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 2015/03/30 17:43:43 UTC
[14/59] [abbrv] isis git commit: ISIS-720: mothballing scimpi
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/logon/Logon.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/logon/Logon.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/logon/Logon.java
deleted file mode 100644
index facd79d..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/logon/Logon.java
+++ /dev/null
@@ -1,126 +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.viewer.scimpi.dispatcher.view.logon;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.isis.core.commons.authentication.AnonymousSession;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext;
-import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext.Scope;
-import org.apache.isis.viewer.scimpi.dispatcher.edit.FieldEditState;
-import org.apache.isis.viewer.scimpi.dispatcher.edit.FormState;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
-import org.apache.isis.viewer.scimpi.dispatcher.view.form.HiddenInputField;
-import org.apache.isis.viewer.scimpi.dispatcher.view.form.HtmlFormBuilder;
-import org.apache.isis.viewer.scimpi.dispatcher.view.form.InputField;
-
-public class Logon extends AbstractElementProcessor {
-
- @Override
- public void process(final Request request) {
- String view = request.getOptionalProperty(VIEW);
- RequestContext context = request.getContext();
- if (view == null) {
- view = (String) context.getVariable("login-path");
- }
-
- final boolean isNotLoggedIn = IsisContext.getSession().getAuthenticationSession() instanceof AnonymousSession;
- if (isNotLoggedIn) {
- loginForm(request, view);
- }
- }
-
- public static void loginForm(final Request request, final String view) {
- final String object = request.getOptionalProperty(OBJECT);
- final String method = request.getOptionalProperty(METHOD, "logon");
- final String result = request.getOptionalProperty(RESULT_NAME, "_user");
- final String resultScope = request.getOptionalProperty(SCOPE, Scope.SESSION.name());
- final String role = request.getOptionalProperty("field", "roles");
-// final String isisUser = request.getOptionalProperty("isis-user", "_web_default");
- final String formId = request.getOptionalProperty(FORM_ID, request.nextFormId());
- final String labelDelimiter = request.getOptionalProperty(LABEL_DELIMITER, ":");
-
- // TODO error if all values are not set (not if use type is not set and all others are still defaults);
-
- if (object != null) {
- RequestContext context = request.getContext();
- context.addVariable(LOGON_OBJECT, object, Scope.SESSION);
- context.addVariable(LOGON_METHOD, method, Scope.SESSION);
- context.addVariable(LOGON_RESULT_NAME, result, Scope.SESSION);
- context.addVariable(LOGON_SCOPE, resultScope, Scope.SESSION);
- context.addVariable(PREFIX + "roles-field", role, Scope.SESSION);
-// context.addVariable(PREFIX + "isis-user", isisUser, Scope.SESSION);
- context.addVariable(LOGON_FORM_ID, formId, Scope.SESSION);
- }
-
- final String error = request.getOptionalProperty(ERROR, request.getContext().getRequestedFile());
- final List<HiddenInputField> hiddenFields = new ArrayList<HiddenInputField>();
- hiddenFields.add(new HiddenInputField(ERROR, error));
- if (view != null) {
- hiddenFields.add(new HiddenInputField(VIEW, view));
- }
- hiddenFields.add(new HiddenInputField("_" + FORM_ID, formId));
-
- final FormState entryState = (FormState) request.getContext().getVariable(ENTRY_FIELDS);
- boolean isforThisForm = entryState != null && entryState.isForForm(formId);
- if (entryState != null && entryState.isForForm(formId)) {
- }
- final InputField nameField = createdField("username", "User Name", InputField.TEXT, isforThisForm ? entryState : null);
- final String width = request.getOptionalProperty("width");
- if (width != null) {
- final int w = Integer.valueOf(width).intValue();
- nameField.setWidth(w);
- }
- final InputField passwordField = createdField("password", "Password", InputField.PASSWORD, isforThisForm ? entryState : null);
- final InputField[] fields = new InputField[] { nameField, passwordField, };
-
- final String formTitle = request.getOptionalProperty(FORM_TITLE);
- final String loginButtonTitle = request.getOptionalProperty(BUTTON_TITLE, "Log in");
- final String className = request.getOptionalProperty(CLASS, "login");
- final String id = request.getOptionalProperty(ID, "logon");
-
- HtmlFormBuilder.createForm(request, "logon.app", hiddenFields.toArray(new HiddenInputField[hiddenFields.size()]), fields,
- className, id, formTitle, labelDelimiter, null, null, loginButtonTitle,
- isforThisForm && entryState != null ? entryState.getError() : null , null);
- }
-
- protected static InputField createdField(final String fieldName, final String fieldLabel, final int type, final FormState entryState) {
- final InputField nameField = new InputField(fieldName);
- nameField.setType(type);
- nameField.setLabel(fieldLabel);
- if (entryState != null) {
- final FieldEditState fieldState = entryState.getField(fieldName);
- final String entry = fieldState == null ? "" : fieldState.getEntry();
- nameField.setValue(entry);
- final String error = fieldState == null ? "" : fieldState.getError();
- nameField.setErrorText(error);
- }
- return nameField;
- }
-
- @Override
- public String getName() {
- return "logon";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/logon/RestrictAccess.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/logon/RestrictAccess.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/logon/RestrictAccess.java
deleted file mode 100644
index 83f2597..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/logon/RestrictAccess.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.viewer.scimpi.dispatcher.view.logon;
-
-import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.Dispatcher;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
-
-public class RestrictAccess extends AbstractElementProcessor {
- private static final String LOGIN_VIEW = "login-view";
- private static final String DEFAULT_LOGIN_VIEW = "login." + Dispatcher.EXTENSION;
-
- public String getName() {
- return "restrict-access";
- }
-
- public void process(Request request) {
- if (!request.getContext().isUserAuthenticated()) {
- final String view = request.getOptionalProperty(LOGIN_VIEW, DEFAULT_LOGIN_VIEW);
- request.getContext().redirectTo(view);
- }
- }
-
-}
-
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/logon/Secure.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/logon/Secure.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/logon/Secure.java
deleted file mode 100644
index 17cd472..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/logon/Secure.java
+++ /dev/null
@@ -1,45 +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.viewer.scimpi.dispatcher.view.logon;
-
-import org.apache.isis.core.commons.authentication.AnonymousSession;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
-
-public class Secure extends AbstractElementProcessor {
- private static final String LOGIN_VIEW = "login-view";
-
- @Override
- public void process(final Request request) {
- final boolean isLoggedIn = !(IsisContext.getSession().getAuthenticationSession() instanceof AnonymousSession);
- if (!isLoggedIn) {
- IsisContext.getMessageBroker().addWarning("You are not currently logged in! Please log in so you can continue.");
- final String view = request.getOptionalProperty(LOGIN_VIEW, "/login.shtml");
- request.getContext().redirectTo(view);
- }
- }
-
- @Override
- public String getName() {
- return "secure";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/logon/User.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/logon/User.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/logon/User.java
deleted file mode 100644
index 4254746..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/logon/User.java
+++ /dev/null
@@ -1,77 +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.viewer.scimpi.dispatcher.view.logon;
-
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.Dispatcher;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
-
-public class User extends AbstractElementProcessor {
- private static final String LOGIN_VIEW = "login-view";
- private static final String DEFAULT_LOGIN_VIEW = "login." + Dispatcher.EXTENSION;
- private static final String LOGOUT_VIEW = "logout-view";
- private static final String DEFAULT_LOGOUT_VIEW = "logout." + Dispatcher.EXTENSION;
-
- @Override
- public void process(final Request request) {
- final boolean isAuthenticatedn = request.getContext().isUserAuthenticated();
- request.appendHtml("<div class=\"user\">");
- if (isAuthenticatedn) {
- displayUserAndLogoutLink(request);
- } else {
- displayLoginForm(request);
- }
- request.appendHtml("</div>");
- }
-
- public void displayLoginForm(final Request request) {
- String loginView = request.getOptionalProperty(LOGIN_VIEW);
- if (loginView == null) {
- Logon.loginForm(request, ".");
- } else {
- if (loginView.trim().length() == 0) {
- loginView = DEFAULT_LOGIN_VIEW;
- }
- request.appendHtml("<a div class=\"link\" href=\"" + loginView + "\">Log in</a>");
- }
- }
-
- public void displayUserAndLogoutLink(final Request request) {
- String user = request.getOptionalProperty(NAME);
- if (user == null) {
- user = (String) request.getContext().getVariable("_username");
- }
- if (user == null) {
- user = IsisContext.getAuthenticationSession().getUserName();
- }
- request.appendHtml("Welcome <span class=\"name\">");
- request.appendAsHtmlEncoded(user);
- request.appendHtml("</span>, ");
- final String logoutView = request.getOptionalProperty(LOGOUT_VIEW, DEFAULT_LOGOUT_VIEW);
- request.appendHtml("<a class=\"link\" href=\"logout.app?view=" + logoutView + "\">Log out</a>");
- }
-
- @Override
- public String getName() {
- return "user";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/AbstractConditionalBlock.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/AbstractConditionalBlock.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/AbstractConditionalBlock.java
deleted file mode 100644
index dc5b39a..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/AbstractConditionalBlock.java
+++ /dev/null
@@ -1,565 +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.viewer.scimpi.dispatcher.view.simple;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import org.apache.isis.applib.annotation.Where;
-import org.apache.isis.applib.filter.Filters;
-import org.apache.isis.core.commons.authentication.AuthenticationSession;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.consent.Consent;
-import org.apache.isis.core.metamodel.facets.actcoll.typeof.TypeOfFacet;
-import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacet;
-import org.apache.isis.core.metamodel.spec.ActionType;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.metamodel.spec.feature.Contributed;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.ResolveFieldUtil;
-import org.apache.isis.viewer.scimpi.dispatcher.ScimpiException;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
-import org.apache.isis.viewer.scimpi.dispatcher.util.MethodsUtils;
-
-public abstract class AbstractConditionalBlock extends AbstractElementProcessor {
-
- private static Map<String, Test> tests = new HashMap<String, Test>();
-
- static {
- addNormal(new TestHasRole(), "has-role");
- addNegated(new TestHasRole(), "has-not-role");
-
- addNormal(new TestVariableExists(), "variable-exists");
- addNegated(new TestVariableExists(), "variable-missing");
- addNormal(new TestVariableTrue(), "variable-true");
- addNegated(new TestVariableTrue(), "variable-false");
-
- addNormal(new TestObjectPersistent(), "object-persistent");
- addNegated(new TestObjectPersistent(), "object-transient");
- addNormal(new TestObjectType(), "object-type");
- /*
- * addNormal(new TestObjectIs(), "object-is"); addNegated(new
- * TestObjectIs(), "object-is-not"); addNormal(new TestObjectType(),
- * "object-type"); addNormal(new TestObjectType(),
- * "object-title-equals"); addNegated(new TestObjectType(),
- * "object-title-not-equals"); addNormal(new TestObjectType(),
- * "object-title-contains"); addNegated(new TestObjectType(),
- * "object-title-not-contains");
- */
- addNormal(new TestCollectionFull(), "collection-full");
- addNegated(new TestCollectionFull(), "collection-empty");
- addNormal(new TestCollectionType(), "collection-type");
- // addNormal(new TestCollectionSize(), "collection-size-equal");
- // addNormal(new TestCollectionSize(), "collection-size-less-than");
- // addNormal(new TestCollectionSize(), "collection-size-greater-than");
-
- addNormal(new TestFieldValue(), "test-field");
- addNegated(new TestFieldValue(), "test-field");
-
- addNormal(new TestFieldExists(), "field-exists");
- addNegated(new TestFieldExists(), "field-missing");
- addNormal(new TestFieldVisible(), "field-visible");
- addNegated(new TestFieldVisible(), "field-hidden");
- addNormal(new TestFieldEditable(), "field-editable");
- addNegated(new TestFieldEditable(), "field-not-editable");
- addNormal(new TestFieldType(), "field-type");
- addNormal(new TestFieldSet(), "field-set");
- addNegated(new TestFieldSet(), "field-empty");
- // empty/set etc
-
- addNormal(new TestMethodExists(), "method-exists");
- addNegated(new TestMethodExists(), "method-missing");
- addNormal(new TestMethodVisible(), "method-visible");
- addNegated(new TestMethodVisible(), "method-hidden");
- addNormal(new TestMethodUseable(), "method-useable");
- addNegated(new TestMethodUseable(), "method-not-useable");
-
- }
-
- private static void addNegated(final Test test, final String name) {
- test.name = name;
- test.negateResult = true;
- tests.put(name, test);
- }
-
- private static void addNormal(final Test test, final String name) {
- test.name = name;
- tests.put(name, test);
- }
-
- @Override
- public void process(final Request request) {
- final String id = request.getOptionalProperty(OBJECT);
-
- boolean checkMade = false;
- boolean allConditionsMet = true;
-
- final String[] propertyNames = request.getAttributes().getPropertyNames(new String[] { "object", "collection" });
- for (final String propertyName : propertyNames) {
- boolean result;
- if (propertyName.equals("set")) {
- result = request.isPropertySet("set");
- } else {
- final Test test = tests.get(propertyName);
- if (test == null) {
- throw new ScimpiException("No such test: " + propertyName);
- }
- final String attributeValue = request.getOptionalProperty(propertyName, false);
- result = test.test(request, attributeValue, id);
- if (test.negateResult) {
- result = !result;
- }
- }
- checkMade = true;
- allConditionsMet &= result;
- }
-
- /*
- *
- * // Check variables if
- * (request.isPropertySpecified("variable-exists")) { boolean
- * valuePresent = request.isPropertySet("variable-exists"); checkMade =
- * true; allConditionsMet &= valuePresent; }
- *
- * String variable = request.getOptionalProperty("variable-true"); if
- * (variable != null) { String value = (String)
- * request.getContext().getVariable(variable); checkMade = true;
- * allConditionsMet &= Attributes.isTrue(value); }
- *
- * variable = request.getOptionalProperty("variable-equals"); if
- * (variable != null) { String value = (String)
- * request.getContext().getVariable(variable); checkMade = true;
- * allConditionsMet &= variable.equals(value); }
- */
- // Check Object
-
- /*
- * // Check Collection String collection =
- * request.getOptionalProperty("collection-" + TYPE); if (collection !=
- * null) { ObjectAdapter object =
- * MethodsUtils.findObject(request.getContext(), collection); Class<?>
- * cls = forClass(request); TypeOfFacet facet =
- * object.getSpecification().getFacet(TypeOfFacet.class); boolean
- * hasType = object != null && (cls == null ||
- * cls.isAssignableFrom(facet.value())); checkMade = true;
- * allConditionsMet &= hasType;; }
- *
- * collection = request.getOptionalProperty("collection-" + "empty"); if
- * (collection != null) { ObjectAdapter object =
- * MethodsUtils.findObject(request.getContext(), id); CollectionFacet
- * facet = object.getSpecification().getFacet(CollectionFacet.class);
- * boolean isEmpty = facet != null && facet.size(object) == 0;
- * processTags(isEmpty, request); allConditionsMet &= isEmpty; }
- */
-
- // Check Methods
- /*
- * String method = request.getOptionalProperty(METHOD + "-exists"); if
- * (method != null) { ObjectAdapter object =
- * MethodsUtils.findObject(request.getContext(), id); List<? extends
- * ObjectAction> objectActions =
- * object.getSpecification().getObjectActions(ActionType.USER); boolean
- * methodExists = false; for (ObjectAction objectAssociation :
- * objectActions) { if (objectAssociation.getId().equals(method)) {
- * methodExists = true; break; } } checkMade = true; allConditionsMet &=
- * methodExists; }
- *
- * method = request.getOptionalProperty(METHOD + "-visible"); if (method
- * != null) { ObjectAdapter object =
- * MethodsUtils.findObject(request.getContext(), id); // TODO needs to
- * work irrespective of parameters ObjectAction objectAction =
- * object.getSpecification().getObjectAction(ActionType.USER, method,
- * ObjectSpecification.EMPTY_LIST); Consent visible =
- * objectAction.isVisible(IsisContext.getAuthenticationSession(),
- * object); checkMade = true; allConditionsMet &= visible.isAllowed(); }
- *
- * method = request.getOptionalProperty(METHOD + "-usable"); if (method
- * != null) { ObjectAdapter object =
- * MethodsUtils.findObject(request.getContext(), id); // TODO needs to
- * work irrespective of parameters ObjectAction objectAction =
- * object.getSpecification().getObjectAction(ActionType.USER, method,
- * ObjectSpecification.EMPTY_LIST); Consent usable =
- * objectAction.isUsable(IsisContext.getAuthenticationSession(),
- * object); checkMade = true; allConditionsMet &= usable.isAllowed(); }
- *
- *
- * // Check Fields String field = request.getOptionalProperty(FIELD +
- * "-exists"); if (field != null) { ObjectAdapter object =
- * MethodsUtils.findObject(request.getContext(), id); List<? extends
- * ObjectAssociation> objectFields =
- * object.getSpecification().getAssociations(); boolean fieldExists =
- * false; for (ObjectAssociation objectAssociation : objectFields) { if
- * (objectAssociation.getId().equals(field)) { fieldExists = true;
- * break; } } checkMade = true; allConditionsMet &= fieldExists; }
- *
- * field = request.getOptionalProperty(FIELD + "-visible"); if (field !=
- * null) { ObjectAdapter object =
- * MethodsUtils.findObject(request.getContext(), id); ObjectAssociation
- * objectField = object.getSpecification().getAssociation(field);
- * Consent visible =
- * objectField.isVisible(IsisContext.getAuthenticationSession(),
- * object); checkMade = true; allConditionsMet &= visible.isAllowed(); }
- *
- * field = request.getOptionalProperty(FIELD + "-editable"); if (field
- * != null) { ObjectAdapter object =
- * MethodsUtils.findObject(request.getContext(), id); ObjectAssociation
- * objectField = object.getSpecification().getAssociation(field);
- * Consent usable =
- * objectField.isUsable(IsisContext.getAuthenticationSession(), object);
- * checkMade = true; allConditionsMet &= usable.isAllowed(); }
- *
- * field = request.getOptionalProperty(FIELD + "-empty"); if (field !=
- * null) { ObjectAdapter object =
- * MethodsUtils.findObject(request.getContext(), id); ObjectAssociation
- * objectField = object.getSpecification().getAssociation(field);
- * IsisContext.getPersistenceSession().resolveField(object,
- * objectField); ObjectAdapter fld = objectField.get(object); if (fld ==
- * null) { checkMade = true; allConditionsMet &= true; } else {
- * CollectionFacet facet =
- * fld.getSpecification().getFacet(CollectionFacet.class); boolean
- * isEmpty = facet != null && facet.size(fld) == 0; processTags(isEmpty,
- * request); allConditionsMet &= isEmpty; } }
- *
- * field = request.getOptionalProperty(FIELD + "-set"); if (field !=
- * null) { ObjectAdapter object =
- * MethodsUtils.findObject(request.getContext(), id); ObjectAssociation
- * objectField = object.getSpecification().getAssociation(field);
- * IsisContext.getPersistenceSession().resolveField(object,
- * objectField); ObjectAdapter fld = objectField.get(object); if (fld ==
- * null) { throw new ScimpiException("No object for field-set " +
- * field); } Object fieldValue = fld.getObject(); if (fieldValue
- * instanceof Boolean) { checkMade = true; allConditionsMet &=
- * ((Boolean) fieldValue).booleanValue(); } else { checkMade = true;
- * allConditionsMet &= true; } }
- */
-
- // Check User
- /*
- * String hasRole = request.getOptionalProperty("has-role"); if (hasRole
- * != null) { AuthenticationSession session =
- * IsisContext.getSession().getAuthenticationSession(); List<String>
- * roles = session.getRoles(); boolean hasMatchingRole = false; for
- * (String role : roles) { if (role.equals(hasRole.trim())) {
- * hasMatchingRole = true; break; } } checkMade = true; allConditionsMet
- * &= hasMatchingRole; }
- */
-
- final String persistent = request.getOptionalProperty("persistent");
- if (persistent != null) {
- final ObjectAdapter object = request.getContext().getMappedObjectOrResult(persistent);
- checkMade = true;
- allConditionsMet &= object.representsPersistent();
- }
- /*
- * String type = request.getOptionalProperty(TYPE); if (type != null) {
- * ObjectAdapter object = MethodsUtils.findObject(request.getContext(),
- * id); Class<?> cls = forClass(request); boolean hasType = object !=
- * null && (cls == null ||
- * cls.isAssignableFrom(object.getObject().getClass())); checkMade =
- * true; allConditionsMet &= hasType;; }
- */
- if (request.isPropertySpecified("empty")) {
- if (request.isPropertySet("empty")) {
- final String collection = request.getOptionalProperty("empty");
- if (collection != null) {
- final ObjectAdapter object = request.getContext().getMappedObjectOrResult(collection);
- final CollectionFacet facet = object.getSpecification().getFacet(CollectionFacet.class);
- checkMade = true;
- allConditionsMet &= facet.size(object) == 0;
- }
- } else {
- checkMade = true;
- allConditionsMet &= true;
- }
- }
-
- if (request.isPropertySpecified("set")) {
- final boolean valuePresent = request.isPropertySet("set");
- checkMade = true;
- allConditionsMet &= valuePresent;
- }
-
- if (checkMade) {
- processTags(allConditionsMet, request);
- } else {
- throw new ScimpiException("No condition in " + getName());
- }
- }
-
- protected abstract void processTags(boolean isSet, Request request);
-
-}
-
-abstract class Test {
- String name;
- boolean negateResult;
-
- abstract boolean test(Request request, String attributeName, String targetId);
-
- protected Class<?> forClass(final String className) {
- Class<?> cls = null;
- if (className != null) {
- try {
- cls = Class.forName(className);
- } catch (final ClassNotFoundException e) {
- throw new ScimpiException("No class for " + className, e);
- }
- }
- return cls;
- }
-
- protected ObjectAction findMethod(final String attributeName, final ObjectAdapter object) {
- final ObjectAction objectAction = object.getSpecification().getObjectAction(ActionType.USER, attributeName, ObjectSpecification.EMPTY_LIST);
- if (objectAction == null) {
- throw new ScimpiException("No such method found in " + object.getSpecification().getIdentifier().getClassName() + " : " + attributeName);
- }
- return objectAction;
- }
-
- protected ObjectAssociation findProperty(final String attributeName, final ObjectAdapter object) {
- final ObjectAssociation objectField = object.getSpecification().getAssociation(attributeName);
- if (objectField == null) {
- throw new ScimpiException("No such property found in " + object.getSpecification().getIdentifier().getClassName() + ": " + attributeName);
- }
- return objectField;
- }
-
-}
-
-class TestVariableExists extends Test {
- @Override
- boolean test(final Request request, final String attributeName, final String targetId) {
- Object variable = request.getContext().getVariable(attributeName);
- if (variable instanceof String && ((String) variable).equals("")) {
- return false;
- }
- return variable != null;
- }
-}
-
-class TestVariableTrue extends Test {
- @Override
- boolean test(final Request request, final String attributeName, final String targetId) {
- final Object variable = request.getContext().getVariable(attributeName);
- final Boolean value = variable instanceof Boolean ? (Boolean) variable : Boolean.valueOf((String) variable);
- return value != null && value.booleanValue();
- }
-}
-
-class TestObjectPersistent extends Test {
- @Override
- boolean test(final Request request, final String attributeName, final String targetId) {
- final ObjectAdapter object = request.getContext().getMappedObjectOrResult(attributeName);
- return object.representsPersistent();
- }
-}
-
-class TestObjectType extends TestObjectPersistent {
- @Override
- boolean test(final Request request, final String attributeName, final String targetId) {
- final ObjectAdapter object = MethodsUtils.findObject(request.getContext(), targetId);
- final Class<?> cls = forClass(attributeName);
- final boolean hasType = object != null && (cls == null || cls.isAssignableFrom(object.getObject().getClass()));
- return hasType;
- }
-}
-
-class TestCollectionType extends Test {
- @Override
- boolean test(final Request request, final String attributeName, final String targetId) {
- final ObjectAdapter object = MethodsUtils.findObject(request.getContext(), targetId);
- final Class<?> cls = forClass(attributeName);
- final TypeOfFacet facet = object.getSpecification().getFacet(TypeOfFacet.class);
- final boolean hasType = object != null && (cls == null || cls.isAssignableFrom(facet.value()));
- return hasType;
- }
-}
-
-class TestCollectionFull extends Test {
- @Override
- boolean test(final Request request, final String attributeName, final String targetId) {
- final ObjectAdapter object = MethodsUtils.findObject(request.getContext(), attributeName);
- final CollectionFacet facet = object.getSpecification().getFacet(CollectionFacet.class);
- final boolean isEmpty = facet != null && facet.size(object) == 0;
- return !isEmpty;
- }
-}
-
-class TestMethodExists extends Test {
- @Override
- boolean test(final Request request, final String attributeName, final String targetId) {
- final ObjectAdapter object = MethodsUtils.findObject(request.getContext(), targetId);
- final List<? extends ObjectAction> objectActions = object.getSpecification().getObjectActions(ActionType.USER, Contributed.INCLUDED, Filters.<ObjectAction>any());
- boolean methodExists = false;
- for (final ObjectAction objectAssociation : objectActions) {
- if (objectAssociation.getId().equals(attributeName)) {
- methodExists = true;
- break;
- }
- }
- return methodExists;
- }
-}
-
-class TestMethodVisible extends Test {
- @Override
- boolean test(final Request request, final String attributeName, final String targetId) {
- final ObjectAdapter object = MethodsUtils.findObject(request.getContext(), targetId);
- // TODO needs to work irrespective of parameters
- final ObjectAction objectAction = findMethod(attributeName, object);
- final Consent visible = objectAction.isVisible(IsisContext.getAuthenticationSession(), object, Where.ANYWHERE);
- return visible.isAllowed();
- }
-}
-
-class TestMethodUseable extends Test {
- @Override
- boolean test(final Request request, final String attributeName, final String targetId) {
- final ObjectAdapter object = MethodsUtils.findObject(request.getContext(), targetId);
- // TODO needs to work irrespective of parameters
- final ObjectAction objectAction = findMethod(attributeName, object);
- final Consent usable = objectAction.isUsable(IsisContext.getAuthenticationSession(), object, Where.ANYWHERE);
- return usable.isAllowed();
- }
-}
-
-class TestFieldExists extends Test {
- @Override
- boolean test(final Request request, final String attributeName, final String targetId) {
- final ObjectAdapter object = MethodsUtils.findObject(request.getContext(), targetId);
- final List<? extends ObjectAssociation> objectFields = object.getSpecification().getAssociations(Contributed.EXCLUDED);
- boolean fieldExists = false;
- for (final ObjectAssociation objectAssociation : objectFields) {
- if (objectAssociation.getId().equals(attributeName)) {
- fieldExists = true;
- break;
- }
- }
- return fieldExists;
- }
-}
-
-class TestFieldVisible extends Test {
- @Override
- boolean test(final Request request, final String attributeName, final String targetId) {
- final ObjectAdapter object = MethodsUtils.findObject(request.getContext(), targetId);
- final ObjectAssociation objectField = findProperty(attributeName, object);
- final Consent visible = objectField.isVisible(IsisContext.getAuthenticationSession(), object, Where.ANYWHERE);
- return visible.isAllowed();
- }
-}
-
-class TestFieldEditable extends Test {
- @Override
- boolean test(final Request request, final String attributeName, final String targetId) {
- final ObjectAdapter object = MethodsUtils.findObject(request.getContext(), targetId);
- final ObjectAssociation objectField = findProperty(attributeName, object);
- final Consent usable = objectField.isUsable(IsisContext.getAuthenticationSession(), object, Where.ANYWHERE);
- return usable.isAllowed();
- }
-}
-
-class TestFieldType extends Test {
- @Override
- boolean test(final Request request, final String attributeName, final String targetId) {
- final ObjectAdapter object = MethodsUtils.findObject(request.getContext(), targetId);
- final Class<?> cls = forClass(attributeName);
- final boolean hasType = object != null && (cls == null || cls.isAssignableFrom(object.getObject().getClass()));
- return hasType;
- }
-}
-
-class TestFieldSet extends Test {
- @Override
- boolean test(final Request request, final String attributeName, final String targetId) {
- final ObjectAdapter object = MethodsUtils.findObject(request.getContext(), targetId);
- final ObjectAssociation objectField = findProperty(attributeName, object);
-
- ResolveFieldUtil.resolveField(object, objectField);
- final ObjectAdapter fld = objectField.get(object);
- if (fld != null) {
- final Object fieldValue = fld.getObject();
- if (fieldValue instanceof Boolean) {
- return ((Boolean) fieldValue).booleanValue();
- } else if (fld.getSpecification().containsFacet(CollectionFacet.class)) {
- final CollectionFacet facet = fld.getSpecification().getFacet(CollectionFacet.class);
- final boolean isEmpty = facet != null && facet.size(fld) == 0;
- return !isEmpty;
- } else {
- return true;
- }
- }
- return false;
- }
-}
-
-class TestFieldValue extends Test {
- @Override
- boolean test(Request request, String attributeName, String targetId) {
- int pos = attributeName.indexOf("==");
- // TODO test for other comparators
- // TODO fail properly if none found
- String fieldName = attributeName.substring(0, pos);
- String fieldValue = attributeName.substring(pos + 2);
-
- final ObjectAdapter object = MethodsUtils.findObject(request.getContext(), targetId);
- final ObjectAssociation objectField = findProperty(fieldName, object);
- ResolveFieldUtil.resolveField(object, objectField);
- final ObjectAdapter fld = objectField.get(object);
-
- // TODO test for reference or value
- final ObjectAdapter object2 = MethodsUtils.findObject(request.getContext(), fieldValue);
-
- if (fld == object2) {
- return true;
- }
- return false;
- }
-
-}
-
-class TestHasRole extends Test {
- @Override
- boolean test(final Request request, final String attributeName, final String targetId) {
- final String[] requiredRoles = attributeName.split("\\|");
- final AuthenticationSession session = IsisContext.getSession().getAuthenticationSession();
- final List<String> sessionRoles = session.getRoles();
- for (final String sessionRole : sessionRoles) {
- for (final String requiredRole : requiredRoles) {
- if (requiredRole.trim().equals(sessionRole)) {
- return true;
- }
- }
- }
- return false;
- }
-}
-
-class TestSet extends Test {
- @Override
- boolean test(final Request request, final String attributeName, final String targetId) {
- final boolean valuePresent = request.isPropertySet("set");
- return valuePresent;
- }
-}
-
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/AbstractLink.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/AbstractLink.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/AbstractLink.java
deleted file mode 100644
index b6798be..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/AbstractLink.java
+++ /dev/null
@@ -1,121 +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.viewer.scimpi.dispatcher.view.simple;
-
-import org.apache.isis.applib.annotation.Where;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.ForbiddenException;
-import org.apache.isis.viewer.scimpi.dispatcher.ResolveFieldUtil;
-import org.apache.isis.viewer.scimpi.dispatcher.ScimpiException;
-import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext;
-import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext.Scope;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
-import org.apache.isis.viewer.scimpi.dispatcher.util.MethodsUtils;
-
-public abstract class AbstractLink extends AbstractElementProcessor {
-
- @Override
- public void process(final Request request) {
- final String title = request.getOptionalProperty(FORM_TITLE);
- final String name = request.getOptionalProperty(NAME);
- final boolean showAsButton = request.isRequested("show-as-button", false);
- final String linkClass = request.getOptionalProperty(CLASS, showAsButton ? "button" : defaultLinkClass());
- final String containerClass = request.getOptionalProperty(CONTAINER_CLASS, "action");
- final String object = request.getOptionalProperty(OBJECT);
- final RequestContext context = request.getContext();
- String objectId = object != null ? object : (String) context.getVariable(RequestContext.RESULT);
- ObjectAdapter adapter = MethodsUtils.findObject(context, objectId);
-
- // REVIEW this is common used code
- final String fieldName = request.getOptionalProperty(FIELD);
- if (fieldName != null) {
- final ObjectAssociation field = adapter.getSpecification().getAssociation(fieldName);
- if (field == null) {
- throw new ScimpiException("No field " + fieldName + " in " + adapter.getSpecification().getFullIdentifier());
- }
-
- // REVIEW: should provide this rendering context, rather than hardcoding.
- // the net effect currently is that class members annotated with
- // @Hidden(where=Where.ANYWHERE) or @Disabled(where=Where.ANYWHERE) will indeed
- // be hidden/disabled, but will be visible/enabled (perhaps incorrectly)
- // for any other value for Where
- final Where where = Where.ANYWHERE;
-
- if (field.isVisible(IsisContext.getAuthenticationSession(), adapter, where).isVetoed()) {
- throw new ForbiddenException(field, ForbiddenException.VISIBLE);
- }
- ResolveFieldUtil.resolveField(adapter, field);
- adapter = field.get(adapter);
- if (adapter != null) {
- objectId = context.mapObject(adapter, Scope.INTERACTION);
- }
- }
-
- if (adapter != null && valid(request, adapter)) {
- final String variable = request.getOptionalProperty("param-name", RequestContext.RESULT);
- final String variableSegment = variable + "=" + objectId;
-
- String view = request.getOptionalProperty(VIEW);
- if (view == null) {
- view = defaultView();
- }
- view = context.fullUriPath(view);
- final String classSegment = " class=\"" + linkClass + "\"";
- final String titleSegment = title == null ? "" : (" title=\"" + title + "\"");
- String additionalSegment = additionalParameters(request);
- additionalSegment = additionalSegment == null ? "" : "&" + additionalSegment;
- if (showAsButton) {
- request.appendHtml("<div class=\"" + containerClass + "\">");
- }
- request.appendHtml("<a" + classSegment + titleSegment + " href=\"" + view + "?" + variableSegment + context.encodedInteractionParameters() + additionalSegment + "\">");
- request.pushNewBuffer();
- request.processUtilCloseTag();
- final String buffer = request.popBuffer();
- if (buffer.trim().length() > 0) {
- request.appendHtml(buffer);
- } else {
- request.appendAsHtmlEncoded(linkLabel(name, adapter));
- }
- request.appendHtml("</a>");
- if (showAsButton) {
- request.appendHtml("</div>");
- }
- } else {
- request.skipUntilClose();
- }
- }
-
- private String defaultLinkClass() {
- return "action";
- }
-
- protected abstract String linkLabel(String name, ObjectAdapter object);
-
- protected String additionalParameters(final Request request) {
- return null;
- }
-
- protected abstract boolean valid(Request request, ObjectAdapter adapter);
-
- protected abstract String defaultView();
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/BlockDefine.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/BlockDefine.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/BlockDefine.java
deleted file mode 100644
index cea5d11..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/BlockDefine.java
+++ /dev/null
@@ -1,42 +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.viewer.scimpi.dispatcher.view.simple;
-
-import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext.Scope;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request.RepeatMarker;
-
-public class BlockDefine extends AbstractElementProcessor {
-
- @Override
- public String getName() {
- return "block";
- }
-
- @Override
- public void process(final Request request) {
- final String name = request.getOptionalProperty(NAME, "unamed");
- final RepeatMarker start = request.createMarker();
- request.skipUntilClose();
- request.getContext().addVariable("_block-" + name, start, Scope.REQUEST);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/BlockUse.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/BlockUse.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/BlockUse.java
deleted file mode 100644
index efd6128..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/BlockUse.java
+++ /dev/null
@@ -1,46 +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.viewer.scimpi.dispatcher.view.simple;
-
-import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request.RepeatMarker;
-
-public class BlockUse extends AbstractElementProcessor {
-
- @Override
- public String getName() {
- return "use-block";
- }
-
- @Override
- public void process(final Request request) {
- final String name = request.getOptionalProperty(NAME, "unamed");
- request.closeEmpty();
- final RepeatMarker end = request.createMarker();
-
- final RepeatMarker marker = (RepeatMarker) request.getContext().getVariable("_block-" + name);
- marker.repeat();
-
- request.processUtilCloseTag();
- end.repeat();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Commit.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Commit.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Commit.java
deleted file mode 100644
index 4106fd9..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Commit.java
+++ /dev/null
@@ -1,45 +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.viewer.scimpi.dispatcher.view.simple;
-
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.core.runtime.system.transaction.IsisTransactionManager;
-import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
-
-public class Commit extends AbstractElementProcessor {
-
- @Override
- public String getName() {
- return "commit";
- }
-
- @Override
- public void process(final Request request) {
- // Note - the session will have changed since the earlier call if a user
- // has logged in or out in the action
- // processing above.
- final IsisTransactionManager transactionManager = IsisContext.getPersistenceSession().getTransactionManager();
- if (transactionManager.getTransaction().getState().canCommit()) {
- transactionManager.endTransaction();
- transactionManager.startTransaction();
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/ContentTag.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/ContentTag.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/ContentTag.java
deleted file mode 100644
index ddda339..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/ContentTag.java
+++ /dev/null
@@ -1,36 +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.viewer.scimpi.dispatcher.view.simple;
-
-import org.apache.isis.viewer.scimpi.dispatcher.ElementProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
-
-public class ContentTag implements ElementProcessor {
-
- @Override
- public String getName() {
- return "content";
- }
-
- @Override
- public void process(final Request request) {
- request.appendHtml("<!-- apply content -->");
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/CookieValue.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/CookieValue.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/CookieValue.java
deleted file mode 100644
index 09e56b0..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/CookieValue.java
+++ /dev/null
@@ -1,46 +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.viewer.scimpi.dispatcher.view.simple;
-
-import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext;
-import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext.Scope;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
-
-public class CookieValue extends AbstractElementProcessor {
-
- @Override
- public void process(final Request request) {
- String name = request.getRequiredProperty(NAME);
- String resultName = request.getOptionalProperty(RESULT_NAME, name);
- final String scopeName = request.getOptionalProperty(SCOPE);
- final Scope scope = RequestContext.scope(scopeName, Scope.REQUEST);
-
- String cookieString = request.getContext().getCookie(name);
-
- request.appendDebug(" " + resultName + " (" + scope + ") set to " + cookieString + " from cookie " + name);
- request.getContext().addVariable(resultName, cookieString, scope);
- }
-
- @Override
- public String getName() {
- return "cookie-value";
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/DefaultValue.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/DefaultValue.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/DefaultValue.java
deleted file mode 100644
index 2cd9593..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/DefaultValue.java
+++ /dev/null
@@ -1,52 +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.viewer.scimpi.dispatcher.view.simple;
-
-import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext;
-import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext.Scope;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
-
-public class DefaultValue extends AbstractElementProcessor {
-
- @Override
- public void process(final Request request) {
- // String sourceObjectId = objectOrResult(request);
- final String variableName = request.getRequiredProperty(NAME);
- final String defaultValue = request.getOptionalProperty(VALUE);
- final String scopeName = request.getOptionalProperty(SCOPE);
- final Scope scope = RequestContext.scope(scopeName, Scope.REQUEST);
-
- final RequestContext context = request.getContext();
- final Object currentValue = context.getVariable(variableName);
- if (currentValue == null) {
- request.appendDebug(" " + variableName + " set to " + defaultValue + " (" + scope + ")");
- context.addVariable(variableName, defaultValue, scope);
- } else {
- request.appendDebug(" " + variableName + " alreadt set to " + currentValue);
- }
- }
-
- @Override
- public String getName() {
- return "default";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/EditLink.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/EditLink.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/EditLink.java
deleted file mode 100644
index ab43eb6..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/EditLink.java
+++ /dev/null
@@ -1,71 +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.viewer.scimpi.dispatcher.view.simple;
-
-import java.util.List;
-
-import org.apache.isis.applib.annotation.When;
-import org.apache.isis.applib.annotation.Where;
-import org.apache.isis.core.commons.authentication.AuthenticationSession;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.facets.object.immutable.ImmutableFacet;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.metamodel.spec.feature.Contributed;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.viewer.scimpi.dispatcher.Dispatcher;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
-
-public class EditLink extends AbstractLink {
-
- // REVIEW: should provide this rendering context, rather than hardcoding.
- // the net effect currently is that class members annotated with
- // @Hidden(where=Where.ANYWHERE) or @Disabled(where=Where.ANYWHERE) will indeed
- // be hidden/disabled, but will be visible/enabled (perhaps incorrectly)
- // for any other value for Where
- private final Where where = Where.ANYWHERE;
-
- @Override
- protected boolean valid(final Request request, final ObjectAdapter adapter) {
- final ObjectSpecification specification = adapter.getSpecification();
- final AuthenticationSession session = IsisContext.getAuthenticationSession();
- final List<ObjectAssociation> visibleFields = specification.getAssociations(Contributed.EXCLUDED, ObjectAssociation.Filters.dynamicallyVisible(session, adapter, where));
- final ImmutableFacet facet = specification.getFacet(ImmutableFacet.class);
- final boolean isImmutable = facet != null && facet.when() == When.ALWAYS;
- final boolean isImmutableOncePersisted = facet != null && facet.when() == When.ONCE_PERSISTED && adapter.representsPersistent();
- return visibleFields.size() > 0 && !isImmutable && !isImmutableOncePersisted;
- }
-
- @Override
- protected String linkLabel(final String name, final ObjectAdapter object) {
- return "edit";
- }
-
- @Override
- protected String defaultView() {
- return Dispatcher.GENERIC + Dispatcher.EDIT + "." + Dispatcher.EXTENSION;
- }
-
- @Override
- public String getName() {
- return "edit-link";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/EndSession.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/EndSession.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/EndSession.java
deleted file mode 100644
index 1a37f99..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/EndSession.java
+++ /dev/null
@@ -1,36 +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.viewer.scimpi.dispatcher.view.simple;
-
-import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
-
-public class EndSession extends AbstractElementProcessor {
-
- @Override
- public void process(final Request request) {
- request.getContext().endHttpSession();
- }
-
- @Override
- public String getName() {
- return "end-session";
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Forward.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Forward.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Forward.java
deleted file mode 100644
index e63ec92..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Forward.java
+++ /dev/null
@@ -1,37 +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.viewer.scimpi.dispatcher.view.simple;
-
-import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
-
-public class Forward extends AbstractElementProcessor {
-
- @Override
- public String getName() {
- return "forward";
- }
-
- @Override
- public void process(final Request request) {
- final String view = request.getRequiredProperty(VIEW);
- request.getContext().forward(view);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/GetCookie.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/GetCookie.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/GetCookie.java
deleted file mode 100644
index f58b13f..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/GetCookie.java
+++ /dev/null
@@ -1,39 +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.viewer.scimpi.dispatcher.view.simple;
-
-import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
-
-public class GetCookie extends AbstractElementProcessor {
-
- @Override
- public void process(final Request request) {
- final String name = request.getRequiredProperty("name");
- final String cookie = request.getContext().getCookie(name);
-
- request.appendHtml(cookie);
- }
-
- @Override
- public String getName() {
- return "get-cookie";
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Import.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Import.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Import.java
deleted file mode 100644
index 1b66290..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Import.java
+++ /dev/null
@@ -1,37 +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.viewer.scimpi.dispatcher.view.simple;
-
-import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
-
-public class Import extends AbstractElementProcessor {
-
- @Override
- public void process(final Request request) {
- request.appendHtml("<!-- " + " import " + request.getOptionalProperty("file") + " -->");
- }
-
- @Override
- public String getName() {
- return "import";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/InitializeFromCookie.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/InitializeFromCookie.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/InitializeFromCookie.java
deleted file mode 100644
index 1e3f47e..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/InitializeFromCookie.java
+++ /dev/null
@@ -1,80 +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.viewer.scimpi.dispatcher.view.simple;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.runtime.persistence.ObjectNotFoundException;
-import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext;
-import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext.Scope;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
-
-public class InitializeFromCookie extends AbstractElementProcessor {
- private static final String SEVEN_DAYS = Integer.toString(60 * 24 * 7);
-
- @Override
- public void process(final Request request) {
- final String name = request.getRequiredProperty(NAME);
-
- final RequestContext context = request.getContext();
- if (context.getVariable(name) != null) {
- request.skipUntilClose();
- } else {
- final String scopeName = request.getOptionalProperty(SCOPE);
- final Scope scope = RequestContext.scope(scopeName, Scope.SESSION);
-
- final String cookieName = request.getOptionalProperty("cookie", name);
- final String cookieValue = context.getCookie(cookieName);
- boolean hasObject;
- if (cookieValue != null) {
- try {
- context.getMappedObject(cookieValue);
- hasObject = true;
- } catch (final ObjectNotFoundException e) {
- hasObject = false;
- }
- } else {
- hasObject = false;
- }
-
- if (hasObject) {
- request.skipUntilClose();
- context.addVariable(name, cookieValue, scope);
- } else {
- final String expiresString = request.getOptionalProperty("expires", SEVEN_DAYS);
- request.pushNewBuffer();
- request.processUtilCloseTag();
- request.popBuffer();
- final String id = (String) context.getVariable(RequestContext.RESULT);
- final ObjectAdapter variable = context.getMappedObject(id);
- if (variable != null) {
- context.addCookie(cookieName, id, Integer.valueOf(expiresString));
- context.addVariable(name, id, scope);
- }
- }
- }
- }
-
- @Override
- public String getName() {
- return "initialize-from-cookie";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/InitializeFromResult.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/InitializeFromResult.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/InitializeFromResult.java
deleted file mode 100644
index 375fdd2..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/InitializeFromResult.java
+++ /dev/null
@@ -1,77 +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.viewer.scimpi.dispatcher.view.simple;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.ScimpiException;
-import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext;
-import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext.Scope;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
-
-public class InitializeFromResult extends AbstractElementProcessor {
-
- @Override
- public void process(final Request request) {
- disallowSourceAndDefault(request);
- final String sourceObjectId = objectOrResult(request);
- final Class<?> cls = forClass(request);
- final String variableName = request.getRequiredProperty(NAME);
- final String defaultObjectId = request.getOptionalProperty(DEFAULT);
- final String scopeName = request.getOptionalProperty(SCOPE);
- final Scope scope = RequestContext.scope(scopeName, Scope.REQUEST);
-
- final RequestContext context = request.getContext();
- final ObjectAdapter sourceObject = context.getMappedObject(sourceObjectId);
- final boolean isSourceSet = sourceObject != null;
- final boolean isSourceAssignable = isSourceSet && (cls == null || cls.isAssignableFrom(sourceObject.getObject().getClass()));
- if (isSourceAssignable) {
- request.appendDebug(" " + variableName + " set to " + sourceObjectId + " (" + scope + ")");
- context.addVariable(variableName, sourceObjectId, scope);
- } else {
- request.appendDebug(" " + variableName + " set to " + sourceObjectId + " (" + scope + ")");
- if (defaultObjectId != null) {
- context.addVariable(variableName, defaultObjectId, scope);
- }
- context.changeScope(variableName, scope);
- }
- }
-
- private String objectOrResult(final Request request) {
- final String sourceObjectId = request.getOptionalProperty(OBJECT);
- if (sourceObjectId == null) {
- return (String) request.getContext().getVariable(RequestContext.RESULT);
- } else {
- return sourceObjectId;
- }
- }
-
- private void disallowSourceAndDefault(final Request request) {
- if (request.getOptionalProperty(DEFAULT) != null && request.getOptionalProperty(OBJECT) != null) {
- throw new ScimpiException("Cannot specify both " + OBJECT + " and " + DEFAULT + " for the " + getName() + " element");
- }
- }
-
- @Override
- public String getName() {
- return "initialize";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Localization.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Localization.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Localization.java
deleted file mode 100644
index fe1474b..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Localization.java
+++ /dev/null
@@ -1,64 +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.viewer.scimpi.dispatcher.view.simple;
-
-import java.util.Locale;
-import java.util.TimeZone;
-
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
-
-/**
- * Displays the localization data for the current user.
- */
-public class Localization extends AbstractElementProcessor {
-
- @Override
- public void process(final Request request) {
- request.closeEmpty();
-
- org.apache.isis.applib.profiles.Localization localization = IsisContext.getLocalization();
- if (localization != null) {
- Locale locale = localization.getLocale();
- String country = locale.getDisplayName();
- // country = locale.toString();
- String timeZone = localization.getTimeZone().getDisplayName();
-
- request.appendAsHtmlEncoded(country + ", " + timeZone);
- } else {
- request.appendAsHtmlEncoded("No localization data!");
- }
-
- Locale locale = Locale.getDefault();
- String country = locale.getDisplayName();
- // country = locale.toString();
- String timeZone = TimeZone.getDefault().getDisplayName();
-
- request.appendAsHtmlEncoded("\n (Default " + country + ", " + timeZone +")");
-
- }
-
- @Override
- public String getName() {
- return "alpha-localization";
- }
-
-}