You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2012/12/05 09:07:34 UTC
[6/11] ISIS-188: more refactoring of artifacts
http://git-wip-us.apache.org/repos/asf/isis/blob/6de87443/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/authentication/standard/SimpleSession.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/authentication/standard/SimpleSession.java b/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/authentication/standard/SimpleSession.java
deleted file mode 100644
index ca6e8c4..0000000
--- a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/authentication/standard/SimpleSession.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.runtime.authentication.standard;
-
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.List;
-
-import org.apache.isis.core.commons.authentication.AuthenticationSessionAbstract;
-import org.apache.isis.core.commons.encoding.DataInputExtended;
-
-public final class SimpleSession extends AuthenticationSessionAbstract {
-
- private static final long serialVersionUID = 1L;
-
- // ///////////////////////////////////////////////////////////////
- // Constructor, encode
- // ///////////////////////////////////////////////////////////////
-
- /**
- * as per {@link #SimpleSession(String, List)}.
- */
- public SimpleSession(final String name, final String[] roles) {
- this(name, Arrays.asList(roles));
- }
-
- /**
- * Defaults {@link #getValidationCode()} to empty string (<tt>""</tt>).
- */
- public SimpleSession(final String name, final List<String> roles) {
- this(name, roles, "");
- }
-
- public SimpleSession(final String name, final String[] roles, final String code) {
- this(name, Arrays.asList(roles), code);
- }
-
- public SimpleSession(final String name, final List<String> roles, final String code) {
- super(name, roles, code);
- }
-
- public SimpleSession(final DataInputExtended input) throws IOException {
- super(input);
- }
-
- // ///////////////////////////////////////////////////////////////
- // equals, hashCode
- // ///////////////////////////////////////////////////////////////
-
- @Override
- public boolean equals(final Object obj) {
- if (obj == this) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (obj.getClass() != getClass()) {
- return false;
- }
- final SimpleSession other = (SimpleSession) obj;
- return equals(other);
- }
-
- public boolean equals(final SimpleSession other) {
- if (other == this) {
- return true;
- }
- if (other == null) {
- return false;
- }
- return getUserName().equals(other.getUserName());
- }
-
- @Override
- public int hashCode() {
- return getUserName().hashCode();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6de87443/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/authorization/AuthorizationManager.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/authorization/AuthorizationManager.java b/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/authorization/AuthorizationManager.java
deleted file mode 100644
index 67fcc03..0000000
--- a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/authorization/AuthorizationManager.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.runtime.authorization;
-
-import org.apache.isis.applib.Identifier;
-import org.apache.isis.core.commons.authentication.AuthenticationSession;
-import org.apache.isis.core.commons.components.ApplicationScopedComponent;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-
-/**
- * Authorises the user in the current session view and use members of an object.
- */
-public interface AuthorizationManager extends ApplicationScopedComponent {
-
- /**
- * Returns true when the user represented by the specified session is
- * authorised to view the member of the class/object represented by the
- * member identifier. Normally the view of the specified field, or the
- * display of the action will be suppress if this returns false.
- */
- boolean isVisible(AuthenticationSession session, ObjectAdapter target, Identifier identifier);
-
- /**
- * Returns true when the use represented by the specified session is
- * authorised to change the field represented by the member identifier.
- * Normally the specified field will be not appear editable if this returns
- * false.
- */
- boolean isUsable(AuthenticationSession session, ObjectAdapter target, Identifier identifier);
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6de87443/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/authorization/AuthorizationManagerAbstract.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/authorization/AuthorizationManagerAbstract.java b/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/authorization/AuthorizationManagerAbstract.java
deleted file mode 100644
index 0deee45..0000000
--- a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/authorization/AuthorizationManagerAbstract.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.runtime.authorization;
-
-import org.apache.isis.core.commons.config.IsisConfiguration;
-import org.apache.isis.core.metamodel.facetapi.MetaModelRefiner;
-
-public abstract class AuthorizationManagerAbstract implements AuthorizationManager, MetaModelRefiner {
-
- private final IsisConfiguration configuration;
-
- // /////////////////////////////////////////////////////////
- // Constructor
- // /////////////////////////////////////////////////////////
-
- public AuthorizationManagerAbstract(final IsisConfiguration configuration) {
- this.configuration = configuration;
- }
-
- public IsisConfiguration getConfiguration() {
- return configuration;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6de87443/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/authorization/AuthorizationManagerInstaller.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/authorization/AuthorizationManagerInstaller.java b/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/authorization/AuthorizationManagerInstaller.java
deleted file mode 100644
index 6be8bcb..0000000
--- a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/authorization/AuthorizationManagerInstaller.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.runtime.authorization;
-
-import org.apache.isis.core.commons.components.Installer;
-
-public interface AuthorizationManagerInstaller extends Installer {
-
- static String TYPE = "authorization";
-
- AuthorizationManager createAuthorizationManager();
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6de87443/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/authorization/package-info.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/authorization/package-info.java b/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/authorization/package-info.java
deleted file mode 100644
index d41212c..0000000
--- a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/authorization/package-info.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * Authorization API..
- *
- * <p>
- * Used in two different ways:
- * <ul>
- * <li>in prototyping or single user, used by the {@link org.apache.isis.runtimes.dflt.runtime.authorization.standard.AuthorizationFacetFactoryImpl facet factory}
- * implementations, that is, enforcing authorization on the "client-side".
- * </li>
- * <li>In client/server mode, used by a {@link org.apache.isis.core.metamodel.facetdecorator.FacetDecorator} for proxy authorization,
- * that is, enforcing authorization by delegating to the "server-side".</li>
- * </ul>
- */
-package org.apache.isis.core.runtime.authorization;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/isis/blob/6de87443/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/authorization/standard/AuthorizationConstants.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/authorization/standard/AuthorizationConstants.java b/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/authorization/standard/AuthorizationConstants.java
deleted file mode 100644
index a499012..0000000
--- a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/authorization/standard/AuthorizationConstants.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.runtime.authorization.standard;
-
-import org.apache.isis.core.commons.config.ConfigurationConstants;
-
-public final class AuthorizationConstants {
-
- private static final String ROOT = ConfigurationConstants.ROOT + "authorization.";
-
- public static final String LEARN = ROOT + "learn";
- public static final boolean LEARN_DEFAULT = false;
-
- private AuthorizationConstants() {
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6de87443/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/authorization/standard/AuthorizationFacet.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/authorization/standard/AuthorizationFacet.java b/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/authorization/standard/AuthorizationFacet.java
deleted file mode 100644
index ddc5681..0000000
--- a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/authorization/standard/AuthorizationFacet.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.runtime.authorization.standard;
-
-import org.apache.isis.core.metamodel.facetapi.Facet;
-import org.apache.isis.core.metamodel.interactions.DisablingInteractionAdvisor;
-import org.apache.isis.core.metamodel.interactions.HidingInteractionAdvisor;
-
-/**
- * Optionally hide or disable an object, property, collection or action
- * depending on the authorization.
- */
-public interface AuthorizationFacet extends Facet, HidingInteractionAdvisor, DisablingInteractionAdvisor {
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6de87443/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/authorization/standard/AuthorizationFacetAbstract.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/authorization/standard/AuthorizationFacetAbstract.java b/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/authorization/standard/AuthorizationFacetAbstract.java
deleted file mode 100644
index 96fb783..0000000
--- a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/authorization/standard/AuthorizationFacetAbstract.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.runtime.authorization.standard;
-
-import org.apache.isis.applib.events.UsabilityEvent;
-import org.apache.isis.applib.events.VisibilityEvent;
-import org.apache.isis.core.metamodel.facetapi.Facet;
-import org.apache.isis.core.metamodel.facetapi.FacetAbstract;
-import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-import org.apache.isis.core.metamodel.interactions.UsabilityContext;
-import org.apache.isis.core.metamodel.interactions.VisibilityContext;
-import org.apache.isis.core.runtime.authorization.AuthorizationManager;
-
-public abstract class AuthorizationFacetAbstract extends FacetAbstract implements AuthorizationFacet {
-
- public static Class<? extends Facet> type() {
- return AuthorizationFacet.class;
- }
-
- private final AuthorizationManager authorizationManager;
-
- public AuthorizationFacetAbstract(final FacetHolder holder, final AuthorizationManager authorizationManager) {
- super(type(), holder, Derivation.NOT_DERIVED);
- this.authorizationManager = authorizationManager;
- }
-
- @Override
- public String hides(final VisibilityContext<? extends VisibilityEvent> ic) {
- return authorizationManager.isVisible(ic.getSession(), ic.getTarget(), ic.getIdentifier()) ? null : "Not authorized to view";
- }
-
- @Override
- public String disables(final UsabilityContext<? extends UsabilityEvent> ic) {
- return authorizationManager.isUsable(ic.getSession(), ic.getTarget(), ic.getIdentifier()) ? null : "Not authorized to edit";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6de87443/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/authorization/standard/AuthorizationFacetFactory.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/authorization/standard/AuthorizationFacetFactory.java b/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/authorization/standard/AuthorizationFacetFactory.java
deleted file mode 100644
index b628a70..0000000
--- a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/authorization/standard/AuthorizationFacetFactory.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.runtime.authorization.standard;
-
-import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-import org.apache.isis.core.metamodel.facetapi.FacetUtil;
-import org.apache.isis.core.metamodel.facetapi.FeatureType;
-import org.apache.isis.core.metamodel.facets.FacetFactoryAbstract;
-import org.apache.isis.core.runtime.authorization.AuthorizationManager;
-
-public class AuthorizationFacetFactory extends FacetFactoryAbstract {
-
- private final AuthorizationManager authorizationManager;
-
- public AuthorizationFacetFactory(final AuthorizationManager authorizationManager) {
- super(FeatureType.EVERYTHING_BUT_PARAMETERS);
- this.authorizationManager = authorizationManager;
- }
-
- @Override
- public void process(final ProcessClassContext processClassContaxt) {
- FacetUtil.addFacet(createFacet(processClassContaxt.getFacetHolder()));
- }
-
- @Override
- public void process(final ProcessMethodContext processMethodContext) {
- FacetUtil.addFacet(createFacet(processMethodContext.getFacetHolder()));
- }
-
- private AuthorizationFacetImpl createFacet(final FacetHolder holder) {
- final AuthorizationManager authorizationManager = getAuthorizationManager();
- return new AuthorizationFacetImpl(holder, authorizationManager);
- }
-
- // //////////////////////////////////////////////////////////////////
- // Dependencies (from context)
- // //////////////////////////////////////////////////////////////////
-
- private AuthorizationManager getAuthorizationManager() {
- return authorizationManager;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6de87443/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/authorization/standard/AuthorizationFacetImpl.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/authorization/standard/AuthorizationFacetImpl.java b/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/authorization/standard/AuthorizationFacetImpl.java
deleted file mode 100644
index bf6df95..0000000
--- a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/authorization/standard/AuthorizationFacetImpl.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.runtime.authorization.standard;
-
-import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-import org.apache.isis.core.runtime.authorization.AuthorizationManager;
-
-public class AuthorizationFacetImpl extends AuthorizationFacetAbstract {
-
- public AuthorizationFacetImpl(final FacetHolder holder, final AuthorizationManager authorizationManager) {
- super(holder, authorizationManager);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6de87443/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/authorization/standard/AuthorizationManagerStandard.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/authorization/standard/AuthorizationManagerStandard.java b/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/authorization/standard/AuthorizationManagerStandard.java
deleted file mode 100644
index 836c7fa..0000000
--- a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/authorization/standard/AuthorizationManagerStandard.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.runtime.authorization.standard;
-
-import org.apache.isis.applib.Identifier;
-import org.apache.isis.core.commons.authentication.AuthenticationSession;
-import org.apache.isis.core.commons.config.IsisConfiguration;
-import org.apache.isis.core.commons.debug.DebugBuilder;
-import org.apache.isis.core.commons.debug.DebuggableWithTitle;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.progmodel.ProgrammingModel;
-import org.apache.isis.core.metamodel.specloader.validator.MetaModelValidatorComposite;
-import org.apache.isis.core.runtime.authorization.AuthorizationManagerAbstract;
-
-public class AuthorizationManagerStandard extends AuthorizationManagerAbstract implements DebuggableWithTitle {
-
- private Authorizor authorizor;
-
- // /////////////////////////////////////////////////////////
- // Constructor
- // /////////////////////////////////////////////////////////
-
- public AuthorizationManagerStandard(final IsisConfiguration configuration) {
- super(configuration);
- // avoid null pointers
- authorizor = new Authorizor() {
-
- @Override
- public void init() {
- }
-
- @Override
- public void shutdown() {
- }
-
- @Override
- public boolean isVisibleInRole(final String user, final Identifier identifier) {
- return true;
- }
-
- @Override
- public boolean isUsableInRole(final String role, final Identifier identifier) {
- return true;
- }
-
- @Override
- public boolean isVisibleInAnyRole(Identifier identifier) {
- return true;
- }
-
- @Override
- public boolean isUsableInAnyRole(Identifier identifier) {
- return true;
- }
- };
- }
-
- // /////////////////////////////////////////////////////////
- // init, shutddown
- // /////////////////////////////////////////////////////////
-
- @Override
- public void init() {
- authorizor.init();
- }
-
- @Override
- public void shutdown() {
- authorizor.shutdown();
- }
-
- // /////////////////////////////////////////////////////////
- // API
- // /////////////////////////////////////////////////////////
-
- @Override
- public boolean isUsable(final AuthenticationSession session, final ObjectAdapter target, final Identifier identifier) {
- if (isPerspectiveMember(identifier)) {
- return true;
- }
- if (authorizor.isUsableInAnyRole(identifier)) {
- return true;
- }
- for (final String roleName : session.getRoles()) {
- if (authorizor.isUsableInRole(roleName, identifier)) {
- return true;
- }
- }
- return false;
- }
-
- @Override
- public boolean isVisible(final AuthenticationSession session, final ObjectAdapter target, final Identifier identifier) {
- if (isPerspectiveMember(identifier)) {
- return true;
- }
- if (authorizor.isVisibleInAnyRole(identifier)) {
- return true;
- }
- for (final String roleName : session.getRoles()) {
- if (authorizor.isVisibleInRole(roleName, identifier)) {
- return true;
- }
- }
- return false;
- }
-
- private boolean isPerspectiveMember(final Identifier identifier) {
- return (identifier.getClassName().equals(""));
- }
-
-
- // //////////////////////////////////////////////////
- // MetaModelRefiner impl
- // //////////////////////////////////////////////////
-
- @Override
- public void refineMetaModelValidator(MetaModelValidatorComposite baseMetaModelValidator, IsisConfiguration configuration) {
- // no-op
- }
-
- @Override
- public void refineProgrammingModel(ProgrammingModel baseProgrammingModel, IsisConfiguration configuration) {
- final AuthorizationFacetFactory facetFactory = new AuthorizationFacetFactory(this);
- baseProgrammingModel.addFactory(facetFactory);
- }
-
- // //////////////////////////////////////////////////////////
- // Debugging
- // //////////////////////////////////////////////////////////
-
- @Override
- public String debugTitle() {
- return "Authorization Manager";
- }
-
- @Override
- public void debugData(final DebugBuilder debug) {
- debug.appendTitle("Authorizor Manager");
- debug.appendln("Authorizer", authorizor);
- }
-
- // //////////////////////////////////////////////////
- // Dependencies (injected)
- // //////////////////////////////////////////////////
-
- protected void setAuthorizor(final Authorizor authorisor) {
- this.authorizor = authorisor;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6de87443/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/authorization/standard/AuthorizationManagerStandardInstallerAbstract.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/authorization/standard/AuthorizationManagerStandardInstallerAbstract.java b/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/authorization/standard/AuthorizationManagerStandardInstallerAbstract.java
deleted file mode 100644
index 47e90f9..0000000
--- a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/authorization/standard/AuthorizationManagerStandardInstallerAbstract.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.runtime.authorization.standard;
-
-import java.util.List;
-
-import org.apache.isis.core.commons.config.InstallerAbstract;
-import org.apache.isis.core.commons.config.IsisConfiguration;
-import org.apache.isis.core.runtime.authorization.AuthorizationManager;
-import org.apache.isis.core.runtime.authorization.AuthorizationManagerInstaller;
-
-public abstract class AuthorizationManagerStandardInstallerAbstract extends InstallerAbstract implements AuthorizationManagerInstaller {
-
- public AuthorizationManagerStandardInstallerAbstract(final String name) {
- super(AuthorizationManagerInstaller.TYPE, name);
- }
-
- @Override
- public AuthorizationManager createAuthorizationManager() {
- final AuthorizationManagerStandard authorizationManager = new AuthorizationManagerStandard(getConfiguration());
- final Authorizor authorizor = createAuthorizor(getConfiguration());
- authorizationManager.setAuthorizor(authorizor);
- return authorizationManager;
- }
-
- /**
- * Hook method
- *
- * @return
- */
- protected abstract Authorizor createAuthorizor(final IsisConfiguration configuration);
-
- @Override
- public List<Class<?>> getTypes() {
- return listOf(AuthorizationManager.class);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6de87443/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/authorization/standard/Authorizor.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/authorization/standard/Authorizor.java b/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/authorization/standard/Authorizor.java
deleted file mode 100644
index a9d34a8..0000000
--- a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/authorization/standard/Authorizor.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.runtime.authorization.standard;
-
-import org.apache.isis.applib.Identifier;
-import org.apache.isis.core.commons.components.ApplicationScopedComponent;
-
-public interface Authorizor extends ApplicationScopedComponent {
-
- public boolean isVisibleInAnyRole(final Identifier identifier);
- public boolean isUsableInAnyRole(final Identifier identifier);
-
- /**
- * Checked for each of the user's roles.
- */
- public boolean isVisibleInRole(final String role, final Identifier identifier);
-
- /**
- * Checked for each of the user's roles.
- */
- public boolean isUsableInRole(final String role, final Identifier identifier);
-
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6de87443/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/authorization/standard/AuthorizorAbstract.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/authorization/standard/AuthorizorAbstract.java b/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/authorization/standard/AuthorizorAbstract.java
deleted file mode 100644
index bd81027..0000000
--- a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/authorization/standard/AuthorizorAbstract.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.runtime.authorization.standard;
-
-import org.apache.isis.applib.Identifier;
-import org.apache.isis.core.commons.config.IsisConfiguration;
-
-public abstract class AuthorizorAbstract implements Authorizor {
-
- private final IsisConfiguration configuration;
-
- public AuthorizorAbstract(final IsisConfiguration configuration) {
- this.configuration = configuration;
- }
-
- public IsisConfiguration getConfiguration() {
- return configuration;
- }
-
- @Override
- public boolean isVisibleInAnyRole(Identifier identifier) {
- return false;
- }
-
- @Override
- public boolean isUsableInAnyRole(Identifier identifier) {
- return false;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6de87443/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/imageloader/TemplateImage.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/imageloader/TemplateImage.java b/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/imageloader/TemplateImage.java
deleted file mode 100644
index 73b1bac..0000000
--- a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/imageloader/TemplateImage.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.runtime.imageloader;
-
-import java.awt.Image;
-
-/**
- * A template image is an image that is used to create other images from.
- *
- * <p>
- * Typically this will be a larger image that can be scaled down in size.
- */
-public interface TemplateImage {
- Image getImage();
-
- Image getIcon(final int height);
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6de87443/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/imageloader/TemplateImageImpl.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/imageloader/TemplateImageImpl.java b/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/imageloader/TemplateImageImpl.java
deleted file mode 100644
index 88d30d6..0000000
--- a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/imageloader/TemplateImageImpl.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.runtime.imageloader;
-
-import java.awt.Canvas;
-import java.awt.Image;
-import java.awt.MediaTracker;
-
-import org.apache.log4j.Logger;
-
-/**
- * Many icons are based on the same image, but in different sizes and possibly
- * different colours. The ImageTemplate class loads and holds them image, and
- * can provide it clients with the full sized images or scaled images.
- */
-public class TemplateImageImpl implements TemplateImage {
- private final static Logger LOG = Logger.getLogger(TemplateImageImpl.class);
-
- /**
- * Factory method.
- */
- public static TemplateImageImpl create(final java.awt.Image image) {
- if (image == null) {
- return null;
- }
- return new TemplateImageImpl(image);
-
- }
-
- private final Image image;
- private final MediaTracker mt = new MediaTracker(new Canvas());
-
- private TemplateImageImpl(final Image image) {
- if (image == null) {
- throw new NullPointerException();
- }
- this.image = image;
- }
-
- @Override
- public Image getImage() {
- return image;
- }
-
- @Override
- public Image getIcon(final int height) {
- Image iconImage;
-
- if (height == image.getHeight(null)) {
- return image;
- }
-
- iconImage = image.getScaledInstance(-1, height, java.awt.Image.SCALE_SMOOTH);
-
- if (iconImage != null) {
- mt.addImage(iconImage, 0);
-
- try {
- mt.waitForAll();
- } catch (final Exception e) {
- // TODO: tidy up this horrid code.
- e.printStackTrace();
- }
-
- if (mt.isErrorAny()) {
- LOG.error("failed to create scaled image: " + iconImage + " " + mt.getErrorsAny()[0]);
- mt.removeImage(iconImage);
- iconImage = null;
- } else {
- mt.removeImage(iconImage);
- if (LOG.isDebugEnabled()) {
- LOG.debug("image " + iconImage + " scaled to " + height);
- }
- }
- }
-
- if (iconImage == null) {
- throw new RuntimeException("no icon image!");
- } else {
- if (iconImage.getWidth(null) == -1) {
- throw new RuntimeException("scaled image! " + iconImage.toString());
- }
- }
-
- return iconImage;
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6de87443/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/imageloader/TemplateImageLoader.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/imageloader/TemplateImageLoader.java b/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/imageloader/TemplateImageLoader.java
deleted file mode 100644
index 85d6ea8..0000000
--- a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/imageloader/TemplateImageLoader.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.runtime.imageloader;
-
-import org.apache.isis.core.commons.components.ApplicationScopedComponent;
-
-/**
- * This interface defines how template images are found by name.
- */
-public interface TemplateImageLoader extends ApplicationScopedComponent {
-
- TemplateImage getTemplateImage(final String name);
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6de87443/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/imageloader/TemplateImageLoaderInstaller.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/imageloader/TemplateImageLoaderInstaller.java b/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/imageloader/TemplateImageLoaderInstaller.java
deleted file mode 100644
index 30f9a4a..0000000
--- a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/imageloader/TemplateImageLoaderInstaller.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.runtime.imageloader;
-
-import org.apache.isis.core.commons.components.Installer;
-
-public interface TemplateImageLoaderInstaller extends Installer {
-
- static String TYPE = "template-image-loader";
-
- TemplateImageLoader createLoader();
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6de87443/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/imageloader/TemplateImageLoaderProvider.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/imageloader/TemplateImageLoaderProvider.java b/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/imageloader/TemplateImageLoaderProvider.java
deleted file mode 100644
index ce71317..0000000
--- a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/imageloader/TemplateImageLoaderProvider.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.runtime.imageloader;
-
-
-public interface TemplateImageLoaderProvider {
-
- TemplateImageLoader getTemplateImageLoader();
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6de87443/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/imageloader/awt/ImageConstants.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/imageloader/awt/ImageConstants.java b/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/imageloader/awt/ImageConstants.java
deleted file mode 100644
index c1b380b..0000000
--- a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/imageloader/awt/ImageConstants.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.runtime.imageloader.awt;
-
-import org.apache.isis.core.commons.config.ConfigurationConstants;
-
-public class ImageConstants {
-
- public static final String PROPERTY_BASE = ConfigurationConstants.ROOT + "images.";
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6de87443/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/imageloader/awt/TemplateImageLoaderAwt.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/imageloader/awt/TemplateImageLoaderAwt.java b/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/imageloader/awt/TemplateImageLoaderAwt.java
deleted file mode 100644
index 3ca5a0b..0000000
--- a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/imageloader/awt/TemplateImageLoaderAwt.java
+++ /dev/null
@@ -1,326 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.runtime.imageloader.awt;
-
-import static org.apache.isis.core.commons.ensure.Ensure.ensureThatState;
-import static org.hamcrest.CoreMatchers.is;
-
-import java.awt.Canvas;
-import java.awt.Image;
-import java.awt.MediaTracker;
-import java.awt.Toolkit;
-import java.awt.image.IndexColorModel;
-import java.awt.image.MemoryImageSource;
-import java.io.File;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Vector;
-
-import org.apache.log4j.Logger;
-
-import org.apache.isis.core.commons.config.IsisConfiguration;
-import org.apache.isis.core.commons.lang.Resources;
-import org.apache.isis.core.runtime.imageloader.TemplateImage;
-import org.apache.isis.core.runtime.imageloader.TemplateImageImpl;
-import org.apache.isis.core.runtime.imageloader.TemplateImageLoader;
-
-/**
- * This class loads up file based images as resources (part of the classpath) or
- * from the file system. Images of type PNG, GIF and JPEG will be used. The
- * default directory is images.
- */
-public class TemplateImageLoaderAwt implements TemplateImageLoader {
-
- private final static Logger LOG = Logger.getLogger(TemplateImageLoaderAwt.class);
-
- private static final String LOAD_IMAGES_FROM_FILES_KEY = ImageConstants.PROPERTY_BASE + "load-images-from-files";
- private static final String[] EXTENSIONS = { "png", "gif", "jpg", "jpeg", "svg" };
- private final static String IMAGE_DIRECTORY = "images";
- private final static String IMAGE_DIRECTORY_PARAM = ImageConstants.PROPERTY_BASE + "image-directory";
- private static final String SEPARATOR = "/";
-
- private boolean initialized;
-
- private boolean alsoLoadAsFiles;
- protected final MediaTracker mt = new MediaTracker(new Canvas());
-
- /**
- * A keyed list of core images, one for each name, keyed by the image path.
- */
- private final Hashtable<String, TemplateImage> loadedImages = new Hashtable<String, TemplateImage>();
- private final Vector<String> missingImages = new Vector<String>();
- private final IsisConfiguration configuration;
- private String directory;
-
- // ////////////////////////////////////////////////////////////
- // constructor
- // ////////////////////////////////////////////////////////////
-
- public TemplateImageLoaderAwt(final IsisConfiguration configuration) {
- this.configuration = configuration;
- }
-
- // ////////////////////////////////////////////////////////////
- // init, shutdown
- // ////////////////////////////////////////////////////////////
-
- @Override
- public void init() {
- ensureNotInitialized();
- LOG.info("images to be loaded from " + directory());
- alsoLoadAsFiles = getConfiguration().getBoolean(LOAD_IMAGES_FROM_FILES_KEY, true);
- initialized = true;
- }
-
- @Override
- public void shutdown() {
- }
-
- private void ensureNotInitialized() {
- ensureThatState(initialized, is(false));
- }
-
- private void ensureInitialized() {
- ensureThatState(initialized, is(true));
- }
-
- // ////////////////////////////////////////////////////////////
- // getTemplateImage
- // ////////////////////////////////////////////////////////////
-
- /**
- * Returns an image template for the specified image (as specified by a path
- * to a file or resource).
- *
- * <p>
- * If the path has no extension (<tt>.gif</tt>, <tt>.png</tt> etc) then all
- * valid {@link #EXTENSIONS extensions} are searched for.
- *
- * <p>
- * This method attempts to load the image from the jar/zip file this class
- * was loaded from ie, your application, and then from the file system as a
- * file if can't be found as a resource. If neither method works the default
- * image is returned.
- *
- * @return returns a {@link TemplateImage} for the specified image file, or
- * null if none found.
- */
- @Override
- public TemplateImage getTemplateImage(final String name) {
- ensureInitialized();
-
- if (loadedImages.containsKey(name)) {
- return loadedImages.get(name);
- }
-
- if (missingImages.contains(name)) {
- return null;
- }
-
- final List<String> candidates = getCandidates(name);
- for (final String candidate : candidates) {
- final Image image = load(candidate);
- final TemplateImageImpl templateImage = TemplateImageImpl.create(image);
- if (templateImage != null) {
- loadedImages.put(name, templateImage);
- return templateImage;
- }
- }
-
- if (LOG.isDebugEnabled()) {
- LOG.debug("failed to find image for " + name);
- }
- missingImages.addElement(name);
- return null;
- }
-
- // ////////////////////////////////////////////////////////////
- // helpers: parsing path
- // ////////////////////////////////////////////////////////////
-
- private List<String> getCandidates(final String name) {
- boolean hasExtension = false;
- for (final String extension : EXTENSIONS) {
- hasExtension = hasExtension || name.endsWith(extension);
- }
-
- final List<String> candidates = new ArrayList<String>();
- if (hasExtension) {
- candidates.add(name);
- } else {
- for (final String extension : EXTENSIONS) {
- candidates.add(name + "." + extension);
- }
- }
- return candidates;
- }
-
- // ////////////////////////////////////////////////////////////
- // helpers: loading
- // ////////////////////////////////////////////////////////////
-
- private Image load(final String name) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("searching for image " + name);
- }
-
- Image image = loadAsResource(name);
- if (image != null) {
- return image;
- }
-
- final String path = directory() + name;
- image = loadAsResource(path);
- if (image != null) {
- return image;
- }
-
- if (alsoLoadAsFiles) {
- image = loadAsFile(path);
- if (image != null) {
- return image;
- }
- }
-
- return null;
- }
-
- /**
- * Get an Image object from the jar/zip file that this class was loaded
- * from.
- */
- protected Image loadAsResource(final String path) {
- final URL url = Resources.getResourceURL(path);
- if (url == null) {
- LOG.debug("not found image in resources: " + path);
- return null;
- }
-
- Image image = Toolkit.getDefaultToolkit().getImage(url);
- if (image != null) {
- mt.addImage(image, 0);
- try {
- mt.waitForAll();
- } catch (final Exception e) {
- e.printStackTrace();
- }
-
- if (mt.isErrorAny()) {
- LOG.error("found image but failed to load it from resources: " + url + " " + mt.getErrorsAny()[0]);
- mt.removeImage(image);
- image = null;
- } else {
- mt.removeImage(image);
- LOG.info("image loaded from resources: " + url);
- }
- }
-
- if (image == null) {
- throw new RuntimeException("null image");
- } else {
- if (image.getWidth(null) == -1) {
- throw new RuntimeException(image.toString());
- }
- }
-
- return image;
- }
-
- /**
- * Get an {@link Image} object from the specified file path on the file
- * system.
- */
- private Image loadAsFile(final String path) {
- final File file = new File(path);
-
- if (!file.exists()) {
- return null;
- }
- final Toolkit t = Toolkit.getDefaultToolkit();
- Image image = t.getImage(file.getAbsolutePath());
-
- if (image != null) {
- mt.addImage(image, 0);
-
- try {
- mt.waitForAll();
- } catch (final Exception e) {
- e.printStackTrace();
- }
-
- if (mt.isErrorAny()) {
- LOG.error("found image file but failed to load it: " + file.getAbsolutePath());
- mt.removeImage(image);
- image = null;
- } else {
- mt.removeImage(image);
- LOG.info("image loaded from file: " + file);
- }
- }
- return image;
- }
-
- private String directory() {
- if (directory == null) {
- directory = getConfiguration().getString(IMAGE_DIRECTORY_PARAM, IMAGE_DIRECTORY);
- if (!directory.endsWith(SEPARATOR)) {
- directory = directory.concat(SEPARATOR);
- }
- }
- return directory;
- }
-
- // ////////////////////////////////////////////////////////////
- // unused
- // ////////////////////////////////////////////////////////////
-
- /**
- * This code was commented out. I've reinstated it, even though it is
- * unused, because it looks interesting and perhaps useful.
- */
- @SuppressWarnings("unused")
- private Image createImage() {
- final byte[] pixels = new byte[128 * 128];
- for (int i = 0; i < pixels.length; i++) {
- pixels[i] = (byte) (i % 128);
- }
-
- final byte[] r = new byte[] { 0, 127 };
- final byte[] g = new byte[] { 0, 127 };
- final byte[] b = new byte[] { 0, 127 };
- final IndexColorModel colorModel = new IndexColorModel(1, 2, r, g, b);
-
- final MemoryImageSource producer = new MemoryImageSource(128, 128, colorModel, pixels, 0, 128);
- final Image image = Toolkit.getDefaultToolkit().createImage(producer);
-
- return image;
- }
-
- // ////////////////////////////////////////////////////////////
- // dependencies (from singleton)
- // ////////////////////////////////////////////////////////////
-
- private IsisConfiguration getConfiguration() {
- return configuration;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6de87443/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/imageloader/awt/TemplateImageLoaderAwtInstaller.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/imageloader/awt/TemplateImageLoaderAwtInstaller.java b/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/imageloader/awt/TemplateImageLoaderAwtInstaller.java
deleted file mode 100644
index 4c933c0..0000000
--- a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/imageloader/awt/TemplateImageLoaderAwtInstaller.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.runtime.imageloader.awt;
-
-import java.util.List;
-
-import org.apache.isis.core.commons.config.InstallerAbstract;
-import org.apache.isis.core.runtime.imageloader.TemplateImageLoader;
-import org.apache.isis.core.runtime.imageloader.TemplateImageLoaderInstaller;
-
-public class TemplateImageLoaderAwtInstaller extends InstallerAbstract implements TemplateImageLoaderInstaller {
-
- public TemplateImageLoaderAwtInstaller() {
- super(TemplateImageLoaderInstaller.TYPE, "awt");
- }
-
- @Override
- public TemplateImageLoader createLoader() {
- return new TemplateImageLoaderAwt(getConfiguration());
- }
-
- @Override
- public List<Class<?>> getTypes() {
- return listOf(TemplateImageLoader.class);
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6de87443/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/imageloader/package-info.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/imageloader/package-info.java b/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/imageloader/package-info.java
deleted file mode 100644
index f01720b..0000000
--- a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/imageloader/package-info.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * Image Loading API.
- *
- * <p>
- * Not generally intended to be implemented; the default implementation should normally suffice.
- */
-package org.apache.isis.core.runtime.imageloader;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/isis/blob/6de87443/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/logging/FileSnapshotAppender.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/logging/FileSnapshotAppender.java b/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/logging/FileSnapshotAppender.java
deleted file mode 100644
index 0da6b3d..0000000
--- a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/logging/FileSnapshotAppender.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.runtime.logging;
-
-import java.io.FileNotFoundException;
-import java.io.IOException;
-
-import org.apache.log4j.Logger;
-import org.apache.log4j.spi.TriggeringEventEvaluator;
-
-public class FileSnapshotAppender extends SnapshotAppender {
- private static final Logger LOG = Logger.getLogger(FileSnapshotAppender.class);
- private String directoryPath;
- private String extension;
- private String fileName = "log-snapshot-";
-
- public FileSnapshotAppender(final TriggeringEventEvaluator evaluator) {
- super(evaluator);
- }
-
- public FileSnapshotAppender() {
- super();
- }
-
- public synchronized String getDirectory() {
- return directoryPath;
- }
-
- public synchronized String getExtension() {
- return extension;
- }
-
- public synchronized String getFileName() {
- return fileName;
- }
-
- public synchronized void setDirectory(final String directoryPath) {
- this.directoryPath = directoryPath;
- }
-
- public synchronized void setExtension(final String extension) {
- this.extension = extension;
- }
-
- public synchronized void setFileName(final String fileName) {
- this.fileName = fileName;
- }
-
- @Override
- protected synchronized void writeSnapshot(final String message, final String details) {
- SnapshotWriter s;
- try {
- final String contentType = layout.getContentType();
- final String fileExtension = isEmpty(extension) ? contentType.substring(contentType.indexOf('/') + 1) : extension;
- s = new SnapshotWriter(directoryPath, fileName, fileExtension, message);
- s.appendLog(details);
- s.close();
- } catch (final FileNotFoundException e) {
- LOG.error("failed to open log file", e);
- } catch (final IOException e) {
- LOG.error("failed to write log file", e);
- }
- }
-
- private boolean isEmpty(final String extension2) {
- return extension2 == null || extension2.length() == 0;
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6de87443/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/logging/IsisLoggingConfigurer.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/logging/IsisLoggingConfigurer.java b/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/logging/IsisLoggingConfigurer.java
deleted file mode 100644
index efee605..0000000
--- a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/logging/IsisLoggingConfigurer.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.runtime.logging;
-
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Properties;
-
-import org.apache.log4j.Appender;
-import org.apache.log4j.BasicConfigurator;
-import org.apache.log4j.ConsoleAppender;
-import org.apache.log4j.Layout;
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
-import org.apache.log4j.PatternLayout;
-import org.apache.log4j.PropertyConfigurator;
-
-import org.apache.isis.core.commons.lang.IoUtils;
-
-public class IsisLoggingConfigurer {
-
- private boolean loggingSetup;
-
- /**
- * As per {@link #configureLogging(String)}.
- *
- * <p>
- * The root logging level can also be adjusted using command line arguments.
- */
- public void configureLogging(final String configDirectory, final String[] args) {
- if (loggingSetup) {
- return;
- }
- loggingSetup = true;
- configureLogging(configDirectory);
- applyLoggingLevelFromCommandLine(args);
- }
-
- private static void applyLoggingLevelFromCommandLine(final String[] args) {
- final Level loggingLevel = loggingLevel(args);
- if (loggingLevel != null) {
- Logger.getRootLogger().setLevel(loggingLevel);
- }
- }
-
- /**
- * Sets up logging using either a logging file or (if cannot be found) some
- * sensible defaults.
- *
- * <p>
- * If a {@link LoggingConstants#LOGGING_CONFIG_FILE logging config file} can
- * be located in the provided directory, then that is used. Otherwise, will
- * set up the {@link Logger#getRootLogger() root logger} to
- * {@link Level#WARN warning}, a typical {@link PatternLayout} and logging
- * to the {@link ConsoleAppender console}.
- */
- private static void configureLogging(final String configDirectory) {
- final Properties properties = new Properties();
- final String path = configDirectory + "/" + LoggingConstants.LOGGING_CONFIG_FILE;
- FileInputStream inStream = null;
- try {
- inStream = new FileInputStream(path);
- properties.load(inStream);
- } catch (final IOException ignore) {
- // ignore
- } finally {
- IoUtils.closeSafely(inStream);
- }
-
- if (properties.size() == 0) {
- InputStream inStream2 = null;
- try {
- final ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
- inStream2 = classLoader.getResourceAsStream(path);
- if (inStream2 != null) {
- properties.load(inStream2);
- }
- } catch (final IOException ignore) {
- } finally {
- IoUtils.closeSafely(inStream2);
- }
- }
-
- if (properties.size() > 0) {
- PropertyConfigurator.configure(properties);
- } else {
- configureFallbackLogging();
- }
- }
-
- private static void configureFallbackLogging() {
- final Layout layout = new PatternLayout("%-5r [%-25.25c{1} %-10.10t %-5.5p] %m%n");
- final Appender appender = new ConsoleAppender(layout);
- BasicConfigurator.configure(appender);
- Logger.getRootLogger().setLevel(Level.WARN);
- Logger.getLogger("ui").setLevel(Level.OFF);
- }
-
- private static Level loggingLevel(final String[] args) {
- Level level = null;
- for (final String arg : args) {
- if (arg.equals("-" + LoggingConstants.DEBUG_OPT)) {
- level = Level.DEBUG;
- break;
- } else if (arg.equals("-" + LoggingConstants.QUIET_OPT)) {
- level = Level.ERROR;
- break;
- } else if (arg.equals("-" + LoggingConstants.VERBOSE_OPT)) {
- level = Level.INFO;
- break;
- }
- }
- return level;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6de87443/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/logging/Logger.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/logging/Logger.java b/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/logging/Logger.java
deleted file mode 100644
index a4c9236..0000000
--- a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/logging/Logger.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.runtime.logging;
-
-import org.apache.log4j.Level;
-
-import org.apache.isis.core.commons.config.ConfigurationConstants;
-
-public abstract class Logger {
- public static final String PROPERTY_ROOT = ConfigurationConstants.ROOT + "logging.";
- private org.apache.log4j.Logger logger;
- private final Level level;
-
- public Logger() {
- this(Level.DEBUG);
- }
-
- public Logger(final String level) {
- this.level = Level.toLevel(level);
- }
-
- public Logger(final Level level) {
- this.level = level;
- }
-
- protected abstract Class<?> getDecoratedClass();
-
- public void log(final String message) {
- logger().log(level, message);
- }
-
- public void log(final String request, final Object result) {
- log(request + " -> " + result);
- }
-
- private org.apache.log4j.Logger logger() {
- if (logger == null) {
- logger = org.apache.log4j.Logger.getLogger(getDecoratedClass());
- }
- return logger;
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6de87443/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/logging/LoggingConstants.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/logging/LoggingConstants.java b/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/logging/LoggingConstants.java
deleted file mode 100644
index 06f2073..0000000
--- a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/logging/LoggingConstants.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.runtime.logging;
-
-public final class LoggingConstants {
-
- public static final String LOGGING_CONFIG_FILE = "logging.properties";
-
- public static final String DEBUG_OPT = "debug";
- public static final String VERBOSE_OPT = "verbose";
- public static final String QUIET_OPT = "quiet";
-
- private LoggingConstants() {
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6de87443/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/logging/PopupSnapshotAppender.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/logging/PopupSnapshotAppender.java b/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/logging/PopupSnapshotAppender.java
deleted file mode 100644
index 9c98316..0000000
--- a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/logging/PopupSnapshotAppender.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.runtime.logging;
-
-import java.awt.BorderLayout;
-import java.awt.Button;
-import java.awt.Color;
-import java.awt.FlowLayout;
-import java.awt.Font;
-import java.awt.Frame;
-import java.awt.Panel;
-import java.awt.TextArea;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-
-import org.apache.log4j.spi.TriggeringEventEvaluator;
-
-public class PopupSnapshotAppender extends SnapshotAppender {
-
- public PopupSnapshotAppender(final TriggeringEventEvaluator evaluator) {
- super(evaluator);
- }
-
- public PopupSnapshotAppender() {
- super();
- }
-
- @Override
- protected void writeSnapshot(final String message, final String details) {
- final SubmitDialog dialog = new SubmitDialog("Error logged");
- dialog.show(message, details);
- }
-}
-
-class SubmitDialog extends Frame {
- private static final long serialVersionUID = 1L;
-
- public SubmitDialog(final String title) {
- super(title);
- setLayout(new BorderLayout());
- setBounds(0, 200, 800, 400);
- }
-
- public void show(final String message, final String text) {
- final TextArea messagePanel = new TextArea();
- messagePanel.setText(message + "\n\n" + text);
- messagePanel.setForeground(Color.black);
- messagePanel.setEditable(false);
- messagePanel.setFont(new Font("Dialog", Font.PLAIN, 9));
-
- add(messagePanel, BorderLayout.CENTER);
-
- final Panel buttonPanel = new Panel();
- buttonPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 20, 0));
- add(buttonPanel, BorderLayout.SOUTH);
-
- final Button ok = new Button("Close");
- ok.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(final ActionEvent e) {
- ok(true);
- }
- });
- buttonPanel.add(ok);
-
- /*
- * Button cancel = new Button("Save and Close"); cancel
- * .addActionListener(new ActionListener() { public void
- * actionPerformed(final ActionEvent e) { ok(false); } });
- * buttonPanel.add(cancel);
- */
- addWindowListener(new WindowAdapter() {
- @Override
- public void windowClosing(final WindowEvent e) {
- ok(false);
- }
- });
-
- setVisible(true);
- }
-
- protected synchronized void ok(final boolean b) {
- dispose();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6de87443/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/logging/SmtpExtendedAppender.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/logging/SmtpExtendedAppender.java b/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/logging/SmtpExtendedAppender.java
deleted file mode 100644
index 3978b95..0000000
--- a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/logging/SmtpExtendedAppender.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.isis.core.runtime.logging;
-
-import java.io.UnsupportedEncodingException;
-
-import javax.mail.MessagingException;
-import javax.mail.internet.MimeUtility;
-
-import org.apache.log4j.net.SMTPAppender;
-import org.apache.log4j.spi.LoggingEvent;
-import org.apache.log4j.spi.TriggeringEventEvaluator;
-
-public class SmtpExtendedAppender extends SMTPAppender {
-
- public SmtpExtendedAppender() {
- super();
- }
-
- public SmtpExtendedAppender(final TriggeringEventEvaluator evaluator) {
- super(evaluator);
- }
-
- @Override
- public void append(final LoggingEvent event) {
- if (evaluator.isTriggeringEvent(event)) {
- try {
- final String subject = limitToFirstLine(String.valueOf(event.getMessage()));
- final String encodedSubject = MimeUtility.encodeText(subject, "UTF-8", null);
- msg.setSubject(encodedSubject);
- } catch (final UnsupportedEncodingException e) {
- // ???
- } catch (final MessagingException e) {
- // ???
- }
- }
- super.append(event);
- }
-
- private String limitToFirstLine(String subject) {
- final int newline = subject.indexOf('\n');
- final int carriageReturn = subject.indexOf('\r');
- if (newline != -1 || carriageReturn != -1) {
- final int pos = Math.max(newline, carriageReturn);
- subject = subject.substring(0, pos);
- }
- return subject;
- }
-
-}