You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by rm...@apache.org on 2013/03/24 18:44:58 UTC
[01/24] Restructuring Scimpi to remove dependencies and enable easier
testing.
Updated Branches:
refs/heads/scimpi-restructure [created] 7700b4371
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/TitleString.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/TitleString.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/TitleString.java
index 6b2078a..7afe506 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/TitleString.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/TitleString.java
@@ -23,9 +23,9 @@ 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.processor.Request;
+import org.apache.isis.viewer.scimpi.ForbiddenException;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
/**
*
@@ -33,11 +33,11 @@ import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
public class TitleString extends AbstractElementProcessor {
@Override
- public void process(final Request request) {
- final String id = request.getOptionalProperty(OBJECT);
- final String fieldName = request.getOptionalProperty(FIELD);
- final int truncateTo = Integer.valueOf(request.getOptionalProperty(TRUNCATE, "0")).intValue();
- final ObjectAdapter object = request.getContext().getMappedObjectOrResult(id);
+ public void process(final TagProcessor tagProcessor) {
+ final String id = tagProcessor.getOptionalProperty(OBJECT);
+ final String fieldName = tagProcessor.getOptionalProperty(FIELD);
+ final int truncateTo = Integer.valueOf(tagProcessor.getOptionalProperty(TRUNCATE, "0")).intValue();
+ final ObjectAdapter object = tagProcessor.getContext().getMappedObjectOrResult(id);
if (object == null) {
return;
}
@@ -56,8 +56,8 @@ public class TitleString extends AbstractElementProcessor {
titleString = "";
}
}
- request.appendDebug(" " + titleString);
- request.appendTruncated(titleString, truncateTo);
+ tagProcessor.appendDebug(" " + titleString);
+ tagProcessor.appendTruncated(titleString, truncateTo);
}
@Override
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/Type.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/Type.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/Type.java
index 9c7861d..2cb2834 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/Type.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/Type.java
@@ -22,31 +22,31 @@ package org.apache.isis.viewer.scimpi.dispatcher.view.value;
import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
import org.apache.isis.core.metamodel.spec.ObjectSpecification;
import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
-import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public class Type extends AbstractElementProcessor {
@Override
- public void process(final Request request) {
- final RequestContext context = request.getContext();
- final String showPlural = request.getOptionalProperty(PLURAL);
- final String id = request.getOptionalProperty(OBJECT);
- final String objectId = id != null ? id : (String) context.getVariable(RequestContext.RESULT);
+ public void process(final TagProcessor tagProcessor) {
+ final Request context = tagProcessor.getContext();
+ final String showPlural = tagProcessor.getOptionalProperty(PLURAL);
+ final String id = tagProcessor.getOptionalProperty(OBJECT);
+ final String objectId = id != null ? id : (String) context.getVariable(RESULT);
ObjectAdapter object = context.getMappedObjectOrResult(objectId);
- final String field = request.getOptionalProperty(FIELD);
+ final String field = tagProcessor.getOptionalProperty(FIELD);
if (field != null) {
final ObjectAssociation objectField = object.getSpecification().getAssociation(field);
object = objectField.get(object);
}
- request.appendDebug(" for " + object);
+ tagProcessor.appendDebug(" for " + object);
final ObjectSpecification specification = object.getSpecification();
final String name = showPlural != null ? specification.getPluralName() : specification.getSingularName();
- request.appendAsHtmlEncoded(name);
+ tagProcessor.appendAsHtmlEncoded(name);
}
@Override
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/widget/FieldFactory.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/widget/FieldFactory.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/widget/FieldFactory.java
new file mode 100644
index 0000000..1936055
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/widget/FieldFactory.java
@@ -0,0 +1,105 @@
+/*
+ * 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.widget;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facets.help.HelpFacet;
+import org.apache.isis.core.metamodel.facets.maxlen.MaxLengthFacet;
+import org.apache.isis.core.metamodel.facets.multiline.MultiLineFacet;
+import org.apache.isis.core.metamodel.facets.object.parseable.ParseableFacet;
+import org.apache.isis.core.metamodel.facets.typicallen.TypicalLengthFacet;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.feature.ObjectFeature;
+import org.apache.isis.core.metamodel.spec.feature.ObjectMember;
+import org.apache.isis.core.progmodel.facets.value.booleans.BooleanValueFacet;
+import org.apache.isis.core.progmodel.facets.value.password.PasswordValueFacet;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.view.form.InputField;
+
+public class FieldFactory {
+
+ public static void initializeField(final Request context, final ObjectAdapter object, final ObjectFeature param, final ObjectAdapter[] optionsForParameter, final boolean isRequired, final InputField field) {
+
+ field.setLabel(param.getName());
+ field.setDescription(param.getDescription());
+ field.setDataType(param.getSpecification().getShortIdentifier());
+ if (param instanceof ObjectMember) {
+ field.setHelpReference(((ObjectMember) param).getHelp());
+ } else {
+ final HelpFacet helpFacet = param.getFacet(HelpFacet.class);
+ final String value = helpFacet.value();
+ field.setHelpReference(value);
+ }
+ field.setRequired(isRequired);
+ field.setHidden(false);
+
+ if (param.getSpecification().getFacet(ParseableFacet.class) != null) {
+ final int maxLength = param.getFacet(MaxLengthFacet.class).value();
+ field.setMaxLength(maxLength);
+
+ final TypicalLengthFacet typicalLengthFacet = param.getFacet(TypicalLengthFacet.class);
+ if (typicalLengthFacet.isDerived() && maxLength > 0) {
+ field.setWidth(maxLength);
+ } else {
+ field.setWidth(typicalLengthFacet.value());
+ }
+
+ final MultiLineFacet multiLineFacet = param.getFacet(MultiLineFacet.class);
+ field.setHeight(multiLineFacet.numberOfLines());
+ field.setWrapped(!multiLineFacet.preventWrapping());
+
+ final ObjectSpecification spec = param.getSpecification();
+ if (spec.containsFacet(BooleanValueFacet.class)) {
+ field.setType(InputField.CHECKBOX);
+ } else if (spec.containsFacet(PasswordValueFacet.class)) {
+ field.setType(InputField.PASSWORD);
+ } else {
+ field.setType(InputField.TEXT);
+ }
+
+ } else {
+ field.setType(InputField.REFERENCE);
+ }
+
+ if (optionsForParameter != null) {
+ final int noOptions = optionsForParameter.length;
+ final String[] optionValues = new String[noOptions];
+ final String[] optionTitles = new String[noOptions];
+ for (int j = 0; j < optionsForParameter.length; j++) {
+ final int i = j; // + (field.isRequired() ? 0 : 1);
+ optionValues[i] = getValue(context, optionsForParameter[j]);
+ optionTitles[i] = optionsForParameter[j].titleString();
+ }
+ field.setOptions(optionTitles, optionValues);
+ }
+ }
+
+ private static String getValue(final Request context, final ObjectAdapter field) {
+ if (field == null) {
+ return "";
+ }
+ if (field.getSpecification().getFacet(ParseableFacet.class) == null) {
+ return context.mapObject(field, Scope.INTERACTION);
+ } else {
+ return field.getObject().toString();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/widget/FormEntry.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/widget/FormEntry.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/widget/FormEntry.java
new file mode 100644
index 0000000..7b1b86c
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/widget/FormEntry.java
@@ -0,0 +1,44 @@
+/*
+ * 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.widget;
+
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+public class FormEntry extends AbstractElementProcessor {
+
+ @Override
+ public void process(final TagProcessor tagProcessor) {
+ final FormFieldBlock block = (FormFieldBlock) tagProcessor.getBlockContent();
+ final String field = tagProcessor.getRequiredProperty(FIELD);
+ final String value = tagProcessor.getRequiredProperty(VALUE);
+ final boolean isHidden = tagProcessor.isRequested(HIDDEN, true);
+ block.exclude(field);
+ // TODO this is replaced because the field is marked as hidden!
+ final String content = "reference <input type=\"" + (isHidden ? "hidden" : "text") + "\" disabled=\"disabled\" name=\"" + field + "\" value=\"" + value + "\" />";
+ block.replaceContent(field, content);
+ }
+
+ @Override
+ public String getName() {
+ return "form-entry";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/widget/FormField.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/widget/FormField.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/widget/FormField.java
new file mode 100644
index 0000000..2707c3d
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/widget/FormField.java
@@ -0,0 +1,44 @@
+/*
+ * 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.widget;
+
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+public class FormField extends AbstractElementProcessor {
+
+ @Override
+ public void process(final TagProcessor tagProcessor) {
+ final FormFieldBlock block = (FormFieldBlock) tagProcessor.getBlockContent();
+ final String field = tagProcessor.getRequiredProperty(FIELD);
+ if (block.isVisible(field)) {
+ tagProcessor.pushNewBuffer();
+ tagProcessor.processUtilCloseTag();
+ final String content = tagProcessor.popBuffer();
+ block.replaceContent(field, content);
+ }
+ }
+
+ @Override
+ public String getName() {
+ return "form-field";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/widget/FormFieldBlock.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/widget/FormFieldBlock.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/widget/FormFieldBlock.java
new file mode 100644
index 0000000..36cf5d8
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/widget/FormFieldBlock.java
@@ -0,0 +1,68 @@
+/*
+ * 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.widget;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.viewer.scimpi.dispatcher.view.field.InclusionList;
+import org.apache.isis.viewer.scimpi.dispatcher.view.form.InputField;
+
+public class FormFieldBlock extends InclusionList {
+ private final Map<String, String> content = new HashMap<String, String>();
+ private final Map<String, String> values = new HashMap<String, String>();
+
+ public void replaceContent(final String field, final String htmlString) {
+ content.put(field, htmlString);
+ }
+
+ public boolean hasContent(final String name) {
+ return content.containsKey(name);
+ }
+
+ public String getContent(final String name) {
+ return content.get(name);
+ }
+
+ public boolean isVisible(final String name) {
+ return true;
+ }
+
+ public boolean isNullable(final String name) {
+ return true;
+ }
+
+ public ObjectAdapter getCurrent(final String name) {
+ return null;
+ }
+
+ public void value(final String field, final String value) {
+ values.put(field, value);
+ }
+
+ public void setUpValues(final InputField[] inputFields) {
+ for (final InputField inputField : inputFields) {
+ final String name = inputField.getName();
+ inputField.setValue(values.get(name));
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/widget/HiddenField.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/widget/HiddenField.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/widget/HiddenField.java
new file mode 100644
index 0000000..cc8e824
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/widget/HiddenField.java
@@ -0,0 +1,48 @@
+/*
+ * 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.widget;
+
+import org.apache.isis.viewer.scimpi.dispatcher.TagOrderException;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.BlockContent;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+public class HiddenField extends AbstractElementProcessor {
+
+ @Override
+ public void process(final TagProcessor tagProcessor) {
+ final BlockContent blockContent = tagProcessor.getBlockContent();
+ if (!(blockContent instanceof FormFieldBlock)) {
+ throw new TagOrderException(tagProcessor);
+ }
+
+ final String field = tagProcessor.getOptionalProperty("name");
+ final String value = tagProcessor.getRequiredProperty("value");
+ final FormFieldBlock block = (FormFieldBlock) blockContent;
+ block.value(field, value);
+ block.exclude(field);
+ }
+
+ @Override
+ public String getName() {
+ return "hidden-field";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/widget/RadioListField.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/widget/RadioListField.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/widget/RadioListField.java
new file mode 100644
index 0000000..7bd51e1
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/widget/RadioListField.java
@@ -0,0 +1,70 @@
+/*
+ * 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.widget;
+
+import java.util.Iterator;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacet;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+public class RadioListField extends AbstractElementProcessor {
+
+ @Override
+ public void process(final TagProcessor tagProcessor) {
+ final FormFieldBlock block = (FormFieldBlock) tagProcessor.getBlockContent();
+ final String field = tagProcessor.getRequiredProperty(FIELD);
+ if (block.isVisible(field)) {
+ final String id = tagProcessor.getRequiredProperty(COLLECTION);
+ final String exclude = tagProcessor.getOptionalProperty("exclude");
+
+ final ObjectAdapter collection = tagProcessor.getContext().getMappedObjectOrResult(id);
+
+ final Request context = tagProcessor.getContext();
+ final CollectionFacet facet = collection.getSpecification().getFacet(CollectionFacet.class);
+ final Iterator<ObjectAdapter> iterator = facet.iterator(collection);
+
+ final StringBuffer buffer = new StringBuffer();
+
+ while (iterator.hasNext()) {
+ final ObjectAdapter element = iterator.next();
+ final Scope scope = Scope.INTERACTION;
+ final String elementId = context.mapObject(element, scope);
+ if (exclude != null && context.getMappedObject(exclude) == element) {
+ continue;
+ }
+ final String title = element.titleString();
+ final String checked = "";
+ buffer.append("<input type=\"radio\" name=\"" + field + "\" value=\"" + elementId + "\"" + checked + " />" + title + "</input><br/>\n");
+ }
+
+ block.replaceContent(field, buffer.toString());
+ }
+ }
+
+ @Override
+ public String getName() {
+ return "radio-list";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/widget/Selector.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/widget/Selector.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/widget/Selector.java
new file mode 100644
index 0000000..8c0b47e
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/widget/Selector.java
@@ -0,0 +1,158 @@
+/*
+ * 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.widget;
+
+import java.util.Iterator;
+
+import org.apache.isis.core.commons.exceptions.UnknownTypeException;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacet;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.util.MethodsUtils;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.action.ActionForm;
+import org.apache.isis.viewer.scimpi.dispatcher.view.action.CreateFormParameter;
+
+public class Selector extends AbstractElementProcessor {
+
+ @Override
+ public void process(final TagProcessor tagProcessor) {
+ final FormFieldBlock block = (FormFieldBlock) tagProcessor.getBlockContent();
+ final String field = tagProcessor.getRequiredProperty(FIELD);
+ if (block.isVisible(field)) {
+ processElement(tagProcessor, block, field);
+ }
+ tagProcessor.skipUntilClose();
+ }
+
+ private void processElement(final TagProcessor tagProcessor, final FormFieldBlock block, final String field) {
+ final String type = tagProcessor.getOptionalProperty(TYPE, "dropdown");
+ if (!tagProcessor.isPropertySpecified(METHOD) && tagProcessor.isPropertySpecified(COLLECTION)) {
+ final String id = tagProcessor.getRequiredProperty(COLLECTION, TagProcessor.NO_VARIABLE_CHECKING);
+ final String selector = showSelectionList(tagProcessor, id, block.getCurrent(field), block.isNullable(field), type);
+ block.replaceContent(field, selector);
+ } else {
+ final String objectId = tagProcessor.getOptionalProperty(OBJECT);
+ final String methodName = tagProcessor.getRequiredProperty(METHOD);
+ final ObjectAdapter object = MethodsUtils.findObject(tagProcessor.getContext(), objectId);
+ final ObjectAction action = MethodsUtils.findAction(object, methodName);
+ if (action.getParameterCount() == 0) {
+ final ObjectAdapter collection = action.execute(object, new ObjectAdapter[0]);
+ final String selector = showSelectionList(tagProcessor, collection, block.getCurrent(field), block.isNullable(field), type);
+ block.replaceContent(field, selector);
+ } else {
+ final String id = "selector_options";
+ final String id2 = (String) tagProcessor.getContext().getVariable(id);
+ final String selector = showSelectionList(tagProcessor, id2, block.getCurrent(field), block.isNullable(field), type);
+
+ final CreateFormParameter parameters = new CreateFormParameter();
+ parameters.objectId = objectId;
+ parameters.methodName = methodName;
+ parameters.buttonTitle = tagProcessor.getOptionalProperty(BUTTON_TITLE, "Search");
+ parameters.formTitle = tagProcessor.getOptionalProperty(FORM_TITLE);
+ parameters.className = tagProcessor.getOptionalProperty(CLASS, "selector");
+ parameters.id = tagProcessor.getOptionalProperty(ID);
+
+ parameters.resultName = id;
+ parameters.forwardResultTo = tagProcessor.getContext().getResourceFile();
+ parameters.forwardVoidTo = "error";
+ parameters.forwardErrorTo = parameters.forwardResultTo;
+ parameters.scope = Scope.REQUEST.name();
+ tagProcessor.pushNewBuffer();
+ ActionForm.createForm(tagProcessor, parameters);
+ block.replaceContent(field, selector);
+
+ tagProcessor.appendHtml(tagProcessor.popBuffer());
+ }
+ }
+ }
+
+ private String showSelectionList(final TagProcessor tagProcessor, final String collectionId, final ObjectAdapter selectedItem, final boolean allowNotSet, final String type) {
+ if (collectionId != null && !collectionId.equals("")) {
+ final ObjectAdapter collection = tagProcessor.getContext().getMappedObjectOrResult(collectionId);
+ return showSelectionList(tagProcessor, collection, selectedItem, allowNotSet, type);
+ } else {
+ return null;
+ }
+ }
+
+ private String showSelectionList(final TagProcessor tagProcessor, final ObjectAdapter collection, final ObjectAdapter selectedItem, final boolean allowNotSet, final String type) {
+ final String field = tagProcessor.getRequiredProperty(FIELD);
+ final CollectionFacet facet = collection.getSpecification().getFacet(CollectionFacet.class);
+
+ if (type.equals("radio")) {
+ return radioButtonList(tagProcessor, field, allowNotSet, collection, selectedItem, facet);
+ } else if (type.equals("list")) {
+ final String size = tagProcessor.getOptionalProperty("size", "5");
+ return dropdownList(tagProcessor, field, allowNotSet, collection, selectedItem, size, facet);
+ } else if (type.equals("dropdown")) {
+ return dropdownList(tagProcessor, field, allowNotSet, collection, selectedItem, null, facet);
+ } else {
+ throw new UnknownTypeException(type);
+ }
+ }
+
+ private String radioButtonList(final TagProcessor tagProcessor, final String field, final boolean allowNotSet, final ObjectAdapter collection, final ObjectAdapter selectedItem, final CollectionFacet facet) {
+ final Request context = tagProcessor.getContext();
+ final Iterator<ObjectAdapter> iterator = facet.iterator(collection);
+ final StringBuffer buffer = new StringBuffer();
+ if (allowNotSet) {
+ buffer.append("<input type=\"radio\" name=\"" + field + "\" value=\"null\"></input><br/>\n");
+ }
+ while (iterator.hasNext()) {
+ final ObjectAdapter element = iterator.next();
+ final String elementId = context.mapObject(element, Scope.INTERACTION);
+ final String title = element.titleString();
+ final String checked = element == selectedItem ? "checked=\"checked\"" : "";
+ buffer.append("<input type=\"radio\" name=\"" + field + "\" value=\"" + elementId + "\"" + checked + ">" + title + "</input><br/>\n");
+ }
+
+ return buffer.toString();
+ }
+
+ private String dropdownList(final TagProcessor tagProcessor, final String field, final boolean allowNotSet, final ObjectAdapter collection, final ObjectAdapter selectedItem, String size, final CollectionFacet facet) {
+ final Request context = tagProcessor.getContext();
+ final Iterator<ObjectAdapter> iterator = facet.iterator(collection);
+ final StringBuffer buffer = new StringBuffer();
+ size = size == null ? "" : " size =\"" + size + "\"";
+ buffer.append("<select name=\"" + field + "\"" + size + " >\n");
+ if (allowNotSet) {
+ buffer.append(" <option value=\"null\"></option>\n");
+ }
+ while (iterator.hasNext()) {
+ final ObjectAdapter element = iterator.next();
+ final String elementId = context.mapObject(element, Scope.INTERACTION);
+ final String title = element.titleString();
+ final String checked = element == selectedItem ? "selected=\"selected\"" : "";
+ buffer.append(" <option value=\"" + elementId + "\"" + checked + ">" + title + "</option>\n");
+ }
+ buffer.append("</select>\n");
+ return buffer.toString();
+ }
+
+ @Override
+ public String getName() {
+ return "selector";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/security/DebugUsers.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/security/DebugUsers.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/security/DebugUsers.java
new file mode 100644
index 0000000..212c6c5
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/security/DebugUsers.java
@@ -0,0 +1,97 @@
+/*
+ * 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.security;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+
+import org.apache.isis.core.commons.authentication.AuthenticationSession;
+import org.apache.isis.core.commons.config.ConfigurationConstants;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.viewer.scimpi.ScimpiException;
+
+public class DebugUsers {
+
+ private static Logger LOG = Logger.getLogger(DebugUsers.class);
+
+ private enum DebugMode {
+ OFF, ON, NAMED, SYSADMIN_ONLY
+ }
+
+ private static List<String> debugUsers = new ArrayList<String>();
+ private static DebugMode debugMode;
+
+ public void initialize() {
+ if (debugMode != null) {
+ throw new ScimpiException("Debug mode is already set up!");
+ }
+
+ final String debugUserEntry = IsisContext.getConfiguration().getString(ConfigurationConstants.ROOT + "scimpi.debug.users", "");
+ final String[] users = debugUserEntry.split("\\|");
+ for (final String name : users) {
+ debugUsers.add(name.trim());
+ }
+
+ final String debugModeEntry = IsisContext.getConfiguration().getString(ConfigurationConstants.ROOT + "scimpi.debug.mode");
+ if (debugModeEntry != null) {
+ try {
+ debugMode = DebugMode.valueOf(debugModeEntry.toUpperCase());
+ LOG.info("Debug mode set to " + debugMode);
+ } catch (final IllegalArgumentException e) {
+ LOG.error("Invalid debug mode - " + debugModeEntry + " - mode set to OFF");
+ debugMode = DebugMode.OFF;
+ }
+ } else {
+ debugMode = DebugMode.OFF;
+ }
+ }
+
+ public boolean isDebugEnabled(final AuthenticationSession session) {
+ if (debugMode == DebugMode.ON) {
+ return true;
+ } else if (session != null && debugMode == DebugMode.SYSADMIN_ONLY && session.getRoles().contains("sysadmin")) {
+ return true;
+ } else if (session != null && debugMode == DebugMode.NAMED && (debugUsers.contains(session.getUserName()) || session.getRoles().contains("sysadmin"))) {
+ return true;
+ }
+ return false;
+ }
+
+ public List<String> getNames() {
+ final ArrayList<String> users = new ArrayList<String>(debugUsers);
+ Collections.sort(users);
+ return users;
+ }
+
+ public void add(final String name) {
+ if (!debugUsers.contains(name)) {
+ debugUsers.add(name);
+ LOG.info("Added '" + debugMode + "' to debug users list");
+ }
+ }
+
+ public void remove(final String name) {
+ debugUsers.remove(name);
+ LOG.info("Removed '" + debugMode + "' from debug users list");
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/security/UserManager.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/security/UserManager.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/security/UserManager.java
new file mode 100644
index 0000000..db2b6d7
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/security/UserManager.java
@@ -0,0 +1,89 @@
+/*
+ * 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.security;
+
+import org.apache.isis.core.commons.authentication.AnonymousSession;
+import org.apache.isis.core.commons.authentication.AuthenticationSession;
+import org.apache.isis.core.runtime.authentication.AuthenticationManager;
+import org.apache.isis.core.runtime.authentication.AuthenticationRequestPassword;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.log4j.Logger;
+
+public class UserManager {
+
+ private static final Logger LOG = Logger.getLogger(UserManager.class);
+ private static UserManager instance;
+
+ private static AuthenticationManager getAuthenticationManager() {
+ if (instance == null) {
+ throw new IllegalStateException("Server initialisation failed, or not defined as a context listener");
+ }
+ return instance.authenticationManager;
+ }
+
+ public static AuthenticationSession startRequest(final AuthenticationSession session) {
+ AuthenticationSession useSession;
+ if (session == null) {
+ useSession = new AnonymousSession();
+ LOG.debug("start anonymous request: " + session);
+ } else {
+ useSession = session;
+ LOG.debug("start request for: " + session.getUserName());
+ }
+ IsisContext.closeSession();
+ IsisContext.openSession(useSession);
+ return useSession;
+ }
+
+ public static AuthenticationSession authenticate(final AuthenticationRequestPassword passwordAuthenticationRequest) {
+ final AuthenticationSession session = getAuthenticationManager().authenticate(passwordAuthenticationRequest);
+ if (session != null) {
+ LOG.info("log on user " + session.getUserName());
+ IsisContext.closeSession();
+ IsisContext.openSession(session);
+ }
+ return session;
+ }
+
+ public static void endRequest(final AuthenticationSession session) {
+ if (session == null) {
+ LOG.debug("end anonymous request");
+ } else {
+ LOG.debug("end request for: " + session.getUserName());
+ }
+ IsisContext.closeSession();
+ }
+
+ public static void logoffUser(final AuthenticationSession session) {
+ LOG.info("log off user " + session.getUserName());
+ IsisContext.closeSession();
+ getAuthenticationManager().closeSession(session);
+
+ final AnonymousSession replacementSession = new AnonymousSession();
+ IsisContext.openSession(replacementSession);
+ }
+
+ private final AuthenticationManager authenticationManager;
+
+ public UserManager(final AuthenticationManager authenticationManager) {
+ this.authenticationManager = authenticationManager;
+ UserManager.instance = this;
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/servlet/src/main/java/org/apache/isis/viewer/scimpi/servlet/DispatchException.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/servlet/src/main/java/org/apache/isis/viewer/scimpi/servlet/DispatchException.java b/component/viewer/scimpi/servlet/src/main/java/org/apache/isis/viewer/scimpi/servlet/DispatchException.java
index 6bb776c..9321fc1 100644
--- a/component/viewer/scimpi/servlet/src/main/java/org/apache/isis/viewer/scimpi/servlet/DispatchException.java
+++ b/component/viewer/scimpi/servlet/src/main/java/org/apache/isis/viewer/scimpi/servlet/DispatchException.java
@@ -19,7 +19,7 @@
package org.apache.isis.viewer.scimpi.servlet;
-import org.apache.isis.viewer.scimpi.dispatcher.ScimpiException;
+import org.apache.isis.viewer.scimpi.ScimpiException;
public class DispatchException extends ScimpiException {
private static final long serialVersionUID = 1L;
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/servlet/src/main/java/org/apache/isis/viewer/scimpi/servlet/DispatcherServlet.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/servlet/src/main/java/org/apache/isis/viewer/scimpi/servlet/DispatcherServlet.java b/component/viewer/scimpi/servlet/src/main/java/org/apache/isis/viewer/scimpi/servlet/DispatcherServlet.java
index 18d4709..0e61c46 100644
--- a/component/viewer/scimpi/servlet/src/main/java/org/apache/isis/viewer/scimpi/servlet/DispatcherServlet.java
+++ b/component/viewer/scimpi/servlet/src/main/java/org/apache/isis/viewer/scimpi/servlet/DispatcherServlet.java
@@ -29,8 +29,9 @@ import javax.servlet.http.HttpServletResponse;
import org.apache.isis.core.runtime.system.context.IsisContext;
import org.apache.isis.viewer.scimpi.dispatcher.Dispatcher;
-import org.apache.isis.viewer.scimpi.dispatcher.UserManager;
-import org.apache.isis.viewer.scimpi.dispatcher.debug.DebugUsers;
+import org.apache.isis.viewer.scimpi.dispatcher.Response;
+import org.apache.isis.viewer.scimpi.security.DebugUsers;
+import org.apache.isis.viewer.scimpi.security.UserManager;
import org.apache.log4j.Logger;
public class DispatcherServlet extends HttpServlet {
@@ -55,7 +56,8 @@ public class DispatcherServlet extends HttpServlet {
try {
final ServletRequestContext context = new ServletRequestContext(debugUsers);
context.startRequest(request, response, getServletContext());
- dispatcher.process(context, request.getServletPath());
+ Response resp = new Response() {};
+ dispatcher.process(context, resp, request.getServletPath());
} catch (final RuntimeException e) {
LOG.error("servlet exception", e);
throw e;
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/servlet/src/main/java/org/apache/isis/viewer/scimpi/servlet/ServletRequestContext.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/servlet/src/main/java/org/apache/isis/viewer/scimpi/servlet/ServletRequestContext.java b/component/viewer/scimpi/servlet/src/main/java/org/apache/isis/viewer/scimpi/servlet/ServletRequestContext.java
index 9b01b60..8c6386b 100644
--- a/component/viewer/scimpi/servlet/src/main/java/org/apache/isis/viewer/scimpi/servlet/ServletRequestContext.java
+++ b/component/viewer/scimpi/servlet/src/main/java/org/apache/isis/viewer/scimpi/servlet/ServletRequestContext.java
@@ -37,14 +37,14 @@ import javax.servlet.http.HttpSession;
import org.apache.isis.core.commons.debug.DebugBuilder;
import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.viewer.scimpi.ScimpiException;
import org.apache.isis.viewer.scimpi.dispatcher.DispatchException;
-import org.apache.isis.viewer.scimpi.dispatcher.ErrorCollator;
-import org.apache.isis.viewer.scimpi.dispatcher.ScimpiException;
import org.apache.isis.viewer.scimpi.dispatcher.ScimpiNotFoundException;
-import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext;
-import org.apache.isis.viewer.scimpi.dispatcher.debug.DebugUsers;
+import org.apache.isis.viewer.scimpi.dispatcher.context.ErrorCollator;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.security.DebugUsers;
-public class ServletRequestContext extends RequestContext {
+public class ServletRequestContext extends Request {
private HttpServletRequest request;
private HttpServletResponse response;
private ServletContext servletContext;
[24/24] git commit: Restructuring Scimpi to remove dependencies and
enable easier testing.
Posted by rm...@apache.org.
Restructuring Scimpi to remove dependencies and enable easier testing.
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/7700b437
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/7700b437
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/7700b437
Branch: refs/heads/scimpi-restructure
Commit: 7700b4371c740cb3ac84a808e32ed408721b1361
Parents: 49518c8
Author: rmatthews <rm...@nakedobjects.org>
Authored: Thu Jan 31 21:53:13 2013 +0000
Committer: rmatthews <rm...@nakedobjects.org>
Committed: Sun Mar 24 17:43:06 2013 +0000
----------------------------------------------------------------------
component/viewer/scimpi/dispatcher/pom.xml | 2 +-
.../apache/isis/viewer/scimpi/ScimpiContext.java | 38 +
.../scimpi/dispatcher/AddElementProcessors.java | 215 ------
.../isis/viewer/scimpi/dispatcher/Dispatcher.java | 42 +-
.../isis/viewer/scimpi/dispatcher/LocaleUtil.java | 101 +++
.../dispatcher/PreinstallElementProcessors.java | 215 ++++++
.../isis/viewer/scimpi/dispatcher/Response.java | 6 -
.../scimpi/dispatcher/RuntimeScimpiContext.java | 17 +
.../scimpi/dispatcher/ScimpiNotFoundException.java | 43 --
.../scimpi/dispatcher/TagOrderException.java | 32 -
.../apache/isis/viewer/scimpi/dispatcher/Util.java | 105 ---
.../scimpi/dispatcher/action/ActionAction.java | 4 +-
.../scimpi/dispatcher/action/DebugUserAction.java | 2 +-
.../scimpi/dispatcher/action/EditAction.java | 4 +-
.../scimpi/dispatcher/action/LogonAction.java | 6 +-
.../scimpi/dispatcher/action/LogoutAction.java | 4 +-
.../scimpi/dispatcher/context/DebugUsers.java | 97 +++
.../viewer/scimpi/dispatcher/context/Request.java | 7 +-
.../scimpi/dispatcher/context/RequestState.java | 47 ++
.../viewer/scimpi/dispatcher/context/Response.java | 6 +
.../context/ScimpiNotFoundException.java | 43 ++
.../scimpi/dispatcher/debug/DebugUsersView.java | 50 --
.../scimpi/dispatcher/debug/ErrorDetails.java | 35 -
.../scimpi/dispatcher/debug/ErrorMessage.java | 35 -
.../scimpi/dispatcher/debug/ErrorReference.java | 35 -
.../scimpi/dispatcher/form/FieldEditState.java | 57 ++
.../viewer/scimpi/dispatcher/form/FormState.java | 67 ++
.../scimpi/dispatcher/processor/Attributes.java | 132 ----
.../scimpi/dispatcher/processor/BlockContent.java | 5 +
.../processor/ElementContentProcessor.java | 25 -
.../dispatcher/processor/ElementProcessor.java | 13 +-
.../processor/ElementProcessorLookup.java | 57 ++
.../scimpi/dispatcher/processor/Encoder.java | 26 -
.../scimpi/dispatcher/processor/HtmlEncoder.java | 26 +
.../dispatcher/processor/HtmlFileParser.java | 8 +-
.../dispatcher/processor/ProcessorLookup.java | 50 --
.../scimpi/dispatcher/processor/SimpleEncoder.java | 32 -
.../scimpi/dispatcher/processor/Snippet.java | 4 +
.../viewer/scimpi/dispatcher/processor/SwfTag.java | 10 +-
.../scimpi/dispatcher/processor/TagAttributes.java | 137 ++++
.../dispatcher/processor/TagOrderException.java | 31 +
.../processor/TagProcessingException.java | 59 --
.../scimpi/dispatcher/processor/TagProcessor.java | 317 --------
.../processor/TemplateProcessingException.java | 59 ++
.../dispatcher/processor/TemplateProcessor.java | 318 ++++++++
.../dispatcher/structure/FieldEditState.java | 57 --
.../scimpi/dispatcher/structure/FormState.java | 67 --
.../scimpi/dispatcher/util/MethodsUtils.java | 3 +-
.../viewer/scimpi/dispatcher/util/UserManager.java | 89 +++
.../dispatcher/view/AbstractElementProcessor.java | 19 +-
.../dispatcher/view/AbstractObjectProcessor.java | 15 +-
.../dispatcher/view/action/ActionButton.java | 109 ++--
.../dispatcher/view/action/ActionContent.java | 6 +-
.../scimpi/dispatcher/view/action/ActionForm.java | 254 +------
.../scimpi/dispatcher/view/action/ActionLink.java | 53 +-
.../scimpi/dispatcher/view/action/ActionName.java | 48 ++
.../view/action/CreateFormParameter.java | 43 --
.../scimpi/dispatcher/view/action/Methods.java | 193 -----
.../dispatcher/view/action/NewActionLink.java | 63 ++
.../scimpi/dispatcher/view/action/Parameter.java | 15 +-
.../dispatcher/view/action/ParameterName.java | 63 ++
.../scimpi/dispatcher/view/action/RunAction.java | 23 +-
.../scimpi/dispatcher/view/action/Services.java | 67 --
.../view/collection/AbstractTableView.java | 150 ++++
.../dispatcher/view/collection/Collection.java | 27 +-
.../dispatcher/view/collection/CountElements.java | 54 ++
.../dispatcher/view/collection/ElementType.java | 62 ++
.../dispatcher/view/collection/ListView.java | 93 +++
.../dispatcher/view/collection/RemoveElement.java | 144 ++++
.../dispatcher/view/collection/TableBlock.java | 86 +++
.../dispatcher/view/collection/TableBuilder.java | 92 +++
.../dispatcher/view/collection/TableCell.java | 96 +++
.../view/collection/TableContentWriter.java | 39 +
.../dispatcher/view/collection/TableEmpty.java | 54 ++
.../dispatcher/view/collection/TableHeader.java | 40 +
.../dispatcher/view/collection/TableRow.java | 50 ++
.../dispatcher/view/collection/TableView.java | 328 +++++++++
.../view/control/AbstractConditionalBlock.java | 563 +++++++++++++++
.../scimpi/dispatcher/view/control/Forward.java | 38 +
.../scimpi/dispatcher/view/control/Redirect.java | 38 +
.../scimpi/dispatcher/view/control/Unless.java | 41 +
.../scimpi/dispatcher/view/control/When.java | 41 +
.../viewer/scimpi/dispatcher/view/debug/Debug.java | 157 ++--
.../dispatcher/view/debug/DebugAccessCheck.java | 7 +-
.../dispatcher/view/debug/DebugCollectionView.java | 31 +-
.../dispatcher/view/debug/DebugObjectView.java | 66 +-
.../dispatcher/view/debug/DebugUsersView.java | 51 ++
.../scimpi/dispatcher/view/debug/DebuggerLink.java | 26 +-
.../scimpi/dispatcher/view/debug/Diagnostics.java | 53 +-
.../viewer/scimpi/dispatcher/view/debug/Log.java | 13 +-
.../scimpi/dispatcher/view/debug/LogLevel.java | 27 +-
.../scimpi/dispatcher/view/debug/Members.java | 39 +-
.../scimpi/dispatcher/view/debug/ShowDebug.java | 11 +-
.../dispatcher/view/debug/Specification.java | 51 +-
.../dispatcher/view/debug/ThrowException.java | 9 +-
.../scimpi/dispatcher/view/determine/Exclude.java | 40 +
.../scimpi/dispatcher/view/determine/Include.java | 40 +
.../dispatcher/view/determine/InclusionList.java | 80 ++
.../scimpi/dispatcher/view/determine/Link.java | 45 ++
.../view/determine/LinkedFieldsBlock.java | 47 ++
.../dispatcher/view/determine/LinkedObject.java | 58 ++
.../dispatcher/view/display/AbstractFormView.java | 142 ----
.../dispatcher/view/display/AbstractTableView.java | 149 ----
.../scimpi/dispatcher/view/display/AddMessage.java | 44 --
.../scimpi/dispatcher/view/display/AddWarning.java | 44 --
.../scimpi/dispatcher/view/display/Errors.java | 65 --
.../scimpi/dispatcher/view/display/Feedback.java | 46 --
.../scimpi/dispatcher/view/display/FieldLabel.java | 77 --
.../scimpi/dispatcher/view/display/FieldValue.java | 118 ---
.../scimpi/dispatcher/view/display/GetField.java | 103 ---
.../dispatcher/view/display/IncludeObject.java | 107 ---
.../scimpi/dispatcher/view/display/ListView.java | 93 ---
.../dispatcher/view/display/LongFormView.java | 85 ---
.../scimpi/dispatcher/view/display/Messages.java | 60 --
.../dispatcher/view/display/SelectedObject.java | 55 --
.../dispatcher/view/display/ShortFormView.java | 36 -
.../scimpi/dispatcher/view/display/TableBlock.java | 86 ---
.../dispatcher/view/display/TableBuilder.java | 92 ---
.../scimpi/dispatcher/view/display/TableCell.java | 95 ---
.../view/display/TableContentWriter.java | 39 -
.../scimpi/dispatcher/view/display/TableEmpty.java | 53 --
.../dispatcher/view/display/TableHeader.java | 39 -
.../scimpi/dispatcher/view/display/TableRow.java | 49 --
.../scimpi/dispatcher/view/display/TableView.java | 329 ---------
.../scimpi/dispatcher/view/display/Title.java | 68 --
.../scimpi/dispatcher/view/display/Warnings.java | 59 --
.../scimpi/dispatcher/view/edit/EditObject.java | 320 --------
.../scimpi/dispatcher/view/field/ExcludeField.java | 39 -
.../scimpi/dispatcher/view/field/IncludeField.java | 39 -
.../dispatcher/view/field/InclusionList.java | 89 ---
.../scimpi/dispatcher/view/field/LinkField.java | 44 --
.../dispatcher/view/field/LinkedFieldsBlock.java | 47 --
.../scimpi/dispatcher/view/field/LinkedObject.java | 58 --
.../dispatcher/view/form/ActionFormAbstract.java | 223 ++++++
.../dispatcher/view/form/CreateFormParameter.java | 43 ++
.../dispatcher/view/form/EditFormAbstract.java | 171 +++++
.../scimpi/dispatcher/view/form/FieldFactory.java | 104 +++
.../scimpi/dispatcher/view/form/FormEntry.java | 45 ++
.../scimpi/dispatcher/view/form/FormField.java | 45 ++
.../dispatcher/view/form/FormFieldBlock.java | 67 ++
.../scimpi/dispatcher/view/form/HiddenField.java | 49 ++
.../dispatcher/view/form/HtmlFormBuilder.java | 91 ++--
.../dispatcher/view/form/LogonFormAbstract.java | 86 +++
.../dispatcher/view/form/RadioListField.java | 71 ++
.../scimpi/dispatcher/view/form/Selector.java | 157 ++++
.../scimpi/dispatcher/view/form/SimpleButton.java | 40 +
.../scimpi/dispatcher/view/global/Commit.java | 46 ++
.../scimpi/dispatcher/view/global/Methods.java | 197 +++++
.../scimpi/dispatcher/view/global/Services.java | 68 ++
.../dispatcher/view/localization/Localization.java | 65 ++
.../view/localization/SetLocalization.java | 65 ++
.../scimpi/dispatcher/view/logon/Logoff.java | 38 -
.../viewer/scimpi/dispatcher/view/logon/Logon.java | 124 ----
.../dispatcher/view/logon/RestrictAccess.java | 41 -
.../scimpi/dispatcher/view/logon/Secure.java | 45 --
.../viewer/scimpi/dispatcher/view/logon/User.java | 77 --
.../scimpi/dispatcher/view/message/AddMessage.java | 45 ++
.../scimpi/dispatcher/view/message/AddWarning.java | 45 ++
.../dispatcher/view/message/ErrorDetails.java | 36 +
.../dispatcher/view/message/ErrorMessage.java | 37 +
.../dispatcher/view/message/ErrorReference.java | 36 +
.../scimpi/dispatcher/view/message/Errors.java | 66 ++
.../scimpi/dispatcher/view/message/Feedback.java | 47 ++
.../scimpi/dispatcher/view/message/Messages.java | 61 ++
.../scimpi/dispatcher/view/message/Warnings.java | 60 ++
.../scimpi/dispatcher/view/object/EditLink.java | 71 ++
.../scimpi/dispatcher/view/object/EditObject.java | 171 +++++
.../scimpi/dispatcher/view/object/FieldLabel.java | 78 ++
.../scimpi/dispatcher/view/object/FieldName.java | 66 ++
.../scimpi/dispatcher/view/object/FieldValue.java | 119 +++
.../scimpi/dispatcher/view/object/GetField.java | 104 +++
.../dispatcher/view/object/IncludeObject.java | 108 +++
.../dispatcher/view/object/LinkAbstract.java | 122 ++++
.../dispatcher/view/object/LongViewForm.java | 87 +++
.../scimpi/dispatcher/view/object/ObjectLink.java | 68 ++
.../dispatcher/view/object/SelectedObject.java | 56 ++
.../dispatcher/view/object/ShortViewForm.java | 36 +
.../scimpi/dispatcher/view/object/Title.java | 69 ++
.../scimpi/dispatcher/view/object/TitleString.java | 69 ++
.../viewer/scimpi/dispatcher/view/object/Type.java | 58 ++
.../dispatcher/view/object/ViewFormAbstract.java | 142 ++++
.../scimpi/dispatcher/view/other/HelpLink.java | 13 +-
.../scimpi/dispatcher/view/other/History.java | 45 +-
.../dispatcher/view/other/VersionNumber.java | 9 +-
.../dispatcher/view/security/EndSession.java | 37 +
.../scimpi/dispatcher/view/security/Logoff.java | 39 +
.../scimpi/dispatcher/view/security/Logon.java | 51 ++
.../dispatcher/view/security/RestrictAccess.java | 42 ++
.../scimpi/dispatcher/view/security/Secure.java | 46 ++
.../dispatcher/view/security/StartSession.java | 37 +
.../scimpi/dispatcher/view/security/User.java | 78 ++
.../view/simple/AbstractConditionalBlock.java | 562 --------------
.../dispatcher/view/simple/AbstractLink.java | 121 ---
.../scimpi/dispatcher/view/simple/BlockDefine.java | 42 --
.../scimpi/dispatcher/view/simple/BlockUse.java | 46 --
.../scimpi/dispatcher/view/simple/Commit.java | 45 --
.../scimpi/dispatcher/view/simple/ContentTag.java | 36 -
.../scimpi/dispatcher/view/simple/CookieValue.java | 46 --
.../dispatcher/view/simple/DefaultValue.java | 52 --
.../scimpi/dispatcher/view/simple/EditLink.java | 71 --
.../scimpi/dispatcher/view/simple/EndSession.java | 36 -
.../scimpi/dispatcher/view/simple/Forward.java | 37 -
.../scimpi/dispatcher/view/simple/GetCookie.java | 39 -
.../scimpi/dispatcher/view/simple/Import.java | 37 -
.../view/simple/InitializeFromCookie.java | 81 --
.../view/simple/InitializeFromResult.java | 78 --
.../dispatcher/view/simple/Localization.java | 64 --
.../viewer/scimpi/dispatcher/view/simple/Mark.java | 43 --
.../dispatcher/view/simple/NewActionLink.java | 62 --
.../scimpi/dispatcher/view/simple/ObjectLink.java | 68 --
.../scimpi/dispatcher/view/simple/PageTitle.java | 35 -
.../scimpi/dispatcher/view/simple/Redirect.java | 37 -
.../dispatcher/view/simple/RemoveElement.java | 143 ----
.../scimpi/dispatcher/view/simple/ScopeTag.java | 51 --
.../scimpi/dispatcher/view/simple/SetCookie.java | 53 --
.../dispatcher/view/simple/SetCookieFromField.java | 55 --
.../dispatcher/view/simple/SetFieldFromCookie.java | 52 --
.../dispatcher/view/simple/SetLocalization.java | 64 --
.../dispatcher/view/simple/SimpleButton.java | 39 -
.../dispatcher/view/simple/StartSession.java | 36 -
.../scimpi/dispatcher/view/simple/TemplateTag.java | 40 -
.../scimpi/dispatcher/view/simple/Unless.java | 41 -
.../scimpi/dispatcher/view/simple/Variable.java | 64 --
.../viewer/scimpi/dispatcher/view/simple/When.java | 41 -
.../dispatcher/view/structure/BlockDefine.java | 43 ++
.../scimpi/dispatcher/view/structure/BlockUse.java | 47 ++
.../dispatcher/view/structure/ContentTag.java | 40 +
.../scimpi/dispatcher/view/structure/Import.java | 38 +
.../scimpi/dispatcher/view/structure/Mark.java | 44 ++
.../dispatcher/view/structure/TemplateTag.java | 44 ++
.../scimpi/dispatcher/view/value/ActionName.java | 47 --
.../dispatcher/view/value/CountElements.java | 54 --
.../scimpi/dispatcher/view/value/ElementType.java | 61 --
.../scimpi/dispatcher/view/value/FieldName.java | 65 --
.../dispatcher/view/value/ParameterName.java | 62 --
.../scimpi/dispatcher/view/value/TitleString.java | 68 --
.../viewer/scimpi/dispatcher/view/value/Type.java | 57 --
.../dispatcher/view/variable/ChangeScope.java | 52 ++
.../dispatcher/view/variable/CookieValue.java | 47 ++
.../dispatcher/view/variable/DefaultValue.java | 53 ++
.../scimpi/dispatcher/view/variable/GetCookie.java | 40 +
.../view/variable/InitializeFromCookie.java | 82 +++
.../view/variable/InitializeFromResult.java | 79 ++
.../scimpi/dispatcher/view/variable/PageTitle.java | 36 +
.../scimpi/dispatcher/view/variable/SetCookie.java | 54 ++
.../view/variable/SetCookieFromField.java | 56 ++
.../view/variable/SetFieldFromCookie.java | 53 ++
.../scimpi/dispatcher/view/variable/Variable.java | 65 ++
.../dispatcher/view/widget/FieldFactory.java | 105 ---
.../scimpi/dispatcher/view/widget/FormEntry.java | 44 --
.../scimpi/dispatcher/view/widget/FormField.java | 44 --
.../dispatcher/view/widget/FormFieldBlock.java | 68 --
.../scimpi/dispatcher/view/widget/HiddenField.java | 48 --
.../dispatcher/view/widget/RadioListField.java | 70 --
.../scimpi/dispatcher/view/widget/Selector.java | 158 ----
.../isis/viewer/scimpi/security/DebugUsers.java | 97 ---
.../isis/viewer/scimpi/security/UserManager.java | 89 ---
.../dispatcher/view/ElementProcessorTest.java | 61 ++
.../scimpi/dispatcher/view/TestRequestState.java | 32 +
.../dispatcher/view/message/ErrorMessageTest.java | 42 ++
component/viewer/scimpi/pom.xml | 2 +-
component/viewer/scimpi/servlet/pom.xml | 2 +-
.../viewer/scimpi/servlet/DispatcherServlet.java | 6 +-
.../scimpi/servlet/ServletRequestContext.java | 4 +-
264 files changed, 9256 insertions(+), 8899 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/pom.xml
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/pom.xml b/component/viewer/scimpi/dispatcher/pom.xml
index 44ed076..7c5d950 100644
--- a/component/viewer/scimpi/dispatcher/pom.xml
+++ b/component/viewer/scimpi/dispatcher/pom.xml
@@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.isis.viewer</groupId>
<artifactId>isis-viewer-scimpi</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>1.0.0-restructure-SNAPSHOT</version>
</parent>
<artifactId>isis-viewer-scimpi-dispatcher</artifactId>
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/ScimpiContext.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/ScimpiContext.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/ScimpiContext.java
new file mode 100644
index 0000000..9e1395e
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/ScimpiContext.java
@@ -0,0 +1,38 @@
+/*
+ * 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;
+
+import org.apache.isis.core.commons.config.ConfigurationConstants;
+import org.apache.isis.core.commons.config.IsisConfiguration;
+
+public interface ScimpiContext {
+
+ static String BASE = ConfigurationConstants.ROOT + "scimpi.";
+
+ /**
+ * Returns the full configuration name for the provided name. This will include the overall isis project
+ * prefix (isis) and the viewer prefix (scimpi). So passing in 'show-icon' will return
+ * 'isis.scimpi.show-icon'.
+ */
+ String configurationName(String name);
+
+ IsisConfiguration getConfiguration();
+}
+
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/AddElementProcessors.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/AddElementProcessors.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/AddElementProcessors.java
deleted file mode 100644
index ad51add..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/AddElementProcessors.java
+++ /dev/null
@@ -1,215 +0,0 @@
-package org.apache.isis.viewer.scimpi.dispatcher;
-
-import org.apache.isis.viewer.scimpi.dispatcher.debug.DebugUsersView;
-import org.apache.isis.viewer.scimpi.dispatcher.debug.ErrorDetails;
-import org.apache.isis.viewer.scimpi.dispatcher.debug.ErrorMessage;
-import org.apache.isis.viewer.scimpi.dispatcher.debug.ErrorReference;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.ProcessorLookup;
-import org.apache.isis.viewer.scimpi.dispatcher.view.action.ActionButton;
-import org.apache.isis.viewer.scimpi.dispatcher.view.action.ActionForm;
-import org.apache.isis.viewer.scimpi.dispatcher.view.action.ActionLink;
-import org.apache.isis.viewer.scimpi.dispatcher.view.action.Methods;
-import org.apache.isis.viewer.scimpi.dispatcher.view.action.Parameter;
-import org.apache.isis.viewer.scimpi.dispatcher.view.action.RunAction;
-import org.apache.isis.viewer.scimpi.dispatcher.view.action.Services;
-import org.apache.isis.viewer.scimpi.dispatcher.view.collection.Collection;
-import org.apache.isis.viewer.scimpi.dispatcher.view.debug.DebugAccessCheck;
-import org.apache.isis.viewer.scimpi.dispatcher.view.debug.DebugCollectionView;
-import org.apache.isis.viewer.scimpi.dispatcher.view.debug.DebugObjectView;
-import org.apache.isis.viewer.scimpi.dispatcher.view.debug.DebuggerLink;
-import org.apache.isis.viewer.scimpi.dispatcher.view.debug.Diagnostics;
-import org.apache.isis.viewer.scimpi.dispatcher.view.debug.Log;
-import org.apache.isis.viewer.scimpi.dispatcher.view.debug.LogLevel;
-import org.apache.isis.viewer.scimpi.dispatcher.view.debug.Members;
-import org.apache.isis.viewer.scimpi.dispatcher.view.debug.ShowDebug;
-import org.apache.isis.viewer.scimpi.dispatcher.view.debug.Specification;
-import org.apache.isis.viewer.scimpi.dispatcher.view.debug.ThrowException;
-import org.apache.isis.viewer.scimpi.dispatcher.view.display.AddMessage;
-import org.apache.isis.viewer.scimpi.dispatcher.view.display.AddWarning;
-import org.apache.isis.viewer.scimpi.dispatcher.view.display.Errors;
-import org.apache.isis.viewer.scimpi.dispatcher.view.display.Feedback;
-import org.apache.isis.viewer.scimpi.dispatcher.view.display.FieldLabel;
-import org.apache.isis.viewer.scimpi.dispatcher.view.display.FieldValue;
-import org.apache.isis.viewer.scimpi.dispatcher.view.display.GetField;
-import org.apache.isis.viewer.scimpi.dispatcher.view.display.IncludeObject;
-import org.apache.isis.viewer.scimpi.dispatcher.view.display.ListView;
-import org.apache.isis.viewer.scimpi.dispatcher.view.display.LongFormView;
-import org.apache.isis.viewer.scimpi.dispatcher.view.display.Messages;
-import org.apache.isis.viewer.scimpi.dispatcher.view.display.SelectedObject;
-import org.apache.isis.viewer.scimpi.dispatcher.view.display.ShortFormView;
-import org.apache.isis.viewer.scimpi.dispatcher.view.display.TableBuilder;
-import org.apache.isis.viewer.scimpi.dispatcher.view.display.TableCell;
-import org.apache.isis.viewer.scimpi.dispatcher.view.display.TableEmpty;
-import org.apache.isis.viewer.scimpi.dispatcher.view.display.TableHeader;
-import org.apache.isis.viewer.scimpi.dispatcher.view.display.TableRow;
-import org.apache.isis.viewer.scimpi.dispatcher.view.display.TableView;
-import org.apache.isis.viewer.scimpi.dispatcher.view.display.Title;
-import org.apache.isis.viewer.scimpi.dispatcher.view.display.Warnings;
-import org.apache.isis.viewer.scimpi.dispatcher.view.edit.EditObject;
-import org.apache.isis.viewer.scimpi.dispatcher.view.field.ExcludeField;
-import org.apache.isis.viewer.scimpi.dispatcher.view.field.IncludeField;
-import org.apache.isis.viewer.scimpi.dispatcher.view.field.LinkField;
-import org.apache.isis.viewer.scimpi.dispatcher.view.logon.Logoff;
-import org.apache.isis.viewer.scimpi.dispatcher.view.logon.Logon;
-import org.apache.isis.viewer.scimpi.dispatcher.view.logon.RestrictAccess;
-import org.apache.isis.viewer.scimpi.dispatcher.view.logon.Secure;
-import org.apache.isis.viewer.scimpi.dispatcher.view.logon.User;
-import org.apache.isis.viewer.scimpi.dispatcher.view.other.HelpLink;
-import org.apache.isis.viewer.scimpi.dispatcher.view.other.History;
-import org.apache.isis.viewer.scimpi.dispatcher.view.other.VersionNumber;
-import org.apache.isis.viewer.scimpi.dispatcher.view.simple.BlockDefine;
-import org.apache.isis.viewer.scimpi.dispatcher.view.simple.BlockUse;
-import org.apache.isis.viewer.scimpi.dispatcher.view.simple.Commit;
-import org.apache.isis.viewer.scimpi.dispatcher.view.simple.ContentTag;
-import org.apache.isis.viewer.scimpi.dispatcher.view.simple.CookieValue;
-import org.apache.isis.viewer.scimpi.dispatcher.view.simple.DefaultValue;
-import org.apache.isis.viewer.scimpi.dispatcher.view.simple.EditLink;
-import org.apache.isis.viewer.scimpi.dispatcher.view.simple.EndSession;
-import org.apache.isis.viewer.scimpi.dispatcher.view.simple.Forward;
-import org.apache.isis.viewer.scimpi.dispatcher.view.simple.GetCookie;
-import org.apache.isis.viewer.scimpi.dispatcher.view.simple.Import;
-import org.apache.isis.viewer.scimpi.dispatcher.view.simple.InitializeFromCookie;
-import org.apache.isis.viewer.scimpi.dispatcher.view.simple.InitializeFromResult;
-import org.apache.isis.viewer.scimpi.dispatcher.view.simple.Localization;
-import org.apache.isis.viewer.scimpi.dispatcher.view.simple.Mark;
-import org.apache.isis.viewer.scimpi.dispatcher.view.simple.NewActionLink;
-import org.apache.isis.viewer.scimpi.dispatcher.view.simple.ObjectLink;
-import org.apache.isis.viewer.scimpi.dispatcher.view.simple.PageTitle;
-import org.apache.isis.viewer.scimpi.dispatcher.view.simple.Redirect;
-import org.apache.isis.viewer.scimpi.dispatcher.view.simple.RemoveElement;
-import org.apache.isis.viewer.scimpi.dispatcher.view.simple.ScopeTag;
-import org.apache.isis.viewer.scimpi.dispatcher.view.simple.SetCookie;
-import org.apache.isis.viewer.scimpi.dispatcher.view.simple.SetCookieFromField;
-import org.apache.isis.viewer.scimpi.dispatcher.view.simple.SetFieldFromCookie;
-import org.apache.isis.viewer.scimpi.dispatcher.view.simple.SetLocalization;
-import org.apache.isis.viewer.scimpi.dispatcher.view.simple.SimpleButton;
-import org.apache.isis.viewer.scimpi.dispatcher.view.simple.StartSession;
-import org.apache.isis.viewer.scimpi.dispatcher.view.simple.TemplateTag;
-import org.apache.isis.viewer.scimpi.dispatcher.view.simple.Unless;
-import org.apache.isis.viewer.scimpi.dispatcher.view.simple.Variable;
-import org.apache.isis.viewer.scimpi.dispatcher.view.simple.When;
-import org.apache.isis.viewer.scimpi.dispatcher.view.value.ActionName;
-import org.apache.isis.viewer.scimpi.dispatcher.view.value.CountElements;
-import org.apache.isis.viewer.scimpi.dispatcher.view.value.ElementType;
-import org.apache.isis.viewer.scimpi.dispatcher.view.value.FieldName;
-import org.apache.isis.viewer.scimpi.dispatcher.view.value.ParameterName;
-import org.apache.isis.viewer.scimpi.dispatcher.view.value.TitleString;
-import org.apache.isis.viewer.scimpi.dispatcher.view.value.Type;
-import org.apache.isis.viewer.scimpi.dispatcher.view.widget.FormEntry;
-import org.apache.isis.viewer.scimpi.dispatcher.view.widget.FormField;
-import org.apache.isis.viewer.scimpi.dispatcher.view.widget.HiddenField;
-import org.apache.isis.viewer.scimpi.dispatcher.view.widget.RadioListField;
-import org.apache.isis.viewer.scimpi.dispatcher.view.widget.Selector;
-
-public class AddElementProcessors {
-
- public static void init(ProcessorLookup processors) {
-
- processors.addElementProcessor(new ActionLink());
- processors.addElementProcessor(new ActionButton());
- processors.addElementProcessor(new ActionForm());
- processors.addElementProcessor(new ActionName());
- processors.addElementProcessor(new AddMessage());
- processors.addElementProcessor(new AddWarning());
- processors.addElementProcessor(new BlockDefine());
- processors.addElementProcessor(new BlockUse());
- processors.addElementProcessor(new History());
- processors.addElementProcessor(new Collection());
- processors.addElementProcessor(new Commit());
- processors.addElementProcessor(new ContentTag());
- processors.addElementProcessor(new CountElements());
- processors.addElementProcessor(new Diagnostics());
- processors.addElementProcessor(new DebugAccessCheck());
- processors.addElementProcessor(new DebugCollectionView());
- processors.addElementProcessor(new DebuggerLink());
- processors.addElementProcessor(new DebugObjectView());
- processors.addElementProcessor(new DebugUsersView());
- processors.addElementProcessor(new DefaultValue());
- processors.addElementProcessor(new EditLink());
- processors.addElementProcessor(new EditObject());
- processors.addElementProcessor(new ElementType());
- processors.addElementProcessor(new Errors());
- processors.addElementProcessor(new ErrorDetails());
- processors.addElementProcessor(new ErrorMessage());
- processors.addElementProcessor(new ErrorReference());
- processors.addElementProcessor(new ExcludeField());
- processors.addElementProcessor(new Feedback());
- processors.addElementProcessor(new FieldLabel());
- processors.addElementProcessor(new FieldName());
- processors.addElementProcessor(new FieldValue());
- processors.addElementProcessor(new FormField());
- processors.addElementProcessor(new FormEntry());
- processors.addElementProcessor(new Forward());
- processors.addElementProcessor(new GetField());
- processors.addElementProcessor(new HelpLink());
- processors.addElementProcessor(new HiddenField());
- processors.addElementProcessor(new Import());
- processors.addElementProcessor(new IncludeObject());
- processors.addElementProcessor(new IncludeField());
- processors.addElementProcessor(new InitializeFromCookie());
- processors.addElementProcessor(new InitializeFromResult());
- processors.addElementProcessor(new Log());
- processors.addElementProcessor(new LogLevel());
- processors.addElementProcessor(new Logon());
- processors.addElementProcessor(new Logoff());
- processors.addElementProcessor(new LongFormView());
- processors.addElementProcessor(new LinkField());
- processors.addElementProcessor(new ListView());
- processors.addElementProcessor(new NewActionLink());
- processors.addElementProcessor(new Mark());
- processors.addElementProcessor(new Members());
- processors.addElementProcessor(new Messages());
- processors.addElementProcessor(new Methods());
- processors.addElementProcessor(new ObjectLink());
- processors.addElementProcessor(new PageTitle());
- processors.addElementProcessor(new Parameter());
- processors.addElementProcessor(new ParameterName());
- processors.addElementProcessor(new RadioListField());
- processors.addElementProcessor(new Redirect());
- processors.addElementProcessor(new RemoveElement());
- processors.addElementProcessor(new VersionNumber());
- processors.addElementProcessor(new RunAction());
- processors.addElementProcessor(new RestrictAccess());
- processors.addElementProcessor(new ScopeTag());
- processors.addElementProcessor(new Secure());
- processors.addElementProcessor(new SelectedObject());
- processors.addElementProcessor(new Selector());
- processors.addElementProcessor(new Services());
- processors.addElementProcessor(new ShortFormView());
- processors.addElementProcessor(new ShowDebug());
- processors.addElementProcessor(new SimpleButton());
- processors.addElementProcessor(new Specification());
- processors.addElementProcessor(new TableCell());
- processors.addElementProcessor(new TableView());
- processors.addElementProcessor(new TableBuilder());
- processors.addElementProcessor(new TableEmpty());
- processors.addElementProcessor(new TableRow());
- processors.addElementProcessor(new TableHeader());
- processors.addElementProcessor(new TemplateTag());
- processors.addElementProcessor(new Title());
- processors.addElementProcessor(new TitleString());
- processors.addElementProcessor(new ThrowException());
- processors.addElementProcessor(new Type());
- processors.addElementProcessor(new User());
- processors.addElementProcessor(new Unless());
- processors.addElementProcessor(new Variable());
- processors.addElementProcessor(new Warnings());
- processors.addElementProcessor(new When());
-
- processors.addElementProcessor(new StartSession());
- processors.addElementProcessor(new EndSession());
-
- processors.addElementProcessor(new CookieValue());
- processors.addElementProcessor(new SetCookie());
- processors.addElementProcessor(new GetCookie());
- processors.addElementProcessor(new SetCookieFromField());
- processors.addElementProcessor(new SetFieldFromCookie());
-
- // new, alpha, processors
- processors.addElementProcessor(new Localization());
- processors.addElementProcessor(new SetLocalization());
-
- }
-
-}
-
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/Dispatcher.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/Dispatcher.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/Dispatcher.java
index f5e2e5e..3a87184 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/Dispatcher.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/Dispatcher.java
@@ -54,6 +54,7 @@ import org.apache.isis.viewer.scimpi.DebugHtmlWriter;
import org.apache.isis.viewer.scimpi.ForbiddenException;
import org.apache.isis.viewer.scimpi.Names;
import org.apache.isis.viewer.scimpi.NotLoggedInException;
+import org.apache.isis.viewer.scimpi.ScimpiContext;
import org.apache.isis.viewer.scimpi.ScimpiException;
import org.apache.isis.viewer.scimpi.dispatcher.action.ActionAction;
import org.apache.isis.viewer.scimpi.dispatcher.action.DebugAction;
@@ -64,21 +65,21 @@ import org.apache.isis.viewer.scimpi.dispatcher.action.LogonAction;
import org.apache.isis.viewer.scimpi.dispatcher.action.LogoutAction;
import org.apache.isis.viewer.scimpi.dispatcher.action.RemoveAction;
import org.apache.isis.viewer.scimpi.dispatcher.context.Action;
+import org.apache.isis.viewer.scimpi.dispatcher.context.DebugUsers;
import org.apache.isis.viewer.scimpi.dispatcher.context.ErrorCollator;
import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Response;
+import org.apache.isis.viewer.scimpi.dispatcher.context.ScimpiNotFoundException;
import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Debug;
import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
import org.apache.isis.viewer.scimpi.dispatcher.processor.ElementProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Encoder;
import org.apache.isis.viewer.scimpi.dispatcher.processor.HtmlFileParser;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.ProcessorLookup;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.SimpleEncoder;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.ElementProcessorLookup;
import org.apache.isis.viewer.scimpi.dispatcher.processor.Snippet;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessingException;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessingException;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
import org.apache.isis.viewer.scimpi.dispatcher.util.MethodsUtils;
-import org.apache.isis.viewer.scimpi.security.DebugUsers;
-import org.apache.isis.viewer.scimpi.security.UserManager;
+import org.apache.isis.viewer.scimpi.dispatcher.util.UserManager;
import org.apache.log4j.Logger;
import org.dom4j.Document;
import org.dom4j.DocumentException;
@@ -102,11 +103,16 @@ public class Dispatcher implements Debuggable {
public static final String COMMAND_ROOT = ".app";
private final Map<String, Action> actions = new HashMap<String, Action>();
private final Map<String, String> parameters = new HashMap<String, String>();
- private final ProcessorLookup processors = new ProcessorLookup();
- private final HtmlFileParser parser = new HtmlFileParser(processors);
- private final Encoder encoder = new SimpleEncoder();
+ private final ElementProcessorLookup processors;
+ private final HtmlFileParser parser;
private boolean showUnshownMessages;
+ public Dispatcher() {
+ ScimpiContext context = new RuntimeScimpiContext();
+ processors = new ElementProcessorLookup(context);
+ parser = new HtmlFileParser(processors);
+ }
+
public void process(final Request request, final Response response, final String servletPath) {
LOG.debug("processing request " + servletPath);
final AuthenticationSession session = UserManager.startRequest(request.getSession());
@@ -114,8 +120,8 @@ public class Dispatcher implements Debuggable {
String language = (String) request.getVariable("user-language");
if (language != null) {
- Locale locale = Util.locale(language);
- TimeZone timeZone = Util.timeZone((String) request.getVariable("user-time-zone"));
+ Locale locale = LocaleUtil.locale(language);
+ TimeZone timeZone = LocaleUtil.timeZone((String) request.getVariable("user-time-zone"));
IsisContext.getUserProfile().setLocalization(new UserLocalization(locale, timeZone));
}
@@ -147,7 +153,7 @@ public class Dispatcher implements Debuggable {
transactionManager.startTransaction();
}
- final Throwable ex = e instanceof TagProcessingException ? e.getCause() : e;
+ final Throwable ex = e instanceof TemplateProcessingException ? e.getCause() : e;
if (ex instanceof ForbiddenException) {
LOG.error("invalid access to " + servletPath, e);
show403ErrorPage(request, error, e, ex);
@@ -288,10 +294,10 @@ public class Dispatcher implements Debuggable {
context.addVariable("title", "Untitled Page", Scope.REQUEST);
final Stack<Snippet> tags = loadPageTemplate(context, fullPath);
- final TagProcessor tagProcessor = new TagProcessor(file, context, encoder, tags, processors);
- tagProcessor.appendDebug("processing " + fullPath);
+ final TemplateProcessor templateProcessor = new TemplateProcessor(file, context, context, tags, processors);
+ templateProcessor.appendDebug("processing " + fullPath);
try {
- tagProcessor.processNextTag();
+ templateProcessor.processNextTag();
noteIfMessagesHaveNotBeenDisplay(context);
IsisContext.getUpdateNotifier().clear();
} catch (final RuntimeException e) {
@@ -300,7 +306,7 @@ public class Dispatcher implements Debuggable {
IsisContext.getUpdateNotifier().clear();
throw e;
}
- final String page = tagProcessor.popBuffer();
+ final String page = templateProcessor.popBuffer();
final PrintWriter writer = context.getWriter();
writer.write(page);
if (context.getDebug() == Debug.PAGE) {
@@ -432,7 +438,7 @@ public class Dispatcher implements Debuggable {
}
}
- AddElementProcessors.init(processors);
+ PreinstallElementProcessors.init(processors);
processors.addElementProcessor(new org.apache.isis.viewer.scimpi.dispatcher.view.debug.Debug(this));
showUnshownMessages = IsisContext.getConfiguration().getBoolean(SHOW_UNSHOWN_MESSAGES, true);
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/LocaleUtil.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/LocaleUtil.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/LocaleUtil.java
new file mode 100644
index 0000000..3c4e08d
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/LocaleUtil.java
@@ -0,0 +1,101 @@
+/*
+ * 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;
+
+import java.text.DateFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Locale;
+import java.util.TimeZone;
+
+class LocaleUtil {
+
+ public static final String DEFAULT_TIME_ZONE = "Europe/London";
+ public static final String DEFAULT_LANGUAGE = "English, United Kingdom (en-gb)";
+
+
+ private LocaleUtil() {}
+
+ public static List<String> languages() {
+ Locale[] locales = DateFormat.getAvailableLocales();
+ List<String> list = new ArrayList<String>(locales.length);
+ for (Locale locale : locales) {
+ list.add(localeName(locale));
+ }
+ Collections.sort(list);
+ return list;
+ }
+
+ public static List<String> timeZones() {
+ List<String> timezones = Arrays.asList(TimeZone.getAvailableIDs());
+ Collections.sort(timezones);
+ return timezones;
+ }
+
+ public static TimeZone timeZone(String timeZoneEntry) {
+ TimeZone timeZone = TimeZone.getTimeZone(timeZoneEntry);
+ return timeZone;
+ }
+
+ public static Locale locale(String localeCode) {
+ String substring[] = localeCode.trim().split("-");
+ Locale locale;
+ switch (substring.length) {
+ case 1:
+ locale = new Locale(substring[0]);
+ break;
+ case 2:
+ locale = new Locale(substring[0], substring[1]);
+ break;
+ case 3:
+ locale = new Locale(substring[0], substring[1], substring[3]);
+ break;
+ default:
+ locale = Locale.getDefault();
+ break;
+ }
+ return locale;
+ }
+
+ public static String languageName(String languageCode) {
+ Locale locale = locale(languageCode);
+ return localeName(locale);
+ }
+
+ public static String codeForLanguage(String language) {
+ Locale[] locales = DateFormat.getAvailableLocales();
+ for (Locale locale : locales) {
+ String name = localeName(locale);
+ if (name.equals(language)) {
+ return locale.toString().toLowerCase().replace('_', '-');
+ }
+ }
+ return null;
+ }
+
+ public static String localeName(Locale locale) {
+ String language = locale.getDisplayLanguage();
+ String country = locale.getDisplayCountry().length() == 0 ? "" : ", " + (locale.getDisplayCountry());
+ return language + country + " (" + locale.toString().toLowerCase().replace('_', '-') + ")";
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/PreinstallElementProcessors.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/PreinstallElementProcessors.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/PreinstallElementProcessors.java
new file mode 100644
index 0000000..ad29000
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/PreinstallElementProcessors.java
@@ -0,0 +1,215 @@
+package org.apache.isis.viewer.scimpi.dispatcher;
+
+import org.apache.isis.viewer.scimpi.dispatcher.processor.ElementProcessorLookup;
+import org.apache.isis.viewer.scimpi.dispatcher.view.action.ActionButton;
+import org.apache.isis.viewer.scimpi.dispatcher.view.action.ActionForm;
+import org.apache.isis.viewer.scimpi.dispatcher.view.action.ActionLink;
+import org.apache.isis.viewer.scimpi.dispatcher.view.action.ActionName;
+import org.apache.isis.viewer.scimpi.dispatcher.view.action.NewActionLink;
+import org.apache.isis.viewer.scimpi.dispatcher.view.action.Parameter;
+import org.apache.isis.viewer.scimpi.dispatcher.view.action.ParameterName;
+import org.apache.isis.viewer.scimpi.dispatcher.view.action.RunAction;
+import org.apache.isis.viewer.scimpi.dispatcher.view.collection.Collection;
+import org.apache.isis.viewer.scimpi.dispatcher.view.collection.CountElements;
+import org.apache.isis.viewer.scimpi.dispatcher.view.collection.ElementType;
+import org.apache.isis.viewer.scimpi.dispatcher.view.collection.ListView;
+import org.apache.isis.viewer.scimpi.dispatcher.view.collection.RemoveElement;
+import org.apache.isis.viewer.scimpi.dispatcher.view.collection.TableBuilder;
+import org.apache.isis.viewer.scimpi.dispatcher.view.collection.TableCell;
+import org.apache.isis.viewer.scimpi.dispatcher.view.collection.TableEmpty;
+import org.apache.isis.viewer.scimpi.dispatcher.view.collection.TableHeader;
+import org.apache.isis.viewer.scimpi.dispatcher.view.collection.TableRow;
+import org.apache.isis.viewer.scimpi.dispatcher.view.collection.TableView;
+import org.apache.isis.viewer.scimpi.dispatcher.view.control.Forward;
+import org.apache.isis.viewer.scimpi.dispatcher.view.control.Redirect;
+import org.apache.isis.viewer.scimpi.dispatcher.view.control.Unless;
+import org.apache.isis.viewer.scimpi.dispatcher.view.control.When;
+import org.apache.isis.viewer.scimpi.dispatcher.view.debug.DebugAccessCheck;
+import org.apache.isis.viewer.scimpi.dispatcher.view.debug.DebugCollectionView;
+import org.apache.isis.viewer.scimpi.dispatcher.view.debug.DebugObjectView;
+import org.apache.isis.viewer.scimpi.dispatcher.view.debug.DebugUsersView;
+import org.apache.isis.viewer.scimpi.dispatcher.view.debug.DebuggerLink;
+import org.apache.isis.viewer.scimpi.dispatcher.view.debug.Diagnostics;
+import org.apache.isis.viewer.scimpi.dispatcher.view.debug.Log;
+import org.apache.isis.viewer.scimpi.dispatcher.view.debug.LogLevel;
+import org.apache.isis.viewer.scimpi.dispatcher.view.debug.Members;
+import org.apache.isis.viewer.scimpi.dispatcher.view.debug.ShowDebug;
+import org.apache.isis.viewer.scimpi.dispatcher.view.debug.Specification;
+import org.apache.isis.viewer.scimpi.dispatcher.view.debug.ThrowException;
+import org.apache.isis.viewer.scimpi.dispatcher.view.determine.Exclude;
+import org.apache.isis.viewer.scimpi.dispatcher.view.determine.Include;
+import org.apache.isis.viewer.scimpi.dispatcher.view.determine.Link;
+import org.apache.isis.viewer.scimpi.dispatcher.view.form.FormEntry;
+import org.apache.isis.viewer.scimpi.dispatcher.view.form.FormField;
+import org.apache.isis.viewer.scimpi.dispatcher.view.form.HiddenField;
+import org.apache.isis.viewer.scimpi.dispatcher.view.form.RadioListField;
+import org.apache.isis.viewer.scimpi.dispatcher.view.form.Selector;
+import org.apache.isis.viewer.scimpi.dispatcher.view.form.SimpleButton;
+import org.apache.isis.viewer.scimpi.dispatcher.view.global.Commit;
+import org.apache.isis.viewer.scimpi.dispatcher.view.global.Methods;
+import org.apache.isis.viewer.scimpi.dispatcher.view.global.Services;
+import org.apache.isis.viewer.scimpi.dispatcher.view.localization.Localization;
+import org.apache.isis.viewer.scimpi.dispatcher.view.localization.SetLocalization;
+import org.apache.isis.viewer.scimpi.dispatcher.view.message.AddMessage;
+import org.apache.isis.viewer.scimpi.dispatcher.view.message.AddWarning;
+import org.apache.isis.viewer.scimpi.dispatcher.view.message.ErrorDetails;
+import org.apache.isis.viewer.scimpi.dispatcher.view.message.ErrorMessage;
+import org.apache.isis.viewer.scimpi.dispatcher.view.message.ErrorReference;
+import org.apache.isis.viewer.scimpi.dispatcher.view.message.Errors;
+import org.apache.isis.viewer.scimpi.dispatcher.view.message.Feedback;
+import org.apache.isis.viewer.scimpi.dispatcher.view.message.Messages;
+import org.apache.isis.viewer.scimpi.dispatcher.view.message.Warnings;
+import org.apache.isis.viewer.scimpi.dispatcher.view.object.EditLink;
+import org.apache.isis.viewer.scimpi.dispatcher.view.object.EditObject;
+import org.apache.isis.viewer.scimpi.dispatcher.view.object.FieldLabel;
+import org.apache.isis.viewer.scimpi.dispatcher.view.object.FieldName;
+import org.apache.isis.viewer.scimpi.dispatcher.view.object.FieldValue;
+import org.apache.isis.viewer.scimpi.dispatcher.view.object.GetField;
+import org.apache.isis.viewer.scimpi.dispatcher.view.object.IncludeObject;
+import org.apache.isis.viewer.scimpi.dispatcher.view.object.LongViewForm;
+import org.apache.isis.viewer.scimpi.dispatcher.view.object.ObjectLink;
+import org.apache.isis.viewer.scimpi.dispatcher.view.object.SelectedObject;
+import org.apache.isis.viewer.scimpi.dispatcher.view.object.ShortViewForm;
+import org.apache.isis.viewer.scimpi.dispatcher.view.object.Title;
+import org.apache.isis.viewer.scimpi.dispatcher.view.object.TitleString;
+import org.apache.isis.viewer.scimpi.dispatcher.view.object.Type;
+import org.apache.isis.viewer.scimpi.dispatcher.view.other.HelpLink;
+import org.apache.isis.viewer.scimpi.dispatcher.view.other.History;
+import org.apache.isis.viewer.scimpi.dispatcher.view.other.VersionNumber;
+import org.apache.isis.viewer.scimpi.dispatcher.view.security.EndSession;
+import org.apache.isis.viewer.scimpi.dispatcher.view.security.Logoff;
+import org.apache.isis.viewer.scimpi.dispatcher.view.security.Logon;
+import org.apache.isis.viewer.scimpi.dispatcher.view.security.RestrictAccess;
+import org.apache.isis.viewer.scimpi.dispatcher.view.security.Secure;
+import org.apache.isis.viewer.scimpi.dispatcher.view.security.StartSession;
+import org.apache.isis.viewer.scimpi.dispatcher.view.security.User;
+import org.apache.isis.viewer.scimpi.dispatcher.view.structure.BlockDefine;
+import org.apache.isis.viewer.scimpi.dispatcher.view.structure.BlockUse;
+import org.apache.isis.viewer.scimpi.dispatcher.view.structure.ContentTag;
+import org.apache.isis.viewer.scimpi.dispatcher.view.structure.Import;
+import org.apache.isis.viewer.scimpi.dispatcher.view.structure.Mark;
+import org.apache.isis.viewer.scimpi.dispatcher.view.structure.TemplateTag;
+import org.apache.isis.viewer.scimpi.dispatcher.view.variable.ChangeScope;
+import org.apache.isis.viewer.scimpi.dispatcher.view.variable.CookieValue;
+import org.apache.isis.viewer.scimpi.dispatcher.view.variable.DefaultValue;
+import org.apache.isis.viewer.scimpi.dispatcher.view.variable.GetCookie;
+import org.apache.isis.viewer.scimpi.dispatcher.view.variable.InitializeFromCookie;
+import org.apache.isis.viewer.scimpi.dispatcher.view.variable.InitializeFromResult;
+import org.apache.isis.viewer.scimpi.dispatcher.view.variable.PageTitle;
+import org.apache.isis.viewer.scimpi.dispatcher.view.variable.SetCookie;
+import org.apache.isis.viewer.scimpi.dispatcher.view.variable.SetCookieFromField;
+import org.apache.isis.viewer.scimpi.dispatcher.view.variable.SetFieldFromCookie;
+import org.apache.isis.viewer.scimpi.dispatcher.view.variable.Variable;
+
+public class PreinstallElementProcessors {
+
+ public static void init(ElementProcessorLookup processors) {
+
+ processors.addElementProcessor(new ActionLink());
+ processors.addElementProcessor(new ActionButton());
+ processors.addElementProcessor(new ActionForm());
+ processors.addElementProcessor(new ActionName());
+ processors.addElementProcessor(new AddMessage());
+ processors.addElementProcessor(new AddWarning());
+ processors.addElementProcessor(new BlockDefine());
+ processors.addElementProcessor(new BlockUse());
+ processors.addElementProcessor(new History());
+ processors.addElementProcessor(new Collection());
+ processors.addElementProcessor(new Commit());
+ processors.addElementProcessor(new ContentTag());
+ processors.addElementProcessor(new CountElements());
+ processors.addElementProcessor(new Diagnostics());
+ processors.addElementProcessor(new DebugAccessCheck());
+ processors.addElementProcessor(new DebugCollectionView());
+ processors.addElementProcessor(new DebuggerLink());
+ processors.addElementProcessor(new DebugObjectView());
+ processors.addElementProcessor(new DebugUsersView());
+ processors.addElementProcessor(new DefaultValue());
+ processors.addElementProcessor(new EditLink());
+ processors.addElementProcessor(new EditObject());
+ processors.addElementProcessor(new ElementType());
+ processors.addElementProcessor(new Errors());
+ processors.addElementProcessor(new ErrorDetails());
+ processors.addElementProcessor(new ErrorMessage());
+ processors.addElementProcessor(new ErrorReference());
+ processors.addElementProcessor(new Exclude());
+ processors.addElementProcessor(new Feedback());
+ processors.addElementProcessor(new FieldLabel());
+ processors.addElementProcessor(new FieldName());
+ processors.addElementProcessor(new FieldValue());
+ processors.addElementProcessor(new FormField());
+ processors.addElementProcessor(new FormEntry());
+ processors.addElementProcessor(new Forward());
+ processors.addElementProcessor(new GetField());
+ processors.addElementProcessor(new HelpLink());
+ processors.addElementProcessor(new HiddenField());
+ processors.addElementProcessor(new Import());
+ processors.addElementProcessor(new IncludeObject());
+ processors.addElementProcessor(new Include());
+ processors.addElementProcessor(new InitializeFromCookie());
+ processors.addElementProcessor(new InitializeFromResult());
+ processors.addElementProcessor(new Log());
+ processors.addElementProcessor(new LogLevel());
+ processors.addElementProcessor(new Logon());
+ processors.addElementProcessor(new Logoff());
+ processors.addElementProcessor(new LongViewForm());
+ processors.addElementProcessor(new Link());
+ processors.addElementProcessor(new ListView());
+ processors.addElementProcessor(new NewActionLink());
+ processors.addElementProcessor(new Mark());
+ processors.addElementProcessor(new Members());
+ processors.addElementProcessor(new Messages());
+ processors.addElementProcessor(new Methods());
+ processors.addElementProcessor(new ObjectLink());
+ processors.addElementProcessor(new PageTitle());
+ processors.addElementProcessor(new Parameter());
+ processors.addElementProcessor(new ParameterName());
+ processors.addElementProcessor(new RadioListField());
+ processors.addElementProcessor(new Redirect());
+ processors.addElementProcessor(new RemoveElement());
+ processors.addElementProcessor(new VersionNumber());
+ processors.addElementProcessor(new RunAction());
+ processors.addElementProcessor(new RestrictAccess());
+ processors.addElementProcessor(new ChangeScope());
+ processors.addElementProcessor(new Secure());
+ processors.addElementProcessor(new SelectedObject());
+ processors.addElementProcessor(new Selector());
+ processors.addElementProcessor(new Services());
+ processors.addElementProcessor(new ShortViewForm());
+ processors.addElementProcessor(new ShowDebug());
+ processors.addElementProcessor(new SimpleButton());
+ processors.addElementProcessor(new Specification());
+ processors.addElementProcessor(new TableCell());
+ processors.addElementProcessor(new TableView());
+ processors.addElementProcessor(new TableBuilder());
+ processors.addElementProcessor(new TableEmpty());
+ processors.addElementProcessor(new TableRow());
+ processors.addElementProcessor(new TableHeader());
+ processors.addElementProcessor(new TemplateTag());
+ processors.addElementProcessor(new Title());
+ processors.addElementProcessor(new TitleString());
+ processors.addElementProcessor(new ThrowException());
+ processors.addElementProcessor(new Type());
+ processors.addElementProcessor(new User());
+ processors.addElementProcessor(new Unless());
+ processors.addElementProcessor(new Variable());
+ processors.addElementProcessor(new Warnings());
+ processors.addElementProcessor(new When());
+
+ processors.addElementProcessor(new StartSession());
+ processors.addElementProcessor(new EndSession());
+
+ processors.addElementProcessor(new CookieValue());
+ processors.addElementProcessor(new SetCookie());
+ processors.addElementProcessor(new GetCookie());
+ processors.addElementProcessor(new SetCookieFromField());
+ processors.addElementProcessor(new SetFieldFromCookie());
+
+ // new, alpha, processors
+ processors.addElementProcessor(new Localization());
+ processors.addElementProcessor(new SetLocalization());
+
+ }
+
+}
+
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/Response.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/Response.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/Response.java
deleted file mode 100644
index 173378e..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/Response.java
+++ /dev/null
@@ -1,6 +0,0 @@
-package org.apache.isis.viewer.scimpi.dispatcher;
-
-public interface Response {
-
-}
-
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/RuntimeScimpiContext.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/RuntimeScimpiContext.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/RuntimeScimpiContext.java
new file mode 100644
index 0000000..85d88ba
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/RuntimeScimpiContext.java
@@ -0,0 +1,17 @@
+package org.apache.isis.viewer.scimpi.dispatcher;
+
+import org.apache.isis.core.commons.config.IsisConfiguration;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.viewer.scimpi.ScimpiContext;
+
+public class RuntimeScimpiContext implements ScimpiContext {
+
+ public String configurationName(String name) {
+ return BASE + name;
+ }
+
+ public IsisConfiguration getConfiguration() {
+ return IsisContext.getConfiguration();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/ScimpiNotFoundException.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/ScimpiNotFoundException.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/ScimpiNotFoundException.java
deleted file mode 100644
index e448293..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/ScimpiNotFoundException.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.viewer.scimpi.dispatcher;
-
-import org.apache.isis.viewer.scimpi.ScimpiException;
-
-public class ScimpiNotFoundException extends ScimpiException {
- public ScimpiNotFoundException() {
- super();
- }
-
- public ScimpiNotFoundException(final String message, final Throwable cause) {
- super(message, cause);
- }
-
- public ScimpiNotFoundException(final String message) {
- super(message);
- }
-
- public ScimpiNotFoundException(final Throwable cause) {
- super(cause);
- }
-
- private static final long serialVersionUID = 1L;
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/TagOrderException.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/TagOrderException.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/TagOrderException.java
deleted file mode 100644
index 543d57b..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/TagOrderException.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.viewer.scimpi.dispatcher;
-
-import org.apache.isis.viewer.scimpi.ScimpiException;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-
-public class TagOrderException extends ScimpiException {
- private static final long serialVersionUID = 1L;
-
- public TagOrderException(final TagProcessor tagProcessor) {
- super("Invalid tag in this context: " + tagProcessor.getTag().getName());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/Util.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/Util.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/Util.java
deleted file mode 100644
index b485dd0..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/Util.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.viewer.scimpi.dispatcher;
-
-import java.text.DateFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.Locale;
-import java.util.TimeZone;
-
-class Util {
-
- public static final String DEFAULT_TIME_ZONE = "Europe/London";
- public static final String DEFAULT_LANGUAGE = "English, United Kingdom (en-gb)";
-
-
- private Util() {}
-
- public static boolean hasChanged(String version1, String version2) {
- return version2 == null && version1 != null || (version2 != null && !version2.equals(version1));
- }
-
- public static List<String> languages() {
- Locale[] locales = DateFormat.getAvailableLocales();
- List<String> list = new ArrayList<String>(locales.length);
- for (Locale locale : locales) {
- list.add(localeName(locale));
- }
- Collections.sort(list);
- return list;
- }
-
- public static List<String> timeZones() {
- List<String> timezones = Arrays.asList(TimeZone.getAvailableIDs());
- Collections.sort(timezones);
- return timezones;
- }
-
- public static TimeZone timeZone(String timeZoneEntry) {
- TimeZone timeZone = TimeZone.getTimeZone(timeZoneEntry);
- return timeZone;
- }
-
- public static Locale locale(String localeCode) {
- String substring[] = localeCode.trim().split("-");
- Locale locale;
- switch (substring.length) {
- case 1:
- locale = new Locale(substring[0]);
- break;
- case 2:
- locale = new Locale(substring[0], substring[1]);
- break;
- case 3:
- locale = new Locale(substring[0], substring[1], substring[3]);
- break;
- default:
- locale = Locale.getDefault();
- break;
- }
- return locale;
- }
-
- public static String languageName(String languageCode) {
- Locale locale = locale(languageCode);
- return localeName(locale);
- }
-
- public static String codeForLanguage(String language) {
- Locale[] locales = DateFormat.getAvailableLocales();
- for (Locale locale : locales) {
- String name = localeName(locale);
- if (name.equals(language)) {
- return locale.toString().toLowerCase().replace('_', '-');
- }
- }
- return null;
- }
-
- public static String localeName(Locale locale) {
- String language = locale.getDisplayLanguage();
- String country = locale.getDisplayCountry().length() == 0 ? "" : ", " + (locale.getDisplayCountry());
- return language + country + " (" + locale.toString().toLowerCase().replace('_', '-') + ")";
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/ActionAction.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/ActionAction.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/ActionAction.java
index 9b30d48..fe95cd4 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/ActionAction.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/ActionAction.java
@@ -42,8 +42,8 @@ import org.apache.isis.core.runtime.system.transaction.MessageBroker;
import org.apache.isis.viewer.scimpi.dispatcher.context.Action;
import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
-import org.apache.isis.viewer.scimpi.dispatcher.structure.FieldEditState;
-import org.apache.isis.viewer.scimpi.dispatcher.structure.FormState;
+import org.apache.isis.viewer.scimpi.dispatcher.form.FieldEditState;
+import org.apache.isis.viewer.scimpi.dispatcher.form.FormState;
import org.apache.isis.viewer.scimpi.dispatcher.util.MethodsUtils;
public class ActionAction implements Action {
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/DebugUserAction.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/DebugUserAction.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/DebugUserAction.java
index c314b01..3d4cfb8 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/DebugUserAction.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/DebugUserAction.java
@@ -25,8 +25,8 @@ import org.apache.isis.core.commons.debug.DebugBuilder;
import org.apache.isis.viewer.scimpi.ForbiddenException;
import org.apache.isis.viewer.scimpi.ScimpiException;
import org.apache.isis.viewer.scimpi.dispatcher.context.Action;
+import org.apache.isis.viewer.scimpi.dispatcher.context.DebugUsers;
import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
-import org.apache.isis.viewer.scimpi.security.DebugUsers;
public class DebugUserAction implements Action {
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/EditAction.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/EditAction.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/EditAction.java
index 86b7046..5686eb2 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/EditAction.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/EditAction.java
@@ -44,8 +44,8 @@ import org.apache.isis.viewer.scimpi.NotLoggedInException;
import org.apache.isis.viewer.scimpi.dispatcher.context.Action;
import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
-import org.apache.isis.viewer.scimpi.dispatcher.structure.FieldEditState;
-import org.apache.isis.viewer.scimpi.dispatcher.structure.FormState;
+import org.apache.isis.viewer.scimpi.dispatcher.form.FieldEditState;
+import org.apache.isis.viewer.scimpi.dispatcher.form.FormState;
public class EditAction implements Action {
public static final String ACTION = "edit";
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/LogonAction.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/LogonAction.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/LogonAction.java
index ea158f1..573b31d 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/LogonAction.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/LogonAction.java
@@ -35,10 +35,10 @@ import org.apache.isis.viewer.scimpi.ScimpiException;
import org.apache.isis.viewer.scimpi.dispatcher.context.Action;
import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
-import org.apache.isis.viewer.scimpi.dispatcher.structure.FieldEditState;
-import org.apache.isis.viewer.scimpi.dispatcher.structure.FormState;
+import org.apache.isis.viewer.scimpi.dispatcher.form.FieldEditState;
+import org.apache.isis.viewer.scimpi.dispatcher.form.FormState;
import org.apache.isis.viewer.scimpi.dispatcher.util.MethodsUtils;
-import org.apache.isis.viewer.scimpi.security.UserManager;
+import org.apache.isis.viewer.scimpi.dispatcher.util.UserManager;
// TODO this should work like EditAction so that logon page is repopulated
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/LogoutAction.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/LogoutAction.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/LogoutAction.java
index af8581a..9a31da5 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/LogoutAction.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/LogoutAction.java
@@ -23,11 +23,11 @@ import java.io.IOException;
import org.apache.isis.core.commons.authentication.AuthenticationSession;
import org.apache.isis.core.commons.debug.DebugBuilder;
-import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.core.runtime.system.context.IsisContext;//
import org.apache.isis.viewer.scimpi.dispatcher.context.Action;
import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
-import org.apache.isis.viewer.scimpi.security.UserManager;
+import org.apache.isis.viewer.scimpi.dispatcher.util.UserManager;
public class LogoutAction implements Action {
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/DebugUsers.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/DebugUsers.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/DebugUsers.java
new file mode 100644
index 0000000..c925da8
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/DebugUsers.java
@@ -0,0 +1,97 @@
+/*
+ * 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.context;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+
+import org.apache.isis.core.commons.authentication.AuthenticationSession;
+import org.apache.isis.core.commons.config.ConfigurationConstants;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.viewer.scimpi.ScimpiException;
+
+public class DebugUsers {
+
+ private static Logger LOG = Logger.getLogger(DebugUsers.class);
+
+ private enum DebugMode {
+ OFF, ON, NAMED, SYSADMIN_ONLY
+ }
+
+ private static List<String> debugUsers = new ArrayList<String>();
+ private static DebugMode debugMode;
+
+ public void initialize() {
+ if (debugMode != null) {
+ throw new ScimpiException("Debug mode is already set up!");
+ }
+
+ final String debugUserEntry = IsisContext.getConfiguration().getString(ConfigurationConstants.ROOT + "scimpi.debug.users", "");
+ final String[] users = debugUserEntry.split("\\|");
+ for (final String name : users) {
+ debugUsers.add(name.trim());
+ }
+
+ final String debugModeEntry = IsisContext.getConfiguration().getString(ConfigurationConstants.ROOT + "scimpi.debug.mode");
+ if (debugModeEntry != null) {
+ try {
+ debugMode = DebugMode.valueOf(debugModeEntry.toUpperCase());
+ LOG.info("Debug mode set to " + debugMode);
+ } catch (final IllegalArgumentException e) {
+ LOG.error("Invalid debug mode - " + debugModeEntry + " - mode set to OFF");
+ debugMode = DebugMode.OFF;
+ }
+ } else {
+ debugMode = DebugMode.OFF;
+ }
+ }
+
+ public boolean isDebugEnabled(final AuthenticationSession session) {
+ if (debugMode == DebugMode.ON) {
+ return true;
+ } else if (session != null && debugMode == DebugMode.SYSADMIN_ONLY && session.getRoles().contains("sysadmin")) {
+ return true;
+ } else if (session != null && debugMode == DebugMode.NAMED && (debugUsers.contains(session.getUserName()) || session.getRoles().contains("sysadmin"))) {
+ return true;
+ }
+ return false;
+ }
+
+ public List<String> getNames() {
+ final ArrayList<String> users = new ArrayList<String>(debugUsers);
+ Collections.sort(users);
+ return users;
+ }
+
+ public void add(final String name) {
+ if (!debugUsers.contains(name)) {
+ debugUsers.add(name);
+ LOG.info("Added '" + debugMode + "' to debug users list");
+ }
+ }
+
+ public void remove(final String name) {
+ debugUsers.remove(name);
+ LOG.info("Removed '" + debugMode + "' from debug users list");
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/Request.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/Request.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/Request.java
index 605bb65..937e796 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/Request.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/Request.java
@@ -51,9 +51,8 @@ import org.apache.isis.core.runtime.system.context.IsisContext;
import org.apache.isis.core.runtime.system.persistence.Persistor;
import org.apache.isis.viewer.scimpi.Names;
import org.apache.isis.viewer.scimpi.ScimpiException;
-import org.apache.isis.viewer.scimpi.security.DebugUsers;
-public abstract class Request {
+public abstract class Request implements RequestState {
private static final Logger LOG = Logger.getLogger(Request.class);
static final String TRANSIENT_OBJECT_OID_MARKER = "~";
@@ -385,7 +384,7 @@ public abstract class Request {
}
public void clearVariable(String name, final Scope scope) {
- name = name != null ? name : RESULT;
+ name = name != null ? name : Names.RESULT;
variables.get(scope).remove(name);
}
@@ -394,7 +393,7 @@ public abstract class Request {
}
public void addVariable(String name, final Object value, final Scope scope) {
- name = name != null ? name : RESULT;
+ name = name != null ? name : Names.RESULT;
if (scope == Scope.SESSION && value != null && !(value instanceof Serializable)) {
throw new ScimpiException("SESSION scoped variable (" + name + ") must be serializable: " + value);
}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/RequestState.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/RequestState.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/RequestState.java
new file mode 100644
index 0000000..a2eb7a8
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/RequestState.java
@@ -0,0 +1,47 @@
+/*
+ * 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.context;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+
+public interface RequestState {
+
+ String replaceVariables(String value);
+
+ String getStringVariable(String result);
+
+
+
+ ObjectAdapter getMappedObject(String objectId);
+
+
+
+
+ String getErrorMessage();
+
+
+
+
+
+ // String getOptionalProperty(String name);
+
+
+}
+
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/Response.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/Response.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/Response.java
new file mode 100644
index 0000000..bbb8d7d
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/Response.java
@@ -0,0 +1,6 @@
+package org.apache.isis.viewer.scimpi.dispatcher.context;
+
+public interface Response {
+
+}
+
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/ScimpiNotFoundException.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/ScimpiNotFoundException.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/ScimpiNotFoundException.java
new file mode 100644
index 0000000..3033ca2
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/ScimpiNotFoundException.java
@@ -0,0 +1,43 @@
+/*
+ * 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.context;
+
+import org.apache.isis.viewer.scimpi.ScimpiException;
+
+public class ScimpiNotFoundException extends ScimpiException {
+ public ScimpiNotFoundException() {
+ super();
+ }
+
+ public ScimpiNotFoundException(final String message, final Throwable cause) {
+ super(message, cause);
+ }
+
+ public ScimpiNotFoundException(final String message) {
+ super(message);
+ }
+
+ public ScimpiNotFoundException(final Throwable cause) {
+ super(cause);
+ }
+
+ private static final long serialVersionUID = 1L;
+
+}
[11/24] git commit: Restructuring Scimpi to remove dependencies and
enable easier testing.
Posted by rm...@apache.org.
Restructuring Scimpi to remove dependencies and enable easier testing.
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/49518c89
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/49518c89
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/49518c89
Branch: refs/heads/scimpi-restructure
Commit: 49518c89ff57987cbd8dcc8c033a8b3b819e037f
Parents: b5ea578
Author: rmatthews <rm...@nakedobjects.org>
Authored: Wed Jan 16 23:25:06 2013 +0000
Committer: rmatthews <rm...@nakedobjects.org>
Committed: Wed Jan 16 23:25:06 2013 +0000
----------------------------------------------------------------------
.../apache/isis/viewer/scimpi/DebugHtmlWriter.java | 45 +
.../isis/viewer/scimpi/ForbiddenException.java | 68 ++
.../java/org/apache/isis/viewer/scimpi/Names.java | 104 ++
.../isis/viewer/scimpi/NotLoggedInException.java | 32 +
.../apache/isis/viewer/scimpi/ScimpiException.java | 44 +
.../dispatcher/AbstractElementProcessor.java | 55 -
.../scimpi/dispatcher/AbstractObjectProcessor.java | 54 -
.../isis/viewer/scimpi/dispatcher/Action.java | 37 -
.../scimpi/dispatcher/AddElementProcessors.java | 215 ++++
.../viewer/scimpi/dispatcher/BlockContent.java | 23 -
.../scimpi/dispatcher/DispatchException.java | 3 +
.../isis/viewer/scimpi/dispatcher/Dispatcher.java | 144 ++--
.../scimpi/dispatcher/ElementContentProcessor.java | 24 -
.../viewer/scimpi/dispatcher/ElementProcessor.java | 30 -
.../viewer/scimpi/dispatcher/ErrorCollator.java | 146 ---
.../scimpi/dispatcher/ForbiddenException.java | 68 --
.../isis/viewer/scimpi/dispatcher/Names.java | 91 --
.../scimpi/dispatcher/NotLoggedInException.java | 31 -
.../isis/viewer/scimpi/dispatcher/Response.java | 6 +
.../viewer/scimpi/dispatcher/ScimpiException.java | 44 -
.../scimpi/dispatcher/ScimpiNotFoundException.java | 2 +
.../scimpi/dispatcher/TagOrderException.java | 7 +-
.../isis/viewer/scimpi/dispatcher/UserManager.java | 90 --
.../scimpi/dispatcher/action/ActionAction.java | 29 +-
.../scimpi/dispatcher/action/Attributes.java | 131 ---
.../scimpi/dispatcher/action/DebugAction.java | 244 ++++
.../scimpi/dispatcher/action/DebugUserAction.java | 72 ++
.../scimpi/dispatcher/action/EditAction.java | 271 +++++
.../viewer/scimpi/dispatcher/action/LogAction.java | 76 ++
.../scimpi/dispatcher/action/LogonAction.java | 146 +++
.../scimpi/dispatcher/action/LogoutAction.java | 71 ++
.../dispatcher/action/PropertyException.java | 44 -
.../scimpi/dispatcher/action/RemoveAction.java | 117 ++
.../action/RequiredPropertyException.java | 43 -
.../viewer/scimpi/dispatcher/context/Action.java | 37 +
.../context/DefaultOidObjectMapping.java | 6 +-
.../scimpi/dispatcher/context/ErrorCollator.java | 145 +++
.../dispatcher/context/IndirectObjectMapping.java | 3 +-
.../scimpi/dispatcher/context/ObjectMapping.java | 2 +-
.../dispatcher/context/PropertyException.java | 44 +
.../viewer/scimpi/dispatcher/context/Request.java | 864 +++++++++++++++
.../scimpi/dispatcher/context/RequestContext.java | 862 --------------
.../scimpi/dispatcher/debug/DebugAction.java | 243 ----
.../scimpi/dispatcher/debug/DebugHtmlWriter.java | 45 -
.../scimpi/dispatcher/debug/DebugUserAction.java | 71 --
.../viewer/scimpi/dispatcher/debug/DebugUsers.java | 97 --
.../scimpi/dispatcher/debug/DebugUsersView.java | 30 +-
.../scimpi/dispatcher/debug/ErrorDetails.java | 8 +-
.../scimpi/dispatcher/debug/ErrorMessage.java | 8 +-
.../scimpi/dispatcher/debug/ErrorReference.java | 8 +-
.../viewer/scimpi/dispatcher/debug/LogAction.java | 76 --
.../viewer/scimpi/dispatcher/edit/EditAction.java | 269 -----
.../scimpi/dispatcher/edit/FieldEditState.java | 57 -
.../viewer/scimpi/dispatcher/edit/FormState.java | 67 --
.../scimpi/dispatcher/edit/RemoveAction.java | 116 --
.../scimpi/dispatcher/logon/LogonAction.java | 147 ---
.../scimpi/dispatcher/logon/LogoutAction.java | 71 --
.../scimpi/dispatcher/processor/Attributes.java | 132 +++
.../scimpi/dispatcher/processor/BlockContent.java | 23 +
.../processor/ElementContentProcessor.java | 25 +
.../dispatcher/processor/ElementProcessor.java | 29 +
.../dispatcher/processor/HtmlFileParser.java | 13 +-
.../scimpi/dispatcher/processor/HtmlSnippet.java | 51 +
.../dispatcher/processor/ProcessorLookup.java | 206 ----
.../scimpi/dispatcher/processor/Request.java | 323 ------
.../processor/RequiredPropertyException.java | 43 +
.../scimpi/dispatcher/processor/Snippet.java | 27 +
.../viewer/scimpi/dispatcher/processor/SwfTag.java | 89 ++
.../processor/TagProcessingException.java | 2 +-
.../scimpi/dispatcher/processor/TagProcessor.java | 317 ++++++
.../dispatcher/structure/FieldEditState.java | 57 +
.../scimpi/dispatcher/structure/FormState.java | 67 ++
.../scimpi/dispatcher/util/MethodsUtils.java | 23 +-
.../dispatcher/view/AbstractElementProcessor.java | 58 +
.../dispatcher/view/AbstractObjectProcessor.java | 55 +
.../viewer/scimpi/dispatcher/view/HelpLink.java | 72 --
.../viewer/scimpi/dispatcher/view/History.java | 150 ---
.../viewer/scimpi/dispatcher/view/HtmlSnippet.java | 51 -
.../viewer/scimpi/dispatcher/view/Snippet.java | 27 -
.../isis/viewer/scimpi/dispatcher/view/SwfTag.java | 90 --
.../scimpi/dispatcher/view/VersionNumber.java | 70 --
.../dispatcher/view/action/ActionButton.java | 117 +-
.../dispatcher/view/action/ActionContent.java | 10 +-
.../scimpi/dispatcher/view/action/ActionForm.java | 97 +-
.../scimpi/dispatcher/view/action/ActionLink.java | 62 +-
.../scimpi/dispatcher/view/action/Methods.java | 110 +-
.../scimpi/dispatcher/view/action/Parameter.java | 16 +-
.../scimpi/dispatcher/view/action/RunAction.java | 32 +-
.../scimpi/dispatcher/view/action/Services.java | 36 +-
.../dispatcher/view/collection/Collection.java | 36 +-
.../viewer/scimpi/dispatcher/view/debug/Debug.java | 168 ++--
.../dispatcher/view/debug/DebugAccessCheck.java | 10 +-
.../dispatcher/view/debug/DebugCollectionView.java | 32 +-
.../dispatcher/view/debug/DebugObjectView.java | 66 +-
.../scimpi/dispatcher/view/debug/DebuggerLink.java | 28 +-
.../scimpi/dispatcher/view/debug/Diagnostics.java | 57 +-
.../viewer/scimpi/dispatcher/view/debug/Log.java | 14 +-
.../scimpi/dispatcher/view/debug/LogLevel.java | 28 +-
.../scimpi/dispatcher/view/debug/Members.java | 44 +-
.../scimpi/dispatcher/view/debug/ShowDebug.java | 12 +-
.../dispatcher/view/debug/Specification.java | 54 +-
.../dispatcher/view/debug/ThrowException.java | 10 +-
.../dispatcher/view/display/AbstractFormView.java | 64 +-
.../dispatcher/view/display/AbstractTableView.java | 60 +-
.../scimpi/dispatcher/view/display/AddMessage.java | 12 +-
.../scimpi/dispatcher/view/display/AddWarning.java | 12 +-
.../scimpi/dispatcher/view/display/Errors.java | 22 +-
.../scimpi/dispatcher/view/display/Feedback.java | 16 +-
.../scimpi/dispatcher/view/display/FieldLabel.java | 22 +-
.../scimpi/dispatcher/view/display/FieldValue.java | 46 +-
.../scimpi/dispatcher/view/display/GetField.java | 44 +-
.../dispatcher/view/display/IncludeObject.java | 32 +-
.../scimpi/dispatcher/view/display/ListView.java | 47 +-
.../dispatcher/view/display/LongFormView.java | 14 +-
.../scimpi/dispatcher/view/display/Messages.java | 14 +-
.../dispatcher/view/display/SelectedObject.java | 26 +-
.../scimpi/dispatcher/view/display/TableBlock.java | 4 +-
.../dispatcher/view/display/TableBuilder.java | 32 +-
.../scimpi/dispatcher/view/display/TableCell.java | 55 +-
.../view/display/TableContentWriter.java | 6 +-
.../scimpi/dispatcher/view/display/TableEmpty.java | 24 +-
.../dispatcher/view/display/TableHeader.java | 12 +-
.../scimpi/dispatcher/view/display/TableRow.java | 20 +-
.../scimpi/dispatcher/view/display/TableView.java | 110 +-
.../scimpi/dispatcher/view/display/Title.java | 32 +-
.../scimpi/dispatcher/view/display/Warnings.java | 14 +-
.../scimpi/dispatcher/view/edit/EditObject.java | 74 +-
.../scimpi/dispatcher/view/edit/FieldFactory.java | 105 --
.../scimpi/dispatcher/view/edit/FormEntry.java | 44 -
.../scimpi/dispatcher/view/edit/FormField.java | 44 -
.../dispatcher/view/edit/FormFieldBlock.java | 68 --
.../scimpi/dispatcher/view/edit/HiddenField.java | 48 -
.../dispatcher/view/edit/RadioListField.java | 70 --
.../scimpi/dispatcher/view/edit/Selector.java | 158 ---
.../scimpi/dispatcher/view/field/ExcludeField.java | 10 +-
.../scimpi/dispatcher/view/field/IncludeField.java | 10 +-
.../dispatcher/view/field/InclusionList.java | 2 +-
.../scimpi/dispatcher/view/field/LinkField.java | 21 +-
.../scimpi/dispatcher/view/field/LinkedObject.java | 6 +-
.../dispatcher/view/form/HtmlFormBuilder.java | 62 +-
.../scimpi/dispatcher/view/logon/Logoff.java | 10 +-
.../viewer/scimpi/dispatcher/view/logon/Logon.java | 54 +-
.../dispatcher/view/logon/RestrictAccess.java | 16 +-
.../scimpi/dispatcher/view/logon/Secure.java | 10 +-
.../viewer/scimpi/dispatcher/view/logon/User.java | 46 +-
.../scimpi/dispatcher/view/other/HelpLink.java | 72 ++
.../scimpi/dispatcher/view/other/History.java | 150 +++
.../dispatcher/view/other/VersionNumber.java | 70 ++
.../view/simple/AbstractConditionalBlock.java | 108 +-
.../dispatcher/view/simple/AbstractLink.java | 65 +-
.../scimpi/dispatcher/view/simple/BlockDefine.java | 18 +-
.../scimpi/dispatcher/view/simple/BlockUse.java | 18 +-
.../scimpi/dispatcher/view/simple/Commit.java | 6 +-
.../scimpi/dispatcher/view/simple/ContentTag.java | 8 +-
.../scimpi/dispatcher/view/simple/CookieValue.java | 24 +-
.../dispatcher/view/simple/DefaultValue.java | 24 +-
.../scimpi/dispatcher/view/simple/EditLink.java | 8 +-
.../scimpi/dispatcher/view/simple/EndSession.java | 8 +-
.../scimpi/dispatcher/view/simple/Forward.java | 10 +-
.../scimpi/dispatcher/view/simple/GetCookie.java | 12 +-
.../scimpi/dispatcher/view/simple/Import.java | 8 +-
.../view/simple/InitializeFromCookie.java | 35 +-
.../view/simple/InitializeFromResult.java | 43 +-
.../dispatcher/view/simple/Localization.java | 14 +-
.../viewer/scimpi/dispatcher/view/simple/Mark.java | 12 +-
.../dispatcher/view/simple/NewActionLink.java | 14 +-
.../scimpi/dispatcher/view/simple/ObjectLink.java | 8 +-
.../scimpi/dispatcher/view/simple/PageTitle.java | 8 +-
.../scimpi/dispatcher/view/simple/Redirect.java | 10 +-
.../dispatcher/view/simple/RemoveElement.java | 86 +-
.../scimpi/dispatcher/view/simple/ScopeTag.java | 28 +-
.../scimpi/dispatcher/view/simple/SetCookie.java | 24 +-
.../dispatcher/view/simple/SetCookieFromField.java | 6 +-
.../dispatcher/view/simple/SetFieldFromCookie.java | 6 +-
.../dispatcher/view/simple/SetLocalization.java | 12 +-
.../dispatcher/view/simple/SimpleButton.java | 16 +-
.../dispatcher/view/simple/StartSession.java | 8 +-
.../scimpi/dispatcher/view/simple/TemplateTag.java | 6 +-
.../scimpi/dispatcher/view/simple/Unless.java | 10 +-
.../scimpi/dispatcher/view/simple/Variable.java | 40 +-
.../viewer/scimpi/dispatcher/view/simple/When.java | 10 +-
.../scimpi/dispatcher/view/value/ActionName.java | 14 +-
.../dispatcher/view/value/CountElements.java | 14 +-
.../scimpi/dispatcher/view/value/ElementType.java | 20 +-
.../scimpi/dispatcher/view/value/FieldName.java | 20 +-
.../dispatcher/view/value/ParameterName.java | 18 +-
.../scimpi/dispatcher/view/value/TitleString.java | 20 +-
.../viewer/scimpi/dispatcher/view/value/Type.java | 22 +-
.../dispatcher/view/widget/FieldFactory.java | 105 ++
.../scimpi/dispatcher/view/widget/FormEntry.java | 44 +
.../scimpi/dispatcher/view/widget/FormField.java | 44 +
.../dispatcher/view/widget/FormFieldBlock.java | 68 ++
.../scimpi/dispatcher/view/widget/HiddenField.java | 48 +
.../dispatcher/view/widget/RadioListField.java | 70 ++
.../scimpi/dispatcher/view/widget/Selector.java | 158 +++
.../isis/viewer/scimpi/security/DebugUsers.java | 97 ++
.../isis/viewer/scimpi/security/UserManager.java | 89 ++
.../viewer/scimpi/servlet/DispatchException.java | 2 +-
.../viewer/scimpi/servlet/DispatcherServlet.java | 8 +-
.../scimpi/servlet/ServletRequestContext.java | 10 +-
200 files changed, 6225 insertions(+), 6171 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/DebugHtmlWriter.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/DebugHtmlWriter.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/DebugHtmlWriter.java
new file mode 100644
index 0000000..0251e7f
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/DebugHtmlWriter.java
@@ -0,0 +1,45 @@
+/*
+ * 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;
+
+import java.io.PrintWriter;
+
+import org.apache.isis.core.commons.debug.DebugHtmlStringAbstract;
+
+public class DebugHtmlWriter extends DebugHtmlStringAbstract {
+
+ private final PrintWriter writer;
+
+ public DebugHtmlWriter(final PrintWriter writer, final boolean createPage) {
+ super(createPage);
+ this.writer = writer;
+ header();
+ }
+
+ @Override
+ protected void appendHtml(final String html) {
+ writer.println(html);
+ }
+
+ @Override
+ protected void doClose() {
+ footer();
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/ForbiddenException.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/ForbiddenException.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/ForbiddenException.java
new file mode 100644
index 0000000..30384ab
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/ForbiddenException.java
@@ -0,0 +1,68 @@
+/*
+ * 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;
+
+import java.util.List;
+
+import org.apache.isis.applib.Identifier;
+import org.apache.isis.core.commons.authentication.AuthenticationSession;
+import org.apache.isis.core.metamodel.facetapi.IdentifiedHolder;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+
+/**
+ * Indicates that request could not complete as it could not access (for
+ * security reasons) some of the content.
+ */
+public class ForbiddenException extends ScimpiException {
+ private static final long serialVersionUID = 1L;
+ public static final boolean VISIBLE_AND_USABLE = true;
+ public static final boolean VISIBLE = false;
+ private final Identifier identifier;
+ private final AuthenticationSession session;
+
+ public ForbiddenException(final String message) {
+ this(IsisContext.getAuthenticationSession(), message);
+ }
+
+ private ForbiddenException(final AuthenticationSession session, final String message) {
+ super(message + " for " + session.getUserName() + " " + session.getRoles());
+ this.session = session;
+ identifier = null;
+ }
+
+ public ForbiddenException(final IdentifiedHolder target, final boolean isVisibleAndUsabable) {
+ this(target.getIdentifier(), IsisContext.getAuthenticationSession(), isVisibleAndUsabable);
+ }
+
+ private ForbiddenException(final Identifier identifier, final AuthenticationSession session, final boolean isVisibleAndUsabable) {
+ super((identifier.getType() == Identifier.Type.PROPERTY_OR_COLLECTION ? "Field" : "Action") + " '" + identifier.getMemberName() + "' in " + identifier.getClassName() + " is not " + (isVisibleAndUsabable ? "visible/usable " : "visible") + " for " + session.getUserName() + " "
+ + session.getRoles());
+ this.identifier = identifier;
+ this.session = session;
+ }
+
+ public Identifier getIdentifier() {
+ return identifier;
+ }
+
+ public List<String> getRoles() {
+ return session.getRoles();
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/Names.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/Names.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/Names.java
new file mode 100644
index 0000000..9ebbbbc
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/Names.java
@@ -0,0 +1,104 @@
+/*
+ * 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;
+
+public interface Names {
+ static final String PREFIX = "_logon-";
+
+ public static final String COMMAND_ROOT = ".app";
+
+ public static final String EXTENSION = "shtml";
+
+ public static final String ACTION = "_action";
+ public static final String EDIT = "_edit";
+ public static final String REMOVE = "_remove";
+ public static final String GENERIC = "_generic";
+
+ public static final String RESULT = "_result";
+ public static final String ERROR_PARAM = "_error";
+ public static final String BACK_TO = "_back_to";
+
+ static final String BUTTON_TITLE = "button-title";
+ static final String CANCEL_TO = "cancel-to";
+ static final String COLLECTION = "collection";
+ static final String CONFIRM = "confirm";
+ static final String CLASS = "class";
+ static final String CONTAINER_CLASS = "container-" + CLASS;
+ static final String DEFAULT = "default";
+ static final String ELEMENT_NAME = "element-name";
+ static final String ELEMENT = "element";
+ static final String EVEN_ROW_CLASS = "even-row";
+ static final String FALSE = "false";
+ static final String ERROR = "error";
+ static final String FIELD = "field";
+ static final String FIELD_NAME = "field-name";
+ static final String FOOTER = "footer";
+ static final String FORM_ID = "form-id";
+ static final String FORM_TITLE = "title";
+ static final String FORMS = "show-forms";
+ static final String HEADER = "header";
+ static final String ICON_CLASS = "icon";
+ static final String HIDDEN = "hidden";
+ static final String HIDE_UNEDITABLE = "hide-uneditable";
+ static final String HEADER_LEVEL = "header";
+ static final String ID = "id";
+ static final String LABEL_DELIMITER = "label";
+ static final String LINK_VIEW = "link-view";
+ static final String LINK_NAME = "link-name";
+ static final String LINK_OBJECT = "link-object";
+ static final String METHOD = "method";
+ static final String MESSAGE = "message";
+ static final String NAME = "name";
+ static final String ODD_ROW_CLASS = "odd-row";
+ static final String OBJECT = "object";
+ static final String PARAMETER = "param";
+ static final String PARAMETER_NUMBER = "number";
+ static final String PLURAL = "plural";
+ static final String REFERENCE_NAME = "reference-name";
+ static final String RESULT_NAME = "result-name";
+ static final String RESULT_OVERRIDE = "result-override";
+ static final String ROW_CLASSES = "row-classes";
+ static final String SCOPE = "scope";
+ static final String SHOW_ICON = "icon";
+ static final String SHOW_SELECT = "select";
+ static final String SHOW_EDIT = "edit";
+ static final String SHOW_DELETE = "delete";
+ static final String SHOW_MESSAGE = "show-message";
+ static final String SHOW_TITLE = "show-title";
+ static final String TRUNCATE = "truncate";
+ static final String TABLE_TITLE = "title";
+ static final String TYPE = "type";
+ static final String VIEW = "view";
+ static final String VALUE = "value";
+ static final String VERSION = "version";
+ static final String USER = "user";
+ static final String VOID = "void";
+ static final String WHEN = "when";
+ static final String ENTRY_FIELDS = "entry-fields";
+
+
+ static final String LOGON_OBJECT = PREFIX + OBJECT;
+ static final String LOGON_METHOD = PREFIX + METHOD;
+ static final String LOGON_SCOPE = PREFIX + SCOPE;
+ static final String LOGON_RESULT_NAME = PREFIX + RESULT_NAME;
+ static final String LOGON_FORM_ID = PREFIX + "form-id";
+
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/NotLoggedInException.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/NotLoggedInException.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/NotLoggedInException.java
new file mode 100644
index 0000000..8a663f1
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/NotLoggedInException.java
@@ -0,0 +1,32 @@
+/*
+ * 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;
+
+
+/**
+ * Indicates that request could not complete as a user was not logged in.
+ */
+public class NotLoggedInException extends ScimpiException {
+ private static final long serialVersionUID = 1L;
+
+ public NotLoggedInException() {
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/ScimpiException.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/ScimpiException.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/ScimpiException.java
new file mode 100644
index 0000000..15781a4
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/ScimpiException.java
@@ -0,0 +1,44 @@
+/*
+ * 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;
+
+public class ScimpiException extends RuntimeException {
+ private static final long serialVersionUID = 1L;
+
+ public ScimpiException() {
+ }
+
+ public ScimpiException(final String message) {
+ super(message);
+ }
+
+ public ScimpiException(final Throwable cause) {
+ super(cause);
+ }
+
+ public ScimpiException(final String message, final Throwable cause) {
+ super(message, cause);
+ }
+
+ public String getHtmlMessage() {
+ return getMessage();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/AbstractElementProcessor.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/AbstractElementProcessor.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/AbstractElementProcessor.java
deleted file mode 100644
index 4869cc4..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/AbstractElementProcessor.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.viewer.scimpi.dispatcher;
-
-import org.apache.isis.core.commons.config.ConfigurationConstants;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
-
-public abstract class AbstractElementProcessor implements ElementProcessor, Names {
-
- private static final String SHOW_ICONS_BY_DEFAULT = ConfigurationConstants.ROOT + "scimpi.show-icons";
-
- private final boolean showIconByDefault;
-
- public AbstractElementProcessor() {
- showIconByDefault = IsisContext.getConfiguration().getBoolean(SHOW_ICONS_BY_DEFAULT, false);
- }
-
- /**
- * Return the Class for the class specified in the type attribute.
- */
- protected Class<?> forClass(final Request request) {
- Class<?> cls = null;
- final String className = request.getOptionalProperty(TYPE);
- if (className != null) {
- try {
- cls = Class.forName(className);
- } catch (final ClassNotFoundException e) {
- throw new ScimpiException("No class for " + className, e);
- }
- }
- return cls;
- }
-
- protected boolean showIconByDefault() {
- return showIconByDefault;
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/AbstractObjectProcessor.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/AbstractObjectProcessor.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/AbstractObjectProcessor.java
deleted file mode 100644
index d163bc1..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/AbstractObjectProcessor.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.viewer.scimpi.dispatcher;
-
-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.processor.Request;
-
-public abstract class AbstractObjectProcessor extends AbstractElementProcessor {
-
- @Override
- public void process(final Request request) {
- final String id = request.getOptionalProperty(OBJECT);
- ObjectAdapter object = request.getContext().getMappedObjectOrResult(id);
-
- final String field = request.getOptionalProperty(FIELD);
- if (field != null) {
- final ObjectAssociation objectField = object.getSpecification().getAssociation(field);
- final String error = checkFieldType(objectField);
- if (error != null) {
- throw new ScimpiException("Field " + objectField.getId() + " " + error);
- }
- IsisContext.getPersistenceSession().resolveField(object, objectField);
- object = objectField.get(object);
- }
-
- process(request, object);
- }
-
- protected String checkFieldType(final ObjectAssociation objectField) {
- return null;
- }
-
- protected abstract void process(Request request, ObjectAdapter object);
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/Action.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/Action.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/Action.java
deleted file mode 100644
index 7bd6b26..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/Action.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;
-
-import java.io.IOException;
-
-import org.apache.isis.core.commons.debug.DebugBuilder;
-import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext;
-
-public interface Action extends Names {
-
- void process(RequestContext context) throws IOException;
-
- String getName();
-
- void init();
-
- void debug(DebugBuilder debug);
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/AddElementProcessors.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/AddElementProcessors.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/AddElementProcessors.java
new file mode 100644
index 0000000..ad51add
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/AddElementProcessors.java
@@ -0,0 +1,215 @@
+package org.apache.isis.viewer.scimpi.dispatcher;
+
+import org.apache.isis.viewer.scimpi.dispatcher.debug.DebugUsersView;
+import org.apache.isis.viewer.scimpi.dispatcher.debug.ErrorDetails;
+import org.apache.isis.viewer.scimpi.dispatcher.debug.ErrorMessage;
+import org.apache.isis.viewer.scimpi.dispatcher.debug.ErrorReference;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.ProcessorLookup;
+import org.apache.isis.viewer.scimpi.dispatcher.view.action.ActionButton;
+import org.apache.isis.viewer.scimpi.dispatcher.view.action.ActionForm;
+import org.apache.isis.viewer.scimpi.dispatcher.view.action.ActionLink;
+import org.apache.isis.viewer.scimpi.dispatcher.view.action.Methods;
+import org.apache.isis.viewer.scimpi.dispatcher.view.action.Parameter;
+import org.apache.isis.viewer.scimpi.dispatcher.view.action.RunAction;
+import org.apache.isis.viewer.scimpi.dispatcher.view.action.Services;
+import org.apache.isis.viewer.scimpi.dispatcher.view.collection.Collection;
+import org.apache.isis.viewer.scimpi.dispatcher.view.debug.DebugAccessCheck;
+import org.apache.isis.viewer.scimpi.dispatcher.view.debug.DebugCollectionView;
+import org.apache.isis.viewer.scimpi.dispatcher.view.debug.DebugObjectView;
+import org.apache.isis.viewer.scimpi.dispatcher.view.debug.DebuggerLink;
+import org.apache.isis.viewer.scimpi.dispatcher.view.debug.Diagnostics;
+import org.apache.isis.viewer.scimpi.dispatcher.view.debug.Log;
+import org.apache.isis.viewer.scimpi.dispatcher.view.debug.LogLevel;
+import org.apache.isis.viewer.scimpi.dispatcher.view.debug.Members;
+import org.apache.isis.viewer.scimpi.dispatcher.view.debug.ShowDebug;
+import org.apache.isis.viewer.scimpi.dispatcher.view.debug.Specification;
+import org.apache.isis.viewer.scimpi.dispatcher.view.debug.ThrowException;
+import org.apache.isis.viewer.scimpi.dispatcher.view.display.AddMessage;
+import org.apache.isis.viewer.scimpi.dispatcher.view.display.AddWarning;
+import org.apache.isis.viewer.scimpi.dispatcher.view.display.Errors;
+import org.apache.isis.viewer.scimpi.dispatcher.view.display.Feedback;
+import org.apache.isis.viewer.scimpi.dispatcher.view.display.FieldLabel;
+import org.apache.isis.viewer.scimpi.dispatcher.view.display.FieldValue;
+import org.apache.isis.viewer.scimpi.dispatcher.view.display.GetField;
+import org.apache.isis.viewer.scimpi.dispatcher.view.display.IncludeObject;
+import org.apache.isis.viewer.scimpi.dispatcher.view.display.ListView;
+import org.apache.isis.viewer.scimpi.dispatcher.view.display.LongFormView;
+import org.apache.isis.viewer.scimpi.dispatcher.view.display.Messages;
+import org.apache.isis.viewer.scimpi.dispatcher.view.display.SelectedObject;
+import org.apache.isis.viewer.scimpi.dispatcher.view.display.ShortFormView;
+import org.apache.isis.viewer.scimpi.dispatcher.view.display.TableBuilder;
+import org.apache.isis.viewer.scimpi.dispatcher.view.display.TableCell;
+import org.apache.isis.viewer.scimpi.dispatcher.view.display.TableEmpty;
+import org.apache.isis.viewer.scimpi.dispatcher.view.display.TableHeader;
+import org.apache.isis.viewer.scimpi.dispatcher.view.display.TableRow;
+import org.apache.isis.viewer.scimpi.dispatcher.view.display.TableView;
+import org.apache.isis.viewer.scimpi.dispatcher.view.display.Title;
+import org.apache.isis.viewer.scimpi.dispatcher.view.display.Warnings;
+import org.apache.isis.viewer.scimpi.dispatcher.view.edit.EditObject;
+import org.apache.isis.viewer.scimpi.dispatcher.view.field.ExcludeField;
+import org.apache.isis.viewer.scimpi.dispatcher.view.field.IncludeField;
+import org.apache.isis.viewer.scimpi.dispatcher.view.field.LinkField;
+import org.apache.isis.viewer.scimpi.dispatcher.view.logon.Logoff;
+import org.apache.isis.viewer.scimpi.dispatcher.view.logon.Logon;
+import org.apache.isis.viewer.scimpi.dispatcher.view.logon.RestrictAccess;
+import org.apache.isis.viewer.scimpi.dispatcher.view.logon.Secure;
+import org.apache.isis.viewer.scimpi.dispatcher.view.logon.User;
+import org.apache.isis.viewer.scimpi.dispatcher.view.other.HelpLink;
+import org.apache.isis.viewer.scimpi.dispatcher.view.other.History;
+import org.apache.isis.viewer.scimpi.dispatcher.view.other.VersionNumber;
+import org.apache.isis.viewer.scimpi.dispatcher.view.simple.BlockDefine;
+import org.apache.isis.viewer.scimpi.dispatcher.view.simple.BlockUse;
+import org.apache.isis.viewer.scimpi.dispatcher.view.simple.Commit;
+import org.apache.isis.viewer.scimpi.dispatcher.view.simple.ContentTag;
+import org.apache.isis.viewer.scimpi.dispatcher.view.simple.CookieValue;
+import org.apache.isis.viewer.scimpi.dispatcher.view.simple.DefaultValue;
+import org.apache.isis.viewer.scimpi.dispatcher.view.simple.EditLink;
+import org.apache.isis.viewer.scimpi.dispatcher.view.simple.EndSession;
+import org.apache.isis.viewer.scimpi.dispatcher.view.simple.Forward;
+import org.apache.isis.viewer.scimpi.dispatcher.view.simple.GetCookie;
+import org.apache.isis.viewer.scimpi.dispatcher.view.simple.Import;
+import org.apache.isis.viewer.scimpi.dispatcher.view.simple.InitializeFromCookie;
+import org.apache.isis.viewer.scimpi.dispatcher.view.simple.InitializeFromResult;
+import org.apache.isis.viewer.scimpi.dispatcher.view.simple.Localization;
+import org.apache.isis.viewer.scimpi.dispatcher.view.simple.Mark;
+import org.apache.isis.viewer.scimpi.dispatcher.view.simple.NewActionLink;
+import org.apache.isis.viewer.scimpi.dispatcher.view.simple.ObjectLink;
+import org.apache.isis.viewer.scimpi.dispatcher.view.simple.PageTitle;
+import org.apache.isis.viewer.scimpi.dispatcher.view.simple.Redirect;
+import org.apache.isis.viewer.scimpi.dispatcher.view.simple.RemoveElement;
+import org.apache.isis.viewer.scimpi.dispatcher.view.simple.ScopeTag;
+import org.apache.isis.viewer.scimpi.dispatcher.view.simple.SetCookie;
+import org.apache.isis.viewer.scimpi.dispatcher.view.simple.SetCookieFromField;
+import org.apache.isis.viewer.scimpi.dispatcher.view.simple.SetFieldFromCookie;
+import org.apache.isis.viewer.scimpi.dispatcher.view.simple.SetLocalization;
+import org.apache.isis.viewer.scimpi.dispatcher.view.simple.SimpleButton;
+import org.apache.isis.viewer.scimpi.dispatcher.view.simple.StartSession;
+import org.apache.isis.viewer.scimpi.dispatcher.view.simple.TemplateTag;
+import org.apache.isis.viewer.scimpi.dispatcher.view.simple.Unless;
+import org.apache.isis.viewer.scimpi.dispatcher.view.simple.Variable;
+import org.apache.isis.viewer.scimpi.dispatcher.view.simple.When;
+import org.apache.isis.viewer.scimpi.dispatcher.view.value.ActionName;
+import org.apache.isis.viewer.scimpi.dispatcher.view.value.CountElements;
+import org.apache.isis.viewer.scimpi.dispatcher.view.value.ElementType;
+import org.apache.isis.viewer.scimpi.dispatcher.view.value.FieldName;
+import org.apache.isis.viewer.scimpi.dispatcher.view.value.ParameterName;
+import org.apache.isis.viewer.scimpi.dispatcher.view.value.TitleString;
+import org.apache.isis.viewer.scimpi.dispatcher.view.value.Type;
+import org.apache.isis.viewer.scimpi.dispatcher.view.widget.FormEntry;
+import org.apache.isis.viewer.scimpi.dispatcher.view.widget.FormField;
+import org.apache.isis.viewer.scimpi.dispatcher.view.widget.HiddenField;
+import org.apache.isis.viewer.scimpi.dispatcher.view.widget.RadioListField;
+import org.apache.isis.viewer.scimpi.dispatcher.view.widget.Selector;
+
+public class AddElementProcessors {
+
+ public static void init(ProcessorLookup processors) {
+
+ processors.addElementProcessor(new ActionLink());
+ processors.addElementProcessor(new ActionButton());
+ processors.addElementProcessor(new ActionForm());
+ processors.addElementProcessor(new ActionName());
+ processors.addElementProcessor(new AddMessage());
+ processors.addElementProcessor(new AddWarning());
+ processors.addElementProcessor(new BlockDefine());
+ processors.addElementProcessor(new BlockUse());
+ processors.addElementProcessor(new History());
+ processors.addElementProcessor(new Collection());
+ processors.addElementProcessor(new Commit());
+ processors.addElementProcessor(new ContentTag());
+ processors.addElementProcessor(new CountElements());
+ processors.addElementProcessor(new Diagnostics());
+ processors.addElementProcessor(new DebugAccessCheck());
+ processors.addElementProcessor(new DebugCollectionView());
+ processors.addElementProcessor(new DebuggerLink());
+ processors.addElementProcessor(new DebugObjectView());
+ processors.addElementProcessor(new DebugUsersView());
+ processors.addElementProcessor(new DefaultValue());
+ processors.addElementProcessor(new EditLink());
+ processors.addElementProcessor(new EditObject());
+ processors.addElementProcessor(new ElementType());
+ processors.addElementProcessor(new Errors());
+ processors.addElementProcessor(new ErrorDetails());
+ processors.addElementProcessor(new ErrorMessage());
+ processors.addElementProcessor(new ErrorReference());
+ processors.addElementProcessor(new ExcludeField());
+ processors.addElementProcessor(new Feedback());
+ processors.addElementProcessor(new FieldLabel());
+ processors.addElementProcessor(new FieldName());
+ processors.addElementProcessor(new FieldValue());
+ processors.addElementProcessor(new FormField());
+ processors.addElementProcessor(new FormEntry());
+ processors.addElementProcessor(new Forward());
+ processors.addElementProcessor(new GetField());
+ processors.addElementProcessor(new HelpLink());
+ processors.addElementProcessor(new HiddenField());
+ processors.addElementProcessor(new Import());
+ processors.addElementProcessor(new IncludeObject());
+ processors.addElementProcessor(new IncludeField());
+ processors.addElementProcessor(new InitializeFromCookie());
+ processors.addElementProcessor(new InitializeFromResult());
+ processors.addElementProcessor(new Log());
+ processors.addElementProcessor(new LogLevel());
+ processors.addElementProcessor(new Logon());
+ processors.addElementProcessor(new Logoff());
+ processors.addElementProcessor(new LongFormView());
+ processors.addElementProcessor(new LinkField());
+ processors.addElementProcessor(new ListView());
+ processors.addElementProcessor(new NewActionLink());
+ processors.addElementProcessor(new Mark());
+ processors.addElementProcessor(new Members());
+ processors.addElementProcessor(new Messages());
+ processors.addElementProcessor(new Methods());
+ processors.addElementProcessor(new ObjectLink());
+ processors.addElementProcessor(new PageTitle());
+ processors.addElementProcessor(new Parameter());
+ processors.addElementProcessor(new ParameterName());
+ processors.addElementProcessor(new RadioListField());
+ processors.addElementProcessor(new Redirect());
+ processors.addElementProcessor(new RemoveElement());
+ processors.addElementProcessor(new VersionNumber());
+ processors.addElementProcessor(new RunAction());
+ processors.addElementProcessor(new RestrictAccess());
+ processors.addElementProcessor(new ScopeTag());
+ processors.addElementProcessor(new Secure());
+ processors.addElementProcessor(new SelectedObject());
+ processors.addElementProcessor(new Selector());
+ processors.addElementProcessor(new Services());
+ processors.addElementProcessor(new ShortFormView());
+ processors.addElementProcessor(new ShowDebug());
+ processors.addElementProcessor(new SimpleButton());
+ processors.addElementProcessor(new Specification());
+ processors.addElementProcessor(new TableCell());
+ processors.addElementProcessor(new TableView());
+ processors.addElementProcessor(new TableBuilder());
+ processors.addElementProcessor(new TableEmpty());
+ processors.addElementProcessor(new TableRow());
+ processors.addElementProcessor(new TableHeader());
+ processors.addElementProcessor(new TemplateTag());
+ processors.addElementProcessor(new Title());
+ processors.addElementProcessor(new TitleString());
+ processors.addElementProcessor(new ThrowException());
+ processors.addElementProcessor(new Type());
+ processors.addElementProcessor(new User());
+ processors.addElementProcessor(new Unless());
+ processors.addElementProcessor(new Variable());
+ processors.addElementProcessor(new Warnings());
+ processors.addElementProcessor(new When());
+
+ processors.addElementProcessor(new StartSession());
+ processors.addElementProcessor(new EndSession());
+
+ processors.addElementProcessor(new CookieValue());
+ processors.addElementProcessor(new SetCookie());
+ processors.addElementProcessor(new GetCookie());
+ processors.addElementProcessor(new SetCookieFromField());
+ processors.addElementProcessor(new SetFieldFromCookie());
+
+ // new, alpha, processors
+ processors.addElementProcessor(new Localization());
+ processors.addElementProcessor(new SetLocalization());
+
+ }
+
+}
+
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/BlockContent.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/BlockContent.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/BlockContent.java
deleted file mode 100644
index 836ae60..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/BlockContent.java
+++ /dev/null
@@ -1,23 +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;
-
-public interface BlockContent {
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/DispatchException.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/DispatchException.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/DispatchException.java
index cc679ae..25eadbc 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/DispatchException.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/DispatchException.java
@@ -19,6 +19,9 @@
package org.apache.isis.viewer.scimpi.dispatcher;
+import org.apache.isis.viewer.scimpi.ScimpiException;
+
+
public class DispatchException extends ScimpiException {
private static final long serialVersionUID = 1L;
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/Dispatcher.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/Dispatcher.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/Dispatcher.java
index 045536e..f5e2e5e 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/Dispatcher.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/Dispatcher.java
@@ -23,7 +23,6 @@ import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.PrintWriter;
-import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@@ -39,6 +38,7 @@ import org.apache.isis.applib.Identifier;
import org.apache.isis.core.commons.authentication.AuthenticationSession;
import org.apache.isis.core.commons.config.ConfigurationConstants;
import org.apache.isis.core.commons.debug.DebugBuilder;
+import org.apache.isis.core.commons.debug.Debuggable;
import org.apache.isis.core.commons.exceptions.IsisException;
import org.apache.isis.core.commons.factory.InstanceUtil;
import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
@@ -50,41 +50,55 @@ import org.apache.isis.core.runtime.system.context.IsisContext;
import org.apache.isis.core.runtime.system.persistence.PersistenceSession;
import org.apache.isis.core.runtime.system.transaction.IsisTransactionManager;
import org.apache.isis.core.runtime.userprofile.UserLocalization;
+import org.apache.isis.viewer.scimpi.DebugHtmlWriter;
+import org.apache.isis.viewer.scimpi.ForbiddenException;
+import org.apache.isis.viewer.scimpi.Names;
+import org.apache.isis.viewer.scimpi.NotLoggedInException;
+import org.apache.isis.viewer.scimpi.ScimpiException;
import org.apache.isis.viewer.scimpi.dispatcher.action.ActionAction;
-import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext;
-import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext.Debug;
-import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext.Scope;
-import org.apache.isis.viewer.scimpi.dispatcher.debug.DebugAction;
-import org.apache.isis.viewer.scimpi.dispatcher.debug.DebugUserAction;
-import org.apache.isis.viewer.scimpi.dispatcher.debug.DebugUsers;
-import org.apache.isis.viewer.scimpi.dispatcher.debug.DebugHtmlWriter;
-import org.apache.isis.viewer.scimpi.dispatcher.debug.LogAction;
-import org.apache.isis.viewer.scimpi.dispatcher.edit.EditAction;
-import org.apache.isis.viewer.scimpi.dispatcher.edit.RemoveAction;
-import org.apache.isis.viewer.scimpi.dispatcher.logon.LogonAction;
-import org.apache.isis.viewer.scimpi.dispatcher.logon.LogoutAction;
+import org.apache.isis.viewer.scimpi.dispatcher.action.DebugAction;
+import org.apache.isis.viewer.scimpi.dispatcher.action.DebugUserAction;
+import org.apache.isis.viewer.scimpi.dispatcher.action.EditAction;
+import org.apache.isis.viewer.scimpi.dispatcher.action.LogAction;
+import org.apache.isis.viewer.scimpi.dispatcher.action.LogonAction;
+import org.apache.isis.viewer.scimpi.dispatcher.action.LogoutAction;
+import org.apache.isis.viewer.scimpi.dispatcher.action.RemoveAction;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Action;
+import org.apache.isis.viewer.scimpi.dispatcher.context.ErrorCollator;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Debug;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.ElementProcessor;
import org.apache.isis.viewer.scimpi.dispatcher.processor.Encoder;
import org.apache.isis.viewer.scimpi.dispatcher.processor.HtmlFileParser;
import org.apache.isis.viewer.scimpi.dispatcher.processor.ProcessorLookup;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
import org.apache.isis.viewer.scimpi.dispatcher.processor.SimpleEncoder;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.Snippet;
import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessingException;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
import org.apache.isis.viewer.scimpi.dispatcher.util.MethodsUtils;
-import org.apache.isis.viewer.scimpi.dispatcher.view.Snippet;
+import org.apache.isis.viewer.scimpi.security.DebugUsers;
+import org.apache.isis.viewer.scimpi.security.UserManager;
import org.apache.log4j.Logger;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
-public class Dispatcher {
+public class Dispatcher implements Debuggable {
private static final String SHOW_UNSHOWN_MESSAGES = ConfigurationConstants.ROOT + "scimpi.show-unshown-messages";
+ @Deprecated
public static final String ACTION = "_action";
+ @Deprecated
public static final String EDIT = "_edit";
+ @Deprecated
public static final String REMOVE = "_remove";
+ @Deprecated
public static final String GENERIC = "_generic";
+ @Deprecated
public static final String EXTENSION = "shtml";
private static final Logger LOG = Logger.getLogger(Dispatcher.class);
+ @Deprecated
public static final String COMMAND_ROOT = ".app";
private final Map<String, Action> actions = new HashMap<String, Action>();
private final Map<String, String> parameters = new HashMap<String, String>();
@@ -93,37 +107,37 @@ public class Dispatcher {
private final Encoder encoder = new SimpleEncoder();
private boolean showUnshownMessages;
- public void process(final RequestContext context, final String servletPath) {
+ public void process(final Request request, final Response response, final String servletPath) {
LOG.debug("processing request " + servletPath);
- final AuthenticationSession session = UserManager.startRequest(context);
- LOG.debug("exsiting session: " + session);
+ final AuthenticationSession session = UserManager.startRequest(request.getSession());
+ LOG.debug(" using session: " + session);
- String language = (String) context.getVariable("user-language");
+ String language = (String) request.getVariable("user-language");
if (language != null) {
Locale locale = Util.locale(language);
- TimeZone timeZone = Util.timeZone((String) context.getVariable("user-time-zone"));
+ TimeZone timeZone = Util.timeZone((String) request.getVariable("user-time-zone"));
IsisContext.getUserProfile().setLocalization(new UserLocalization(locale, timeZone));
}
IsisContext.getPersistenceSession().getTransactionManager().startTransaction();
- context.setRequestPath(servletPath);
- context.startRequest();
+ request.setRequestPath(servletPath);
+ request.startRequest();
try {
- processActions(context, false, servletPath);
- processTheView(context);
+ processActions(request, false, servletPath);
+ processTheView(request);
} catch (final ScimpiNotFoundException e) {
- if (context.isInternalRequest()) {
+ if (request.isInternalRequest()) {
LOG.error("invalid page request (from within application): " + e.getMessage());
ErrorCollator error = new ErrorCollator();
error.missingFile("Failed to find page " + servletPath + ".");
- show500ErrorPage(context, e, error);
+ show500ErrorPage(request, e, error);
} else {
LOG.info("invalid page request (from outside application): " + e.getMessage());
- show404ErrorPage(context, servletPath);
+ show404ErrorPage(request, servletPath);
}
} catch (final NotLoggedInException e) {
- redirectToLoginPage(context);
+ redirectToLoginPage(request);
} catch (final Throwable e) {
ErrorCollator error = new ErrorCollator();
final PersistenceSession checkSession = IsisContext.getPersistenceSession();
@@ -136,25 +150,25 @@ public class Dispatcher {
final Throwable ex = e instanceof TagProcessingException ? e.getCause() : e;
if (ex instanceof ForbiddenException) {
LOG.error("invalid access to " + servletPath, e);
- show403ErrorPage(context, error, e, ex);
+ show403ErrorPage(request, error, e, ex);
} else {
LOG.error("error procesing " + servletPath, e);
- if (context.getErrorMessage() != null) {
- fallbackToSimpleErrorPage(context, e);
+ if (request.getErrorMessage() != null) {
+ fallbackToSimpleErrorPage(request, e);
} else {
- show500ErrorPage(context, e, error);
+ show500ErrorPage(request, e, error);
}
}
} finally {
try {
- UserManager.endRequest(context.getSession());
+ UserManager.endRequest(request.getSession());
} catch (final Exception e1) {
LOG.error("endRequest call failed", e1);
}
}
}
- private void redirectToLoginPage(final RequestContext context) {
+ private void redirectToLoginPage(final Request context) {
IsisContext.getMessageBroker().addWarning(
"You are not currently logged in! Please log in so you can continue.");
context.setRequestPath("/login.shtml");
@@ -165,13 +179,13 @@ public class Dispatcher {
}
}
- private void show404ErrorPage(final RequestContext context, final String servletPath) {
+ private void show404ErrorPage(final Request context, final String servletPath) {
ErrorCollator error = new ErrorCollator();
error.missingFile("Failed to find page " + servletPath + ".");
context.raiseError(404, error);
}
- private void show403ErrorPage(final RequestContext context, ErrorCollator error, final Throwable e, final Throwable ex) {
+ private void show403ErrorPage(final Request context, ErrorCollator error, final Throwable e, final Throwable ex) {
DebugBuilder debug = error.getDebug();
error.message(e);
error.message(ex);
@@ -195,13 +209,13 @@ public class Dispatcher {
context.raiseError(403, error);
}
- private void show500ErrorPage(final RequestContext context, final Throwable e, ErrorCollator error) {
+ private void show500ErrorPage(final Request context, final Throwable e, ErrorCollator error) {
error.exception(e);
error.compileError(context);
context.raiseError(500, error);
}
- private void fallbackToSimpleErrorPage(final RequestContext context, final Throwable e) {
+ private void fallbackToSimpleErrorPage(final Request context, final Throwable e) {
context.setContentType("text/html");
final PrintWriter writer = context.getWriter();
writer.write("<html><head><title>Error</title></head>");
@@ -213,7 +227,7 @@ public class Dispatcher {
LOG.error("Error while processing error", e);
}
- protected void processTheView(final RequestContext context) throws IOException {
+ protected void processTheView(final Request context) throws IOException {
IsisTransactionManager transactionManager = IsisContext.getPersistenceSession().getTransactionManager();
if (transactionManager.getTransaction().getState().canFlush()) {
transactionManager.flushTransaction();
@@ -239,7 +253,7 @@ public class Dispatcher {
return parameters.get(name);
}
- private void processActions(final RequestContext context, final boolean userLoggedIn, final String actionName) throws IOException {
+ private void processActions(final Request context, final boolean userLoggedIn, final String actionName) throws IOException {
if (actionName.endsWith(COMMAND_ROOT)) {
final int pos = actionName.lastIndexOf('/');
final Action action = actions.get(actionName.substring(pos, actionName.length() - COMMAND_ROOT.length()));
@@ -256,7 +270,7 @@ public class Dispatcher {
}
}
- private void processView(final RequestContext context) throws IOException {
+ private void processView(final Request context) throws IOException {
String file = context.getRequestedFile();
if (file == null) {
LOG.warn("No view specified to process");
@@ -274,10 +288,10 @@ public class Dispatcher {
context.addVariable("title", "Untitled Page", Scope.REQUEST);
final Stack<Snippet> tags = loadPageTemplate(context, fullPath);
- final Request request = new Request(file, context, encoder, tags, processors);
- request.appendDebug("processing " + fullPath);
+ final TagProcessor tagProcessor = new TagProcessor(file, context, encoder, tags, processors);
+ tagProcessor.appendDebug("processing " + fullPath);
try {
- request.processNextTag();
+ tagProcessor.processNextTag();
noteIfMessagesHaveNotBeenDisplay(context);
IsisContext.getUpdateNotifier().clear();
} catch (final RuntimeException e) {
@@ -286,7 +300,7 @@ public class Dispatcher {
IsisContext.getUpdateNotifier().clear();
throw e;
}
- final String page = request.popBuffer();
+ final String page = tagProcessor.popBuffer();
final PrintWriter writer = context.getWriter();
writer.write(page);
if (context.getDebug() == Debug.PAGE) {
@@ -295,7 +309,7 @@ public class Dispatcher {
}
}
- public void noteIfMessagesHaveNotBeenDisplay(final RequestContext context) {
+ public void noteIfMessagesHaveNotBeenDisplay(final Request context) {
final List<String> messages = IsisContext.getMessageBroker().getMessages();
if (showUnshownMessages) {
if (messages.size() > 0) {
@@ -316,43 +330,43 @@ public class Dispatcher {
}
}
- private String determineFile(final RequestContext context, String file) {
+ private String determineFile(final Request context, String file) {
final String fileName = file.trim();
- if (fileName.startsWith(GENERIC)) {
- final Object result = context.getVariable(RequestContext.RESULT);
+ if (fileName.startsWith(Names.GENERIC)) {
+ final Object result = context.getVariable(Names.RESULT);
final ObjectAdapter mappedObject = MethodsUtils.findObject(context, (String) result);
if (mappedObject == null) {
throw new ScimpiException("No object mapping for " + result);
}
- if (fileName.equals(GENERIC + "." + EXTENSION)) {
+ if (fileName.equals(Names.GENERIC + "." + Names.EXTENSION)) {
final Facet facet = mappedObject.getSpecification().getFacet(CollectionFacet.class);
if (facet != null) {
final ObjectSpecification specification = mappedObject.getSpecification();
final TypeOfFacet facet2 = specification.getFacet(TypeOfFacet.class);
- file = findFileForSpecification(context, facet2.valueSpec(), "collection", EXTENSION);
+ file = findFileForSpecification(context, facet2.valueSpec(), "collection", Names.EXTENSION);
} else {
final ObjectAdapter mappedObject2 = mappedObject;
if (mappedObject2.isTransient()) {
- file = findFileForSpecification(context, mappedObject.getSpecification(), "edit", EXTENSION);
+ file = findFileForSpecification(context, mappedObject.getSpecification(), "edit", Names.EXTENSION);
} else {
- file = findFileForSpecification(context, mappedObject.getSpecification(), "object", EXTENSION);
+ file = findFileForSpecification(context, mappedObject.getSpecification(), "object", Names.EXTENSION);
}
}
- } else if (fileName.equals(GENERIC + EDIT + "." + EXTENSION)) {
- file = findFileForSpecification(context, mappedObject.getSpecification(), "edit", EXTENSION);
- } else if (fileName.equals(GENERIC + ACTION + "." + EXTENSION)) {
+ } else if (fileName.equals(Names.GENERIC + Names.EDIT + "." + Names.EXTENSION)) {
+ file = findFileForSpecification(context, mappedObject.getSpecification(), "edit", Names.EXTENSION);
+ } else if (fileName.equals(Names.GENERIC + Names.ACTION + "." + Names.EXTENSION)) {
final String method = context.getParameter("method");
- file = findFileForSpecification(context, mappedObject.getSpecification(), method, "action", EXTENSION);
+ file = findFileForSpecification(context, mappedObject.getSpecification(), method, "action", Names.EXTENSION);
}
}
return file;
}
- private String findFileForSpecification(final RequestContext context, final ObjectSpecification specification, final String name, final String extension) {
+ private String findFileForSpecification(final Request context, final ObjectSpecification specification, final String name, final String extension) {
return findFileForSpecification(context, specification, name, name, extension);
}
- private String findFileForSpecification(final RequestContext context, final ObjectSpecification specification, final String name, final String defaultName, final String extension) {
+ private String findFileForSpecification(final Request context, final ObjectSpecification specification, final String name, final String defaultName, final String extension) {
String find = findFile(context, specification, name, extension);
if (find == null) {
@@ -361,7 +375,7 @@ public class Dispatcher {
return find;
}
- private String findFile(final RequestContext context, final ObjectSpecification specification, final String name, final String extension) {
+ private String findFile(final Request context, final ObjectSpecification specification, final String name, final String extension) {
final String className = specification.getShortIdentifier();
String fileName = context.findFile("/" + className + "/" + name + "." + extension);
if (fileName == null) {
@@ -379,14 +393,14 @@ public class Dispatcher {
return fileName;
}
- private Stack<Snippet> loadPageTemplate(final RequestContext context, final String path) throws IOException, FileNotFoundException {
+ private Stack<Snippet> loadPageTemplate(final Request context, final String path) throws IOException, FileNotFoundException {
// TODO cache stacks and check for them first
copyParametersToVariableList(context);
LOG.debug("parsing source " + path);
return parser.parseHtmlFile(path, context);
}
- private void copyParametersToVariableList(final RequestContext context) {
+ private void copyParametersToVariableList(final Request context) {
/*
* Enumeration parameterNames = context.getParameterNames(); while
* (parameterNames.hasMoreElements()) { String name = (String)
@@ -418,7 +432,7 @@ public class Dispatcher {
}
}
- processors.init();
+ AddElementProcessors.init(processors);
processors.addElementProcessor(new org.apache.isis.viewer.scimpi.dispatcher.view.debug.Debug(this));
showUnshownMessages = IsisContext.getConfiguration().getBoolean(SHOW_UNSHOWN_MESSAGES, true);
@@ -463,7 +477,7 @@ public class Dispatcher {
action.init();
}
- public void debug(final DebugBuilder debug) {
+ public void debugData(final DebugBuilder debug) {
debug.startSection("Actions");
final Set<String> keySet = actions.keySet();
final ArrayList<String> list = new ArrayList<String>(keySet);
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/ElementContentProcessor.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/ElementContentProcessor.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/ElementContentProcessor.java
deleted file mode 100644
index eaae2ac..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/ElementContentProcessor.java
+++ /dev/null
@@ -1,24 +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;
-
-public interface ElementContentProcessor extends ElementProcessor {
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/ElementProcessor.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/ElementProcessor.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/ElementProcessor.java
deleted file mode 100644
index 471ac00..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/ElementProcessor.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.viewer.scimpi.dispatcher;
-
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
-
-public interface ElementProcessor {
-
- String getName();
-
- void process(Request request);
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/ErrorCollator.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/ErrorCollator.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/ErrorCollator.java
deleted file mode 100644
index 4c162a2..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/ErrorCollator.java
+++ /dev/null
@@ -1,146 +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;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.PrintWriter;
-import java.util.List;
-
-import org.apache.isis.core.commons.config.ConfigurationConstants;
-import org.apache.isis.core.commons.debug.DebugBuilder;
-import org.apache.isis.core.commons.debug.DebugHtmlString;
-import org.apache.isis.core.commons.debug.DebugString;
-import org.apache.isis.core.commons.debug.DebugTee;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext;
-import org.apache.isis.viewer.scimpi.dispatcher.debug.DebugHtmlWriter;
-import org.apache.log4j.Logger;
-
-public class ErrorCollator {
- private static final Logger LOG = Logger.getLogger(ErrorCollator.class);
-
- private String errorRef;
- private String message;
- private final DebugString debugText = new DebugString();
- private final DebugHtmlString debugHtml = new DebugHtmlString();
- private final DebugBuilder debug = new DebugTee(debugText, debugHtml);
-
- public void missingFile(String message) {
- this.message = message;
- }
-
- public void message(final Throwable exception) {
- LOG.debug(exception.getMessage(), exception);
- message = exception.getMessage();
- debug.appendPreformatted(message);
- }
-
- public void exception(final Throwable exception) {
- String messageText = exception.getMessage();
- LOG.debug(messageText, exception);
- try {
- debug.startSection("Exception");
- debug.appendException(exception);
- debug.endSection();
- } catch (final RuntimeException e) {
- debug.appendln("NOTE - an exception occurred while dumping an exception!");
- debug.appendException(e);
- }
- message = messageText == null ? exception.getClass().getName() : messageText;
- }
-
- public DebugBuilder getDebug() {
- return debug;
- }
-
- public void compileError(final RequestContext requestContext) {
- errorRef = Long.toString(System.currentTimeMillis(), 36).toUpperCase();
- LOG.info("error " + errorRef);
-
- captureWarningsAndMessages();
- dumpDebugDetails(requestContext);
- writeErrorFile();
- }
-
- private void captureWarningsAndMessages() {
- // Capture warnings/messages
- if (IsisContext.getCurrentTransaction() != null) {
- final List<String> messages = IsisContext.getMessageBroker().getMessages();
- final List<String> warnings = IsisContext.getMessageBroker().getWarnings();
- if (messages.size() > 0 || messages.size() > 0) {
- debug.startSection("Warnings/Messages");
- for (final String message : messages) {
- debug.appendln("message", message);
- }
- for (final String message : warnings) {
- debug.appendln("warning", message);
- }
- }
- }
- }
-
- private void dumpDebugDetails(final RequestContext requestContext) {
- // Dump page debug details
- requestContext.append(debug);
-
- debug.startSection("Processing Trace");
- debug.appendPreformatted(requestContext.getDebugTrace());
- debug.endSection();
- debug.close();
- }
-
- private void writeErrorFile() {
- LOG.error(message + "\n" + debugText.toString());
-
-
- PrintWriter writer;
- try {
- final String directory =
- IsisContext.getConfiguration().getString(ConfigurationConstants.ROOT + "scimpi.error-snapshots", ".");
- File dir = new File(directory);
- if (!dir.exists()) {
- dir.mkdirs();
- }
- writer = new PrintWriter(new File(dir, "error_" + errorRef + ".html"));
- final DebugHtmlWriter writer2 = new DebugHtmlWriter(writer, true);
- writer2.concat(debugHtml);
- writer2.close();
- writer.close();
- } catch (final FileNotFoundException e) {
- LOG.error("Failed to archive error page", e);
- }
- }
-
- public String getReference() {
- return errorRef;
- }
-
- public String getDetails() {
- return debugHtml.toString();
- }
-
- public String getMessage() {
- return message;
- }
-
-
-}
-
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/ForbiddenException.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/ForbiddenException.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/ForbiddenException.java
deleted file mode 100644
index 32d0c0c..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/ForbiddenException.java
+++ /dev/null
@@ -1,68 +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;
-
-import java.util.List;
-
-import org.apache.isis.applib.Identifier;
-import org.apache.isis.core.commons.authentication.AuthenticationSession;
-import org.apache.isis.core.metamodel.facetapi.IdentifiedHolder;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-
-/**
- * Indicates that request could not complete as it could not access (for
- * security reasons) some of the content.
- */
-public class ForbiddenException extends ScimpiException {
- private static final long serialVersionUID = 1L;
- public static final boolean VISIBLE_AND_USABLE = true;
- public static final boolean VISIBLE = false;
- private final Identifier identifier;
- private final AuthenticationSession session;
-
- public ForbiddenException(final String message) {
- this(IsisContext.getAuthenticationSession(), message);
- }
-
- private ForbiddenException(final AuthenticationSession session, final String message) {
- super(message + " for " + session.getUserName() + " " + session.getRoles());
- this.session = session;
- identifier = null;
- }
-
- public ForbiddenException(final IdentifiedHolder target, final boolean isVisibleAndUsabable) {
- this(target.getIdentifier(), IsisContext.getAuthenticationSession(), isVisibleAndUsabable);
- }
-
- private ForbiddenException(final Identifier identifier, final AuthenticationSession session, final boolean isVisibleAndUsabable) {
- super((identifier.getType() == Identifier.Type.PROPERTY_OR_COLLECTION ? "Field" : "Action") + " '" + identifier.getMemberName() + "' in " + identifier.getClassName() + " is not " + (isVisibleAndUsabable ? "visible/usable " : "visible") + " for " + session.getUserName() + " "
- + session.getRoles());
- this.identifier = identifier;
- this.session = session;
- }
-
- public Identifier getIdentifier() {
- return identifier;
- }
-
- public List<String> getRoles() {
- return session.getRoles();
- }
-}
[20/24] Restructuring Scimpi to remove dependencies and enable easier
testing.
Posted by rm...@apache.org.
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/control/AbstractConditionalBlock.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/control/AbstractConditionalBlock.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/control/AbstractConditionalBlock.java
new file mode 100644
index 0000000..4f9ec0d
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/control/AbstractConditionalBlock.java
@@ -0,0 +1,563 @@
+/*
+ * 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.control;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+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.consent.Consent;
+import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacet;
+import org.apache.isis.core.metamodel.facets.typeof.TypeOfFacet;
+import org.apache.isis.core.metamodel.spec.ActionType;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
+import org.apache.isis.core.metamodel.spec.feature.ObjectActionContainer.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.ScimpiException;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.util.MethodsUtils;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+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 TemplateProcessor templateProcessor, RequestState state) {
+ final String id = templateProcessor.getOptionalProperty(OBJECT);
+
+ boolean checkMade = false;
+ boolean allConditionsMet = true;
+
+ final String[] propertyNames = templateProcessor.getAttributes().getPropertyNames(new String[] { "object", "collection" });
+ for (final String propertyName : propertyNames) {
+ boolean result;
+ if (propertyName.equals("set")) {
+ result = templateProcessor.isPropertySet("set");
+ } else {
+ final Test test = tests.get(propertyName);
+ if (test == null) {
+ throw new ScimpiException("No such test: " + propertyName);
+ }
+ final String attributeValue = templateProcessor.getOptionalProperty(propertyName, false);
+ result = test.test(templateProcessor, 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 = templateProcessor.getOptionalProperty("persistent");
+ if (persistent != null) {
+ final ObjectAdapter object = templateProcessor.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 (templateProcessor.isPropertySpecified("empty")) {
+ if (templateProcessor.isPropertySet("empty")) {
+ final String collection = templateProcessor.getOptionalProperty("empty");
+ if (collection != null) {
+ final ObjectAdapter object = templateProcessor.getContext().getMappedObjectOrResult(collection);
+ final CollectionFacet facet = object.getSpecification().getFacet(CollectionFacet.class);
+ checkMade = true;
+ allConditionsMet &= facet.size(object) == 0;
+ }
+ } else {
+ checkMade = true;
+ allConditionsMet &= true;
+ }
+ }
+
+ if (templateProcessor.isPropertySpecified("set")) {
+ final boolean valuePresent = templateProcessor.isPropertySet("set");
+ checkMade = true;
+ allConditionsMet &= valuePresent;
+ }
+
+ if (checkMade) {
+ processTags(allConditionsMet, templateProcessor);
+ } else {
+ throw new ScimpiException("No condition in " + getName());
+ }
+ }
+
+ protected abstract void processTags(boolean isSet, TemplateProcessor templateProcessor);
+
+}
+
+abstract class Test {
+ String name;
+ boolean negateResult;
+
+ abstract boolean test(TemplateProcessor templateProcessor, 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 TemplateProcessor templateProcessor, final String attributeName, final String targetId) {
+ Object variable = templateProcessor.getContext().getVariable(attributeName);
+ if (variable instanceof String && ((String) variable).equals("")) {
+ return false;
+ }
+ return variable != null;
+ }
+}
+
+class TestVariableTrue extends Test {
+ @Override
+ boolean test(final TemplateProcessor templateProcessor, final String attributeName, final String targetId) {
+ final Object variable = templateProcessor.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 TemplateProcessor templateProcessor, final String attributeName, final String targetId) {
+ final ObjectAdapter object = templateProcessor.getContext().getMappedObjectOrResult(attributeName);
+ return object.representsPersistent();
+ }
+}
+
+class TestObjectType extends TestObjectPersistent {
+ @Override
+ boolean test(final TemplateProcessor templateProcessor, final String attributeName, final String targetId) {
+ final ObjectAdapter object = MethodsUtils.findObject(templateProcessor.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 TemplateProcessor templateProcessor, final String attributeName, final String targetId) {
+ final ObjectAdapter object = MethodsUtils.findObject(templateProcessor.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 TemplateProcessor templateProcessor, final String attributeName, final String targetId) {
+ final ObjectAdapter object = MethodsUtils.findObject(templateProcessor.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 TemplateProcessor templateProcessor, final String attributeName, final String targetId) {
+ final ObjectAdapter object = MethodsUtils.findObject(templateProcessor.getContext(), targetId);
+ final List<? extends ObjectAction> objectActions = object.getSpecification().getObjectActions(ActionType.USER, Contributed.INCLUDED);
+ 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 TemplateProcessor templateProcessor, final String attributeName, final String targetId) {
+ final ObjectAdapter object = MethodsUtils.findObject(templateProcessor.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 TemplateProcessor templateProcessor, final String attributeName, final String targetId) {
+ final ObjectAdapter object = MethodsUtils.findObject(templateProcessor.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 TemplateProcessor templateProcessor, final String attributeName, final String targetId) {
+ final ObjectAdapter object = MethodsUtils.findObject(templateProcessor.getContext(), targetId);
+ final List<? extends ObjectAssociation> objectFields = object.getSpecification().getAssociations();
+ 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 TemplateProcessor templateProcessor, final String attributeName, final String targetId) {
+ final ObjectAdapter object = MethodsUtils.findObject(templateProcessor.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 TemplateProcessor templateProcessor, final String attributeName, final String targetId) {
+ final ObjectAdapter object = MethodsUtils.findObject(templateProcessor.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 TemplateProcessor templateProcessor, final String attributeName, final String targetId) {
+ final ObjectAdapter object = MethodsUtils.findObject(templateProcessor.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 TemplateProcessor templateProcessor, final String attributeName, final String targetId) {
+ final ObjectAdapter object = MethodsUtils.findObject(templateProcessor.getContext(), targetId);
+ final ObjectAssociation objectField = findProperty(attributeName, object);
+ IsisContext.getPersistenceSession().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(TemplateProcessor templateProcessor, 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(templateProcessor.getContext(), targetId);
+ final ObjectAssociation objectField = findProperty(fieldName, object);
+ IsisContext.getPersistenceSession().resolveField(object, objectField);
+ final ObjectAdapter fld = objectField.get(object);
+
+ // TODO test for reference or value
+ final ObjectAdapter object2 = MethodsUtils.findObject(templateProcessor.getContext(), fieldValue);
+
+ if (fld == object2) {
+ return true;
+ }
+ return false;
+ }
+
+}
+
+class TestHasRole extends Test {
+ @Override
+ boolean test(final TemplateProcessor templateProcessor, 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 TemplateProcessor templateProcessor, final String attributeName, final String targetId) {
+ final boolean valuePresent = templateProcessor.isPropertySet("set");
+ return valuePresent;
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/control/Forward.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/control/Forward.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/control/Forward.java
new file mode 100644
index 0000000..9f46a5c
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/control/Forward.java
@@ -0,0 +1,38 @@
+/*
+ * 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.control;
+
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+public class Forward extends AbstractElementProcessor {
+
+ @Override
+ public String getName() {
+ return "forward";
+ }
+
+ @Override
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ final String view = templateProcessor.getRequiredProperty(VIEW);
+ templateProcessor.getContext().forward(view);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/control/Redirect.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/control/Redirect.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/control/Redirect.java
new file mode 100644
index 0000000..1554c08
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/control/Redirect.java
@@ -0,0 +1,38 @@
+/*
+ * 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.control;
+
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+public class Redirect extends AbstractElementProcessor {
+
+ @Override
+ public String getName() {
+ return "redirect";
+ }
+
+ @Override
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ final String view = templateProcessor.getRequiredProperty(VIEW);
+ templateProcessor.getContext().redirectTo(view);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/control/Unless.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/control/Unless.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/control/Unless.java
new file mode 100644
index 0000000..b2f8451
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/control/Unless.java
@@ -0,0 +1,41 @@
+/*
+ * 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.control;
+
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+
+public class Unless extends AbstractConditionalBlock {
+
+ @Override
+ protected void processTags(final boolean isSet, final TemplateProcessor templateProcessor) {
+ if (isSet) {
+ templateProcessor.skipUntilClose();
+ templateProcessor.appendDebug(" skipping segment");
+ } else {
+ templateProcessor.processUtilCloseTag();
+ }
+ }
+
+ @Override
+ public String getName() {
+ return "unless";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/control/When.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/control/When.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/control/When.java
new file mode 100644
index 0000000..67f420a
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/control/When.java
@@ -0,0 +1,41 @@
+/*
+ * 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.control;
+
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+
+public class When extends AbstractConditionalBlock {
+
+ @Override
+ protected void processTags(final boolean isSet, final TemplateProcessor templateProcessor) {
+ if (isSet) {
+ templateProcessor.processUtilCloseTag();
+ } else {
+ templateProcessor.appendDebug(" skipping segment");
+ templateProcessor.skipUntilClose();
+ }
+ }
+
+ @Override
+ public String getName() {
+ return "when";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Debug.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Debug.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Debug.java
index d6754ef..6121860 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Debug.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Debug.java
@@ -44,7 +44,8 @@ import org.apache.isis.core.metamodel.spec.feature.ObjectMember;
import org.apache.isis.core.metamodel.util.Dump;
import org.apache.isis.core.runtime.system.context.IsisContext;
import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public class Debug extends AbstractElementProcessor {
@@ -56,19 +57,19 @@ public class Debug extends AbstractElementProcessor {
}
@Override
- public void process(final TagProcessor tagProcessor) {
- if (tagProcessor.getContext().isDebugDisabled()) {
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ if (templateProcessor.getContext().isDebugDisabled()) {
return;
}
- final String type = tagProcessor.getOptionalProperty(TYPE);
+ final String type = templateProcessor.getOptionalProperty(TYPE);
- final boolean alwaysShow = tagProcessor.isRequested("force", false);
+ final boolean alwaysShow = templateProcessor.isRequested("force", false);
if (type != null) {
if (type.equals("system")) {
- displaySystem(tagProcessor);
+ displaySystem(templateProcessor);
} else if (type.equals("session")) {
- displaySession(tagProcessor);
+ displaySession(templateProcessor);
} else if (type.equals("test")) {
final DebugBuilder debug = new DebugHtmlString();
debug.appendTitle("Title");
@@ -106,153 +107,153 @@ public class Debug extends AbstractElementProcessor {
debug.appendln("A lot of text etc.");
debug.endSection();
- tagProcessor.appendHtml(debug.toString());
+ templateProcessor.appendHtml(debug.toString());
//request.appendHtml("<pre>" + debug.toString() + "</pre>");
debug.close();
} else if (type.equals("variables")) {
- displayVariables(tagProcessor);
+ displayVariables(templateProcessor);
} else if (type.equals("dispatcher")) {
- displayDispatcher(tagProcessor);
+ displayDispatcher(templateProcessor);
} else if (type.equals("context")) {
- displayContext(tagProcessor);
+ displayContext(templateProcessor);
} else if (type.equals("specifications")) {
- listSpecifications(tagProcessor);
+ listSpecifications(templateProcessor);
} else if (type.equals("specification-for")) {
- specificationFor(tagProcessor);
+ specificationFor(templateProcessor);
} else if (type.equals("specification")) {
- specification(tagProcessor);
+ specification(templateProcessor);
} else if (type.equals("specification-graph")) {
- specificationGraph(tagProcessor);
+ specificationGraph(templateProcessor);
} else if (type.equals("object-graph")) {
- objectGraph(tagProcessor);
+ objectGraph(templateProcessor);
} else if (type.equals("object")) {
- final String value = tagProcessor.getOptionalProperty(VALUE);
- final Request context = tagProcessor.getContext();
+ final String value = templateProcessor.getOptionalProperty(VALUE);
+ final Request context = templateProcessor.getContext();
final ObjectAdapter object = context.getMappedObject(value);
final DebugString str = new DebugString();
Dump.adapter(object, str);
Dump.graph(object, IsisContext.getAuthenticationSession(), str);
- tagProcessor.appendHtml("<h2>" + object.getSpecification().getFullIdentifier() + "</h2>");
- tagProcessor.appendHtml("<pre class=\"debug\">" + str + "</pre>");
+ templateProcessor.appendHtml("<h2>" + object.getSpecification().getFullIdentifier() + "</h2>");
+ templateProcessor.appendHtml("<pre class=\"debug\">" + str + "</pre>");
}
}
- if (alwaysShow || tagProcessor.getContext().getDebug() == Request.Debug.ON) {
+ if (alwaysShow || templateProcessor.getContext().getDebug() == Request.Debug.ON) {
- final Request context = tagProcessor.getContext();
+ final Request context = templateProcessor.getContext();
- final String id = tagProcessor.getOptionalProperty("object");
+ final String id = templateProcessor.getOptionalProperty("object");
if (id != null) {
final ObjectAdapter object = context.getMappedObject(id);
if (object instanceof DebuggableWithTitle) {
final DebugString debug = new DebugString();
((DebuggableWithTitle) object).debugData(debug);
- tagProcessor.appendHtml("<pre class=\"debug\">" + debug + "</pre>");
+ templateProcessor.appendHtml("<pre class=\"debug\">" + debug + "</pre>");
} else {
- tagProcessor.appendHtml(object.toString());
+ templateProcessor.appendHtml(object.toString());
}
}
- final String variable = tagProcessor.getOptionalProperty("variable");
+ final String variable = templateProcessor.getOptionalProperty("variable");
if (variable != null) {
final Object object = context.getVariable(variable);
- tagProcessor.appendHtml(variable + " => " + (object == null ? "null" : object.toString()));
+ templateProcessor.appendHtml(variable + " => " + (object == null ? "null" : object.toString()));
}
- final String list = tagProcessor.getOptionalProperty("list");
+ final String list = templateProcessor.getOptionalProperty("list");
if (list != null) {
final DebugString debug = new DebugString();
context.append(debug, list);
- tagProcessor.appendHtml(debug.toString());
+ templateProcessor.appendHtml(debug.toString());
}
- final String uri = tagProcessor.getOptionalProperty("uri");
+ final String uri = templateProcessor.getOptionalProperty("uri");
if (uri != null) {
- tagProcessor.appendHtml("<pre class=\"debug\">");
- tagProcessor.appendHtml(context.getUri());
- tagProcessor.appendHtml("</pre>");
+ templateProcessor.appendHtml("<pre class=\"debug\">");
+ templateProcessor.appendHtml(context.getUri());
+ templateProcessor.appendHtml("</pre>");
}
}
}
- protected void objectGraph(final TagProcessor tagProcessor) {
- final String id = tagProcessor.getOptionalProperty(VALUE);
- final ObjectAdapter object = tagProcessor.getContext().getMappedObjectOrResult(id);
- tagProcessor.appendHtml("<h1>Object Graph - " + object + "</h1>");
- tagProcessor.appendHtml("<pre>");
+ protected void objectGraph(final TemplateProcessor templateProcessor) {
+ final String id = templateProcessor.getOptionalProperty(VALUE);
+ final ObjectAdapter object = templateProcessor.getContext().getMappedObjectOrResult(id);
+ templateProcessor.appendHtml("<h1>Object Graph - " + object + "</h1>");
+ templateProcessor.appendHtml("<pre>");
final DebugBuilder debug = new DebugString();
Dump.graph(object, null, debug);
- tagProcessor.appendHtml(debug.toString());
- tagProcessor.appendHtml("</pre>");
+ templateProcessor.appendHtml(debug.toString());
+ templateProcessor.appendHtml("</pre>");
}
- protected void specificationFor(final TagProcessor tagProcessor) {
- final String id = tagProcessor.getOptionalProperty(VALUE);
- final ObjectAdapter object = tagProcessor.getContext().getMappedObjectOrResult(id);
- specification(tagProcessor, object.getSpecification());
+ protected void specificationFor(final TemplateProcessor templateProcessor) {
+ final String id = templateProcessor.getOptionalProperty(VALUE);
+ final ObjectAdapter object = templateProcessor.getContext().getMappedObjectOrResult(id);
+ specification(templateProcessor, object.getSpecification());
}
- protected void specification(final TagProcessor tagProcessor) {
- final String name = tagProcessor.getOptionalProperty(VALUE);
+ protected void specification(final TemplateProcessor templateProcessor) {
+ final String name = templateProcessor.getOptionalProperty(VALUE);
final ObjectSpecification spec = getSpecificationLoader().loadSpecification(name);
- specification(tagProcessor, spec);
+ specification(templateProcessor, spec);
}
- private void specification(final TagProcessor tagProcessor, final ObjectSpecification spec) {
- tagProcessor.appendHtml("<h1>Specification - " + spec.getFullIdentifier() + "</h1>");
- tagProcessor.appendHtml("<p><a href=\"./debug.shtml?type=specification-graph&value=" + spec.getFullIdentifier() + "\">Specification Graph</a></p>");
+ private void specification(final TemplateProcessor templateProcessor, final ObjectSpecification spec) {
+ templateProcessor.appendHtml("<h1>Specification - " + spec.getFullIdentifier() + "</h1>");
+ templateProcessor.appendHtml("<p><a href=\"./debug.shtml?type=specification-graph&value=" + spec.getFullIdentifier() + "\">Specification Graph</a></p>");
final DebugBuilder debug = new DebugHtmlString();
specification(spec, debug);
- tagProcessor.appendHtml(debug.toString());
+ templateProcessor.appendHtml(debug.toString());
}
- protected void specificationGraph(final TagProcessor tagProcessor) {
- final String name = tagProcessor.getOptionalProperty(VALUE);
+ protected void specificationGraph(final TemplateProcessor templateProcessor) {
+ final String name = templateProcessor.getOptionalProperty(VALUE);
final ObjectSpecification spec = getSpecificationLoader().loadSpecification(name);
- tagProcessor.appendHtml("<h1>Specification Graph - " + spec.getFullIdentifier() + "</h1>");
- tagProcessor.appendHtml("<p><a href=\"./debug.shtml?type=specification&value=" + spec.getFullIdentifier() + "\">Full Specification</a></p>");
- tagProcessor.appendHtml("<pre>");
+ templateProcessor.appendHtml("<h1>Specification Graph - " + spec.getFullIdentifier() + "</h1>");
+ templateProcessor.appendHtml("<p><a href=\"./debug.shtml?type=specification&value=" + spec.getFullIdentifier() + "\">Full Specification</a></p>");
+ templateProcessor.appendHtml("<pre>");
final DebugBuilder debug = new DebugString();
debug.appendln(spec.getFullIdentifier());
debug.indent();
specificationGraph(spec, debug, new ArrayList<ObjectSpecification>());
debug.unindent();
- tagProcessor.appendHtml(debug.toString());
- tagProcessor.appendHtml("</pre>");
+ templateProcessor.appendHtml(debug.toString());
+ templateProcessor.appendHtml("</pre>");
}
- private void displayContext(final TagProcessor tagProcessor) {
- tagProcessor.appendHtml("<h1>Context</h1>");
+ private void displayContext(final TemplateProcessor templateProcessor) {
+ templateProcessor.appendHtml("<h1>Context</h1>");
final DebugHtmlString debugString = new DebugHtmlString();
- tagProcessor.getContext().append(debugString);
+ templateProcessor.getContext().append(debugString);
debugString.close();
- tagProcessor.appendHtml(debugString.toString());
+ templateProcessor.appendHtml(debugString.toString());
}
- private void displayDispatcher(final TagProcessor tagProcessor) {
- tagProcessor.appendHtml("<h1>Dispatcher</h1>");
+ private void displayDispatcher(final TemplateProcessor templateProcessor) {
+ templateProcessor.appendHtml("<h1>Dispatcher</h1>");
final DebugHtmlString debugString = new DebugHtmlString();
dispatcher.debugData(debugString);
debugString.close();
- tagProcessor.appendHtml(debugString.toString());
+ templateProcessor.appendHtml(debugString.toString());
}
- protected void displayVariables(final TagProcessor tagProcessor) {
- tagProcessor.appendHtml("<h1>Variables</h1>");
+ protected void displayVariables(final TemplateProcessor templateProcessor) {
+ templateProcessor.appendHtml("<h1>Variables</h1>");
final DebugHtmlString debug = new DebugHtmlString();
- final Request context = tagProcessor.getContext();
+ final Request context = templateProcessor.getContext();
context.append(debug, "variables");
debug.close();
- tagProcessor.appendHtml(debug.toString());
+ templateProcessor.appendHtml(debug.toString());
}
- protected void displaySystem(final TagProcessor tagProcessor) {
- tagProcessor.appendHtml("<h1>System</h1>");
+ protected void displaySystem(final TemplateProcessor templateProcessor) {
+ templateProcessor.appendHtml("<h1>System</h1>");
final DebuggableWithTitle[] debugItems = IsisContext.debugSystem();
for (final DebuggableWithTitle debug : debugItems) {
final DebugHtmlString debugBuffer = new DebugHtmlString();
@@ -260,12 +261,12 @@ public class Debug extends AbstractElementProcessor {
debug.debugData(debugBuffer);
debugBuffer.endSection();
debugBuffer.close();
- tagProcessor.appendHtml(debugBuffer.toString());
+ templateProcessor.appendHtml(debugBuffer.toString());
}
}
- protected void displaySession(final TagProcessor tagProcessor) {
- tagProcessor.appendHtml("<h1>Session</h1>");
+ protected void displaySession(final TemplateProcessor templateProcessor) {
+ templateProcessor.appendHtml("<h1>Session</h1>");
final DebuggableWithTitle[] debugItems = IsisContext.debugSession();
for (final DebuggableWithTitle debug : debugItems) {
final DebugHtmlString debugBuffer = new DebugHtmlString();
@@ -273,12 +274,12 @@ public class Debug extends AbstractElementProcessor {
debug.debugData(debugBuffer);
debugBuffer.endSection();
debugBuffer.close();
- tagProcessor.appendHtml(debugBuffer.toString());
+ templateProcessor.appendHtml(debugBuffer.toString());
}
}
- protected void listSpecifications(final TagProcessor tagProcessor) {
- tagProcessor.appendHtml("<h1>Specifications</h1>");
+ protected void listSpecifications(final TemplateProcessor templateProcessor) {
+ templateProcessor.appendHtml("<h1>Specifications</h1>");
final List<ObjectSpecification> fullIdentifierList = new ArrayList<ObjectSpecification>(getSpecificationLoader().allSpecifications());
Collections.sort(fullIdentifierList, ObjectSpecification.COMPARATOR_SHORT_IDENTIFIER_IGNORE_CASE);
final DebugHtmlString debug = new DebugHtmlString();
@@ -287,7 +288,7 @@ public class Debug extends AbstractElementProcessor {
debug.appendln(name, specificationLink(spec));
}
debug.close();
- tagProcessor.appendHtml(debug.toString());
+ templateProcessor.appendHtml(debug.toString());
}
private String specificationLink(final ObjectSpecification specification) {
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/DebugAccessCheck.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/DebugAccessCheck.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/DebugAccessCheck.java
index f48fcad..a418d87 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/DebugAccessCheck.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/DebugAccessCheck.java
@@ -20,14 +20,15 @@
package org.apache.isis.viewer.scimpi.dispatcher.view.debug;
import org.apache.isis.viewer.scimpi.ForbiddenException;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public class DebugAccessCheck extends AbstractElementProcessor {
@Override
- public void process(final TagProcessor tagProcessor) {
- if (tagProcessor.getContext().isDebugDisabled()) {
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ if (templateProcessor.getContext().isDebugDisabled()) {
throw new ForbiddenException("Debug is disabled");
}
}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/DebugCollectionView.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/DebugCollectionView.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/DebugCollectionView.java
index bab6e54..a39a254 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/DebugCollectionView.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/DebugCollectionView.java
@@ -23,33 +23,34 @@ import java.util.List;
import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractObjectProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.view.field.LinkedObject;
+import org.apache.isis.viewer.scimpi.dispatcher.view.determine.LinkedObject;
import org.apache.isis.viewer.scimpi.dispatcher.view.other.HelpLink;
public class DebugCollectionView extends AbstractObjectProcessor {
@Override
- public void process(final TagProcessor tagProcessor, final ObjectAdapter object) {
- final String cls = tagProcessor.getOptionalProperty(CLASS, "form");
+ public void process(final TemplateProcessor templateProcessor, final ObjectAdapter object) {
+ final String cls = templateProcessor.getOptionalProperty(CLASS, "form");
final String classString = " class=\"" + cls + "\"";
- String title = tagProcessor.getOptionalProperty(FORM_TITLE);
- final String oddRowClass = tagProcessor.getOptionalProperty(ODD_ROW_CLASS);
- final String evenRowClass = tagProcessor.getOptionalProperty(EVEN_ROW_CLASS);
- final boolean showIcons = tagProcessor.isRequested(SHOW_ICON, true);
+ String title = templateProcessor.getOptionalProperty(FORM_TITLE);
+ final String oddRowClass = templateProcessor.getOptionalProperty(ODD_ROW_CLASS);
+ final String evenRowClass = templateProcessor.getOptionalProperty(EVEN_ROW_CLASS);
+ final boolean showIcons = templateProcessor.isRequested(SHOW_ICON, true);
+ write(templateProcessor, object, null, null, classString, title, oddRowClass, evenRowClass, showIcons);
}
- private void write(final TagProcessor tagProcessor, final ObjectAdapter object, final List<ObjectAssociation> fields,
+ private void write(final TemplateProcessor templateProcessor, final ObjectAdapter object, final List<ObjectAssociation> fields,
final LinkedObject[] linkFields, final String classString, final String title, final String oddRowClass,
final String evenRowClass, final boolean showIcons) {
- tagProcessor.appendHtml("<div" + classString + ">");
+ templateProcessor.appendHtml("<div" + classString + ">");
if (title != null) {
- tagProcessor.appendHtml("<div class=\"title\">");
- tagProcessor.appendAsHtmlEncoded(title);
- tagProcessor.appendHtml("</div>");
- HelpLink.append(tagProcessor, object.getSpecification().getDescription(), object.getSpecification().getHelp());
+ templateProcessor.appendHtml("<div class=\"title\">");
+ templateProcessor.appendAsHtmlEncoded(title);
+ templateProcessor.appendHtml("</div>");
+ HelpLink.append(templateProcessor, object.getSpecification().getDescription(), object.getSpecification().getHelp());
}
/*
final List<ObjectAssociation> fields =
@@ -97,7 +98,7 @@ public class DebugCollectionView extends AbstractObjectProcessor {
request.appendHtml("</div>");
}
*/
- tagProcessor.appendHtml("</div>");
+ templateProcessor.appendHtml("</div>");
}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/DebugObjectView.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/DebugObjectView.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/DebugObjectView.java
index cb16c94..9273adf 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/DebugObjectView.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/DebugObjectView.java
@@ -30,34 +30,34 @@ import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
import org.apache.isis.core.metamodel.spec.feature.ObjectAssociationFilters;
import org.apache.isis.core.runtime.system.context.IsisContext;
import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractObjectProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.view.display.FieldValue;
-import org.apache.isis.viewer.scimpi.dispatcher.view.field.LinkedObject;
+import org.apache.isis.viewer.scimpi.dispatcher.view.determine.LinkedObject;
+import org.apache.isis.viewer.scimpi.dispatcher.view.object.FieldValue;
public class DebugObjectView extends AbstractObjectProcessor {
@Override
- public void process(final TagProcessor tagProcessor, final ObjectAdapter object) {
- final String classString = " class=\"" + tagProcessor.getOptionalProperty(CLASS, "form debug") + "\"";
- final String objectLink = tagProcessor.getOptionalProperty(OBJECT + "-" + LINK_VIEW, tagProcessor.getViewPath());
+ public void process(final TemplateProcessor templateProcessor, final ObjectAdapter object) {
+ final String classString = " class=\"" + templateProcessor.getOptionalProperty(CLASS, "form debug") + "\"";
+ final String objectLink = templateProcessor.getOptionalProperty(OBJECT + "-" + LINK_VIEW, templateProcessor.getViewPath());
// final String collectionLink = request.getOptionalProperty(COLLECTION + "-" + LINK_VIEW, request.getViewPath());
- final String oddRowClass = tagProcessor.getOptionalProperty(ODD_ROW_CLASS);
- final String evenRowClass = tagProcessor.getOptionalProperty(EVEN_ROW_CLASS);
- final boolean showIcons = tagProcessor.isRequested(SHOW_ICON, true);
+ final String oddRowClass = templateProcessor.getOptionalProperty(ODD_ROW_CLASS);
+ final String evenRowClass = templateProcessor.getOptionalProperty(EVEN_ROW_CLASS);
+ final boolean showIcons = templateProcessor.isRequested(SHOW_ICON, true);
ObjectSpecification specification = object.getSpecification();
- tagProcessor.appendHtml("<div" + classString + ">");
- tagProcessor.appendHtml("<div class=\"title\">");
- tagProcessor.appendAsHtmlEncoded(specification.getSingularName() + " - " + specification.getFullIdentifier());
- tagProcessor.appendHtml("</div>");
+ templateProcessor.appendHtml("<div" + classString + ">");
+ templateProcessor.appendHtml("<div class=\"title\">");
+ templateProcessor.appendAsHtmlEncoded(specification.getSingularName() + " - " + specification.getFullIdentifier());
+ templateProcessor.appendHtml("</div>");
Version version = object.getVersion();
- tagProcessor.appendHtml("<div class=\"version\">");
- tagProcessor.appendAsHtmlEncoded("#" + version.sequence() + " - " + version.getUser() + " (" + version.getTime() + ")" );
- tagProcessor.appendHtml("</div>");
+ templateProcessor.appendHtml("<div class=\"version\">");
+ templateProcessor.appendAsHtmlEncoded("#" + version.sequence() + " - " + version.getUser() + " (" + version.getTime() + ")" );
+ templateProcessor.appendHtml("</div>");
final List<ObjectAssociation> fields = specification.getAssociations(ObjectAssociationFilters.ALL);
@@ -73,9 +73,9 @@ public class DebugObjectView extends AbstractObjectProcessor {
} else {
cls = " class=\"field " + (evenRowClass == null ? EVEN_ROW_CLASS : evenRowClass) + "\"";
}
- tagProcessor.appendHtml("<div " + cls + "><span class=\"label\">");
- tagProcessor.appendAsHtmlEncoded(field.getName());
- tagProcessor.appendHtml(":</span>");
+ templateProcessor.appendHtml("<div " + cls + "><span class=\"label\">");
+ templateProcessor.appendAsHtmlEncoded(field.getName());
+ templateProcessor.appendHtml(":</span>");
final boolean isNotParseable =
!fields.get(i).getSpecification().containsFacet(ParseableFacet.class);
@@ -84,44 +84,44 @@ public class DebugObjectView extends AbstractObjectProcessor {
// linkedObject = new LinkedObject(field.isOneToManyAssociation() ? collectionLink : objectLink);
linkedObject = new LinkedObject(objectLink);
}
- addField(tagProcessor, object, field, linkedObject, showIcons);
+ addField(templateProcessor, object, field, linkedObject, showIcons);
if (field.isOneToManyAssociation()) {
Collection collection = (Collection) field.get(object).getObject();
if (collection.size() == 0) {
- tagProcessor.appendHtml("[empty]");
+ templateProcessor.appendHtml("[empty]");
} else {
// request.appendHtml(collection.size() + " elements");
- tagProcessor.appendHtml("<ol>");
+ templateProcessor.appendHtml("<ol>");
for (Object element : collection) {
ObjectAdapter adapterFor = IsisContext.getPersistenceSession().getAdapterManager().getAdapterFor(element);
IsisContext.getPersistenceSession().resolveImmediately(adapterFor);
- String id = tagProcessor.getContext().mapObject(adapterFor, linkedObject.getScope(), Scope.INTERACTION);
+ String id = templateProcessor.getContext().mapObject(adapterFor, linkedObject.getScope(), Scope.INTERACTION);
- tagProcessor.appendHtml("<li class=\"element\">");
- tagProcessor.appendHtml("<a href=\"" + linkedObject.getForwardView() + "?" + linkedObject.getVariable() + "="
- + id + tagProcessor.getContext().encodedInteractionParameters() + "\">");
- tagProcessor.appendHtml(element.toString());
- tagProcessor.appendHtml("</a></li>");
+ templateProcessor.appendHtml("<li class=\"element\">");
+ templateProcessor.appendHtml("<a href=\"" + linkedObject.getForwardView() + "?" + linkedObject.getVariable() + "="
+ + id + templateProcessor.getContext().encodedInteractionParameters() + "\">");
+ templateProcessor.appendHtml(element.toString());
+ templateProcessor.appendHtml("</a></li>");
}
- tagProcessor.appendHtml("</ol>");
+ templateProcessor.appendHtml("</ol>");
}
} else {
- FieldValue.write(tagProcessor, object, field, linkedObject, "value", showIcons, 0);
+ FieldValue.write(templateProcessor, object, field, linkedObject, "value", showIcons, 0);
}
- tagProcessor.appendHtml("</div>");
+ templateProcessor.appendHtml("</div>");
}
- tagProcessor.appendHtml("</div>");
+ templateProcessor.appendHtml("</div>");
}
protected void addField(
- final TagProcessor tagProcessor,
+ final TemplateProcessor templateProcessor,
final ObjectAdapter object,
final ObjectAssociation field,
final LinkedObject linkedObject,
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/DebugUsersView.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/DebugUsersView.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/DebugUsersView.java
new file mode 100644
index 0000000..6aad2ca
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/DebugUsersView.java
@@ -0,0 +1,51 @@
+/*
+ * 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.debug;
+
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+public class DebugUsersView extends AbstractElementProcessor {
+
+ @Override
+ public String getName() {
+ return "debug-users";
+ }
+
+ @Override
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ final String view = templateProcessor.getContext().getContextPath() + templateProcessor.getContext().getResourceParentPath() + templateProcessor.getContext().getResourceFile();
+
+ templateProcessor.appendHtml("<form class=\"generic action\" action=\"debug-user.app\" method=\"post\" accept-charset=\"ISO-8859-1\">\n");
+ templateProcessor.appendHtml("<div class=\"title\">Add Debug User</div>\n");
+ templateProcessor.appendHtml("<div class=\"field\"><label>User Name:</label><input type=\"text\" name=\"name\" size=\"30\" /></div>\n");
+ templateProcessor.appendHtml("<input type=\"hidden\" name=\"method\" value=\"add\" />\n");
+ templateProcessor.appendHtml("<input type=\"hidden\" name=\"view\" value=\"" + view + "\" />\n");
+ templateProcessor.appendHtml("<input class=\"button\" type=\"submit\" value=\"Add User\" />\n");
+ templateProcessor.appendHtml("</form>\n");
+
+ templateProcessor.appendHtml("<table class=\"debug\">\n<tr><th class=\"title\">Name</th><th class=\"title\"></th></tr>\n");
+ for (final String name : templateProcessor.getContext().getDebugUsers()) {
+ templateProcessor.appendHtml("<tr><th>" + name + "</th><th><a href=\"debug-user.app?method=remove&name=" + name + "&view=" + view + " \">remove</a></th></tr>\n");
+ }
+ templateProcessor.appendHtml("</table>\n");
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/DebuggerLink.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/DebuggerLink.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/DebuggerLink.java
index 64c7ecb..78e7f33 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/DebuggerLink.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/DebuggerLink.java
@@ -19,30 +19,32 @@
package org.apache.isis.viewer.scimpi.dispatcher.view.debug;
+import org.apache.isis.viewer.scimpi.Names;
import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public class DebuggerLink extends AbstractElementProcessor {
@Override
- public void process(final TagProcessor tagProcessor) {
- if (tagProcessor.getContext().isDebugDisabled()) {
- tagProcessor.skipUntilClose();
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ if (templateProcessor.getContext().isDebugDisabled()) {
+ templateProcessor.skipUntilClose();
return;
}
- final Request context = tagProcessor.getContext();
- final Object result = context.getVariable(Request.RESULT);
- tagProcessor.appendHtml("<div class=\"debug\">");
- tagProcessor.appendHtml("<a class=\"debug-link\" href=\"/debug/debug.shtml\" target=\"debug\" title=\"debug\" >...</a>");
+ final Request context = templateProcessor.getContext();
+ final Object result = context.getVariable(Names.RESULT);
+ templateProcessor.appendHtml("<div class=\"debug\">");
+ templateProcessor.appendHtml("<a class=\"debug-link\" href=\"/debug/debug.shtml\" target=\"debug\" title=\"debug\" >...</a>");
if (result != null) {
- tagProcessor.appendHtml(" <a href=\"/debug/object.shtml?_result=" + result + "\" target=\"debug\" title=\"debug instance\">...</a>");
+ templateProcessor.appendHtml(" <a href=\"/debug/object.shtml?_result=" + result + "\" target=\"debug\" title=\"debug instance\">...</a>");
}
- tagProcessor.appendHtml(" <span class=\"debug-link\" onclick=\"$('#page-debug').toggle()\" alt=\"show/hide debug details\">...</span>");
- tagProcessor.appendHtml("</div>");
+ templateProcessor.appendHtml(" <span class=\"debug-link\" onclick=\"$('#page-debug').toggle()\" alt=\"show/hide debug details\">...</span>");
+ templateProcessor.appendHtml("</div>");
- tagProcessor.processUtilCloseTag();
+ templateProcessor.processUtilCloseTag();
}
@Override
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Diagnostics.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Diagnostics.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Diagnostics.java
index 0033c55..9c05671 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Diagnostics.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Diagnostics.java
@@ -24,53 +24,54 @@ import org.apache.isis.core.commons.debug.DebugHtmlString;
import org.apache.isis.core.runtime.system.context.IsisContext;
import org.apache.isis.viewer.scimpi.Names;
import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public class Diagnostics extends AbstractElementProcessor {
@Override
- public void process(final TagProcessor tagProcessor) {
- if (tagProcessor.getContext().isDebugDisabled()) {
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ if (templateProcessor.getContext().isDebugDisabled()) {
return;
}
- final String type = tagProcessor.getOptionalProperty(TYPE, "page");
- final boolean isForced = tagProcessor.isRequested("force");
- if (isForced || tagProcessor.getContext().showDebugData()) {
- tagProcessor.appendHtml("<div class=\"debug\">");
+ final String type = templateProcessor.getOptionalProperty(TYPE, "page");
+ final boolean isForced = templateProcessor.isRequested("force");
+ if (isForced || templateProcessor.getContext().showDebugData()) {
+ templateProcessor.appendHtml("<div class=\"debug\">");
if ("page".equals(type)) {
- tagProcessor.appendHtml("<pre>");
- final Request context = tagProcessor.getContext();
- tagProcessor.appendHtml("URI: " + context.getUri());
- tagProcessor.appendHtml("\n");
- tagProcessor.appendHtml("File: " + context.fullFilePath(context.getResourceFile()));
- final String result = (String) tagProcessor.getContext().getVariable(Names.RESULT);
+ templateProcessor.appendHtml("<pre>");
+ final Request context = templateProcessor.getContext();
+ templateProcessor.appendHtml("URI: " + context.getUri());
+ templateProcessor.appendHtml("\n");
+ templateProcessor.appendHtml("File: " + context.fullFilePath(context.getResourceFile()));
+ final String result = (String) templateProcessor.getContext().getVariable(Names.RESULT);
if (result != null) {
- tagProcessor.appendHtml("\n");
- tagProcessor.appendHtml("Object: " + result);
+ templateProcessor.appendHtml("\n");
+ templateProcessor.appendHtml("Object: " + result);
}
- tagProcessor.appendHtml("</pre>");
+ templateProcessor.appendHtml("</pre>");
} else if ("session".equals(type)) {
- tagProcessor.appendHtml("<pre>");
+ templateProcessor.appendHtml("<pre>");
final AuthenticationSession session = IsisContext.getAuthenticationSession();
- tagProcessor.appendHtml("Session: " + session.getUserName() + " " + session.getRoles());
- tagProcessor.appendHtml("</pre>");
+ templateProcessor.appendHtml("Session: " + session.getUserName() + " " + session.getRoles());
+ templateProcessor.appendHtml("</pre>");
} else if ("variables".equals(type)) {
- final Request context = tagProcessor.getContext();
+ final Request context = templateProcessor.getContext();
final DebugHtmlString debug = new DebugHtmlString();
debug.appendln("", "");
context.append(debug, "variables");
debug.close();
- tagProcessor.appendHtml(debug.toString());
+ templateProcessor.appendHtml(debug.toString());
} else if ("processing".equals(type)) {
- tagProcessor.appendHtml("<pre>");
- tagProcessor.appendHtml(tagProcessor.getContext().getDebugTrace());
- tagProcessor.appendHtml("</pre>");
+ templateProcessor.appendHtml("<pre>");
+ templateProcessor.appendHtml(templateProcessor.getContext().getDebugTrace());
+ templateProcessor.appendHtml("</pre>");
} else {
- tagProcessor.appendHtml("<i>No such type " + type + "</i>");
+ templateProcessor.appendHtml("<i>No such type " + type + "</i>");
}
- tagProcessor.appendHtml("</div>");
+ templateProcessor.appendHtml("</div>");
}
}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Log.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Log.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Log.java
index ae07894..a63bd21 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Log.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Log.java
@@ -19,20 +19,21 @@
package org.apache.isis.viewer.scimpi.dispatcher.view.debug;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
import org.apache.log4j.Logger;
public class Log extends AbstractElementProcessor {
@Override
- public void process(final TagProcessor tagProcessor) {
- String name = tagProcessor.getRequiredProperty(NAME);
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ String name = templateProcessor.getRequiredProperty(NAME);
Logger logger = Logger.getLogger(name);
- tagProcessor.pushNewBuffer();
- tagProcessor.processUtilCloseTag();
- final String message = tagProcessor.popBuffer();
+ templateProcessor.pushNewBuffer();
+ templateProcessor.processUtilCloseTag();
+ final String message = templateProcessor.popBuffer();
logger.info(message);
}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/LogLevel.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/LogLevel.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/LogLevel.java
index 9c954e6..d567e8a 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/LogLevel.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/LogLevel.java
@@ -22,31 +22,32 @@ package org.apache.isis.viewer.scimpi.dispatcher.view.debug;
import org.apache.log4j.Level;
import org.apache.log4j.LogManager;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public class LogLevel extends AbstractElementProcessor {
@Override
- public void process(final TagProcessor tagProcessor) {
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
- String view = tagProcessor.getOptionalProperty(VIEW, tagProcessor.getViewPath());
- view = tagProcessor.getContext().fullFilePath(view);
+ String view = templateProcessor.getOptionalProperty(VIEW, templateProcessor.getViewPath());
+ view = templateProcessor.getContext().fullFilePath(view);
final Level level = LogManager.getRootLogger().getLevel();
- final boolean showSelector = tagProcessor.isRequested(SHOW_SELECT, true);
+ final boolean showSelector = templateProcessor.isRequested(SHOW_SELECT, true);
if (showSelector) {
- tagProcessor.appendHtml("<form action=\"log.app\" type=\"post\" >");
- tagProcessor.appendHtml("<input type=\"hidden\" name=\"view\" value=\"" + view + "\" />");
- tagProcessor.appendHtml("<select name=\"level\">");
+ templateProcessor.appendHtml("<form action=\"log.app\" type=\"post\" >");
+ templateProcessor.appendHtml("<input type=\"hidden\" name=\"view\" value=\"" + view + "\" />");
+ templateProcessor.appendHtml("<select name=\"level\">");
for (final Level l : new Level[] { Level.OFF, Level.FATAL, Level.ERROR, Level.WARN, Level.INFO, Level.DEBUG, Level.TRACE }) {
final String settings = level + "\"" + (level == l ? " selected=\"selected\" " : "");
- tagProcessor.appendHtml("<option " + settings + ">" + l + "</option>");
+ templateProcessor.appendHtml("<option " + settings + ">" + l + "</option>");
}
- tagProcessor.appendHtml("<input type=\"submit\" value=\"Change Level\" />");
- tagProcessor.appendHtml("</select>");
- tagProcessor.appendHtml("</form>");
+ templateProcessor.appendHtml("<input type=\"submit\" value=\"Change Level\" />");
+ templateProcessor.appendHtml("</select>");
+ templateProcessor.appendHtml("</form>");
} else {
- tagProcessor.appendHtml(level.toString());
+ templateProcessor.appendHtml(level.toString());
}
}
[17/24] Restructuring Scimpi to remove dependencies and enable easier
testing.
Posted by rm...@apache.org.
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/field/LinkedFieldsBlock.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/field/LinkedFieldsBlock.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/field/LinkedFieldsBlock.java
deleted file mode 100644
index 5049a3d..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/field/LinkedFieldsBlock.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.viewer.scimpi.dispatcher.view.field;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
-
-public class LinkedFieldsBlock extends InclusionList {
- private final Map<String, LinkedObject> linkedFields = new HashMap<String, LinkedObject>();
-
- public void link(final String field, final String variable, final String scope, final String forwardView) {
- include(field);
- linkedFields.put(field, new LinkedObject(variable, scope, forwardView));
- }
-
- public LinkedObject[] linkedFields(final List<ObjectAssociation> fields) {
- final LinkedObject[] includedFields = new LinkedObject[fields.size()];
- for (int i = 0; i < fields.size(); i++) {
- final String id2 = fields.get(i).getId();
- if (fields.get(i).isOneToOneAssociation() && linkedFields.containsKey(id2)) {
- includedFields[i] = linkedFields.get(id2);
- }
- }
- return includedFields;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/field/LinkedObject.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/field/LinkedObject.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/field/LinkedObject.java
deleted file mode 100644
index 934e1c1..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/field/LinkedObject.java
+++ /dev/null
@@ -1,58 +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.field;
-
-import org.apache.isis.viewer.scimpi.Names;
-import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
-
-public class LinkedObject {
- private final String variable;
- private final String scope;
- private String forwardView;
-
- public LinkedObject(final String variable, final String scope, final String forwardView) {
- this.variable = variable;
- this.scope = scope;
- this.forwardView = forwardView;
- }
-
- public LinkedObject(final String forwardView) {
- this.forwardView = forwardView;
- scope = Scope.INTERACTION.toString();
- variable = Names.RESULT;
- }
-
- public String getVariable() {
- return variable;
- }
-
- public String getScope() {
- return scope;
- }
-
- public String getForwardView() {
- return forwardView;
- }
-
- public void setForwardView(final String path) {
- forwardView = path;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/form/ActionFormAbstract.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/form/ActionFormAbstract.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/form/ActionFormAbstract.java
new file mode 100644
index 0000000..f3fa4dd
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/form/ActionFormAbstract.java
@@ -0,0 +1,223 @@
+package org.apache.isis.viewer.scimpi.dispatcher.view.form;
+
+import java.util.List;
+
+import org.apache.isis.applib.annotation.Where;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
+import org.apache.isis.core.metamodel.spec.feature.ObjectActionParameter;
+import org.apache.isis.viewer.scimpi.Names;
+import org.apache.isis.viewer.scimpi.ScimpiException;
+import org.apache.isis.viewer.scimpi.dispatcher.action.ActionAction;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.form.FieldEditState;
+import org.apache.isis.viewer.scimpi.dispatcher.form.FormState;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.util.MethodsUtils;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+// TODO combine the common stuff that is found here and in EditFormAbstract and LoginFormAbstract
+public abstract class ActionFormAbstract extends AbstractElementProcessor {
+
+ private static final Where where = Where.OBJECT_FORMS;
+
+ public static void createForm(final TemplateProcessor templateProcessor, final CreateFormParameter parameterObject) {
+ createForm(templateProcessor, parameterObject, false);
+ }
+
+ public static void createForm(final TemplateProcessor templateProcessor, final CreateFormParameter parameterObject, final boolean withoutProcessing) {
+ final Request context = templateProcessor.getContext();
+ final ObjectAdapter object = MethodsUtils.findObject(context, parameterObject.objectId);
+ final String version = templateProcessor.getContext().mapVersion(object);
+ final ObjectAction action = MethodsUtils.findAction(object, parameterObject.methodName);
+ // TODO how do we distinguish between overloaded methods?
+
+ // REVIEW Is this useful?
+ if (action.getParameterCount() == 0) {
+ throw new ScimpiException("Action form can only be used for actions with parameters");
+ }
+ if (parameterObject.showMessage && MethodsUtils.isVisible(object, action, where)) {
+ final String notUsable = MethodsUtils.isUsable(object, action, where);
+ if (notUsable != null) {
+ if (!withoutProcessing) {
+ templateProcessor.skipUntilClose();
+ }
+ templateProcessor.appendHtml("<div class=\"" + parameterObject.className + "-message\" >");
+ templateProcessor.appendAsHtmlEncoded(notUsable);
+ templateProcessor.appendHtml("</div>");
+ return;
+ }
+ }
+ if (!MethodsUtils.isVisibleAndUsable(object, action, where)) {
+ if (!withoutProcessing) {
+ templateProcessor.skipUntilClose();
+ }
+ return;
+ }
+ final String objectId = context.mapObject(object, Scope.INTERACTION);
+ final String errorView = context.fullFilePath(parameterObject.forwardErrorTo == null ? context.getResourceFile() : parameterObject.forwardErrorTo);
+ final String voidView = context.fullFilePath(parameterObject.forwardVoidTo == null ? context.getResourceFile() : parameterObject.forwardVoidTo);
+ if (action.isContributed() && !action.hasReturn() && parameterObject.resultOverride == null) {
+ parameterObject.resultOverride = objectId;
+ }
+ final HiddenInputField[] hiddenFields = new HiddenInputField[] { new HiddenInputField("_" + OBJECT, objectId), new HiddenInputField("_" + VERSION, version), new HiddenInputField("_" + FORM_ID, parameterObject.formId), new HiddenInputField("_" + METHOD, parameterObject.methodName),
+ parameterObject.forwardResultTo == null ? null : new HiddenInputField("_" + VIEW, context.fullFilePath(parameterObject.forwardResultTo)), new HiddenInputField("_" + VOID, voidView), new HiddenInputField("_" + ERROR, errorView),
+ parameterObject.completionMessage == null ? null : new HiddenInputField("_" + MESSAGE, parameterObject.completionMessage), parameterObject.scope == null ? null : new HiddenInputField("_" + SCOPE, parameterObject.scope),
+ parameterObject.resultOverride == null ? null : new HiddenInputField("_" + RESULT_OVERRIDE, parameterObject.resultOverride), parameterObject.resultName == null ? null : new HiddenInputField("_" + RESULT_NAME, parameterObject.resultName),
+ parameterObject.resultName == null ? null : new HiddenInputField(Names.RESULT, (String) templateProcessor.getContext().getVariable(Names.RESULT)) };
+
+ // TODO when the block contains a selector tag it doesn't disable it if
+ // the field cannot be edited!!!
+ final FormFieldBlock containedBlock = new FormFieldBlock() {
+ @Override
+ public boolean isNullable(final String name) {
+ final int index = Integer.parseInt(name.substring(5)) - 1;
+ final ObjectActionParameter param = action.getParameters().get(index);
+ return param.isOptional();
+ }
+ };
+ templateProcessor.pushBlock(containedBlock);
+ if (!withoutProcessing) {
+ templateProcessor.processUtilCloseTag();
+ }
+
+ final FormState entryState = (FormState) context.getVariable(ENTRY_FIELDS);
+
+ // TODO the list of included fields should be considered in the next
+ // method (see EditObject)
+ final InputField[] formFields = createFields(action, object);
+ hideExcludedParameters(containedBlock, formFields);
+ containedBlock.setUpValues(formFields);
+ initializeFields(context, object, action, formFields);
+ setDefaults(context, object, action, formFields, entryState, parameterObject.showIcon);
+ String errors = null;
+ if (entryState != null && entryState.isForForm(parameterObject.formId)) {
+ copyEntryState(context, object, action, formFields, entryState);
+ errors = entryState.getError();
+ }
+ overrideWithHtml(context, containedBlock, formFields);
+
+ String formTitle;
+ if (parameterObject.formTitle == null) {
+ formTitle = action.getName();
+ } else {
+ formTitle = parameterObject.formTitle;
+ }
+
+ String buttonTitle = parameterObject.buttonTitle;
+ if (buttonTitle == null) {
+ buttonTitle = action.getName();
+ } else if (buttonTitle.equals("")) {
+ buttonTitle = "Ok";
+ }
+
+ HtmlFormBuilder.createForm(templateProcessor, ActionAction.ACTION + ".app", hiddenFields, formFields, parameterObject.className,
+ parameterObject.id, formTitle, parameterObject.labelDelimiter, action.getDescription(), action.getHelp(), buttonTitle, errors, parameterObject.cancelTo);
+
+ templateProcessor.popBlock();
+ }
+
+ private static void hideExcludedParameters(final FormFieldBlock containedBlock, final InputField[] formFields) {
+ for (final InputField inputField : formFields) {
+ final String id2 = inputField.getName();
+ if (!containedBlock.includes(id2)) {
+ inputField.setHidden(true);
+ }
+ }
+ }
+
+ private static InputField[] createFields(final ObjectAction action, final ObjectAdapter object) {
+ final int parameterCount = action.getParameterCount();
+ final InputField[] fields = new InputField[parameterCount];
+ for (int i = 0; i < fields.length; i++) {
+ fields[i] = new InputField(ActionAction.parameterName(i));
+ }
+ return fields;
+ }
+
+ private static void initializeFields(final Request context, final ObjectAdapter object, final ObjectAction action, final InputField[] fields) {
+ final List<ObjectActionParameter> parameters = action.getParameters();
+ for (int i = 0; i < fields.length; i++) {
+ final InputField field = fields[i];
+ final ObjectActionParameter param = parameters.get(i);
+ if (action.isContributed() && i == 0) {
+ // fields[i].setValue(context.mapObject(object,
+ // Scope.INTERACTION));
+ fields[i].setType(InputField.REFERENCE);
+ fields[i].setHidden(true);
+ } else {
+
+ fields[i].setHelpReference("xxxhelp");
+ final ObjectAdapter[] optionsForParameter = action.getChoices(object)[i];
+ FieldFactory.initializeField(context, object, param, optionsForParameter, !param.isOptional(), field);
+ }
+ }
+ }
+
+ /**
+ * Sets up the fields with their initial values
+ *
+ * @param showIcon
+ */
+ private static void setDefaults(final Request context, final ObjectAdapter object, final ObjectAction action, final InputField[] fields, final FormState entryState, final boolean showIcon) {
+ final ObjectAdapter[] defaultValues = action.getDefaults(object);
+ if (defaultValues == null) {
+ return;
+ }
+
+ for (int i = 0; i < fields.length; i++) {
+ final InputField field = fields[i];
+ final ObjectAdapter defaultValue = defaultValues[i];
+
+ final String title = defaultValue == null ? "" : defaultValue.titleString();
+ if (field.getType() == InputField.REFERENCE) {
+ final ObjectSpecification objectSpecification = action.getParameters().get(i).getSpecification();
+ if (defaultValue != null) {
+ final String imageSegment = showIcon ? "<img class=\"small-icon\" src=\"" + context.imagePath(objectSpecification) + "\" alt=\"" + objectSpecification.getShortIdentifier() + "\"/>" : "";
+ final String html = imageSegment + title;
+ final String value = context.mapObject(defaultValue, Scope.INTERACTION);
+ field.setValue(value);
+ field.setHtml(html);
+ }
+ } else {
+ field.setValue(title);
+ }
+ }
+ }
+
+ private static void copyEntryState(final Request context, final ObjectAdapter object, final ObjectAction action, final InputField[] fields, final FormState entryState) {
+
+ for (final InputField field : fields) {
+ final FieldEditState fieldState = entryState.getField(field.getName());
+ if (fieldState != null) {
+ if (field.isEditable()) {
+ String entry;
+ entry = fieldState.getEntry();
+ field.setValue(entry);
+ }
+
+ field.setErrorText(fieldState.getError());
+ }
+ }
+ }
+
+ private static void overrideWithHtml(final Request context, final FormFieldBlock containedBlock, final InputField[] formFields) {
+ for (int i = 0; i < formFields.length; i++) {
+ final String id = ActionAction.parameterName(i);
+ if (containedBlock.hasContent(id)) {
+ final String content = containedBlock.getContent(id);
+ if (content != null) {
+ formFields[i].setHtml(content);
+ formFields[i].setType(InputField.HTML);
+ }
+ }
+ }
+ }
+
+ public ActionFormAbstract() {
+ super();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/form/CreateFormParameter.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/form/CreateFormParameter.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/form/CreateFormParameter.java
new file mode 100644
index 0000000..d4d02f0
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/form/CreateFormParameter.java
@@ -0,0 +1,43 @@
+/*
+ * 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.form;
+
+public class CreateFormParameter {
+ public String methodName;
+ public String forwardResultTo;
+ public String forwardVoidTo;
+ public String forwardErrorTo;
+ public String buttonTitle;
+ public String formTitle;
+ public String formId;
+ public String resultName;
+ public String scope;
+ public String objectId;
+ public String description;
+ public String helpReference;
+ public String className;
+ public String id;
+ public String resultOverride;
+ public boolean showMessage;
+ public boolean showIcon;
+ public String completionMessage;
+ public String cancelTo;
+ public String labelDelimiter;
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/form/EditFormAbstract.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/form/EditFormAbstract.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/form/EditFormAbstract.java
new file mode 100644
index 0000000..096b8f9
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/form/EditFormAbstract.java
@@ -0,0 +1,171 @@
+package org.apache.isis.viewer.scimpi.dispatcher.view.form;
+
+import java.util.List;
+
+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.consent.Consent;
+import org.apache.isis.core.metamodel.facets.object.parseable.ParseableFacet;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
+import org.apache.isis.core.progmodel.facets.object.choices.enums.EnumFacet;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.form.FieldEditState;
+import org.apache.isis.viewer.scimpi.dispatcher.form.FormState;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+
+//TODO combine the common stuff that is found here and in ActionFormAbstract and LoginFormAbstract
+public abstract class EditFormAbstract extends AbstractElementProcessor {
+
+ protected final Where where = Where.OBJECT_FORMS;
+
+ public EditFormAbstract() {
+ super();
+ }
+
+ protected InputField[] createFields(final List<ObjectAssociation> fields) {
+ final InputField[] formFields = new InputField[fields.size()];
+ int length = 0;
+ for (int i = 0; i < fields.size(); i++) {
+ if (!fields.get(i).isOneToManyAssociation()) {
+ formFields[i] = new InputField(fields.get(i).getId());
+ length++;
+ }
+ }
+ final InputField[] array = new InputField[length];
+ for (int i = 0, j = 0; i < formFields.length; i++) {
+ if (formFields[i] != null) {
+ array[j++] = formFields[i];
+ }
+ }
+ return array;
+ }
+
+ protected void initializeFields(final Request context, final ObjectAdapter object, final InputField[] formFields, final FormState entryState, final boolean includeUnusableFields) {
+ for (final InputField formField : formFields) {
+ final String fieldId = formField.getName();
+ final ObjectAssociation field = object.getSpecification().getAssociation(fieldId);
+ final AuthenticationSession session = IsisContext.getAuthenticationSession();
+ final Consent usable = field.isUsable(session, object, where);
+ final ObjectAdapter[] options = field.getChoices(object);
+ FieldFactory.initializeField(context, object, field, options, field.isMandatory(), formField);
+
+ final boolean isEditable = usable.isAllowed();
+ if (!isEditable) {
+ formField.setDescription(usable.getReason());
+ }
+ formField.setEditable(isEditable);
+ final boolean hiddenField = field.isVisible(session, object, where).isVetoed();
+ final boolean unusable = usable.isVetoed();
+ final boolean hideAsUnusable = unusable && !includeUnusableFields;
+ if (hiddenField || hideAsUnusable) {
+ formField.setHidden(true);
+ }
+ }
+ }
+
+ protected void copyFieldContent(final Request context, final ObjectAdapter object, final InputField[] formFields, final boolean showIcon) {
+ for (final InputField inputField : formFields) {
+ final String fieldName = inputField.getName();
+ final ObjectAssociation field = object.getSpecification().getAssociation(fieldName);
+ if (field.isVisible(IsisContext.getAuthenticationSession(), object, where).isAllowed()) {
+ IsisContext.getPersistenceSession().resolveField(object, field);
+ final ObjectAdapter fieldValue = field.get(object);
+ if (inputField.isEditable()) {
+ final String value = getValue(context, fieldValue);
+ if (!value.equals("") || inputField.getValue() == null) {
+ inputField.setValue(value);
+ }
+ } else {
+ final String entry = getValue(context, fieldValue);
+ inputField.setHtml(entry);
+ inputField.setType(InputField.HTML);
+
+ }
+
+ if (field.getSpecification().getFacet(ParseableFacet.class) == null) {
+ if (fieldValue != null) {
+ final String iconSegment = showIcon ? "<img class=\"small-icon\" src=\"" + context.imagePath(field.getSpecification()) + "\" alt=\"" + field.getSpecification().getShortIdentifier() + "\"/>" : "";
+ final String entry = iconSegment + fieldValue.titleString();
+ inputField.setHtml(entry);
+ } else {
+ final String entry = "<em>none specified</em>";
+ inputField.setHtml(entry);
+ }
+ }
+ }
+ }
+ }
+
+ protected void setDefaults(final Request context, final ObjectAdapter object, final InputField[] formFields, final FormState entryState, final boolean showIcon) {
+ for (final InputField formField : formFields) {
+ final String fieldId = formField.getName();
+ final ObjectAssociation field = object.getSpecification().getAssociation(fieldId);
+ final ObjectAdapter defaultValue = field.getDefault(object);
+ if (defaultValue == null) {
+ continue;
+ }
+
+ final String title = defaultValue.titleString();
+ if (field.getSpecification().containsFacet(ParseableFacet.class)) {
+ formField.setValue(title);
+ } else if (field.isOneToOneAssociation()) {
+ final ObjectSpecification objectSpecification = field.getSpecification();
+ if (defaultValue != null) {
+ final String iconSegment = showIcon ? "<img class=\"small-icon\" src=\"" + context.imagePath(objectSpecification) + "\" alt=\"" + objectSpecification.getShortIdentifier() + "\"/>" : "";
+ final String html = iconSegment + title;
+ formField.setHtml(html);
+ final String value = defaultValue == null ? null : context.mapObject(defaultValue, Scope.INTERACTION);
+ formField.setValue(value);
+ }
+ }
+ }
+ }
+
+ protected void overrideWithHtml(final Request context, final FormFieldBlock containedBlock, final InputField[] formFields) {
+ for (final InputField formField : formFields) {
+ final String fieldId = formField.getName();
+ if (containedBlock.hasContent(fieldId)) {
+ final String content = containedBlock.getContent(fieldId);
+ if (content != null) {
+ formField.setHtml(content);
+ formField.setValue(null);
+ formField.setType(InputField.HTML);
+ }
+ }
+ }
+ }
+
+ protected void copyEntryState(final Request context, final ObjectAdapter object, final InputField[] formFields, final FormState entryState) {
+ for (final InputField formField : formFields) {
+ final String fieldId = formField.getName();
+ final ObjectAssociation field = object.getSpecification().getAssociation(fieldId);
+ if (field.isVisible(IsisContext.getAuthenticationSession(), object, where).isAllowed() && formField.isEditable()) {
+ final FieldEditState fieldState = entryState.getField(field.getId());
+ final String entry = fieldState == null ? "" : fieldState.getEntry();
+ formField.setValue(entry);
+ final String error = fieldState == null ? "" : fieldState.getError();
+ formField.setErrorText(error);
+ }
+ }
+ }
+
+ protected String getValue(final Request context, final ObjectAdapter field) {
+ if (field == null || field.isTransient()) {
+ return "";
+ }
+ final ObjectSpecification specification = field.getSpecification();
+ if (specification.containsFacet(EnumFacet.class)) {
+ return String.valueOf(field.getObject());
+ } else if (specification.getFacet(ParseableFacet.class) == null) {
+ return context.mapObject(field, Scope.INTERACTION);
+ } else {
+ return field.titleString();
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/form/FieldFactory.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/form/FieldFactory.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/form/FieldFactory.java
new file mode 100644
index 0000000..d6470fc
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/form/FieldFactory.java
@@ -0,0 +1,104 @@
+/*
+ * 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.form;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facets.help.HelpFacet;
+import org.apache.isis.core.metamodel.facets.maxlen.MaxLengthFacet;
+import org.apache.isis.core.metamodel.facets.multiline.MultiLineFacet;
+import org.apache.isis.core.metamodel.facets.object.parseable.ParseableFacet;
+import org.apache.isis.core.metamodel.facets.typicallen.TypicalLengthFacet;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.feature.ObjectFeature;
+import org.apache.isis.core.metamodel.spec.feature.ObjectMember;
+import org.apache.isis.core.progmodel.facets.value.booleans.BooleanValueFacet;
+import org.apache.isis.core.progmodel.facets.value.password.PasswordValueFacet;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
+
+public class FieldFactory {
+
+ public static void initializeField(final Request context, final ObjectAdapter object, final ObjectFeature param, final ObjectAdapter[] optionsForParameter, final boolean isRequired, final InputField field) {
+
+ field.setLabel(param.getName());
+ field.setDescription(param.getDescription());
+ field.setDataType(param.getSpecification().getShortIdentifier());
+ if (param instanceof ObjectMember) {
+ field.setHelpReference(((ObjectMember) param).getHelp());
+ } else {
+ final HelpFacet helpFacet = param.getFacet(HelpFacet.class);
+ final String value = helpFacet.value();
+ field.setHelpReference(value);
+ }
+ field.setRequired(isRequired);
+ field.setHidden(false);
+
+ if (param.getSpecification().getFacet(ParseableFacet.class) != null) {
+ final int maxLength = param.getFacet(MaxLengthFacet.class).value();
+ field.setMaxLength(maxLength);
+
+ final TypicalLengthFacet typicalLengthFacet = param.getFacet(TypicalLengthFacet.class);
+ if (typicalLengthFacet.isDerived() && maxLength > 0) {
+ field.setWidth(maxLength);
+ } else {
+ field.setWidth(typicalLengthFacet.value());
+ }
+
+ final MultiLineFacet multiLineFacet = param.getFacet(MultiLineFacet.class);
+ field.setHeight(multiLineFacet.numberOfLines());
+ field.setWrapped(!multiLineFacet.preventWrapping());
+
+ final ObjectSpecification spec = param.getSpecification();
+ if (spec.containsFacet(BooleanValueFacet.class)) {
+ field.setType(InputField.CHECKBOX);
+ } else if (spec.containsFacet(PasswordValueFacet.class)) {
+ field.setType(InputField.PASSWORD);
+ } else {
+ field.setType(InputField.TEXT);
+ }
+
+ } else {
+ field.setType(InputField.REFERENCE);
+ }
+
+ if (optionsForParameter != null) {
+ final int noOptions = optionsForParameter.length;
+ final String[] optionValues = new String[noOptions];
+ final String[] optionTitles = new String[noOptions];
+ for (int j = 0; j < optionsForParameter.length; j++) {
+ final int i = j; // + (field.isRequired() ? 0 : 1);
+ optionValues[i] = getValue(context, optionsForParameter[j]);
+ optionTitles[i] = optionsForParameter[j].titleString();
+ }
+ field.setOptions(optionTitles, optionValues);
+ }
+ }
+
+ private static String getValue(final Request context, final ObjectAdapter field) {
+ if (field == null) {
+ return "";
+ }
+ if (field.getSpecification().getFacet(ParseableFacet.class) == null) {
+ return context.mapObject(field, Scope.INTERACTION);
+ } else {
+ return field.getObject().toString();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/form/FormEntry.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/form/FormEntry.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/form/FormEntry.java
new file mode 100644
index 0000000..f196f7d
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/form/FormEntry.java
@@ -0,0 +1,45 @@
+/*
+ * 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.form;
+
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+public class FormEntry extends AbstractElementProcessor {
+
+ @Override
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ final FormFieldBlock block = (FormFieldBlock) templateProcessor.peekBlock();
+ final String field = templateProcessor.getRequiredProperty(FIELD);
+ final String value = templateProcessor.getRequiredProperty(VALUE);
+ final boolean isHidden = templateProcessor.isRequested(HIDDEN, true);
+ block.exclude(field);
+ // TODO this is replaced because the field is marked as hidden!
+ final String content = "reference <input type=\"" + (isHidden ? "hidden" : "text") + "\" disabled=\"disabled\" name=\"" + field + "\" value=\"" + value + "\" />";
+ block.replaceContent(field, content);
+ }
+
+ @Override
+ public String getName() {
+ return "form-entry";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/form/FormField.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/form/FormField.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/form/FormField.java
new file mode 100644
index 0000000..4409897
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/form/FormField.java
@@ -0,0 +1,45 @@
+/*
+ * 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.form;
+
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+public class FormField extends AbstractElementProcessor {
+
+ @Override
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ final FormFieldBlock block = (FormFieldBlock) templateProcessor.peekBlock();
+ final String field = templateProcessor.getRequiredProperty(FIELD);
+ if (block.isVisible(field)) {
+ templateProcessor.pushNewBuffer();
+ templateProcessor.processUtilCloseTag();
+ final String content = templateProcessor.popBuffer();
+ block.replaceContent(field, content);
+ }
+ }
+
+ @Override
+ public String getName() {
+ return "form-field";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/form/FormFieldBlock.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/form/FormFieldBlock.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/form/FormFieldBlock.java
new file mode 100644
index 0000000..9247eb0
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/form/FormFieldBlock.java
@@ -0,0 +1,67 @@
+/*
+ * 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.form;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.viewer.scimpi.dispatcher.view.determine.InclusionList;
+
+public class FormFieldBlock extends InclusionList {
+ private final Map<String, String> content = new HashMap<String, String>();
+ private final Map<String, String> values = new HashMap<String, String>();
+
+ public void replaceContent(final String field, final String htmlString) {
+ content.put(field, htmlString);
+ }
+
+ public boolean hasContent(final String name) {
+ return content.containsKey(name);
+ }
+
+ public String getContent(final String name) {
+ return content.get(name);
+ }
+
+ public boolean isVisible(final String name) {
+ return true;
+ }
+
+ public boolean isNullable(final String name) {
+ return true;
+ }
+
+ public ObjectAdapter getCurrent(final String name) {
+ return null;
+ }
+
+ public void value(final String field, final String value) {
+ values.put(field, value);
+ }
+
+ public void setUpValues(final InputField[] inputFields) {
+ for (final InputField inputField : inputFields) {
+ final String name = inputField.getName();
+ inputField.setValue(values.get(name));
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/form/HiddenField.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/form/HiddenField.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/form/HiddenField.java
new file mode 100644
index 0000000..d03b4e3
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/form/HiddenField.java
@@ -0,0 +1,49 @@
+/*
+ * 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.form;
+
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.BlockContent;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagOrderException;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+public class HiddenField extends AbstractElementProcessor {
+
+ @Override
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ final BlockContent blockContent = templateProcessor.peekBlock();
+ if (!(blockContent instanceof FormFieldBlock)) {
+ throw new TagOrderException(templateProcessor);
+ }
+
+ final String field = templateProcessor.getOptionalProperty("name");
+ final String value = templateProcessor.getRequiredProperty("value");
+ final FormFieldBlock block = (FormFieldBlock) blockContent;
+ block.value(field, value);
+ block.exclude(field);
+ }
+
+ @Override
+ public String getName() {
+ return "hidden-field";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/form/HtmlFormBuilder.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/form/HtmlFormBuilder.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/form/HtmlFormBuilder.java
index 6d362a6..3272a3e 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/form/HtmlFormBuilder.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/form/HtmlFormBuilder.java
@@ -20,13 +20,14 @@
package org.apache.isis.viewer.scimpi.dispatcher.view.form;
import org.apache.isis.core.commons.exceptions.UnknownTypeException;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.HtmlEncoder;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
import org.apache.isis.viewer.scimpi.dispatcher.view.other.HelpLink;
public class HtmlFormBuilder {
public static void createForm(
- final TagProcessor tagProcessor,
+ final TemplateProcessor templateProcessor,
final String action,
final HiddenInputField[] hiddenFields,
final InputField[] fields,
@@ -41,12 +42,12 @@ public class HtmlFormBuilder {
final String cancelTo) {
String classSegment = " class=\"" + className + (id == null ? "\"" : "\" id=\"" + id + "\"");
- tagProcessor.appendHtml("<form " + classSegment + " action=\"" + action + "\" method=\"post\" accept-charset=\"UTF-8\">\n");
+ templateProcessor.appendHtml("<form " + classSegment + " action=\"" + action + "\" method=\"post\" accept-charset=\"UTF-8\">\n");
if (formTitle != null && formTitle.trim().length() > 0) {
classSegment = " class=\"title\"";
- tagProcessor.appendHtml("<div" + classSegment + ">");
- tagProcessor.appendAsHtmlEncoded(formTitle);
- tagProcessor.appendHtml("</div>\n");
+ templateProcessor.appendHtml("<div" + classSegment + ">");
+ templateProcessor.appendAsHtmlEncoded(formTitle);
+ templateProcessor.appendHtml("</div>\n");
}
// TODO reinstate fieldsets when we can specify them
@@ -54,54 +55,54 @@ public class HtmlFormBuilder {
final String cls = "errors";
if (errors != null) {
- tagProcessor.appendHtml("<div class=\"" + cls + "\">");
- tagProcessor.appendAsHtmlEncoded(errors);
- tagProcessor.appendHtml("</div>");
+ templateProcessor.appendHtml("<div class=\"" + cls + "\">");
+ templateProcessor.appendAsHtmlEncoded(errors);
+ templateProcessor.appendHtml("</div>");
}
for (final HiddenInputField hiddenField : hiddenFields) {
if (hiddenField == null) {
continue;
}
- tagProcessor.appendHtml(" <input type=\"hidden\" name=\"" + hiddenField.getName() + "\" value=\"");
- tagProcessor.appendAsHtmlEncoded(hiddenField.getValue());
- tagProcessor.appendHtml("\" />\n");
+ templateProcessor.appendHtml(" <input type=\"hidden\" name=\"" + hiddenField.getName() + "\" value=\"");
+ templateProcessor.appendAsHtmlEncoded(hiddenField.getValue());
+ templateProcessor.appendHtml("\" />\n");
}
- tagProcessor.appendHtml(tagProcessor.getContext().interactionFields());
+ templateProcessor.appendHtml(templateProcessor.getContext().interactionFields());
for (final InputField fld : fields) {
if (fld.isHidden()) {
- tagProcessor.appendHtml(" <input type=\"hidden\" name=\"" + fld.getName() + "\" value=\"");
- tagProcessor.appendAsHtmlEncoded(fld.getValue());
- tagProcessor.appendHtml("\" />\n");
+ templateProcessor.appendHtml(" <input type=\"hidden\" name=\"" + fld.getName() + "\" value=\"");
+ templateProcessor.appendAsHtmlEncoded(fld.getValue());
+ templateProcessor.appendHtml("\" />\n");
} else {
final String errorSegment = fld.getErrorText() == null ? "" : "<span class=\"error\">" + fld.getErrorText() + "</span>";
- final String fieldSegment = createField(fld);
+ final String fieldSegment = createField(fld, templateProcessor);
final String helpSegment = HelpLink.createHelpSegment(fld.getDescription(), fld.getHelpReference());
final String title = fld.getDescription().equals("") ? "" : " title=\"" + fld.getDescription() + "\"";
- tagProcessor.appendHtml(" <div class=\"field " + fld.getName() + "\"><label class=\"label\" " + title + ">");
- tagProcessor.appendAsHtmlEncoded(fld.getLabel());
- tagProcessor.appendHtml(labelDelimiter + "</label>" + fieldSegment + errorSegment + helpSegment + "</div>\n");
+ templateProcessor.appendHtml(" <div class=\"field " + fld.getName() + "\"><label class=\"label\" " + title + ">");
+ templateProcessor.appendAsHtmlEncoded(fld.getLabel());
+ templateProcessor.appendHtml(labelDelimiter + "</label>" + fieldSegment + errorSegment + helpSegment + "</div>\n");
}
}
- tagProcessor.appendHtml(" <input class=\"button\" type=\"submit\" value=\"");
- tagProcessor.appendAsHtmlEncoded(buttonTitle);
- tagProcessor.appendHtml("\" name=\"execute\" />\n");
- HelpLink.append(tagProcessor, description, helpReference);
+ templateProcessor.appendHtml(" <input class=\"button\" type=\"submit\" value=\"");
+ templateProcessor.appendAsHtmlEncoded(buttonTitle);
+ templateProcessor.appendHtml("\" name=\"execute\" />\n");
+ HelpLink.append(templateProcessor, description, helpReference);
// TODO alllow forms to be cancelled, returning to previous page.
// request.appendHtml(" <div class=\"action\"><a class=\"button\" href=\"reset\">Cancel</a></div>");
if (cancelTo != null) {
- tagProcessor.appendHtml(" <input class=\"button\" type=\"button\" value=\"");
- tagProcessor.appendAsHtmlEncoded("Cancel");
- tagProcessor.appendHtml("\" onclick=\"window.location = '" + cancelTo + "'\" name=\"cancel\" />\n");
+ templateProcessor.appendHtml(" <input class=\"button\" type=\"button\" value=\"");
+ templateProcessor.appendAsHtmlEncoded("Cancel");
+ templateProcessor.appendHtml("\" onclick=\"window.location = '" + cancelTo + "'\" name=\"cancel\" />\n");
}
// TODO reinstate fieldsets when we can specify them
// request.appendHtml("</fieldset>\n");
- tagProcessor.appendHtml("</form>\n");
+ templateProcessor.appendHtml("</form>\n");
}
- private static String createField(final InputField field) {
+ private static String createField(final InputField field, final HtmlEncoder htmlEncoder) {
if (field.isHidden()) {
if (field.getType() == InputField.REFERENCE) {
return createObjectField(field, "hidden");
@@ -112,18 +113,18 @@ public class HtmlFormBuilder {
if (field.getType() == InputField.HTML) {
return "<span class=\"value\">" + field.getHtml() + "</span>";
} else if (field.getOptionsText() != null) {
- return createOptions(field);
+ return createOptions(field, htmlEncoder);
} else if (field.getType() == InputField.REFERENCE) {
return createObjectField(field, "text");
} else if (field.getType() == InputField.CHECKBOX) {
- return createCheckbox(field);
+ return createCheckbox(field, htmlEncoder);
} else if (field.getType() == InputField.PASSWORD) {
- return createPasswordField(field);
+ return createPasswordField(field, htmlEncoder);
} else if (field.getType() == InputField.TEXT) {
if (field.getHeight() > 1) {
- return createTextArea(field);
+ return createTextArea(field, htmlEncoder);
} else {
- return createTextField(field);
+ return createTextField(field, htmlEncoder);
}
} else {
throw new UnknownTypeException(field.toString());
@@ -135,7 +136,7 @@ public class HtmlFormBuilder {
return field.getHtml();
}
- private static String createTextArea(final InputField field) {
+ private static String createTextArea(final InputField field, final HtmlEncoder htmlEncoder) {
final String columnsSegment = field.getWidth() == 0 ? "" : " cols=\"" + field.getWidth() / field.getHeight() + "\"";
final String rowsSegment = field.getHeight() == 0 ? "" : " rows=\"" + field.getHeight() + "\"";
final String wrapSegment = !field.isWrapped() ? "" : " wrap=\"off\"";
@@ -143,21 +144,21 @@ public class HtmlFormBuilder {
final String disabled = field.isEditable() ? "" : " disabled=\"disabled\"";
final String maxLength = field.getMaxLength() == 0 ? "" : " maxlength=\"" + field.getMaxLength() + "\"";
return "<textarea" + requiredSegment + " name=\"" + field.getName() + "\"" + columnsSegment + rowsSegment + wrapSegment
- + maxLength + disabled + ">" + TagProcessor.getEncoder().encoder(field.getValue()) + "</textarea>";
+ + maxLength + disabled + ">" + htmlEncoder.encodeHtml(field.getValue()) + "</textarea>";
}
- private static String createPasswordField(final InputField field) {
+ private static String createPasswordField(final InputField field, final HtmlEncoder htmlEncoder) {
final String extra = " autocomplete=\"off\"";
- return createTextField(field, "password", extra);
+ return createTextField(field, "password", extra, htmlEncoder);
}
- private static String createTextField(final InputField field) {
- return createTextField(field, "text", "");
+ private static String createTextField(final InputField field, final HtmlEncoder htmlEncoder) {
+ return createTextField(field, "text", "", htmlEncoder);
}
- private static String createTextField(final InputField field, final String type, final String additionalAttributes) {
+ private static String createTextField(final InputField field, final String type, final String additionalAttributes, final HtmlEncoder htmlEncoder) {
final String value = field.getValue();
- final String valueSegment = value == null ? "" : " value=\"" + TagProcessor.getEncoder().encoder(value) + "\"";
+ final String valueSegment = value == null ? "" : " value=\"" + htmlEncoder.encodeHtml(value) + "\"";
final String lengthSegment = field.getWidth() == 0 ? "" : " size=\"" + field.getWidth() + "\"";
final String maxLengthSegment = field.getMaxLength() == 0 ? "" : " maxlength=\"" + field.getMaxLength() + "\"";
final String requiredSegment = !field.isRequired() ? "" : " required";
@@ -166,14 +167,14 @@ public class HtmlFormBuilder {
valueSegment + lengthSegment + maxLengthSegment + disabled + additionalAttributes + " />";
}
- private static String createCheckbox(final InputField field) {
+ private static String createCheckbox(final InputField field, final HtmlEncoder htmlEncoder) {
final String entryText = field.getValue();
final String valueSegment = entryText != null && entryText.toLowerCase().equals("true") ? " checked=\"checked\"" : "";
final String disabled = field.isEditable() ? "" : " disabled=\"disabled\"";
return "<input type=\"checkbox\" name=\"" + field.getName() + "\" value=\"true\" " + valueSegment + disabled + " />";
}
- private static String createOptions(final InputField field) {
+ private static String createOptions(final InputField field, final HtmlEncoder htmlEncoder) {
final String[] options = field.getOptionsText();
final String[] ids = field.getOptionValues();
final int length = options.length;
@@ -187,7 +188,7 @@ public class HtmlFormBuilder {
if (field.getType() == InputField.TEXT && options[i].equals("__other")) {
offerOther = true;
} else {
- str.append(" <option value=\"" + TagProcessor.getEncoder().encoder(ids[i]) + "\"" + selectedSegment + ">" + TagProcessor.getEncoder().encoder(options[i]) + "</option>\n");
+ str.append(" <option value=\"" + htmlEncoder.encodeHtml(ids[i]) + "\"" + selectedSegment + ">" + htmlEncoder.encodeHtml(options[i]) + "</option>\n");
}
}
if (!field.isRequired() || length == 0) {
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/form/LogonFormAbstract.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/form/LogonFormAbstract.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/form/LogonFormAbstract.java
new file mode 100644
index 0000000..cdc7dcd
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/form/LogonFormAbstract.java
@@ -0,0 +1,86 @@
+package org.apache.isis.viewer.scimpi.dispatcher.view.form;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.form.FieldEditState;
+import org.apache.isis.viewer.scimpi.dispatcher.form.FormState;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+//TODO combine the common stuff that is found here and in ActionFormAbstract and EditFormAbstract
+public abstract class LogonFormAbstract extends AbstractElementProcessor {
+
+ public static void loginForm(final TemplateProcessor templateProcessor, final String view) {
+ final String object = templateProcessor.getOptionalProperty(OBJECT);
+ final String method = templateProcessor.getOptionalProperty(METHOD, "logon");
+ final String result = templateProcessor.getOptionalProperty(RESULT_NAME, "_user");
+ final String resultScope = templateProcessor.getOptionalProperty(SCOPE, Scope.SESSION.name());
+ final String isisUser = templateProcessor.getOptionalProperty("isis-user", "_web_default");
+ final String formId = templateProcessor.getOptionalProperty(FORM_ID, templateProcessor.nextFormId());
+ final String labelDelimiter = templateProcessor.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) {
+ Request context = templateProcessor.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 + "isis-user", isisUser, Scope.SESSION);
+ context.addVariable(LOGON_FORM_ID, formId, Scope.SESSION);
+ }
+
+ final String error = templateProcessor.getOptionalProperty(ERROR, templateProcessor.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) templateProcessor.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 = templateProcessor.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 = templateProcessor.getOptionalProperty(FORM_TITLE);
+ final String loginButtonTitle = templateProcessor.getOptionalProperty(BUTTON_TITLE, "Log in");
+ final String className = templateProcessor.getOptionalProperty(CLASS, "login");
+ final String id = templateProcessor.getOptionalProperty(ID, "logon");
+
+ HtmlFormBuilder.createForm(templateProcessor, "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;
+ }
+
+ public LogonFormAbstract() {
+ super();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/form/RadioListField.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/form/RadioListField.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/form/RadioListField.java
new file mode 100644
index 0000000..9530834
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/form/RadioListField.java
@@ -0,0 +1,71 @@
+/*
+ * 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.form;
+
+import java.util.Iterator;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacet;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+public class RadioListField extends AbstractElementProcessor {
+
+ @Override
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ final FormFieldBlock block = (FormFieldBlock) templateProcessor.peekBlock();
+ final String field = templateProcessor.getRequiredProperty(FIELD);
+ if (block.isVisible(field)) {
+ final String id = templateProcessor.getRequiredProperty(COLLECTION);
+ final String exclude = templateProcessor.getOptionalProperty("exclude");
+
+ final ObjectAdapter collection = templateProcessor.getContext().getMappedObjectOrResult(id);
+
+ final Request context = templateProcessor.getContext();
+ final CollectionFacet facet = collection.getSpecification().getFacet(CollectionFacet.class);
+ final Iterator<ObjectAdapter> iterator = facet.iterator(collection);
+
+ final StringBuffer buffer = new StringBuffer();
+
+ while (iterator.hasNext()) {
+ final ObjectAdapter element = iterator.next();
+ final Scope scope = Scope.INTERACTION;
+ final String elementId = context.mapObject(element, scope);
+ if (exclude != null && context.getMappedObject(exclude) == element) {
+ continue;
+ }
+ final String title = element.titleString();
+ final String checked = "";
+ buffer.append("<input type=\"radio\" name=\"" + field + "\" value=\"" + elementId + "\"" + checked + " />" + title + "</input><br/>\n");
+ }
+
+ block.replaceContent(field, buffer.toString());
+ }
+ }
+
+ @Override
+ public String getName() {
+ return "radio-list";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/form/Selector.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/form/Selector.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/form/Selector.java
new file mode 100644
index 0000000..effe589
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/form/Selector.java
@@ -0,0 +1,157 @@
+/*
+ * 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.form;
+
+import java.util.Iterator;
+
+import org.apache.isis.core.commons.exceptions.UnknownTypeException;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacet;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.util.MethodsUtils;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+public class Selector extends AbstractElementProcessor {
+
+ @Override
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ final FormFieldBlock block = (FormFieldBlock) templateProcessor.peekBlock();
+ final String field = templateProcessor.getRequiredProperty(FIELD);
+ if (block.isVisible(field)) {
+ processElement(templateProcessor, block, field);
+ }
+ templateProcessor.skipUntilClose();
+ }
+
+ private void processElement(final TemplateProcessor templateProcessor, final FormFieldBlock block, final String field) {
+ final String type = templateProcessor.getOptionalProperty(TYPE, "dropdown");
+ if (!templateProcessor.isPropertySpecified(METHOD) && templateProcessor.isPropertySpecified(COLLECTION)) {
+ final String id = templateProcessor.getRequiredProperty(COLLECTION, TemplateProcessor.NO_VARIABLE_CHECKING);
+ final String selector = showSelectionList(templateProcessor, id, block.getCurrent(field), block.isNullable(field), type);
+ block.replaceContent(field, selector);
+ } else {
+ final String objectId = templateProcessor.getOptionalProperty(OBJECT);
+ final String methodName = templateProcessor.getRequiredProperty(METHOD);
+ final ObjectAdapter object = MethodsUtils.findObject(templateProcessor.getContext(), objectId);
+ final ObjectAction action = MethodsUtils.findAction(object, methodName);
+ if (action.getParameterCount() == 0) {
+ final ObjectAdapter collection = action.execute(object, new ObjectAdapter[0]);
+ final String selector = showSelectionList(templateProcessor, collection, block.getCurrent(field), block.isNullable(field), type);
+ block.replaceContent(field, selector);
+ } else {
+ final String id = "selector_options";
+ final String id2 = (String) templateProcessor.getContext().getVariable(id);
+ final String selector = showSelectionList(templateProcessor, id2, block.getCurrent(field), block.isNullable(field), type);
+
+ final CreateFormParameter parameters = new CreateFormParameter();
+ parameters.objectId = objectId;
+ parameters.methodName = methodName;
+ parameters.buttonTitle = templateProcessor.getOptionalProperty(BUTTON_TITLE, "Search");
+ parameters.formTitle = templateProcessor.getOptionalProperty(FORM_TITLE);
+ parameters.className = templateProcessor.getOptionalProperty(CLASS, "selector");
+ parameters.id = templateProcessor.getOptionalProperty(ID);
+
+ parameters.resultName = id;
+ parameters.forwardResultTo = templateProcessor.getContext().getResourceFile();
+ parameters.forwardVoidTo = "error";
+ parameters.forwardErrorTo = parameters.forwardResultTo;
+ parameters.scope = Scope.REQUEST.name();
+ templateProcessor.pushNewBuffer();
+ ActionFormAbstract.createForm(templateProcessor, parameters);
+ block.replaceContent(field, selector);
+
+ templateProcessor.appendHtml(templateProcessor.popBuffer());
+ }
+ }
+ }
+
+ private String showSelectionList(final TemplateProcessor templateProcessor, final String collectionId, final ObjectAdapter selectedItem, final boolean allowNotSet, final String type) {
+ if (collectionId != null && !collectionId.equals("")) {
+ final ObjectAdapter collection = templateProcessor.getContext().getMappedObjectOrResult(collectionId);
+ return showSelectionList(templateProcessor, collection, selectedItem, allowNotSet, type);
+ } else {
+ return null;
+ }
+ }
+
+ private String showSelectionList(final TemplateProcessor templateProcessor, final ObjectAdapter collection, final ObjectAdapter selectedItem, final boolean allowNotSet, final String type) {
+ final String field = templateProcessor.getRequiredProperty(FIELD);
+ final CollectionFacet facet = collection.getSpecification().getFacet(CollectionFacet.class);
+
+ if (type.equals("radio")) {
+ return radioButtonList(templateProcessor, field, allowNotSet, collection, selectedItem, facet);
+ } else if (type.equals("list")) {
+ final String size = templateProcessor.getOptionalProperty("size", "5");
+ return dropdownList(templateProcessor, field, allowNotSet, collection, selectedItem, size, facet);
+ } else if (type.equals("dropdown")) {
+ return dropdownList(templateProcessor, field, allowNotSet, collection, selectedItem, null, facet);
+ } else {
+ throw new UnknownTypeException(type);
+ }
+ }
+
+ private String radioButtonList(final TemplateProcessor templateProcessor, final String field, final boolean allowNotSet, final ObjectAdapter collection, final ObjectAdapter selectedItem, final CollectionFacet facet) {
+ final Request context = templateProcessor.getContext();
+ final Iterator<ObjectAdapter> iterator = facet.iterator(collection);
+ final StringBuffer buffer = new StringBuffer();
+ if (allowNotSet) {
+ buffer.append("<input type=\"radio\" name=\"" + field + "\" value=\"null\"></input><br/>\n");
+ }
+ while (iterator.hasNext()) {
+ final ObjectAdapter element = iterator.next();
+ final String elementId = context.mapObject(element, Scope.INTERACTION);
+ final String title = element.titleString();
+ final String checked = element == selectedItem ? "checked=\"checked\"" : "";
+ buffer.append("<input type=\"radio\" name=\"" + field + "\" value=\"" + elementId + "\"" + checked + ">" + title + "</input><br/>\n");
+ }
+
+ return buffer.toString();
+ }
+
+ private String dropdownList(final TemplateProcessor templateProcessor, final String field, final boolean allowNotSet, final ObjectAdapter collection, final ObjectAdapter selectedItem, String size, final CollectionFacet facet) {
+ final Request context = templateProcessor.getContext();
+ final Iterator<ObjectAdapter> iterator = facet.iterator(collection);
+ final StringBuffer buffer = new StringBuffer();
+ size = size == null ? "" : " size =\"" + size + "\"";
+ buffer.append("<select name=\"" + field + "\"" + size + " >\n");
+ if (allowNotSet) {
+ buffer.append(" <option value=\"null\"></option>\n");
+ }
+ while (iterator.hasNext()) {
+ final ObjectAdapter element = iterator.next();
+ final String elementId = context.mapObject(element, Scope.INTERACTION);
+ final String title = element.titleString();
+ final String checked = element == selectedItem ? "selected=\"selected\"" : "";
+ buffer.append(" <option value=\"" + elementId + "\"" + checked + ">" + title + "</option>\n");
+ }
+ buffer.append("</select>\n");
+ return buffer.toString();
+ }
+
+ @Override
+ public String getName() {
+ return "selector";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/form/SimpleButton.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/form/SimpleButton.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/form/SimpleButton.java
new file mode 100644
index 0000000..1a16dde
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/form/SimpleButton.java
@@ -0,0 +1,40 @@
+/*
+ * 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.form;
+
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+public class SimpleButton extends AbstractElementProcessor {
+ @Override
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ final String href = templateProcessor.getRequiredProperty("href");
+ templateProcessor.pushNewBuffer();
+ templateProcessor.processUtilCloseTag();
+ final String text = templateProcessor.popBuffer();
+ templateProcessor.appendHtml("<div class=\"action\"><a class=\"button\" href=\"" + href + "\">" + text + "</a></div>");
+ }
+
+ @Override
+ public String getName() {
+ return "button";
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/global/Commit.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/global/Commit.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/global/Commit.java
new file mode 100644
index 0000000..f9375f5
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/global/Commit.java
@@ -0,0 +1,46 @@
+/*
+ * 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.global;
+
+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.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+public class Commit extends AbstractElementProcessor {
+
+ @Override
+ public String getName() {
+ return "commit";
+ }
+
+ @Override
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ // 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();
+ }
+ }
+
+}
[22/24] Restructuring Scimpi to remove dependencies and enable easier
testing.
Posted by rm...@apache.org.
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/AbstractElementProcessor.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/AbstractElementProcessor.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/AbstractElementProcessor.java
index 4885128..6453b62 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/AbstractElementProcessor.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/AbstractElementProcessor.java
@@ -19,29 +19,28 @@
package org.apache.isis.viewer.scimpi.dispatcher.view;
-import org.apache.isis.core.commons.config.ConfigurationConstants;
-import org.apache.isis.core.runtime.system.context.IsisContext;
import org.apache.isis.viewer.scimpi.Names;
+import org.apache.isis.viewer.scimpi.ScimpiContext;
import org.apache.isis.viewer.scimpi.ScimpiException;
import org.apache.isis.viewer.scimpi.dispatcher.processor.ElementProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
public abstract class AbstractElementProcessor implements ElementProcessor, Names {
- private static final String SHOW_ICONS_BY_DEFAULT = ConfigurationConstants.ROOT + "scimpi.show-icons";
+ private static final String SHOW_ICONS_BY_DEFAULT = "show-icons";
- private final boolean showIconByDefault;
+ private boolean showIconByDefault;
- public AbstractElementProcessor() {
- showIconByDefault = IsisContext.getConfiguration().getBoolean(SHOW_ICONS_BY_DEFAULT, false);
+ public void init(ScimpiContext context) {
+ showIconByDefault = context.getConfiguration().getBoolean(SHOW_ICONS_BY_DEFAULT, false);
}
-
+
/**
* Return the Class for the class specified in the type attribute.
*/
- protected Class<?> forClass(final TagProcessor tagProcessor) {
+ protected Class<?> forClass(final TemplateProcessor templateProcessor) {
Class<?> cls = null;
- final String className = tagProcessor.getOptionalProperty(TYPE);
+ final String className = templateProcessor.getOptionalProperty(TYPE);
if (className != null) {
try {
cls = Class.forName(className);
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/AbstractObjectProcessor.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/AbstractObjectProcessor.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/AbstractObjectProcessor.java
index b430594..a8e3dad 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/AbstractObjectProcessor.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/AbstractObjectProcessor.java
@@ -23,16 +23,17 @@ 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.ScimpiException;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
public abstract class AbstractObjectProcessor extends AbstractElementProcessor {
@Override
- public void process(final TagProcessor tagProcessor) {
- final String id = tagProcessor.getOptionalProperty(OBJECT);
- ObjectAdapter object = tagProcessor.getContext().getMappedObjectOrResult(id);
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ final String id = templateProcessor.getOptionalProperty(OBJECT);
+ ObjectAdapter object = templateProcessor.getContext().getMappedObjectOrResult(id);
- final String field = tagProcessor.getOptionalProperty(FIELD);
+ final String field = templateProcessor.getOptionalProperty(FIELD);
if (field != null) {
final ObjectAssociation objectField = object.getSpecification().getAssociation(field);
final String error = checkFieldType(objectField);
@@ -43,13 +44,13 @@ public abstract class AbstractObjectProcessor extends AbstractElementProcessor {
object = objectField.get(object);
}
- process(tagProcessor, object);
+ process(templateProcessor, object);
}
protected String checkFieldType(final ObjectAssociation objectField) {
return null;
}
- protected abstract void process(TagProcessor tagProcessor, ObjectAdapter object);
+ protected abstract void process(TemplateProcessor templateProcessor, ObjectAdapter object);
}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/ActionButton.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/ActionButton.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/ActionButton.java
index 2954e4e..4c35720 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/ActionButton.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/ActionButton.java
@@ -32,8 +32,9 @@ import org.apache.isis.core.metamodel.spec.feature.ObjectActionParameter;
import org.apache.isis.core.runtime.system.context.IsisContext;
import org.apache.isis.viewer.scimpi.Names;
import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
import org.apache.isis.viewer.scimpi.dispatcher.util.MethodsUtils;
import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
import org.apache.isis.viewer.scimpi.dispatcher.view.other.HelpLink;
@@ -49,28 +50,28 @@ public class ActionButton extends AbstractElementProcessor {
private final static Where where = Where.ANYWHERE;
@Override
- public void process(final TagProcessor tagProcessor) {
- final String objectId = tagProcessor.getOptionalProperty(OBJECT);
- final String methodName = tagProcessor.getRequiredProperty(METHOD);
- final String forwardResultTo = tagProcessor.getOptionalProperty(VIEW);
- final String forwardVoidTo = tagProcessor.getOptionalProperty(VOID);
- final String forwardErrorTo = tagProcessor.getOptionalProperty(ERROR);
- final String variable = tagProcessor.getOptionalProperty(RESULT_NAME);
- final String scope = tagProcessor.getOptionalProperty(SCOPE);
- final String buttonTitle = tagProcessor.getOptionalProperty(BUTTON_TITLE);
- String resultOverride = tagProcessor.getOptionalProperty(RESULT_OVERRIDE);
- final String idName = tagProcessor.getOptionalProperty(ID, methodName);
- final String className = tagProcessor.getOptionalProperty(CLASS);
- final boolean showMessage = tagProcessor.isRequested(SHOW_MESSAGE, false);
- final String completionMessage = tagProcessor.getOptionalProperty(MESSAGE);
-
- final ObjectAdapter object = MethodsUtils.findObject(tagProcessor.getContext(), objectId);
- final String version = tagProcessor.getContext().mapVersion(object);
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ final String objectId = templateProcessor.getOptionalProperty(OBJECT);
+ final String methodName = templateProcessor.getRequiredProperty(METHOD);
+ final String forwardResultTo = templateProcessor.getOptionalProperty(VIEW);
+ final String forwardVoidTo = templateProcessor.getOptionalProperty(VOID);
+ final String forwardErrorTo = templateProcessor.getOptionalProperty(ERROR);
+ final String variable = templateProcessor.getOptionalProperty(RESULT_NAME);
+ final String scope = templateProcessor.getOptionalProperty(SCOPE);
+ final String buttonTitle = templateProcessor.getOptionalProperty(BUTTON_TITLE);
+ String resultOverride = templateProcessor.getOptionalProperty(RESULT_OVERRIDE);
+ final String idName = templateProcessor.getOptionalProperty(ID, methodName);
+ final String className = templateProcessor.getOptionalProperty(CLASS);
+ final boolean showMessage = templateProcessor.isRequested(SHOW_MESSAGE, false);
+ final String completionMessage = templateProcessor.getOptionalProperty(MESSAGE);
+
+ final ObjectAdapter object = MethodsUtils.findObject(templateProcessor.getContext(), objectId);
+ final String version = templateProcessor.getContext().mapVersion(object);
final ObjectAction action = MethodsUtils.findAction(object, methodName);
final ActionContent parameterBlock = new ActionContent(action);
- tagProcessor.setBlockContent(parameterBlock);
- tagProcessor.processUtilCloseTag();
+ templateProcessor.pushBlock(parameterBlock);
+ templateProcessor.processUtilCloseTag();
final String[] parameters = parameterBlock.getParameters();
final ObjectAdapter[] objectParameters;
@@ -78,7 +79,7 @@ public class ActionButton extends AbstractElementProcessor {
if (action.isContributed()) {
objectParameters= null;
System.arraycopy(parameters, 0, parameters, 1, parameters.length - 1);
- parameters[0] = tagProcessor.getContext().mapObject(object, Scope.REQUEST);
+ parameters[0] = templateProcessor.getContext().mapObject(object, Scope.REQUEST);
target = action.realTarget(object);
if (!action.hasReturn() && resultOverride == null) {
resultOverride = parameters[0];
@@ -96,7 +97,7 @@ public class ActionButton extends AbstractElementProcessor {
Localization localization = IsisContext.getLocalization();
objectParameters[i] = facet.parseTextEntry(null, parameters[i], localization);
} else {
- objectParameters[i] = MethodsUtils.findObject(tagProcessor.getContext(), parameters[i]);
+ objectParameters[i] = MethodsUtils.findObject(templateProcessor.getContext(), parameters[i]);
}
i++;
}
@@ -104,7 +105,7 @@ public class ActionButton extends AbstractElementProcessor {
if (MethodsUtils.isVisibleAndUsable(object, action, where) && MethodsUtils.canRunMethod(object, action, objectParameters).isAllowed()) {
// TODO use the form creation mechanism as used in ActionForm
- write(tagProcessor, target, action, parameters, objectId, version, forwardResultTo, forwardVoidTo, forwardErrorTo, variable, scope, buttonTitle, completionMessage, resultOverride, idName, className);
+ write(templateProcessor, target, action, parameters, objectId, version, forwardResultTo, forwardVoidTo, forwardErrorTo, variable, scope, buttonTitle, completionMessage, resultOverride, idName, className);
}
if (showMessage) {
@@ -113,35 +114,35 @@ public class ActionButton extends AbstractElementProcessor {
final String notUsable = usable.getReason();
if (notUsable != null) {
String title = buttonTitle == null ? action.getName() : buttonTitle;
- disabledButton(tagProcessor, title, notUsable, idName, className);
+ disabledButton(templateProcessor, title, notUsable, idName, className);
}
} else {
final Consent valid = action.isProposedArgumentSetValid(object, objectParameters);
final String notValid = valid.getReason();
if (notValid != null) {
String title = buttonTitle == null ? action.getName() : buttonTitle;
- disabledButton(tagProcessor, title, notValid, idName, className);
+ disabledButton(templateProcessor, title, notValid, idName, className);
}
}
}
- tagProcessor.popBlockContent();
+ templateProcessor.popBlock();
}
- private void disabledButton(final TagProcessor tagProcessor, final String buttonTitle, String message, String id, String className) {
+ private void disabledButton(final TemplateProcessor templateProcessor, final String buttonTitle, String message, String id, String className) {
if (className == null) {
className = "access";
}
- tagProcessor.appendHtml("<div id=\"" + id + "\" class=\"" + className + " disabled-form\">");
- tagProcessor.appendHtml("<div class=\"button disabled\" title=\"");
- tagProcessor.appendAsHtmlEncoded(message);
- tagProcessor.appendHtml("\" >" + buttonTitle);
- tagProcessor.appendHtml("</div>");
- tagProcessor.appendHtml("</div>");
+ templateProcessor.appendHtml("<div id=\"" + id + "\" class=\"" + className + " disabled-form\">");
+ templateProcessor.appendHtml("<div class=\"button disabled\" title=\"");
+ templateProcessor.appendAsHtmlEncoded(message);
+ templateProcessor.appendHtml("\" >" + buttonTitle);
+ templateProcessor.appendHtml("</div>");
+ templateProcessor.appendHtml("</div>");
}
public static void write(
- final TagProcessor tagProcessor,
+ final TemplateProcessor templateProcessor,
final ObjectAdapter object,
final ObjectAction action,
final String[] parameters,
@@ -157,7 +158,7 @@ public class ActionButton extends AbstractElementProcessor {
final String resultOverride,
final String idName,
final String className) {
- final Request context = tagProcessor.getContext();
+ final Request context = templateProcessor.getContext();
buttonTitle = buttonTitle != null ? buttonTitle : action.getName();
@@ -184,48 +185,48 @@ public class ActionButton extends AbstractElementProcessor {
final String idSegment = idName == null ? "" : ("id=\"" + idName + "\" ");
final String classSegment = "class=\"" + (className == null ? "action in-line" : className) + "\"";
- tagProcessor.appendHtml("\n<form " + idSegment + classSegment + " action=\"action.app\" method=\"post\">\n");
+ templateProcessor.appendHtml("\n<form " + idSegment + classSegment + " action=\"action.app\" method=\"post\">\n");
if (objectId == null) {
- tagProcessor.appendHtml(" <input type=\"hidden\" name=\"" + "_" + OBJECT + "\" value=\"" + context.getVariable(Names.RESULT) + "\" />\n");
+ templateProcessor.appendHtml(" <input type=\"hidden\" name=\"" + "_" + OBJECT + "\" value=\"" + context.getVariable(Names.RESULT) + "\" />\n");
} else {
- tagProcessor.appendHtml(" <input type=\"hidden\" name=\"" + "_" + OBJECT + "\" value=\"" + objectId + "\" />\n");
+ templateProcessor.appendHtml(" <input type=\"hidden\" name=\"" + "_" + OBJECT + "\" value=\"" + objectId + "\" />\n");
}
- tagProcessor.appendHtml(" <input type=\"hidden\" name=\"" + "_" + VERSION + "\" value=\"" + version + "\" />\n");
+ templateProcessor.appendHtml(" <input type=\"hidden\" name=\"" + "_" + VERSION + "\" value=\"" + version + "\" />\n");
if (scope != null) {
- tagProcessor.appendHtml(" <input type=\"hidden\" name=\"" + "_" + SCOPE + "\" value=\"" + scope + "\" />\n");
+ templateProcessor.appendHtml(" <input type=\"hidden\" name=\"" + "_" + SCOPE + "\" value=\"" + scope + "\" />\n");
}
- tagProcessor.appendHtml(" <input type=\"hidden\" name=\"" + "_" + METHOD + "\" value=\"" + action.getId() + "\" />\n");
+ templateProcessor.appendHtml(" <input type=\"hidden\" name=\"" + "_" + METHOD + "\" value=\"" + action.getId() + "\" />\n");
if (forwardResultTo != null) {
forwardResultTo = context.fullFilePath(forwardResultTo);
- tagProcessor.appendHtml(" <input type=\"hidden\" name=\"" + "_" + VIEW + "\" value=\"" + forwardResultTo + "\" />\n");
+ templateProcessor.appendHtml(" <input type=\"hidden\" name=\"" + "_" + VIEW + "\" value=\"" + forwardResultTo + "\" />\n");
}
if (forwardErrorTo == null) {
- forwardErrorTo = tagProcessor.getContext().getResourceFile();
+ forwardErrorTo = templateProcessor.getContext().getResourceFile();
}
forwardErrorTo = context.fullFilePath(forwardErrorTo);
- tagProcessor.appendHtml(" <input type=\"hidden\" name=\"" + "_" + ERROR + "\" value=\"" + forwardErrorTo + "\" />\n");
+ templateProcessor.appendHtml(" <input type=\"hidden\" name=\"" + "_" + ERROR + "\" value=\"" + forwardErrorTo + "\" />\n");
if (forwardVoidTo == null) {
- forwardVoidTo = tagProcessor.getContext().getResourceFile();
+ forwardVoidTo = templateProcessor.getContext().getResourceFile();
}
forwardVoidTo = context.fullFilePath(forwardVoidTo);
- tagProcessor.appendHtml(" <input type=\"hidden\" name=\"" + "_" + VOID + "\" value=\"" + forwardVoidTo + "\" />\n");
+ templateProcessor.appendHtml(" <input type=\"hidden\" name=\"" + "_" + VOID + "\" value=\"" + forwardVoidTo + "\" />\n");
if (variable != null) {
- tagProcessor.appendHtml(" <input type=\"hidden\" name=\"" + "_" + RESULT_NAME + "\" value=\"" + variable + "\" />\n");
+ templateProcessor.appendHtml(" <input type=\"hidden\" name=\"" + "_" + RESULT_NAME + "\" value=\"" + variable + "\" />\n");
}
if (resultOverride != null) {
- tagProcessor.appendHtml(" <input type=\"hidden\" name=\"" + "_" + RESULT_OVERRIDE + "\" value=\"" + resultOverride + "\" />\n");
+ templateProcessor.appendHtml(" <input type=\"hidden\" name=\"" + "_" + RESULT_OVERRIDE + "\" value=\"" + resultOverride + "\" />\n");
}
if (completionMessage != null) {
- tagProcessor.appendHtml(" <input type=\"hidden\" name=\"" + "_" + MESSAGE + "\" value=\"" + completionMessage + "\" />\n");
+ templateProcessor.appendHtml(" <input type=\"hidden\" name=\"" + "_" + MESSAGE + "\" value=\"" + completionMessage + "\" />\n");
}
for (int i = 0; i < parameters.length; i++) {
- tagProcessor.appendHtml(" <input type=\"hidden\" name=\"param" + (i + 1) + "\" value=\"" + parameters[i] + "\" />\n");
+ templateProcessor.appendHtml(" <input type=\"hidden\" name=\"param" + (i + 1) + "\" value=\"" + parameters[i] + "\" />\n");
}
- tagProcessor.appendHtml(tagProcessor.getContext().interactionFields());
- tagProcessor.appendHtml(" <input class=\"button\" type=\"submit\" value=\"" + buttonTitle + "\" name=\"execute\" title=\"" + action.getDescription() + "\" />");
- HelpLink.append(tagProcessor, action.getDescription(), action.getHelp());
- tagProcessor.appendHtml("\n</form>\n");
+ templateProcessor.appendHtml(templateProcessor.getContext().interactionFields());
+ templateProcessor.appendHtml(" <input class=\"button\" type=\"submit\" value=\"" + buttonTitle + "\" name=\"execute\" title=\"" + action.getDescription() + "\" />");
+ HelpLink.append(templateProcessor, action.getDescription(), action.getHelp());
+ templateProcessor.appendHtml("\n</form>\n");
}
@Override
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/ActionContent.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/ActionContent.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/ActionContent.java
index 5d30f0d..c5ea18c 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/ActionContent.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/ActionContent.java
@@ -30,7 +30,7 @@ import org.apache.isis.core.metamodel.spec.feature.ObjectActionParameter;
import org.apache.isis.core.runtime.system.context.IsisContext;
import org.apache.isis.viewer.scimpi.ScimpiException;
import org.apache.isis.viewer.scimpi.dispatcher.processor.BlockContent;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
public class ActionContent implements BlockContent {
private final ObjectAction action;
@@ -55,7 +55,7 @@ public class ActionContent implements BlockContent {
parameters[index] = value;
}
- public ObjectAdapter[] getParameters(final TagProcessor tagProcessor) {
+ public ObjectAdapter[] getParameters(final TemplateProcessor templateProcessor) {
final ObjectAdapter[] params = new ObjectAdapter[parameters.length];
final List<ObjectActionParameter> pars = action.getParameters();
for (int i = 0; i < parameters.length; i++) {
@@ -65,7 +65,7 @@ public class ActionContent implements BlockContent {
Localization localization = IsisContext.getLocalization();
params[i] = facet.parseTextEntry(null, parameters[i], localization);
} else {
- params[i] = tagProcessor.getContext().getMappedObject(parameters[i]);
+ params[i] = templateProcessor.getContext().getMappedObject(parameters[i]);
}
}
return params;
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/ActionForm.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/ActionForm.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/ActionForm.java
index 9f1d682..503a2b6 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/ActionForm.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/ActionForm.java
@@ -19,240 +19,36 @@
package org.apache.isis.viewer.scimpi.dispatcher.view.action;
-import java.util.List;
-import org.apache.isis.applib.annotation.Where;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
-import org.apache.isis.core.metamodel.spec.feature.ObjectActionParameter;
-import org.apache.isis.viewer.scimpi.Names;
-import org.apache.isis.viewer.scimpi.ScimpiException;
-import org.apache.isis.viewer.scimpi.dispatcher.action.ActionAction;
-import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
-import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.structure.FieldEditState;
-import org.apache.isis.viewer.scimpi.dispatcher.structure.FormState;
-import org.apache.isis.viewer.scimpi.dispatcher.util.MethodsUtils;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
-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;
-import org.apache.isis.viewer.scimpi.dispatcher.view.widget.FieldFactory;
-import org.apache.isis.viewer.scimpi.dispatcher.view.widget.FormFieldBlock;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.form.ActionFormAbstract;
+import org.apache.isis.viewer.scimpi.dispatcher.view.form.CreateFormParameter;
-public class ActionForm extends AbstractElementProcessor {
-
- // REVIEW: confirm this rendering context
- private final static Where where = Where.OBJECT_FORMS;
+public class ActionForm extends ActionFormAbstract {
@Override
- public void process(final TagProcessor tagProcessor) {
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
final CreateFormParameter parameters = new CreateFormParameter();
- parameters.objectId = tagProcessor.getOptionalProperty(OBJECT);
- parameters.methodName = tagProcessor.getRequiredProperty(METHOD);
- parameters.forwardResultTo = tagProcessor.getOptionalProperty(VIEW);
- parameters.forwardVoidTo = tagProcessor.getOptionalProperty(VOID);
- parameters.forwardErrorTo = tagProcessor.getOptionalProperty(ERROR);
- parameters.cancelTo = tagProcessor.getOptionalProperty(CANCEL_TO);
- parameters.showIcon = tagProcessor.isRequested(SHOW_ICON, showIconByDefault());
- parameters.buttonTitle = tagProcessor.getOptionalProperty(BUTTON_TITLE);
- parameters.formTitle = tagProcessor.getOptionalProperty(FORM_TITLE);
- parameters.labelDelimiter = tagProcessor.getOptionalProperty(LABEL_DELIMITER, ":");
- parameters.formId = tagProcessor.getOptionalProperty(FORM_ID, tagProcessor.nextFormId());
- parameters.resultName = tagProcessor.getOptionalProperty(RESULT_NAME);
- parameters.resultOverride = tagProcessor.getOptionalProperty(RESULT_OVERRIDE);
- parameters.scope = tagProcessor.getOptionalProperty(SCOPE);
- parameters.className = tagProcessor.getOptionalProperty(CLASS, "action full");
- parameters.showMessage = tagProcessor.isRequested(SHOW_MESSAGE, false);
- parameters.completionMessage = tagProcessor.getOptionalProperty(MESSAGE);
- parameters.id = tagProcessor.getOptionalProperty(ID, parameters.methodName);
- createForm(tagProcessor, parameters);
- }
-
- public static void createForm(final TagProcessor tagProcessor, final CreateFormParameter parameterObject) {
- createForm(tagProcessor, parameterObject, false);
- }
-
- protected static void createForm(final TagProcessor tagProcessor, final CreateFormParameter parameterObject, final boolean withoutProcessing) {
- final Request context = tagProcessor.getContext();
- final ObjectAdapter object = MethodsUtils.findObject(context, parameterObject.objectId);
- final String version = tagProcessor.getContext().mapVersion(object);
- final ObjectAction action = MethodsUtils.findAction(object, parameterObject.methodName);
- // TODO how do we distinguish between overloaded methods?
-
- // REVIEW Is this useful?
- if (action.getParameterCount() == 0) {
- throw new ScimpiException("Action form can only be used for actions with parameters");
- }
- if (parameterObject.showMessage && MethodsUtils.isVisible(object, action, where)) {
- final String notUsable = MethodsUtils.isUsable(object, action, where);
- if (notUsable != null) {
- if (!withoutProcessing) {
- tagProcessor.skipUntilClose();
- }
- tagProcessor.appendHtml("<div class=\"" + parameterObject.className + "-message\" >");
- tagProcessor.appendAsHtmlEncoded(notUsable);
- tagProcessor.appendHtml("</div>");
- return;
- }
- }
- if (!MethodsUtils.isVisibleAndUsable(object, action, where)) {
- if (!withoutProcessing) {
- tagProcessor.skipUntilClose();
- }
- return;
- }
- final String objectId = context.mapObject(object, Scope.INTERACTION);
- final String errorView = context.fullFilePath(parameterObject.forwardErrorTo == null ? context.getResourceFile() : parameterObject.forwardErrorTo);
- final String voidView = context.fullFilePath(parameterObject.forwardVoidTo == null ? context.getResourceFile() : parameterObject.forwardVoidTo);
- if (action.isContributed() && !action.hasReturn() && parameterObject.resultOverride == null) {
- parameterObject.resultOverride = objectId;
- }
- final HiddenInputField[] hiddenFields = new HiddenInputField[] { new HiddenInputField("_" + OBJECT, objectId), new HiddenInputField("_" + VERSION, version), new HiddenInputField("_" + FORM_ID, parameterObject.formId), new HiddenInputField("_" + METHOD, parameterObject.methodName),
- parameterObject.forwardResultTo == null ? null : new HiddenInputField("_" + VIEW, context.fullFilePath(parameterObject.forwardResultTo)), new HiddenInputField("_" + VOID, voidView), new HiddenInputField("_" + ERROR, errorView),
- parameterObject.completionMessage == null ? null : new HiddenInputField("_" + MESSAGE, parameterObject.completionMessage), parameterObject.scope == null ? null : new HiddenInputField("_" + SCOPE, parameterObject.scope),
- parameterObject.resultOverride == null ? null : new HiddenInputField("_" + RESULT_OVERRIDE, parameterObject.resultOverride), parameterObject.resultName == null ? null : new HiddenInputField("_" + RESULT_NAME, parameterObject.resultName),
- parameterObject.resultName == null ? null : new HiddenInputField(Names.RESULT, (String) tagProcessor.getContext().getVariable(Names.RESULT)) };
-
- // TODO when the block contains a selector tag it doesn't disable it if
- // the field cannot be edited!!!
- final FormFieldBlock containedBlock = new FormFieldBlock() {
- @Override
- public boolean isNullable(final String name) {
- final int index = Integer.parseInt(name.substring(5)) - 1;
- final ObjectActionParameter param = action.getParameters().get(index);
- return param.isOptional();
- }
- };
- tagProcessor.setBlockContent(containedBlock);
- if (!withoutProcessing) {
- tagProcessor.processUtilCloseTag();
- }
-
- final FormState entryState = (FormState) context.getVariable(ENTRY_FIELDS);
-
- // TODO the list of included fields should be considered in the next
- // method (see EditObject)
- final InputField[] formFields = createFields(action, object);
- containedBlock.hideExcludedParameters(formFields);
- containedBlock.setUpValues(formFields);
- initializeFields(context, object, action, formFields);
- setDefaults(context, object, action, formFields, entryState, parameterObject.showIcon);
- String errors = null;
- if (entryState != null && entryState.isForForm(parameterObject.formId)) {
- copyEntryState(context, object, action, formFields, entryState);
- errors = entryState.getError();
- }
- overrideWithHtml(context, containedBlock, formFields);
-
- String formTitle;
- if (parameterObject.formTitle == null) {
- formTitle = action.getName();
- } else {
- formTitle = parameterObject.formTitle;
- }
-
- String buttonTitle = parameterObject.buttonTitle;
- if (buttonTitle == null) {
- buttonTitle = action.getName();
- } else if (buttonTitle.equals("")) {
- buttonTitle = "Ok";
- }
-
- HtmlFormBuilder.createForm(tagProcessor, ActionAction.ACTION + ".app", hiddenFields, formFields, parameterObject.className,
- parameterObject.id, formTitle, parameterObject.labelDelimiter, action.getDescription(), action.getHelp(), buttonTitle, errors, parameterObject.cancelTo);
-
- tagProcessor.popBlockContent();
- }
-
- private static InputField[] createFields(final ObjectAction action, final ObjectAdapter object) {
- final int parameterCount = action.getParameterCount();
- final InputField[] fields = new InputField[parameterCount];
- for (int i = 0; i < fields.length; i++) {
- fields[i] = new InputField(ActionAction.parameterName(i));
- }
- return fields;
- }
-
- private static void initializeFields(final Request context, final ObjectAdapter object, final ObjectAction action, final InputField[] fields) {
- final List<ObjectActionParameter> parameters = action.getParameters();
- for (int i = 0; i < fields.length; i++) {
- final InputField field = fields[i];
- final ObjectActionParameter param = parameters.get(i);
- if (action.isContributed() && i == 0) {
- // fields[i].setValue(context.mapObject(object,
- // Scope.INTERACTION));
- fields[i].setType(InputField.REFERENCE);
- fields[i].setHidden(true);
- } else {
-
- fields[i].setHelpReference("xxxhelp");
- final ObjectAdapter[] optionsForParameter = action.getChoices(object)[i];
- FieldFactory.initializeField(context, object, param, optionsForParameter, !param.isOptional(), field);
- }
- }
- }
-
- /**
- * Sets up the fields with their initial values
- *
- * @param showIcon
- */
- private static void setDefaults(final Request context, final ObjectAdapter object, final ObjectAction action, final InputField[] fields, final FormState entryState, final boolean showIcon) {
- final ObjectAdapter[] defaultValues = action.getDefaults(object);
- if (defaultValues == null) {
- return;
- }
-
- for (int i = 0; i < fields.length; i++) {
- final InputField field = fields[i];
- final ObjectAdapter defaultValue = defaultValues[i];
-
- final String title = defaultValue == null ? "" : defaultValue.titleString();
- if (field.getType() == InputField.REFERENCE) {
- final ObjectSpecification objectSpecification = action.getParameters().get(i).getSpecification();
- if (defaultValue != null) {
- final String imageSegment = showIcon ? "<img class=\"small-icon\" src=\"" + context.imagePath(objectSpecification) + "\" alt=\"" + objectSpecification.getShortIdentifier() + "\"/>" : "";
- final String html = imageSegment + title;
- final String value = context.mapObject(defaultValue, Scope.INTERACTION);
- field.setValue(value);
- field.setHtml(html);
- }
- } else {
- field.setValue(title);
- }
- }
- }
-
- private static void copyEntryState(final Request context, final ObjectAdapter object, final ObjectAction action, final InputField[] fields, final FormState entryState) {
-
- for (final InputField field : fields) {
- final FieldEditState fieldState = entryState.getField(field.getName());
- if (fieldState != null) {
- if (field.isEditable()) {
- String entry;
- entry = fieldState.getEntry();
- field.setValue(entry);
- }
-
- field.setErrorText(fieldState.getError());
- }
- }
- }
-
- private static void overrideWithHtml(final Request context, final FormFieldBlock containedBlock, final InputField[] formFields) {
- for (int i = 0; i < formFields.length; i++) {
- final String id = ActionAction.parameterName(i);
- if (containedBlock.hasContent(id)) {
- final String content = containedBlock.getContent(id);
- if (content != null) {
- formFields[i].setHtml(content);
- formFields[i].setType(InputField.HTML);
- }
- }
- }
+ parameters.objectId = templateProcessor.getOptionalProperty(OBJECT);
+ parameters.methodName = templateProcessor.getRequiredProperty(METHOD);
+ parameters.forwardResultTo = templateProcessor.getOptionalProperty(VIEW);
+ parameters.forwardVoidTo = templateProcessor.getOptionalProperty(VOID);
+ parameters.forwardErrorTo = templateProcessor.getOptionalProperty(ERROR);
+ parameters.cancelTo = templateProcessor.getOptionalProperty(CANCEL_TO);
+ parameters.showIcon = templateProcessor.isRequested(SHOW_ICON, showIconByDefault());
+ parameters.buttonTitle = templateProcessor.getOptionalProperty(BUTTON_TITLE);
+ parameters.formTitle = templateProcessor.getOptionalProperty(FORM_TITLE);
+ parameters.labelDelimiter = templateProcessor.getOptionalProperty(LABEL_DELIMITER, ":");
+ parameters.formId = templateProcessor.getOptionalProperty(FORM_ID, templateProcessor.nextFormId());
+ parameters.resultName = templateProcessor.getOptionalProperty(RESULT_NAME);
+ parameters.resultOverride = templateProcessor.getOptionalProperty(RESULT_OVERRIDE);
+ parameters.scope = templateProcessor.getOptionalProperty(SCOPE);
+ parameters.className = templateProcessor.getOptionalProperty(CLASS, "action full");
+ parameters.showMessage = templateProcessor.isRequested(SHOW_MESSAGE, false);
+ parameters.completionMessage = templateProcessor.getOptionalProperty(MESSAGE);
+ parameters.id = templateProcessor.getOptionalProperty(ID, parameters.methodName);
+ createForm(templateProcessor, parameters);
}
@Override
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/ActionLink.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/ActionLink.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/ActionLink.java
index 3a50cda..6223c5c 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/ActionLink.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/ActionLink.java
@@ -25,8 +25,9 @@ import org.apache.isis.applib.annotation.Where;
import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
import org.apache.isis.viewer.scimpi.dispatcher.util.MethodsUtils;
import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
import org.apache.isis.viewer.scimpi.dispatcher.view.other.HelpLink;
@@ -37,43 +38,43 @@ public class ActionLink extends AbstractElementProcessor {
private final Where where = Where.OBJECT_FORMS;
@Override
- public void process(final TagProcessor tagProcessor) {
- String objectId = tagProcessor.getOptionalProperty(OBJECT);
- final String method = tagProcessor.getOptionalProperty(METHOD);
- final String forwardResultTo = tagProcessor.getOptionalProperty(VIEW);
- final String forwardVoidTo = tagProcessor.getOptionalProperty(VOID);
- String resultOverride = tagProcessor.getOptionalProperty(RESULT_OVERRIDE);
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ String objectId = templateProcessor.getOptionalProperty(OBJECT);
+ final String method = templateProcessor.getOptionalProperty(METHOD);
+ final String forwardResultTo = templateProcessor.getOptionalProperty(VIEW);
+ final String forwardVoidTo = templateProcessor.getOptionalProperty(VOID);
+ String resultOverride = templateProcessor.getOptionalProperty(RESULT_OVERRIDE);
- final String resultName = tagProcessor.getOptionalProperty(RESULT_NAME);
+ final String resultName = templateProcessor.getOptionalProperty(RESULT_NAME);
final String resultNameSegment = resultName == null ? "" : "&" + RESULT_NAME + "=" + resultName;
- final String scope = tagProcessor.getOptionalProperty(SCOPE);
+ final String scope = templateProcessor.getOptionalProperty(SCOPE);
final String scopeSegment = scope == null ? "" : "&" + SCOPE + "=" + scope;
- final String confirm = tagProcessor.getOptionalProperty(CONFIRM);
- final String completionMessage = tagProcessor.getOptionalProperty(MESSAGE);
+ final String confirm = templateProcessor.getOptionalProperty(CONFIRM);
+ final String completionMessage = templateProcessor.getOptionalProperty(MESSAGE);
// TODO need a mechanism for globally dealing with encoding; then use
// the new encode method
final String confirmSegment = confirm == null ? "" : "&" + "_" + CONFIRM + "=" + URLEncoder.encode(confirm);
final String messageSegment = completionMessage == null ? "" : "&" + "_" + MESSAGE + "=" + URLEncoder.encode(completionMessage);
- final Request context = tagProcessor.getContext();
+ final Request context = templateProcessor.getContext();
final ObjectAdapter object = MethodsUtils.findObject(context, objectId);
final String version = context.mapVersion(object);
final ObjectAction action = MethodsUtils.findAction(object, method);
- objectId = tagProcessor.getContext().mapObject(object, Scope.REQUEST);
+ objectId = templateProcessor.getContext().mapObject(object, Scope.REQUEST);
final ActionContent parameterBlock = new ActionContent(action);
- tagProcessor.setBlockContent(parameterBlock);
- tagProcessor.pushNewBuffer();
- tagProcessor.processUtilCloseTag();
- final String text = tagProcessor.popBuffer();
+ templateProcessor.pushBlock(parameterBlock);
+ templateProcessor.pushNewBuffer();
+ templateProcessor.processUtilCloseTag();
+ final String text = templateProcessor.popBuffer();
final String[] parameters = parameterBlock.getParameters();
final String target;
if (action.isContributed()) {
System.arraycopy(parameters, 0, parameters, 1, parameters.length - 1);
- parameters[0] = tagProcessor.getContext().mapObject(object, Scope.REQUEST);
- target = tagProcessor.getContext().mapObject(action.realTarget(object), Scope.REQUEST);
+ parameters[0] = templateProcessor.getContext().mapObject(object, Scope.REQUEST);
+ target = templateProcessor.getContext().mapObject(action.realTarget(object), Scope.REQUEST);
if (!action.hasReturn() && resultOverride == null) {
resultOverride = parameters[0];
}
@@ -82,14 +83,14 @@ public class ActionLink extends AbstractElementProcessor {
}
if (MethodsUtils.isVisibleAndUsable(object, action, where)) {
- writeLink(tagProcessor, target, version, method, forwardResultTo, forwardVoidTo, resultNameSegment, resultOverride, scopeSegment,
+ writeLink(templateProcessor, target, version, method, forwardResultTo, forwardVoidTo, resultNameSegment, resultOverride, scopeSegment,
confirmSegment, messageSegment, context, action, parameters, text);
}
- tagProcessor.popBlockContent();
+ templateProcessor.popBlock();
}
public static void writeLink(
- final TagProcessor tagProcessor,
+ final TemplateProcessor templateProcessor,
final String objectId,
final String version,
final String method,
@@ -116,12 +117,12 @@ public class ActionLink extends AbstractElementProcessor {
final String resultOverrideSegment = resultOverride == null ? "" : "&" + "_" + RESULT_OVERRIDE + "=" + resultOverride;
final String voidView = context.fullFilePath(forwardVoidTo == null ? context.getResourceFile() : forwardVoidTo);
final String forwardVoidSegment = "&" + "_" + VOID + "=" + voidView;
- tagProcessor.appendHtml("<a href=\"action.app?" + "_" + OBJECT + "=" + objectId + "&" + "_" + VERSION + "=" + version
+ templateProcessor.appendHtml("<a href=\"action.app?" + "_" + OBJECT + "=" + objectId + "&" + "_" + VERSION + "=" + version
+ "&" + "_" + METHOD + "=" + method + resultOverrideSegment + forwardResultSegment + forwardVoidSegment + resultNameSegment
+ parameterSegment + scopeSegment + confirmSegment + messageSegment + interactionParamters + "\">");
- tagProcessor.appendHtml(text);
- tagProcessor.appendHtml("</a>");
- HelpLink.append(tagProcessor, action.getDescription(), action.getHelp());
+ templateProcessor.appendHtml(text);
+ templateProcessor.appendHtml("</a>");
+ HelpLink.append(templateProcessor, action.getDescription(), action.getHelp());
}
@Override
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/ActionName.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/ActionName.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/ActionName.java
new file mode 100644
index 0000000..836a33d
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/ActionName.java
@@ -0,0 +1,48 @@
+/*
+ * 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.action;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.util.MethodsUtils;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+// TODO do the same for description and help, and for fields
+public class ActionName extends AbstractElementProcessor {
+
+ @Override
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ final String objectId = templateProcessor.getOptionalProperty(OBJECT);
+ final String methodName = templateProcessor.getRequiredProperty(METHOD);
+
+ final ObjectAdapter object = MethodsUtils.findObject(templateProcessor.getContext(), objectId);
+ final ObjectAction action = MethodsUtils.findAction(object, methodName);
+
+ templateProcessor.appendAsHtmlEncoded(action.getName());
+ }
+
+ @Override
+ public String getName() {
+ return "action-name";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/CreateFormParameter.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/CreateFormParameter.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/CreateFormParameter.java
deleted file mode 100644
index 2628449..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/CreateFormParameter.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.viewer.scimpi.dispatcher.view.action;
-
-public class CreateFormParameter {
- public String methodName;
- public String forwardResultTo;
- public String forwardVoidTo;
- public String forwardErrorTo;
- public String buttonTitle;
- public String formTitle;
- public String formId;
- public String resultName;
- public String scope;
- public String objectId;
- public String description;
- public String helpReference;
- public String className;
- public String id;
- public String resultOverride;
- public boolean showMessage;
- public boolean showIcon;
- public String completionMessage;
- public String cancelTo;
- public String labelDelimiter;
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/Methods.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/Methods.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/Methods.java
deleted file mode 100644
index 7c334fb..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/Methods.java
+++ /dev/null
@@ -1,193 +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.action;
-
-import java.util.List;
-
-import org.apache.isis.applib.annotation.Where;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.spec.ActionType;
-import org.apache.isis.core.metamodel.spec.ObjectActionSet;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
-import org.apache.isis.core.metamodel.spec.feature.ObjectActionContainer.Contributed;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.viewer.scimpi.Names;
-import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.util.MethodsUtils;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.view.field.InclusionList;
-
-public class Methods extends AbstractElementProcessor {
-
- // 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 static Where where = Where.ANYWHERE;
-
- @Override
- public void process(final TagProcessor tagProcessor) {
- String objectId = tagProcessor.getOptionalProperty(OBJECT);
- final String view = tagProcessor.getOptionalProperty(VIEW, "_generic_action." + Names.EXTENSION);
- // final String cancelTo = tagProcessor.getOptionalProperty(CANCEL_TO);
- final boolean showForms = tagProcessor.isRequested(FORMS, false);
- final ObjectAdapter object = MethodsUtils.findObject(tagProcessor.getContext(), objectId);
- if (objectId == null) {
- objectId = tagProcessor.getContext().mapObject(object, null);
- }
-
- final InclusionList inclusionList = new InclusionList();
- tagProcessor.setBlockContent(inclusionList);
- tagProcessor.processUtilCloseTag();
-
- tagProcessor.appendHtml("<div class=\"actions\">");
- if (inclusionList.includes("edit") && !object.getSpecification().isService()) {
- tagProcessor.appendHtml("<div class=\"action\">");
- tagProcessor.appendHtml("<a class=\"button\" href=\"_generic_edit." + Names.EXTENSION + "?_result=" + objectId + "\">Edit...</a>");
- tagProcessor.appendHtml("</div>");
- }
- writeMethods(tagProcessor, objectId, object, showForms, inclusionList, view, "_generic.shtml?_result=" + objectId);
- tagProcessor.popBlockContent();
- tagProcessor.appendHtml("</div>");
- }
-
- public static void writeMethods(
- final TagProcessor tagProcessor,
- final String objectId,
- final ObjectAdapter adapter,
- final boolean showForms,
- final InclusionList inclusionList,
- final String view,
- final String cancelTo) {
- List<ObjectAction> actions = adapter.getSpecification().getObjectActions(ActionType.USER, Contributed.INCLUDED);
- writeMethods(tagProcessor, adapter, actions, objectId, showForms, inclusionList, view, cancelTo);
- // TODO determine if system is set up to display exploration methods
- if (true) {
- actions = adapter.getSpecification().getObjectActions(ActionType.EXPLORATION, Contributed.INCLUDED);
- writeMethods(tagProcessor, adapter, actions, objectId, showForms, inclusionList, view, cancelTo);
- }
- // TODO determine if system is set up to display debug methods
- if (true) {
- actions = adapter.getSpecification().getObjectActions(ActionType.DEBUG, Contributed.INCLUDED);
- writeMethods(tagProcessor, adapter, actions, objectId, showForms, inclusionList, view, cancelTo);
- }
- }
-
- private static void writeMethods(
- final TagProcessor tagProcessor,
- final ObjectAdapter adapter,
- List<ObjectAction> actions,
- final String objectId,
- final boolean showForms,
- final InclusionList inclusionList,
- final String view,
- final String cancelTo) {
- actions = inclusionList.includedActions(actions);
- for (int j = 0; j < actions.size(); j++) {
- final ObjectAction action = actions.get(j);
- if (action instanceof ObjectActionSet) {
- tagProcessor.appendHtml("<div class=\"actions\">");
- writeMethods(tagProcessor, adapter, action.getActions(), objectId, showForms, inclusionList, view, cancelTo);
- tagProcessor.appendHtml("</div>");
- } else if (action.isContributed()) {
- if (action.getParameterCount() == 1 && adapter.getSpecification().isOfType(action.getParameters().get(0).getSpecification())) {
- if (objectId != null) {
- final ObjectAdapter target = tagProcessor.getContext().getMappedObject(objectId);
- final ObjectAdapter realTarget = action.realTarget(target);
- final String realTargetId = tagProcessor.getContext().mapObject(realTarget, Scope.INTERACTION);
- writeMethod(tagProcessor, adapter, new String[] { objectId }, action, realTargetId, showForms, view, cancelTo);
- } else {
- tagProcessor.appendHtml("<div class=\"action\">");
- tagProcessor.appendAsHtmlEncoded(action.getName());
- tagProcessor.appendHtml("???</div>");
- }
- } else if (!adapter.getSpecification().isService()) {
- writeMethod(tagProcessor, adapter, new String[0], action, objectId, showForms, view, cancelTo);
- }
- } else {
- writeMethod(tagProcessor, adapter, new String[0], action, objectId, showForms, view, cancelTo);
- }
- }
- }
-
- private static void writeMethod(
- final TagProcessor tagProcessor,
- final ObjectAdapter adapter,
- final String[] parameters,
- final ObjectAction action,
- final String objectId,
- final boolean showForms,
- final String view,
- final String cancelTo) {
- // if (action.isVisible(IsisContext.getSession(), null) &&
- // action.isVisible(IsisContext.getSession(), adapter))
- // {
- if (action.isVisible(IsisContext.getAuthenticationSession(), adapter, where).isAllowed()) {
- tagProcessor.appendHtml("<div class=\"action\">");
- if (IsisContext.getSession() == null) {
- tagProcessor.appendHtml("<span class=\"disabled\" title=\"no user logged in\">");
- tagProcessor.appendAsHtmlEncoded(action.getName());
- tagProcessor.appendHtml("</span>");
- /*
- * } else if (action.isUsable(IsisContext.getSession(),
- * null).isVetoed()) {
- * request.appendHtml("<span class=\"disabled\" title=\"" +
- * action.isUsable(IsisContext.getSession(), null).getReason() +
- * "\">"); request.appendHtml(action.getName());
- * request.appendHtml("</span>");
- */} else if (action.isUsable(IsisContext.getAuthenticationSession(), adapter, where).isVetoed()) {
- tagProcessor.appendHtml("<span class=\"disabled\" title=\"" + action.isUsable(IsisContext.getAuthenticationSession(), adapter, where).getReason() + "\">");
- tagProcessor.appendAsHtmlEncoded(action.getName());
- tagProcessor.appendHtml("</span>");
- } else {
- final String version = tagProcessor.getContext().mapVersion(adapter);
- if (action.getParameterCount() == 0 || (action.isContributed() && action.getParameterCount() == 1)) {
- ActionButton.write(tagProcessor, adapter, action, parameters, objectId, version, "_generic." + Names.EXTENSION, null, null, null, null, null, null, null, null, null);
- } else if (showForms) {
- final CreateFormParameter params = new CreateFormParameter();
- params.objectId = objectId;
- params.methodName = action.getId();
- params.forwardResultTo = "_generic." + Names.EXTENSION;
- params.buttonTitle = "OK";
- params.formTitle = action.getName();
- ActionForm.createForm(tagProcessor, params, true);
- } else {
- tagProcessor.appendHtml("<a class=\"button\" href=\"" + view + "?_result=" + objectId + "&_" + VERSION + "=" + version + "&_" + METHOD + "=" + action.getId());
- if (cancelTo != null) {
- tagProcessor.appendHtml("&_cancel-to=");
- tagProcessor.appendAsHtmlEncoded("cancel-to=\"" + cancelTo + "\"");
- }
- tagProcessor.appendHtml("\" title=\"" + action.getDescription() + "\">");
- tagProcessor.appendAsHtmlEncoded(action.getName() + "...");
- tagProcessor.appendHtml("</a>");
- }
- }
- tagProcessor.appendHtml("</div>");
- }
- }
-
- @Override
- public String getName() {
- return "methods";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/NewActionLink.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/NewActionLink.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/NewActionLink.java
new file mode 100644
index 0000000..884d191
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/NewActionLink.java
@@ -0,0 +1,63 @@
+/*
+ * 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.action;
+
+import org.apache.isis.applib.annotation.Where;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
+import org.apache.isis.viewer.scimpi.Names;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.util.MethodsUtils;
+import org.apache.isis.viewer.scimpi.dispatcher.view.object.LinkAbstract;
+
+public class NewActionLink extends LinkAbstract {
+
+ // REVIEW: confirm this rendering context
+ private final Where where = Where.OBJECT_FORMS;
+
+ @Override
+ protected boolean valid(final TemplateProcessor templateProcessor, final ObjectAdapter object) {
+ final String method = templateProcessor.getRequiredProperty(METHOD);
+ final ObjectAction action = MethodsUtils.findAction(object, method);
+ return MethodsUtils.isVisibleAndUsable(object, action, where);
+ }
+
+ @Override
+ protected String linkLabel(final String name, final ObjectAdapter object) {
+ return "run";
+ }
+
+ @Override
+ protected String defaultView() {
+ return "_generic_action." + Names.EXTENSION;
+ }
+
+ @Override
+ protected String additionalParameters(final TemplateProcessor templateProcessor) {
+ final String method = templateProcessor.getRequiredProperty(METHOD);
+ return "method=" + method;
+ }
+
+ @Override
+ public String getName() {
+ return "new-action-link";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/Parameter.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/Parameter.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/Parameter.java
index cbf7464..78ad9e3 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/Parameter.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/Parameter.java
@@ -19,22 +19,23 @@
package org.apache.isis.viewer.scimpi.dispatcher.view.action;
-import org.apache.isis.viewer.scimpi.dispatcher.TagOrderException;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
import org.apache.isis.viewer.scimpi.dispatcher.processor.BlockContent;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagOrderException;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public class Parameter extends AbstractElementProcessor {
@Override
- public void process(final TagProcessor tagProcessor) {
- final BlockContent blockContent = tagProcessor.getBlockContent();
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ final BlockContent blockContent = templateProcessor.peekBlock();
if (!(blockContent instanceof ActionContent)) {
- throw new TagOrderException(tagProcessor);
+ throw new TagOrderException(templateProcessor);
}
- final String field = tagProcessor.getOptionalProperty(PARAMETER_NUMBER);
- final String value = tagProcessor.getRequiredProperty(VALUE);
+ final String field = templateProcessor.getOptionalProperty(PARAMETER_NUMBER);
+ final String value = templateProcessor.getRequiredProperty(VALUE);
final ActionContent block = (ActionContent) blockContent;
block.setParameter(field, value);
}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/ParameterName.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/ParameterName.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/ParameterName.java
new file mode 100644
index 0000000..0bc27c1
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/ParameterName.java
@@ -0,0 +1,63 @@
+/*
+ * 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.action;
+
+import java.util.List;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
+import org.apache.isis.core.metamodel.spec.feature.ObjectActionParameter;
+import org.apache.isis.viewer.scimpi.ScimpiException;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.util.MethodsUtils;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+public class ParameterName extends AbstractElementProcessor {
+
+ @Override
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ final String objectId = templateProcessor.getOptionalProperty(OBJECT);
+ final String methodName = templateProcessor.getRequiredProperty(METHOD);
+ final String field = templateProcessor.getOptionalProperty(PARAMETER_NUMBER);
+
+ final ObjectAdapter object = MethodsUtils.findObject(templateProcessor.getContext(), objectId);
+ final ObjectAction action = MethodsUtils.findAction(object, methodName);
+ final List<ObjectActionParameter> parameters = action.getParameters();
+
+ int index;
+ if (field == null) {
+ index = 0;
+ } else {
+ index = Integer.valueOf(field).intValue() - 1;
+ }
+ if (index < 0 || index >= parameters.size()) {
+ throw new ScimpiException("Parameter numbers should be between 1 and " + parameters.size() + ": " + index);
+ }
+
+ templateProcessor.appendAsHtmlEncoded(parameters.get(index).getName());
+ }
+
+ @Override
+ public String getName() {
+ return "parameter-name";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/RunAction.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/RunAction.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/RunAction.java
index 00d617c..d2478bb 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/RunAction.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/RunAction.java
@@ -27,8 +27,9 @@ import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
import org.apache.isis.core.metamodel.spec.feature.ObjectActionParameter;
import org.apache.isis.viewer.scimpi.ForbiddenException;
import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
import org.apache.isis.viewer.scimpi.dispatcher.util.MethodsUtils;
import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
@@ -42,22 +43,22 @@ public class RunAction extends AbstractElementProcessor {
private final Where where = Where.ANYWHERE;
@Override
- public void process(final TagProcessor tagProcessor) {
- final Request context = tagProcessor.getContext();
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ final Request context = templateProcessor.getContext();
- final String objectId = tagProcessor.getOptionalProperty(OBJECT);
+ final String objectId = templateProcessor.getOptionalProperty(OBJECT);
final ObjectAdapter object = MethodsUtils.findObject(context, objectId);
- final String methodName = tagProcessor.getRequiredProperty(METHOD);
+ final String methodName = templateProcessor.getRequiredProperty(METHOD);
final ObjectAction action = MethodsUtils.findAction(object, methodName);
- final String variableName = tagProcessor.getOptionalProperty(RESULT_NAME);
- final String scopeName = tagProcessor.getOptionalProperty(SCOPE);
+ final String variableName = templateProcessor.getOptionalProperty(RESULT_NAME);
+ final String scopeName = templateProcessor.getOptionalProperty(SCOPE);
final ActionContent parameterBlock = new ActionContent(action);
- tagProcessor.setBlockContent(parameterBlock);
- tagProcessor.processUtilCloseTag();
- final ObjectAdapter[] parameters = parameterBlock.getParameters(tagProcessor);
+ templateProcessor.pushBlock(parameterBlock);
+ templateProcessor.processUtilCloseTag();
+ final ObjectAdapter[] parameters = parameterBlock.getParameters(templateProcessor);
if (!MethodsUtils.isVisibleAndUsable(object, action, where)) {
throw new ForbiddenException(action, ForbiddenException.VISIBLE_AND_USABLE);
@@ -76,7 +77,7 @@ public class RunAction extends AbstractElementProcessor {
final Scope scope = Request.scope(scopeName, Scope.REQUEST);
MethodsUtils.runMethod(context, action, object, parameters, variableName, scope);
- tagProcessor.popBlockContent();
+ templateProcessor.popBlock();
}
@Override
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/Services.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/Services.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/Services.java
deleted file mode 100644
index 761b849..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/Services.java
+++ /dev/null
@@ -1,67 +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.action;
-
-import java.util.List;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.core.runtime.system.persistence.PersistenceSession;
-import org.apache.isis.viewer.scimpi.Names;
-import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.view.field.InclusionList;
-
-public class Services extends AbstractElementProcessor {
-
- @Override
- public void process(final TagProcessor tagProcessor) {
- final boolean showForms = tagProcessor.isRequested(FORMS, false);
- final String view = tagProcessor.getOptionalProperty(VIEW, "_generic_action." + Names.EXTENSION);
- final String cancelTo = tagProcessor.getOptionalProperty(CANCEL_TO);
-
- final InclusionList inclusionList = new InclusionList();
- tagProcessor.setBlockContent(inclusionList);
- tagProcessor.processUtilCloseTag();
-
- final List<ObjectAdapter> serviceAdapters = getPersistenceSession().getServices();
- for (final ObjectAdapter adapter : serviceAdapters) {
- final String serviceId = tagProcessor.getContext().mapObject(adapter, Scope.REQUEST);
- tagProcessor.appendHtml("<div class=\"actions\">");
- tagProcessor.appendHtml("<h3>");
- tagProcessor.appendAsHtmlEncoded(adapter.titleString());
- tagProcessor.appendHtml("</h3>");
- Methods.writeMethods(tagProcessor, serviceId, adapter, showForms, inclusionList, view, cancelTo);
- tagProcessor.appendHtml("</div>");
- }
- tagProcessor.popBlockContent();
- }
-
- @Override
- public String getName() {
- return "services";
- }
-
- private static PersistenceSession getPersistenceSession() {
- return IsisContext.getPersistenceSession();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/collection/AbstractTableView.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/collection/AbstractTableView.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/collection/AbstractTableView.java
new file mode 100644
index 0000000..d73b0a0
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/collection/AbstractTableView.java
@@ -0,0 +1,150 @@
+/*
+ * 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.collection;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.isis.applib.annotation.Where;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacet;
+import org.apache.isis.core.metamodel.facets.typeof.TypeOfFacet;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociationFilters;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.core.runtime.system.persistence.Persistor;
+import org.apache.isis.viewer.scimpi.ScimpiException;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+public abstract class AbstractTableView extends AbstractElementProcessor {
+
+ // REVIEW: should provide this rendering context, rather than hardcoding.
+ // the net effect currently is that class members annotated with
+ // @Hidden(where=Where.ALL_TABLES) or @Disabled(where=Where.ALL_TABLES) will indeed
+ // be hidden from all tables but will be visible/enabled (perhaps incorrectly)
+ // if annotated with Where.PARENTED_TABLE or Where.STANDALONE_TABLE
+ private final Where where = Where.ALL_TABLES;
+
+ @Override
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ final Request context = templateProcessor.getContext();
+
+ ObjectAdapter collection;
+ String parentObjectId = null;
+ boolean isFieldEditable = false;
+ final String field = templateProcessor.getOptionalProperty(FIELD);
+ final String tableClass = templateProcessor.getOptionalProperty(CLASS);
+ ObjectSpecification elementSpec;
+ String tableId;
+ if (field != null) {
+ final String objectId = templateProcessor.getOptionalProperty(OBJECT);
+ final ObjectAdapter object = context.getMappedObjectOrResult(objectId);
+ if (object == null) {
+ throw new ScimpiException("No object for result or " + objectId);
+ }
+ final ObjectAssociation objectField = object.getSpecification().getAssociation(field);
+ if (!objectField.isOneToManyAssociation()) {
+ throw new ScimpiException("Field " + objectField.getId() + " is not a collection");
+ }
+ isFieldEditable = objectField.isUsable(IsisContext.getAuthenticationSession(), object, where).isAllowed();
+ getPersistenceSession().resolveField(object, objectField);
+ collection = objectField.get(object);
+ final TypeOfFacet facet = objectField.getFacet(TypeOfFacet.class);
+ elementSpec = facet.valueSpec();
+ parentObjectId = objectId == null ? context.mapObject(object, Scope.REQUEST) : objectId;
+ tableId = templateProcessor.getOptionalProperty(ID, field);
+ } else {
+ final String id = templateProcessor.getOptionalProperty(COLLECTION);
+ collection = context.getMappedObjectOrResult(id);
+ elementSpec = collection.getElementSpecification();
+ tableId = templateProcessor.getOptionalProperty(ID, collection.getElementSpecification().getShortIdentifier());
+ }
+
+ final String summary = templateProcessor.getOptionalProperty("summary");
+ final String rowClassesList = templateProcessor.getOptionalProperty(ROW_CLASSES, ODD_ROW_CLASS + "|" + EVEN_ROW_CLASS);
+ String[] rowClasses = null;
+ if (rowClassesList.length() > 0) {
+ rowClasses = rowClassesList.split("[,|/]");
+ }
+
+ final List<ObjectAssociation> allFields = elementSpec.getAssociations(ObjectAssociationFilters.WHEN_VISIBLE_IRRESPECTIVE_OF_WHERE);
+ final TableContentWriter rowBuilder = createRowBuilder(templateProcessor, context, isFieldEditable ? parentObjectId : null, allFields, collection);
+ write(templateProcessor, collection, summary, rowBuilder, tableId, tableClass, rowClasses);
+
+ }
+
+ protected Persistor getPersistenceSession() {
+ return IsisContext.getPersistenceSession();
+ }
+
+ protected abstract TableContentWriter createRowBuilder(final TemplateProcessor templateProcessor, Request context, final String parent, final List<ObjectAssociation> allFields, ObjectAdapter collection);
+
+ public static void write(
+ final TemplateProcessor templateProcessor,
+ final ObjectAdapter collection,
+ final String summary,
+ final TableContentWriter rowBuilder,
+ final String tableId,
+ final String tableClass,
+ final String[] rowClasses) {
+ final Request context = templateProcessor.getContext();
+
+ final String summarySegment = summary == null ? "" : (" summary=\"" + summary + "\"");
+ final String idSegment = tableId == null ? "" : (" id=\"" + tableId + "\"");
+ final String classSegment = tableClass == null ? "" : (" class=\"" + tableClass + "\"");
+ templateProcessor.appendHtml("<table" + idSegment + classSegment + summarySegment + ">");
+ rowBuilder.writeCaption(templateProcessor);
+ rowBuilder.writeHeaders(templateProcessor);
+ rowBuilder.writeFooters(templateProcessor);
+
+ templateProcessor.appendHtml("<tbody>");
+ final CollectionFacet facet = collection.getSpecification().getFacet(CollectionFacet.class);
+ final Iterator<ObjectAdapter> iterator = facet.iterator(collection);
+ int row = 1;
+ while (iterator.hasNext()) {
+ final ObjectAdapter element = iterator.next();
+
+ context.addVariable("row", "" + (row), Scope.REQUEST);
+ String cls = "";
+ if (rowClasses != null) {
+ cls = " class=\"" + rowClasses[row % rowClasses.length] + "\"";
+ }
+ templateProcessor.appendHtml("<tr" + cls + ">");
+ rowBuilder.writeElement(templateProcessor, context, element);
+ templateProcessor.appendHtml("</tr>");
+ row++;
+ }
+ templateProcessor.appendHtml("</tbody>");
+ templateProcessor.appendHtml("</table>");
+
+ rowBuilder.tidyUp();
+ }
+
+ @Override
+ public String getName() {
+ return "table";
+ }
+
+}
[13/24] Restructuring Scimpi to remove dependencies and enable easier
testing.
Posted by rm...@apache.org.
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/RemoveElement.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/RemoveElement.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/RemoveElement.java
deleted file mode 100644
index a9b9800..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/RemoveElement.java
+++ /dev/null
@@ -1,143 +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.Where;
-import org.apache.isis.applib.filter.Filter;
-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.spec.feature.ObjectAssociation;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAssociationFilters;
-import org.apache.isis.core.metamodel.spec.feature.OneToManyAssociation;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.viewer.scimpi.ForbiddenException;
-import org.apache.isis.viewer.scimpi.Names;
-import org.apache.isis.viewer.scimpi.ScimpiException;
-import org.apache.isis.viewer.scimpi.dispatcher.action.RemoveAction;
-import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
-import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.util.MethodsUtils;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
-
-public class RemoveElement extends AbstractElementProcessor {
-
- // 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 static Where where = Where.ANYWHERE;
-
- @Override
- public void process(final TagProcessor tagProcessor) {
- final String title = tagProcessor.getOptionalProperty(BUTTON_TITLE, "Remove From List");
- final String cls = tagProcessor.getOptionalProperty(CLASS, "action in-line delete confirm");
- final String object = tagProcessor.getOptionalProperty(OBJECT);
- final String resultOverride = tagProcessor.getOptionalProperty(RESULT_OVERRIDE);
- final Request context = tagProcessor.getContext();
- final String objectId = object != null ? object : (String) context.getVariable(Names.RESULT);
- final ObjectAdapter adapter = MethodsUtils.findObject(context, objectId);
-
- final String element = tagProcessor.getOptionalProperty(ELEMENT, (String) context.getVariable(ELEMENT));
- final ObjectAdapter elementId = MethodsUtils.findObject(context, element);
-
- final String fieldName = tagProcessor.getRequiredProperty(FIELD);
-
- String view = tagProcessor.getOptionalProperty(VIEW);
- view = context.fullFilePath(view == null ? context.getResourceFile() : view);
- String error = tagProcessor.getOptionalProperty(ERROR);
- error = context.fullFilePath(error == null ? context.getResourceFile() : error);
-
- tagProcessor.processUtilCloseTag();
-
- write(tagProcessor, adapter, fieldName, elementId, resultOverride, view, error, title, cls);
- }
-
- @Override
- public String getName() {
- return "remove-element";
- }
-
- public static void write(final TagProcessor tagProcessor, final ObjectAdapter adapter, final String fieldName, final ObjectAdapter element, final String resultOverride, final String view, final String error, final String title, final String cssClass) {
- final ObjectAssociation field = adapter.getSpecification().getAssociation(fieldName);
- if (field == null) {
- throw new ScimpiException("No field " + fieldName + " in " + adapter.getSpecification().getFullIdentifier());
- }
- if (!field.isOneToManyAssociation()) {
- throw new ScimpiException("Field " + fieldName + " not a collection, in " + adapter.getSpecification().getFullIdentifier());
- }
- if (field.isVisible(IsisContext.getAuthenticationSession(), adapter, where).isVetoed()) {
- throw new ForbiddenException(field, ForbiddenException.VISIBLE);
- }
- IsisContext.getPersistenceSession().resolveField(adapter, field);
-
- Consent usable = field.isUsable(IsisContext.getAuthenticationSession(), adapter, where);
- if (usable.isAllowed()) {
- usable = ((OneToManyAssociation) field).isValidToRemove(adapter, element);
- }
-
- if (usable.isVetoed()) {
- tagProcessor.appendHtml("<div class=\"" + cssClass + " disabled-form\">");
- tagProcessor.appendHtml("<div class=\"button disabled\" title=\"");
- tagProcessor.appendAsHtmlEncoded(usable.getReason());
- tagProcessor.appendHtml("\" >" + title);
- tagProcessor.appendHtml("</div>");
- tagProcessor.appendHtml("</div>");
- } else {
- if (valid(tagProcessor, adapter)) {
- final String classSegment = " class=\"" + cssClass + "\"";
-
- final String objectId = tagProcessor.getContext().mapObject(adapter, Scope.INTERACTION);
- final String elementId = tagProcessor.getContext().mapObject(element, Scope.INTERACTION);
- final String action = RemoveAction.ACTION + Names.COMMAND_ROOT;
- tagProcessor.appendHtml("<form" + classSegment + " method=\"post\" action=\"" + action + "\" >");
- tagProcessor.appendHtml("<input type=\"hidden\" name=\"" + OBJECT + "\" value=\"" + objectId + "\" />");
- tagProcessor.appendHtml("<input type=\"hidden\" name=\"" + FIELD + "\" value=\"" + fieldName + "\" />");
- tagProcessor.appendHtml("<input type=\"hidden\" name=\"" + ELEMENT + "\" value=\"" + elementId + "\" />");
- if (resultOverride != null) {
- tagProcessor.appendHtml("<input type=\"hidden\" name=\"" + RESULT_OVERRIDE + "\" value=\"" + resultOverride + "\" />");
- }
- tagProcessor.appendHtml("<input type=\"hidden\" name=\"" + VIEW + "\" value=\"" + view + "\" />");
- tagProcessor.appendHtml("<input type=\"hidden\" name=\"" + ERROR + "\" value=\"" + error + "\" />");
- tagProcessor.appendHtml(tagProcessor.getContext().interactionFields());
- tagProcessor.appendHtml("<input class=\"button\" type=\"submit\" value=\"" + title + "\" />");
- tagProcessor.appendHtml("</form>");
- }
- }
- }
-
- private static boolean valid(final TagProcessor tagProcessor, final ObjectAdapter adapter) {
- // TODO is this check valid/necessary?
-
- // TODO check is valid to remove element
- final AuthenticationSession session = IsisContext.getAuthenticationSession();
- final Filter<ObjectAssociation> filter = ObjectAssociationFilters.dynamicallyVisible(session, adapter, where);
- final List<ObjectAssociation> visibleFields = adapter.getSpecification().getAssociations(filter);
- if (visibleFields.size() == 0) {
- return false;
- }
-
- return true;
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/ScopeTag.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/ScopeTag.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/ScopeTag.java
deleted file mode 100644
index ece1d68..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/ScopeTag.java
+++ /dev/null
@@ -1,51 +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.context.Request;
-import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
-
-public class ScopeTag extends AbstractElementProcessor {
-
- @Override
- public void process(final TagProcessor tagProcessor) {
- final String name = tagProcessor.getRequiredProperty(NAME);
- final String scopeName = tagProcessor.getRequiredProperty(SCOPE);
- final Scope scope = Request.scope(scopeName);
- tagProcessor.processUtilCloseTag();
- changeScope(tagProcessor, name, scope);
- }
-
- protected static void changeScope(final TagProcessor tagProcessor, final String name, final Scope scope) {
- tagProcessor.getContext().changeScope(name, scope);
- final Object value = tagProcessor.getContext().getVariable(name);
- if (value != null) {
- tagProcessor.getContext().addVariable(name, value, scope);
- }
- }
-
- @Override
- public String getName() {
- return "scope";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/SetCookie.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/SetCookie.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/SetCookie.java
deleted file mode 100644
index 2ecb0cf..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/SetCookie.java
+++ /dev/null
@@ -1,53 +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.processor.RequiredPropertyException;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
-
-public class SetCookie extends AbstractElementProcessor {
-
- @Override
- public void process(final TagProcessor tagProcessor) {
- final String name = tagProcessor.getRequiredProperty("name");
- final String value = tagProcessor.getOptionalProperty("value");
- final boolean isClear = tagProcessor.getOptionalProperty("action", "set").equals("clear");
- final String expiresString = tagProcessor.getOptionalProperty("expires", "-1");
-
- if (!isClear && value == null) {
- throw new RequiredPropertyException("Property not set: " + value);
- }
- if (isClear) {
- tagProcessor.appendDebug("cookie: " + name + " (cleared)");
- tagProcessor.getContext().addCookie(name, null, 0);
- } else {
- if (value.length() > 0) {
- tagProcessor.appendDebug("cookie: " + name + " set to"+ value);
- tagProcessor.getContext().addCookie(name, value, Integer.valueOf(expiresString));
- }
- }
- }
-
- @Override
- public String getName() {
- return "set-cookie";
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/SetCookieFromField.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/SetCookieFromField.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/SetCookieFromField.java
deleted file mode 100644
index 6e422d6..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/SetCookieFromField.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.viewer.scimpi.dispatcher.view.simple;
-
-import org.apache.isis.core.commons.exceptions.NotYetImplementedException;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
-
-public class SetCookieFromField extends AbstractElementProcessor {
-
- @Override
- public void process(final TagProcessor tagProcessor) {
- throw new NotYetImplementedException("3.1");
- /*
- * String objectId = request.getOptionalProperty(OBJECT); String
- * fieldName = request.getRequiredProperty(FIELD);
- *
- * ObjectAdapter object = (ObjectAdapter)
- * request.getContext().getMappedObjectOrResult(objectId);
- * ObjectAssociation field =
- * object.getSpecification().getField(fieldName); if (field.isValue()) {
- * throw new ScimpiException("Can only set up a value field"); }
- * ObjectAdapter value = field.get(object); if (value != null) { String
- * title = value.titleString();
- *
- * if (title.length() > 0) { String name =
- * request.getRequiredProperty(NAME); String expiresString =
- * request.getOptionalProperty("expires", "-1");
- * request.getContext().addCookie(name, title,
- * Integer.valueOf(expiresString)); } }
- */
- }
-
- @Override
- public String getName() {
- return "set-cookie-from-field";
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/SetFieldFromCookie.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/SetFieldFromCookie.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/SetFieldFromCookie.java
deleted file mode 100644
index 11c3861..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/SetFieldFromCookie.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.core.commons.exceptions.NotYetImplementedException;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
-
-public class SetFieldFromCookie extends AbstractElementProcessor {
-
- @Override
- public void process(final TagProcessor tagProcessor) {
- throw new NotYetImplementedException("3.1");
- /*
- * String name = request.getRequiredProperty(NAME); String cookieString
- * = request.getContext().getCookie(name); ObjectAdapter valueAdapter =
- * IsisContext.getObjectPersistor().createAdapterForValue(cookieString);
- *
- * String objectId = request.getOptionalProperty(OBJECT); String
- * fieldName = request.getRequiredProperty(FIELD); ObjectAdapter object
- * = (ObjectAdapter)
- * request.getContext().getMappedObjectOrResult(objectId);
- * ObjectAssociation field =
- * object.getSpecification().getField(fieldName); if (field.isValue()) {
- * throw new ScimpiException("Can only set up a value field"); }
- *
- * ((ValueAssociation) field).setValue(object, valueAdapter);
- */
- }
-
- @Override
- public String getName() {
- return "set-field-from-cookie";
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/SetLocalization.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/SetLocalization.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/SetLocalization.java
deleted file mode 100644
index f241e2e..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/SetLocalization.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.core.runtime.userprofile.UserLocalization;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
-
-/**
- * Displays the localization data for the current user.
- */
-public class SetLocalization extends AbstractElementProcessor {
-
- @Override
- public void process(final TagProcessor tagProcessor) {
- tagProcessor.closeEmpty();
-
- final String localeCode = tagProcessor.getRequiredProperty("locale");
- final String timeZone = tagProcessor.getRequiredProperty("time-zone");
-
- String country;
- String language;
- int pos = localeCode.indexOf('_');
- if (pos == 1) {
- language = localeCode;
- country = "";
- } else {
- language = localeCode.substring(0, pos);
- country = localeCode.substring(pos + 1);
- }
-
- Locale l = new Locale(language, country);
- TimeZone t = TimeZone.getTimeZone(timeZone);
- IsisContext.getUserProfile().setLocalization(new UserLocalization(l, t));
-
- }
-
- @Override
- public String getName() {
- return "alpha-set-localization";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/SimpleButton.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/SimpleButton.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/SimpleButton.java
deleted file mode 100644
index e6ab245..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/SimpleButton.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.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
-
-public class SimpleButton extends AbstractElementProcessor {
- @Override
- public void process(final TagProcessor tagProcessor) {
- final String href = tagProcessor.getRequiredProperty("href");
- tagProcessor.pushNewBuffer();
- tagProcessor.processUtilCloseTag();
- final String text = tagProcessor.popBuffer();
- tagProcessor.appendHtml("<div class=\"action\"><a class=\"button\" href=\"" + href + "\">" + text + "</a></div>");
- }
-
- @Override
- public String getName() {
- return "button";
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/StartSession.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/StartSession.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/StartSession.java
deleted file mode 100644
index 82d0242..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/StartSession.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.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
-
-public class StartSession extends AbstractElementProcessor {
-
- @Override
- public void process(final TagProcessor tagProcessor) {
- tagProcessor.getContext().startHttpSession();
- }
-
- @Override
- public String getName() {
- return "start-session";
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/TemplateTag.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/TemplateTag.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/TemplateTag.java
deleted file mode 100644
index 071814d..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/TemplateTag.java
+++ /dev/null
@@ -1,40 +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.processor.ElementProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-
-public class TemplateTag implements ElementProcessor {
-
- @Override
- public String getName() {
- return "template";
- }
-
- @Override
- public void process(final TagProcessor tagProcessor) {
- // REVIEW this make IE8 render poorly as the browser doesn't think a
- // DOCTYPE is provided, causing it to run in
- // quirk mode
- // request.appendHtml("<!-- zz apply template " +
- // request.getOptionalProperty("file") + " -->");
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Unless.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Unless.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Unless.java
deleted file mode 100644
index 3de6348..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Unless.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.simple;
-
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-
-public class Unless extends AbstractConditionalBlock {
-
- @Override
- protected void processTags(final boolean isSet, final TagProcessor tagProcessor) {
- if (isSet) {
- tagProcessor.skipUntilClose();
- tagProcessor.appendDebug(" skipping segment");
- } else {
- tagProcessor.processUtilCloseTag();
- }
- }
-
- @Override
- public String getName() {
- return "unless";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Variable.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Variable.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Variable.java
deleted file mode 100644
index 559e0e1..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Variable.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 org.apache.isis.viewer.scimpi.dispatcher.context.Request;
-import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
-
-public class Variable extends AbstractElementProcessor {
-
- @Override
- public void process(final TagProcessor tagProcessor) {
- final String name = tagProcessor.getOptionalProperty(NAME);
- final String value = tagProcessor.getOptionalProperty(VALUE);
- final String defaultTo = tagProcessor.getOptionalProperty(DEFAULT);
- final String scopeName = tagProcessor.getOptionalProperty(SCOPE);
- final boolean isClear = tagProcessor.getOptionalProperty("action", "set").equals("clear");
- final Scope scope = Request.scope(scopeName, isClear ? Scope.SESSION : Scope.REQUEST);
- process(tagProcessor, name, value, defaultTo, isClear, scope);
- }
-
- protected void process(final TagProcessor tagProcessor, final String name, final String value, final String defaultTo, final boolean isClear, final Scope scope) {
- tagProcessor.pushNewBuffer();
- tagProcessor.processUtilCloseTag();
- String source = tagProcessor.popBuffer();
- if (isClear) {
- tagProcessor.appendDebug("variable: " + name + " (cleared)");
- tagProcessor.getContext().clearVariable(name, scope);
- } else {
- if (source.length() == 0 && value != null) {
- source = value;
- }
- if (source.length() == 0) {
- source = defaultTo;
- }
- tagProcessor.appendDebug(" " + name + " (" + scope + ") set to " + source);
- tagProcessor.getContext().addVariable(name, source, scope);
- }
- }
-
- @Override
- public String getName() {
- return "variable";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/When.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/When.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/When.java
deleted file mode 100644
index 459faaa..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/When.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.simple;
-
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-
-public class When extends AbstractConditionalBlock {
-
- @Override
- protected void processTags(final boolean isSet, final TagProcessor tagProcessor) {
- if (isSet) {
- tagProcessor.processUtilCloseTag();
- } else {
- tagProcessor.appendDebug(" skipping segment");
- tagProcessor.skipUntilClose();
- }
- }
-
- @Override
- public String getName() {
- return "when";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/structure/BlockDefine.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/structure/BlockDefine.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/structure/BlockDefine.java
new file mode 100644
index 0000000..e8d1d66
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/structure/BlockDefine.java
@@ -0,0 +1,43 @@
+/*
+ * 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.structure;
+
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor.RepeatMarker;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+public class BlockDefine extends AbstractElementProcessor {
+
+ @Override
+ public String getName() {
+ return "block";
+ }
+
+ @Override
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ final String name = templateProcessor.getOptionalProperty(NAME, "unamed");
+ final RepeatMarker start = templateProcessor.createMarker();
+ templateProcessor.skipUntilClose();
+ templateProcessor.getContext().addVariable("_block-" + name, start, Scope.REQUEST);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/structure/BlockUse.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/structure/BlockUse.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/structure/BlockUse.java
new file mode 100644
index 0000000..735e938
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/structure/BlockUse.java
@@ -0,0 +1,47 @@
+/*
+ * 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.structure;
+
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor.RepeatMarker;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+public class BlockUse extends AbstractElementProcessor {
+
+ @Override
+ public String getName() {
+ return "use-block";
+ }
+
+ @Override
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ final String name = templateProcessor.getOptionalProperty(NAME, "unamed");
+ templateProcessor.closeEmpty();
+ final RepeatMarker end = templateProcessor.createMarker();
+
+ final RepeatMarker marker = (RepeatMarker) templateProcessor.getContext().getVariable("_block-" + name);
+ marker.repeat();
+
+ templateProcessor.processUtilCloseTag();
+ end.repeat();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/structure/ContentTag.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/structure/ContentTag.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/structure/ContentTag.java
new file mode 100644
index 0000000..33c87b1
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/structure/ContentTag.java
@@ -0,0 +1,40 @@
+/*
+ * 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.structure;
+
+import org.apache.isis.viewer.scimpi.ScimpiContext;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.ElementProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+
+public class ContentTag implements ElementProcessor {
+
+ public void init(ScimpiContext context) {}
+
+ @Override
+ public String getName() {
+ return "content";
+ }
+
+ @Override
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ templateProcessor.appendHtml("<!-- apply content -->");
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/structure/Import.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/structure/Import.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/structure/Import.java
new file mode 100644
index 0000000..00acae0
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/structure/Import.java
@@ -0,0 +1,38 @@
+/*
+ * 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.structure;
+
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+public class Import extends AbstractElementProcessor {
+
+ @Override
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ templateProcessor.appendHtml("<!-- " + " import " + templateProcessor.getOptionalProperty("file") + " -->");
+ }
+
+ @Override
+ public String getName() {
+ return "import";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/structure/Mark.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/structure/Mark.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/structure/Mark.java
new file mode 100644
index 0000000..b388062
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/structure/Mark.java
@@ -0,0 +1,44 @@
+/*
+ * 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.structure;
+
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+public class Mark extends AbstractElementProcessor {
+
+ // TODO the return points should be pushed on to a stack so that there is
+ // traceable history.
+ @Override
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ // String name = request.getOptionalProperty(NAME);
+ final Request context = templateProcessor.getContext();
+ context.addVariable("_return-to", context.getUri(), Scope.SESSION);
+ }
+
+ @Override
+ public String getName() {
+ return "mark";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/structure/TemplateTag.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/structure/TemplateTag.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/structure/TemplateTag.java
new file mode 100644
index 0000000..5c8c0cd
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/structure/TemplateTag.java
@@ -0,0 +1,44 @@
+/*
+ * 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.structure;
+
+import org.apache.isis.viewer.scimpi.ScimpiContext;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.ElementProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+
+public class TemplateTag implements ElementProcessor {
+
+ public void init(ScimpiContext context) {}
+
+ @Override
+ public String getName() {
+ return "template";
+ }
+
+ @Override
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ // REVIEW this make IE8 render poorly as the browser doesn't think a
+ // DOCTYPE is provided, causing it to run in
+ // quirk mode
+ // request.appendHtml("<!-- zz apply template " +
+ // request.getOptionalProperty("file") + " -->");
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/ActionName.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/ActionName.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/ActionName.java
deleted file mode 100644
index 43264ad..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/ActionName.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.viewer.scimpi.dispatcher.view.value;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.util.MethodsUtils;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
-
-// TODO do the same for description and help, and for fields
-public class ActionName extends AbstractElementProcessor {
-
- @Override
- public void process(final TagProcessor tagProcessor) {
- final String objectId = tagProcessor.getOptionalProperty(OBJECT);
- final String methodName = tagProcessor.getRequiredProperty(METHOD);
-
- final ObjectAdapter object = MethodsUtils.findObject(tagProcessor.getContext(), objectId);
- final ObjectAction action = MethodsUtils.findAction(object, methodName);
-
- tagProcessor.appendAsHtmlEncoded(action.getName());
- }
-
- @Override
- public String getName() {
- return "action-name";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/CountElements.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/CountElements.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/CountElements.java
deleted file mode 100644
index d22fc44..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/CountElements.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.viewer.scimpi.dispatcher.view.value;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacet;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractObjectProcessor;
-
-public class CountElements extends AbstractObjectProcessor {
-
- @Override
- protected void process(final TagProcessor tagProcessor, final ObjectAdapter collection) {
- final CollectionFacet facet = collection.getSpecification().getFacet(CollectionFacet.class);
- final int size = facet.size(collection);
- if (size == 0) {
- tagProcessor.appendHtml(tagProcessor.getOptionalProperty("none", "0"));
- } else if (size == 1) {
- tagProcessor.appendHtml(tagProcessor.getOptionalProperty("one", "1"));
- } else {
- final String text = tagProcessor.getOptionalProperty("many", "" + size);
- tagProcessor.appendHtml(String.format(text, size));
- }
- }
-
- @Override
- protected String checkFieldType(final ObjectAssociation objectField) {
- return objectField.isOneToManyAssociation() ? null : "must be a collection";
- }
-
- @Override
- public String getName() {
- return "count";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/ElementType.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/ElementType.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/ElementType.java
deleted file mode 100644
index b15c107..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/ElementType.java
+++ /dev/null
@@ -1,61 +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.value;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
-import org.apache.isis.viewer.scimpi.ScimpiException;
-import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
-
-public class ElementType extends AbstractElementProcessor {
-
- @Override
- public void process(final TagProcessor tagProcessor) {
- ObjectAdapter collection;
- final String field = tagProcessor.getOptionalProperty(FIELD);
- final Request context = tagProcessor.getContext();
- if (field != null) {
- final String id = tagProcessor.getRequiredProperty(OBJECT);
- final ObjectAdapter object = context.getMappedObjectOrResult(id);
- final ObjectAssociation objectField = object.getSpecification().getAssociation(field);
- if (!objectField.isOneToManyAssociation()) {
- throw new ScimpiException("Field " + objectField.getId() + " is not a collection");
- }
- collection = objectField.get(object);
- } else {
- final String id = tagProcessor.getOptionalProperty(COLLECTION);
- collection = context.getMappedObjectOrResult(id);
- }
-
- final ObjectSpecification elementSpecification = collection.getElementSpecification();
- final String name = elementSpecification.getSingularName();
-
- tagProcessor.appendAsHtmlEncoded(name);
- }
-
- @Override
- public String getName() {
- return "element-type";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/FieldName.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/FieldName.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/FieldName.java
deleted file mode 100644
index 1fefdf3..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/FieldName.java
+++ /dev/null
@@ -1,65 +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.value;
-
-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.ForbiddenException;
-import org.apache.isis.viewer.scimpi.ScimpiException;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
-
-public class FieldName extends AbstractElementProcessor {
-
- // 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
- public void process(final TagProcessor tagProcessor) {
- final String id = tagProcessor.getOptionalProperty(OBJECT);
- final String fieldName = tagProcessor.getRequiredProperty(FIELD);
- final ObjectAdapter object = tagProcessor.getContext().getMappedObjectOrResult(id);
- final ObjectAssociation field = object.getSpecification().getAssociation(fieldName);
- if (field == null) {
- throw new ScimpiException("No field " + fieldName + " in " + object.getSpecification().getFullIdentifier());
- }
- if (field.isVisible(IsisContext.getAuthenticationSession(), object, where).isVetoed()) {
- throw new ForbiddenException(field, ForbiddenException.VISIBLE);
- }
- tagProcessor.appendAsHtmlEncoded(field.getName());
- }
-
- @Override
- public String getName() {
- return "field-name";
- }
-
- public static void write(final TagProcessor content, final ObjectAssociation field) {
- content.appendHtml("<span class=\"label\" title=\"" + field.getDescription() + "\">");
- content.appendHtml("</span>");
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/ParameterName.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/ParameterName.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/ParameterName.java
deleted file mode 100644
index 029b819..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/ParameterName.java
+++ /dev/null
@@ -1,62 +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.value;
-
-import java.util.List;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
-import org.apache.isis.core.metamodel.spec.feature.ObjectActionParameter;
-import org.apache.isis.viewer.scimpi.ScimpiException;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.util.MethodsUtils;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
-
-public class ParameterName extends AbstractElementProcessor {
-
- @Override
- public void process(final TagProcessor tagProcessor) {
- final String objectId = tagProcessor.getOptionalProperty(OBJECT);
- final String methodName = tagProcessor.getRequiredProperty(METHOD);
- final String field = tagProcessor.getOptionalProperty(PARAMETER_NUMBER);
-
- final ObjectAdapter object = MethodsUtils.findObject(tagProcessor.getContext(), objectId);
- final ObjectAction action = MethodsUtils.findAction(object, methodName);
- final List<ObjectActionParameter> parameters = action.getParameters();
-
- int index;
- if (field == null) {
- index = 0;
- } else {
- index = Integer.valueOf(field).intValue() - 1;
- }
- if (index < 0 || index >= parameters.size()) {
- throw new ScimpiException("Parameter numbers should be between 1 and " + parameters.size() + ": " + index);
- }
-
- tagProcessor.appendAsHtmlEncoded(parameters.get(index).getName());
- }
-
- @Override
- public String getName() {
- return "parameter-name";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/TitleString.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/TitleString.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/TitleString.java
deleted file mode 100644
index 7afe506..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/TitleString.java
+++ /dev/null
@@ -1,68 +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.value;
-
-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.ForbiddenException;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
-
-/**
- *
- */
-public class TitleString extends AbstractElementProcessor {
-
- @Override
- public void process(final TagProcessor tagProcessor) {
- final String id = tagProcessor.getOptionalProperty(OBJECT);
- final String fieldName = tagProcessor.getOptionalProperty(FIELD);
- final int truncateTo = Integer.valueOf(tagProcessor.getOptionalProperty(TRUNCATE, "0")).intValue();
- final ObjectAdapter object = tagProcessor.getContext().getMappedObjectOrResult(id);
- if (object == null) {
- return;
- }
- String titleString;
- if (fieldName == null) {
- titleString = object.titleString();
- } else {
- final ObjectAssociation field = object.getSpecification().getAssociation(fieldName);
- if (field.isVisible(IsisContext.getAuthenticationSession(), object, Where.ANYWHERE).isVetoed()) {
- throw new ForbiddenException(field, ForbiddenException.VISIBLE);
- }
- final ObjectAdapter fieldReference = field.get(object);
- if (fieldReference != null) {
- titleString = fieldReference.titleString();
- } else {
- titleString = "";
- }
- }
- tagProcessor.appendDebug(" " + titleString);
- tagProcessor.appendTruncated(titleString, truncateTo);
- }
-
- @Override
- public String getName() {
- return "title-string";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/Type.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/Type.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/Type.java
deleted file mode 100644
index 2cb2834..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/Type.java
+++ /dev/null
@@ -1,57 +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.value;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
-import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
-
-public class Type extends AbstractElementProcessor {
-
- @Override
- public void process(final TagProcessor tagProcessor) {
- final Request context = tagProcessor.getContext();
- final String showPlural = tagProcessor.getOptionalProperty(PLURAL);
- final String id = tagProcessor.getOptionalProperty(OBJECT);
- final String objectId = id != null ? id : (String) context.getVariable(RESULT);
-
- ObjectAdapter object = context.getMappedObjectOrResult(objectId);
- final String field = tagProcessor.getOptionalProperty(FIELD);
- if (field != null) {
- final ObjectAssociation objectField = object.getSpecification().getAssociation(field);
- object = objectField.get(object);
- }
- tagProcessor.appendDebug(" for " + object);
-
- final ObjectSpecification specification = object.getSpecification();
- final String name = showPlural != null ? specification.getPluralName() : specification.getSingularName();
-
- tagProcessor.appendAsHtmlEncoded(name);
- }
-
- @Override
- public String getName() {
- return "type";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/variable/ChangeScope.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/variable/ChangeScope.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/variable/ChangeScope.java
new file mode 100644
index 0000000..9c187ee
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/variable/ChangeScope.java
@@ -0,0 +1,52 @@
+/*
+ * 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.variable;
+
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+public class ChangeScope extends AbstractElementProcessor {
+
+ @Override
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ final String name = templateProcessor.getRequiredProperty(NAME);
+ final String scopeName = templateProcessor.getRequiredProperty(SCOPE);
+ final Scope scope = Request.scope(scopeName);
+ templateProcessor.processUtilCloseTag();
+ changeScope(templateProcessor, name, scope);
+ }
+
+ protected static void changeScope(final TemplateProcessor templateProcessor, final String name, final Scope scope) {
+ templateProcessor.getContext().changeScope(name, scope);
+ final Object value = templateProcessor.getContext().getVariable(name);
+ if (value != null) {
+ templateProcessor.getContext().addVariable(name, value, scope);
+ }
+ }
+
+ @Override
+ public String getName() {
+ return "scope";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/variable/CookieValue.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/variable/CookieValue.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/variable/CookieValue.java
new file mode 100644
index 0000000..9264460
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/variable/CookieValue.java
@@ -0,0 +1,47 @@
+/*
+ * 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.variable;
+
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+public class CookieValue extends AbstractElementProcessor {
+
+ @Override
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ String name = templateProcessor.getRequiredProperty(NAME);
+ String resultName = templateProcessor.getOptionalProperty(RESULT_NAME, name);
+ final String scopeName = templateProcessor.getOptionalProperty(SCOPE);
+ final Scope scope = Request.scope(scopeName, Scope.REQUEST);
+
+ String cookieString = templateProcessor.getContext().getCookie(name);
+
+ templateProcessor.appendDebug(" " + resultName + " (" + scope + ") set to " + cookieString + " from cookie " + name);
+ templateProcessor.getContext().addVariable(resultName, cookieString, scope);
+ }
+
+ @Override
+ public String getName() {
+ return "cookie-value";
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/variable/DefaultValue.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/variable/DefaultValue.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/variable/DefaultValue.java
new file mode 100644
index 0000000..fb1606f
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/variable/DefaultValue.java
@@ -0,0 +1,53 @@
+/*
+ * 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.variable;
+
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+public class DefaultValue extends AbstractElementProcessor {
+
+ @Override
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ // String sourceObjectId = objectOrResult(request);
+ final String variableName = templateProcessor.getRequiredProperty(NAME);
+ final String defaultValue = templateProcessor.getOptionalProperty(VALUE);
+ final String scopeName = templateProcessor.getOptionalProperty(SCOPE);
+ final Scope scope = Request.scope(scopeName, Scope.REQUEST);
+
+ final Request context = templateProcessor.getContext();
+ final Object currentValue = context.getVariable(variableName);
+ if (currentValue == null) {
+ templateProcessor.appendDebug(" " + variableName + " set to " + defaultValue + " (" + scope + ")");
+ context.addVariable(variableName, defaultValue, scope);
+ } else {
+ templateProcessor.appendDebug(" " + variableName + " already set to " + currentValue);
+ }
+ }
+
+ @Override
+ public String getName() {
+ return "default";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/variable/GetCookie.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/variable/GetCookie.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/variable/GetCookie.java
new file mode 100644
index 0000000..05ad76f
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/variable/GetCookie.java
@@ -0,0 +1,40 @@
+/*
+ * 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.variable;
+
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+public class GetCookie extends AbstractElementProcessor {
+
+ @Override
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ final String name = templateProcessor.getRequiredProperty("name");
+ final String cookie = templateProcessor.getContext().getCookie(name);
+
+ templateProcessor.appendHtml(cookie);
+ }
+
+ @Override
+ public String getName() {
+ return "get-cookie";
+ }
+}
[18/24] Restructuring Scimpi to remove dependencies and enable easier
testing.
Posted by rm...@apache.org.
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/LongFormView.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/LongFormView.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/LongFormView.java
deleted file mode 100644
index a157858..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/LongFormView.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.viewer.scimpi.dispatcher.view.display;
-
-import java.util.List;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAssociationFilters;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.view.display.TableView.SimpleTableBuilder;
-import org.apache.isis.viewer.scimpi.dispatcher.view.field.LinkedObject;
-
-public class LongFormView extends AbstractFormView {
-
- @Override
- protected void addField(final TagProcessor tagProcessor, final ObjectAdapter object, final ObjectAssociation field, final LinkedObject linkedObject, final boolean showIcons) {
- if (field.isOneToManyAssociation()) {
- final String noColumnsString = tagProcessor.getOptionalProperty("no-columns", "3");
- final String tableClass = tagProcessor.getOptionalProperty("table-class");
- final String rowClassesList = tagProcessor.getOptionalProperty("row-classes", ODD_ROW_CLASS + "|" + EVEN_ROW_CLASS);
- String[] rowClasses = new String[0];
- if (rowClassesList != null) {
- rowClasses = rowClassesList.split("[,|/]");
- }
- int noColumns;
- IsisContext.getPersistenceSession().resolveField(object, field);
- final ObjectAdapter collection = field.get(object);
- final ObjectSpecification elementSpec = collection.getElementSpecification();
- final List<ObjectAssociation> fields = elementSpec.getAssociations(ObjectAssociationFilters.WHEN_VISIBLE_IRRESPECTIVE_OF_WHERE);
- if (noColumnsString.equalsIgnoreCase("all")) {
- noColumns = fields.size();
- } else {
- noColumns = Math.min(fields.size(), Integer.valueOf(noColumnsString));
- }
- // final boolean isFieldEditable = field.isUsable(IsisContext.getAuthenticationSession(), object).isAllowed();
- final String summary = "Table of elements in " + field.getName();
- // TableView.write(request, summary, object, field, collection, noColumns, fields, isFieldEditable, showIconByDefault(), tableClass, rowClasses, linkedObject);
-
-
- final String headers[] = new String[fields.size()];
- int h = 0;
- for (int i = 0; i < noColumns; i++) {
- if (fields.get(i).isOneToManyAssociation()) {
- continue;
- }
- headers[h++] = fields.get(i).getName();
- }
-
- final LinkedObject[] linkedFields = new LinkedObject[fields.size()];
-
-
- final TableContentWriter rowBuilder =new SimpleTableBuilder(object.titleString(), true, false, "", noColumns, headers, fields, false,
- showIcons, false, false, false, field.getName(), linkedFields, null);
- TableView.write(tagProcessor, collection, summary, rowBuilder, null, tableClass, rowClasses);
- } else {
- super.addField(tagProcessor, object, field, linkedObject, showIcons);
- }
- }
-
- @Override
- public String getName() {
- return "long-form";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/Messages.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/Messages.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/Messages.java
deleted file mode 100644
index 21fae12..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/Messages.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.viewer.scimpi.dispatcher.view.display;
-
-import java.util.List;
-
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.core.runtime.system.transaction.MessageBroker;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
-
-public class Messages extends AbstractElementProcessor {
-
- @Override
- public void process(final TagProcessor tagProcessor) {
- final String cls = tagProcessor.getOptionalProperty(CLASS);
- final StringBuffer buffer = new StringBuffer();
- write(cls, buffer);
- if (buffer.length() > 0) {
- tagProcessor.appendHtml("<div class=\"feedback\">");
- tagProcessor.appendHtml(buffer.toString());
- tagProcessor.appendHtml("</div>");
- }
-
- }
-
- public static void write(String cls, final StringBuffer buffer) {
- if (cls == null) {
- cls = "message";
- }
- final MessageBroker messageBroker = IsisContext.getMessageBroker();
- final List<String> messages = messageBroker.getMessages();
- for (final String message : messages) {
- buffer.append("<div class=\"" + cls + "\">" + message + "</div>");
- }
- }
-
- @Override
- public String getName() {
- return "messages";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/SelectedObject.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/SelectedObject.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/SelectedObject.java
deleted file mode 100644
index bba9d03..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/SelectedObject.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.viewer.scimpi.dispatcher.view.display;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
-
-/**
- * <swf:selected name="selected" object="${action}" equals="${subaction}" />
- */
-public class SelectedObject extends AbstractElementProcessor {
-
- @Override
- public void process(final TagProcessor tagProcessor) {
- final String name = tagProcessor.getOptionalProperty(NAME, "selected");
- final String objectId = tagProcessor.getRequiredProperty(OBJECT);
- final String equalsId = tagProcessor.getOptionalProperty("equals");
- final String title = tagProcessor.getOptionalProperty(BUTTON_TITLE);
-
- final ObjectAdapter object = tagProcessor.getContext().getMappedObjectOrResult(objectId);
- final ObjectAdapter other = tagProcessor.getContext().getMappedObjectOrResult(equalsId);
- if (object == other || object.equals(title)) {
- // TODO title is not being used!
- tagProcessor.getContext().addVariable(ID, " id=\"" + name + "\" ", Scope.INTERACTION);
- } else {
- tagProcessor.getContext().addVariable(ID, "", Scope.INTERACTION);
- }
- tagProcessor.closeEmpty();
- }
-
- @Override
- public String getName() {
- return "selected";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/ShortFormView.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/ShortFormView.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/ShortFormView.java
deleted file mode 100644
index 31e903b..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/ShortFormView.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.display;
-
-import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
-
-public class ShortFormView extends AbstractFormView {
-
- @Override
- protected boolean ignoreField(final ObjectAssociation field) {
- return field.isOneToManyAssociation();
- }
-
- @Override
- public String getName() {
- return "short-form";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableBlock.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableBlock.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableBlock.java
deleted file mode 100644
index 6fa85b9..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableBlock.java
+++ /dev/null
@@ -1,86 +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.display;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.BlockContent;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor.RepeatMarker;
-
-public class TableBlock implements BlockContent {
-
- // {{ collection
- private ObjectAdapter collection;
-
- public void setCollection(final ObjectAdapter collection) {
- this.collection = collection;
- }
-
- public ObjectAdapter getCollection() {
- return collection;
- }
- // }}
-
- // {{ linkView
- private String linkView;
-
- public String getlinkView() {
- return linkView;
- }
-
- public void setlinkView(final String linkView) {
- this.linkView = linkView;
- }
- // }}
-
- // {{ linkName
- private String linkName;
-
- public String getlinkName() {
- return linkName;
- }
-
- public void setlinkName(final String linkName) {
- this.linkName = linkName;
- }
- // }}
-
- // {{ elementName
- private String elementName;
-
- public String getElementName() {
- return elementName;
- }
-
- public void setElementName(final String linkObject) {
- this.elementName = linkObject;
- }
- // }}
-
- private RepeatMarker marker;
-
- public RepeatMarker getMarker() {
- return marker;
- }
-
- public void setMarker(final RepeatMarker marker) {
- this.marker = marker;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableBuilder.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableBuilder.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableBuilder.java
deleted file mode 100644
index b1d526b..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableBuilder.java
+++ /dev/null
@@ -1,92 +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.display;
-
-import java.util.List;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
-import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
-import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.PageWriter;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor.RepeatMarker;
-
-public class TableBuilder extends AbstractTableView {
-
- @Override
- protected TableContentWriter createRowBuilder(final TagProcessor tagProcessor, final Request context, final String parent, final List<ObjectAssociation> allFields, final ObjectAdapter collection) {
-
- final String title = tagProcessor.getOptionalProperty(TABLE_TITLE);
- final String variable = tagProcessor.getOptionalProperty(ELEMENT_NAME, ELEMENT);
- final String headerClass = tagProcessor.getOptionalProperty("head-" + CLASS);
-
- final TableBlock block = new TableBlock();
- block.setCollection(collection);
- block.setElementName(variable);
- tagProcessor.setBlockContent(block);
- tagProcessor.pushNewBuffer();
- tagProcessor.processUtilCloseTag();
- final String headers = tagProcessor.popBuffer();
- return new TableContentWriter() {
-
- @Override
- public void writeFooters(final PageWriter writer) {
- }
-
- public void tidyUp() {
- tagProcessor.popBlockContent();
- }
-
- @Override
- public void writeCaption(PageWriter writer) {
- if (title != null) {
- writer.appendHtml("<caption>");
- writer.appendHtml(title);
- writer.appendHtml("</thead>");
- }
- }
-
- @Override
- public void writeHeaders(final PageWriter writer) {
- final String headerSegment = headerClass == null ? "" : (" class=\"" + headerClass + "\"");
- writer.appendHtml("<thead" + headerSegment + ">");
- writer.appendHtml(headers);
- writer.appendHtml("</thead>");
- }
-
- @Override
- public void writeElement(final TagProcessor tagProcessor, final Request context, final ObjectAdapter element) {
- context.addVariable(variable, context.mapObject(element, Scope.REQUEST), Scope.REQUEST);
- final RepeatMarker end = tagProcessor.createMarker();
- final RepeatMarker marker = block.getMarker();
- marker.repeat();
- tagProcessor.processUtilCloseTag();
- end.repeat();
- }
- };
- }
-
- @Override
- public String getName() {
- return "table-builder";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableCell.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableCell.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableCell.java
deleted file mode 100644
index 80f1753..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableCell.java
+++ /dev/null
@@ -1,95 +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.display;
-
-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.Names;
-import org.apache.isis.viewer.scimpi.ScimpiException;
-import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
-import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
-
-public class TableCell extends AbstractElementProcessor {
-
- // REVIEW: should provide this rendering context, rather than hardcoding.
- // the net effect currently is that class members annotated with
- // @Hidden(where=Where.ALL_TABLES) or @Disabled(where=Where.ALL_TABLES) will indeed
- // be hidden from all tables but will be visible/enabled (perhaps incorrectly)
- // if annotated with Where.PARENTED_TABLE or Where.STANDALONE_TABLE
- private final Where where = Where.ALL_TABLES;
-
- @Override
- public void process(final TagProcessor tagProcessor) {
- final TableBlock tableBlock = (TableBlock) tagProcessor.getBlockContent();
- final String id = tagProcessor.getOptionalProperty(OBJECT);
- final String fieldName = tagProcessor.getRequiredProperty(FIELD);
- final String linkView = tagProcessor.getOptionalProperty(LINK_VIEW);
- String className = tagProcessor.getOptionalProperty(CLASS);
- className = className == null ? "" : " class=\"" + className + "\"";
- Request context = tagProcessor.getContext();
- final ObjectAdapter object = context.getMappedObjectOrVariable(id, tableBlock.getElementName());
- final ObjectAssociation field = object.getSpecification().getAssociation(fieldName);
- if (field == null) {
- throw new ScimpiException("No field " + fieldName + " in " + object.getSpecification().getFullIdentifier());
- }
- tagProcessor.appendHtml("<td" + className + ">");
- if (field.isVisible(IsisContext.getAuthenticationSession(), object, where).isAllowed()) {
- final ObjectAdapter fieldReference = field.get(object);
- final String source = fieldReference == null ? "" : context.mapObject(fieldReference, Scope.REQUEST);
- final String name = tagProcessor.getOptionalProperty(RESULT_NAME, fieldName);
- context.addVariable(name, TagProcessor.getEncoder().encoder(source), Scope.REQUEST);
-
- if (linkView != null) {
- final String linkId = context.mapObject(object, Scope.REQUEST);
- final String linkName = tagProcessor.getOptionalProperty(LINK_NAME, Names.RESULT);
- final String linkObject = tagProcessor.getOptionalProperty(LINK_OBJECT, linkId);
- tagProcessor.appendHtml("<a href=\"" + linkView + "?" + linkName + "=" + linkObject + context.encodedInteractionParameters() + "\">");
- } else if(tableBlock.getlinkView() != null) {
- String linkObjectInVariable = tableBlock.getElementName();
- final String linkId = (String) context.getVariable(linkObjectInVariable);
- tagProcessor.appendHtml("<a href=\"" + tableBlock.getlinkView() + "?" + tableBlock.getlinkName() + "=" + linkId + context.encodedInteractionParameters() + "\">");
- }
- tagProcessor.pushNewBuffer();
- tagProcessor.processUtilCloseTag();
- final String buffer = tagProcessor.popBuffer();
- if (buffer.trim().length() == 0) {
- tagProcessor.appendAsHtmlEncoded(fieldReference == null ? "" : fieldReference.titleString());
- } else {
- tagProcessor.appendHtml(buffer);
- }
- if (linkView != null) {
- tagProcessor.appendHtml("</a>");
- }
- } else {
- tagProcessor.skipUntilClose();
- }
- tagProcessor.appendHtml("</td>");
- }
-
- @Override
- public String getName() {
- return "table-cell";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableContentWriter.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableContentWriter.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableContentWriter.java
deleted file mode 100644
index 92a9929..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableContentWriter.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.display;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.PageWriter;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-
-public interface TableContentWriter {
-
- void writeCaption(PageWriter writer);
-
- void writeHeaders(PageWriter writer);
-
- void writeFooters(PageWriter writer);
-
- void writeElement(TagProcessor tagProcessor, Request context, ObjectAdapter element);
-
- void tidyUp();
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableEmpty.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableEmpty.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableEmpty.java
deleted file mode 100644
index 145733f..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableEmpty.java
+++ /dev/null
@@ -1,53 +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.display;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacet;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
-
-public class TableEmpty extends AbstractElementProcessor {
-
- @Override
- public void process(final TagProcessor tagProcessor) {
- final TableBlock tableBlock = (TableBlock) tagProcessor.getBlockContent();
- final ObjectAdapter collection = tableBlock.getCollection();
- final CollectionFacet facet = collection.getSpecification().getFacet(CollectionFacet.class);
- if (facet.size(collection) == 0) {
- String className = tagProcessor.getOptionalProperty(CLASS);
- className = className == null ? "" : " class=\"" + className + "\"";
- tagProcessor.appendHtml("<tr" + className + ">");
- tagProcessor.pushNewBuffer();
- tagProcessor.processUtilCloseTag();
- final String buffer = tagProcessor.popBuffer();
- tagProcessor.appendHtml(buffer);
- tagProcessor.appendHtml("</td>");
- } else {
- tagProcessor.skipUntilClose();
- }
- }
-
- @Override
- public String getName() {
- return "table-empty";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableHeader.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableHeader.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableHeader.java
deleted file mode 100644
index 22a8e7f..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableHeader.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.display;
-
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
-
-public class TableHeader extends AbstractElementProcessor {
-
- @Override
- public String getName() {
- return "table-header";
- }
-
- @Override
- public void process(final TagProcessor tagProcessor) {
- tagProcessor.appendHtml("<thead><tr>");
- tagProcessor.processUtilCloseTag();
- tagProcessor.appendHtml("</tr></thead>");
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableRow.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableRow.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableRow.java
deleted file mode 100644
index e8ba18a..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableRow.java
+++ /dev/null
@@ -1,49 +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.display;
-
-import org.apache.isis.viewer.scimpi.Names;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor.RepeatMarker;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
-
-public class TableRow extends AbstractElementProcessor {
-
- @Override
- public String getName() {
- return "table-row";
- }
-
- @Override
- public void process(final TagProcessor tagProcessor) {
- final TableBlock block = (TableBlock) tagProcessor.getBlockContent();
-
- final RepeatMarker start = tagProcessor.createMarker();
- block.setMarker(start);
-
- final String linkView = tagProcessor.getOptionalProperty(LINK_VIEW);
- if (linkView != null) {
- block.setlinkView(linkView);
- block.setlinkName(tagProcessor.getOptionalProperty(LINK_NAME, Names.RESULT));
- }
-
- tagProcessor.skipUntilClose();
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableView.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableView.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableView.java
deleted file mode 100644
index aa19f74..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableView.java
+++ /dev/null
@@ -1,329 +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.display;
-
-import java.util.List;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.facets.object.parseable.ParseableFacet;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
-import org.apache.isis.core.runtime.persistence.ObjectNotFoundException;
-import org.apache.isis.viewer.scimpi.Names;
-import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
-import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.PageWriter;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.view.field.LinkedFieldsBlock;
-import org.apache.isis.viewer.scimpi.dispatcher.view.field.LinkedObject;
-import org.apache.isis.viewer.scimpi.dispatcher.view.simple.RemoveElement;
-
-public class TableView extends AbstractTableView {
-
- static final class SimpleTableBuilder implements TableContentWriter {
- private final String parent;
- private final boolean includeHeader;
- private final boolean includeFooter;
- private final String title;
- private final String[] headers;
- private final List<ObjectAssociation> fields;
- private final boolean showTitle;
- private final boolean showIcons;
- private final boolean showSelectOption;
- private final boolean showDeleteOption;
- private final boolean showEditOption;
- private final String fieldName;
- private final LinkedObject[] linkedFields;
- private final LinkedObject linkRow;
- private final int noColumns;
-
- SimpleTableBuilder(
- final String parent,
- final boolean includeHeader,
- final boolean includeFooter,
- final String title,
- final int noColumns,
- final String[] headers,
- final List<ObjectAssociation> fields,
- final boolean showTitle,
- final boolean showIcons,
- final boolean showSelectOption,
- final boolean showDeleteOption,
- final boolean showEditOption,
- final String fieldName,
- final LinkedObject[] linkedFields,
- final LinkedObject linkRow) {
- this.parent = parent;
- this.includeHeader = includeHeader;
- this.includeFooter = includeFooter;
- this.title = title;
- this.showTitle = showTitle;
- this.noColumns = noColumns < 1 ? fields.size() : noColumns;
- this.headers = headers;
- this.fields = fields;
- this.showIcons = showIcons;
- this.showSelectOption = showSelectOption;
- this.showDeleteOption = showDeleteOption;
- this.showEditOption = showEditOption;
- this.fieldName = fieldName;
- this.linkedFields = linkedFields;
- this.linkRow = linkRow;
- }
-
- @Override
- public void writeFooters(final PageWriter writer) {
- if (includeFooter) {
- writer.appendHtml("<tfoot>");
- columnHeaders(writer, headers);
- writer.appendHtml("</tfoot>");
- }
- }
-
- @Override
- public void writeCaption(PageWriter writer) {
- if (title != null) {
- writer.appendHtml("<caption>");
- writer.appendHtml(title);
- writer.appendHtml("</caption>");
- }
- }
-
- @Override
- public void writeHeaders(final PageWriter writer) {
- if (includeHeader) {
- writer.appendHtml("<thead>");
- columnHeaders(writer, headers);
- writer.appendHtml("</thead>");
- }
- }
-
- private void columnHeaders(final PageWriter writer, final String[] headers) {
- writer.appendHtml("<tr class=\"column-headers\">");
- if (showTitle) {
- writer.appendHtml("<th></th>");
- }
- final String[] columnHeaders = headers;
- for (final String columnHeader : columnHeaders) {
- if (columnHeader != null) {
- writer.appendHtml("<th>");
- writer.appendAsHtmlEncoded(columnHeader);
- writer.appendHtml("</th>");
- }
- }
- writer.appendHtml("<th class=\"controls\"></th>");
- writer.appendHtml("</tr>");
- }
-
- public void tidyUp() {
- // request.popBlockContent();
-
- // Is it the block that is left over, or is the collection form not being closed?
- }
-
- @Override
- public void writeElement(final TagProcessor tagProcessor, final Request context, final ObjectAdapter element) {
- final String rowId = context.mapObject(element, Scope.INTERACTION);
- final String scope = linkRow == null ? "" : "&" + SCOPE + "=" + linkRow.getScope();
- String result = "";
- result = context.encodedInteractionParameters();
-
- if (noColumns == 0) {
- tagProcessor.appendHtml("<td>");
- if (linkRow != null) {
- tagProcessor.appendHtml("<td><a href=\"" + linkRow.getForwardView() + "?" + linkRow.getVariable() + "=" + rowId + result + scope + "\">");
- tagProcessor.appendAsHtmlEncoded(element.titleString());
- tagProcessor.appendHtml("</a>");
- } else {
- tagProcessor.appendAsHtmlEncoded(element.titleString());
- }
- tagProcessor.appendHtml("</td>");
-
- } else {
- if (showTitle) {
- tagProcessor.appendHtml("<td>");
- tagProcessor.appendAsHtmlEncoded(element.titleString());
- tagProcessor.appendHtml("</td>");
- }
-
- for (int i = 0; i < noColumns; i++) {
- if (fields.get(i).isOneToManyAssociation()) {
- continue;
- }
- tagProcessor.appendHtml("<td>");
- final ObjectAdapter field = fields.get(i).get(element);
- if (field != null) {
- if (showIcons && !fields.get(i).getSpecification().containsFacet(ParseableFacet.class)) {
- tagProcessor.appendHtml("<img class=\"" + "small-icon" + "\" src=\"" + tagProcessor.getContext().imagePath(field) + "\" alt=\"" + fields.get(i).getSpecification().getShortIdentifier() + "\"/>");
- }
- if (linkRow != null) {
- tagProcessor.appendHtml("<a href=\"" + linkRow.getForwardView() + "?" + linkRow.getVariable() + "=" + rowId + result + scope + "\">");
- } else if (linkedFields[i] != null) {
- final ObjectAdapter fieldObject = fields.get(i).get(element);
- final String id = context.mapObject(fieldObject, Scope.INTERACTION);
- tagProcessor.appendHtml("<a href=\"" + linkedFields[i].getForwardView() + "?" + linkedFields[i].getVariable() + "=" + id + "\">");
- context.mapObject(fieldObject, Request.scope(linkedFields[i].getScope()));
-
- }
- try {
- tagProcessor.appendAsHtmlEncoded(field.titleString());
- } catch (final ObjectNotFoundException e) {
- tagProcessor.appendAsHtmlEncoded(e.getMessage());
- }
- if (linkRow != null || linkedFields[i] != null) {
- tagProcessor.appendHtml("</a>");
- }
- }
- tagProcessor.appendHtml("</td>");
-
- }
- }
- tagProcessor.appendHtml("<td class=\"controls\">");
- if (showSelectOption) {
- tagProcessor.appendHtml("<a class=\"button element-select\" href=\"" + "_generic." + Names.EXTENSION + "?" + Names.RESULT + "=" + rowId + result + scope + "\">view</a>");
- }
- if (showEditOption) {
- tagProcessor.appendHtml(" <a class=\"button element-edit\" href=\"" + "_generic_edit." + Names.EXTENSION + "?" + Names.RESULT + "=" + rowId + result + scope + "\">edit</a>");
- }
-
- if (showDeleteOption && parent != null) {
- String view = tagProcessor.getViewPath();
- view = context.fullFilePath(view == null ? context.getResourceFile() : view);
- RemoveElement.write(tagProcessor, context.getMappedObject(parent), fieldName, element, null, view, view, "delete", "action in-line element-delete confirm");
- }
-
- tagProcessor.appendHtml("</td>");
-
- }
- }
-
- @Override
- protected TableContentWriter createRowBuilder(
- final TagProcessor tagProcessor,
- final Request context,
- final String parent,
- final List<ObjectAssociation> allFields,
- final ObjectAdapter collection) {
- final String fieldName = tagProcessor.getOptionalProperty(FIELD);
- final String title = tagProcessor.getOptionalProperty(FORM_TITLE);
- return rowBuilder(tagProcessor, context, title, parent, fieldName, allFields, showIconByDefault());
- }
-
- private static TableContentWriter rowBuilder(
- final TagProcessor tagProcessor,
- final Request context,
- final String title,
- final String object,
- final String fieldName,
- final List<ObjectAssociation> allFields,
- final boolean showIconByDefault) {
- final String linkRowView = tagProcessor.getOptionalProperty(LINK_VIEW);
- final String linkObjectName = tagProcessor.getOptionalProperty(ELEMENT_NAME, Names.RESULT);
- final String linkObjectScope = tagProcessor.getOptionalProperty(SCOPE, Scope.INTERACTION.toString());
- final LinkedObject linkRow = linkRowView == null ? null : new LinkedObject(linkObjectName, linkObjectScope, context.fullUriPath(linkRowView));
- final boolean includeHeader = tagProcessor.isRequested(HEADER, true);
- final boolean includeFooter = tagProcessor.isRequested(FOOTER, false);
-
- final boolean linkFields = tagProcessor.isRequested("link-fields", true);
- final boolean showTitle = tagProcessor.isRequested(SHOW_TITLE, false);
- final boolean showIcons = tagProcessor.isRequested(SHOW_ICON, showIconByDefault);
- final boolean showSelectOption = tagProcessor.isRequested(SHOW_SELECT, true);
- final boolean showEditOption = tagProcessor.isRequested(SHOW_EDIT, true);
- final boolean showDeleteOption = tagProcessor.isRequested(SHOW_DELETE, true);
-
- final String noColumnsString = tagProcessor.getOptionalProperty("no-columns", "3");
-
- final LinkedFieldsBlock block = new LinkedFieldsBlock();
- tagProcessor.setBlockContent(block);
- tagProcessor.processUtilCloseTag();
- final List<ObjectAssociation> fields = block.includedFields(allFields);
- final LinkedObject[] linkedFields = block.linkedFields(fields);
- for (int i = 0; i < linkedFields.length; i++) {
- if (linkedFields[i] == null && linkFields && !fields.get(i).getSpecification().containsFacet(ParseableFacet.class)) {
- linkedFields[i] = new LinkedObject("_generic.shtml");
- }
- if (linkedFields[i] != null) {
- linkedFields[i].setForwardView(context.fullUriPath(linkedFields[i].getForwardView()));
- }
- }
-
- int noColumns;
- if (noColumnsString.equalsIgnoreCase("all")) {
- noColumns = fields.size();
- } else {
- noColumns = Math.min(fields.size(), Integer.valueOf(noColumnsString));
- }
-
- final String headers[] = new String[noColumns];
- int h = 0;
- for (int i = 0; i < noColumns; i++) {
- if (fields.get(i).isOneToManyAssociation()) {
- continue;
- }
- headers[h++] = fields.get(i).getName();
- }
-
- tagProcessor.popBlockContent();
-
- return new SimpleTableBuilder(object, includeHeader, includeFooter, title, noColumns, headers, fields, showTitle,
- showIcons, showSelectOption, showDeleteOption, showEditOption, fieldName, linkedFields, linkRow);
- }
-
- public static void write(
- final TagProcessor tagProcessor,
- final String summary,
- final ObjectAdapter object,
- final ObjectAssociation field,
- final ObjectAdapter collection,
- final int noColumns,
- final List<ObjectAssociation> fields,
- final boolean linkAllFields,
- final boolean showIconByDefault,
- final String tableClass,
- final String[] rowClasses,
- LinkedObject linkedObject) {
- final LinkedObject[] linkedFields = new LinkedObject[fields.size()];
- if (linkAllFields) {
- for (int i = 0; i < linkedFields.length; i++) {
- if (fields.get(i).isOneToOneAssociation()) {
- linkedFields[i] = linkedObject == null ? new LinkedObject("_generic.shtml") : linkedObject;
- }
- }
- }
-
- final String headers[] = new String[fields.size()];
- int h = 0;
- for (int i = 0; i < fields.size(); i++) {
- if (fields.get(i).isOneToManyAssociation()) {
- continue;
- }
- headers[h++] = fields.get(i).getName();
- }
-
- final Request context = tagProcessor.getContext();
- final TableContentWriter rowBuilder = rowBuilder(tagProcessor, context, null, context.mapObject(object, Scope.REQUEST), field.getIdentifier().getMemberName(), fields,
- showIconByDefault);
- write(tagProcessor, collection, summary, rowBuilder, null, null, null);
- }
-
- @Override
- public String getName() {
- return "table";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/Title.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/Title.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/Title.java
deleted file mode 100644
index 76f8278..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/Title.java
+++ /dev/null
@@ -1,68 +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.display;
-
-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.ForbiddenException;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.util.MethodsUtils;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
-
-public class Title extends AbstractElementProcessor {
-
- @Override
- public void process(final TagProcessor tagProcessor) {
- final String id = tagProcessor.getOptionalProperty(OBJECT);
- final String fieldName = tagProcessor.getOptionalProperty(FIELD);
- final int truncateTo = Integer.valueOf(tagProcessor.getOptionalProperty(TRUNCATE, "0")).intValue();
- final boolean isIconShowing = tagProcessor.isRequested(SHOW_ICON, showIconByDefault());
- String className = tagProcessor.getOptionalProperty(CLASS);
- className = className == null ? "title-icon" : className;
- ObjectAdapter object = MethodsUtils.findObject(tagProcessor.getContext(), id);
- if (fieldName != null) {
- final ObjectAssociation field = object.getSpecification().getAssociation(fieldName);
- if (field.isVisible(IsisContext.getAuthenticationSession(), object, Where.ANYWHERE).isVetoed()) {
- throw new ForbiddenException(field, ForbiddenException.VISIBLE);
- }
- object = field.get(object);
- }
-
- if (object != null) {
- tagProcessor.appendHtml("<span class=\"object\">");
- IsisContext.getPersistenceSession().resolveImmediately(object);
- if (isIconShowing) {
- final String iconPath = tagProcessor.getContext().imagePath(object);
- tagProcessor.appendHtml("<img class=\"" + className + "\" src=\"" + iconPath + "\" />");
- }
- tagProcessor.appendTruncated(object.titleString(), truncateTo);
- tagProcessor.appendHtml("</span>");
- }
- tagProcessor.closeEmpty();
- }
-
- @Override
- public String getName() {
- return "title";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/Warnings.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/Warnings.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/Warnings.java
deleted file mode 100644
index f6ea1a3..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/Warnings.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.viewer.scimpi.dispatcher.view.display;
-
-import java.util.List;
-
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.core.runtime.system.transaction.MessageBroker;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
-
-public class Warnings extends AbstractElementProcessor {
-
- @Override
- public void process(final TagProcessor tagProcessor) {
- final String cls = tagProcessor.getOptionalProperty(CLASS);
- final StringBuffer buffer = new StringBuffer();
- write(cls, buffer);
- if (buffer.length() > 0) {
- tagProcessor.appendHtml("<div class=\"feedback\">");
- tagProcessor.appendHtml(buffer.toString());
- tagProcessor.appendHtml("</div>");
- }
- }
-
- public static void write(String cls, final StringBuffer buffer) {
- if (cls == null) {
- cls = "warning";
- }
- final MessageBroker messageBroker = IsisContext.getMessageBroker();
- final List<String> warnings = messageBroker.getWarnings();
- for (final String warning : warnings) {
- buffer.append("<div class=\"" + cls + "\">" + warning + "</div>");
- }
- }
-
- @Override
- public String getName() {
- return "warnings";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/edit/EditObject.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/edit/EditObject.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/edit/EditObject.java
deleted file mode 100644
index 468fc6a..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/edit/EditObject.java
+++ /dev/null
@@ -1,320 +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.edit;
-
-import java.util.ArrayList;
-import java.util.List;
-
-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.consent.Consent;
-import org.apache.isis.core.metamodel.facets.object.parseable.ParseableFacet;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAssociationFilters;
-import org.apache.isis.core.progmodel.facets.object.choices.enums.EnumFacet;
-import org.apache.isis.core.progmodel.facets.value.booleans.BooleanValueFacet;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.viewer.scimpi.dispatcher.action.EditAction;
-import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
-import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.structure.FieldEditState;
-import org.apache.isis.viewer.scimpi.dispatcher.structure.FormState;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
-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;
-import org.apache.isis.viewer.scimpi.dispatcher.view.widget.FieldFactory;
-import org.apache.isis.viewer.scimpi.dispatcher.view.widget.FormFieldBlock;
-
-public class EditObject extends AbstractElementProcessor {
-
- // REVIEW: confirm this rendering context
- private final Where where = Where.OBJECT_FORMS;
-
- @Override
- public void process(final TagProcessor tagProcessor) {
- final Request context = tagProcessor.getContext();
-
- final String objectId = tagProcessor.getOptionalProperty(OBJECT);
- final String forwardEditedTo = tagProcessor.getOptionalProperty(VIEW);
- final String forwardErrorTo = tagProcessor.getOptionalProperty(ERROR);
- final String cancelTo = tagProcessor.getOptionalProperty(CANCEL_TO);
- final boolean hideNonEditableFields = tagProcessor.isRequested(HIDE_UNEDITABLE, false);
- final boolean showIcon = tagProcessor.isRequested(SHOW_ICON, showIconByDefault());
- final String labelDelimiter = tagProcessor.getOptionalProperty(LABEL_DELIMITER, ":");
- String buttonTitle = tagProcessor.getOptionalProperty(BUTTON_TITLE);
- String formTitle = tagProcessor.getOptionalProperty(FORM_TITLE);
- final String formId = tagProcessor.getOptionalProperty(FORM_ID, tagProcessor.nextFormId());
- final String variable = tagProcessor.getOptionalProperty(RESULT_NAME);
- final String resultOverride = tagProcessor.getOptionalProperty(RESULT_OVERRIDE);
- final String scope = tagProcessor.getOptionalProperty(SCOPE);
- final String className = tagProcessor.getOptionalProperty(CLASS, "edit full");
- final String completionMessage = tagProcessor.getOptionalProperty(MESSAGE);
-
- final ObjectAdapter object = context.getMappedObjectOrResult(objectId);
- final String actualObjectId = context.mapObject(object, Scope.INTERACTION);
- final String version = context.mapVersion(object);
-
- final String id = tagProcessor.getOptionalProperty(ID, object.getSpecification().getShortIdentifier());
-
- final FormState entryState = (FormState) context.getVariable(ENTRY_FIELDS);
-
- final ObjectSpecification specification = object.getSpecification();
- final FormFieldBlock containedBlock = new FormFieldBlock() {
- @Override
- public boolean isVisible(final String name) {
- final ObjectAssociation fld = specification.getAssociation(name);
- final boolean isVisible = fld.isVisible(IsisContext.getAuthenticationSession(), object, where).isAllowed();
- final boolean isUseable = fld.isUsable(IsisContext.getAuthenticationSession(), object, where).isAllowed();
- return isVisible && isUseable;
- }
-
- @Override
- public ObjectAdapter getCurrent(final String name) {
- ObjectAdapter value = null;
- if (entryState != null) {
- final FieldEditState field2 = entryState.getField(name);
- value = field2.getValue();
- }
- if (value == null) {
- final ObjectAssociation fld = specification.getAssociation(name);
- value = fld.get(object);
- }
- return value;
- }
-
- @Override
- public boolean isNullable(final String name) {
- final ObjectAssociation fld = specification.getAssociation(name);
- return !fld.isMandatory();
- }
- };
-
- tagProcessor.setBlockContent(containedBlock);
- tagProcessor.processUtilCloseTag();
-
- final AuthenticationSession session = IsisContext.getAuthenticationSession();
- List<ObjectAssociation> viewFields = specification.getAssociations(ObjectAssociationFilters.dynamicallyVisible(session, object, where));
- viewFields = containedBlock.includedFields(viewFields);
- final InputField[] formFields = createFields(viewFields);
-
- initializeFields(context, object, formFields, entryState, !hideNonEditableFields);
- setDefaults(context, object, formFields, entryState, showIcon);
-
- copyFieldContent(context, object, formFields, showIcon);
- overrideWithHtml(context, containedBlock, formFields);
- String errors = null;
- if (entryState != null && entryState.isForForm(formId)) {
- copyEntryState(context, object, formFields, entryState);
- errors = entryState.getError();
- }
-
- final String errorView = context.fullFilePath(forwardErrorTo == null ? context.getResourceFile() : forwardErrorTo);
- final List<HiddenInputField> hiddenFields = new ArrayList<HiddenInputField>();
- hiddenFields.add(new HiddenInputField("_" + OBJECT, actualObjectId));
- hiddenFields.add(new HiddenInputField("_" + VERSION, version));
- hiddenFields.add(new HiddenInputField("_" + FORM_ID, formId));
- hiddenFields.add(completionMessage == null ? null : new HiddenInputField("_" + MESSAGE, completionMessage));
- hiddenFields.add(forwardEditedTo == null ? null : new HiddenInputField("_" + VIEW, context.fullFilePath(forwardEditedTo)));
- hiddenFields.add(new HiddenInputField("_" + ERROR, errorView));
- hiddenFields.add(variable == null ? null : new HiddenInputField("_" + RESULT_NAME, variable));
- hiddenFields.add(resultOverride == null ? null : new HiddenInputField("_" + RESULT_OVERRIDE, resultOverride));
- hiddenFields.add(scope == null ? null : new HiddenInputField("_" + SCOPE, scope));
-
- if (!object.isTransient()) {
- // ensure all booleans are included so the pass back TRUE if set.
- final List<ObjectAssociation> fields2 = object.getSpecification().getAssociations();
- for (int i = 0; i < fields2.size(); i++) {
- final ObjectAssociation field = fields2.get(i);
- if (!viewFields.contains(field) && field.getSpecification().containsFacet(BooleanValueFacet.class)) {
- final String fieldId = field.getId();
- final String value = getValue(context, field.get(object));
- hiddenFields.add(new HiddenInputField(fieldId, value));
- }
- }
- }
-
- if (formTitle == null) {
- formTitle = specification.getSingularName();
- }
-
- if (buttonTitle == null) {
- buttonTitle = "Save " + specification.getSingularName();
- } else if (buttonTitle.equals("")) {
- buttonTitle = "Save";
- }
-
- final HiddenInputField[] hiddenFieldArray = hiddenFields.toArray(new HiddenInputField[hiddenFields.size()]);
- HtmlFormBuilder.createForm(tagProcessor, EditAction.ACTION + ".app", hiddenFieldArray, formFields, className, id, formTitle,
- labelDelimiter, null, null, buttonTitle, errors, cancelTo);
- tagProcessor.popBlockContent();
- }
-
- private InputField[] createFields(final List<ObjectAssociation> fields) {
- final InputField[] formFields = new InputField[fields.size()];
- int length = 0;
- for (int i = 0; i < fields.size(); i++) {
- if (!fields.get(i).isOneToManyAssociation()) {
- formFields[i] = new InputField(fields.get(i).getId());
- length++;
- }
- }
- final InputField[] array = new InputField[length];
- for (int i = 0, j = 0; i < formFields.length; i++) {
- if (formFields[i] != null) {
- array[j++] = formFields[i];
- }
- }
- return array;
- }
-
- // TODO duplicated in ActionForm#initializeFields
- private void initializeFields(final Request context, final ObjectAdapter object, final InputField[] formFields, final FormState entryState, final boolean includeUnusableFields) {
- for (final InputField formField : formFields) {
- final String fieldId = formField.getName();
- final ObjectAssociation field = object.getSpecification().getAssociation(fieldId);
- final AuthenticationSession session = IsisContext.getAuthenticationSession();
- final Consent usable = field.isUsable(session, object, where);
- final ObjectAdapter[] options = field.getChoices(object);
- FieldFactory.initializeField(context, object, field, options, field.isMandatory(), formField);
-
- final boolean isEditable = usable.isAllowed();
- if (!isEditable) {
- formField.setDescription(usable.getReason());
- }
- formField.setEditable(isEditable);
- final boolean hiddenField = field.isVisible(session, object, where).isVetoed();
- final boolean unusable = usable.isVetoed();
- final boolean hideAsUnusable = unusable && !includeUnusableFields;
- if (hiddenField || hideAsUnusable) {
- formField.setHidden(true);
- }
- }
- }
-
- private void copyFieldContent(final Request context, final ObjectAdapter object, final InputField[] formFields, final boolean showIcon) {
- for (final InputField inputField : formFields) {
- final String fieldName = inputField.getName();
- final ObjectAssociation field = object.getSpecification().getAssociation(fieldName);
- if (field.isVisible(IsisContext.getAuthenticationSession(), object, where).isAllowed()) {
- IsisContext.getPersistenceSession().resolveField(object, field);
- final ObjectAdapter fieldValue = field.get(object);
- if (inputField.isEditable()) {
- final String value = getValue(context, fieldValue);
- if (!value.equals("") || inputField.getValue() == null) {
- inputField.setValue(value);
- }
- } else {
- final String entry = getValue(context, fieldValue);
- inputField.setHtml(entry);
- inputField.setType(InputField.HTML);
-
- }
-
- if (field.getSpecification().getFacet(ParseableFacet.class) == null) {
- if (fieldValue != null) {
- final String iconSegment = showIcon ? "<img class=\"small-icon\" src=\"" + context.imagePath(field.getSpecification()) + "\" alt=\"" + field.getSpecification().getShortIdentifier() + "\"/>" : "";
- final String entry = iconSegment + fieldValue.titleString();
- inputField.setHtml(entry);
- } else {
- final String entry = "<em>none specified</em>";
- inputField.setHtml(entry);
- }
- }
- }
- }
- }
-
- private void setDefaults(final Request context, final ObjectAdapter object, final InputField[] formFields, final FormState entryState, final boolean showIcon) {
- for (final InputField formField : formFields) {
- final String fieldId = formField.getName();
- final ObjectAssociation field = object.getSpecification().getAssociation(fieldId);
- final ObjectAdapter defaultValue = field.getDefault(object);
- if (defaultValue == null) {
- continue;
- }
-
- final String title = defaultValue.titleString();
- if (field.getSpecification().containsFacet(ParseableFacet.class)) {
- formField.setValue(title);
- } else if (field.isOneToOneAssociation()) {
- final ObjectSpecification objectSpecification = field.getSpecification();
- if (defaultValue != null) {
- final String iconSegment = showIcon ? "<img class=\"small-icon\" src=\"" + context.imagePath(objectSpecification) + "\" alt=\"" + objectSpecification.getShortIdentifier() + "\"/>" : "";
- final String html = iconSegment + title;
- formField.setHtml(html);
- final String value = defaultValue == null ? null : context.mapObject(defaultValue, Scope.INTERACTION);
- formField.setValue(value);
- }
- }
- }
- }
-
- private void overrideWithHtml(final Request context, final FormFieldBlock containedBlock, final InputField[] formFields) {
- for (final InputField formField : formFields) {
- final String fieldId = formField.getName();
- if (containedBlock.hasContent(fieldId)) {
- final String content = containedBlock.getContent(fieldId);
- if (content != null) {
- formField.setHtml(content);
- formField.setValue(null);
- formField.setType(InputField.HTML);
- }
- }
- }
- }
-
- private void copyEntryState(final Request context, final ObjectAdapter object, final InputField[] formFields, final FormState entryState) {
- for (final InputField formField : formFields) {
- final String fieldId = formField.getName();
- final ObjectAssociation field = object.getSpecification().getAssociation(fieldId);
- if (field.isVisible(IsisContext.getAuthenticationSession(), object, where).isAllowed() && formField.isEditable()) {
- final FieldEditState fieldState = entryState.getField(field.getId());
- final String entry = fieldState == null ? "" : fieldState.getEntry();
- formField.setValue(entry);
- final String error = fieldState == null ? "" : fieldState.getError();
- formField.setErrorText(error);
- }
- }
- }
-
- private String getValue(final Request context, final ObjectAdapter field) {
- if (field == null || field.isTransient()) {
- return "";
- }
- final ObjectSpecification specification = field.getSpecification();
- if (specification.containsFacet(EnumFacet.class)) {
- return String.valueOf(field.getObject());
- } else if (specification.getFacet(ParseableFacet.class) == null) {
- return context.mapObject(field, Scope.INTERACTION);
- } else {
- return field.titleString();
- }
- }
-
- @Override
- public String getName() {
- return "edit";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/field/ExcludeField.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/field/ExcludeField.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/field/ExcludeField.java
deleted file mode 100644
index 247aa92..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/field/ExcludeField.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.field;
-
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
-
-public class ExcludeField extends AbstractElementProcessor {
-
- @Override
- public void process(final TagProcessor tagProcessor) {
- final String field = tagProcessor.getOptionalProperty(NAME);
- final InclusionList block = (InclusionList) tagProcessor.getBlockContent();
- block.exclude(field);
- }
-
- @Override
- public String getName() {
- return "exclude";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/field/IncludeField.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/field/IncludeField.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/field/IncludeField.java
deleted file mode 100644
index 0d176d2..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/field/IncludeField.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.field;
-
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
-
-public class IncludeField extends AbstractElementProcessor {
-
- @Override
- public void process(final TagProcessor tagProcessor) {
- final String field = tagProcessor.getOptionalProperty(NAME);
- final InclusionList block = (InclusionList) tagProcessor.getBlockContent();
- block.include(field);
- }
-
- @Override
- public String getName() {
- return "include";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/field/InclusionList.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/field/InclusionList.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/field/InclusionList.java
deleted file mode 100644
index 3a72451..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/field/InclusionList.java
+++ /dev/null
@@ -1,89 +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.field;
-
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import com.google.common.collect.Lists;
-
-import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.BlockContent;
-import org.apache.isis.viewer.scimpi.dispatcher.view.form.InputField;
-
-public class InclusionList implements BlockContent {
- private final Set<String> includedList = new HashSet<String>();
- private final Set<String> excludedList = new HashSet<String>();
-
- private boolean inIncludedList(final String fieldName) {
- return includedList.size() == 0 || includedList.contains(fieldName) || includedList.contains("all");
- }
-
- private boolean inExcludedList(final String fieldName) {
- return excludedList.contains(fieldName) || excludedList.contains("all");
- }
-
- public void include(final String field) {
- includedList.add(field);
- }
-
- public void exclude(final String field) {
- excludedList.add(field);
- }
-
- public List<ObjectAssociation> includedFields(final List<ObjectAssociation> originalFields) {
- final List<ObjectAssociation> includedFields = Lists.newArrayList();
- for (int i = 0; i < originalFields.size(); i++) {
- final String id2 = originalFields.get(i).getId();
- if (includes(id2)) {
- includedFields.add(originalFields.get(i));
- }
- }
-
- return includedFields;
- }
-
- public void hideExcludedParameters(final InputField[] inputFields) {
- for (final InputField inputField : inputFields) {
- final String id2 = inputField.getName();
- if (!includes(id2)) {
- inputField.setHidden(true);
- }
- }
- }
-
- public boolean includes(final String id) {
- return inIncludedList(id) && !inExcludedList(id);
- }
-
- public List<ObjectAction> includedActions(final List<ObjectAction> originalActions) {
- final List<ObjectAction> includedActions = Lists.newArrayList();
- for (int i = 0; i < originalActions.size(); i++) {
- final String id2 = originalActions.get(i).getId();
- if (includes(id2)) {
- includedActions.add(originalActions.get(i));
- }
- }
-
- return includedActions;
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/field/LinkField.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/field/LinkField.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/field/LinkField.java
deleted file mode 100644
index e36612d..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/field/LinkField.java
+++ /dev/null
@@ -1,44 +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.field;
-
-import org.apache.isis.viewer.scimpi.Names;
-import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
-
-public class LinkField extends AbstractElementProcessor {
-
- @Override
- public void process(final TagProcessor tagProcessor) {
- final String field = tagProcessor.getOptionalProperty(NAME);
- final String variable = tagProcessor.getOptionalProperty(REFERENCE_NAME, Names.RESULT);
- final String scope = tagProcessor.getOptionalProperty(SCOPE, Scope.INTERACTION.toString());
- final String forwardView = tagProcessor.getOptionalProperty(VIEW, "_generic." + Names.EXTENSION);
- final LinkedFieldsBlock tag = (LinkedFieldsBlock) tagProcessor.getBlockContent();
- tag.link(field, variable, scope, forwardView);
- }
-
- @Override
- public String getName() {
- return "link";
- }
-
-}
[08/24] Restructuring Scimpi to remove dependencies and enable easier
testing.
Posted by rm...@apache.org.
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/debug/DebugAction.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/debug/DebugAction.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/debug/DebugAction.java
deleted file mode 100644
index b0f2910..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/debug/DebugAction.java
+++ /dev/null
@@ -1,243 +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.debug;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-
-import com.google.common.base.Function;
-import com.google.common.collect.Collections2;
-import com.google.common.collect.Lists;
-
-import org.apache.isis.core.commons.debug.DebugBuilder;
-import org.apache.isis.core.commons.debug.DebugString;
-import org.apache.isis.core.commons.debug.DebuggableWithTitle;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.metamodel.spec.SpecificationLoaderSpi;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
-import org.apache.isis.core.metamodel.spec.feature.ObjectActionContainer.Contributed;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
-import org.apache.isis.core.metamodel.util.Dump;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.viewer.scimpi.dispatcher.Action;
-import org.apache.isis.viewer.scimpi.dispatcher.Dispatcher;
-import org.apache.isis.viewer.scimpi.dispatcher.ForbiddenException;
-import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext;
-import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext.Scope;
-
-public class DebugAction implements Action {
- private final Dispatcher dispatcher;
-
- public DebugAction(final Dispatcher dispatcher) {
- this.dispatcher = dispatcher;
- }
-
- @Override
- public String getName() {
- return "debug";
- }
-
- @Override
- public void debug(final DebugBuilder debug) {
- }
-
- @Override
- public void process(final RequestContext context) throws IOException {
- if (context.isDebugDisabled()) {
- throw new ForbiddenException("Can't access debug action when debug is disabled");
- }
-
- final String action = context.getParameter("action");
- if ("list-i18n".equals(action)) {
- i18n(context, null);
- } else if ("list-authorization".equals(action)) {
- authorization(context, null);
- } else if (context.getParameter("mode") != null) {
- final boolean isDebugOn = context.getParameter("mode").equals("debug");
- context.addVariable("debug-on", isDebugOn, Scope.SESSION);
- // TODO need to use configuration to find path
- context.setRequestPath("/debug/debug.shtml");
- } else {
-
- // TODO remove - replaced by Debug tag
- final DebugHtmlWriter view = new DebugHtmlWriter(context.getWriter(), true);
- view.appendln("<div class=\"links\">");
- view.appendln("<a href=\"debug.app?action=system\">System</a>");
- view.appendln(" | <a href=\"debug.app?action=specifications\">List specifications</a>");
- view.appendln(" | <a href=\"debug.app?action=list-i18n\">I18N File</a>");
- view.appendln(" | <a href=\"debug.app?action=list-authorization\">Authorization File</a>");
- view.appendln(" | <a href=\"debug.app?action=context\">Context</a>");
- view.appendln(" | <a href=\"debug.app?action=dispatcher\">Dispatcher</a>");
- view.appendln("</div>");
-
- if ("specifications".equals(action)) {
- listSpecifications(view);
- } else if ("specification".equals(action)) {
- // specification(context, view);
- } else if ("object".equals(action)) {
- object(context, view);
- } else if ("system".equals(action)) {
- system(context, view);
- } else if ("context".equals(action)) {
- context.append(view);
- } else if ("dispatcher".equals(action)) {
- dispatcher.debug(view);
- }
-
- context.clearRequestedPath();
- }
- }
-
- private void object(final RequestContext context, final DebugHtmlWriter view) {
- final ObjectAdapter object = context.getMappedObjectOrResult(context.getParameter("object"));
- final DebugString str = new DebugString();
- Dump.adapter(object, str);
- Dump.graph(object, IsisContext.getAuthenticationSession(), str);
- view.appendTitle(object.getSpecification().getFullIdentifier());
- view.appendln("<pre class=\"debug\">" + str + "</pre>");
- }
-
- private void system(final RequestContext context, final DebugHtmlWriter view) {
- final DebuggableWithTitle[] debug = IsisContext.debugSystem();
- view.appendTitle("System");
- for (final DebuggableWithTitle element2 : debug) {
- final DebugString str = new DebugString();
- element2.debugData(str);
- view.appendTitle(element2.debugTitle());
- view.appendln("<pre class=\"debug\">" + str + "</pre>");
- }
- }
-
- private void i18n(final RequestContext context, final DebugHtmlWriter view) {
- final Collection<ObjectSpecification> allSpecifications = getSpecificationLoader().allSpecifications();
- final List<ObjectSpecification> specs = Lists.newArrayList(allSpecifications);
- Collections.sort(specs, new Comparator<ObjectSpecification>() {
- @Override
- public int compare(final ObjectSpecification o1, final ObjectSpecification o2) {
- return o1.getShortIdentifier().compareTo(o2.getShortIdentifier());
- }
- });
- final Function<ObjectSpecification, String> className = ObjectSpecification.FUNCTION_FULLY_QUALIFIED_CLASS_NAME;
- final List<String> fullIdentifierList = Lists.newArrayList(Collections2.transform(specs, className));
- for (final String fullIdentifier : fullIdentifierList) {
- final ObjectSpecification spec = getSpecificationLoader().loadSpecification(fullIdentifier);
- if (spec.getAssociations().size() == 0 && spec.getObjectActions(Contributed.EXCLUDED).size() == 0) {
- continue;
- }
- final String name = spec.getIdentifier().toClassIdentityString();
- context.getWriter().append("# " + spec.getShortIdentifier() + "\n");
- for (final ObjectAssociation assoc : spec.getAssociations()) {
- context.getWriter().append("#" + name + ".property." + assoc.getId() + ".name" + "=\n");
- context.getWriter().append("#" + name + ".property." + assoc.getId() + ".description" + "=\n");
- context.getWriter().append("#" + name + ".property." + assoc.getId() + ".help" + "=\n");
- }
- for (final ObjectAction action : spec.getObjectActions(Contributed.EXCLUDED)) {
- context.getWriter().append("#" + name + ".action." + action.getId() + ".name" + "=\n");
- context.getWriter().append("#" + name + ".action." + action.getId() + ".description" + "=\n");
- context.getWriter().append("#" + name + ".action." + action.getId() + ".help" + "=\n");
- }
- context.getWriter().append("\n");
- }
- }
-
- private void authorization(final RequestContext context, final DebugHtmlWriter view) {
- final Collection<ObjectSpecification> allSpecifications = getSpecificationLoader().allSpecifications();
- final List<ObjectSpecification> specs = Lists.newArrayList(allSpecifications);
- Collections.sort(specs, new Comparator<ObjectSpecification>() {
- @Override
- public int compare(final ObjectSpecification o1, final ObjectSpecification o2) {
- return o1.getShortIdentifier().compareTo(o2.getShortIdentifier());
- }
- });
- final Function<ObjectSpecification, String> className = ObjectSpecification.FUNCTION_FULLY_QUALIFIED_CLASS_NAME;
- final List<String> fullIdentifierList = Lists.newArrayList(Collections2.transform(specs, className));
- for (final String fullIdentifier : fullIdentifierList) {
- final ObjectSpecification spec = getSpecificationLoader().loadSpecification(fullIdentifier);
- if (spec.getAssociations().size() == 0 && spec.getObjectActions(Contributed.EXCLUDED).size() == 0) {
- continue;
- }
- final String name = spec.getIdentifier().toClassIdentityString();
- context.getWriter().append("# " + spec.getShortIdentifier() + "\n");
- context.getWriter().append("" + name + ":roles\n");
- for (final ObjectAssociation assoc : spec.getAssociations()) {
- context.getWriter().append("#" + name + "#" + assoc.getId() + ":roles\n");
- // context.getWriter().append("#" + name + ".property." +
- // assoc.getId() + ".description" + "=\n");
- // context.getWriter().append("#" + name + ".property." +
- // assoc.getId() + ".help" + "=\n");
- }
- for (final ObjectAction action : spec.getObjectActions(Contributed.EXCLUDED)) {
- context.getWriter().append("#" + name + "#" + action.getId() + "():roles\n");
- // context.getWriter().append("#" + name + ".action." +
- // action.getId() + ".description" + "=\n");
- // context.getWriter().append("#" + name + ".action." +
- // action.getId() + ".help" + "=\n");
- }
- context.getWriter().append("\n");
- }
- }
-
- private void listSpecifications(final DebugHtmlWriter view) {
- final List<ObjectSpecification> fullIdentifierList = new ArrayList<ObjectSpecification>(getSpecificationLoader().allSpecifications());
- Collections.sort(fullIdentifierList, ObjectSpecification.COMPARATOR_SHORT_IDENTIFIER_IGNORE_CASE);
- view.appendTitle("Specifications");
- for (final ObjectSpecification spec : fullIdentifierList) {
- final String name = spec.getSingularName();
- view.appendln(name, "");
- // view.appendln(name, specificationLink(spec));
- }
-
- /*
- * new Comparator<ObjectSpecification>() { public int
- * compare(ObjectSpecification o1, ObjectSpecification o2) { return
- * o1.getSingularName().compareTo(o2.getSingularName()); }});
- *
- * /* Collection<ObjectSpecification> allSpecifications =
- * getSpecificationLoader().allSpecifications(); Collection<String> list
- * = Collections2.transform(allSpecifications,
- * ObjectSpecification.COMPARATOR_SHORT_IDENTIFIER_IGNORE_CASE); final
- * List<String> fullIdentifierList = Lists.newArrayList(list); /*
- * Collections.sort(fullIdentifierList, new
- * Comparator<ObjectSpecification>() { public int
- * compare(ObjectSpecification o1, ObjectSpecification o2) { return
- * o1.getSingularName().compareTo(o2.getSingularName()); }});
- */
- /*
- * view.divider("Specifications"); for (String fullIdentifier :
- * fullIdentifierList) { ObjectSpecification spec =
- * getSpecificationLoader().loadSpecification(fullIdentifier); String
- * name = spec.getSingularName(); view.appendRow(name,
- * specificationLink(spec)); }
- */
- }
-
- protected SpecificationLoaderSpi getSpecificationLoader() {
- return IsisContext.getSpecificationLoader();
- }
-
- @Override
- public void init() {
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/debug/DebugHtmlWriter.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/debug/DebugHtmlWriter.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/debug/DebugHtmlWriter.java
deleted file mode 100644
index 112bc77..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/debug/DebugHtmlWriter.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.debug;
-
-import java.io.PrintWriter;
-
-import org.apache.isis.core.commons.debug.DebugHtmlStringAbstract;
-
-public class DebugHtmlWriter extends DebugHtmlStringAbstract {
-
- private final PrintWriter writer;
-
- public DebugHtmlWriter(final PrintWriter writer, final boolean createPage) {
- super(createPage);
- this.writer = writer;
- header();
- }
-
- @Override
- protected void appendHtml(final String html) {
- writer.println(html);
- }
-
- @Override
- protected void doClose() {
- footer();
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/debug/DebugUserAction.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/debug/DebugUserAction.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/debug/DebugUserAction.java
deleted file mode 100644
index 461ce84..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/debug/DebugUserAction.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.debug;
-
-import java.io.IOException;
-
-import org.apache.isis.core.commons.debug.DebugBuilder;
-import org.apache.isis.viewer.scimpi.dispatcher.Action;
-import org.apache.isis.viewer.scimpi.dispatcher.ForbiddenException;
-import org.apache.isis.viewer.scimpi.dispatcher.ScimpiException;
-import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext;
-
-public class DebugUserAction implements Action {
-
- private final DebugUsers debugUsers;
-
- public DebugUserAction(final DebugUsers debugUsers) {
- this.debugUsers = debugUsers;
- }
-
- @Override
- public String getName() {
- return "debug-user";
- }
-
- @Override
- public void debug(final DebugBuilder debug) {
- }
-
- @Override
- public void process(final RequestContext context) throws IOException {
- if (context.isDebugDisabled()) {
- throw new ForbiddenException("Can't access debug action when debug is disabled");
- }
-
- final String method = context.getParameter(METHOD);
- final String name = context.getParameter(NAME);
- final String view = context.getParameter(VIEW);
-
- if (method != null && method.equals("add")) {
- debugUsers.add(name);
- } else if (method != null && method.equals("remove")) {
- debugUsers.remove(name);
- } else {
- throw new ScimpiException("Invalid debug-user action");
- }
-
- context.setRequestPath(view);
- }
-
- @Override
- public void init() {
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/debug/DebugUsers.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/debug/DebugUsers.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/debug/DebugUsers.java
deleted file mode 100644
index 81a215a..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/debug/DebugUsers.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.viewer.scimpi.dispatcher.debug;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.apache.log4j.Logger;
-
-import org.apache.isis.core.commons.authentication.AuthenticationSession;
-import org.apache.isis.core.commons.config.ConfigurationConstants;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.viewer.scimpi.dispatcher.ScimpiException;
-
-public class DebugUsers {
-
- private static Logger LOG = Logger.getLogger(DebugUsers.class);
-
- private enum DebugMode {
- OFF, ON, NAMED, SYSADMIN_ONLY
- }
-
- private static List<String> debugUsers = new ArrayList<String>();
- private static DebugMode debugMode;
-
- public void initialize() {
- if (debugMode != null) {
- throw new ScimpiException("Debug mode is already set up!");
- }
-
- final String debugUserEntry = IsisContext.getConfiguration().getString(ConfigurationConstants.ROOT + "scimpi.debug.users", "");
- final String[] users = debugUserEntry.split("\\|");
- for (final String name : users) {
- debugUsers.add(name.trim());
- }
-
- final String debugModeEntry = IsisContext.getConfiguration().getString(ConfigurationConstants.ROOT + "scimpi.debug.mode");
- if (debugModeEntry != null) {
- try {
- debugMode = DebugMode.valueOf(debugModeEntry.toUpperCase());
- LOG.info("Debug mode set to " + debugMode);
- } catch (final IllegalArgumentException e) {
- LOG.error("Invalid debug mode - " + debugModeEntry + " - mode set to OFF");
- debugMode = DebugMode.OFF;
- }
- } else {
- debugMode = DebugMode.OFF;
- }
- }
-
- public boolean isDebugEnabled(final AuthenticationSession session) {
- if (debugMode == DebugMode.ON) {
- return true;
- } else if (session != null && debugMode == DebugMode.SYSADMIN_ONLY && session.getRoles().contains("sysadmin")) {
- return true;
- } else if (session != null && debugMode == DebugMode.NAMED && (debugUsers.contains(session.getUserName()) || session.getRoles().contains("sysadmin"))) {
- return true;
- }
- return false;
- }
-
- public List<String> getNames() {
- final ArrayList<String> users = new ArrayList<String>(debugUsers);
- Collections.sort(users);
- return users;
- }
-
- public void add(final String name) {
- if (!debugUsers.contains(name)) {
- debugUsers.add(name);
- LOG.info("Added '" + debugMode + "' to debug users list");
- }
- }
-
- public void remove(final String name) {
- debugUsers.remove(name);
- LOG.info("Removed '" + debugMode + "' from debug users list");
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/debug/DebugUsersView.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/debug/DebugUsersView.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/debug/DebugUsersView.java
index 360c48a..3243d92 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/debug/DebugUsersView.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/debug/DebugUsersView.java
@@ -19,8 +19,8 @@
package org.apache.isis.viewer.scimpi.dispatcher.debug;
-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.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public class DebugUsersView extends AbstractElementProcessor {
@@ -30,21 +30,21 @@ public class DebugUsersView extends AbstractElementProcessor {
}
@Override
- public void process(final Request request) {
- final String view = request.getContext().getContextPath() + request.getContext().getResourceParentPath() + request.getContext().getResourceFile();
+ public void process(final TagProcessor tagProcessor) {
+ final String view = tagProcessor.getContext().getContextPath() + tagProcessor.getContext().getResourceParentPath() + tagProcessor.getContext().getResourceFile();
- request.appendHtml("<form class=\"generic action\" action=\"debug-user.app\" method=\"post\" accept-charset=\"ISO-8859-1\">\n");
- request.appendHtml("<div class=\"title\">Add Debug User</div>\n");
- request.appendHtml("<div class=\"field\"><label>User Name:</label><input type=\"text\" name=\"name\" size=\"30\" /></div>\n");
- request.appendHtml("<input type=\"hidden\" name=\"method\" value=\"add\" />\n");
- request.appendHtml("<input type=\"hidden\" name=\"view\" value=\"" + view + "\" />\n");
- request.appendHtml("<input class=\"button\" type=\"submit\" value=\"Add User\" />\n");
- request.appendHtml("</form>\n");
+ tagProcessor.appendHtml("<form class=\"generic action\" action=\"debug-user.app\" method=\"post\" accept-charset=\"ISO-8859-1\">\n");
+ tagProcessor.appendHtml("<div class=\"title\">Add Debug User</div>\n");
+ tagProcessor.appendHtml("<div class=\"field\"><label>User Name:</label><input type=\"text\" name=\"name\" size=\"30\" /></div>\n");
+ tagProcessor.appendHtml("<input type=\"hidden\" name=\"method\" value=\"add\" />\n");
+ tagProcessor.appendHtml("<input type=\"hidden\" name=\"view\" value=\"" + view + "\" />\n");
+ tagProcessor.appendHtml("<input class=\"button\" type=\"submit\" value=\"Add User\" />\n");
+ tagProcessor.appendHtml("</form>\n");
- request.appendHtml("<table class=\"debug\">\n<tr><th class=\"title\">Name</th><th class=\"title\"></th></tr>\n");
- for (final String name : request.getContext().getDebugUsers()) {
- request.appendHtml("<tr><th>" + name + "</th><th><a href=\"debug-user.app?method=remove&name=" + name + "&view=" + view + " \">remove</a></th></tr>\n");
+ tagProcessor.appendHtml("<table class=\"debug\">\n<tr><th class=\"title\">Name</th><th class=\"title\"></th></tr>\n");
+ for (final String name : tagProcessor.getContext().getDebugUsers()) {
+ tagProcessor.appendHtml("<tr><th>" + name + "</th><th><a href=\"debug-user.app?method=remove&name=" + name + "&view=" + view + " \">remove</a></th></tr>\n");
}
- request.appendHtml("</table>\n");
+ tagProcessor.appendHtml("</table>\n");
}
}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/debug/ErrorDetails.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/debug/ErrorDetails.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/debug/ErrorDetails.java
index 3049b26..0459390 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/debug/ErrorDetails.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/debug/ErrorDetails.java
@@ -19,8 +19,8 @@
package org.apache.isis.viewer.scimpi.dispatcher.debug;
-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.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public class ErrorDetails extends AbstractElementProcessor {
@@ -29,7 +29,7 @@ public class ErrorDetails extends AbstractElementProcessor {
return "error-details";
}
- public void process(final Request request) {
- request.appendHtml(request.getContext().getErrorDetails());
+ public void process(final TagProcessor tagProcessor) {
+ tagProcessor.appendHtml(tagProcessor.getContext().getErrorDetails());
}
}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/debug/ErrorMessage.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/debug/ErrorMessage.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/debug/ErrorMessage.java
index 07538ce..dfc48cf 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/debug/ErrorMessage.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/debug/ErrorMessage.java
@@ -19,8 +19,8 @@
package org.apache.isis.viewer.scimpi.dispatcher.debug;
-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.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public class ErrorMessage extends AbstractElementProcessor {
@@ -29,7 +29,7 @@ public class ErrorMessage extends AbstractElementProcessor {
return "error-message";
}
- public void process(final Request request) {
- request.appendAsHtmlEncoded(request.getContext().getErrorMessage());
+ public void process(final TagProcessor tagProcessor) {
+ tagProcessor.appendAsHtmlEncoded(tagProcessor.getContext().getErrorMessage());
}
}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/debug/ErrorReference.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/debug/ErrorReference.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/debug/ErrorReference.java
index 75700cc..49e0b24 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/debug/ErrorReference.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/debug/ErrorReference.java
@@ -19,8 +19,8 @@
package org.apache.isis.viewer.scimpi.dispatcher.debug;
-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.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public class ErrorReference extends AbstractElementProcessor {
@@ -29,7 +29,7 @@ public class ErrorReference extends AbstractElementProcessor {
return "error-reference";
}
- public void process(final Request request) {
- request.appendAsHtmlEncoded(request.getContext().getErrorReference());
+ public void process(final TagProcessor tagProcessor) {
+ tagProcessor.appendAsHtmlEncoded(tagProcessor.getContext().getErrorReference());
}
}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/debug/LogAction.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/debug/LogAction.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/debug/LogAction.java
deleted file mode 100644
index 138213a..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/debug/LogAction.java
+++ /dev/null
@@ -1,76 +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.debug;
-
-import java.io.IOException;
-
-import org.apache.log4j.Level;
-import org.apache.log4j.LogManager;
-import org.apache.log4j.Logger;
-
-import org.apache.isis.core.commons.authentication.AuthenticationSession;
-import org.apache.isis.core.commons.debug.DebugBuilder;
-import org.apache.isis.viewer.scimpi.dispatcher.Action;
-import org.apache.isis.viewer.scimpi.dispatcher.NotLoggedInException;
-import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext;
-
-public class LogAction implements Action {
-
- private static final Logger LOG = Logger.getLogger(LogAction.class);
-
- @Override
- public void process(final RequestContext context) throws IOException {
-
- final AuthenticationSession session = context.getSession();
- if (session == null) {
- throw new NotLoggedInException();
- }
-
- final String levelName = (String) context.getVariable("level");
-
- final Level level = Level.toLevel(levelName);
- boolean changeLogged = false;
- if (Level.INFO.isGreaterOrEqual(LogManager.getRootLogger().getLevel())) {
- LOG.info("log level changed to " + level);
- changeLogged = true;
- }
- LogManager.getRootLogger().setLevel(level);
- if (!changeLogged) {
- LOG.info("log level changed to " + level);
- }
- final String view = (String) context.getVariable("view");
- context.setRequestPath(view);
-
- }
-
- @Override
- public String getName() {
- return "log";
- }
-
- @Override
- public void init() {
- }
-
- @Override
- public void debug(final DebugBuilder debug) {
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/edit/EditAction.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/edit/EditAction.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/edit/EditAction.java
deleted file mode 100644
index f78575f..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/edit/EditAction.java
+++ /dev/null
@@ -1,269 +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.edit;
-
-import java.io.IOException;
-import java.util.List;
-
-import org.apache.isis.applib.annotation.Where;
-import org.apache.isis.applib.profiles.Localization;
-import org.apache.isis.core.commons.authentication.AnonymousSession;
-import org.apache.isis.core.commons.authentication.AuthenticationSession;
-import org.apache.isis.core.commons.debug.DebugBuilder;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.adapter.version.Version;
-import org.apache.isis.core.metamodel.consent.Consent;
-import org.apache.isis.core.metamodel.consent.Veto;
-import org.apache.isis.core.metamodel.facets.object.parseable.ParseableFacet;
-import org.apache.isis.core.metamodel.facets.object.parseable.TextEntryParseException;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAssociationFilters;
-import org.apache.isis.core.metamodel.spec.feature.OneToOneAssociation;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.core.runtime.system.transaction.MessageBroker;
-import org.apache.isis.viewer.scimpi.dispatcher.Action;
-import org.apache.isis.viewer.scimpi.dispatcher.Dispatcher;
-import org.apache.isis.viewer.scimpi.dispatcher.NotLoggedInException;
-import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext;
-import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext.Scope;
-
-public class EditAction implements Action {
- public static final String ACTION = "edit";
-
- // 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
- public String getName() {
- return ACTION;
- }
-
- @Override
- public void process(final RequestContext context) throws IOException {
- AuthenticationSession session = context.getSession();
- if (session == null) {
- session = new AnonymousSession();
- }
-
- try {
- final String objectId = context.getParameter("_" + OBJECT);
- final String version = context.getParameter("_" + VERSION);
- final String formId = context.getParameter("_" + FORM_ID);
- String resultName = context.getParameter("_" + RESULT_NAME);
- resultName = resultName == null ? RequestContext.RESULT : resultName;
- final String override = context.getParameter("_" + RESULT_OVERRIDE);
- String message = context.getParameter("_" + MESSAGE);
-
- final ObjectAdapter adapter = context.getMappedObject(objectId);
-
- final List<ObjectAssociation> fields = adapter.getSpecification().getAssociations(ObjectAssociationFilters.dynamicallyVisible(session, adapter, where));
-
- for (final ObjectAssociation objectAssociation : fields) {
- if (objectAssociation.isVisible(session, adapter, where).isVetoed()) {
- throw new NotLoggedInException();
- }
- }
-
- final FormState entryState = validateObject(context, adapter, fields);
- final Version adapterVersion = adapter.getVersion();
- final Version formVersion = context.getVersion(version);
- if (formVersion != null && adapterVersion.different(formVersion)) {
-
- IsisContext.getMessageBroker().addMessage("The " + adapter.getSpecification().getSingularName() + " was edited " + "by another user (" + adapterVersion.getUser() + "). Please make your changes based on their changes.");
-
- final String view = context.getParameter("_" + ERROR);
- context.setRequestPath(view, Dispatcher.EDIT);
-
- entryState.setForm(formId);
- context.addVariable(ENTRY_FIELDS, entryState, Scope.REQUEST);
- context.addVariable(resultName, objectId, Scope.REQUEST);
- if (override != null) {
- context.addVariable(resultName, override, Scope.REQUEST);
- }
-
- } else if (entryState.isValid()) {
- changeObject(context, adapter, entryState, fields);
-
- if (adapter.isTransient()) {
- IsisContext.getPersistenceSession().makePersistent(adapter);
- context.unmapObject(adapter, Scope.REQUEST);
- }
-
- String view = context.getParameter("_" + VIEW);
-
- final String id = context.mapObject(adapter, Scope.REQUEST);
- context.addVariable(resultName, id, Scope.REQUEST);
- if (override != null) {
- context.addVariable(resultName, override, Scope.REQUEST);
- }
-
- final int questionMark = view == null ? -1 : view.indexOf("?");
- if (questionMark > -1) {
- final String params = view.substring(questionMark + 1);
- final int equals = params.indexOf("=");
- context.addVariable(params.substring(0, equals), params.substring(equals + 1), Scope.REQUEST);
- view = view.substring(0, questionMark);
- }
- context.setRequestPath(view);
- if (message == null) {
- message = "Saved changes to " + adapter.getSpecification().getSingularName();
- } else if (message.equals("")) {
- message = null;
- }
- if (message != null) {
- final MessageBroker messageBroker = IsisContext.getMessageBroker();
- messageBroker.addMessage(message);
- }
-
- } else {
- final String view = context.getParameter("_" + ERROR);
- context.setRequestPath(view, Dispatcher.EDIT);
-
- entryState.setForm(formId);
- context.addVariable(ENTRY_FIELDS, entryState, Scope.REQUEST);
- context.addVariable(resultName, objectId, Scope.REQUEST);
- if (override != null) {
- context.addVariable(resultName, override, Scope.REQUEST);
- }
-
- final MessageBroker messageBroker = IsisContext.getMessageBroker();
- messageBroker.addWarning(entryState.getError());
- }
-
- } catch (final RuntimeException e) {
- IsisContext.getMessageBroker().getMessages();
- IsisContext.getMessageBroker().getWarnings();
- IsisContext.getUpdateNotifier().clear();
- IsisContext.getUpdateNotifier().clear();
- throw e;
- }
- }
-
- private FormState validateObject(final RequestContext context, final ObjectAdapter object, final List<ObjectAssociation> fields) {
- final FormState formState = new FormState();
- for (int i = 0; i < fields.size(); i++) {
- final ObjectAssociation field = fields.get(i);
- final String fieldId = field.getId();
- String newEntry = context.getParameter(fieldId);
- if (fields.get(i).isOneToManyAssociation()) {
- continue;
- }
- if (fields.get(i).isVisible(IsisContext.getAuthenticationSession(), object, where).isVetoed()) {
- continue;
- }
- if (field.isUsable(IsisContext.getAuthenticationSession(), object, where).isVetoed()) {
- continue;
- }
-
- if (newEntry != null && newEntry.equals("-OTHER-")) {
- newEntry = context.getParameter(fieldId + "-other");
- }
-
- if (newEntry == null) {
- // TODO duplicated in EditObject; line 97
- final ObjectSpecification spec = field.getSpecification();
- if (spec.isOfType(IsisContext.getSpecificationLoader().loadSpecification(boolean.class)) || spec.isOfType(IsisContext.getSpecificationLoader().loadSpecification(Boolean.class))) {
- newEntry = FALSE;
- } else {
- continue;
- }
- }
- final FieldEditState fieldState = formState.createField(fieldId, newEntry);
-
- Consent consent = null;
- if (field.isMandatory() && (newEntry.equals("") || newEntry.equals("NULL"))) {
- consent = new Veto(field.getName() + " required");
- formState.setError("Not all fields have been set");
- } else if (field.getSpecification().containsFacet(ParseableFacet.class)) {
- try {
- final ParseableFacet facet = field.getSpecification().getFacet(ParseableFacet.class);
- final ObjectAdapter originalValue = field.get(object);
- Localization localization = IsisContext.getLocalization();
- final ObjectAdapter newValue = facet.parseTextEntry(originalValue, newEntry, localization);
- consent = ((OneToOneAssociation) field).isAssociationValid(object, newValue);
- fieldState.setValue(newValue);
- } catch (final TextEntryParseException e) {
- consent = new Veto(e.getMessage());
- // formState.setError("Not all fields have been entered correctly");
- }
-
- } else {
- final ObjectAdapter associate = newEntry.equals("null") ? null : context.getMappedObject(newEntry);
- if (associate != null) {
- IsisContext.getPersistenceSession().resolveImmediately(associate);
- }
- consent = ((OneToOneAssociation) field).isAssociationValid(object, associate);
- fieldState.setValue(associate);
-
- }
- if (consent.isVetoed()) {
- fieldState.setError(consent.getReason());
- formState.setError("Not all fields have been entered correctly");
- }
- }
-
- // TODO check the state of the complete object.
- return formState;
- }
-
- private void changeObject(final RequestContext context, final ObjectAdapter object, final FormState editState, final List<ObjectAssociation> fields) {
- for (int i = 0; i < fields.size(); i++) {
- final FieldEditState field = editState.getField(fields.get(i).getId());
- if (field == null) {
- continue;
- }
- final String newEntry = field.getEntry();
- final ObjectAdapter originalValue = fields.get(i).get(object);
- final boolean isVisible = fields.get(i).isVisible(IsisContext.getAuthenticationSession(), object, where).isAllowed();
- final boolean isUsable = fields.get(i).isUsable(IsisContext.getAuthenticationSession(), object, where).isAllowed();
- final boolean bothEmpty = originalValue == null && newEntry.equals("");
- final boolean bothSame = newEntry.equals(originalValue == null ? "" : originalValue.titleString());
- if ((!isVisible || !isUsable) || bothEmpty || bothSame) {
- if (fields.get(i).getSpecification().getFacet(ParseableFacet.class) == null) {
- // REVIEW restores object to loader
- context.getMappedObject(newEntry);
- }
- continue;
- }
-
- if (fields.get(i).getSpecification().containsFacet(ParseableFacet.class)) {
- final ParseableFacet facet = fields.get(i).getSpecification().getFacet(ParseableFacet.class);
- Localization localization = IsisContext.getLocalization();
- final ObjectAdapter newValue = facet.parseTextEntry(originalValue, newEntry, localization);
- ((OneToOneAssociation) fields.get(i)).set(object, newValue);
- } else {
- ((OneToOneAssociation) fields.get(i)).set(object, field.getValue());
- }
- }
- }
-
- @Override
- public void init() {
- }
-
- @Override
- public void debug(final DebugBuilder debug) {
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/edit/FieldEditState.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/edit/FieldEditState.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/edit/FieldEditState.java
deleted file mode 100644
index 70e6789..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/edit/FieldEditState.java
+++ /dev/null
@@ -1,57 +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.edit;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-
-public class FieldEditState {
- private final String entry;
- private String reason;
- private ObjectAdapter value;
-
- public FieldEditState(final String entry) {
- this.entry = entry;
- }
-
- public void setError(final String reason) {
- this.reason = reason;
- }
-
- public boolean isEntryValid() {
- return reason == null;
- }
-
- public String getEntry() {
- return entry;
- }
-
- public String getError() {
- return reason;
- }
-
- public ObjectAdapter getValue() {
- return value;
- }
-
- public void setValue(final ObjectAdapter value) {
- this.value = value;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/edit/FormState.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/edit/FormState.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/edit/FormState.java
deleted file mode 100644
index 7349837..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/edit/FormState.java
+++ /dev/null
@@ -1,67 +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.edit;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-public class FormState {
- private final Map<String, FieldEditState> fields = new HashMap<String, FieldEditState>();
- private String error;
- private String formId;
-
- public FieldEditState createField(final String name, final String entry) {
- final FieldEditState fieldEditState = new FieldEditState(entry);
- fields.put(name, fieldEditState);
- return fieldEditState;
- }
-
- public boolean isValid() {
- final Iterator<FieldEditState> iterator = fields.values().iterator();
- while (iterator.hasNext()) {
- if (!iterator.next().isEntryValid()) {
- return false;
- }
- }
- return error == null;
- }
-
- public FieldEditState getField(final String name) {
- return fields.get(name);
- }
-
- public void setError(final String error) {
- this.error = error;
- }
-
- public String getError() {
- return error;
- }
-
- public void setForm(final String formId) {
- this.formId = formId;
- }
-
- public boolean isForForm(final String formId) {
- return this.formId == null || this.formId.equals(formId);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/edit/RemoveAction.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/edit/RemoveAction.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/edit/RemoveAction.java
deleted file mode 100644
index 1bd86a2..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/edit/RemoveAction.java
+++ /dev/null
@@ -1,116 +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.edit;
-
-import java.io.IOException;
-
-import org.apache.isis.applib.annotation.Where;
-import org.apache.isis.core.commons.authentication.AnonymousSession;
-import org.apache.isis.core.commons.authentication.AuthenticationSession;
-import org.apache.isis.core.commons.debug.DebugBuilder;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
-import org.apache.isis.core.metamodel.spec.feature.OneToManyAssociation;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.viewer.scimpi.dispatcher.Action;
-import org.apache.isis.viewer.scimpi.dispatcher.ForbiddenException;
-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;
-
-/**
- * Remove an element from a collection.
- */
-public class RemoveAction implements Action {
- public static final String ACTION = "remove";
-
- // REVIEW: confirm this rendering context
- private final Where where = Where.OBJECT_FORMS;
-
- @Override
- public String getName() {
- return ACTION;
- }
-
- @Override
- public void process(final RequestContext context) throws IOException {
- AuthenticationSession session = context.getSession();
- if (session == null) {
- session = new AnonymousSession();
- }
-
- final String parentId = context.getParameter(OBJECT);
- final String rowId = context.getParameter(ELEMENT);
-
- try {
- final ObjectAdapter parent = context.getMappedObject(parentId);
- final ObjectAdapter row = context.getMappedObject(rowId);
-
- final String fieldName = context.getParameter(FIELD);
- final ObjectAssociation field = parent.getSpecification().getAssociation(fieldName);
- if (field == null) {
- throw new ScimpiException("No field " + fieldName + " in " + parent.getSpecification().getFullIdentifier());
- }
- if (field.isVisible(IsisContext.getAuthenticationSession(), parent, where).isVetoed()) {
- throw new ForbiddenException(field, ForbiddenException.VISIBLE);
- }
-
- ((OneToManyAssociation) field).removeElement(parent, row);
-
- // TODO duplicated in EditAction
- String view = context.getParameter(VIEW);
- final String override = context.getParameter(RESULT_OVERRIDE);
-
- String resultName = context.getParameter(RESULT_NAME);
- resultName = resultName == null ? RequestContext.RESULT : resultName;
-
- final String id = context.mapObject(parent, Scope.REQUEST);
- context.addVariable(resultName, id, Scope.REQUEST);
- if (override != null) {
- context.addVariable(resultName, override, Scope.REQUEST);
- }
-
- final int questionMark = view == null ? -1 : view.indexOf("?");
- if (questionMark > -1) {
- final String params = view.substring(questionMark + 1);
- final int equals = params.indexOf("=");
- context.addVariable(params.substring(0, equals), params.substring(equals + 1), Scope.REQUEST);
- view = view.substring(0, questionMark);
- }
- context.setRequestPath(view);
- // TODO end of duplication
-
- } catch (final RuntimeException e) {
- IsisContext.getMessageBroker().getMessages();
- IsisContext.getMessageBroker().getWarnings();
- IsisContext.getUpdateNotifier().clear();
- IsisContext.getUpdateNotifier().clear();
- throw e;
- }
- }
-
- @Override
- public void init() {
- }
-
- @Override
- public void debug(final DebugBuilder debug) {
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/logon/LogonAction.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/logon/LogonAction.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/logon/LogonAction.java
deleted file mode 100644
index 52a15fe..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/logon/LogonAction.java
+++ /dev/null
@@ -1,147 +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.logon;
-
-import java.io.IOException;
-import java.util.List;
-
-import org.apache.isis.applib.profiles.Localization;
-import org.apache.isis.core.commons.authentication.AuthenticationSession;
-import org.apache.isis.core.commons.debug.DebugBuilder;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.facets.object.parseable.ParseableFacet;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
-import org.apache.isis.core.metamodel.spec.feature.ObjectActionParameter;
-import org.apache.isis.core.runtime.authentication.AuthenticationRequestPassword;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.viewer.scimpi.dispatcher.Action;
-import org.apache.isis.viewer.scimpi.dispatcher.Dispatcher;
-import org.apache.isis.viewer.scimpi.dispatcher.ScimpiException;
-import org.apache.isis.viewer.scimpi.dispatcher.UserManager;
-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.util.MethodsUtils;
-
-
-// TODO this should work like EditAction so that logon page is repopulated
-public class LogonAction implements Action {
-
- @Override
- public void process(final RequestContext context) throws IOException {
- final String username = context.getParameter("username");
- final String password = context.getParameter("password");
- final String actualFormId = context.getParameter("_" + FORM_ID);
- final String expectedFormId = context.getParameter(LOGON_FORM_ID);
- boolean isDomainLogon = expectedFormId != null && expectedFormId.equals(actualFormId);
- boolean isValid;
-
- AuthenticationSession session = null;
- if (username.length() == 0 || password.length() == 0) {
- isValid = false;
- } else {
- if (isDomainLogon) {
- final String objectId = context.getParameter(LOGON_OBJECT);
- final String scope = context.getParameter(LOGON_SCOPE);
- final String methodName = context.getParameter(LOGON_METHOD);
- String resultName = context.getParameter(LOGON_RESULT_NAME);
- resultName = resultName == null ? "_" + USER : resultName;
-
- final ObjectAdapter object = MethodsUtils.findObject(context, objectId);
- final ObjectAction action = MethodsUtils.findAction(object, methodName);
- final int parameterCount = action.getParameterCount();
- final ObjectAdapter[] parameters = new ObjectAdapter[parameterCount];
- List<ObjectActionParameter> parameters2 = action.getParameters();
- if (parameters.length != 2) {
- throw new ScimpiException("Expected two parameters for the log-on method: " + methodName);
- }
-
- Localization localization = IsisContext.getLocalization();
- ParseableFacet facet = parameters2.get(0).getSpecification().getFacet(ParseableFacet.class);
- parameters[0] = facet.parseTextEntry(null, username, localization);
- facet = parameters2.get(1).getSpecification().getFacet(ParseableFacet.class);
- parameters[1] = facet.parseTextEntry(null, password, localization);
- final ObjectAdapter result = action.execute(object, parameters);
- isValid = result != null;
- if (isValid) {
- Scope scope2 = scope == null ? Scope.SESSION : RequestContext.scope(scope);
- final String resultId = context.mapObject(result, scope2);
- context.addVariable(resultName, resultId, scope);
- context.addVariable("_username", username, Scope.SESSION);
-
- context.clearVariable(LOGON_OBJECT, Scope.SESSION);
- context.clearVariable(LOGON_METHOD, Scope.SESSION);
- context.clearVariable(LOGON_RESULT_NAME, Scope.SESSION);
- context.clearVariable(LOGON_SCOPE, Scope.SESSION);
- context.clearVariable(PREFIX + "isis-user", Scope.SESSION);
- context.clearVariable(LOGON_FORM_ID, Scope.SESSION);
- }
- session = context.getSession();
- } else {
- session = UserManager.authenticate(new AuthenticationRequestPassword(username, password));
- isValid = session != null;
- }
- }
-
- String view;
- if (!isValid) {
- final FormState formState = new FormState();
- formState.setForm(actualFormId);
- formState.setError("Failed to login. Check the username and ensure that your password was entered correctly");
- FieldEditState fieldState = formState.createField("username", username);
- if (username.length() == 0) {
- fieldState.setError("User Name required");
- }
- fieldState = formState.createField("password", password);
- if (password.length() == 0) {
- fieldState.setError("Password required");
- }
- if (username.length() == 0 || password.length() == 0) {
- formState.setError("Both the user name and password must be entered");
- }
- context.addVariable(ENTRY_FIELDS, formState, Scope.REQUEST);
-
- view = context.getParameter(ERROR);
- context.setRequestPath("/" + view, Dispatcher.ACTION);
- } else {
- context.setSession(session);
- context.startHttpSession();
- context.setUserAuthenticated(true);
- view = context.getParameter(VIEW);
- if (view == null) {
- // REVIEW this is duplicated in Logon.java
- view = "start." + Dispatcher.EXTENSION;
- }
- context.redirectTo(view);
- }
- }
-
- @Override
- public String getName() {
- return "logon";
- }
-
- @Override
- public void init() {}
-
- @Override
- public void debug(final DebugBuilder debug) {}
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/logon/LogoutAction.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/logon/LogoutAction.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/logon/LogoutAction.java
deleted file mode 100644
index 219b5b4..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/logon/LogoutAction.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.logon;
-
-import java.io.IOException;
-
-import org.apache.isis.core.commons.authentication.AuthenticationSession;
-import org.apache.isis.core.commons.debug.DebugBuilder;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.viewer.scimpi.dispatcher.Action;
-import org.apache.isis.viewer.scimpi.dispatcher.UserManager;
-import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext;
-import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext.Scope;
-
-public class LogoutAction implements Action {
-
- public static void logoutUser(final RequestContext context) {
- if (context.isUserAuthenticated()) {
- final AuthenticationSession session = context.getSession();
- if (session != null) {
- IsisContext.getUpdateNotifier().clear();
- UserManager.logoffUser(session);
- }
- context.endHttpSession();
- context.setUserAuthenticated(false);
- }
- context.clearVariables(Scope.SESSION);
- }
-
- @Override
- public String getName() {
- return "logout";
- }
-
- @Override
- public void init() {
- }
-
- @Override
- public void process(final RequestContext context) throws IOException {
- logoutUser(context);
-
- String view = context.getParameter("view");
- if (view == null) {
- view = context.getContextPath();
- }
- context.redirectTo(view);
- }
-
- @Override
- public void debug(final DebugBuilder debug) {
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/Attributes.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/Attributes.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/Attributes.java
new file mode 100644
index 0000000..86fd17e
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/Attributes.java
@@ -0,0 +1,132 @@
+/*
+ * 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.processor;
+
+import java.util.Enumeration;
+import java.util.Vector;
+
+import org.htmlparser.Attribute;
+import org.htmlparser.nodes.TagNode;
+
+import org.apache.isis.viewer.scimpi.dispatcher.context.PropertyException;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+
+public class Attributes {
+ private static final String TRUE = " true yes on ";
+ private static final String FALSE = " false no off ";
+ private final TagNode tagNode;
+ private final Request context;
+
+ public Attributes(final TagNode tagNode, final Request context) {
+ this.tagNode = tagNode;
+ this.context = context;
+ }
+
+ public boolean isPropertySet(final String name) {
+ final String attribute = tagNode.getAttribute(name);
+ int end = attribute.length() - 1;
+ final int pos = attribute.indexOf(':');
+ end = pos == -1 ? end : pos;
+ final String variabelName = attribute.substring(2, end);
+ final Object value = context.getVariable(variabelName);
+ return value != null;
+ // return attribute != null &&
+ // !context.replaceVariables(attribute).equals("");
+ }
+
+ public boolean isPropertySpecified(final String name) {
+ final String attribute = tagNode.getAttribute(name);
+ return attribute != null;
+ }
+
+ public String getOptionalProperty(final String name, final boolean ensureVariablesExists) {
+ return getOptionalProperty(name, null, ensureVariablesExists);
+ }
+
+ public String getOptionalProperty(final String name, final String defaultValue, final boolean ensureVariablesExists) {
+ final String attribute = tagNode.getAttribute(name);
+ return attribute == null ? defaultValue : context.replaceVariables(attribute);
+ }
+
+ public String getRequiredProperty(final String name, final boolean ensureVariablesExists) {
+ final String attribute = tagNode.getAttribute(name);
+ if (attribute == null) {
+ throw new RequiredPropertyException("Missing property: " + name);
+ } else if (attribute.equals("")) {
+ throw new RequiredPropertyException("Property not set: " + name);
+ } else {
+ return context.replaceVariables(attribute);
+ }
+ }
+
+ public String[] getPropertyNames(final String excluding[]) {
+ final Vector attributes = tagNode.getAttributesEx();
+ final String[] names = new String[attributes.size()];
+ int i = 0;
+ names: for (final Enumeration e = attributes.elements(); e.hasMoreElements();) {
+ final String name = ((Attribute) e.nextElement()).getName();
+ if (name == null) {
+ continue;
+ }
+ for (int j = 0; j < excluding.length; j++) {
+ if (name.equals(excluding[j])) {
+ continue names;
+ }
+ }
+ if (tagNode.getAttribute(name) != null) {
+ names[i++] = name;
+ }
+ }
+
+ final String[] array = new String[i];
+ System.arraycopy(names, 0, array, 0, i);
+ return array;
+ }
+
+ @Override
+ public String toString() {
+ return tagNode.toHtml(); // getAttributesEx().toString();
+ }
+
+ public boolean isRequested(final String name) {
+ return isRequested(name, false);
+ }
+
+ public boolean isRequested(final String name, final boolean defaultValue) {
+ final String flag = getOptionalProperty(name, true);
+ if (flag == null) {
+ return defaultValue;
+ } else {
+ return isTrue(flag);
+ }
+ }
+
+ public static boolean isTrue(final String flag) {
+ final String value = " " + flag.toLowerCase().trim() + " ";
+ if (TRUE.indexOf(value) >= 0) {
+ return true;
+ } else if (FALSE.indexOf(value) >= 0) {
+ return false;
+ } else {
+ throw new PropertyException("Illegal flag value: " + flag);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/BlockContent.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/BlockContent.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/BlockContent.java
new file mode 100644
index 0000000..0d91bdf
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/BlockContent.java
@@ -0,0 +1,23 @@
+/*
+ * 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.processor;
+
+public interface BlockContent {
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/ElementContentProcessor.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/ElementContentProcessor.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/ElementContentProcessor.java
new file mode 100644
index 0000000..65e0bcf
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/ElementContentProcessor.java
@@ -0,0 +1,25 @@
+/*
+ * 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.processor;
+
+
+public interface ElementContentProcessor extends ElementProcessor {
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/ElementProcessor.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/ElementProcessor.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/ElementProcessor.java
new file mode 100644
index 0000000..37fa0e1
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/ElementProcessor.java
@@ -0,0 +1,29 @@
+/*
+ * 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.processor;
+
+
+public interface ElementProcessor {
+
+ String getName();
+
+ void process(TagProcessor tagProcessor);
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/HtmlFileParser.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/HtmlFileParser.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/HtmlFileParser.java
index c7f2476..354af87 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/HtmlFileParser.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/HtmlFileParser.java
@@ -33,13 +33,8 @@ import org.htmlparser.lexer.Page;
import org.htmlparser.nodes.TagNode;
import org.htmlparser.util.ParserException;
-import org.apache.isis.viewer.scimpi.dispatcher.ElementProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.ScimpiException;
-import org.apache.isis.viewer.scimpi.dispatcher.action.Attributes;
-import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext;
-import org.apache.isis.viewer.scimpi.dispatcher.view.HtmlSnippet;
-import org.apache.isis.viewer.scimpi.dispatcher.view.Snippet;
-import org.apache.isis.viewer.scimpi.dispatcher.view.SwfTag;
+import org.apache.isis.viewer.scimpi.ScimpiException;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
public class HtmlFileParser {
private static final Logger LOG = Logger.getLogger(HtmlFileParser.class);
@@ -49,14 +44,14 @@ public class HtmlFileParser {
this.processors = processors;
}
- public Stack<Snippet> parseHtmlFile(final String filePath, final RequestContext context) {
+ public Stack<Snippet> parseHtmlFile(final String filePath, final Request context) {
final Stack<Snippet> tagsBeforeContent = new Stack<Snippet>();
final Stack<Snippet> tagsAfterContent = new Stack<Snippet>();
parseHtmlFile("/", filePath, context, tagsBeforeContent, tagsAfterContent);
return tagsBeforeContent;
}
- public void parseHtmlFile(final String parentPath, final String filePath, final RequestContext context, final Stack<Snippet> allTags, final Stack<Snippet> tagsForPreviousTemplate) {
+ public void parseHtmlFile(final String parentPath, final String filePath, final Request context, final Stack<Snippet> allTags, final Stack<Snippet> tagsForPreviousTemplate) {
LOG.debug("parent/file: " + parentPath + " & " + filePath);
final File directory = filePath.startsWith("/") ? new File(".") : new File(parentPath);
final File loadFile = new File(directory.getParentFile(), filePath);
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/HtmlSnippet.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/HtmlSnippet.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/HtmlSnippet.java
new file mode 100644
index 0000000..2e98c71
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/HtmlSnippet.java
@@ -0,0 +1,51 @@
+/*
+ * 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.processor;
+
+public class HtmlSnippet implements Snippet {
+ private final StringBuffer html = new StringBuffer();
+ private boolean containsVariable;
+ private final String lineNumbers;
+ private final String path;
+
+ public HtmlSnippet(final String lineNumbers, final String path) {
+ this.lineNumbers = lineNumbers;
+ this.path = path;
+ }
+
+ public void append(final String html) {
+ this.html.append(html);
+ containsVariable |= html.indexOf("${") >= 0;
+ }
+
+ @Override
+ public String getHtml() {
+ return html.toString();
+ }
+
+ public boolean isContainsVariable() {
+ return containsVariable;
+ }
+
+ @Override
+ public String errorAt() {
+ return path + ":" + lineNumbers;
+ }
+}
[21/24] Restructuring Scimpi to remove dependencies and enable easier
testing.
Posted by rm...@apache.org.
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/collection/Collection.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/collection/Collection.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/collection/Collection.java
index 20e0cc9..e139836 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/collection/Collection.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/collection/Collection.java
@@ -27,22 +27,23 @@ import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
import org.apache.isis.core.runtime.system.context.IsisContext;
import org.apache.isis.viewer.scimpi.ScimpiException;
import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor.RepeatMarker;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor.RepeatMarker;
import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public class Collection extends AbstractElementProcessor {
@Override
- public void process(final TagProcessor tagProcessor) {
- final Request context = tagProcessor.getContext();
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ final Request context = templateProcessor.getContext();
ObjectAdapter collection;
- final String field = tagProcessor.getOptionalProperty(FIELD);
+ final String field = templateProcessor.getOptionalProperty(FIELD);
if (field != null) {
- final String id = tagProcessor.getOptionalProperty(OBJECT);
+ final String id = templateProcessor.getOptionalProperty(OBJECT);
final ObjectAdapter object = context.getMappedObjectOrResult(id);
final ObjectAssociation objectField = object.getSpecification().getAssociation(field);
if (!objectField.isOneToManyAssociation()) {
@@ -51,16 +52,16 @@ public class Collection extends AbstractElementProcessor {
IsisContext.getPersistenceSession().resolveField(object, objectField);
collection = objectField.get(object);
} else {
- final String id = tagProcessor.getOptionalProperty(COLLECTION);
+ final String id = templateProcessor.getOptionalProperty(COLLECTION);
collection = context.getMappedObjectOrResult(id);
}
- final RepeatMarker marker = tagProcessor.createMarker();
+ final RepeatMarker marker = templateProcessor.createMarker();
- final String variable = tagProcessor.getOptionalProperty(ELEMENT_NAME);
- final String scopeName = tagProcessor.getOptionalProperty(SCOPE);
+ final String variable = templateProcessor.getOptionalProperty(ELEMENT_NAME);
+ final String scopeName = templateProcessor.getOptionalProperty(SCOPE);
final Scope scope = Request.scope(scopeName, Scope.REQUEST);
- final String rowClassesList = tagProcessor.getOptionalProperty(ROW_CLASSES, ODD_ROW_CLASS + "|" + EVEN_ROW_CLASS);
+ final String rowClassesList = templateProcessor.getOptionalProperty(ROW_CLASSES, ODD_ROW_CLASS + "|" + EVEN_ROW_CLASS);
String[] rowClasses = new String[0];
if (rowClassesList != null) {
rowClasses = rowClassesList.split("[,|/]");
@@ -68,7 +69,7 @@ public class Collection extends AbstractElementProcessor {
final CollectionFacet facet = collection.getSpecification().getFacet(CollectionFacet.class);
if (facet.size(collection) == 0) {
- tagProcessor.skipUntilClose();
+ templateProcessor.skipUntilClose();
} else {
final Iterator<ObjectAdapter> iterator = facet.iterator(collection);
int row = 0;
@@ -80,7 +81,7 @@ public class Collection extends AbstractElementProcessor {
}
context.addVariable(variable, context.mapObject(element, scope), scope);
marker.repeat();
- tagProcessor.processUtilCloseTag();
+ templateProcessor.processUtilCloseTag();
row++;
}
}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/collection/CountElements.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/collection/CountElements.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/collection/CountElements.java
new file mode 100644
index 0000000..086977d
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/collection/CountElements.java
@@ -0,0 +1,54 @@
+/*
+ * 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.collection;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacet;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractObjectProcessor;
+
+public class CountElements extends AbstractObjectProcessor {
+
+ @Override
+ protected void process(final TemplateProcessor templateProcessor, final ObjectAdapter collection) {
+ final CollectionFacet facet = collection.getSpecification().getFacet(CollectionFacet.class);
+ final int size = facet.size(collection);
+ if (size == 0) {
+ templateProcessor.appendHtml(templateProcessor.getOptionalProperty("none", "0"));
+ } else if (size == 1) {
+ templateProcessor.appendHtml(templateProcessor.getOptionalProperty("one", "1"));
+ } else {
+ final String text = templateProcessor.getOptionalProperty("many", "" + size);
+ templateProcessor.appendHtml(String.format(text, size));
+ }
+ }
+
+ @Override
+ protected String checkFieldType(final ObjectAssociation objectField) {
+ return objectField.isOneToManyAssociation() ? null : "must be a collection";
+ }
+
+ @Override
+ public String getName() {
+ return "count";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/collection/ElementType.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/collection/ElementType.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/collection/ElementType.java
new file mode 100644
index 0000000..8038658
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/collection/ElementType.java
@@ -0,0 +1,62 @@
+/*
+ * 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.collection;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
+import org.apache.isis.viewer.scimpi.ScimpiException;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+public class ElementType extends AbstractElementProcessor {
+
+ @Override
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ ObjectAdapter collection;
+ final String field = templateProcessor.getOptionalProperty(FIELD);
+ final Request context = templateProcessor.getContext();
+ if (field != null) {
+ final String id = templateProcessor.getRequiredProperty(OBJECT);
+ final ObjectAdapter object = context.getMappedObjectOrResult(id);
+ final ObjectAssociation objectField = object.getSpecification().getAssociation(field);
+ if (!objectField.isOneToManyAssociation()) {
+ throw new ScimpiException("Field " + objectField.getId() + " is not a collection");
+ }
+ collection = objectField.get(object);
+ } else {
+ final String id = templateProcessor.getOptionalProperty(COLLECTION);
+ collection = context.getMappedObjectOrResult(id);
+ }
+
+ final ObjectSpecification elementSpecification = collection.getElementSpecification();
+ final String name = elementSpecification.getSingularName();
+
+ templateProcessor.appendAsHtmlEncoded(name);
+ }
+
+ @Override
+ public String getName() {
+ return "element-type";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/collection/ListView.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/collection/ListView.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/collection/ListView.java
new file mode 100644
index 0000000..1e4627b
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/collection/ListView.java
@@ -0,0 +1,93 @@
+/*
+ * 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.collection;
+
+import java.util.Iterator;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacet;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
+import org.apache.isis.viewer.scimpi.Names;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractObjectProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.determine.LinkedObject;
+
+public class ListView extends AbstractObjectProcessor {
+
+ @Override
+ public String checkFieldType(final ObjectAssociation objectField) {
+ return objectField.isOneToManyAssociation() ? null : "is not a collection";
+ }
+
+ @Override
+ public void process(final TemplateProcessor templateProcessor, final ObjectAdapter object) {
+ final String linkRowView = templateProcessor.getOptionalProperty(LINK_VIEW);
+ final String linkObjectName = templateProcessor.getOptionalProperty(ELEMENT_NAME, Names.RESULT);
+ final String linkObjectScope = templateProcessor.getOptionalProperty(SCOPE, Scope.INTERACTION.toString());
+ LinkedObject linkedRow = null;
+ if (linkRowView != null) {
+ linkedRow = new LinkedObject(linkObjectName, linkObjectScope, templateProcessor.getContext().fullUriPath(linkRowView));
+ }
+ final String bulletType = templateProcessor.getOptionalProperty("type");
+ write(templateProcessor, object, linkedRow, bulletType);
+ }
+
+ public static void write(final TemplateProcessor templateProcessor, final ObjectAdapter collection, final LinkedObject linkRow, final String bulletType) {
+
+ if (bulletType == null) {
+ templateProcessor.appendHtml("<ol>");
+ } else {
+ templateProcessor.appendHtml("<ul type=\"" + bulletType + "\">");
+ }
+
+ final CollectionFacet facet = collection.getSpecification().getFacet(CollectionFacet.class);
+ final Iterator<ObjectAdapter> iterator = facet.iterator(collection);
+ while (iterator.hasNext()) {
+ final ObjectAdapter element = iterator.next();
+
+ templateProcessor.appendHtml("<li>");
+ if (linkRow != null) {
+ final Scope scope = linkRow == null ? Scope.INTERACTION : Request.scope(linkRow.getScope());
+ final String rowId = templateProcessor.getContext().mapObject(element, scope);
+ templateProcessor.appendHtml("<a class=\"item-select\" href=\"" + linkRow.getForwardView() + "?" + linkRow.getVariable() + "=" + rowId + "\">");
+ }
+ templateProcessor.appendAsHtmlEncoded(element.titleString());
+ if (linkRow != null) {
+ templateProcessor.appendHtml("</a>");
+ }
+
+ templateProcessor.appendHtml("</li>\n");
+ }
+ if (bulletType == null) {
+ templateProcessor.appendHtml("</ol>");
+ } else {
+ templateProcessor.appendHtml("</ul>");
+ }
+
+ }
+
+ @Override
+ public String getName() {
+ return "list";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/collection/RemoveElement.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/collection/RemoveElement.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/collection/RemoveElement.java
new file mode 100644
index 0000000..0d3830e
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/collection/RemoveElement.java
@@ -0,0 +1,144 @@
+/*
+ * 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.collection;
+
+import java.util.List;
+
+import org.apache.isis.applib.annotation.Where;
+import org.apache.isis.applib.filter.Filter;
+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.spec.feature.ObjectAssociation;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociationFilters;
+import org.apache.isis.core.metamodel.spec.feature.OneToManyAssociation;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.viewer.scimpi.ForbiddenException;
+import org.apache.isis.viewer.scimpi.Names;
+import org.apache.isis.viewer.scimpi.ScimpiException;
+import org.apache.isis.viewer.scimpi.dispatcher.action.RemoveAction;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.util.MethodsUtils;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+public class RemoveElement extends AbstractElementProcessor {
+
+ // 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 static Where where = Where.ANYWHERE;
+
+ @Override
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ final String title = templateProcessor.getOptionalProperty(BUTTON_TITLE, "Remove From List");
+ final String cls = templateProcessor.getOptionalProperty(CLASS, "action in-line delete confirm");
+ final String object = templateProcessor.getOptionalProperty(OBJECT);
+ final String resultOverride = templateProcessor.getOptionalProperty(RESULT_OVERRIDE);
+ final Request context = templateProcessor.getContext();
+ final String objectId = object != null ? object : (String) context.getVariable(Names.RESULT);
+ final ObjectAdapter adapter = MethodsUtils.findObject(context, objectId);
+
+ final String element = templateProcessor.getOptionalProperty(ELEMENT, (String) context.getVariable(ELEMENT));
+ final ObjectAdapter elementId = MethodsUtils.findObject(context, element);
+
+ final String fieldName = templateProcessor.getRequiredProperty(FIELD);
+
+ String view = templateProcessor.getOptionalProperty(VIEW);
+ view = context.fullFilePath(view == null ? context.getResourceFile() : view);
+ String error = templateProcessor.getOptionalProperty(ERROR);
+ error = context.fullFilePath(error == null ? context.getResourceFile() : error);
+
+ templateProcessor.processUtilCloseTag();
+
+ write(templateProcessor, adapter, fieldName, elementId, resultOverride, view, error, title, cls);
+ }
+
+ @Override
+ public String getName() {
+ return "remove-element";
+ }
+
+ public static void write(final TemplateProcessor templateProcessor, final ObjectAdapter adapter, final String fieldName, final ObjectAdapter element, final String resultOverride, final String view, final String error, final String title, final String cssClass) {
+ final ObjectAssociation field = adapter.getSpecification().getAssociation(fieldName);
+ if (field == null) {
+ throw new ScimpiException("No field " + fieldName + " in " + adapter.getSpecification().getFullIdentifier());
+ }
+ if (!field.isOneToManyAssociation()) {
+ throw new ScimpiException("Field " + fieldName + " not a collection, in " + adapter.getSpecification().getFullIdentifier());
+ }
+ if (field.isVisible(IsisContext.getAuthenticationSession(), adapter, where).isVetoed()) {
+ throw new ForbiddenException(field, ForbiddenException.VISIBLE);
+ }
+ IsisContext.getPersistenceSession().resolveField(adapter, field);
+
+ Consent usable = field.isUsable(IsisContext.getAuthenticationSession(), adapter, where);
+ if (usable.isAllowed()) {
+ usable = ((OneToManyAssociation) field).isValidToRemove(adapter, element);
+ }
+
+ if (usable.isVetoed()) {
+ templateProcessor.appendHtml("<div class=\"" + cssClass + " disabled-form\">");
+ templateProcessor.appendHtml("<div class=\"button disabled\" title=\"");
+ templateProcessor.appendAsHtmlEncoded(usable.getReason());
+ templateProcessor.appendHtml("\" >" + title);
+ templateProcessor.appendHtml("</div>");
+ templateProcessor.appendHtml("</div>");
+ } else {
+ if (valid(templateProcessor, adapter)) {
+ final String classSegment = " class=\"" + cssClass + "\"";
+
+ final String objectId = templateProcessor.getContext().mapObject(adapter, Scope.INTERACTION);
+ final String elementId = templateProcessor.getContext().mapObject(element, Scope.INTERACTION);
+ final String action = RemoveAction.ACTION + Names.COMMAND_ROOT;
+ templateProcessor.appendHtml("<form" + classSegment + " method=\"post\" action=\"" + action + "\" >");
+ templateProcessor.appendHtml("<input type=\"hidden\" name=\"" + OBJECT + "\" value=\"" + objectId + "\" />");
+ templateProcessor.appendHtml("<input type=\"hidden\" name=\"" + FIELD + "\" value=\"" + fieldName + "\" />");
+ templateProcessor.appendHtml("<input type=\"hidden\" name=\"" + ELEMENT + "\" value=\"" + elementId + "\" />");
+ if (resultOverride != null) {
+ templateProcessor.appendHtml("<input type=\"hidden\" name=\"" + RESULT_OVERRIDE + "\" value=\"" + resultOverride + "\" />");
+ }
+ templateProcessor.appendHtml("<input type=\"hidden\" name=\"" + VIEW + "\" value=\"" + view + "\" />");
+ templateProcessor.appendHtml("<input type=\"hidden\" name=\"" + ERROR + "\" value=\"" + error + "\" />");
+ templateProcessor.appendHtml(templateProcessor.getContext().interactionFields());
+ templateProcessor.appendHtml("<input class=\"button\" type=\"submit\" value=\"" + title + "\" />");
+ templateProcessor.appendHtml("</form>");
+ }
+ }
+ }
+
+ private static boolean valid(final TemplateProcessor templateProcessor, final ObjectAdapter adapter) {
+ // TODO is this check valid/necessary?
+
+ // TODO check is valid to remove element
+ final AuthenticationSession session = IsisContext.getAuthenticationSession();
+ final Filter<ObjectAssociation> filter = ObjectAssociationFilters.dynamicallyVisible(session, adapter, where);
+ final List<ObjectAssociation> visibleFields = adapter.getSpecification().getAssociations(filter);
+ if (visibleFields.size() == 0) {
+ return false;
+ }
+
+ return true;
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/collection/TableBlock.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/collection/TableBlock.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/collection/TableBlock.java
new file mode 100644
index 0000000..7671317
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/collection/TableBlock.java
@@ -0,0 +1,86 @@
+/*
+ * 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.collection;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.BlockContent;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor.RepeatMarker;
+
+public class TableBlock implements BlockContent {
+
+ // {{ collection
+ private ObjectAdapter collection;
+
+ public void setCollection(final ObjectAdapter collection) {
+ this.collection = collection;
+ }
+
+ public ObjectAdapter getCollection() {
+ return collection;
+ }
+ // }}
+
+ // {{ linkView
+ private String linkView;
+
+ public String getlinkView() {
+ return linkView;
+ }
+
+ public void setlinkView(final String linkView) {
+ this.linkView = linkView;
+ }
+ // }}
+
+ // {{ linkName
+ private String linkName;
+
+ public String getlinkName() {
+ return linkName;
+ }
+
+ public void setlinkName(final String linkName) {
+ this.linkName = linkName;
+ }
+ // }}
+
+ // {{ elementName
+ private String elementName;
+
+ public String getElementName() {
+ return elementName;
+ }
+
+ public void setElementName(final String linkObject) {
+ this.elementName = linkObject;
+ }
+ // }}
+
+ private RepeatMarker marker;
+
+ public RepeatMarker getMarker() {
+ return marker;
+ }
+
+ public void setMarker(final RepeatMarker marker) {
+ this.marker = marker;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/collection/TableBuilder.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/collection/TableBuilder.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/collection/TableBuilder.java
new file mode 100644
index 0000000..7809e74
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/collection/TableBuilder.java
@@ -0,0 +1,92 @@
+/*
+ * 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.collection;
+
+import java.util.List;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.PageWriter;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor.RepeatMarker;
+
+public class TableBuilder extends AbstractTableView {
+
+ @Override
+ protected TableContentWriter createRowBuilder(final TemplateProcessor templateProcessor, final Request context, final String parent, final List<ObjectAssociation> allFields, final ObjectAdapter collection) {
+
+ final String title = templateProcessor.getOptionalProperty(TABLE_TITLE);
+ final String variable = templateProcessor.getOptionalProperty(ELEMENT_NAME, ELEMENT);
+ final String headerClass = templateProcessor.getOptionalProperty("head-" + CLASS);
+
+ final TableBlock block = new TableBlock();
+ block.setCollection(collection);
+ block.setElementName(variable);
+ templateProcessor.pushBlock(block);
+ templateProcessor.pushNewBuffer();
+ templateProcessor.processUtilCloseTag();
+ final String headers = templateProcessor.popBuffer();
+ return new TableContentWriter() {
+
+ @Override
+ public void writeFooters(final PageWriter writer) {
+ }
+
+ public void tidyUp() {
+ templateProcessor.popBlock();
+ }
+
+ @Override
+ public void writeCaption(PageWriter writer) {
+ if (title != null) {
+ writer.appendHtml("<caption>");
+ writer.appendHtml(title);
+ writer.appendHtml("</thead>");
+ }
+ }
+
+ @Override
+ public void writeHeaders(final PageWriter writer) {
+ final String headerSegment = headerClass == null ? "" : (" class=\"" + headerClass + "\"");
+ writer.appendHtml("<thead" + headerSegment + ">");
+ writer.appendHtml(headers);
+ writer.appendHtml("</thead>");
+ }
+
+ @Override
+ public void writeElement(final TemplateProcessor templateProcessor, final Request context, final ObjectAdapter element) {
+ context.addVariable(variable, context.mapObject(element, Scope.REQUEST), Scope.REQUEST);
+ final RepeatMarker end = templateProcessor.createMarker();
+ final RepeatMarker marker = block.getMarker();
+ marker.repeat();
+ templateProcessor.processUtilCloseTag();
+ end.repeat();
+ }
+ };
+ }
+
+ @Override
+ public String getName() {
+ return "table-builder";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/collection/TableCell.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/collection/TableCell.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/collection/TableCell.java
new file mode 100644
index 0000000..9160a0a
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/collection/TableCell.java
@@ -0,0 +1,96 @@
+/*
+ * 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.collection;
+
+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.Names;
+import org.apache.isis.viewer.scimpi.ScimpiException;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+public class TableCell extends AbstractElementProcessor {
+
+ // REVIEW: should provide this rendering context, rather than hardcoding.
+ // the net effect currently is that class members annotated with
+ // @Hidden(where=Where.ALL_TABLES) or @Disabled(where=Where.ALL_TABLES) will indeed
+ // be hidden from all tables but will be visible/enabled (perhaps incorrectly)
+ // if annotated with Where.PARENTED_TABLE or Where.STANDALONE_TABLE
+ private final Where where = Where.ALL_TABLES;
+
+ @Override
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ final TableBlock tableBlock = (TableBlock) templateProcessor.peekBlock();
+ final String id = templateProcessor.getOptionalProperty(OBJECT);
+ final String fieldName = templateProcessor.getRequiredProperty(FIELD);
+ final String linkView = templateProcessor.getOptionalProperty(LINK_VIEW);
+ String className = templateProcessor.getOptionalProperty(CLASS);
+ className = className == null ? "" : " class=\"" + className + "\"";
+ Request context = templateProcessor.getContext();
+ final ObjectAdapter object = context.getMappedObjectOrVariable(id, tableBlock.getElementName());
+ final ObjectAssociation field = object.getSpecification().getAssociation(fieldName);
+ if (field == null) {
+ throw new ScimpiException("No field " + fieldName + " in " + object.getSpecification().getFullIdentifier());
+ }
+ templateProcessor.appendHtml("<td" + className + ">");
+ if (field.isVisible(IsisContext.getAuthenticationSession(), object, where).isAllowed()) {
+ final ObjectAdapter fieldReference = field.get(object);
+ final String source = fieldReference == null ? "" : context.mapObject(fieldReference, Scope.REQUEST);
+ final String name = templateProcessor.getOptionalProperty(RESULT_NAME, fieldName);
+ context.addVariable(name, templateProcessor.encodeHtml(source), Scope.REQUEST);
+
+ if (linkView != null) {
+ final String linkId = context.mapObject(object, Scope.REQUEST);
+ final String linkName = templateProcessor.getOptionalProperty(LINK_NAME, Names.RESULT);
+ final String linkObject = templateProcessor.getOptionalProperty(LINK_OBJECT, linkId);
+ templateProcessor.appendHtml("<a href=\"" + linkView + "?" + linkName + "=" + linkObject + context.encodedInteractionParameters() + "\">");
+ } else if(tableBlock.getlinkView() != null) {
+ String linkObjectInVariable = tableBlock.getElementName();
+ final String linkId = (String) context.getVariable(linkObjectInVariable);
+ templateProcessor.appendHtml("<a href=\"" + tableBlock.getlinkView() + "?" + tableBlock.getlinkName() + "=" + linkId + context.encodedInteractionParameters() + "\">");
+ }
+ templateProcessor.pushNewBuffer();
+ templateProcessor.processUtilCloseTag();
+ final String buffer = templateProcessor.popBuffer();
+ if (buffer.trim().length() == 0) {
+ templateProcessor.appendAsHtmlEncoded(fieldReference == null ? "" : fieldReference.titleString());
+ } else {
+ templateProcessor.appendHtml(buffer);
+ }
+ if (linkView != null) {
+ templateProcessor.appendHtml("</a>");
+ }
+ } else {
+ templateProcessor.skipUntilClose();
+ }
+ templateProcessor.appendHtml("</td>");
+ }
+
+ @Override
+ public String getName() {
+ return "table-cell";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/collection/TableContentWriter.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/collection/TableContentWriter.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/collection/TableContentWriter.java
new file mode 100644
index 0000000..5683264
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/collection/TableContentWriter.java
@@ -0,0 +1,39 @@
+/*
+ * 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.collection;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.PageWriter;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+
+public interface TableContentWriter {
+
+ void writeCaption(PageWriter writer);
+
+ void writeHeaders(PageWriter writer);
+
+ void writeFooters(PageWriter writer);
+
+ void writeElement(TemplateProcessor templateProcessor, Request context, ObjectAdapter element);
+
+ void tidyUp();
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/collection/TableEmpty.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/collection/TableEmpty.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/collection/TableEmpty.java
new file mode 100644
index 0000000..4b918bc
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/collection/TableEmpty.java
@@ -0,0 +1,54 @@
+/*
+ * 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.collection;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacet;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+public class TableEmpty extends AbstractElementProcessor {
+
+ @Override
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ final TableBlock tableBlock = (TableBlock) templateProcessor.peekBlock();
+ final ObjectAdapter collection = tableBlock.getCollection();
+ final CollectionFacet facet = collection.getSpecification().getFacet(CollectionFacet.class);
+ if (facet.size(collection) == 0) {
+ String className = templateProcessor.getOptionalProperty(CLASS);
+ className = className == null ? "" : " class=\"" + className + "\"";
+ templateProcessor.appendHtml("<tr" + className + ">");
+ templateProcessor.pushNewBuffer();
+ templateProcessor.processUtilCloseTag();
+ final String buffer = templateProcessor.popBuffer();
+ templateProcessor.appendHtml(buffer);
+ templateProcessor.appendHtml("</td>");
+ } else {
+ templateProcessor.skipUntilClose();
+ }
+ }
+
+ @Override
+ public String getName() {
+ return "table-empty";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/collection/TableHeader.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/collection/TableHeader.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/collection/TableHeader.java
new file mode 100644
index 0000000..c3d15f4
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/collection/TableHeader.java
@@ -0,0 +1,40 @@
+/*
+ * 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.collection;
+
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+public class TableHeader extends AbstractElementProcessor {
+
+ @Override
+ public String getName() {
+ return "table-header";
+ }
+
+ @Override
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ templateProcessor.appendHtml("<thead><tr>");
+ templateProcessor.processUtilCloseTag();
+ templateProcessor.appendHtml("</tr></thead>");
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/collection/TableRow.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/collection/TableRow.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/collection/TableRow.java
new file mode 100644
index 0000000..46b7c03
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/collection/TableRow.java
@@ -0,0 +1,50 @@
+/*
+ * 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.collection;
+
+import org.apache.isis.viewer.scimpi.Names;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor.RepeatMarker;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+public class TableRow extends AbstractElementProcessor {
+
+ @Override
+ public String getName() {
+ return "table-row";
+ }
+
+ @Override
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ final TableBlock block = (TableBlock) templateProcessor.peekBlock();
+
+ final RepeatMarker start = templateProcessor.createMarker();
+ block.setMarker(start);
+
+ final String linkView = templateProcessor.getOptionalProperty(LINK_VIEW);
+ if (linkView != null) {
+ block.setlinkView(linkView);
+ block.setlinkName(templateProcessor.getOptionalProperty(LINK_NAME, Names.RESULT));
+ }
+
+ templateProcessor.skipUntilClose();
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/collection/TableView.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/collection/TableView.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/collection/TableView.java
new file mode 100644
index 0000000..72baeaf
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/collection/TableView.java
@@ -0,0 +1,328 @@
+/*
+ * 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.collection;
+
+import java.util.List;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facets.object.parseable.ParseableFacet;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
+import org.apache.isis.core.runtime.persistence.ObjectNotFoundException;
+import org.apache.isis.viewer.scimpi.Names;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.PageWriter;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.determine.LinkedFieldsBlock;
+import org.apache.isis.viewer.scimpi.dispatcher.view.determine.LinkedObject;
+
+public class TableView extends AbstractTableView {
+
+ public static final class SimpleTableBuilder implements TableContentWriter {
+ private final String parent;
+ private final boolean includeHeader;
+ private final boolean includeFooter;
+ private final String title;
+ private final String[] headers;
+ private final List<ObjectAssociation> fields;
+ private final boolean showTitle;
+ private final boolean showIcons;
+ private final boolean showSelectOption;
+ private final boolean showDeleteOption;
+ private final boolean showEditOption;
+ private final String fieldName;
+ private final LinkedObject[] linkedFields;
+ private final LinkedObject linkRow;
+ private final int noColumns;
+
+ public SimpleTableBuilder(
+ final String parent,
+ final boolean includeHeader,
+ final boolean includeFooter,
+ final String title,
+ final int noColumns,
+ final String[] headers,
+ final List<ObjectAssociation> fields,
+ final boolean showTitle,
+ final boolean showIcons,
+ final boolean showSelectOption,
+ final boolean showDeleteOption,
+ final boolean showEditOption,
+ final String fieldName,
+ final LinkedObject[] linkedFields,
+ final LinkedObject linkRow) {
+ this.parent = parent;
+ this.includeHeader = includeHeader;
+ this.includeFooter = includeFooter;
+ this.title = title;
+ this.showTitle = showTitle;
+ this.noColumns = noColumns < 1 ? fields.size() : noColumns;
+ this.headers = headers;
+ this.fields = fields;
+ this.showIcons = showIcons;
+ this.showSelectOption = showSelectOption;
+ this.showDeleteOption = showDeleteOption;
+ this.showEditOption = showEditOption;
+ this.fieldName = fieldName;
+ this.linkedFields = linkedFields;
+ this.linkRow = linkRow;
+ }
+
+ @Override
+ public void writeFooters(final PageWriter writer) {
+ if (includeFooter) {
+ writer.appendHtml("<tfoot>");
+ columnHeaders(writer, headers);
+ writer.appendHtml("</tfoot>");
+ }
+ }
+
+ @Override
+ public void writeCaption(PageWriter writer) {
+ if (title != null) {
+ writer.appendHtml("<caption>");
+ writer.appendHtml(title);
+ writer.appendHtml("</caption>");
+ }
+ }
+
+ @Override
+ public void writeHeaders(final PageWriter writer) {
+ if (includeHeader) {
+ writer.appendHtml("<thead>");
+ columnHeaders(writer, headers);
+ writer.appendHtml("</thead>");
+ }
+ }
+
+ private void columnHeaders(final PageWriter writer, final String[] headers) {
+ writer.appendHtml("<tr class=\"column-headers\">");
+ if (showTitle) {
+ writer.appendHtml("<th></th>");
+ }
+ final String[] columnHeaders = headers;
+ for (final String columnHeader : columnHeaders) {
+ if (columnHeader != null) {
+ writer.appendHtml("<th>");
+ writer.appendAsHtmlEncoded(columnHeader);
+ writer.appendHtml("</th>");
+ }
+ }
+ writer.appendHtml("<th class=\"controls\"></th>");
+ writer.appendHtml("</tr>");
+ }
+
+ public void tidyUp() {
+ // request.popBlockContent();
+
+ // Is it the block that is left over, or is the collection form not being closed?
+ }
+
+ @Override
+ public void writeElement(final TemplateProcessor templateProcessor, final Request context, final ObjectAdapter element) {
+ final String rowId = context.mapObject(element, Scope.INTERACTION);
+ final String scope = linkRow == null ? "" : "&" + SCOPE + "=" + linkRow.getScope();
+ String result = "";
+ result = context.encodedInteractionParameters();
+
+ if (noColumns == 0) {
+ templateProcessor.appendHtml("<td>");
+ if (linkRow != null) {
+ templateProcessor.appendHtml("<td><a href=\"" + linkRow.getForwardView() + "?" + linkRow.getVariable() + "=" + rowId + result + scope + "\">");
+ templateProcessor.appendAsHtmlEncoded(element.titleString());
+ templateProcessor.appendHtml("</a>");
+ } else {
+ templateProcessor.appendAsHtmlEncoded(element.titleString());
+ }
+ templateProcessor.appendHtml("</td>");
+
+ } else {
+ if (showTitle) {
+ templateProcessor.appendHtml("<td>");
+ templateProcessor.appendAsHtmlEncoded(element.titleString());
+ templateProcessor.appendHtml("</td>");
+ }
+
+ for (int i = 0; i < noColumns; i++) {
+ if (fields.get(i).isOneToManyAssociation()) {
+ continue;
+ }
+ templateProcessor.appendHtml("<td>");
+ final ObjectAdapter field = fields.get(i).get(element);
+ if (field != null) {
+ if (showIcons && !fields.get(i).getSpecification().containsFacet(ParseableFacet.class)) {
+ templateProcessor.appendHtml("<img class=\"" + "small-icon" + "\" src=\"" + templateProcessor.getContext().imagePath(field) + "\" alt=\"" + fields.get(i).getSpecification().getShortIdentifier() + "\"/>");
+ }
+ if (linkRow != null) {
+ templateProcessor.appendHtml("<a href=\"" + linkRow.getForwardView() + "?" + linkRow.getVariable() + "=" + rowId + result + scope + "\">");
+ } else if (linkedFields[i] != null) {
+ final ObjectAdapter fieldObject = fields.get(i).get(element);
+ final String id = context.mapObject(fieldObject, Scope.INTERACTION);
+ templateProcessor.appendHtml("<a href=\"" + linkedFields[i].getForwardView() + "?" + linkedFields[i].getVariable() + "=" + id + "\">");
+ context.mapObject(fieldObject, Request.scope(linkedFields[i].getScope()));
+
+ }
+ try {
+ templateProcessor.appendAsHtmlEncoded(field.titleString());
+ } catch (final ObjectNotFoundException e) {
+ templateProcessor.appendAsHtmlEncoded(e.getMessage());
+ }
+ if (linkRow != null || linkedFields[i] != null) {
+ templateProcessor.appendHtml("</a>");
+ }
+ }
+ templateProcessor.appendHtml("</td>");
+
+ }
+ }
+ templateProcessor.appendHtml("<td class=\"controls\">");
+ if (showSelectOption) {
+ templateProcessor.appendHtml("<a class=\"button element-select\" href=\"" + "_generic." + Names.EXTENSION + "?" + Names.RESULT + "=" + rowId + result + scope + "\">view</a>");
+ }
+ if (showEditOption) {
+ templateProcessor.appendHtml(" <a class=\"button element-edit\" href=\"" + "_generic_edit." + Names.EXTENSION + "?" + Names.RESULT + "=" + rowId + result + scope + "\">edit</a>");
+ }
+
+ if (showDeleteOption && parent != null) {
+ String view = templateProcessor.getViewPath();
+ view = context.fullFilePath(view == null ? context.getResourceFile() : view);
+ RemoveElement.write(templateProcessor, context.getMappedObject(parent), fieldName, element, null, view, view, "delete", "action in-line element-delete confirm");
+ }
+
+ templateProcessor.appendHtml("</td>");
+
+ }
+ }
+
+ @Override
+ protected TableContentWriter createRowBuilder(
+ final TemplateProcessor templateProcessor,
+ final Request context,
+ final String parent,
+ final List<ObjectAssociation> allFields,
+ final ObjectAdapter collection) {
+ final String fieldName = templateProcessor.getOptionalProperty(FIELD);
+ final String title = templateProcessor.getOptionalProperty(FORM_TITLE);
+ return rowBuilder(templateProcessor, context, title, parent, fieldName, allFields, showIconByDefault());
+ }
+
+ private static TableContentWriter rowBuilder(
+ final TemplateProcessor templateProcessor,
+ final Request context,
+ final String title,
+ final String object,
+ final String fieldName,
+ final List<ObjectAssociation> allFields,
+ final boolean showIconByDefault) {
+ final String linkRowView = templateProcessor.getOptionalProperty(LINK_VIEW);
+ final String linkObjectName = templateProcessor.getOptionalProperty(ELEMENT_NAME, Names.RESULT);
+ final String linkObjectScope = templateProcessor.getOptionalProperty(SCOPE, Scope.INTERACTION.toString());
+ final LinkedObject linkRow = linkRowView == null ? null : new LinkedObject(linkObjectName, linkObjectScope, context.fullUriPath(linkRowView));
+ final boolean includeHeader = templateProcessor.isRequested(HEADER, true);
+ final boolean includeFooter = templateProcessor.isRequested(FOOTER, false);
+
+ final boolean linkFields = templateProcessor.isRequested("link-fields", true);
+ final boolean showTitle = templateProcessor.isRequested(SHOW_TITLE, false);
+ final boolean showIcons = templateProcessor.isRequested(SHOW_ICON, showIconByDefault);
+ final boolean showSelectOption = templateProcessor.isRequested(SHOW_SELECT, true);
+ final boolean showEditOption = templateProcessor.isRequested(SHOW_EDIT, true);
+ final boolean showDeleteOption = templateProcessor.isRequested(SHOW_DELETE, true);
+
+ final String noColumnsString = templateProcessor.getOptionalProperty("no-columns", "3");
+
+ final LinkedFieldsBlock block = new LinkedFieldsBlock();
+ templateProcessor.pushBlock(block);
+ templateProcessor.processUtilCloseTag();
+ final List<ObjectAssociation> fields = block.includedFields(allFields);
+ final LinkedObject[] linkedFields = block.linkedFields(fields);
+ for (int i = 0; i < linkedFields.length; i++) {
+ if (linkedFields[i] == null && linkFields && !fields.get(i).getSpecification().containsFacet(ParseableFacet.class)) {
+ linkedFields[i] = new LinkedObject("_generic.shtml");
+ }
+ if (linkedFields[i] != null) {
+ linkedFields[i].setForwardView(context.fullUriPath(linkedFields[i].getForwardView()));
+ }
+ }
+
+ int noColumns;
+ if (noColumnsString.equalsIgnoreCase("all")) {
+ noColumns = fields.size();
+ } else {
+ noColumns = Math.min(fields.size(), Integer.valueOf(noColumnsString));
+ }
+
+ final String headers[] = new String[noColumns];
+ int h = 0;
+ for (int i = 0; i < noColumns; i++) {
+ if (fields.get(i).isOneToManyAssociation()) {
+ continue;
+ }
+ headers[h++] = fields.get(i).getName();
+ }
+
+ templateProcessor.popBlock();
+
+ return new SimpleTableBuilder(object, includeHeader, includeFooter, title, noColumns, headers, fields, showTitle,
+ showIcons, showSelectOption, showDeleteOption, showEditOption, fieldName, linkedFields, linkRow);
+ }
+
+ public static void write(
+ final TemplateProcessor templateProcessor,
+ final String summary,
+ final ObjectAdapter object,
+ final ObjectAssociation field,
+ final ObjectAdapter collection,
+ final int noColumns,
+ final List<ObjectAssociation> fields,
+ final boolean linkAllFields,
+ final boolean showIconByDefault,
+ final String tableClass,
+ final String[] rowClasses,
+ LinkedObject linkedObject) {
+ final LinkedObject[] linkedFields = new LinkedObject[fields.size()];
+ if (linkAllFields) {
+ for (int i = 0; i < linkedFields.length; i++) {
+ if (fields.get(i).isOneToOneAssociation()) {
+ linkedFields[i] = linkedObject == null ? new LinkedObject("_generic.shtml") : linkedObject;
+ }
+ }
+ }
+
+ final String headers[] = new String[fields.size()];
+ int h = 0;
+ for (int i = 0; i < fields.size(); i++) {
+ if (fields.get(i).isOneToManyAssociation()) {
+ continue;
+ }
+ headers[h++] = fields.get(i).getName();
+ }
+
+ final Request context = templateProcessor.getContext();
+ final TableContentWriter rowBuilder = rowBuilder(templateProcessor, context, null, context.mapObject(object, Scope.REQUEST), field.getIdentifier().getMemberName(), fields,
+ showIconByDefault);
+ write(templateProcessor, collection, summary, rowBuilder, null, null, null);
+ }
+
+ @Override
+ public String getName() {
+ return "table";
+ }
+
+}
[19/24] Restructuring Scimpi to remove dependencies and enable easier
testing.
Posted by rm...@apache.org.
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Members.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Members.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Members.java
index 4f9e084..21160dd 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Members.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Members.java
@@ -32,7 +32,8 @@ import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
import org.apache.isis.core.runtime.system.context.IsisContext;
import org.apache.isis.viewer.scimpi.ForbiddenException;
import org.apache.isis.viewer.scimpi.ScimpiException;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public class Members extends AbstractElementProcessor {
@@ -50,16 +51,16 @@ public class Members extends AbstractElementProcessor {
}
@Override
- public void process(final TagProcessor tagProcessor) {
- if (tagProcessor.getContext().isDebugDisabled()) {
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ if (templateProcessor.getContext().isDebugDisabled()) {
return;
}
- final String id = tagProcessor.getOptionalProperty(OBJECT);
- final String fieldName = tagProcessor.getOptionalProperty(FIELD);
- tagProcessor.appendHtml("<pre class=\"debug\">");
+ final String id = templateProcessor.getOptionalProperty(OBJECT);
+ final String fieldName = templateProcessor.getOptionalProperty(FIELD);
+ templateProcessor.appendHtml("<pre class=\"debug\">");
try {
- ObjectAdapter object = tagProcessor.getContext().getMappedObjectOrResult(id);
+ ObjectAdapter object = templateProcessor.getContext().getMappedObjectOrResult(id);
ObjectAssociation field = null;
if (fieldName != null) {
field = object.getSpecification().getAssociation(fieldName);
@@ -68,40 +69,40 @@ public class Members extends AbstractElementProcessor {
}
object = field.get(object);
}
- tagProcessor.processUtilCloseTag();
+ templateProcessor.processUtilCloseTag();
final ObjectSpecification specification = field == null ? object.getSpecification() : field.getSpecification();
- tagProcessor.appendHtml(specification.getSingularName() + " (" + specification.getFullIdentifier() + ") \n");
+ templateProcessor.appendHtml(specification.getSingularName() + " (" + specification.getFullIdentifier() + ") \n");
final List<ObjectAssociation> fields = specification.getAssociations();
for (final ObjectAssociation fld : fields) {
if (!fld.isAlwaysHidden()) {
- tagProcessor.appendHtml(" " + fld.getId() + " - '" + fld.getName() + "' -> " + fld.getSpecification().getSingularName() + (fld.isOneToManyAssociation() ? " (collection of)" : "") + "\n");
+ templateProcessor.appendHtml(" " + fld.getId() + " - '" + fld.getName() + "' -> " + fld.getSpecification().getSingularName() + (fld.isOneToManyAssociation() ? " (collection of)" : "") + "\n");
}
}
- tagProcessor.appendHtml(" --------------\n");
+ templateProcessor.appendHtml(" --------------\n");
final List<ObjectAction> actions = specification.getObjectActions(ActionType.USER, Contributed.INCLUDED);
;
for (final ObjectAction action : actions) {
- tagProcessor.appendHtml(" " + action.getId() + " (");
+ templateProcessor.appendHtml(" " + action.getId() + " (");
boolean first = true;
for (final ObjectActionParameter parameter : action.getParameters()) {
if (!first) {
- tagProcessor.appendHtml(", ");
+ templateProcessor.appendHtml(", ");
}
- tagProcessor.appendHtml(parameter.getSpecification().getSingularName());
+ templateProcessor.appendHtml(parameter.getSpecification().getSingularName());
first = false;
}
- tagProcessor.appendHtml(")" + " - '" + action.getName() + "'");
+ templateProcessor.appendHtml(")" + " - '" + action.getName() + "'");
if (action.getSpecification() != null) {
- tagProcessor.appendHtml(" -> " + action.getSpecification().getSingularName() + ")");
+ templateProcessor.appendHtml(" -> " + action.getSpecification().getSingularName() + ")");
}
- tagProcessor.appendHtml("\n");
+ templateProcessor.appendHtml("\n");
}
} catch (final ScimpiException e) {
- tagProcessor.appendHtml("Debug failed: " + e.getMessage());
+ templateProcessor.appendHtml("Debug failed: " + e.getMessage());
}
- tagProcessor.appendHtml("</pre>");
+ templateProcessor.appendHtml("</pre>");
}
}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/ShowDebug.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/ShowDebug.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/ShowDebug.java
index 5ed423b..e683262 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/ShowDebug.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/ShowDebug.java
@@ -19,17 +19,18 @@
package org.apache.isis.viewer.scimpi.dispatcher.view.debug;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public class ShowDebug extends AbstractElementProcessor {
@Override
- public void process(final TagProcessor tagProcessor) {
- if (tagProcessor.getContext().isDebugDisabled()) {
- tagProcessor.skipUntilClose();
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ if (templateProcessor.getContext().isDebugDisabled()) {
+ templateProcessor.skipUntilClose();
} else {
- tagProcessor.processUtilCloseTag();
+ templateProcessor.processUtilCloseTag();
}
}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Specification.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Specification.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Specification.java
index db6cc57..e26cd5d 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Specification.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Specification.java
@@ -27,52 +27,53 @@ import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
import org.apache.isis.core.metamodel.spec.ObjectSpecification;
import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public class Specification extends AbstractElementProcessor {
@Override
- public void process(final TagProcessor tagProcessor) {
- final Request context = tagProcessor.getContext();
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ final Request context = templateProcessor.getContext();
if (context.isDebugDisabled()) {
return;
}
- if (tagProcessor.isRequested("always") || context.getDebug() == Request.Debug.ON) {
- tagProcessor.appendHtml("<div class=\"debug\">");
- tagProcessor.appendHtml("<pre>");
+ if (templateProcessor.isRequested("always") || context.getDebug() == Request.Debug.ON) {
+ templateProcessor.appendHtml("<div class=\"debug\">");
+ templateProcessor.appendHtml("<pre>");
- final String id = tagProcessor.getOptionalProperty("object");
+ final String id = templateProcessor.getOptionalProperty("object");
final ObjectAdapter object = context.getMappedObjectOrResult(id);
final ObjectSpecification specification = object.getSpecification();
- String type = tagProcessor.getOptionalProperty(TYPE, "details");
+ String type = templateProcessor.getOptionalProperty(TYPE, "details");
if (type.equals("graph")) {
- specificationGraph(tagProcessor, specification, null, new ArrayList<ObjectSpecification>(), 0);
+ specificationGraph(templateProcessor, specification, null, new ArrayList<ObjectSpecification>(), 0);
} else if (type.equals("details")) {
- specificationDetails(tagProcessor, specification);
+ specificationDetails(templateProcessor, specification);
} else {
- tagProcessor.appendHtml("invalid type: " + type);
+ templateProcessor.appendHtml("invalid type: " + type);
}
- tagProcessor.appendHtml("</pre>");
- tagProcessor.appendHtml("</div>");
+ templateProcessor.appendHtml("</pre>");
+ templateProcessor.appendHtml("</div>");
}
}
- private void specificationDetails(final TagProcessor tagProcessor, final ObjectSpecification specification) {
- renderName(tagProcessor, specification);
+ private void specificationDetails(final TemplateProcessor templateProcessor, final ObjectSpecification specification) {
+ renderName(templateProcessor, specification);
final List<ObjectAssociation> fields = specification.getAssociations();
for (int i = 0; i < fields.size(); i++) {
- tagProcessor.appendHtml(" " + fields.get(i).getName() + " (" + fields.get(i).getSpecification().getSingularName()
+ templateProcessor.appendHtml(" " + fields.get(i).getName() + " (" + fields.get(i).getSpecification().getSingularName()
+ ") \n");
}
}
private void specificationGraph(
- TagProcessor tagProcessor,
+ TemplateProcessor templateProcessor,
ObjectSpecification specification,
String fieldName,
List<ObjectSpecification> processed,
@@ -81,15 +82,15 @@ public class Specification extends AbstractElementProcessor {
return;
}
- tagProcessor.appendHtml(StringUtils.repeat(" ", level));
+ templateProcessor.appendHtml(StringUtils.repeat(" ", level));
if (processed.contains(specification)) {
- tagProcessor.appendHtml("* ");
+ templateProcessor.appendHtml("* ");
}
- tagProcessor.appendHtml(specification.getFullIdentifier());
+ templateProcessor.appendHtml(specification.getFullIdentifier());
if (fieldName != null) {
- tagProcessor.appendHtml(" (" + fieldName + ")");
+ templateProcessor.appendHtml(" (" + fieldName + ")");
}
- tagProcessor.appendHtml("\n");
+ templateProcessor.appendHtml("\n");
if (processed.contains(specification)) {
return;
@@ -102,12 +103,12 @@ public class Specification extends AbstractElementProcessor {
if (fieldSpecification.isValue()) {
continue;
}
- specificationGraph(tagProcessor, fieldSpecification, fields.get(i).getName(), processed, level + 1);
+ specificationGraph(templateProcessor, fieldSpecification, fields.get(i).getName(), processed, level + 1);
}
}
- private void renderName(final TagProcessor tagProcessor, final ObjectSpecification specification) {
- tagProcessor.appendHtml(specification.getSingularName() + " (" + specification.getFullIdentifier() + ") \n");
+ private void renderName(final TemplateProcessor templateProcessor, final ObjectSpecification specification) {
+ templateProcessor.appendHtml(specification.getSingularName() + " (" + specification.getFullIdentifier() + ") \n");
}
@Override
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/ThrowException.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/ThrowException.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/ThrowException.java
index 8a458b8..30d6d7e 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/ThrowException.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/ThrowException.java
@@ -20,18 +20,19 @@
package org.apache.isis.viewer.scimpi.dispatcher.view.debug;
import org.apache.isis.core.commons.exceptions.IsisException;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public class ThrowException extends AbstractElementProcessor {
@Override
- public void process(final TagProcessor tagProcessor) {
- if (tagProcessor.getContext().isDebugDisabled()) {
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ if (templateProcessor.getContext().isDebugDisabled()) {
return;
}
- final String message = tagProcessor.getOptionalProperty("message", "Exception throw for testing purposes");
+ final String message = templateProcessor.getOptionalProperty("message", "Exception throw for testing purposes");
throw new IsisException(message);
}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/determine/Exclude.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/determine/Exclude.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/determine/Exclude.java
new file mode 100644
index 0000000..b04bec3
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/determine/Exclude.java
@@ -0,0 +1,40 @@
+/*
+ * 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.determine;
+
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+public class Exclude extends AbstractElementProcessor {
+
+ @Override
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ final String field = templateProcessor.getOptionalProperty(NAME);
+ final InclusionList block = (InclusionList) templateProcessor.peekBlock();
+ block.exclude(field);
+ }
+
+ @Override
+ public String getName() {
+ return "exclude";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/determine/Include.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/determine/Include.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/determine/Include.java
new file mode 100644
index 0000000..c86732e
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/determine/Include.java
@@ -0,0 +1,40 @@
+/*
+ * 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.determine;
+
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+public class Include extends AbstractElementProcessor {
+
+ @Override
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ final String field = templateProcessor.getOptionalProperty(NAME);
+ final InclusionList block = (InclusionList) templateProcessor.peekBlock();
+ block.include(field);
+ }
+
+ @Override
+ public String getName() {
+ return "include";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/determine/InclusionList.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/determine/InclusionList.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/determine/InclusionList.java
new file mode 100644
index 0000000..3139f5f
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/determine/InclusionList.java
@@ -0,0 +1,80 @@
+/*
+ * 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.determine;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import com.google.common.collect.Lists;
+
+import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.BlockContent;
+//import org.apache.isis.viewer.scimpi.dispatcher.view.form.InputField;
+
+public class InclusionList implements BlockContent {
+ private final Set<String> includedList = new HashSet<String>();
+ private final Set<String> excludedList = new HashSet<String>();
+
+ private boolean inIncludedList(final String fieldName) {
+ return includedList.size() == 0 || includedList.contains(fieldName) || includedList.contains("all");
+ }
+
+ private boolean inExcludedList(final String fieldName) {
+ return excludedList.contains(fieldName) || excludedList.contains("all");
+ }
+
+ public void include(final String field) {
+ includedList.add(field);
+ }
+
+ public void exclude(final String field) {
+ excludedList.add(field);
+ }
+
+ public List<ObjectAssociation> includedFields(final List<ObjectAssociation> originalFields) {
+ final List<ObjectAssociation> includedFields = Lists.newArrayList();
+ for (int i = 0; i < originalFields.size(); i++) {
+ final String id2 = originalFields.get(i).getId();
+ if (includes(id2)) {
+ includedFields.add(originalFields.get(i));
+ }
+ }
+
+ return includedFields;
+ }
+
+ public boolean includes(final String id) {
+ return inIncludedList(id) && !inExcludedList(id);
+ }
+
+ public List<ObjectAction> includedActions(final List<ObjectAction> originalActions) {
+ final List<ObjectAction> includedActions = Lists.newArrayList();
+ for (int i = 0; i < originalActions.size(); i++) {
+ final String id2 = originalActions.get(i).getId();
+ if (includes(id2)) {
+ includedActions.add(originalActions.get(i));
+ }
+ }
+
+ return includedActions;
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/determine/Link.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/determine/Link.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/determine/Link.java
new file mode 100644
index 0000000..92a60c4
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/determine/Link.java
@@ -0,0 +1,45 @@
+/*
+ * 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.determine;
+
+import org.apache.isis.viewer.scimpi.Names;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+public class Link extends AbstractElementProcessor {
+
+ @Override
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ final String field = templateProcessor.getOptionalProperty(NAME);
+ final String variable = templateProcessor.getOptionalProperty(REFERENCE_NAME, Names.RESULT);
+ final String scope = templateProcessor.getOptionalProperty(SCOPE, Scope.INTERACTION.toString());
+ final String forwardView = templateProcessor.getOptionalProperty(VIEW, "_generic." + Names.EXTENSION);
+ final LinkedFieldsBlock tag = (LinkedFieldsBlock) templateProcessor.peekBlock();
+ tag.link(field, variable, scope, forwardView);
+ }
+
+ @Override
+ public String getName() {
+ return "link";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/determine/LinkedFieldsBlock.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/determine/LinkedFieldsBlock.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/determine/LinkedFieldsBlock.java
new file mode 100644
index 0000000..9f3440b
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/determine/LinkedFieldsBlock.java
@@ -0,0 +1,47 @@
+/*
+ * 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.determine;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
+
+public class LinkedFieldsBlock extends InclusionList {
+ private final Map<String, LinkedObject> linkedFields = new HashMap<String, LinkedObject>();
+
+ public void link(final String field, final String variable, final String scope, final String forwardView) {
+ include(field);
+ linkedFields.put(field, new LinkedObject(variable, scope, forwardView));
+ }
+
+ public LinkedObject[] linkedFields(final List<ObjectAssociation> fields) {
+ final LinkedObject[] includedFields = new LinkedObject[fields.size()];
+ for (int i = 0; i < fields.size(); i++) {
+ final String id2 = fields.get(i).getId();
+ if (fields.get(i).isOneToOneAssociation() && linkedFields.containsKey(id2)) {
+ includedFields[i] = linkedFields.get(id2);
+ }
+ }
+ return includedFields;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/determine/LinkedObject.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/determine/LinkedObject.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/determine/LinkedObject.java
new file mode 100644
index 0000000..28d5819
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/determine/LinkedObject.java
@@ -0,0 +1,58 @@
+/*
+ * 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.determine;
+
+import org.apache.isis.viewer.scimpi.Names;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
+
+public class LinkedObject {
+ private final String variable;
+ private final String scope;
+ private String forwardView;
+
+ public LinkedObject(final String variable, final String scope, final String forwardView) {
+ this.variable = variable;
+ this.scope = scope;
+ this.forwardView = forwardView;
+ }
+
+ public LinkedObject(final String forwardView) {
+ this.forwardView = forwardView;
+ scope = Scope.INTERACTION.toString();
+ variable = Names.RESULT;
+ }
+
+ public String getVariable() {
+ return variable;
+ }
+
+ public String getScope() {
+ return scope;
+ }
+
+ public String getForwardView() {
+ return forwardView;
+ }
+
+ public void setForwardView(final String path) {
+ forwardView = path;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/AbstractFormView.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/AbstractFormView.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/AbstractFormView.java
deleted file mode 100644
index 28c3c65..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/AbstractFormView.java
+++ /dev/null
@@ -1,142 +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.display;
-
-import java.util.List;
-
-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.parseable.ParseableFacet;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAssociationFilters;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractObjectProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.view.field.LinkedFieldsBlock;
-import org.apache.isis.viewer.scimpi.dispatcher.view.field.LinkedObject;
-import org.apache.isis.viewer.scimpi.dispatcher.view.other.HelpLink;
-
-public abstract class AbstractFormView extends AbstractObjectProcessor {
-
- @Override
- public String checkFieldType(final ObjectAssociation objectField) {
- return objectField.isOneToOneAssociation() ? null : "is not an object";
- }
-
- @Override
- public void process(final TagProcessor tagProcessor, final ObjectAdapter object) {
- final LinkedFieldsBlock tag = new LinkedFieldsBlock();
-
- if (object != null) {
- final String id = tagProcessor.getOptionalProperty(ID, object.getSpecification().getShortIdentifier());
- final String cls = tagProcessor.getOptionalProperty(CLASS, "form");
- final String classString = " id=\"" + id + "\" class=\"" + cls + "\"";
- String title = tagProcessor.getOptionalProperty(FORM_TITLE);
- final String oddRowClass = tagProcessor.getOptionalProperty(ODD_ROW_CLASS);
- final String evenRowClass = tagProcessor.getOptionalProperty(EVEN_ROW_CLASS);
- final String labelDelimiter = tagProcessor.getOptionalProperty(LABEL_DELIMITER, ":");
- final boolean showIcons = tagProcessor.isRequested(SHOW_ICON, showIconByDefault());
- String linkAllView = tagProcessor.getOptionalProperty(LINK_VIEW);
-
- tagProcessor.setBlockContent(tag);
- tagProcessor.processUtilCloseTag();
-
- final AuthenticationSession session = IsisContext.getAuthenticationSession();
- List<ObjectAssociation> associations = object.getSpecification().getAssociations(ObjectAssociationFilters.dynamicallyVisible(session, object, Where.OBJECT_FORMS));
- final List<ObjectAssociation> fields = tag.includedFields(associations);
- final LinkedObject[] linkFields = tag.linkedFields(fields);
-
- if (linkAllView != null) {
- linkAllView = tagProcessor.getContext().fullUriPath(linkAllView);
- for (int i = 0; i < linkFields.length; i++) {
- final boolean isObject = fields.get(i).isOneToOneAssociation();
- final boolean isNotParseable = !fields.get(i).getSpecification().containsFacet(ParseableFacet.class);
- linkFields[i] = isObject && isNotParseable ? new LinkedObject(linkAllView) : null;
- }
- }
-
- if (title == null) {
- title = object.getSpecification().getSingularName();
- } else if (title.equals("")) {
- title = null;
- }
-
- write(tagProcessor, object, fields, linkFields, classString, title, labelDelimiter, oddRowClass, evenRowClass, showIcons);
- } else {
- tagProcessor.skipUntilClose();
- }
- }
-
- private void write(
- final TagProcessor tagProcessor,
- final ObjectAdapter object,
- final List<ObjectAssociation> fields,
- final LinkedObject[] linkFields,
- final String classString,
- final String title,
- final String labelDelimiter,
- final String oddRowClass,
- final String evenRowClass,
- final boolean showIcons) {
- tagProcessor.appendHtml("<div" + classString + ">");
- if (title != null) {
- tagProcessor.appendHtml("<div class=\"title\">");
- tagProcessor.appendAsHtmlEncoded(title);
- tagProcessor.appendHtml("</div>");
- HelpLink.append(tagProcessor, object.getSpecification().getDescription(), object.getSpecification().getHelp());
- }
- int row = 1;
- for (int i = 0; i < fields.size(); i++) {
- final ObjectAssociation field = fields.get(i);
- if (ignoreField(field)) {
- continue;
- }
- if (field.isVisible(IsisContext.getAuthenticationSession(), object, Where.OBJECT_FORMS).isVetoed()) {
- continue;
- }
-
- final String description = field.getDescription().equals("") ? "" : "title=\"" + field.getDescription() + "\"";
- String cls;
- if (row++ % 2 == 1) {
- cls = " class=\"field " + (oddRowClass == null ? ODD_ROW_CLASS : oddRowClass) + "\"";
- } else {
- cls = " class=\"field " + (evenRowClass == null ? EVEN_ROW_CLASS : evenRowClass) + "\"";
- }
- tagProcessor.appendHtml("<div " + cls + description + "><span class=\"label\">");
- tagProcessor.appendAsHtmlEncoded(field.getName());
- tagProcessor.appendHtml(labelDelimiter + "</span>");
- final LinkedObject linkedObject = linkFields[i];
- addField(tagProcessor, object, field, linkedObject, showIcons);
- HelpLink.append(tagProcessor, field.getDescription(), field.getHelp());
- tagProcessor.appendHtml("</div>");
- }
- tagProcessor.appendHtml("</div>");
- }
-
- protected void addField(final TagProcessor tagProcessor, final ObjectAdapter object, final ObjectAssociation field, final LinkedObject linkedObject, final boolean showIcons) {
- FieldValue.write(tagProcessor, object, field, linkedObject, null, showIcons, 0);
- }
-
- protected boolean ignoreField(final ObjectAssociation objectField) {
- return false;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/AbstractTableView.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/AbstractTableView.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/AbstractTableView.java
deleted file mode 100644
index f47bd60..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/AbstractTableView.java
+++ /dev/null
@@ -1,149 +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.display;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.isis.applib.annotation.Where;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacet;
-import org.apache.isis.core.metamodel.facets.typeof.TypeOfFacet;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAssociationFilters;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.core.runtime.system.persistence.Persistor;
-import org.apache.isis.viewer.scimpi.ScimpiException;
-import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
-import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
-
-public abstract class AbstractTableView extends AbstractElementProcessor {
-
- // REVIEW: should provide this rendering context, rather than hardcoding.
- // the net effect currently is that class members annotated with
- // @Hidden(where=Where.ALL_TABLES) or @Disabled(where=Where.ALL_TABLES) will indeed
- // be hidden from all tables but will be visible/enabled (perhaps incorrectly)
- // if annotated with Where.PARENTED_TABLE or Where.STANDALONE_TABLE
- private final Where where = Where.ALL_TABLES;
-
- @Override
- public void process(final TagProcessor tagProcessor) {
- final Request context = tagProcessor.getContext();
-
- ObjectAdapter collection;
- String parentObjectId = null;
- boolean isFieldEditable = false;
- final String field = tagProcessor.getOptionalProperty(FIELD);
- final String tableClass = tagProcessor.getOptionalProperty(CLASS);
- ObjectSpecification elementSpec;
- String tableId;
- if (field != null) {
- final String objectId = tagProcessor.getOptionalProperty(OBJECT);
- final ObjectAdapter object = context.getMappedObjectOrResult(objectId);
- if (object == null) {
- throw new ScimpiException("No object for result or " + objectId);
- }
- final ObjectAssociation objectField = object.getSpecification().getAssociation(field);
- if (!objectField.isOneToManyAssociation()) {
- throw new ScimpiException("Field " + objectField.getId() + " is not a collection");
- }
- isFieldEditable = objectField.isUsable(IsisContext.getAuthenticationSession(), object, where).isAllowed();
- getPersistenceSession().resolveField(object, objectField);
- collection = objectField.get(object);
- final TypeOfFacet facet = objectField.getFacet(TypeOfFacet.class);
- elementSpec = facet.valueSpec();
- parentObjectId = objectId == null ? context.mapObject(object, Scope.REQUEST) : objectId;
- tableId = tagProcessor.getOptionalProperty(ID, field);
- } else {
- final String id = tagProcessor.getOptionalProperty(COLLECTION);
- collection = context.getMappedObjectOrResult(id);
- elementSpec = collection.getElementSpecification();
- tableId = tagProcessor.getOptionalProperty(ID, collection.getElementSpecification().getShortIdentifier());
- }
-
- final String summary = tagProcessor.getOptionalProperty("summary");
- final String rowClassesList = tagProcessor.getOptionalProperty(ROW_CLASSES, ODD_ROW_CLASS + "|" + EVEN_ROW_CLASS);
- String[] rowClasses = null;
- if (rowClassesList.length() > 0) {
- rowClasses = rowClassesList.split("[,|/]");
- }
-
- final List<ObjectAssociation> allFields = elementSpec.getAssociations(ObjectAssociationFilters.WHEN_VISIBLE_IRRESPECTIVE_OF_WHERE);
- final TableContentWriter rowBuilder = createRowBuilder(tagProcessor, context, isFieldEditable ? parentObjectId : null, allFields, collection);
- write(tagProcessor, collection, summary, rowBuilder, tableId, tableClass, rowClasses);
-
- }
-
- protected Persistor getPersistenceSession() {
- return IsisContext.getPersistenceSession();
- }
-
- protected abstract TableContentWriter createRowBuilder(final TagProcessor tagProcessor, Request context, final String parent, final List<ObjectAssociation> allFields, ObjectAdapter collection);
-
- public static void write(
- final TagProcessor tagProcessor,
- final ObjectAdapter collection,
- final String summary,
- final TableContentWriter rowBuilder,
- final String tableId,
- final String tableClass,
- final String[] rowClasses) {
- final Request context = tagProcessor.getContext();
-
- final String summarySegment = summary == null ? "" : (" summary=\"" + summary + "\"");
- final String idSegment = tableId == null ? "" : (" id=\"" + tableId + "\"");
- final String classSegment = tableClass == null ? "" : (" class=\"" + tableClass + "\"");
- tagProcessor.appendHtml("<table" + idSegment + classSegment + summarySegment + ">");
- rowBuilder.writeCaption(tagProcessor);
- rowBuilder.writeHeaders(tagProcessor);
- rowBuilder.writeFooters(tagProcessor);
-
- tagProcessor.appendHtml("<tbody>");
- final CollectionFacet facet = collection.getSpecification().getFacet(CollectionFacet.class);
- final Iterator<ObjectAdapter> iterator = facet.iterator(collection);
- int row = 1;
- while (iterator.hasNext()) {
- final ObjectAdapter element = iterator.next();
-
- context.addVariable("row", "" + (row), Scope.REQUEST);
- String cls = "";
- if (rowClasses != null) {
- cls = " class=\"" + rowClasses[row % rowClasses.length] + "\"";
- }
- tagProcessor.appendHtml("<tr" + cls + ">");
- rowBuilder.writeElement(tagProcessor, context, element);
- tagProcessor.appendHtml("</tr>");
- row++;
- }
- tagProcessor.appendHtml("</tbody>");
- tagProcessor.appendHtml("</table>");
-
- rowBuilder.tidyUp();
- }
-
- @Override
- public String getName() {
- return "table";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/AddMessage.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/AddMessage.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/AddMessage.java
deleted file mode 100644
index 4e3bbbb..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/AddMessage.java
+++ /dev/null
@@ -1,44 +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.display;
-
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.core.runtime.system.transaction.MessageBroker;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
-
-public class AddMessage extends AbstractElementProcessor {
-
- @Override
- public void process(final TagProcessor tagProcessor) {
- tagProcessor.pushNewBuffer();
- tagProcessor.processUtilCloseTag();
- final String content = tagProcessor.popBuffer();
-
- final MessageBroker messageBroker = IsisContext.getMessageBroker();
- messageBroker.addMessage(content);
- }
-
- @Override
- public String getName() {
- return "add-message";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/AddWarning.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/AddWarning.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/AddWarning.java
deleted file mode 100644
index bc56ffc..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/AddWarning.java
+++ /dev/null
@@ -1,44 +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.display;
-
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.core.runtime.system.transaction.MessageBroker;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
-
-public class AddWarning extends AbstractElementProcessor {
-
- @Override
- public void process(final TagProcessor tagProcessor) {
- tagProcessor.pushNewBuffer();
- tagProcessor.processUtilCloseTag();
- final String content = tagProcessor.popBuffer();
-
- final MessageBroker messageBroker = IsisContext.getMessageBroker();
- messageBroker.addWarning(content);
- }
-
- @Override
- public String getName() {
- return "add-warning";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/Errors.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/Errors.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/Errors.java
deleted file mode 100644
index a172df4..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/Errors.java
+++ /dev/null
@@ -1,65 +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.display;
-
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
-
-public class Errors extends AbstractElementProcessor {
-
- @Override
- public void process(final TagProcessor tagProcessor) {
- final String cls = tagProcessor.getOptionalProperty(CLASS);
- final StringBuffer buffer = new StringBuffer();
- write(tagProcessor, cls, buffer);
- if (buffer.length() > 0) {
- tagProcessor.appendHtml("<div class=\"error\">");
- tagProcessor.appendHtml(buffer.toString());
- tagProcessor.appendHtml("</div>");
- }
- }
-
- public static void write(final TagProcessor tagProcessor, String cls, final StringBuffer buffer) {
- if (cls == null) {
- cls = "error";
- }
- final String message = (String) tagProcessor.getContext().getVariable("_error-message");
- if (message != null) {
- buffer.append(message);
- }
- final String details = (String) tagProcessor.getContext().getVariable("_error-details");
- if (details != null) {
- buffer.append(details);
- }
-
- /*
- * final MessageBroker messageBroker = IsisContext.getMessageBroker();
- * final List<String> warnings = messageBroker.getWarnings(); for (final
- * String warning : warnings) { buffer.append("<div class=\"" + cls +
- * "\">" + warning + "</div>"); }
- */
- }
-
- @Override
- public String getName() {
- return "errors";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/Feedback.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/Feedback.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/Feedback.java
deleted file mode 100644
index e8f4cd8..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/Feedback.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.display;
-
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
-
-public class Feedback extends AbstractElementProcessor {
-
- @Override
- public void process(final TagProcessor tagProcessor) {
- final String cls = tagProcessor.getOptionalProperty(CLASS);
- final StringBuffer buffer = new StringBuffer();
- Errors.write(tagProcessor, cls, buffer);
- Warnings.write(cls, buffer);
- Messages.write(cls, buffer);
- if (buffer.length() > 0) {
- tagProcessor.appendHtml("<div class=\"feedback\">");
- tagProcessor.appendHtml(buffer.toString());
- tagProcessor.appendHtml("</div>");
- }
- }
-
- @Override
- public String getName() {
- return "feedback";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/FieldLabel.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/FieldLabel.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/FieldLabel.java
deleted file mode 100644
index 7447424..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/FieldLabel.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.display;
-
-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.ForbiddenException;
-import org.apache.isis.viewer.scimpi.ScimpiException;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
-
-public class FieldLabel extends AbstractElementProcessor {
-
- // 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
- public void process(final TagProcessor tagProcessor) {
- final String id = tagProcessor.getOptionalProperty(OBJECT);
- final String fieldName = tagProcessor.getRequiredProperty(FIELD);
- final ObjectAdapter object = tagProcessor.getContext().getMappedObjectOrResult(id);
- final ObjectAssociation field = object.getSpecification().getAssociation(fieldName);
- if (field == null) {
- throw new ScimpiException("No field " + fieldName + " in " + object.getSpecification().getFullIdentifier());
- }
- if (field.isVisible(IsisContext.getAuthenticationSession(), object, where).isVetoed()) {
- throw new ForbiddenException(field, ForbiddenException.VISIBLE);
- }
- String delimiter = tagProcessor.getOptionalProperty("delimiter");
- if (delimiter == null) {
- delimiter = ": ";
- } else if (delimiter.equals("")) {
- delimiter = null;
- }
- write(tagProcessor, field, delimiter);
- }
-
- @Override
- public String getName() {
- return "label";
- }
-
- public static void write(final TagProcessor content, final ObjectAssociation field, final String delimiter) {
- final String description = field.getDescription();
- final String titleSegment = description == null || description.equals("") ? null : ("title=\"" + description + "\"");
- content.appendHtml("<span class=\"label\"" + titleSegment + ">");
- content.appendAsHtmlEncoded(field.getName());
- if (delimiter != null) {
- content.appendHtml("<span class=\"delimiter\">" + delimiter + "</span>");
- }
- content.appendHtml("</span>");
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/FieldValue.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/FieldValue.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/FieldValue.java
deleted file mode 100644
index bc68ca2..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/FieldValue.java
+++ /dev/null
@@ -1,118 +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.display;
-
-import org.apache.isis.applib.annotation.Where;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.facets.object.parseable.ParseableFacet;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
-import org.apache.isis.core.progmodel.facets.value.booleans.BooleanValueFacet;
-import org.apache.isis.core.runtime.persistence.ObjectNotFoundException;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.viewer.scimpi.ForbiddenException;
-import org.apache.isis.viewer.scimpi.ScimpiException;
-import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.view.field.LinkedObject;
-
-public class FieldValue extends AbstractElementProcessor {
-
- // 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
- public void process(final TagProcessor tagProcessor) {
- final String className = tagProcessor.getOptionalProperty(CLASS);
- final String id = tagProcessor.getOptionalProperty(OBJECT);
- final String fieldName = tagProcessor.getRequiredProperty(FIELD);
- final ObjectAdapter object = tagProcessor.getContext().getMappedObjectOrResult(id);
- final ObjectAssociation field = object.getSpecification().getAssociation(fieldName);
- if (field == null) {
- throw new ScimpiException("No field " + fieldName + " in " + object.getSpecification().getFullIdentifier());
- }
- if (field.isVisible(IsisContext.getAuthenticationSession(), object, where).isVetoed()) {
- throw new ForbiddenException(field, ForbiddenException.VISIBLE);
- }
- final boolean isIconShowing = tagProcessor.isRequested(SHOW_ICON, showIconByDefault());
- final int truncateTo = Integer.valueOf(tagProcessor.getOptionalProperty(TRUNCATE, "0")).intValue();
-
- write(tagProcessor, object, field, null, className, isIconShowing, truncateTo);
- }
-
- @Override
- public String getName() {
- return "field";
- }
-
- public static void write(final TagProcessor tagProcessor, final ObjectAdapter object, final ObjectAssociation field, final LinkedObject linkedField, final String className, final boolean showIcon, final int truncateTo) {
-
- final ObjectAdapter fieldReference = field.get(object);
-
- if (fieldReference != null) {
- final String classSection = "class=\"" + (className == null ? "value" : className) + "\"";
- tagProcessor.appendHtml("<span " + classSection + ">");
- if (field.isOneToOneAssociation()) {
- try {
- IsisContext.getPersistenceSession().resolveImmediately(fieldReference);
- } catch (final ObjectNotFoundException e) {
- tagProcessor.appendHtml(e.getMessage() + "</span>");
- }
- }
-
- if (!field.getSpecification().containsFacet(ParseableFacet.class) && showIcon) {
- tagProcessor.appendHtml("<img class=\"small-icon\" src=\"" + tagProcessor.getContext().imagePath(fieldReference) + "\" alt=\"" + field.getSpecification().getShortIdentifier() + "\"/>");
- }
-
- if (linkedField != null) {
- final String id = tagProcessor.getContext().mapObject(fieldReference, linkedField.getScope(), Scope.INTERACTION);
- tagProcessor.appendHtml("<a href=\"" + linkedField.getForwardView() + "?" + linkedField.getVariable() + "=" + id + tagProcessor.getContext().encodedInteractionParameters() + "\">");
- }
- String value = fieldReference == null ? "" : fieldReference.titleString();
- if (truncateTo > 0 && value.length() > truncateTo) {
- value = value.substring(0, truncateTo) + "...";
- }
-
- // TODO figure out a better way to determine if boolean or a
- // password
- final ObjectSpecification spec = field.getSpecification();
- final BooleanValueFacet facet = spec.getFacet(BooleanValueFacet.class);
- if (facet != null) {
- final boolean flag = facet.isSet(fieldReference);
- final String valueSegment = flag ? " checked=\"checked\"" : "";
- final String disabled = " disabled=\"disabled\"";
- tagProcessor.appendHtml("<input type=\"checkbox\"" + valueSegment + disabled + " />");
- } else {
- tagProcessor.appendAsHtmlEncoded(value);
- }
-
- if (linkedField != null) {
- tagProcessor.appendHtml("</a>");
- }
- tagProcessor.appendHtml("</span>");
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/GetField.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/GetField.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/GetField.java
deleted file mode 100644
index 4a76b6a..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/GetField.java
+++ /dev/null
@@ -1,103 +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.display;
-
-import java.text.DecimalFormat;
-import java.text.Format;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-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.spec.feature.ObjectAssociation;
-import org.apache.isis.core.progmodel.facets.value.date.DateValueFacet;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.viewer.scimpi.ForbiddenException;
-import org.apache.isis.viewer.scimpi.ScimpiException;
-import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
-import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
-
-public class GetField extends AbstractElementProcessor {
-
- // 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
- public void process(final TagProcessor tagProcessor) {
- final String id = tagProcessor.getOptionalProperty(OBJECT);
- final String fieldName = tagProcessor.getRequiredProperty(FIELD);
- final ObjectAdapter object = tagProcessor.getContext().getMappedObjectOrResult(id);
- if (object == null) {
- throw new ScimpiException("No object to get field for: " + fieldName + " - " + id);
- }
- final ObjectAssociation field = object.getSpecification().getAssociation(fieldName);
- if (field == null) {
- throw new ScimpiException("No field " + fieldName + " in " + object.getSpecification().getFullIdentifier());
- }
- final AuthenticationSession session = IsisContext.getAuthenticationSession();
- if (field.isVisible(session, object, where).isVetoed()) {
- throw new ForbiddenException(field, ForbiddenException.VISIBLE);
- }
-
- String pattern = tagProcessor.getOptionalProperty("decimal-format");
- Format format = null;
- if (pattern != null) {
- format = new DecimalFormat(pattern);
- }
- pattern = tagProcessor.getOptionalProperty("date-format");
- if (pattern != null) {
- format = new SimpleDateFormat(pattern);
- }
-
- final String name = tagProcessor.getOptionalProperty(RESULT_NAME, fieldName);
- final String scopeName = tagProcessor.getOptionalProperty(SCOPE);
- final Scope scope = Request.scope(scopeName, Scope.REQUEST);
-
- process(tagProcessor, object, field, format, name, scope);
- }
-
- protected void process(final TagProcessor tagProcessor, final ObjectAdapter object, final ObjectAssociation field, final Format format, final String name, final Scope scope) {
- final ObjectAdapter fieldReference = field.get(object);
- if (format != null && fieldReference.isValue()) {
- final DateValueFacet facet = fieldReference.getSpecification().getFacet(DateValueFacet.class);
- final Date date = facet.dateValue(fieldReference);
- final String value = format.format(date);
- tagProcessor.appendDebug(" " + object + " -> " + value);
- tagProcessor.getContext().addVariable(name, TagProcessor.getEncoder().encoder(value), scope);
- } else {
- final String source = fieldReference == null ? "" : tagProcessor.getContext().mapObject(fieldReference, scope);
- tagProcessor.appendDebug(" " + object + " -> " + source);
- tagProcessor.getContext().addVariable(name, source, scope);
- }
- }
-
- @Override
- public String getName() {
- return "get-field";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/IncludeObject.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/IncludeObject.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/IncludeObject.java
deleted file mode 100644
index 0972dd9..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/IncludeObject.java
+++ /dev/null
@@ -1,107 +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.display;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStreamReader;
-
-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.ForbiddenException;
-import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
-
-/**
- * Element to include another file that will display an object.
- */
-public class IncludeObject extends AbstractElementProcessor {
-
- // 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
- public void process(final TagProcessor tagProcessor) {
- final String path = tagProcessor.getOptionalProperty("file");
- String id = tagProcessor.getOptionalProperty(OBJECT);
- final String fieldName = tagProcessor.getOptionalProperty(FIELD);
- ObjectAdapter object = tagProcessor.getContext().getMappedObjectOrResult(id);
- if (fieldName != null) {
- final ObjectAssociation field = object.getSpecification().getAssociation(fieldName);
- if (field.isVisible(IsisContext.getAuthenticationSession(), object, where).isVetoed()) {
- throw new ForbiddenException(field, ForbiddenException.VISIBLE);
- }
- object = field.get(object);
- id = tagProcessor.getContext().mapObject(object, Scope.REQUEST);
- }
-
- if (object != null) {
- IsisContext.getPersistenceSession().resolveImmediately(object);
- tagProcessor.getContext().addVariable("_object", id, Scope.REQUEST);
- importFile(tagProcessor, path);
- }
- tagProcessor.closeEmpty();
- }
-
- private static void importFile(final TagProcessor tagProcessor, final String path) {
- // TODO load in file via HtmlFileParser
- final File file = new File(path);
- BufferedReader reader = null;
- try {
- if (file.exists()) {
- reader = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
- String line;
- while ((line = reader.readLine()) != null) {
- tagProcessor.appendHtml(line);
- }
- } else {
- tagProcessor.appendHtml("<P classs=\"error\">File " + path + " not found to import</P>");
- }
- } catch (final FileNotFoundException e) {
- throw new RuntimeException(e);
- } catch (final IOException e) {
- throw new RuntimeException(e);
- } finally {
- if (reader != null) {
- try {
- reader.close();
- } catch (final IOException e) {
- throw new RuntimeException(e);
- }
- }
- }
- }
-
- @Override
- public String getName() {
- return "include-object";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/ListView.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/ListView.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/ListView.java
deleted file mode 100644
index cf957fb..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/ListView.java
+++ /dev/null
@@ -1,93 +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.display;
-
-import java.util.Iterator;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacet;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
-import org.apache.isis.viewer.scimpi.Names;
-import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
-import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractObjectProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.view.field.LinkedObject;
-
-public class ListView extends AbstractObjectProcessor {
-
- @Override
- public String checkFieldType(final ObjectAssociation objectField) {
- return objectField.isOneToManyAssociation() ? null : "is not a collection";
- }
-
- @Override
- public void process(final TagProcessor tagProcessor, final ObjectAdapter object) {
- final String linkRowView = tagProcessor.getOptionalProperty(LINK_VIEW);
- final String linkObjectName = tagProcessor.getOptionalProperty(ELEMENT_NAME, Names.RESULT);
- final String linkObjectScope = tagProcessor.getOptionalProperty(SCOPE, Scope.INTERACTION.toString());
- LinkedObject linkedRow = null;
- if (linkRowView != null) {
- linkedRow = new LinkedObject(linkObjectName, linkObjectScope, tagProcessor.getContext().fullUriPath(linkRowView));
- }
- final String bulletType = tagProcessor.getOptionalProperty("type");
- write(tagProcessor, object, linkedRow, bulletType);
- }
-
- public static void write(final TagProcessor tagProcessor, final ObjectAdapter collection, final LinkedObject linkRow, final String bulletType) {
-
- if (bulletType == null) {
- tagProcessor.appendHtml("<ol>");
- } else {
- tagProcessor.appendHtml("<ul type=\"" + bulletType + "\">");
- }
-
- final CollectionFacet facet = collection.getSpecification().getFacet(CollectionFacet.class);
- final Iterator<ObjectAdapter> iterator = facet.iterator(collection);
- while (iterator.hasNext()) {
- final ObjectAdapter element = iterator.next();
-
- tagProcessor.appendHtml("<li>");
- if (linkRow != null) {
- final Scope scope = linkRow == null ? Scope.INTERACTION : Request.scope(linkRow.getScope());
- final String rowId = tagProcessor.getContext().mapObject(element, scope);
- tagProcessor.appendHtml("<a class=\"item-select\" href=\"" + linkRow.getForwardView() + "?" + linkRow.getVariable() + "=" + rowId + "\">");
- }
- tagProcessor.appendAsHtmlEncoded(element.titleString());
- if (linkRow != null) {
- tagProcessor.appendHtml("</a>");
- }
-
- tagProcessor.appendHtml("</li>\n");
- }
- if (bulletType == null) {
- tagProcessor.appendHtml("</ol>");
- } else {
- tagProcessor.appendHtml("</ul>");
- }
-
- }
-
- @Override
- public String getName() {
- return "list";
- }
-
-}
[05/24] Restructuring Scimpi to remove dependencies and enable easier
testing.
Posted by rm...@apache.org.
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/DebugCollectionView.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/DebugCollectionView.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/DebugCollectionView.java
index 9137783..bab6e54 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/DebugCollectionView.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/DebugCollectionView.java
@@ -23,33 +23,33 @@ import java.util.List;
import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
-import org.apache.isis.viewer.scimpi.dispatcher.AbstractObjectProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
-import org.apache.isis.viewer.scimpi.dispatcher.view.HelpLink;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractObjectProcessor;
import org.apache.isis.viewer.scimpi.dispatcher.view.field.LinkedObject;
+import org.apache.isis.viewer.scimpi.dispatcher.view.other.HelpLink;
public class DebugCollectionView extends AbstractObjectProcessor {
@Override
- public void process(final Request request, final ObjectAdapter object) {
- final String cls = request.getOptionalProperty(CLASS, "form");
+ public void process(final TagProcessor tagProcessor, final ObjectAdapter object) {
+ final String cls = tagProcessor.getOptionalProperty(CLASS, "form");
final String classString = " class=\"" + cls + "\"";
- String title = request.getOptionalProperty(FORM_TITLE);
- final String oddRowClass = request.getOptionalProperty(ODD_ROW_CLASS);
- final String evenRowClass = request.getOptionalProperty(EVEN_ROW_CLASS);
- final boolean showIcons = request.isRequested(SHOW_ICON, true);
+ String title = tagProcessor.getOptionalProperty(FORM_TITLE);
+ final String oddRowClass = tagProcessor.getOptionalProperty(ODD_ROW_CLASS);
+ final String evenRowClass = tagProcessor.getOptionalProperty(EVEN_ROW_CLASS);
+ final boolean showIcons = tagProcessor.isRequested(SHOW_ICON, true);
}
- private void write(final Request request, final ObjectAdapter object, final List<ObjectAssociation> fields,
+ private void write(final TagProcessor tagProcessor, final ObjectAdapter object, final List<ObjectAssociation> fields,
final LinkedObject[] linkFields, final String classString, final String title, final String oddRowClass,
final String evenRowClass, final boolean showIcons) {
- request.appendHtml("<div" + classString + ">");
+ tagProcessor.appendHtml("<div" + classString + ">");
if (title != null) {
- request.appendHtml("<div class=\"title\">");
- request.appendAsHtmlEncoded(title);
- request.appendHtml("</div>");
- HelpLink.append(request, object.getSpecification().getDescription(), object.getSpecification().getHelp());
+ tagProcessor.appendHtml("<div class=\"title\">");
+ tagProcessor.appendAsHtmlEncoded(title);
+ tagProcessor.appendHtml("</div>");
+ HelpLink.append(tagProcessor, object.getSpecification().getDescription(), object.getSpecification().getHelp());
}
/*
final List<ObjectAssociation> fields =
@@ -97,7 +97,7 @@ public class DebugCollectionView extends AbstractObjectProcessor {
request.appendHtml("</div>");
}
*/
- request.appendHtml("</div>");
+ tagProcessor.appendHtml("</div>");
}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/DebugObjectView.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/DebugObjectView.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/DebugObjectView.java
index 09563a2..cb16c94 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/DebugObjectView.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/DebugObjectView.java
@@ -29,9 +29,9 @@ import org.apache.isis.core.metamodel.spec.ObjectSpecification;
import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
import org.apache.isis.core.metamodel.spec.feature.ObjectAssociationFilters;
import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.viewer.scimpi.dispatcher.AbstractObjectProcessor;
-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.context.Request.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractObjectProcessor;
import org.apache.isis.viewer.scimpi.dispatcher.view.display.FieldValue;
import org.apache.isis.viewer.scimpi.dispatcher.view.field.LinkedObject;
@@ -39,25 +39,25 @@ import org.apache.isis.viewer.scimpi.dispatcher.view.field.LinkedObject;
public class DebugObjectView extends AbstractObjectProcessor {
@Override
- public void process(final Request request, final ObjectAdapter object) {
- final String classString = " class=\"" + request.getOptionalProperty(CLASS, "form debug") + "\"";
- final String objectLink = request.getOptionalProperty(OBJECT + "-" + LINK_VIEW, request.getViewPath());
+ public void process(final TagProcessor tagProcessor, final ObjectAdapter object) {
+ final String classString = " class=\"" + tagProcessor.getOptionalProperty(CLASS, "form debug") + "\"";
+ final String objectLink = tagProcessor.getOptionalProperty(OBJECT + "-" + LINK_VIEW, tagProcessor.getViewPath());
// final String collectionLink = request.getOptionalProperty(COLLECTION + "-" + LINK_VIEW, request.getViewPath());
- final String oddRowClass = request.getOptionalProperty(ODD_ROW_CLASS);
- final String evenRowClass = request.getOptionalProperty(EVEN_ROW_CLASS);
- final boolean showIcons = request.isRequested(SHOW_ICON, true);
+ final String oddRowClass = tagProcessor.getOptionalProperty(ODD_ROW_CLASS);
+ final String evenRowClass = tagProcessor.getOptionalProperty(EVEN_ROW_CLASS);
+ final boolean showIcons = tagProcessor.isRequested(SHOW_ICON, true);
ObjectSpecification specification = object.getSpecification();
- request.appendHtml("<div" + classString + ">");
- request.appendHtml("<div class=\"title\">");
- request.appendAsHtmlEncoded(specification.getSingularName() + " - " + specification.getFullIdentifier());
- request.appendHtml("</div>");
+ tagProcessor.appendHtml("<div" + classString + ">");
+ tagProcessor.appendHtml("<div class=\"title\">");
+ tagProcessor.appendAsHtmlEncoded(specification.getSingularName() + " - " + specification.getFullIdentifier());
+ tagProcessor.appendHtml("</div>");
Version version = object.getVersion();
- request.appendHtml("<div class=\"version\">");
- request.appendAsHtmlEncoded("#" + version.sequence() + " - " + version.getUser() + " (" + version.getTime() + ")" );
- request.appendHtml("</div>");
+ tagProcessor.appendHtml("<div class=\"version\">");
+ tagProcessor.appendAsHtmlEncoded("#" + version.sequence() + " - " + version.getUser() + " (" + version.getTime() + ")" );
+ tagProcessor.appendHtml("</div>");
final List<ObjectAssociation> fields = specification.getAssociations(ObjectAssociationFilters.ALL);
@@ -73,9 +73,9 @@ public class DebugObjectView extends AbstractObjectProcessor {
} else {
cls = " class=\"field " + (evenRowClass == null ? EVEN_ROW_CLASS : evenRowClass) + "\"";
}
- request.appendHtml("<div " + cls + "><span class=\"label\">");
- request.appendAsHtmlEncoded(field.getName());
- request.appendHtml(":</span>");
+ tagProcessor.appendHtml("<div " + cls + "><span class=\"label\">");
+ tagProcessor.appendAsHtmlEncoded(field.getName());
+ tagProcessor.appendHtml(":</span>");
final boolean isNotParseable =
!fields.get(i).getSpecification().containsFacet(ParseableFacet.class);
@@ -84,44 +84,44 @@ public class DebugObjectView extends AbstractObjectProcessor {
// linkedObject = new LinkedObject(field.isOneToManyAssociation() ? collectionLink : objectLink);
linkedObject = new LinkedObject(objectLink);
}
- addField(request, object, field, linkedObject, showIcons);
+ addField(tagProcessor, object, field, linkedObject, showIcons);
if (field.isOneToManyAssociation()) {
Collection collection = (Collection) field.get(object).getObject();
if (collection.size() == 0) {
- request.appendHtml("[empty]");
+ tagProcessor.appendHtml("[empty]");
} else {
// request.appendHtml(collection.size() + " elements");
- request.appendHtml("<ol>");
+ tagProcessor.appendHtml("<ol>");
for (Object element : collection) {
ObjectAdapter adapterFor = IsisContext.getPersistenceSession().getAdapterManager().getAdapterFor(element);
IsisContext.getPersistenceSession().resolveImmediately(adapterFor);
- String id = request.getContext().mapObject(adapterFor, linkedObject.getScope(), Scope.INTERACTION);
+ String id = tagProcessor.getContext().mapObject(adapterFor, linkedObject.getScope(), Scope.INTERACTION);
- request.appendHtml("<li class=\"element\">");
- request.appendHtml("<a href=\"" + linkedObject.getForwardView() + "?" + linkedObject.getVariable() + "="
- + id + request.getContext().encodedInteractionParameters() + "\">");
- request.appendHtml(element.toString());
- request.appendHtml("</a></li>");
+ tagProcessor.appendHtml("<li class=\"element\">");
+ tagProcessor.appendHtml("<a href=\"" + linkedObject.getForwardView() + "?" + linkedObject.getVariable() + "="
+ + id + tagProcessor.getContext().encodedInteractionParameters() + "\">");
+ tagProcessor.appendHtml(element.toString());
+ tagProcessor.appendHtml("</a></li>");
}
- request.appendHtml("</ol>");
+ tagProcessor.appendHtml("</ol>");
}
} else {
- FieldValue.write(request, object, field, linkedObject, "value", showIcons, 0);
+ FieldValue.write(tagProcessor, object, field, linkedObject, "value", showIcons, 0);
}
- request.appendHtml("</div>");
+ tagProcessor.appendHtml("</div>");
}
- request.appendHtml("</div>");
+ tagProcessor.appendHtml("</div>");
}
protected void addField(
- final Request request,
+ final TagProcessor tagProcessor,
final ObjectAdapter object,
final ObjectAssociation field,
final LinkedObject linkedObject,
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/DebuggerLink.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/DebuggerLink.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/DebuggerLink.java
index 795d272..64c7ecb 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/DebuggerLink.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/DebuggerLink.java
@@ -19,30 +19,30 @@
package org.apache.isis.viewer.scimpi.dispatcher.view.debug;
-import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public class DebuggerLink extends AbstractElementProcessor {
@Override
- public void process(final Request request) {
- if (request.getContext().isDebugDisabled()) {
- request.skipUntilClose();
+ public void process(final TagProcessor tagProcessor) {
+ if (tagProcessor.getContext().isDebugDisabled()) {
+ tagProcessor.skipUntilClose();
return;
}
- final RequestContext context = request.getContext();
- final Object result = context.getVariable(RequestContext.RESULT);
- request.appendHtml("<div class=\"debug\">");
- request.appendHtml("<a class=\"debug-link\" href=\"/debug/debug.shtml\" target=\"debug\" title=\"debug\" >...</a>");
+ final Request context = tagProcessor.getContext();
+ final Object result = context.getVariable(Request.RESULT);
+ tagProcessor.appendHtml("<div class=\"debug\">");
+ tagProcessor.appendHtml("<a class=\"debug-link\" href=\"/debug/debug.shtml\" target=\"debug\" title=\"debug\" >...</a>");
if (result != null) {
- request.appendHtml(" <a href=\"/debug/object.shtml?_result=" + result + "\" target=\"debug\" title=\"debug instance\">...</a>");
+ tagProcessor.appendHtml(" <a href=\"/debug/object.shtml?_result=" + result + "\" target=\"debug\" title=\"debug instance\">...</a>");
}
- request.appendHtml(" <span class=\"debug-link\" onclick=\"$('#page-debug').toggle()\" alt=\"show/hide debug details\">...</span>");
- request.appendHtml("</div>");
+ tagProcessor.appendHtml(" <span class=\"debug-link\" onclick=\"$('#page-debug').toggle()\" alt=\"show/hide debug details\">...</span>");
+ tagProcessor.appendHtml("</div>");
- request.processUtilCloseTag();
+ tagProcessor.processUtilCloseTag();
}
@Override
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Diagnostics.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Diagnostics.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Diagnostics.java
index 037812e..0033c55 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Diagnostics.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Diagnostics.java
@@ -22,54 +22,55 @@ package org.apache.isis.viewer.scimpi.dispatcher.view.debug;
import org.apache.isis.core.commons.authentication.AuthenticationSession;
import org.apache.isis.core.commons.debug.DebugHtmlString;
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.processor.Request;
+import org.apache.isis.viewer.scimpi.Names;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public class Diagnostics extends AbstractElementProcessor {
@Override
- public void process(final Request request) {
- if (request.getContext().isDebugDisabled()) {
+ public void process(final TagProcessor tagProcessor) {
+ if (tagProcessor.getContext().isDebugDisabled()) {
return;
}
- final String type = request.getOptionalProperty(TYPE, "page");
- final boolean isForced = request.isRequested("force");
- if (isForced || request.getContext().showDebugData()) {
- request.appendHtml("<div class=\"debug\">");
+ final String type = tagProcessor.getOptionalProperty(TYPE, "page");
+ final boolean isForced = tagProcessor.isRequested("force");
+ if (isForced || tagProcessor.getContext().showDebugData()) {
+ tagProcessor.appendHtml("<div class=\"debug\">");
if ("page".equals(type)) {
- request.appendHtml("<pre>");
- final RequestContext context = request.getContext();
- request.appendHtml("URI: " + context.getUri());
- request.appendHtml("\n");
- request.appendHtml("File: " + context.fullFilePath(context.getResourceFile()));
- final String result = (String) request.getContext().getVariable(RequestContext.RESULT);
+ tagProcessor.appendHtml("<pre>");
+ final Request context = tagProcessor.getContext();
+ tagProcessor.appendHtml("URI: " + context.getUri());
+ tagProcessor.appendHtml("\n");
+ tagProcessor.appendHtml("File: " + context.fullFilePath(context.getResourceFile()));
+ final String result = (String) tagProcessor.getContext().getVariable(Names.RESULT);
if (result != null) {
- request.appendHtml("\n");
- request.appendHtml("Object: " + result);
+ tagProcessor.appendHtml("\n");
+ tagProcessor.appendHtml("Object: " + result);
}
- request.appendHtml("</pre>");
+ tagProcessor.appendHtml("</pre>");
} else if ("session".equals(type)) {
- request.appendHtml("<pre>");
+ tagProcessor.appendHtml("<pre>");
final AuthenticationSession session = IsisContext.getAuthenticationSession();
- request.appendHtml("Session: " + session.getUserName() + " " + session.getRoles());
- request.appendHtml("</pre>");
+ tagProcessor.appendHtml("Session: " + session.getUserName() + " " + session.getRoles());
+ tagProcessor.appendHtml("</pre>");
} else if ("variables".equals(type)) {
- final RequestContext context = request.getContext();
+ final Request context = tagProcessor.getContext();
final DebugHtmlString debug = new DebugHtmlString();
debug.appendln("", "");
context.append(debug, "variables");
debug.close();
- request.appendHtml(debug.toString());
+ tagProcessor.appendHtml(debug.toString());
} else if ("processing".equals(type)) {
- request.appendHtml("<pre>");
- request.appendHtml(request.getContext().getDebugTrace());
- request.appendHtml("</pre>");
+ tagProcessor.appendHtml("<pre>");
+ tagProcessor.appendHtml(tagProcessor.getContext().getDebugTrace());
+ tagProcessor.appendHtml("</pre>");
} else {
- request.appendHtml("<i>No such type " + type + "</i>");
+ tagProcessor.appendHtml("<i>No such type " + type + "</i>");
}
- request.appendHtml("</div>");
+ tagProcessor.appendHtml("</div>");
}
}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Log.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Log.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Log.java
index 02144ad..ae07894 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Log.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Log.java
@@ -19,20 +19,20 @@
package org.apache.isis.viewer.scimpi.dispatcher.view.debug;
-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.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
import org.apache.log4j.Logger;
public class Log extends AbstractElementProcessor {
@Override
- public void process(final Request request) {
- String name = request.getRequiredProperty(NAME);
+ public void process(final TagProcessor tagProcessor) {
+ String name = tagProcessor.getRequiredProperty(NAME);
Logger logger = Logger.getLogger(name);
- request.pushNewBuffer();
- request.processUtilCloseTag();
- final String message = request.popBuffer();
+ tagProcessor.pushNewBuffer();
+ tagProcessor.processUtilCloseTag();
+ final String message = tagProcessor.popBuffer();
logger.info(message);
}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/LogLevel.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/LogLevel.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/LogLevel.java
index e12c9bc..9c954e6 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/LogLevel.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/LogLevel.java
@@ -22,31 +22,31 @@ package org.apache.isis.viewer.scimpi.dispatcher.view.debug;
import org.apache.log4j.Level;
import org.apache.log4j.LogManager;
-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.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public class LogLevel extends AbstractElementProcessor {
@Override
- public void process(final Request request) {
+ public void process(final TagProcessor tagProcessor) {
- String view = request.getOptionalProperty(VIEW, request.getViewPath());
- view = request.getContext().fullFilePath(view);
+ String view = tagProcessor.getOptionalProperty(VIEW, tagProcessor.getViewPath());
+ view = tagProcessor.getContext().fullFilePath(view);
final Level level = LogManager.getRootLogger().getLevel();
- final boolean showSelector = request.isRequested(SHOW_SELECT, true);
+ final boolean showSelector = tagProcessor.isRequested(SHOW_SELECT, true);
if (showSelector) {
- request.appendHtml("<form action=\"log.app\" type=\"post\" >");
- request.appendHtml("<input type=\"hidden\" name=\"view\" value=\"" + view + "\" />");
- request.appendHtml("<select name=\"level\">");
+ tagProcessor.appendHtml("<form action=\"log.app\" type=\"post\" >");
+ tagProcessor.appendHtml("<input type=\"hidden\" name=\"view\" value=\"" + view + "\" />");
+ tagProcessor.appendHtml("<select name=\"level\">");
for (final Level l : new Level[] { Level.OFF, Level.FATAL, Level.ERROR, Level.WARN, Level.INFO, Level.DEBUG, Level.TRACE }) {
final String settings = level + "\"" + (level == l ? " selected=\"selected\" " : "");
- request.appendHtml("<option " + settings + ">" + l + "</option>");
+ tagProcessor.appendHtml("<option " + settings + ">" + l + "</option>");
}
- request.appendHtml("<input type=\"submit\" value=\"Change Level\" />");
- request.appendHtml("</select>");
- request.appendHtml("</form>");
+ tagProcessor.appendHtml("<input type=\"submit\" value=\"Change Level\" />");
+ tagProcessor.appendHtml("</select>");
+ tagProcessor.appendHtml("</form>");
} else {
- request.appendHtml(level.toString());
+ tagProcessor.appendHtml(level.toString());
}
}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Members.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Members.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Members.java
index 9fc0665..4f9e084 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Members.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Members.java
@@ -30,10 +30,10 @@ import org.apache.isis.core.metamodel.spec.feature.ObjectActionContainer.Contrib
import org.apache.isis.core.metamodel.spec.feature.ObjectActionParameter;
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.ScimpiException;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
+import org.apache.isis.viewer.scimpi.ForbiddenException;
+import org.apache.isis.viewer.scimpi.ScimpiException;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public class Members extends AbstractElementProcessor {
@@ -50,16 +50,16 @@ public class Members extends AbstractElementProcessor {
}
@Override
- public void process(final Request request) {
- if (request.getContext().isDebugDisabled()) {
+ public void process(final TagProcessor tagProcessor) {
+ if (tagProcessor.getContext().isDebugDisabled()) {
return;
}
- final String id = request.getOptionalProperty(OBJECT);
- final String fieldName = request.getOptionalProperty(FIELD);
- request.appendHtml("<pre class=\"debug\">");
+ final String id = tagProcessor.getOptionalProperty(OBJECT);
+ final String fieldName = tagProcessor.getOptionalProperty(FIELD);
+ tagProcessor.appendHtml("<pre class=\"debug\">");
try {
- ObjectAdapter object = request.getContext().getMappedObjectOrResult(id);
+ ObjectAdapter object = tagProcessor.getContext().getMappedObjectOrResult(id);
ObjectAssociation field = null;
if (fieldName != null) {
field = object.getSpecification().getAssociation(fieldName);
@@ -68,40 +68,40 @@ public class Members extends AbstractElementProcessor {
}
object = field.get(object);
}
- request.processUtilCloseTag();
+ tagProcessor.processUtilCloseTag();
final ObjectSpecification specification = field == null ? object.getSpecification() : field.getSpecification();
- request.appendHtml(specification.getSingularName() + " (" + specification.getFullIdentifier() + ") \n");
+ tagProcessor.appendHtml(specification.getSingularName() + " (" + specification.getFullIdentifier() + ") \n");
final List<ObjectAssociation> fields = specification.getAssociations();
for (final ObjectAssociation fld : fields) {
if (!fld.isAlwaysHidden()) {
- request.appendHtml(" " + fld.getId() + " - '" + fld.getName() + "' -> " + fld.getSpecification().getSingularName() + (fld.isOneToManyAssociation() ? " (collection of)" : "") + "\n");
+ tagProcessor.appendHtml(" " + fld.getId() + " - '" + fld.getName() + "' -> " + fld.getSpecification().getSingularName() + (fld.isOneToManyAssociation() ? " (collection of)" : "") + "\n");
}
}
- request.appendHtml(" --------------\n");
+ tagProcessor.appendHtml(" --------------\n");
final List<ObjectAction> actions = specification.getObjectActions(ActionType.USER, Contributed.INCLUDED);
;
for (final ObjectAction action : actions) {
- request.appendHtml(" " + action.getId() + " (");
+ tagProcessor.appendHtml(" " + action.getId() + " (");
boolean first = true;
for (final ObjectActionParameter parameter : action.getParameters()) {
if (!first) {
- request.appendHtml(", ");
+ tagProcessor.appendHtml(", ");
}
- request.appendHtml(parameter.getSpecification().getSingularName());
+ tagProcessor.appendHtml(parameter.getSpecification().getSingularName());
first = false;
}
- request.appendHtml(")" + " - '" + action.getName() + "'");
+ tagProcessor.appendHtml(")" + " - '" + action.getName() + "'");
if (action.getSpecification() != null) {
- request.appendHtml(" -> " + action.getSpecification().getSingularName() + ")");
+ tagProcessor.appendHtml(" -> " + action.getSpecification().getSingularName() + ")");
}
- request.appendHtml("\n");
+ tagProcessor.appendHtml("\n");
}
} catch (final ScimpiException e) {
- request.appendHtml("Debug failed: " + e.getMessage());
+ tagProcessor.appendHtml("Debug failed: " + e.getMessage());
}
- request.appendHtml("</pre>");
+ tagProcessor.appendHtml("</pre>");
}
}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/ShowDebug.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/ShowDebug.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/ShowDebug.java
index 895f9a6..5ed423b 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/ShowDebug.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/ShowDebug.java
@@ -19,17 +19,17 @@
package org.apache.isis.viewer.scimpi.dispatcher.view.debug;
-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.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public class ShowDebug extends AbstractElementProcessor {
@Override
- public void process(final Request request) {
- if (request.getContext().isDebugDisabled()) {
- request.skipUntilClose();
+ public void process(final TagProcessor tagProcessor) {
+ if (tagProcessor.getContext().isDebugDisabled()) {
+ tagProcessor.skipUntilClose();
} else {
- request.processUtilCloseTag();
+ tagProcessor.processUtilCloseTag();
}
}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Specification.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Specification.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Specification.java
index 1421290..db6cc57 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Specification.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Specification.java
@@ -26,53 +26,53 @@ import org.apache.commons.lang.StringUtils;
import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
import org.apache.isis.core.metamodel.spec.ObjectSpecification;
import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
-import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public class Specification extends AbstractElementProcessor {
@Override
- public void process(final Request request) {
- final RequestContext context = request.getContext();
+ public void process(final TagProcessor tagProcessor) {
+ final Request context = tagProcessor.getContext();
if (context.isDebugDisabled()) {
return;
}
- if (request.isRequested("always") || context.getDebug() == RequestContext.Debug.ON) {
- request.appendHtml("<div class=\"debug\">");
- request.appendHtml("<pre>");
+ if (tagProcessor.isRequested("always") || context.getDebug() == Request.Debug.ON) {
+ tagProcessor.appendHtml("<div class=\"debug\">");
+ tagProcessor.appendHtml("<pre>");
- final String id = request.getOptionalProperty("object");
+ final String id = tagProcessor.getOptionalProperty("object");
final ObjectAdapter object = context.getMappedObjectOrResult(id);
final ObjectSpecification specification = object.getSpecification();
- String type = request.getOptionalProperty(TYPE, "details");
+ String type = tagProcessor.getOptionalProperty(TYPE, "details");
if (type.equals("graph")) {
- specificationGraph(request, specification, null, new ArrayList<ObjectSpecification>(), 0);
+ specificationGraph(tagProcessor, specification, null, new ArrayList<ObjectSpecification>(), 0);
} else if (type.equals("details")) {
- specificationDetails(request, specification);
+ specificationDetails(tagProcessor, specification);
} else {
- request.appendHtml("invalid type: " + type);
+ tagProcessor.appendHtml("invalid type: " + type);
}
- request.appendHtml("</pre>");
- request.appendHtml("</div>");
+ tagProcessor.appendHtml("</pre>");
+ tagProcessor.appendHtml("</div>");
}
}
- private void specificationDetails(final Request request, final ObjectSpecification specification) {
- renderName(request, specification);
+ private void specificationDetails(final TagProcessor tagProcessor, final ObjectSpecification specification) {
+ renderName(tagProcessor, specification);
final List<ObjectAssociation> fields = specification.getAssociations();
for (int i = 0; i < fields.size(); i++) {
- request.appendHtml(" " + fields.get(i).getName() + " (" + fields.get(i).getSpecification().getSingularName()
+ tagProcessor.appendHtml(" " + fields.get(i).getName() + " (" + fields.get(i).getSpecification().getSingularName()
+ ") \n");
}
}
private void specificationGraph(
- Request request,
+ TagProcessor tagProcessor,
ObjectSpecification specification,
String fieldName,
List<ObjectSpecification> processed,
@@ -81,15 +81,15 @@ public class Specification extends AbstractElementProcessor {
return;
}
- request.appendHtml(StringUtils.repeat(" ", level));
+ tagProcessor.appendHtml(StringUtils.repeat(" ", level));
if (processed.contains(specification)) {
- request.appendHtml("* ");
+ tagProcessor.appendHtml("* ");
}
- request.appendHtml(specification.getFullIdentifier());
+ tagProcessor.appendHtml(specification.getFullIdentifier());
if (fieldName != null) {
- request.appendHtml(" (" + fieldName + ")");
+ tagProcessor.appendHtml(" (" + fieldName + ")");
}
- request.appendHtml("\n");
+ tagProcessor.appendHtml("\n");
if (processed.contains(specification)) {
return;
@@ -102,12 +102,12 @@ public class Specification extends AbstractElementProcessor {
if (fieldSpecification.isValue()) {
continue;
}
- specificationGraph(request, fieldSpecification, fields.get(i).getName(), processed, level + 1);
+ specificationGraph(tagProcessor, fieldSpecification, fields.get(i).getName(), processed, level + 1);
}
}
- private void renderName(final Request request, final ObjectSpecification specification) {
- request.appendHtml(specification.getSingularName() + " (" + specification.getFullIdentifier() + ") \n");
+ private void renderName(final TagProcessor tagProcessor, final ObjectSpecification specification) {
+ tagProcessor.appendHtml(specification.getSingularName() + " (" + specification.getFullIdentifier() + ") \n");
}
@Override
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/ThrowException.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/ThrowException.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/ThrowException.java
index 65af85e..8a458b8 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/ThrowException.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/ThrowException.java
@@ -20,18 +20,18 @@
package org.apache.isis.viewer.scimpi.dispatcher.view.debug;
import org.apache.isis.core.commons.exceptions.IsisException;
-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.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public class ThrowException extends AbstractElementProcessor {
@Override
- public void process(final Request request) {
- if (request.getContext().isDebugDisabled()) {
+ public void process(final TagProcessor tagProcessor) {
+ if (tagProcessor.getContext().isDebugDisabled()) {
return;
}
- final String message = request.getOptionalProperty("message", "Exception throw for testing purposes");
+ final String message = tagProcessor.getOptionalProperty("message", "Exception throw for testing purposes");
throw new IsisException(message);
}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/AbstractFormView.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/AbstractFormView.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/AbstractFormView.java
index 872f657..28c3c65 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/AbstractFormView.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/AbstractFormView.java
@@ -28,11 +28,11 @@ import org.apache.isis.core.metamodel.facets.object.parseable.ParseableFacet;
import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
import org.apache.isis.core.metamodel.spec.feature.ObjectAssociationFilters;
import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.viewer.scimpi.dispatcher.AbstractObjectProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
-import org.apache.isis.viewer.scimpi.dispatcher.view.HelpLink;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractObjectProcessor;
import org.apache.isis.viewer.scimpi.dispatcher.view.field.LinkedFieldsBlock;
import org.apache.isis.viewer.scimpi.dispatcher.view.field.LinkedObject;
+import org.apache.isis.viewer.scimpi.dispatcher.view.other.HelpLink;
public abstract class AbstractFormView extends AbstractObjectProcessor {
@@ -42,22 +42,22 @@ public abstract class AbstractFormView extends AbstractObjectProcessor {
}
@Override
- public void process(final Request request, final ObjectAdapter object) {
+ public void process(final TagProcessor tagProcessor, final ObjectAdapter object) {
final LinkedFieldsBlock tag = new LinkedFieldsBlock();
if (object != null) {
- final String id = request.getOptionalProperty(ID, object.getSpecification().getShortIdentifier());
- final String cls = request.getOptionalProperty(CLASS, "form");
+ final String id = tagProcessor.getOptionalProperty(ID, object.getSpecification().getShortIdentifier());
+ final String cls = tagProcessor.getOptionalProperty(CLASS, "form");
final String classString = " id=\"" + id + "\" class=\"" + cls + "\"";
- String title = request.getOptionalProperty(FORM_TITLE);
- final String oddRowClass = request.getOptionalProperty(ODD_ROW_CLASS);
- final String evenRowClass = request.getOptionalProperty(EVEN_ROW_CLASS);
- final String labelDelimiter = request.getOptionalProperty(LABEL_DELIMITER, ":");
- final boolean showIcons = request.isRequested(SHOW_ICON, showIconByDefault());
- String linkAllView = request.getOptionalProperty(LINK_VIEW);
+ String title = tagProcessor.getOptionalProperty(FORM_TITLE);
+ final String oddRowClass = tagProcessor.getOptionalProperty(ODD_ROW_CLASS);
+ final String evenRowClass = tagProcessor.getOptionalProperty(EVEN_ROW_CLASS);
+ final String labelDelimiter = tagProcessor.getOptionalProperty(LABEL_DELIMITER, ":");
+ final boolean showIcons = tagProcessor.isRequested(SHOW_ICON, showIconByDefault());
+ String linkAllView = tagProcessor.getOptionalProperty(LINK_VIEW);
- request.setBlockContent(tag);
- request.processUtilCloseTag();
+ tagProcessor.setBlockContent(tag);
+ tagProcessor.processUtilCloseTag();
final AuthenticationSession session = IsisContext.getAuthenticationSession();
List<ObjectAssociation> associations = object.getSpecification().getAssociations(ObjectAssociationFilters.dynamicallyVisible(session, object, Where.OBJECT_FORMS));
@@ -65,7 +65,7 @@ public abstract class AbstractFormView extends AbstractObjectProcessor {
final LinkedObject[] linkFields = tag.linkedFields(fields);
if (linkAllView != null) {
- linkAllView = request.getContext().fullUriPath(linkAllView);
+ linkAllView = tagProcessor.getContext().fullUriPath(linkAllView);
for (int i = 0; i < linkFields.length; i++) {
final boolean isObject = fields.get(i).isOneToOneAssociation();
final boolean isNotParseable = !fields.get(i).getSpecification().containsFacet(ParseableFacet.class);
@@ -79,14 +79,14 @@ public abstract class AbstractFormView extends AbstractObjectProcessor {
title = null;
}
- write(request, object, fields, linkFields, classString, title, labelDelimiter, oddRowClass, evenRowClass, showIcons);
+ write(tagProcessor, object, fields, linkFields, classString, title, labelDelimiter, oddRowClass, evenRowClass, showIcons);
} else {
- request.skipUntilClose();
+ tagProcessor.skipUntilClose();
}
}
private void write(
- final Request request,
+ final TagProcessor tagProcessor,
final ObjectAdapter object,
final List<ObjectAssociation> fields,
final LinkedObject[] linkFields,
@@ -96,12 +96,12 @@ public abstract class AbstractFormView extends AbstractObjectProcessor {
final String oddRowClass,
final String evenRowClass,
final boolean showIcons) {
- request.appendHtml("<div" + classString + ">");
+ tagProcessor.appendHtml("<div" + classString + ">");
if (title != null) {
- request.appendHtml("<div class=\"title\">");
- request.appendAsHtmlEncoded(title);
- request.appendHtml("</div>");
- HelpLink.append(request, object.getSpecification().getDescription(), object.getSpecification().getHelp());
+ tagProcessor.appendHtml("<div class=\"title\">");
+ tagProcessor.appendAsHtmlEncoded(title);
+ tagProcessor.appendHtml("</div>");
+ HelpLink.append(tagProcessor, object.getSpecification().getDescription(), object.getSpecification().getHelp());
}
int row = 1;
for (int i = 0; i < fields.size(); i++) {
@@ -120,19 +120,19 @@ public abstract class AbstractFormView extends AbstractObjectProcessor {
} else {
cls = " class=\"field " + (evenRowClass == null ? EVEN_ROW_CLASS : evenRowClass) + "\"";
}
- request.appendHtml("<div " + cls + description + "><span class=\"label\">");
- request.appendAsHtmlEncoded(field.getName());
- request.appendHtml(labelDelimiter + "</span>");
+ tagProcessor.appendHtml("<div " + cls + description + "><span class=\"label\">");
+ tagProcessor.appendAsHtmlEncoded(field.getName());
+ tagProcessor.appendHtml(labelDelimiter + "</span>");
final LinkedObject linkedObject = linkFields[i];
- addField(request, object, field, linkedObject, showIcons);
- HelpLink.append(request, field.getDescription(), field.getHelp());
- request.appendHtml("</div>");
+ addField(tagProcessor, object, field, linkedObject, showIcons);
+ HelpLink.append(tagProcessor, field.getDescription(), field.getHelp());
+ tagProcessor.appendHtml("</div>");
}
- request.appendHtml("</div>");
+ tagProcessor.appendHtml("</div>");
}
- protected void addField(final Request request, final ObjectAdapter object, final ObjectAssociation field, final LinkedObject linkedObject, final boolean showIcons) {
- FieldValue.write(request, object, field, linkedObject, null, showIcons, 0);
+ protected void addField(final TagProcessor tagProcessor, final ObjectAdapter object, final ObjectAssociation field, final LinkedObject linkedObject, final boolean showIcons) {
+ FieldValue.write(tagProcessor, object, field, linkedObject, null, showIcons, 0);
}
protected boolean ignoreField(final ObjectAssociation objectField) {
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/AbstractTableView.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/AbstractTableView.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/AbstractTableView.java
index 9482209..f47bd60 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/AbstractTableView.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/AbstractTableView.java
@@ -31,11 +31,11 @@ import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
import org.apache.isis.core.metamodel.spec.feature.ObjectAssociationFilters;
import org.apache.isis.core.runtime.system.context.IsisContext;
import org.apache.isis.core.runtime.system.persistence.Persistor;
-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;
+import org.apache.isis.viewer.scimpi.ScimpiException;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public abstract class AbstractTableView extends AbstractElementProcessor {
@@ -47,18 +47,18 @@ public abstract class AbstractTableView extends AbstractElementProcessor {
private final Where where = Where.ALL_TABLES;
@Override
- public void process(final Request request) {
- final RequestContext context = request.getContext();
+ public void process(final TagProcessor tagProcessor) {
+ final Request context = tagProcessor.getContext();
ObjectAdapter collection;
String parentObjectId = null;
boolean isFieldEditable = false;
- final String field = request.getOptionalProperty(FIELD);
- final String tableClass = request.getOptionalProperty(CLASS);
+ final String field = tagProcessor.getOptionalProperty(FIELD);
+ final String tableClass = tagProcessor.getOptionalProperty(CLASS);
ObjectSpecification elementSpec;
String tableId;
if (field != null) {
- final String objectId = request.getOptionalProperty(OBJECT);
+ final String objectId = tagProcessor.getOptionalProperty(OBJECT);
final ObjectAdapter object = context.getMappedObjectOrResult(objectId);
if (object == null) {
throw new ScimpiException("No object for result or " + objectId);
@@ -73,24 +73,24 @@ public abstract class AbstractTableView extends AbstractElementProcessor {
final TypeOfFacet facet = objectField.getFacet(TypeOfFacet.class);
elementSpec = facet.valueSpec();
parentObjectId = objectId == null ? context.mapObject(object, Scope.REQUEST) : objectId;
- tableId = request.getOptionalProperty(ID, field);
+ tableId = tagProcessor.getOptionalProperty(ID, field);
} else {
- final String id = request.getOptionalProperty(COLLECTION);
+ final String id = tagProcessor.getOptionalProperty(COLLECTION);
collection = context.getMappedObjectOrResult(id);
elementSpec = collection.getElementSpecification();
- tableId = request.getOptionalProperty(ID, collection.getElementSpecification().getShortIdentifier());
+ tableId = tagProcessor.getOptionalProperty(ID, collection.getElementSpecification().getShortIdentifier());
}
- final String summary = request.getOptionalProperty("summary");
- final String rowClassesList = request.getOptionalProperty(ROW_CLASSES, ODD_ROW_CLASS + "|" + EVEN_ROW_CLASS);
+ final String summary = tagProcessor.getOptionalProperty("summary");
+ final String rowClassesList = tagProcessor.getOptionalProperty(ROW_CLASSES, ODD_ROW_CLASS + "|" + EVEN_ROW_CLASS);
String[] rowClasses = null;
if (rowClassesList.length() > 0) {
rowClasses = rowClassesList.split("[,|/]");
}
final List<ObjectAssociation> allFields = elementSpec.getAssociations(ObjectAssociationFilters.WHEN_VISIBLE_IRRESPECTIVE_OF_WHERE);
- final TableContentWriter rowBuilder = createRowBuilder(request, context, isFieldEditable ? parentObjectId : null, allFields, collection);
- write(request, collection, summary, rowBuilder, tableId, tableClass, rowClasses);
+ final TableContentWriter rowBuilder = createRowBuilder(tagProcessor, context, isFieldEditable ? parentObjectId : null, allFields, collection);
+ write(tagProcessor, collection, summary, rowBuilder, tableId, tableClass, rowClasses);
}
@@ -98,27 +98,27 @@ public abstract class AbstractTableView extends AbstractElementProcessor {
return IsisContext.getPersistenceSession();
}
- protected abstract TableContentWriter createRowBuilder(final Request request, RequestContext context, final String parent, final List<ObjectAssociation> allFields, ObjectAdapter collection);
+ protected abstract TableContentWriter createRowBuilder(final TagProcessor tagProcessor, Request context, final String parent, final List<ObjectAssociation> allFields, ObjectAdapter collection);
public static void write(
- final Request request,
+ final TagProcessor tagProcessor,
final ObjectAdapter collection,
final String summary,
final TableContentWriter rowBuilder,
final String tableId,
final String tableClass,
final String[] rowClasses) {
- final RequestContext context = request.getContext();
+ final Request context = tagProcessor.getContext();
final String summarySegment = summary == null ? "" : (" summary=\"" + summary + "\"");
final String idSegment = tableId == null ? "" : (" id=\"" + tableId + "\"");
final String classSegment = tableClass == null ? "" : (" class=\"" + tableClass + "\"");
- request.appendHtml("<table" + idSegment + classSegment + summarySegment + ">");
- rowBuilder.writeCaption(request);
- rowBuilder.writeHeaders(request);
- rowBuilder.writeFooters(request);
+ tagProcessor.appendHtml("<table" + idSegment + classSegment + summarySegment + ">");
+ rowBuilder.writeCaption(tagProcessor);
+ rowBuilder.writeHeaders(tagProcessor);
+ rowBuilder.writeFooters(tagProcessor);
- request.appendHtml("<tbody>");
+ tagProcessor.appendHtml("<tbody>");
final CollectionFacet facet = collection.getSpecification().getFacet(CollectionFacet.class);
final Iterator<ObjectAdapter> iterator = facet.iterator(collection);
int row = 1;
@@ -130,13 +130,13 @@ public abstract class AbstractTableView extends AbstractElementProcessor {
if (rowClasses != null) {
cls = " class=\"" + rowClasses[row % rowClasses.length] + "\"";
}
- request.appendHtml("<tr" + cls + ">");
- rowBuilder.writeElement(request, context, element);
- request.appendHtml("</tr>");
+ tagProcessor.appendHtml("<tr" + cls + ">");
+ rowBuilder.writeElement(tagProcessor, context, element);
+ tagProcessor.appendHtml("</tr>");
row++;
}
- request.appendHtml("</tbody>");
- request.appendHtml("</table>");
+ tagProcessor.appendHtml("</tbody>");
+ tagProcessor.appendHtml("</table>");
rowBuilder.tidyUp();
}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/AddMessage.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/AddMessage.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/AddMessage.java
index acb53eb..4e3bbbb 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/AddMessage.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/AddMessage.java
@@ -21,16 +21,16 @@ package org.apache.isis.viewer.scimpi.dispatcher.view.display;
import org.apache.isis.core.runtime.system.context.IsisContext;
import org.apache.isis.core.runtime.system.transaction.MessageBroker;
-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.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public class AddMessage extends AbstractElementProcessor {
@Override
- public void process(final Request request) {
- request.pushNewBuffer();
- request.processUtilCloseTag();
- final String content = request.popBuffer();
+ public void process(final TagProcessor tagProcessor) {
+ tagProcessor.pushNewBuffer();
+ tagProcessor.processUtilCloseTag();
+ final String content = tagProcessor.popBuffer();
final MessageBroker messageBroker = IsisContext.getMessageBroker();
messageBroker.addMessage(content);
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/AddWarning.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/AddWarning.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/AddWarning.java
index 59d3dcc..bc56ffc 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/AddWarning.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/AddWarning.java
@@ -21,16 +21,16 @@ package org.apache.isis.viewer.scimpi.dispatcher.view.display;
import org.apache.isis.core.runtime.system.context.IsisContext;
import org.apache.isis.core.runtime.system.transaction.MessageBroker;
-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.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public class AddWarning extends AbstractElementProcessor {
@Override
- public void process(final Request request) {
- request.pushNewBuffer();
- request.processUtilCloseTag();
- final String content = request.popBuffer();
+ public void process(final TagProcessor tagProcessor) {
+ tagProcessor.pushNewBuffer();
+ tagProcessor.processUtilCloseTag();
+ final String content = tagProcessor.popBuffer();
final MessageBroker messageBroker = IsisContext.getMessageBroker();
messageBroker.addWarning(content);
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/Errors.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/Errors.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/Errors.java
index 960997d..a172df4 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/Errors.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/Errors.java
@@ -19,32 +19,32 @@
package org.apache.isis.viewer.scimpi.dispatcher.view.display;
-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.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public class Errors extends AbstractElementProcessor {
@Override
- public void process(final Request request) {
- final String cls = request.getOptionalProperty(CLASS);
+ public void process(final TagProcessor tagProcessor) {
+ final String cls = tagProcessor.getOptionalProperty(CLASS);
final StringBuffer buffer = new StringBuffer();
- write(request, cls, buffer);
+ write(tagProcessor, cls, buffer);
if (buffer.length() > 0) {
- request.appendHtml("<div class=\"error\">");
- request.appendHtml(buffer.toString());
- request.appendHtml("</div>");
+ tagProcessor.appendHtml("<div class=\"error\">");
+ tagProcessor.appendHtml(buffer.toString());
+ tagProcessor.appendHtml("</div>");
}
}
- public static void write(final Request request, String cls, final StringBuffer buffer) {
+ public static void write(final TagProcessor tagProcessor, String cls, final StringBuffer buffer) {
if (cls == null) {
cls = "error";
}
- final String message = (String) request.getContext().getVariable("_error-message");
+ final String message = (String) tagProcessor.getContext().getVariable("_error-message");
if (message != null) {
buffer.append(message);
}
- final String details = (String) request.getContext().getVariable("_error-details");
+ final String details = (String) tagProcessor.getContext().getVariable("_error-details");
if (details != null) {
buffer.append(details);
}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/Feedback.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/Feedback.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/Feedback.java
index f734ce2..e8f4cd8 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/Feedback.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/Feedback.java
@@ -19,22 +19,22 @@
package org.apache.isis.viewer.scimpi.dispatcher.view.display;
-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.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public class Feedback extends AbstractElementProcessor {
@Override
- public void process(final Request request) {
- final String cls = request.getOptionalProperty(CLASS);
+ public void process(final TagProcessor tagProcessor) {
+ final String cls = tagProcessor.getOptionalProperty(CLASS);
final StringBuffer buffer = new StringBuffer();
- Errors.write(request, cls, buffer);
+ Errors.write(tagProcessor, cls, buffer);
Warnings.write(cls, buffer);
Messages.write(cls, buffer);
if (buffer.length() > 0) {
- request.appendHtml("<div class=\"feedback\">");
- request.appendHtml(buffer.toString());
- request.appendHtml("</div>");
+ tagProcessor.appendHtml("<div class=\"feedback\">");
+ tagProcessor.appendHtml(buffer.toString());
+ tagProcessor.appendHtml("</div>");
}
}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/FieldLabel.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/FieldLabel.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/FieldLabel.java
index 32e2cd8..7447424 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/FieldLabel.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/FieldLabel.java
@@ -23,10 +23,10 @@ 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.ScimpiException;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
+import org.apache.isis.viewer.scimpi.ForbiddenException;
+import org.apache.isis.viewer.scimpi.ScimpiException;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public class FieldLabel extends AbstractElementProcessor {
@@ -38,10 +38,10 @@ public class FieldLabel extends AbstractElementProcessor {
private final Where where = Where.ANYWHERE;
@Override
- public void process(final Request request) {
- final String id = request.getOptionalProperty(OBJECT);
- final String fieldName = request.getRequiredProperty(FIELD);
- final ObjectAdapter object = request.getContext().getMappedObjectOrResult(id);
+ public void process(final TagProcessor tagProcessor) {
+ final String id = tagProcessor.getOptionalProperty(OBJECT);
+ final String fieldName = tagProcessor.getRequiredProperty(FIELD);
+ final ObjectAdapter object = tagProcessor.getContext().getMappedObjectOrResult(id);
final ObjectAssociation field = object.getSpecification().getAssociation(fieldName);
if (field == null) {
throw new ScimpiException("No field " + fieldName + " in " + object.getSpecification().getFullIdentifier());
@@ -49,13 +49,13 @@ public class FieldLabel extends AbstractElementProcessor {
if (field.isVisible(IsisContext.getAuthenticationSession(), object, where).isVetoed()) {
throw new ForbiddenException(field, ForbiddenException.VISIBLE);
}
- String delimiter = request.getOptionalProperty("delimiter");
+ String delimiter = tagProcessor.getOptionalProperty("delimiter");
if (delimiter == null) {
delimiter = ": ";
} else if (delimiter.equals("")) {
delimiter = null;
}
- write(request, field, delimiter);
+ write(tagProcessor, field, delimiter);
}
@Override
@@ -63,7 +63,7 @@ public class FieldLabel extends AbstractElementProcessor {
return "label";
}
- public static void write(final Request content, final ObjectAssociation field, final String delimiter) {
+ public static void write(final TagProcessor content, final ObjectAssociation field, final String delimiter) {
final String description = field.getDescription();
final String titleSegment = description == null || description.equals("") ? null : ("title=\"" + description + "\"");
content.appendHtml("<span class=\"label\"" + titleSegment + ">");
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/FieldValue.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/FieldValue.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/FieldValue.java
index e739603..bc68ca2 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/FieldValue.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/FieldValue.java
@@ -27,11 +27,11 @@ import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
import org.apache.isis.core.progmodel.facets.value.booleans.BooleanValueFacet;
import org.apache.isis.core.runtime.persistence.ObjectNotFoundException;
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.ScimpiException;
-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.ForbiddenException;
+import org.apache.isis.viewer.scimpi.ScimpiException;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
import org.apache.isis.viewer.scimpi.dispatcher.view.field.LinkedObject;
public class FieldValue extends AbstractElementProcessor {
@@ -44,11 +44,11 @@ public class FieldValue extends AbstractElementProcessor {
private final Where where = Where.ANYWHERE;
@Override
- public void process(final Request request) {
- final String className = request.getOptionalProperty(CLASS);
- final String id = request.getOptionalProperty(OBJECT);
- final String fieldName = request.getRequiredProperty(FIELD);
- final ObjectAdapter object = request.getContext().getMappedObjectOrResult(id);
+ public void process(final TagProcessor tagProcessor) {
+ final String className = tagProcessor.getOptionalProperty(CLASS);
+ final String id = tagProcessor.getOptionalProperty(OBJECT);
+ final String fieldName = tagProcessor.getRequiredProperty(FIELD);
+ final ObjectAdapter object = tagProcessor.getContext().getMappedObjectOrResult(id);
final ObjectAssociation field = object.getSpecification().getAssociation(fieldName);
if (field == null) {
throw new ScimpiException("No field " + fieldName + " in " + object.getSpecification().getFullIdentifier());
@@ -56,10 +56,10 @@ public class FieldValue extends AbstractElementProcessor {
if (field.isVisible(IsisContext.getAuthenticationSession(), object, where).isVetoed()) {
throw new ForbiddenException(field, ForbiddenException.VISIBLE);
}
- final boolean isIconShowing = request.isRequested(SHOW_ICON, showIconByDefault());
- final int truncateTo = Integer.valueOf(request.getOptionalProperty(TRUNCATE, "0")).intValue();
+ final boolean isIconShowing = tagProcessor.isRequested(SHOW_ICON, showIconByDefault());
+ final int truncateTo = Integer.valueOf(tagProcessor.getOptionalProperty(TRUNCATE, "0")).intValue();
- write(request, object, field, null, className, isIconShowing, truncateTo);
+ write(tagProcessor, object, field, null, className, isIconShowing, truncateTo);
}
@Override
@@ -67,28 +67,28 @@ public class FieldValue extends AbstractElementProcessor {
return "field";
}
- public static void write(final Request request, final ObjectAdapter object, final ObjectAssociation field, final LinkedObject linkedField, final String className, final boolean showIcon, final int truncateTo) {
+ public static void write(final TagProcessor tagProcessor, final ObjectAdapter object, final ObjectAssociation field, final LinkedObject linkedField, final String className, final boolean showIcon, final int truncateTo) {
final ObjectAdapter fieldReference = field.get(object);
if (fieldReference != null) {
final String classSection = "class=\"" + (className == null ? "value" : className) + "\"";
- request.appendHtml("<span " + classSection + ">");
+ tagProcessor.appendHtml("<span " + classSection + ">");
if (field.isOneToOneAssociation()) {
try {
IsisContext.getPersistenceSession().resolveImmediately(fieldReference);
} catch (final ObjectNotFoundException e) {
- request.appendHtml(e.getMessage() + "</span>");
+ tagProcessor.appendHtml(e.getMessage() + "</span>");
}
}
if (!field.getSpecification().containsFacet(ParseableFacet.class) && showIcon) {
- request.appendHtml("<img class=\"small-icon\" src=\"" + request.getContext().imagePath(fieldReference) + "\" alt=\"" + field.getSpecification().getShortIdentifier() + "\"/>");
+ tagProcessor.appendHtml("<img class=\"small-icon\" src=\"" + tagProcessor.getContext().imagePath(fieldReference) + "\" alt=\"" + field.getSpecification().getShortIdentifier() + "\"/>");
}
if (linkedField != null) {
- final String id = request.getContext().mapObject(fieldReference, linkedField.getScope(), Scope.INTERACTION);
- request.appendHtml("<a href=\"" + linkedField.getForwardView() + "?" + linkedField.getVariable() + "=" + id + request.getContext().encodedInteractionParameters() + "\">");
+ final String id = tagProcessor.getContext().mapObject(fieldReference, linkedField.getScope(), Scope.INTERACTION);
+ tagProcessor.appendHtml("<a href=\"" + linkedField.getForwardView() + "?" + linkedField.getVariable() + "=" + id + tagProcessor.getContext().encodedInteractionParameters() + "\">");
}
String value = fieldReference == null ? "" : fieldReference.titleString();
if (truncateTo > 0 && value.length() > truncateTo) {
@@ -103,15 +103,15 @@ public class FieldValue extends AbstractElementProcessor {
final boolean flag = facet.isSet(fieldReference);
final String valueSegment = flag ? " checked=\"checked\"" : "";
final String disabled = " disabled=\"disabled\"";
- request.appendHtml("<input type=\"checkbox\"" + valueSegment + disabled + " />");
+ tagProcessor.appendHtml("<input type=\"checkbox\"" + valueSegment + disabled + " />");
} else {
- request.appendAsHtmlEncoded(value);
+ tagProcessor.appendAsHtmlEncoded(value);
}
if (linkedField != null) {
- request.appendHtml("</a>");
+ tagProcessor.appendHtml("</a>");
}
- request.appendHtml("</span>");
+ tagProcessor.appendHtml("</span>");
}
}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/GetField.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/GetField.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/GetField.java
index 3da420d..4a76b6a 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/GetField.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/GetField.java
@@ -30,12 +30,12 @@ import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
import org.apache.isis.core.progmodel.facets.value.date.DateValueFacet;
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.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.ForbiddenException;
+import org.apache.isis.viewer.scimpi.ScimpiException;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public class GetField extends AbstractElementProcessor {
@@ -47,10 +47,10 @@ public class GetField extends AbstractElementProcessor {
private final Where where = Where.ANYWHERE;
@Override
- public void process(final Request request) {
- final String id = request.getOptionalProperty(OBJECT);
- final String fieldName = request.getRequiredProperty(FIELD);
- final ObjectAdapter object = request.getContext().getMappedObjectOrResult(id);
+ public void process(final TagProcessor tagProcessor) {
+ final String id = tagProcessor.getOptionalProperty(OBJECT);
+ final String fieldName = tagProcessor.getRequiredProperty(FIELD);
+ final ObjectAdapter object = tagProcessor.getContext().getMappedObjectOrResult(id);
if (object == null) {
throw new ScimpiException("No object to get field for: " + fieldName + " - " + id);
}
@@ -63,35 +63,35 @@ public class GetField extends AbstractElementProcessor {
throw new ForbiddenException(field, ForbiddenException.VISIBLE);
}
- String pattern = request.getOptionalProperty("decimal-format");
+ String pattern = tagProcessor.getOptionalProperty("decimal-format");
Format format = null;
if (pattern != null) {
format = new DecimalFormat(pattern);
}
- pattern = request.getOptionalProperty("date-format");
+ pattern = tagProcessor.getOptionalProperty("date-format");
if (pattern != null) {
format = new SimpleDateFormat(pattern);
}
- final String name = request.getOptionalProperty(RESULT_NAME, fieldName);
- final String scopeName = request.getOptionalProperty(SCOPE);
- final Scope scope = RequestContext.scope(scopeName, Scope.REQUEST);
+ final String name = tagProcessor.getOptionalProperty(RESULT_NAME, fieldName);
+ final String scopeName = tagProcessor.getOptionalProperty(SCOPE);
+ final Scope scope = Request.scope(scopeName, Scope.REQUEST);
- process(request, object, field, format, name, scope);
+ process(tagProcessor, object, field, format, name, scope);
}
- protected void process(final Request request, final ObjectAdapter object, final ObjectAssociation field, final Format format, final String name, final Scope scope) {
+ protected void process(final TagProcessor tagProcessor, final ObjectAdapter object, final ObjectAssociation field, final Format format, final String name, final Scope scope) {
final ObjectAdapter fieldReference = field.get(object);
if (format != null && fieldReference.isValue()) {
final DateValueFacet facet = fieldReference.getSpecification().getFacet(DateValueFacet.class);
final Date date = facet.dateValue(fieldReference);
final String value = format.format(date);
- request.appendDebug(" " + object + " -> " + value);
- request.getContext().addVariable(name, Request.getEncoder().encoder(value), scope);
+ tagProcessor.appendDebug(" " + object + " -> " + value);
+ tagProcessor.getContext().addVariable(name, TagProcessor.getEncoder().encoder(value), scope);
} else {
- final String source = fieldReference == null ? "" : request.getContext().mapObject(fieldReference, scope);
- request.appendDebug(" " + object + " -> " + source);
- request.getContext().addVariable(name, source, scope);
+ final String source = fieldReference == null ? "" : tagProcessor.getContext().mapObject(fieldReference, scope);
+ tagProcessor.appendDebug(" " + object + " -> " + source);
+ tagProcessor.getContext().addVariable(name, source, scope);
}
}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/IncludeObject.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/IncludeObject.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/IncludeObject.java
index aa3bfff..0972dd9 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/IncludeObject.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/IncludeObject.java
@@ -30,10 +30,10 @@ 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.context.RequestContext.Scope;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
+import org.apache.isis.viewer.scimpi.ForbiddenException;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
/**
* Element to include another file that will display an object.
@@ -48,29 +48,29 @@ public class IncludeObject extends AbstractElementProcessor {
private final Where where = Where.ANYWHERE;
@Override
- public void process(final Request request) {
- final String path = request.getOptionalProperty("file");
- String id = request.getOptionalProperty(OBJECT);
- final String fieldName = request.getOptionalProperty(FIELD);
- ObjectAdapter object = request.getContext().getMappedObjectOrResult(id);
+ public void process(final TagProcessor tagProcessor) {
+ final String path = tagProcessor.getOptionalProperty("file");
+ String id = tagProcessor.getOptionalProperty(OBJECT);
+ final String fieldName = tagProcessor.getOptionalProperty(FIELD);
+ ObjectAdapter object = tagProcessor.getContext().getMappedObjectOrResult(id);
if (fieldName != null) {
final ObjectAssociation field = object.getSpecification().getAssociation(fieldName);
if (field.isVisible(IsisContext.getAuthenticationSession(), object, where).isVetoed()) {
throw new ForbiddenException(field, ForbiddenException.VISIBLE);
}
object = field.get(object);
- id = request.getContext().mapObject(object, Scope.REQUEST);
+ id = tagProcessor.getContext().mapObject(object, Scope.REQUEST);
}
if (object != null) {
IsisContext.getPersistenceSession().resolveImmediately(object);
- request.getContext().addVariable("_object", id, Scope.REQUEST);
- importFile(request, path);
+ tagProcessor.getContext().addVariable("_object", id, Scope.REQUEST);
+ importFile(tagProcessor, path);
}
- request.closeEmpty();
+ tagProcessor.closeEmpty();
}
- private static void importFile(final Request request, final String path) {
+ private static void importFile(final TagProcessor tagProcessor, final String path) {
// TODO load in file via HtmlFileParser
final File file = new File(path);
BufferedReader reader = null;
@@ -79,10 +79,10 @@ public class IncludeObject extends AbstractElementProcessor {
reader = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
String line;
while ((line = reader.readLine()) != null) {
- request.appendHtml(line);
+ tagProcessor.appendHtml(line);
}
} else {
- request.appendHtml("<P classs=\"error\">File " + path + " not found to import</P>");
+ tagProcessor.appendHtml("<P classs=\"error\">File " + path + " not found to import</P>");
}
} catch (final FileNotFoundException e) {
throw new RuntimeException(e);
[03/24] Restructuring Scimpi to remove dependencies and enable easier
testing.
Posted by rm...@apache.org.
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/edit/Selector.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/edit/Selector.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/edit/Selector.java
deleted file mode 100644
index e814f28..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/edit/Selector.java
+++ /dev/null
@@ -1,158 +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.edit;
-
-import java.util.Iterator;
-
-import org.apache.isis.core.commons.exceptions.UnknownTypeException;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacet;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
-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;
-import org.apache.isis.viewer.scimpi.dispatcher.util.MethodsUtils;
-import org.apache.isis.viewer.scimpi.dispatcher.view.action.ActionForm;
-import org.apache.isis.viewer.scimpi.dispatcher.view.action.CreateFormParameter;
-
-public class Selector extends AbstractElementProcessor {
-
- @Override
- public void process(final Request request) {
- final FormFieldBlock block = (FormFieldBlock) request.getBlockContent();
- final String field = request.getRequiredProperty(FIELD);
- if (block.isVisible(field)) {
- processElement(request, block, field);
- }
- request.skipUntilClose();
- }
-
- private void processElement(final Request request, final FormFieldBlock block, final String field) {
- final String type = request.getOptionalProperty(TYPE, "dropdown");
- if (!request.isPropertySpecified(METHOD) && request.isPropertySpecified(COLLECTION)) {
- final String id = request.getRequiredProperty(COLLECTION, Request.NO_VARIABLE_CHECKING);
- final String selector = showSelectionList(request, id, block.getCurrent(field), block.isNullable(field), type);
- block.replaceContent(field, selector);
- } else {
- final String objectId = request.getOptionalProperty(OBJECT);
- final String methodName = request.getRequiredProperty(METHOD);
- final ObjectAdapter object = MethodsUtils.findObject(request.getContext(), objectId);
- final ObjectAction action = MethodsUtils.findAction(object, methodName);
- if (action.getParameterCount() == 0) {
- final ObjectAdapter collection = action.execute(object, new ObjectAdapter[0]);
- final String selector = showSelectionList(request, collection, block.getCurrent(field), block.isNullable(field), type);
- block.replaceContent(field, selector);
- } else {
- final String id = "selector_options";
- final String id2 = (String) request.getContext().getVariable(id);
- final String selector = showSelectionList(request, id2, block.getCurrent(field), block.isNullable(field), type);
-
- final CreateFormParameter parameters = new CreateFormParameter();
- parameters.objectId = objectId;
- parameters.methodName = methodName;
- parameters.buttonTitle = request.getOptionalProperty(BUTTON_TITLE, "Search");
- parameters.formTitle = request.getOptionalProperty(FORM_TITLE);
- parameters.className = request.getOptionalProperty(CLASS, "selector");
- parameters.id = request.getOptionalProperty(ID);
-
- parameters.resultName = id;
- parameters.forwardResultTo = request.getContext().getResourceFile();
- parameters.forwardVoidTo = "error";
- parameters.forwardErrorTo = parameters.forwardResultTo;
- parameters.scope = Scope.REQUEST.name();
- request.pushNewBuffer();
- ActionForm.createForm(request, parameters);
- block.replaceContent(field, selector);
-
- request.appendHtml(request.popBuffer());
- }
- }
- }
-
- private String showSelectionList(final Request request, final String collectionId, final ObjectAdapter selectedItem, final boolean allowNotSet, final String type) {
- if (collectionId != null && !collectionId.equals("")) {
- final ObjectAdapter collection = request.getContext().getMappedObjectOrResult(collectionId);
- return showSelectionList(request, collection, selectedItem, allowNotSet, type);
- } else {
- return null;
- }
- }
-
- private String showSelectionList(final Request request, final ObjectAdapter collection, final ObjectAdapter selectedItem, final boolean allowNotSet, final String type) {
- final String field = request.getRequiredProperty(FIELD);
- final CollectionFacet facet = collection.getSpecification().getFacet(CollectionFacet.class);
-
- if (type.equals("radio")) {
- return radioButtonList(request, field, allowNotSet, collection, selectedItem, facet);
- } else if (type.equals("list")) {
- final String size = request.getOptionalProperty("size", "5");
- return dropdownList(request, field, allowNotSet, collection, selectedItem, size, facet);
- } else if (type.equals("dropdown")) {
- return dropdownList(request, field, allowNotSet, collection, selectedItem, null, facet);
- } else {
- throw new UnknownTypeException(type);
- }
- }
-
- private String radioButtonList(final Request request, final String field, final boolean allowNotSet, final ObjectAdapter collection, final ObjectAdapter selectedItem, final CollectionFacet facet) {
- final RequestContext context = request.getContext();
- final Iterator<ObjectAdapter> iterator = facet.iterator(collection);
- final StringBuffer buffer = new StringBuffer();
- if (allowNotSet) {
- buffer.append("<input type=\"radio\" name=\"" + field + "\" value=\"null\"></input><br/>\n");
- }
- while (iterator.hasNext()) {
- final ObjectAdapter element = iterator.next();
- final String elementId = context.mapObject(element, Scope.INTERACTION);
- final String title = element.titleString();
- final String checked = element == selectedItem ? "checked=\"checked\"" : "";
- buffer.append("<input type=\"radio\" name=\"" + field + "\" value=\"" + elementId + "\"" + checked + ">" + title + "</input><br/>\n");
- }
-
- return buffer.toString();
- }
-
- private String dropdownList(final Request request, final String field, final boolean allowNotSet, final ObjectAdapter collection, final ObjectAdapter selectedItem, String size, final CollectionFacet facet) {
- final RequestContext context = request.getContext();
- final Iterator<ObjectAdapter> iterator = facet.iterator(collection);
- final StringBuffer buffer = new StringBuffer();
- size = size == null ? "" : " size =\"" + size + "\"";
- buffer.append("<select name=\"" + field + "\"" + size + " >\n");
- if (allowNotSet) {
- buffer.append(" <option value=\"null\"></option>\n");
- }
- while (iterator.hasNext()) {
- final ObjectAdapter element = iterator.next();
- final String elementId = context.mapObject(element, Scope.INTERACTION);
- final String title = element.titleString();
- final String checked = element == selectedItem ? "selected=\"selected\"" : "";
- buffer.append(" <option value=\"" + elementId + "\"" + checked + ">" + title + "</option>\n");
- }
- buffer.append("</select>\n");
- return buffer.toString();
- }
-
- @Override
- public String getName() {
- return "selector";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/field/ExcludeField.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/field/ExcludeField.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/field/ExcludeField.java
index 0c12990..247aa92 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/field/ExcludeField.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/field/ExcludeField.java
@@ -19,15 +19,15 @@
package org.apache.isis.viewer.scimpi.dispatcher.view.field;
-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.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public class ExcludeField extends AbstractElementProcessor {
@Override
- public void process(final Request request) {
- final String field = request.getOptionalProperty(NAME);
- final InclusionList block = (InclusionList) request.getBlockContent();
+ public void process(final TagProcessor tagProcessor) {
+ final String field = tagProcessor.getOptionalProperty(NAME);
+ final InclusionList block = (InclusionList) tagProcessor.getBlockContent();
block.exclude(field);
}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/field/IncludeField.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/field/IncludeField.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/field/IncludeField.java
index bff9858..0d176d2 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/field/IncludeField.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/field/IncludeField.java
@@ -19,15 +19,15 @@
package org.apache.isis.viewer.scimpi.dispatcher.view.field;
-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.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public class IncludeField extends AbstractElementProcessor {
@Override
- public void process(final Request request) {
- final String field = request.getOptionalProperty(NAME);
- final InclusionList block = (InclusionList) request.getBlockContent();
+ public void process(final TagProcessor tagProcessor) {
+ final String field = tagProcessor.getOptionalProperty(NAME);
+ final InclusionList block = (InclusionList) tagProcessor.getBlockContent();
block.include(field);
}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/field/InclusionList.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/field/InclusionList.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/field/InclusionList.java
index 1fdc2f6..3a72451 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/field/InclusionList.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/field/InclusionList.java
@@ -27,7 +27,7 @@ import com.google.common.collect.Lists;
import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
-import org.apache.isis.viewer.scimpi.dispatcher.BlockContent;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.BlockContent;
import org.apache.isis.viewer.scimpi.dispatcher.view.form.InputField;
public class InclusionList implements BlockContent {
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/field/LinkField.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/field/LinkField.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/field/LinkField.java
index 74a24e6..e36612d 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/field/LinkField.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/field/LinkField.java
@@ -19,21 +19,20 @@
package org.apache.isis.viewer.scimpi.dispatcher.view.field;
-import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.Dispatcher;
-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.Names;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public class LinkField extends AbstractElementProcessor {
@Override
- public void process(final Request request) {
- final String field = request.getOptionalProperty(NAME);
- final String variable = request.getOptionalProperty(REFERENCE_NAME, RequestContext.RESULT);
- final String scope = request.getOptionalProperty(SCOPE, Scope.INTERACTION.toString());
- final String forwardView = request.getOptionalProperty(VIEW, "_generic." + Dispatcher.EXTENSION);
- final LinkedFieldsBlock tag = (LinkedFieldsBlock) request.getBlockContent();
+ public void process(final TagProcessor tagProcessor) {
+ final String field = tagProcessor.getOptionalProperty(NAME);
+ final String variable = tagProcessor.getOptionalProperty(REFERENCE_NAME, Names.RESULT);
+ final String scope = tagProcessor.getOptionalProperty(SCOPE, Scope.INTERACTION.toString());
+ final String forwardView = tagProcessor.getOptionalProperty(VIEW, "_generic." + Names.EXTENSION);
+ final LinkedFieldsBlock tag = (LinkedFieldsBlock) tagProcessor.getBlockContent();
tag.link(field, variable, scope, forwardView);
}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/field/LinkedObject.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/field/LinkedObject.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/field/LinkedObject.java
index d2c8548..934e1c1 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/field/LinkedObject.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/field/LinkedObject.java
@@ -19,8 +19,8 @@
package org.apache.isis.viewer.scimpi.dispatcher.view.field;
-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.Names;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
public class LinkedObject {
private final String variable;
@@ -36,7 +36,7 @@ public class LinkedObject {
public LinkedObject(final String forwardView) {
this.forwardView = forwardView;
scope = Scope.INTERACTION.toString();
- variable = RequestContext.RESULT;
+ variable = Names.RESULT;
}
public String getVariable() {
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/form/HtmlFormBuilder.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/form/HtmlFormBuilder.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/form/HtmlFormBuilder.java
index fd44cc8..6d362a6 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/form/HtmlFormBuilder.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/form/HtmlFormBuilder.java
@@ -20,13 +20,13 @@
package org.apache.isis.viewer.scimpi.dispatcher.view.form;
import org.apache.isis.core.commons.exceptions.UnknownTypeException;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
-import org.apache.isis.viewer.scimpi.dispatcher.view.HelpLink;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.other.HelpLink;
public class HtmlFormBuilder {
public static void createForm(
- final Request request,
+ final TagProcessor tagProcessor,
final String action,
final HiddenInputField[] hiddenFields,
final InputField[] fields,
@@ -41,12 +41,12 @@ public class HtmlFormBuilder {
final String cancelTo) {
String classSegment = " class=\"" + className + (id == null ? "\"" : "\" id=\"" + id + "\"");
- request.appendHtml("<form " + classSegment + " action=\"" + action + "\" method=\"post\" accept-charset=\"UTF-8\">\n");
+ tagProcessor.appendHtml("<form " + classSegment + " action=\"" + action + "\" method=\"post\" accept-charset=\"UTF-8\">\n");
if (formTitle != null && formTitle.trim().length() > 0) {
classSegment = " class=\"title\"";
- request.appendHtml("<div" + classSegment + ">");
- request.appendAsHtmlEncoded(formTitle);
- request.appendHtml("</div>\n");
+ tagProcessor.appendHtml("<div" + classSegment + ">");
+ tagProcessor.appendAsHtmlEncoded(formTitle);
+ tagProcessor.appendHtml("</div>\n");
}
// TODO reinstate fieldsets when we can specify them
@@ -54,51 +54,51 @@ public class HtmlFormBuilder {
final String cls = "errors";
if (errors != null) {
- request.appendHtml("<div class=\"" + cls + "\">");
- request.appendAsHtmlEncoded(errors);
- request.appendHtml("</div>");
+ tagProcessor.appendHtml("<div class=\"" + cls + "\">");
+ tagProcessor.appendAsHtmlEncoded(errors);
+ tagProcessor.appendHtml("</div>");
}
for (final HiddenInputField hiddenField : hiddenFields) {
if (hiddenField == null) {
continue;
}
- request.appendHtml(" <input type=\"hidden\" name=\"" + hiddenField.getName() + "\" value=\"");
- request.appendAsHtmlEncoded(hiddenField.getValue());
- request.appendHtml("\" />\n");
+ tagProcessor.appendHtml(" <input type=\"hidden\" name=\"" + hiddenField.getName() + "\" value=\"");
+ tagProcessor.appendAsHtmlEncoded(hiddenField.getValue());
+ tagProcessor.appendHtml("\" />\n");
}
- request.appendHtml(request.getContext().interactionFields());
+ tagProcessor.appendHtml(tagProcessor.getContext().interactionFields());
for (final InputField fld : fields) {
if (fld.isHidden()) {
- request.appendHtml(" <input type=\"hidden\" name=\"" + fld.getName() + "\" value=\"");
- request.appendAsHtmlEncoded(fld.getValue());
- request.appendHtml("\" />\n");
+ tagProcessor.appendHtml(" <input type=\"hidden\" name=\"" + fld.getName() + "\" value=\"");
+ tagProcessor.appendAsHtmlEncoded(fld.getValue());
+ tagProcessor.appendHtml("\" />\n");
} else {
final String errorSegment = fld.getErrorText() == null ? "" : "<span class=\"error\">" + fld.getErrorText() + "</span>";
final String fieldSegment = createField(fld);
final String helpSegment = HelpLink.createHelpSegment(fld.getDescription(), fld.getHelpReference());
final String title = fld.getDescription().equals("") ? "" : " title=\"" + fld.getDescription() + "\"";
- request.appendHtml(" <div class=\"field " + fld.getName() + "\"><label class=\"label\" " + title + ">");
- request.appendAsHtmlEncoded(fld.getLabel());
- request.appendHtml(labelDelimiter + "</label>" + fieldSegment + errorSegment + helpSegment + "</div>\n");
+ tagProcessor.appendHtml(" <div class=\"field " + fld.getName() + "\"><label class=\"label\" " + title + ">");
+ tagProcessor.appendAsHtmlEncoded(fld.getLabel());
+ tagProcessor.appendHtml(labelDelimiter + "</label>" + fieldSegment + errorSegment + helpSegment + "</div>\n");
}
}
- request.appendHtml(" <input class=\"button\" type=\"submit\" value=\"");
- request.appendAsHtmlEncoded(buttonTitle);
- request.appendHtml("\" name=\"execute\" />\n");
- HelpLink.append(request, description, helpReference);
+ tagProcessor.appendHtml(" <input class=\"button\" type=\"submit\" value=\"");
+ tagProcessor.appendAsHtmlEncoded(buttonTitle);
+ tagProcessor.appendHtml("\" name=\"execute\" />\n");
+ HelpLink.append(tagProcessor, description, helpReference);
// TODO alllow forms to be cancelled, returning to previous page.
// request.appendHtml(" <div class=\"action\"><a class=\"button\" href=\"reset\">Cancel</a></div>");
if (cancelTo != null) {
- request.appendHtml(" <input class=\"button\" type=\"button\" value=\"");
- request.appendAsHtmlEncoded("Cancel");
- request.appendHtml("\" onclick=\"window.location = '" + cancelTo + "'\" name=\"cancel\" />\n");
+ tagProcessor.appendHtml(" <input class=\"button\" type=\"button\" value=\"");
+ tagProcessor.appendAsHtmlEncoded("Cancel");
+ tagProcessor.appendHtml("\" onclick=\"window.location = '" + cancelTo + "'\" name=\"cancel\" />\n");
}
// TODO reinstate fieldsets when we can specify them
// request.appendHtml("</fieldset>\n");
- request.appendHtml("</form>\n");
+ tagProcessor.appendHtml("</form>\n");
}
private static String createField(final InputField field) {
@@ -143,7 +143,7 @@ public class HtmlFormBuilder {
final String disabled = field.isEditable() ? "" : " disabled=\"disabled\"";
final String maxLength = field.getMaxLength() == 0 ? "" : " maxlength=\"" + field.getMaxLength() + "\"";
return "<textarea" + requiredSegment + " name=\"" + field.getName() + "\"" + columnsSegment + rowsSegment + wrapSegment
- + maxLength + disabled + ">" + Request.getEncoder().encoder(field.getValue()) + "</textarea>";
+ + maxLength + disabled + ">" + TagProcessor.getEncoder().encoder(field.getValue()) + "</textarea>";
}
private static String createPasswordField(final InputField field) {
@@ -157,7 +157,7 @@ public class HtmlFormBuilder {
private static String createTextField(final InputField field, final String type, final String additionalAttributes) {
final String value = field.getValue();
- final String valueSegment = value == null ? "" : " value=\"" + Request.getEncoder().encoder(value) + "\"";
+ final String valueSegment = value == null ? "" : " value=\"" + TagProcessor.getEncoder().encoder(value) + "\"";
final String lengthSegment = field.getWidth() == 0 ? "" : " size=\"" + field.getWidth() + "\"";
final String maxLengthSegment = field.getMaxLength() == 0 ? "" : " maxlength=\"" + field.getMaxLength() + "\"";
final String requiredSegment = !field.isRequired() ? "" : " required";
@@ -187,7 +187,7 @@ public class HtmlFormBuilder {
if (field.getType() == InputField.TEXT && options[i].equals("__other")) {
offerOther = true;
} else {
- str.append(" <option value=\"" + Request.getEncoder().encoder(ids[i]) + "\"" + selectedSegment + ">" + Request.getEncoder().encoder(options[i]) + "</option>\n");
+ str.append(" <option value=\"" + TagProcessor.getEncoder().encoder(ids[i]) + "\"" + selectedSegment + ">" + TagProcessor.getEncoder().encoder(options[i]) + "</option>\n");
}
}
if (!field.isRequired() || length == 0) {
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/logon/Logoff.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/logon/Logoff.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/logon/Logoff.java
index 1632f5d..0fa8e84 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/logon/Logoff.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/logon/Logoff.java
@@ -19,15 +19,15 @@
package org.apache.isis.viewer.scimpi.dispatcher.view.logon;
-import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.logon.LogoutAction;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.action.LogoutAction;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public class Logoff extends AbstractElementProcessor {
@Override
- public void process(final Request request) {
- LogoutAction.logoutUser(request.getContext());
+ public void process(final TagProcessor tagProcessor) {
+ LogoutAction.logoutUser(tagProcessor.getContext());
}
@Override
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/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
index b25ccbe..63a47ee 100644
--- 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
@@ -24,12 +24,12 @@ 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.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.structure.FieldEditState;
+import org.apache.isis.viewer.scimpi.dispatcher.structure.FormState;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
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;
@@ -37,32 +37,32 @@ 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();
+ public void process(final TagProcessor tagProcessor) {
+ String view = tagProcessor.getOptionalProperty(VIEW);
+ Request context = tagProcessor.getContext();
if (view == null) {
view = (String) context.getVariable("login-path");
}
final boolean isNotLoggedIn = IsisContext.getSession().getAuthenticationSession() instanceof AnonymousSession;
if (isNotLoggedIn) {
- loginForm(request, view);
+ loginForm(tagProcessor, 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 isisUser = request.getOptionalProperty("isis-user", "_web_default");
- final String formId = request.getOptionalProperty(FORM_ID, request.nextFormId());
- final String labelDelimiter = request.getOptionalProperty(LABEL_DELIMITER, ":");
+ public static void loginForm(final TagProcessor tagProcessor, final String view) {
+ final String object = tagProcessor.getOptionalProperty(OBJECT);
+ final String method = tagProcessor.getOptionalProperty(METHOD, "logon");
+ final String result = tagProcessor.getOptionalProperty(RESULT_NAME, "_user");
+ final String resultScope = tagProcessor.getOptionalProperty(SCOPE, Scope.SESSION.name());
+ final String isisUser = tagProcessor.getOptionalProperty("isis-user", "_web_default");
+ final String formId = tagProcessor.getOptionalProperty(FORM_ID, tagProcessor.nextFormId());
+ final String labelDelimiter = tagProcessor.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();
+ Request context = tagProcessor.getContext();
context.addVariable(LOGON_OBJECT, object, Scope.SESSION);
context.addVariable(LOGON_METHOD, method, Scope.SESSION);
context.addVariable(LOGON_RESULT_NAME, result, Scope.SESSION);
@@ -71,7 +71,7 @@ public class Logon extends AbstractElementProcessor {
context.addVariable(LOGON_FORM_ID, formId, Scope.SESSION);
}
- final String error = request.getOptionalProperty(ERROR, request.getContext().getRequestedFile());
+ final String error = tagProcessor.getOptionalProperty(ERROR, tagProcessor.getContext().getRequestedFile());
final List<HiddenInputField> hiddenFields = new ArrayList<HiddenInputField>();
hiddenFields.add(new HiddenInputField(ERROR, error));
if (view != null) {
@@ -79,12 +79,12 @@ public class Logon extends AbstractElementProcessor {
}
hiddenFields.add(new HiddenInputField("_" + FORM_ID, formId));
- final FormState entryState = (FormState) request.getContext().getVariable(ENTRY_FIELDS);
+ final FormState entryState = (FormState) tagProcessor.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");
+ final String width = tagProcessor.getOptionalProperty("width");
if (width != null) {
final int w = Integer.valueOf(width).intValue();
nameField.setWidth(w);
@@ -92,12 +92,12 @@ public class Logon extends AbstractElementProcessor {
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");
+ final String formTitle = tagProcessor.getOptionalProperty(FORM_TITLE);
+ final String loginButtonTitle = tagProcessor.getOptionalProperty(BUTTON_TITLE, "Log in");
+ final String className = tagProcessor.getOptionalProperty(CLASS, "login");
+ final String id = tagProcessor.getOptionalProperty(ID, "logon");
- HtmlFormBuilder.createForm(request, "logon.app", hiddenFields.toArray(new HiddenInputField[hiddenFields.size()]), fields,
+ HtmlFormBuilder.createForm(tagProcessor, "logon.app", hiddenFields.toArray(new HiddenInputField[hiddenFields.size()]), fields,
className, id, formTitle, labelDelimiter, null, null, loginButtonTitle,
isforThisForm && entryState != null ? entryState.getError() : null , null);
}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/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
index 83f2597..baf7eef 100644
--- 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
@@ -18,22 +18,22 @@
*/
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;
+import org.apache.isis.viewer.scimpi.Names;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public class RestrictAccess extends AbstractElementProcessor {
private static final String LOGIN_VIEW = "login-view";
- private static final String DEFAULT_LOGIN_VIEW = "login." + Dispatcher.EXTENSION;
+ private static final String DEFAULT_LOGIN_VIEW = "login." + Names.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);
+ public void process(TagProcessor tagProcessor) {
+ if (!tagProcessor.getContext().isUserAuthenticated()) {
+ final String view = tagProcessor.getOptionalProperty(LOGIN_VIEW, DEFAULT_LOGIN_VIEW);
+ tagProcessor.getContext().redirectTo(view);
}
}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/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
index 17cd472..85c9a23 100644
--- 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
@@ -21,19 +21,19 @@ 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;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public class Secure extends AbstractElementProcessor {
private static final String LOGIN_VIEW = "login-view";
@Override
- public void process(final Request request) {
+ public void process(final TagProcessor tagProcessor) {
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);
+ final String view = tagProcessor.getOptionalProperty(LOGIN_VIEW, "/login.shtml");
+ tagProcessor.getContext().redirectTo(view);
}
}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/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
index 4254746..2a0a1e8 100644
--- 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
@@ -20,53 +20,53 @@
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;
+import org.apache.isis.viewer.scimpi.Names;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
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 DEFAULT_LOGIN_VIEW = "login." + Names.EXTENSION;
private static final String LOGOUT_VIEW = "logout-view";
- private static final String DEFAULT_LOGOUT_VIEW = "logout." + Dispatcher.EXTENSION;
+ private static final String DEFAULT_LOGOUT_VIEW = "logout." + Names.EXTENSION;
@Override
- public void process(final Request request) {
- final boolean isAuthenticatedn = request.getContext().isUserAuthenticated();
- request.appendHtml("<div class=\"user\">");
+ public void process(final TagProcessor tagProcessor) {
+ final boolean isAuthenticatedn = tagProcessor.getContext().isUserAuthenticated();
+ tagProcessor.appendHtml("<div class=\"user\">");
if (isAuthenticatedn) {
- displayUserAndLogoutLink(request);
+ displayUserAndLogoutLink(tagProcessor);
} else {
- displayLoginForm(request);
+ displayLoginForm(tagProcessor);
}
- request.appendHtml("</div>");
+ tagProcessor.appendHtml("</div>");
}
- public void displayLoginForm(final Request request) {
- String loginView = request.getOptionalProperty(LOGIN_VIEW);
+ public void displayLoginForm(final TagProcessor tagProcessor) {
+ String loginView = tagProcessor.getOptionalProperty(LOGIN_VIEW);
if (loginView == null) {
- Logon.loginForm(request, ".");
+ Logon.loginForm(tagProcessor, ".");
} else {
if (loginView.trim().length() == 0) {
loginView = DEFAULT_LOGIN_VIEW;
}
- request.appendHtml("<a div class=\"link\" href=\"" + loginView + "\">Log in</a>");
+ tagProcessor.appendHtml("<a div class=\"link\" href=\"" + loginView + "\">Log in</a>");
}
}
- public void displayUserAndLogoutLink(final Request request) {
- String user = request.getOptionalProperty(NAME);
+ public void displayUserAndLogoutLink(final TagProcessor tagProcessor) {
+ String user = tagProcessor.getOptionalProperty(NAME);
if (user == null) {
- user = (String) request.getContext().getVariable("_username");
+ user = (String) tagProcessor.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>");
+ tagProcessor.appendHtml("Welcome <span class=\"name\">");
+ tagProcessor.appendAsHtmlEncoded(user);
+ tagProcessor.appendHtml("</span>, ");
+ final String logoutView = tagProcessor.getOptionalProperty(LOGOUT_VIEW, DEFAULT_LOGOUT_VIEW);
+ tagProcessor.appendHtml("<a class=\"link\" href=\"logout.app?view=" + logoutView + "\">Log out</a>");
}
@Override
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/other/HelpLink.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/other/HelpLink.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/other/HelpLink.java
new file mode 100644
index 0000000..9bc5987
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/other/HelpLink.java
@@ -0,0 +1,72 @@
+/*
+ * 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.other;
+
+import org.apache.isis.core.commons.config.ConfigurationConstants;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+public class HelpLink extends AbstractElementProcessor {
+
+ private static String site;
+ private static String suffix;
+
+ public static void append(final TagProcessor tagProcessor, final String description, final String helpReference) {
+ tagProcessor.appendHtml(createHelpSegment(description, helpReference));
+ }
+
+ public static String createHelpSegment(final String description, final String helpReference) {
+ if (site == null) {
+ site = IsisContext.getConfiguration().getString(ConfigurationConstants.ROOT + "scimpi.help-site", "/help/");
+ }
+ if (suffix == null) {
+ suffix = IsisContext.getConfiguration().getString(ConfigurationConstants.ROOT + "scimpi.help-suffix", "shtml");
+ if (suffix == null || suffix.equals("")) {
+ suffix = "";
+ } else {
+ suffix = "." + suffix;
+ }
+ }
+
+ if (helpReference == null || helpReference.equals("No help available")) {
+ return "";
+ } else {
+ final String elementClass = "help-link";
+ final String link = site + helpReference + suffix;
+ final String linkText = "Help";
+ final String target = "scimpi-help";
+ final String titleSection = description == null ? "" : ("\" title=\"" + description);
+ return "<a class=\"" + elementClass + "\" href=\"" + link + "\" target=\"" + target + titleSection + "\"><img src=\"/images/help.png\" alt=\"" + linkText + "\" /></a>";
+ }
+ }
+
+ @Override
+ public String getName() {
+ return "help";
+ }
+
+ @Override
+ public void process(final TagProcessor tagProcessor) {
+ final String description = null;
+ final String helpReference = tagProcessor.getRequiredProperty("ref");
+ append(tagProcessor, description, helpReference);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/other/History.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/other/History.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/other/History.java
new file mode 100644
index 0000000..d328921
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/other/History.java
@@ -0,0 +1,150 @@
+/*
+ * 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.other;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.util.MethodsUtils;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+public class History extends AbstractElementProcessor {
+
+ private static final String _HISTORY = "_history";
+
+ static class Crumb {
+ String name;
+ String link;
+ }
+
+ static class Crumbs implements Serializable {
+ private static final long serialVersionUID = 1L;
+ private static final int MAXIMUM_SIZE = 10;
+ private final List<Crumb> crumbs = new ArrayList<Crumb>();
+
+ public void add(final String name, final String link) {
+ for (final Crumb crumb : crumbs) {
+ if (crumb.link.equals(link)) {
+ crumbs.remove(crumb);
+ crumbs.add(crumb);
+ return;
+ }
+ }
+
+ final Crumb crumb = new Crumb();
+ crumb.name = name;
+ crumb.link = link;
+ crumbs.add(crumb);
+
+ if (crumbs.size() > MAXIMUM_SIZE) {
+ crumbs.remove(0);
+ }
+ }
+
+ public void clear() {
+ crumbs.clear();
+ }
+
+ public boolean isEmpty() {
+ return crumbs.size() == 0;
+ }
+
+ public int size() {
+ return crumbs.size();
+ }
+
+ public Iterable<Crumb> iterator() {
+ return crumbs;
+ }
+
+ }
+
+ @Override
+ public String getName() {
+ return "history";
+ }
+
+ @Override
+ public void process(final TagProcessor tagProcessor) {
+ final String action = tagProcessor.getOptionalProperty("action", "display");
+ final Crumbs crumbs = getCrumbs(tagProcessor);
+ if (action.equals("display") && crumbs != null) {
+ write(crumbs, tagProcessor);
+ } else if (action.equals("link")) {
+ final String name = tagProcessor.getRequiredProperty(NAME);
+ final String link = tagProcessor.getRequiredProperty(LINK_VIEW);
+ crumbs.add(name, link);
+ } else if (action.equals("object")) {
+ final String id = tagProcessor.getOptionalProperty(OBJECT);
+ final ObjectAdapter object = MethodsUtils.findObject(tagProcessor.getContext(), id);
+ final String name = object.titleString();
+ String link = tagProcessor.getRequiredProperty(LINK_VIEW);
+ link += "?_result=" + id;
+ crumbs.add(name, link);
+ } else if (action.equals("return")) {
+
+ } else if (action.equals("clear")) {
+ crumbs.clear();
+ }
+
+ }
+
+ public void write(final Crumbs crumbs, final TagProcessor tagProcessor) {
+ if (crumbs.isEmpty()) {
+ return;
+ }
+
+ tagProcessor.appendHtml("<div id=\"history\">");
+ int i = 0;
+ final int length = crumbs.size();
+ for (final Crumb crumb : crumbs.iterator()) {
+ final String link = crumb.link;
+ if (i > 0) {
+ tagProcessor.appendHtml("<span class=\"separator\"> | </span>");
+ }
+ if (i == length - 1 || link == null) {
+ tagProcessor.appendHtml("<span class=\"disabled\">");
+ tagProcessor.appendHtml(crumb.name);
+ tagProcessor.appendHtml("</span>");
+ } else {
+ tagProcessor.appendHtml("<a class=\"linked\" href=\"" + link + "\">");
+ tagProcessor.appendHtml(crumb.name);
+ tagProcessor.appendHtml("</a>");
+ }
+ i++;
+ }
+ tagProcessor.appendHtml("</div>");
+ }
+
+ private Crumbs getCrumbs(final TagProcessor tagProcessor) {
+ final Request context = tagProcessor.getContext();
+ Crumbs crumbs = (Crumbs) context.getVariable(_HISTORY);
+ if (crumbs == null) {
+ crumbs = new Crumbs();
+ context.addVariable(_HISTORY, crumbs, Scope.SESSION);
+ }
+ return crumbs;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/other/VersionNumber.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/other/VersionNumber.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/other/VersionNumber.java
new file mode 100644
index 0000000..5ae6dff
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/other/VersionNumber.java
@@ -0,0 +1,70 @@
+/*
+ * 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.other;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
+import org.apache.isis.viewer.scimpi.ScimpiException;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+public class VersionNumber extends AbstractElementProcessor {
+
+ private static final String MARKER = "Implementation-Build: ";
+ private static final String FILE = "/META-INF/MANIFEST.MF";
+ private String version;
+
+ @Override
+ public String getName() {
+ return "version-number";
+ }
+
+ @Override
+ public void process(final TagProcessor tagProcessor) {
+ if (version == null) {
+ version = "0000"; // default revision number
+ loadRevisonNumber(tagProcessor.getContext());
+ }
+ tagProcessor.appendHtml(version);
+ }
+
+ private void loadRevisonNumber(final Request context) {
+ BufferedReader reader;
+ try {
+ String file = FILE;
+
+ file = context.findFile(FILE);
+ reader = new BufferedReader(new InputStreamReader(context.openStream(file)));
+ String line;
+ while ((line = reader.readLine()) != null) {
+ if (line.startsWith(MARKER)) {
+ version = line.substring(MARKER.length());
+ break;
+ }
+ }
+ reader.close();
+ } catch (final IOException e) {
+ throw new ScimpiException(e);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/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
index 293429e..1572197 100644
--- 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
@@ -35,10 +35,10 @@ import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
import org.apache.isis.core.metamodel.spec.feature.ObjectActionContainer.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.AbstractElementProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.ScimpiException;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
+import org.apache.isis.viewer.scimpi.ScimpiException;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
import org.apache.isis.viewer.scimpi.dispatcher.util.MethodsUtils;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public abstract class AbstractConditionalBlock extends AbstractElementProcessor {
@@ -107,24 +107,24 @@ public abstract class AbstractConditionalBlock extends AbstractElementProcessor
}
@Override
- public void process(final Request request) {
- final String id = request.getOptionalProperty(OBJECT);
+ public void process(final TagProcessor tagProcessor) {
+ final String id = tagProcessor.getOptionalProperty(OBJECT);
boolean checkMade = false;
boolean allConditionsMet = true;
- final String[] propertyNames = request.getAttributes().getPropertyNames(new String[] { "object", "collection" });
+ final String[] propertyNames = tagProcessor.getAttributes().getPropertyNames(new String[] { "object", "collection" });
for (final String propertyName : propertyNames) {
boolean result;
if (propertyName.equals("set")) {
- result = request.isPropertySet("set");
+ result = tagProcessor.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);
+ final String attributeValue = tagProcessor.getOptionalProperty(propertyName, false);
+ result = test.test(tagProcessor, attributeValue, id);
if (test.negateResult) {
result = !result;
}
@@ -263,9 +263,9 @@ public abstract class AbstractConditionalBlock extends AbstractElementProcessor
* &= hasMatchingRole; }
*/
- final String persistent = request.getOptionalProperty("persistent");
+ final String persistent = tagProcessor.getOptionalProperty("persistent");
if (persistent != null) {
- final ObjectAdapter object = request.getContext().getMappedObjectOrResult(persistent);
+ final ObjectAdapter object = tagProcessor.getContext().getMappedObjectOrResult(persistent);
checkMade = true;
allConditionsMet &= object.representsPersistent();
}
@@ -277,11 +277,11 @@ public abstract class AbstractConditionalBlock extends AbstractElementProcessor
* cls.isAssignableFrom(object.getObject().getClass())); checkMade =
* true; allConditionsMet &= hasType;; }
*/
- if (request.isPropertySpecified("empty")) {
- if (request.isPropertySet("empty")) {
- final String collection = request.getOptionalProperty("empty");
+ if (tagProcessor.isPropertySpecified("empty")) {
+ if (tagProcessor.isPropertySet("empty")) {
+ final String collection = tagProcessor.getOptionalProperty("empty");
if (collection != null) {
- final ObjectAdapter object = request.getContext().getMappedObjectOrResult(collection);
+ final ObjectAdapter object = tagProcessor.getContext().getMappedObjectOrResult(collection);
final CollectionFacet facet = object.getSpecification().getFacet(CollectionFacet.class);
checkMade = true;
allConditionsMet &= facet.size(object) == 0;
@@ -292,20 +292,20 @@ public abstract class AbstractConditionalBlock extends AbstractElementProcessor
}
}
- if (request.isPropertySpecified("set")) {
- final boolean valuePresent = request.isPropertySet("set");
+ if (tagProcessor.isPropertySpecified("set")) {
+ final boolean valuePresent = tagProcessor.isPropertySet("set");
checkMade = true;
allConditionsMet &= valuePresent;
}
if (checkMade) {
- processTags(allConditionsMet, request);
+ processTags(allConditionsMet, tagProcessor);
} else {
throw new ScimpiException("No condition in " + getName());
}
}
- protected abstract void processTags(boolean isSet, Request request);
+ protected abstract void processTags(boolean isSet, TagProcessor tagProcessor);
}
@@ -313,7 +313,7 @@ abstract class Test {
String name;
boolean negateResult;
- abstract boolean test(Request request, String attributeName, String targetId);
+ abstract boolean test(TagProcessor tagProcessor, String attributeName, String targetId);
protected Class<?> forClass(final String className) {
Class<?> cls = null;
@@ -347,8 +347,8 @@ abstract class Test {
class TestVariableExists extends Test {
@Override
- boolean test(final Request request, final String attributeName, final String targetId) {
- Object variable = request.getContext().getVariable(attributeName);
+ boolean test(final TagProcessor tagProcessor, final String attributeName, final String targetId) {
+ Object variable = tagProcessor.getContext().getVariable(attributeName);
if (variable instanceof String && ((String) variable).equals("")) {
return false;
}
@@ -358,8 +358,8 @@ class TestVariableExists extends Test {
class TestVariableTrue extends Test {
@Override
- boolean test(final Request request, final String attributeName, final String targetId) {
- final Object variable = request.getContext().getVariable(attributeName);
+ boolean test(final TagProcessor tagProcessor, final String attributeName, final String targetId) {
+ final Object variable = tagProcessor.getContext().getVariable(attributeName);
final Boolean value = variable instanceof Boolean ? (Boolean) variable : Boolean.valueOf((String) variable);
return value != null && value.booleanValue();
}
@@ -367,16 +367,16 @@ class TestVariableTrue extends Test {
class TestObjectPersistent extends Test {
@Override
- boolean test(final Request request, final String attributeName, final String targetId) {
- final ObjectAdapter object = request.getContext().getMappedObjectOrResult(attributeName);
+ boolean test(final TagProcessor tagProcessor, final String attributeName, final String targetId) {
+ final ObjectAdapter object = tagProcessor.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);
+ boolean test(final TagProcessor tagProcessor, final String attributeName, final String targetId) {
+ final ObjectAdapter object = MethodsUtils.findObject(tagProcessor.getContext(), targetId);
final Class<?> cls = forClass(attributeName);
final boolean hasType = object != null && (cls == null || cls.isAssignableFrom(object.getObject().getClass()));
return hasType;
@@ -385,8 +385,8 @@ class TestObjectType extends TestObjectPersistent {
class TestCollectionType extends Test {
@Override
- boolean test(final Request request, final String attributeName, final String targetId) {
- final ObjectAdapter object = MethodsUtils.findObject(request.getContext(), targetId);
+ boolean test(final TagProcessor tagProcessor, final String attributeName, final String targetId) {
+ final ObjectAdapter object = MethodsUtils.findObject(tagProcessor.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()));
@@ -396,8 +396,8 @@ class TestCollectionType extends Test {
class TestCollectionFull extends Test {
@Override
- boolean test(final Request request, final String attributeName, final String targetId) {
- final ObjectAdapter object = MethodsUtils.findObject(request.getContext(), attributeName);
+ boolean test(final TagProcessor tagProcessor, final String attributeName, final String targetId) {
+ final ObjectAdapter object = MethodsUtils.findObject(tagProcessor.getContext(), attributeName);
final CollectionFacet facet = object.getSpecification().getFacet(CollectionFacet.class);
final boolean isEmpty = facet != null && facet.size(object) == 0;
return !isEmpty;
@@ -406,8 +406,8 @@ class TestCollectionFull extends Test {
class TestMethodExists extends Test {
@Override
- boolean test(final Request request, final String attributeName, final String targetId) {
- final ObjectAdapter object = MethodsUtils.findObject(request.getContext(), targetId);
+ boolean test(final TagProcessor tagProcessor, final String attributeName, final String targetId) {
+ final ObjectAdapter object = MethodsUtils.findObject(tagProcessor.getContext(), targetId);
final List<? extends ObjectAction> objectActions = object.getSpecification().getObjectActions(ActionType.USER, Contributed.INCLUDED);
boolean methodExists = false;
for (final ObjectAction objectAssociation : objectActions) {
@@ -422,8 +422,8 @@ class TestMethodExists extends Test {
class TestMethodVisible extends Test {
@Override
- boolean test(final Request request, final String attributeName, final String targetId) {
- final ObjectAdapter object = MethodsUtils.findObject(request.getContext(), targetId);
+ boolean test(final TagProcessor tagProcessor, final String attributeName, final String targetId) {
+ final ObjectAdapter object = MethodsUtils.findObject(tagProcessor.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);
@@ -433,8 +433,8 @@ class TestMethodVisible extends Test {
class TestMethodUseable extends Test {
@Override
- boolean test(final Request request, final String attributeName, final String targetId) {
- final ObjectAdapter object = MethodsUtils.findObject(request.getContext(), targetId);
+ boolean test(final TagProcessor tagProcessor, final String attributeName, final String targetId) {
+ final ObjectAdapter object = MethodsUtils.findObject(tagProcessor.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);
@@ -444,8 +444,8 @@ class TestMethodUseable extends Test {
class TestFieldExists extends Test {
@Override
- boolean test(final Request request, final String attributeName, final String targetId) {
- final ObjectAdapter object = MethodsUtils.findObject(request.getContext(), targetId);
+ boolean test(final TagProcessor tagProcessor, final String attributeName, final String targetId) {
+ final ObjectAdapter object = MethodsUtils.findObject(tagProcessor.getContext(), targetId);
final List<? extends ObjectAssociation> objectFields = object.getSpecification().getAssociations();
boolean fieldExists = false;
for (final ObjectAssociation objectAssociation : objectFields) {
@@ -460,8 +460,8 @@ class TestFieldExists extends Test {
class TestFieldVisible extends Test {
@Override
- boolean test(final Request request, final String attributeName, final String targetId) {
- final ObjectAdapter object = MethodsUtils.findObject(request.getContext(), targetId);
+ boolean test(final TagProcessor tagProcessor, final String attributeName, final String targetId) {
+ final ObjectAdapter object = MethodsUtils.findObject(tagProcessor.getContext(), targetId);
final ObjectAssociation objectField = findProperty(attributeName, object);
final Consent visible = objectField.isVisible(IsisContext.getAuthenticationSession(), object, Where.ANYWHERE);
return visible.isAllowed();
@@ -470,8 +470,8 @@ class TestFieldVisible extends Test {
class TestFieldEditable extends Test {
@Override
- boolean test(final Request request, final String attributeName, final String targetId) {
- final ObjectAdapter object = MethodsUtils.findObject(request.getContext(), targetId);
+ boolean test(final TagProcessor tagProcessor, final String attributeName, final String targetId) {
+ final ObjectAdapter object = MethodsUtils.findObject(tagProcessor.getContext(), targetId);
final ObjectAssociation objectField = findProperty(attributeName, object);
final Consent usable = objectField.isUsable(IsisContext.getAuthenticationSession(), object, Where.ANYWHERE);
return usable.isAllowed();
@@ -480,8 +480,8 @@ class TestFieldEditable extends Test {
class TestFieldType extends Test {
@Override
- boolean test(final Request request, final String attributeName, final String targetId) {
- final ObjectAdapter object = MethodsUtils.findObject(request.getContext(), targetId);
+ boolean test(final TagProcessor tagProcessor, final String attributeName, final String targetId) {
+ final ObjectAdapter object = MethodsUtils.findObject(tagProcessor.getContext(), targetId);
final Class<?> cls = forClass(attributeName);
final boolean hasType = object != null && (cls == null || cls.isAssignableFrom(object.getObject().getClass()));
return hasType;
@@ -490,8 +490,8 @@ class TestFieldType extends Test {
class TestFieldSet extends Test {
@Override
- boolean test(final Request request, final String attributeName, final String targetId) {
- final ObjectAdapter object = MethodsUtils.findObject(request.getContext(), targetId);
+ boolean test(final TagProcessor tagProcessor, final String attributeName, final String targetId) {
+ final ObjectAdapter object = MethodsUtils.findObject(tagProcessor.getContext(), targetId);
final ObjectAssociation objectField = findProperty(attributeName, object);
IsisContext.getPersistenceSession().resolveField(object, objectField);
final ObjectAdapter fld = objectField.get(object);
@@ -513,20 +513,20 @@ class TestFieldSet extends Test {
class TestFieldValue extends Test {
@Override
- boolean test(Request request, String attributeName, String targetId) {
+ boolean test(TagProcessor tagProcessor, 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 ObjectAdapter object = MethodsUtils.findObject(tagProcessor.getContext(), targetId);
final ObjectAssociation objectField = findProperty(fieldName, object);
IsisContext.getPersistenceSession().resolveField(object, objectField);
final ObjectAdapter fld = objectField.get(object);
// TODO test for reference or value
- final ObjectAdapter object2 = MethodsUtils.findObject(request.getContext(), fieldValue);
+ final ObjectAdapter object2 = MethodsUtils.findObject(tagProcessor.getContext(), fieldValue);
if (fld == object2) {
return true;
@@ -538,7 +538,7 @@ class TestFieldValue extends Test {
class TestHasRole extends Test {
@Override
- boolean test(final Request request, final String attributeName, final String targetId) {
+ boolean test(final TagProcessor tagProcessor, final String attributeName, final String targetId) {
final String[] requiredRoles = attributeName.split("\\|");
final AuthenticationSession session = IsisContext.getSession().getAuthenticationSession();
final List<String> sessionRoles = session.getRoles();
@@ -555,8 +555,8 @@ class TestHasRole extends Test {
class TestSet extends Test {
@Override
- boolean test(final Request request, final String attributeName, final String targetId) {
- final boolean valuePresent = request.isPropertySet("set");
+ boolean test(final TagProcessor tagProcessor, final String attributeName, final String targetId) {
+ final boolean valuePresent = tagProcessor.isPropertySet("set");
return valuePresent;
}
}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/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
index 743be2d..b5777a4 100644
--- 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
@@ -23,30 +23,31 @@ 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.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.ForbiddenException;
+import org.apache.isis.viewer.scimpi.Names;
+import org.apache.isis.viewer.scimpi.ScimpiException;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
import org.apache.isis.viewer.scimpi.dispatcher.util.MethodsUtils;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
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);
+ public void process(final TagProcessor tagProcessor) {
+ final String title = tagProcessor.getOptionalProperty(FORM_TITLE);
+ final String name = tagProcessor.getOptionalProperty(NAME);
+ final boolean showAsButton = tagProcessor.isRequested("show-as-button", false);
+ final String linkClass = tagProcessor.getOptionalProperty(CLASS, showAsButton ? "button" : defaultLinkClass());
+ final String containerClass = tagProcessor.getOptionalProperty(CONTAINER_CLASS, "action");
+ final String object = tagProcessor.getOptionalProperty(OBJECT);
+ final Request context = tagProcessor.getContext();
+ String objectId = object != null ? object : (String) context.getVariable(Names.RESULT);
ObjectAdapter adapter = MethodsUtils.findObject(context, objectId);
// REVIEW this is common used code
- final String fieldName = request.getOptionalProperty(FIELD);
+ final String fieldName = tagProcessor.getOptionalProperty(FIELD);
if (fieldName != null) {
final ObjectAssociation field = adapter.getSpecification().getAssociation(fieldName);
if (field == null) {
@@ -70,37 +71,37 @@ public abstract class AbstractLink extends AbstractElementProcessor {
}
}
- if (adapter != null && valid(request, adapter)) {
- final String variable = request.getOptionalProperty("param-name", RequestContext.RESULT);
+ if (adapter != null && valid(tagProcessor, adapter)) {
+ final String variable = tagProcessor.getOptionalProperty("param-name", Names.RESULT);
final String variableSegment = variable + "=" + objectId;
- String view = request.getOptionalProperty(VIEW);
+ String view = tagProcessor.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);
+ String additionalSegment = additionalParameters(tagProcessor);
additionalSegment = additionalSegment == null ? "" : "&" + additionalSegment;
if (showAsButton) {
- request.appendHtml("<div class=\"" + containerClass + "\">");
+ tagProcessor.appendHtml("<div class=\"" + containerClass + "\">");
}
- request.appendHtml("<a" + classSegment + titleSegment + " href=\"" + view + "?" + variableSegment + context.encodedInteractionParameters() + additionalSegment + "\">");
- request.pushNewBuffer();
- request.processUtilCloseTag();
- final String buffer = request.popBuffer();
+ tagProcessor.appendHtml("<a" + classSegment + titleSegment + " href=\"" + view + "?" + variableSegment + context.encodedInteractionParameters() + additionalSegment + "\">");
+ tagProcessor.pushNewBuffer();
+ tagProcessor.processUtilCloseTag();
+ final String buffer = tagProcessor.popBuffer();
if (buffer.trim().length() > 0) {
- request.appendHtml(buffer);
+ tagProcessor.appendHtml(buffer);
} else {
- request.appendAsHtmlEncoded(linkLabel(name, adapter));
+ tagProcessor.appendAsHtmlEncoded(linkLabel(name, adapter));
}
- request.appendHtml("</a>");
+ tagProcessor.appendHtml("</a>");
if (showAsButton) {
- request.appendHtml("</div>");
+ tagProcessor.appendHtml("</div>");
}
} else {
- request.skipUntilClose();
+ tagProcessor.skipUntilClose();
}
}
@@ -110,11 +111,11 @@ public abstract class AbstractLink extends AbstractElementProcessor {
protected abstract String linkLabel(String name, ObjectAdapter object);
- protected String additionalParameters(final Request request) {
+ protected String additionalParameters(final TagProcessor tagProcessor) {
return null;
}
- protected abstract boolean valid(Request request, ObjectAdapter adapter);
+ protected abstract boolean valid(TagProcessor tagProcessor, ObjectAdapter adapter);
protected abstract String defaultView();
}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/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
index cea5d11..8b7f645 100644
--- 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
@@ -19,10 +19,10 @@
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;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor.RepeatMarker;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public class BlockDefine extends AbstractElementProcessor {
@@ -32,11 +32,11 @@ public class BlockDefine extends AbstractElementProcessor {
}
@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);
+ public void process(final TagProcessor tagProcessor) {
+ final String name = tagProcessor.getOptionalProperty(NAME, "unamed");
+ final RepeatMarker start = tagProcessor.createMarker();
+ tagProcessor.skipUntilClose();
+ tagProcessor.getContext().addVariable("_block-" + name, start, Scope.REQUEST);
}
}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/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
index efd6128..014daf2 100644
--- 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
@@ -19,9 +19,9 @@
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;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor.RepeatMarker;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public class BlockUse extends AbstractElementProcessor {
@@ -31,15 +31,15 @@ public class BlockUse extends AbstractElementProcessor {
}
@Override
- public void process(final Request request) {
- final String name = request.getOptionalProperty(NAME, "unamed");
- request.closeEmpty();
- final RepeatMarker end = request.createMarker();
+ public void process(final TagProcessor tagProcessor) {
+ final String name = tagProcessor.getOptionalProperty(NAME, "unamed");
+ tagProcessor.closeEmpty();
+ final RepeatMarker end = tagProcessor.createMarker();
- final RepeatMarker marker = (RepeatMarker) request.getContext().getVariable("_block-" + name);
+ final RepeatMarker marker = (RepeatMarker) tagProcessor.getContext().getVariable("_block-" + name);
marker.repeat();
- request.processUtilCloseTag();
+ tagProcessor.processUtilCloseTag();
end.repeat();
}
[12/24] Restructuring Scimpi to remove dependencies and enable easier
testing.
Posted by rm...@apache.org.
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/variable/InitializeFromCookie.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/variable/InitializeFromCookie.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/variable/InitializeFromCookie.java
new file mode 100644
index 0000000..ed0467b
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/variable/InitializeFromCookie.java
@@ -0,0 +1,82 @@
+/*
+ * 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.variable;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.runtime.persistence.ObjectNotFoundException;
+import org.apache.isis.viewer.scimpi.Names;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+public class InitializeFromCookie extends AbstractElementProcessor {
+ private static final String SEVEN_DAYS = Integer.toString(60 * 24 * 7);
+
+ @Override
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ final String name = templateProcessor.getRequiredProperty(NAME);
+
+ final Request context = templateProcessor.getContext();
+ if (context.getVariable(name) != null) {
+ templateProcessor.skipUntilClose();
+ } else {
+ final String scopeName = templateProcessor.getOptionalProperty(SCOPE);
+ final Scope scope = Request.scope(scopeName, Scope.SESSION);
+
+ final String cookieName = templateProcessor.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) {
+ templateProcessor.skipUntilClose();
+ context.addVariable(name, cookieValue, scope);
+ } else {
+ final String expiresString = templateProcessor.getOptionalProperty("expires", SEVEN_DAYS);
+ templateProcessor.pushNewBuffer();
+ templateProcessor.processUtilCloseTag();
+ templateProcessor.popBuffer();
+ final String id = (String) context.getVariable(Names.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/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/variable/InitializeFromResult.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/variable/InitializeFromResult.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/variable/InitializeFromResult.java
new file mode 100644
index 0000000..cce1a96
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/variable/InitializeFromResult.java
@@ -0,0 +1,79 @@
+/*
+ * 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.variable;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.viewer.scimpi.Names;
+import org.apache.isis.viewer.scimpi.ScimpiException;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+public class InitializeFromResult extends AbstractElementProcessor {
+
+ @Override
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ disallowSourceAndDefault(templateProcessor);
+ final String sourceObjectId = objectOrResult(templateProcessor);
+ final Class<?> cls = forClass(templateProcessor);
+ final String variableName = templateProcessor.getRequiredProperty(NAME);
+ final String defaultObjectId = templateProcessor.getOptionalProperty(DEFAULT);
+ final String scopeName = templateProcessor.getOptionalProperty(SCOPE);
+ final Scope scope = Request.scope(scopeName, Scope.REQUEST);
+
+ final Request context = templateProcessor.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) {
+ templateProcessor.appendDebug(" " + variableName + " set to " + sourceObjectId + " (" + scope + ")");
+ context.addVariable(variableName, sourceObjectId, scope);
+ } else {
+ templateProcessor.appendDebug(" " + variableName + " set to " + sourceObjectId + " (" + scope + ")");
+ if (defaultObjectId != null) {
+ context.addVariable(variableName, defaultObjectId, scope);
+ }
+ context.changeScope(variableName, scope);
+ }
+ }
+
+ private String objectOrResult(final TemplateProcessor templateProcessor) {
+ final String sourceObjectId = templateProcessor.getOptionalProperty(OBJECT);
+ if (sourceObjectId == null) {
+ return (String) templateProcessor.getContext().getVariable(Names.RESULT);
+ } else {
+ return sourceObjectId;
+ }
+ }
+
+ private void disallowSourceAndDefault(final TemplateProcessor templateProcessor) {
+ if (templateProcessor.getOptionalProperty(DEFAULT) != null && templateProcessor.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/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/variable/PageTitle.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/variable/PageTitle.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/variable/PageTitle.java
new file mode 100644
index 0000000..96e94a8
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/variable/PageTitle.java
@@ -0,0 +1,36 @@
+/*
+ * 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.variable;
+
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+
+public class PageTitle extends Variable {
+ @Override
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ process(templateProcessor, "title", null, null, false, Scope.REQUEST);
+ }
+
+ @Override
+ public String getName() {
+ return "page-title";
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/variable/SetCookie.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/variable/SetCookie.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/variable/SetCookie.java
new file mode 100644
index 0000000..46add9a
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/variable/SetCookie.java
@@ -0,0 +1,54 @@
+/*
+ * 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.variable;
+
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.RequiredPropertyException;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+public class SetCookie extends AbstractElementProcessor {
+
+ @Override
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ final String name = templateProcessor.getRequiredProperty("name");
+ final String value = templateProcessor.getOptionalProperty("value");
+ final boolean isClear = templateProcessor.getOptionalProperty("action", "set").equals("clear");
+ final String expiresString = templateProcessor.getOptionalProperty("expires", "-1");
+
+ if (!isClear && value == null) {
+ throw new RequiredPropertyException("Property not set: " + value);
+ }
+ if (isClear) {
+ templateProcessor.appendDebug("cookie: " + name + " (cleared)");
+ templateProcessor.getContext().addCookie(name, null, 0);
+ } else {
+ if (value.length() > 0) {
+ templateProcessor.appendDebug("cookie: " + name + " set to"+ value);
+ templateProcessor.getContext().addCookie(name, value, Integer.valueOf(expiresString));
+ }
+ }
+ }
+
+ @Override
+ public String getName() {
+ return "set-cookie";
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/variable/SetCookieFromField.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/variable/SetCookieFromField.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/variable/SetCookieFromField.java
new file mode 100644
index 0000000..7a92a71
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/variable/SetCookieFromField.java
@@ -0,0 +1,56 @@
+/*
+ * 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.variable;
+
+import org.apache.isis.core.commons.exceptions.NotYetImplementedException;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+public class SetCookieFromField extends AbstractElementProcessor {
+
+ @Override
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ throw new NotYetImplementedException("3.1");
+ /*
+ * String objectId = request.getOptionalProperty(OBJECT); String
+ * fieldName = request.getRequiredProperty(FIELD);
+ *
+ * ObjectAdapter object = (ObjectAdapter)
+ * request.getContext().getMappedObjectOrResult(objectId);
+ * ObjectAssociation field =
+ * object.getSpecification().getField(fieldName); if (field.isValue()) {
+ * throw new ScimpiException("Can only set up a value field"); }
+ * ObjectAdapter value = field.get(object); if (value != null) { String
+ * title = value.titleString();
+ *
+ * if (title.length() > 0) { String name =
+ * request.getRequiredProperty(NAME); String expiresString =
+ * request.getOptionalProperty("expires", "-1");
+ * request.getContext().addCookie(name, title,
+ * Integer.valueOf(expiresString)); } }
+ */
+ }
+
+ @Override
+ public String getName() {
+ return "set-cookie-from-field";
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/variable/SetFieldFromCookie.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/variable/SetFieldFromCookie.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/variable/SetFieldFromCookie.java
new file mode 100644
index 0000000..8b02691
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/variable/SetFieldFromCookie.java
@@ -0,0 +1,53 @@
+/*
+ * 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.variable;
+
+import org.apache.isis.core.commons.exceptions.NotYetImplementedException;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+public class SetFieldFromCookie extends AbstractElementProcessor {
+
+ @Override
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ throw new NotYetImplementedException("3.1");
+ /*
+ * String name = request.getRequiredProperty(NAME); String cookieString
+ * = request.getContext().getCookie(name); ObjectAdapter valueAdapter =
+ * IsisContext.getObjectPersistor().createAdapterForValue(cookieString);
+ *
+ * String objectId = request.getOptionalProperty(OBJECT); String
+ * fieldName = request.getRequiredProperty(FIELD); ObjectAdapter object
+ * = (ObjectAdapter)
+ * request.getContext().getMappedObjectOrResult(objectId);
+ * ObjectAssociation field =
+ * object.getSpecification().getField(fieldName); if (field.isValue()) {
+ * throw new ScimpiException("Can only set up a value field"); }
+ *
+ * ((ValueAssociation) field).setValue(object, valueAdapter);
+ */
+ }
+
+ @Override
+ public String getName() {
+ return "set-field-from-cookie";
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/variable/Variable.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/variable/Variable.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/variable/Variable.java
new file mode 100644
index 0000000..645ff45
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/variable/Variable.java
@@ -0,0 +1,65 @@
+/*
+ * 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.variable;
+
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+public class Variable extends AbstractElementProcessor {
+
+ @Override
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ final String name = templateProcessor.getOptionalProperty(NAME);
+ final String value = templateProcessor.getOptionalProperty(VALUE);
+ final String defaultTo = templateProcessor.getOptionalProperty(DEFAULT);
+ final String scopeName = templateProcessor.getOptionalProperty(SCOPE);
+ final boolean isClear = templateProcessor.getOptionalProperty("action", "set").equals("clear");
+ final Scope scope = Request.scope(scopeName, isClear ? Scope.SESSION : Scope.REQUEST);
+ process(templateProcessor, name, value, defaultTo, isClear, scope);
+ }
+
+ protected void process(final TemplateProcessor templateProcessor, final String name, final String value, final String defaultTo, final boolean isClear, final Scope scope) {
+ templateProcessor.pushNewBuffer();
+ templateProcessor.processUtilCloseTag();
+ String source = templateProcessor.popBuffer();
+ if (isClear) {
+ templateProcessor.appendDebug("variable: " + name + " (cleared)");
+ templateProcessor.getContext().clearVariable(name, scope);
+ } else {
+ if (source.length() == 0 && value != null) {
+ source = value;
+ }
+ if (source.length() == 0) {
+ source = defaultTo;
+ }
+ templateProcessor.appendDebug(" " + name + " (" + scope + ") set to " + source);
+ templateProcessor.getContext().addVariable(name, source, scope);
+ }
+ }
+
+ @Override
+ public String getName() {
+ return "variable";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/widget/FieldFactory.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/widget/FieldFactory.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/widget/FieldFactory.java
deleted file mode 100644
index 1936055..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/widget/FieldFactory.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.viewer.scimpi.dispatcher.view.widget;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.facets.help.HelpFacet;
-import org.apache.isis.core.metamodel.facets.maxlen.MaxLengthFacet;
-import org.apache.isis.core.metamodel.facets.multiline.MultiLineFacet;
-import org.apache.isis.core.metamodel.facets.object.parseable.ParseableFacet;
-import org.apache.isis.core.metamodel.facets.typicallen.TypicalLengthFacet;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.metamodel.spec.feature.ObjectFeature;
-import org.apache.isis.core.metamodel.spec.feature.ObjectMember;
-import org.apache.isis.core.progmodel.facets.value.booleans.BooleanValueFacet;
-import org.apache.isis.core.progmodel.facets.value.password.PasswordValueFacet;
-import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
-import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
-import org.apache.isis.viewer.scimpi.dispatcher.view.form.InputField;
-
-public class FieldFactory {
-
- public static void initializeField(final Request context, final ObjectAdapter object, final ObjectFeature param, final ObjectAdapter[] optionsForParameter, final boolean isRequired, final InputField field) {
-
- field.setLabel(param.getName());
- field.setDescription(param.getDescription());
- field.setDataType(param.getSpecification().getShortIdentifier());
- if (param instanceof ObjectMember) {
- field.setHelpReference(((ObjectMember) param).getHelp());
- } else {
- final HelpFacet helpFacet = param.getFacet(HelpFacet.class);
- final String value = helpFacet.value();
- field.setHelpReference(value);
- }
- field.setRequired(isRequired);
- field.setHidden(false);
-
- if (param.getSpecification().getFacet(ParseableFacet.class) != null) {
- final int maxLength = param.getFacet(MaxLengthFacet.class).value();
- field.setMaxLength(maxLength);
-
- final TypicalLengthFacet typicalLengthFacet = param.getFacet(TypicalLengthFacet.class);
- if (typicalLengthFacet.isDerived() && maxLength > 0) {
- field.setWidth(maxLength);
- } else {
- field.setWidth(typicalLengthFacet.value());
- }
-
- final MultiLineFacet multiLineFacet = param.getFacet(MultiLineFacet.class);
- field.setHeight(multiLineFacet.numberOfLines());
- field.setWrapped(!multiLineFacet.preventWrapping());
-
- final ObjectSpecification spec = param.getSpecification();
- if (spec.containsFacet(BooleanValueFacet.class)) {
- field.setType(InputField.CHECKBOX);
- } else if (spec.containsFacet(PasswordValueFacet.class)) {
- field.setType(InputField.PASSWORD);
- } else {
- field.setType(InputField.TEXT);
- }
-
- } else {
- field.setType(InputField.REFERENCE);
- }
-
- if (optionsForParameter != null) {
- final int noOptions = optionsForParameter.length;
- final String[] optionValues = new String[noOptions];
- final String[] optionTitles = new String[noOptions];
- for (int j = 0; j < optionsForParameter.length; j++) {
- final int i = j; // + (field.isRequired() ? 0 : 1);
- optionValues[i] = getValue(context, optionsForParameter[j]);
- optionTitles[i] = optionsForParameter[j].titleString();
- }
- field.setOptions(optionTitles, optionValues);
- }
- }
-
- private static String getValue(final Request context, final ObjectAdapter field) {
- if (field == null) {
- return "";
- }
- if (field.getSpecification().getFacet(ParseableFacet.class) == null) {
- return context.mapObject(field, Scope.INTERACTION);
- } else {
- return field.getObject().toString();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/widget/FormEntry.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/widget/FormEntry.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/widget/FormEntry.java
deleted file mode 100644
index 7b1b86c..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/widget/FormEntry.java
+++ /dev/null
@@ -1,44 +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.widget;
-
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
-
-public class FormEntry extends AbstractElementProcessor {
-
- @Override
- public void process(final TagProcessor tagProcessor) {
- final FormFieldBlock block = (FormFieldBlock) tagProcessor.getBlockContent();
- final String field = tagProcessor.getRequiredProperty(FIELD);
- final String value = tagProcessor.getRequiredProperty(VALUE);
- final boolean isHidden = tagProcessor.isRequested(HIDDEN, true);
- block.exclude(field);
- // TODO this is replaced because the field is marked as hidden!
- final String content = "reference <input type=\"" + (isHidden ? "hidden" : "text") + "\" disabled=\"disabled\" name=\"" + field + "\" value=\"" + value + "\" />";
- block.replaceContent(field, content);
- }
-
- @Override
- public String getName() {
- return "form-entry";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/widget/FormField.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/widget/FormField.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/widget/FormField.java
deleted file mode 100644
index 2707c3d..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/widget/FormField.java
+++ /dev/null
@@ -1,44 +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.widget;
-
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
-
-public class FormField extends AbstractElementProcessor {
-
- @Override
- public void process(final TagProcessor tagProcessor) {
- final FormFieldBlock block = (FormFieldBlock) tagProcessor.getBlockContent();
- final String field = tagProcessor.getRequiredProperty(FIELD);
- if (block.isVisible(field)) {
- tagProcessor.pushNewBuffer();
- tagProcessor.processUtilCloseTag();
- final String content = tagProcessor.popBuffer();
- block.replaceContent(field, content);
- }
- }
-
- @Override
- public String getName() {
- return "form-field";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/widget/FormFieldBlock.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/widget/FormFieldBlock.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/widget/FormFieldBlock.java
deleted file mode 100644
index 36cf5d8..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/widget/FormFieldBlock.java
+++ /dev/null
@@ -1,68 +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.widget;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.viewer.scimpi.dispatcher.view.field.InclusionList;
-import org.apache.isis.viewer.scimpi.dispatcher.view.form.InputField;
-
-public class FormFieldBlock extends InclusionList {
- private final Map<String, String> content = new HashMap<String, String>();
- private final Map<String, String> values = new HashMap<String, String>();
-
- public void replaceContent(final String field, final String htmlString) {
- content.put(field, htmlString);
- }
-
- public boolean hasContent(final String name) {
- return content.containsKey(name);
- }
-
- public String getContent(final String name) {
- return content.get(name);
- }
-
- public boolean isVisible(final String name) {
- return true;
- }
-
- public boolean isNullable(final String name) {
- return true;
- }
-
- public ObjectAdapter getCurrent(final String name) {
- return null;
- }
-
- public void value(final String field, final String value) {
- values.put(field, value);
- }
-
- public void setUpValues(final InputField[] inputFields) {
- for (final InputField inputField : inputFields) {
- final String name = inputField.getName();
- inputField.setValue(values.get(name));
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/widget/HiddenField.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/widget/HiddenField.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/widget/HiddenField.java
deleted file mode 100644
index cc8e824..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/widget/HiddenField.java
+++ /dev/null
@@ -1,48 +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.widget;
-
-import org.apache.isis.viewer.scimpi.dispatcher.TagOrderException;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.BlockContent;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
-
-public class HiddenField extends AbstractElementProcessor {
-
- @Override
- public void process(final TagProcessor tagProcessor) {
- final BlockContent blockContent = tagProcessor.getBlockContent();
- if (!(blockContent instanceof FormFieldBlock)) {
- throw new TagOrderException(tagProcessor);
- }
-
- final String field = tagProcessor.getOptionalProperty("name");
- final String value = tagProcessor.getRequiredProperty("value");
- final FormFieldBlock block = (FormFieldBlock) blockContent;
- block.value(field, value);
- block.exclude(field);
- }
-
- @Override
- public String getName() {
- return "hidden-field";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/widget/RadioListField.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/widget/RadioListField.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/widget/RadioListField.java
deleted file mode 100644
index 7bd51e1..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/widget/RadioListField.java
+++ /dev/null
@@ -1,70 +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.widget;
-
-import java.util.Iterator;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacet;
-import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
-import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
-
-public class RadioListField extends AbstractElementProcessor {
-
- @Override
- public void process(final TagProcessor tagProcessor) {
- final FormFieldBlock block = (FormFieldBlock) tagProcessor.getBlockContent();
- final String field = tagProcessor.getRequiredProperty(FIELD);
- if (block.isVisible(field)) {
- final String id = tagProcessor.getRequiredProperty(COLLECTION);
- final String exclude = tagProcessor.getOptionalProperty("exclude");
-
- final ObjectAdapter collection = tagProcessor.getContext().getMappedObjectOrResult(id);
-
- final Request context = tagProcessor.getContext();
- final CollectionFacet facet = collection.getSpecification().getFacet(CollectionFacet.class);
- final Iterator<ObjectAdapter> iterator = facet.iterator(collection);
-
- final StringBuffer buffer = new StringBuffer();
-
- while (iterator.hasNext()) {
- final ObjectAdapter element = iterator.next();
- final Scope scope = Scope.INTERACTION;
- final String elementId = context.mapObject(element, scope);
- if (exclude != null && context.getMappedObject(exclude) == element) {
- continue;
- }
- final String title = element.titleString();
- final String checked = "";
- buffer.append("<input type=\"radio\" name=\"" + field + "\" value=\"" + elementId + "\"" + checked + " />" + title + "</input><br/>\n");
- }
-
- block.replaceContent(field, buffer.toString());
- }
- }
-
- @Override
- public String getName() {
- return "radio-list";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/widget/Selector.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/widget/Selector.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/widget/Selector.java
deleted file mode 100644
index 8c0b47e..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/widget/Selector.java
+++ /dev/null
@@ -1,158 +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.widget;
-
-import java.util.Iterator;
-
-import org.apache.isis.core.commons.exceptions.UnknownTypeException;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacet;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
-import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
-import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.util.MethodsUtils;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.view.action.ActionForm;
-import org.apache.isis.viewer.scimpi.dispatcher.view.action.CreateFormParameter;
-
-public class Selector extends AbstractElementProcessor {
-
- @Override
- public void process(final TagProcessor tagProcessor) {
- final FormFieldBlock block = (FormFieldBlock) tagProcessor.getBlockContent();
- final String field = tagProcessor.getRequiredProperty(FIELD);
- if (block.isVisible(field)) {
- processElement(tagProcessor, block, field);
- }
- tagProcessor.skipUntilClose();
- }
-
- private void processElement(final TagProcessor tagProcessor, final FormFieldBlock block, final String field) {
- final String type = tagProcessor.getOptionalProperty(TYPE, "dropdown");
- if (!tagProcessor.isPropertySpecified(METHOD) && tagProcessor.isPropertySpecified(COLLECTION)) {
- final String id = tagProcessor.getRequiredProperty(COLLECTION, TagProcessor.NO_VARIABLE_CHECKING);
- final String selector = showSelectionList(tagProcessor, id, block.getCurrent(field), block.isNullable(field), type);
- block.replaceContent(field, selector);
- } else {
- final String objectId = tagProcessor.getOptionalProperty(OBJECT);
- final String methodName = tagProcessor.getRequiredProperty(METHOD);
- final ObjectAdapter object = MethodsUtils.findObject(tagProcessor.getContext(), objectId);
- final ObjectAction action = MethodsUtils.findAction(object, methodName);
- if (action.getParameterCount() == 0) {
- final ObjectAdapter collection = action.execute(object, new ObjectAdapter[0]);
- final String selector = showSelectionList(tagProcessor, collection, block.getCurrent(field), block.isNullable(field), type);
- block.replaceContent(field, selector);
- } else {
- final String id = "selector_options";
- final String id2 = (String) tagProcessor.getContext().getVariable(id);
- final String selector = showSelectionList(tagProcessor, id2, block.getCurrent(field), block.isNullable(field), type);
-
- final CreateFormParameter parameters = new CreateFormParameter();
- parameters.objectId = objectId;
- parameters.methodName = methodName;
- parameters.buttonTitle = tagProcessor.getOptionalProperty(BUTTON_TITLE, "Search");
- parameters.formTitle = tagProcessor.getOptionalProperty(FORM_TITLE);
- parameters.className = tagProcessor.getOptionalProperty(CLASS, "selector");
- parameters.id = tagProcessor.getOptionalProperty(ID);
-
- parameters.resultName = id;
- parameters.forwardResultTo = tagProcessor.getContext().getResourceFile();
- parameters.forwardVoidTo = "error";
- parameters.forwardErrorTo = parameters.forwardResultTo;
- parameters.scope = Scope.REQUEST.name();
- tagProcessor.pushNewBuffer();
- ActionForm.createForm(tagProcessor, parameters);
- block.replaceContent(field, selector);
-
- tagProcessor.appendHtml(tagProcessor.popBuffer());
- }
- }
- }
-
- private String showSelectionList(final TagProcessor tagProcessor, final String collectionId, final ObjectAdapter selectedItem, final boolean allowNotSet, final String type) {
- if (collectionId != null && !collectionId.equals("")) {
- final ObjectAdapter collection = tagProcessor.getContext().getMappedObjectOrResult(collectionId);
- return showSelectionList(tagProcessor, collection, selectedItem, allowNotSet, type);
- } else {
- return null;
- }
- }
-
- private String showSelectionList(final TagProcessor tagProcessor, final ObjectAdapter collection, final ObjectAdapter selectedItem, final boolean allowNotSet, final String type) {
- final String field = tagProcessor.getRequiredProperty(FIELD);
- final CollectionFacet facet = collection.getSpecification().getFacet(CollectionFacet.class);
-
- if (type.equals("radio")) {
- return radioButtonList(tagProcessor, field, allowNotSet, collection, selectedItem, facet);
- } else if (type.equals("list")) {
- final String size = tagProcessor.getOptionalProperty("size", "5");
- return dropdownList(tagProcessor, field, allowNotSet, collection, selectedItem, size, facet);
- } else if (type.equals("dropdown")) {
- return dropdownList(tagProcessor, field, allowNotSet, collection, selectedItem, null, facet);
- } else {
- throw new UnknownTypeException(type);
- }
- }
-
- private String radioButtonList(final TagProcessor tagProcessor, final String field, final boolean allowNotSet, final ObjectAdapter collection, final ObjectAdapter selectedItem, final CollectionFacet facet) {
- final Request context = tagProcessor.getContext();
- final Iterator<ObjectAdapter> iterator = facet.iterator(collection);
- final StringBuffer buffer = new StringBuffer();
- if (allowNotSet) {
- buffer.append("<input type=\"radio\" name=\"" + field + "\" value=\"null\"></input><br/>\n");
- }
- while (iterator.hasNext()) {
- final ObjectAdapter element = iterator.next();
- final String elementId = context.mapObject(element, Scope.INTERACTION);
- final String title = element.titleString();
- final String checked = element == selectedItem ? "checked=\"checked\"" : "";
- buffer.append("<input type=\"radio\" name=\"" + field + "\" value=\"" + elementId + "\"" + checked + ">" + title + "</input><br/>\n");
- }
-
- return buffer.toString();
- }
-
- private String dropdownList(final TagProcessor tagProcessor, final String field, final boolean allowNotSet, final ObjectAdapter collection, final ObjectAdapter selectedItem, String size, final CollectionFacet facet) {
- final Request context = tagProcessor.getContext();
- final Iterator<ObjectAdapter> iterator = facet.iterator(collection);
- final StringBuffer buffer = new StringBuffer();
- size = size == null ? "" : " size =\"" + size + "\"";
- buffer.append("<select name=\"" + field + "\"" + size + " >\n");
- if (allowNotSet) {
- buffer.append(" <option value=\"null\"></option>\n");
- }
- while (iterator.hasNext()) {
- final ObjectAdapter element = iterator.next();
- final String elementId = context.mapObject(element, Scope.INTERACTION);
- final String title = element.titleString();
- final String checked = element == selectedItem ? "selected=\"selected\"" : "";
- buffer.append(" <option value=\"" + elementId + "\"" + checked + ">" + title + "</option>\n");
- }
- buffer.append("</select>\n");
- return buffer.toString();
- }
-
- @Override
- public String getName() {
- return "selector";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/security/DebugUsers.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/security/DebugUsers.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/security/DebugUsers.java
deleted file mode 100644
index 212c6c5..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/security/DebugUsers.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.viewer.scimpi.security;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.apache.log4j.Logger;
-
-import org.apache.isis.core.commons.authentication.AuthenticationSession;
-import org.apache.isis.core.commons.config.ConfigurationConstants;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.viewer.scimpi.ScimpiException;
-
-public class DebugUsers {
-
- private static Logger LOG = Logger.getLogger(DebugUsers.class);
-
- private enum DebugMode {
- OFF, ON, NAMED, SYSADMIN_ONLY
- }
-
- private static List<String> debugUsers = new ArrayList<String>();
- private static DebugMode debugMode;
-
- public void initialize() {
- if (debugMode != null) {
- throw new ScimpiException("Debug mode is already set up!");
- }
-
- final String debugUserEntry = IsisContext.getConfiguration().getString(ConfigurationConstants.ROOT + "scimpi.debug.users", "");
- final String[] users = debugUserEntry.split("\\|");
- for (final String name : users) {
- debugUsers.add(name.trim());
- }
-
- final String debugModeEntry = IsisContext.getConfiguration().getString(ConfigurationConstants.ROOT + "scimpi.debug.mode");
- if (debugModeEntry != null) {
- try {
- debugMode = DebugMode.valueOf(debugModeEntry.toUpperCase());
- LOG.info("Debug mode set to " + debugMode);
- } catch (final IllegalArgumentException e) {
- LOG.error("Invalid debug mode - " + debugModeEntry + " - mode set to OFF");
- debugMode = DebugMode.OFF;
- }
- } else {
- debugMode = DebugMode.OFF;
- }
- }
-
- public boolean isDebugEnabled(final AuthenticationSession session) {
- if (debugMode == DebugMode.ON) {
- return true;
- } else if (session != null && debugMode == DebugMode.SYSADMIN_ONLY && session.getRoles().contains("sysadmin")) {
- return true;
- } else if (session != null && debugMode == DebugMode.NAMED && (debugUsers.contains(session.getUserName()) || session.getRoles().contains("sysadmin"))) {
- return true;
- }
- return false;
- }
-
- public List<String> getNames() {
- final ArrayList<String> users = new ArrayList<String>(debugUsers);
- Collections.sort(users);
- return users;
- }
-
- public void add(final String name) {
- if (!debugUsers.contains(name)) {
- debugUsers.add(name);
- LOG.info("Added '" + debugMode + "' to debug users list");
- }
- }
-
- public void remove(final String name) {
- debugUsers.remove(name);
- LOG.info("Removed '" + debugMode + "' from debug users list");
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/security/UserManager.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/security/UserManager.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/security/UserManager.java
deleted file mode 100644
index db2b6d7..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/security/UserManager.java
+++ /dev/null
@@ -1,89 +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.security;
-
-import org.apache.isis.core.commons.authentication.AnonymousSession;
-import org.apache.isis.core.commons.authentication.AuthenticationSession;
-import org.apache.isis.core.runtime.authentication.AuthenticationManager;
-import org.apache.isis.core.runtime.authentication.AuthenticationRequestPassword;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.log4j.Logger;
-
-public class UserManager {
-
- private static final Logger LOG = Logger.getLogger(UserManager.class);
- private static UserManager instance;
-
- private static AuthenticationManager getAuthenticationManager() {
- if (instance == null) {
- throw new IllegalStateException("Server initialisation failed, or not defined as a context listener");
- }
- return instance.authenticationManager;
- }
-
- public static AuthenticationSession startRequest(final AuthenticationSession session) {
- AuthenticationSession useSession;
- if (session == null) {
- useSession = new AnonymousSession();
- LOG.debug("start anonymous request: " + session);
- } else {
- useSession = session;
- LOG.debug("start request for: " + session.getUserName());
- }
- IsisContext.closeSession();
- IsisContext.openSession(useSession);
- return useSession;
- }
-
- public static AuthenticationSession authenticate(final AuthenticationRequestPassword passwordAuthenticationRequest) {
- final AuthenticationSession session = getAuthenticationManager().authenticate(passwordAuthenticationRequest);
- if (session != null) {
- LOG.info("log on user " + session.getUserName());
- IsisContext.closeSession();
- IsisContext.openSession(session);
- }
- return session;
- }
-
- public static void endRequest(final AuthenticationSession session) {
- if (session == null) {
- LOG.debug("end anonymous request");
- } else {
- LOG.debug("end request for: " + session.getUserName());
- }
- IsisContext.closeSession();
- }
-
- public static void logoffUser(final AuthenticationSession session) {
- LOG.info("log off user " + session.getUserName());
- IsisContext.closeSession();
- getAuthenticationManager().closeSession(session);
-
- final AnonymousSession replacementSession = new AnonymousSession();
- IsisContext.openSession(replacementSession);
- }
-
- private final AuthenticationManager authenticationManager;
-
- public UserManager(final AuthenticationManager authenticationManager) {
- this.authenticationManager = authenticationManager;
- UserManager.instance = this;
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/test/java/org/apache/isis/viewer/scimpi/dispatcher/view/ElementProcessorTest.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/test/java/org/apache/isis/viewer/scimpi/dispatcher/view/ElementProcessorTest.java b/component/viewer/scimpi/dispatcher/src/test/java/org/apache/isis/viewer/scimpi/dispatcher/view/ElementProcessorTest.java
new file mode 100644
index 0000000..b5dc774
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/test/java/org/apache/isis/viewer/scimpi/dispatcher/view/ElementProcessorTest.java
@@ -0,0 +1,61 @@
+package org.apache.isis.viewer.scimpi.dispatcher.view;
+
+import java.util.Stack;
+
+import org.apache.isis.viewer.scimpi.Names;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.Snippet;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.SwfTag;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagAttributes;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.htmlparser.nodes.TagNode;
+import org.junit.Test;
+
+import static org.hamcrest.Matchers.equalTo;
+import static org.junit.Assert.assertThat;
+
+
+public class ElementProcessorTest {
+
+ @Test
+ public void test() {
+ ExampleElementProcessor processor = new ExampleElementProcessor();
+
+ TagNode tagNode = new TagNode();
+ tagNode.setTagName("swf:test");
+ tagNode.setAttribute(Names.NAME, "attribute-name");
+ tagNode.setAttribute(Names.ACTION, "attribute-name-2");
+
+ TagAttributes tagAttributes = new TagAttributes(tagNode, null);
+ Stack<Snippet> snippets = new Stack<Snippet>();
+ Snippet snippet = new SwfTag("", tagAttributes , SwfTag.EMPTY, "", "") ;
+ snippets.push(snippet);
+
+ TestRequestState state = new TestRequestState();
+ TemplateProcessor templateProcessor = new TemplateProcessor(null, state, null, snippets, null);
+
+ processor.process(templateProcessor, state);
+ String content = templateProcessor.popBuffer().toString();
+ assertThat(content, equalTo("<p>html-code</p>a & b > c<div>attribute-name</div><div>attribute-name-2</div>"));
+ }
+}
+
+
+
+class ExampleElementProcessor extends AbstractElementProcessor {
+
+ public String getName() {
+ return "test";
+ }
+
+ public void process(TemplateProcessor templateProcessor, RequestState state) {
+ templateProcessor.appendHtml("<p>html-code</p>");
+ templateProcessor.appendAsHtmlEncoded("a & b > c");
+
+ final String name = templateProcessor.getOptionalProperty(NAME);
+ templateProcessor.appendHtml("<div>" + name + "</div>");
+ final String var = templateProcessor.getRequiredProperty(ACTION);
+ templateProcessor.appendHtml("<div>" + var + "</div>");
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/test/java/org/apache/isis/viewer/scimpi/dispatcher/view/TestRequestState.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/test/java/org/apache/isis/viewer/scimpi/dispatcher/view/TestRequestState.java b/component/viewer/scimpi/dispatcher/src/test/java/org/apache/isis/viewer/scimpi/dispatcher/view/TestRequestState.java
new file mode 100644
index 0000000..bd82751
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/test/java/org/apache/isis/viewer/scimpi/dispatcher/view/TestRequestState.java
@@ -0,0 +1,32 @@
+package org.apache.isis.viewer.scimpi.dispatcher.view;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+
+public class TestRequestState implements RequestState {
+
+ private ObjectAdapter adapter;
+
+ public String replaceVariables(String value) {
+ return value;
+ }
+
+ public String getErrorMessage() {
+ return "an error" ;
+ }
+
+ public String getStringVariable(String result) {
+ return "string-var";
+ }
+
+ public ObjectAdapter getMappedObject(String objectId) {
+ return adapter;
+ }
+
+ public void setObject(ObjectAdapter adapter) {
+ this.adapter = adapter;}
+
+
+
+}
+
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/test/java/org/apache/isis/viewer/scimpi/dispatcher/view/message/ErrorMessageTest.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/test/java/org/apache/isis/viewer/scimpi/dispatcher/view/message/ErrorMessageTest.java b/component/viewer/scimpi/dispatcher/src/test/java/org/apache/isis/viewer/scimpi/dispatcher/view/message/ErrorMessageTest.java
new file mode 100644
index 0000000..e94ae6e
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/test/java/org/apache/isis/viewer/scimpi/dispatcher/view/message/ErrorMessageTest.java
@@ -0,0 +1,42 @@
+package org.apache.isis.viewer.scimpi.dispatcher.view.message;
+
+import java.util.Stack;
+
+import org.apache.isis.viewer.scimpi.dispatcher.processor.Snippet;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.SwfTag;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagAttributes;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.TestRequestState;
+import org.htmlparser.nodes.TagNode;
+import org.junit.Test;
+
+import static org.hamcrest.Matchers.equalTo;
+import static org.junit.Assert.*;
+
+public class ErrorMessageTest {
+
+ @Test
+ public void test() {
+ TagNode tagNode = new TagNode();
+
+ TagAttributes tagAttributes = new TagAttributes(tagNode, null);
+ Stack<Snippet> snippets = new Stack<Snippet>();
+ Snippet snippet = new SwfTag("", tagAttributes , SwfTag.EMPTY, "", "") ;
+ snippets.push(snippet);
+
+ TestRequestState state = new TestRequestState();
+ TemplateProcessor templateProcessor = new TemplateProcessor(null, state, null, snippets, null);
+
+ // tagNode.setTagName("swf:error-message");
+
+
+
+ ErrorMessage processor = new ErrorMessage();
+ processor.process(templateProcessor, state);
+ String content = templateProcessor.popBuffer().toString();
+
+ assertThat(content, equalTo("an error"));
+ }
+
+}
+
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/pom.xml
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/pom.xml b/component/viewer/scimpi/pom.xml
index 86949c1..330d7f2 100644
--- a/component/viewer/scimpi/pom.xml
+++ b/component/viewer/scimpi/pom.xml
@@ -29,7 +29,7 @@
<groupId>org.apache.isis.viewer</groupId>
<artifactId>isis-viewer-scimpi</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>1.0.0-restructure-SNAPSHOT</version>
<name>Isis Scimpi Viewer</name>
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/servlet/pom.xml
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/servlet/pom.xml b/component/viewer/scimpi/servlet/pom.xml
index 51526e3..dbb479f 100644
--- a/component/viewer/scimpi/servlet/pom.xml
+++ b/component/viewer/scimpi/servlet/pom.xml
@@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.isis.viewer</groupId>
<artifactId>isis-viewer-scimpi</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>1.0.0-restructure-SNAPSHOT</version>
</parent>
<artifactId>isis-viewer-scimpi-servlet</artifactId>
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/servlet/src/main/java/org/apache/isis/viewer/scimpi/servlet/DispatcherServlet.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/servlet/src/main/java/org/apache/isis/viewer/scimpi/servlet/DispatcherServlet.java b/component/viewer/scimpi/servlet/src/main/java/org/apache/isis/viewer/scimpi/servlet/DispatcherServlet.java
index 0e61c46..9b2a166 100644
--- a/component/viewer/scimpi/servlet/src/main/java/org/apache/isis/viewer/scimpi/servlet/DispatcherServlet.java
+++ b/component/viewer/scimpi/servlet/src/main/java/org/apache/isis/viewer/scimpi/servlet/DispatcherServlet.java
@@ -29,9 +29,9 @@ import javax.servlet.http.HttpServletResponse;
import org.apache.isis.core.runtime.system.context.IsisContext;
import org.apache.isis.viewer.scimpi.dispatcher.Dispatcher;
-import org.apache.isis.viewer.scimpi.dispatcher.Response;
-import org.apache.isis.viewer.scimpi.security.DebugUsers;
-import org.apache.isis.viewer.scimpi.security.UserManager;
+import org.apache.isis.viewer.scimpi.dispatcher.context.DebugUsers;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Response;
+import org.apache.isis.viewer.scimpi.dispatcher.util.UserManager;
import org.apache.log4j.Logger;
public class DispatcherServlet extends HttpServlet {
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/servlet/src/main/java/org/apache/isis/viewer/scimpi/servlet/ServletRequestContext.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/servlet/src/main/java/org/apache/isis/viewer/scimpi/servlet/ServletRequestContext.java b/component/viewer/scimpi/servlet/src/main/java/org/apache/isis/viewer/scimpi/servlet/ServletRequestContext.java
index 8c6386b..eb00f5b 100644
--- a/component/viewer/scimpi/servlet/src/main/java/org/apache/isis/viewer/scimpi/servlet/ServletRequestContext.java
+++ b/component/viewer/scimpi/servlet/src/main/java/org/apache/isis/viewer/scimpi/servlet/ServletRequestContext.java
@@ -39,10 +39,10 @@ import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
import org.apache.isis.core.metamodel.spec.ObjectSpecification;
import org.apache.isis.viewer.scimpi.ScimpiException;
import org.apache.isis.viewer.scimpi.dispatcher.DispatchException;
-import org.apache.isis.viewer.scimpi.dispatcher.ScimpiNotFoundException;
+import org.apache.isis.viewer.scimpi.dispatcher.context.DebugUsers;
import org.apache.isis.viewer.scimpi.dispatcher.context.ErrorCollator;
import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
-import org.apache.isis.viewer.scimpi.security.DebugUsers;
+import org.apache.isis.viewer.scimpi.dispatcher.context.ScimpiNotFoundException;
public class ServletRequestContext extends Request {
private HttpServletRequest request;
[06/24] Restructuring Scimpi to remove dependencies and enable easier
testing.
Posted by rm...@apache.org.
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/ActionButton.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/ActionButton.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/ActionButton.java
index 0192724..2954e4e 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/ActionButton.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/ActionButton.java
@@ -30,12 +30,13 @@ import org.apache.isis.core.metamodel.spec.ObjectSpecification;
import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
import org.apache.isis.core.metamodel.spec.feature.ObjectActionParameter;
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.processor.Request;
+import org.apache.isis.viewer.scimpi.Names;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
import org.apache.isis.viewer.scimpi.dispatcher.util.MethodsUtils;
-import org.apache.isis.viewer.scimpi.dispatcher.view.HelpLink;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.other.HelpLink;
public class ActionButton extends AbstractElementProcessor {
private static final Logger LOG = Logger.getLogger(ActionButton.class);
@@ -48,28 +49,28 @@ public class ActionButton extends AbstractElementProcessor {
private final static Where where = Where.ANYWHERE;
@Override
- public void process(final Request request) {
- final String objectId = request.getOptionalProperty(OBJECT);
- final String methodName = request.getRequiredProperty(METHOD);
- final String forwardResultTo = request.getOptionalProperty(VIEW);
- final String forwardVoidTo = request.getOptionalProperty(VOID);
- final String forwardErrorTo = request.getOptionalProperty(ERROR);
- final String variable = request.getOptionalProperty(RESULT_NAME);
- final String scope = request.getOptionalProperty(SCOPE);
- final String buttonTitle = request.getOptionalProperty(BUTTON_TITLE);
- String resultOverride = request.getOptionalProperty(RESULT_OVERRIDE);
- final String idName = request.getOptionalProperty(ID, methodName);
- final String className = request.getOptionalProperty(CLASS);
- final boolean showMessage = request.isRequested(SHOW_MESSAGE, false);
- final String completionMessage = request.getOptionalProperty(MESSAGE);
-
- final ObjectAdapter object = MethodsUtils.findObject(request.getContext(), objectId);
- final String version = request.getContext().mapVersion(object);
+ public void process(final TagProcessor tagProcessor) {
+ final String objectId = tagProcessor.getOptionalProperty(OBJECT);
+ final String methodName = tagProcessor.getRequiredProperty(METHOD);
+ final String forwardResultTo = tagProcessor.getOptionalProperty(VIEW);
+ final String forwardVoidTo = tagProcessor.getOptionalProperty(VOID);
+ final String forwardErrorTo = tagProcessor.getOptionalProperty(ERROR);
+ final String variable = tagProcessor.getOptionalProperty(RESULT_NAME);
+ final String scope = tagProcessor.getOptionalProperty(SCOPE);
+ final String buttonTitle = tagProcessor.getOptionalProperty(BUTTON_TITLE);
+ String resultOverride = tagProcessor.getOptionalProperty(RESULT_OVERRIDE);
+ final String idName = tagProcessor.getOptionalProperty(ID, methodName);
+ final String className = tagProcessor.getOptionalProperty(CLASS);
+ final boolean showMessage = tagProcessor.isRequested(SHOW_MESSAGE, false);
+ final String completionMessage = tagProcessor.getOptionalProperty(MESSAGE);
+
+ final ObjectAdapter object = MethodsUtils.findObject(tagProcessor.getContext(), objectId);
+ final String version = tagProcessor.getContext().mapVersion(object);
final ObjectAction action = MethodsUtils.findAction(object, methodName);
final ActionContent parameterBlock = new ActionContent(action);
- request.setBlockContent(parameterBlock);
- request.processUtilCloseTag();
+ tagProcessor.setBlockContent(parameterBlock);
+ tagProcessor.processUtilCloseTag();
final String[] parameters = parameterBlock.getParameters();
final ObjectAdapter[] objectParameters;
@@ -77,7 +78,7 @@ public class ActionButton extends AbstractElementProcessor {
if (action.isContributed()) {
objectParameters= null;
System.arraycopy(parameters, 0, parameters, 1, parameters.length - 1);
- parameters[0] = request.getContext().mapObject(object, Scope.REQUEST);
+ parameters[0] = tagProcessor.getContext().mapObject(object, Scope.REQUEST);
target = action.realTarget(object);
if (!action.hasReturn() && resultOverride == null) {
resultOverride = parameters[0];
@@ -95,7 +96,7 @@ public class ActionButton extends AbstractElementProcessor {
Localization localization = IsisContext.getLocalization();
objectParameters[i] = facet.parseTextEntry(null, parameters[i], localization);
} else {
- objectParameters[i] = MethodsUtils.findObject(request.getContext(), parameters[i]);
+ objectParameters[i] = MethodsUtils.findObject(tagProcessor.getContext(), parameters[i]);
}
i++;
}
@@ -103,7 +104,7 @@ public class ActionButton extends AbstractElementProcessor {
if (MethodsUtils.isVisibleAndUsable(object, action, where) && MethodsUtils.canRunMethod(object, action, objectParameters).isAllowed()) {
// TODO use the form creation mechanism as used in ActionForm
- write(request, target, action, parameters, objectId, version, forwardResultTo, forwardVoidTo, forwardErrorTo, variable, scope, buttonTitle, completionMessage, resultOverride, idName, className);
+ write(tagProcessor, target, action, parameters, objectId, version, forwardResultTo, forwardVoidTo, forwardErrorTo, variable, scope, buttonTitle, completionMessage, resultOverride, idName, className);
}
if (showMessage) {
@@ -112,35 +113,35 @@ public class ActionButton extends AbstractElementProcessor {
final String notUsable = usable.getReason();
if (notUsable != null) {
String title = buttonTitle == null ? action.getName() : buttonTitle;
- disabledButton(request, title, notUsable, idName, className);
+ disabledButton(tagProcessor, title, notUsable, idName, className);
}
} else {
final Consent valid = action.isProposedArgumentSetValid(object, objectParameters);
final String notValid = valid.getReason();
if (notValid != null) {
String title = buttonTitle == null ? action.getName() : buttonTitle;
- disabledButton(request, title, notValid, idName, className);
+ disabledButton(tagProcessor, title, notValid, idName, className);
}
}
}
- request.popBlockContent();
+ tagProcessor.popBlockContent();
}
- private void disabledButton(final Request request, final String buttonTitle, String message, String id, String className) {
+ private void disabledButton(final TagProcessor tagProcessor, final String buttonTitle, String message, String id, String className) {
if (className == null) {
className = "access";
}
- request.appendHtml("<div id=\"" + id + "\" class=\"" + className + " disabled-form\">");
- request.appendHtml("<div class=\"button disabled\" title=\"");
- request.appendAsHtmlEncoded(message);
- request.appendHtml("\" >" + buttonTitle);
- request.appendHtml("</div>");
- request.appendHtml("</div>");
+ tagProcessor.appendHtml("<div id=\"" + id + "\" class=\"" + className + " disabled-form\">");
+ tagProcessor.appendHtml("<div class=\"button disabled\" title=\"");
+ tagProcessor.appendAsHtmlEncoded(message);
+ tagProcessor.appendHtml("\" >" + buttonTitle);
+ tagProcessor.appendHtml("</div>");
+ tagProcessor.appendHtml("</div>");
}
public static void write(
- final Request request,
+ final TagProcessor tagProcessor,
final ObjectAdapter object,
final ObjectAction action,
final String[] parameters,
@@ -156,7 +157,7 @@ public class ActionButton extends AbstractElementProcessor {
final String resultOverride,
final String idName,
final String className) {
- final RequestContext context = request.getContext();
+ final Request context = tagProcessor.getContext();
buttonTitle = buttonTitle != null ? buttonTitle : action.getName();
@@ -183,48 +184,48 @@ public class ActionButton extends AbstractElementProcessor {
final String idSegment = idName == null ? "" : ("id=\"" + idName + "\" ");
final String classSegment = "class=\"" + (className == null ? "action in-line" : className) + "\"";
- request.appendHtml("\n<form " + idSegment + classSegment + " action=\"action.app\" method=\"post\">\n");
+ tagProcessor.appendHtml("\n<form " + idSegment + classSegment + " action=\"action.app\" method=\"post\">\n");
if (objectId == null) {
- request.appendHtml(" <input type=\"hidden\" name=\"" + "_" + OBJECT + "\" value=\"" + context.getVariable(RequestContext.RESULT) + "\" />\n");
+ tagProcessor.appendHtml(" <input type=\"hidden\" name=\"" + "_" + OBJECT + "\" value=\"" + context.getVariable(Names.RESULT) + "\" />\n");
} else {
- request.appendHtml(" <input type=\"hidden\" name=\"" + "_" + OBJECT + "\" value=\"" + objectId + "\" />\n");
+ tagProcessor.appendHtml(" <input type=\"hidden\" name=\"" + "_" + OBJECT + "\" value=\"" + objectId + "\" />\n");
}
- request.appendHtml(" <input type=\"hidden\" name=\"" + "_" + VERSION + "\" value=\"" + version + "\" />\n");
+ tagProcessor.appendHtml(" <input type=\"hidden\" name=\"" + "_" + VERSION + "\" value=\"" + version + "\" />\n");
if (scope != null) {
- request.appendHtml(" <input type=\"hidden\" name=\"" + "_" + SCOPE + "\" value=\"" + scope + "\" />\n");
+ tagProcessor.appendHtml(" <input type=\"hidden\" name=\"" + "_" + SCOPE + "\" value=\"" + scope + "\" />\n");
}
- request.appendHtml(" <input type=\"hidden\" name=\"" + "_" + METHOD + "\" value=\"" + action.getId() + "\" />\n");
+ tagProcessor.appendHtml(" <input type=\"hidden\" name=\"" + "_" + METHOD + "\" value=\"" + action.getId() + "\" />\n");
if (forwardResultTo != null) {
forwardResultTo = context.fullFilePath(forwardResultTo);
- request.appendHtml(" <input type=\"hidden\" name=\"" + "_" + VIEW + "\" value=\"" + forwardResultTo + "\" />\n");
+ tagProcessor.appendHtml(" <input type=\"hidden\" name=\"" + "_" + VIEW + "\" value=\"" + forwardResultTo + "\" />\n");
}
if (forwardErrorTo == null) {
- forwardErrorTo = request.getContext().getResourceFile();
+ forwardErrorTo = tagProcessor.getContext().getResourceFile();
}
forwardErrorTo = context.fullFilePath(forwardErrorTo);
- request.appendHtml(" <input type=\"hidden\" name=\"" + "_" + ERROR + "\" value=\"" + forwardErrorTo + "\" />\n");
+ tagProcessor.appendHtml(" <input type=\"hidden\" name=\"" + "_" + ERROR + "\" value=\"" + forwardErrorTo + "\" />\n");
if (forwardVoidTo == null) {
- forwardVoidTo = request.getContext().getResourceFile();
+ forwardVoidTo = tagProcessor.getContext().getResourceFile();
}
forwardVoidTo = context.fullFilePath(forwardVoidTo);
- request.appendHtml(" <input type=\"hidden\" name=\"" + "_" + VOID + "\" value=\"" + forwardVoidTo + "\" />\n");
+ tagProcessor.appendHtml(" <input type=\"hidden\" name=\"" + "_" + VOID + "\" value=\"" + forwardVoidTo + "\" />\n");
if (variable != null) {
- request.appendHtml(" <input type=\"hidden\" name=\"" + "_" + RESULT_NAME + "\" value=\"" + variable + "\" />\n");
+ tagProcessor.appendHtml(" <input type=\"hidden\" name=\"" + "_" + RESULT_NAME + "\" value=\"" + variable + "\" />\n");
}
if (resultOverride != null) {
- request.appendHtml(" <input type=\"hidden\" name=\"" + "_" + RESULT_OVERRIDE + "\" value=\"" + resultOverride + "\" />\n");
+ tagProcessor.appendHtml(" <input type=\"hidden\" name=\"" + "_" + RESULT_OVERRIDE + "\" value=\"" + resultOverride + "\" />\n");
}
if (completionMessage != null) {
- request.appendHtml(" <input type=\"hidden\" name=\"" + "_" + MESSAGE + "\" value=\"" + completionMessage + "\" />\n");
+ tagProcessor.appendHtml(" <input type=\"hidden\" name=\"" + "_" + MESSAGE + "\" value=\"" + completionMessage + "\" />\n");
}
for (int i = 0; i < parameters.length; i++) {
- request.appendHtml(" <input type=\"hidden\" name=\"param" + (i + 1) + "\" value=\"" + parameters[i] + "\" />\n");
+ tagProcessor.appendHtml(" <input type=\"hidden\" name=\"param" + (i + 1) + "\" value=\"" + parameters[i] + "\" />\n");
}
- request.appendHtml(request.getContext().interactionFields());
- request.appendHtml(" <input class=\"button\" type=\"submit\" value=\"" + buttonTitle + "\" name=\"execute\" title=\"" + action.getDescription() + "\" />");
- HelpLink.append(request, action.getDescription(), action.getHelp());
- request.appendHtml("\n</form>\n");
+ tagProcessor.appendHtml(tagProcessor.getContext().interactionFields());
+ tagProcessor.appendHtml(" <input class=\"button\" type=\"submit\" value=\"" + buttonTitle + "\" name=\"execute\" title=\"" + action.getDescription() + "\" />");
+ HelpLink.append(tagProcessor, action.getDescription(), action.getHelp());
+ tagProcessor.appendHtml("\n</form>\n");
}
@Override
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/ActionContent.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/ActionContent.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/ActionContent.java
index 2466726..5d30f0d 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/ActionContent.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/ActionContent.java
@@ -28,9 +28,9 @@ import org.apache.isis.core.metamodel.spec.ObjectSpecification;
import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
import org.apache.isis.core.metamodel.spec.feature.ObjectActionParameter;
import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.viewer.scimpi.dispatcher.BlockContent;
-import org.apache.isis.viewer.scimpi.dispatcher.ScimpiException;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
+import org.apache.isis.viewer.scimpi.ScimpiException;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.BlockContent;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
public class ActionContent implements BlockContent {
private final ObjectAction action;
@@ -55,7 +55,7 @@ public class ActionContent implements BlockContent {
parameters[index] = value;
}
- public ObjectAdapter[] getParameters(final Request request) {
+ public ObjectAdapter[] getParameters(final TagProcessor tagProcessor) {
final ObjectAdapter[] params = new ObjectAdapter[parameters.length];
final List<ObjectActionParameter> pars = action.getParameters();
for (int i = 0; i < parameters.length; i++) {
@@ -65,7 +65,7 @@ public class ActionContent implements BlockContent {
Localization localization = IsisContext.getLocalization();
params[i] = facet.parseTextEntry(null, parameters[i], localization);
} else {
- params[i] = request.getContext().getMappedObject(parameters[i]);
+ params[i] = tagProcessor.getContext().getMappedObject(parameters[i]);
}
}
return params;
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/ActionForm.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/ActionForm.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/ActionForm.java
index 5f47985..9f1d682 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/ActionForm.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/ActionForm.java
@@ -26,20 +26,21 @@ import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
import org.apache.isis.core.metamodel.spec.ObjectSpecification;
import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
import org.apache.isis.core.metamodel.spec.feature.ObjectActionParameter;
-import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.ScimpiException;
+import org.apache.isis.viewer.scimpi.Names;
+import org.apache.isis.viewer.scimpi.ScimpiException;
import org.apache.isis.viewer.scimpi.dispatcher.action.ActionAction;
-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.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.structure.FieldEditState;
+import org.apache.isis.viewer.scimpi.dispatcher.structure.FormState;
import org.apache.isis.viewer.scimpi.dispatcher.util.MethodsUtils;
-import org.apache.isis.viewer.scimpi.dispatcher.view.edit.FieldFactory;
-import org.apache.isis.viewer.scimpi.dispatcher.view.edit.FormFieldBlock;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
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;
+import org.apache.isis.viewer.scimpi.dispatcher.view.widget.FieldFactory;
+import org.apache.isis.viewer.scimpi.dispatcher.view.widget.FormFieldBlock;
public class ActionForm extends AbstractElementProcessor {
@@ -47,37 +48,37 @@ public class ActionForm extends AbstractElementProcessor {
private final static Where where = Where.OBJECT_FORMS;
@Override
- public void process(final Request request) {
+ public void process(final TagProcessor tagProcessor) {
final CreateFormParameter parameters = new CreateFormParameter();
- parameters.objectId = request.getOptionalProperty(OBJECT);
- parameters.methodName = request.getRequiredProperty(METHOD);
- parameters.forwardResultTo = request.getOptionalProperty(VIEW);
- parameters.forwardVoidTo = request.getOptionalProperty(VOID);
- parameters.forwardErrorTo = request.getOptionalProperty(ERROR);
- parameters.cancelTo = request.getOptionalProperty(CANCEL_TO);
- parameters.showIcon = request.isRequested(SHOW_ICON, showIconByDefault());
- parameters.buttonTitle = request.getOptionalProperty(BUTTON_TITLE);
- parameters.formTitle = request.getOptionalProperty(FORM_TITLE);
- parameters.labelDelimiter = request.getOptionalProperty(LABEL_DELIMITER, ":");
- parameters.formId = request.getOptionalProperty(FORM_ID, request.nextFormId());
- parameters.resultName = request.getOptionalProperty(RESULT_NAME);
- parameters.resultOverride = request.getOptionalProperty(RESULT_OVERRIDE);
- parameters.scope = request.getOptionalProperty(SCOPE);
- parameters.className = request.getOptionalProperty(CLASS, "action full");
- parameters.showMessage = request.isRequested(SHOW_MESSAGE, false);
- parameters.completionMessage = request.getOptionalProperty(MESSAGE);
- parameters.id = request.getOptionalProperty(ID, parameters.methodName);
- createForm(request, parameters);
+ parameters.objectId = tagProcessor.getOptionalProperty(OBJECT);
+ parameters.methodName = tagProcessor.getRequiredProperty(METHOD);
+ parameters.forwardResultTo = tagProcessor.getOptionalProperty(VIEW);
+ parameters.forwardVoidTo = tagProcessor.getOptionalProperty(VOID);
+ parameters.forwardErrorTo = tagProcessor.getOptionalProperty(ERROR);
+ parameters.cancelTo = tagProcessor.getOptionalProperty(CANCEL_TO);
+ parameters.showIcon = tagProcessor.isRequested(SHOW_ICON, showIconByDefault());
+ parameters.buttonTitle = tagProcessor.getOptionalProperty(BUTTON_TITLE);
+ parameters.formTitle = tagProcessor.getOptionalProperty(FORM_TITLE);
+ parameters.labelDelimiter = tagProcessor.getOptionalProperty(LABEL_DELIMITER, ":");
+ parameters.formId = tagProcessor.getOptionalProperty(FORM_ID, tagProcessor.nextFormId());
+ parameters.resultName = tagProcessor.getOptionalProperty(RESULT_NAME);
+ parameters.resultOverride = tagProcessor.getOptionalProperty(RESULT_OVERRIDE);
+ parameters.scope = tagProcessor.getOptionalProperty(SCOPE);
+ parameters.className = tagProcessor.getOptionalProperty(CLASS, "action full");
+ parameters.showMessage = tagProcessor.isRequested(SHOW_MESSAGE, false);
+ parameters.completionMessage = tagProcessor.getOptionalProperty(MESSAGE);
+ parameters.id = tagProcessor.getOptionalProperty(ID, parameters.methodName);
+ createForm(tagProcessor, parameters);
}
- public static void createForm(final Request request, final CreateFormParameter parameterObject) {
- createForm(request, parameterObject, false);
+ public static void createForm(final TagProcessor tagProcessor, final CreateFormParameter parameterObject) {
+ createForm(tagProcessor, parameterObject, false);
}
- protected static void createForm(final Request request, final CreateFormParameter parameterObject, final boolean withoutProcessing) {
- final RequestContext context = request.getContext();
+ protected static void createForm(final TagProcessor tagProcessor, final CreateFormParameter parameterObject, final boolean withoutProcessing) {
+ final Request context = tagProcessor.getContext();
final ObjectAdapter object = MethodsUtils.findObject(context, parameterObject.objectId);
- final String version = request.getContext().mapVersion(object);
+ final String version = tagProcessor.getContext().mapVersion(object);
final ObjectAction action = MethodsUtils.findAction(object, parameterObject.methodName);
// TODO how do we distinguish between overloaded methods?
@@ -89,17 +90,17 @@ public class ActionForm extends AbstractElementProcessor {
final String notUsable = MethodsUtils.isUsable(object, action, where);
if (notUsable != null) {
if (!withoutProcessing) {
- request.skipUntilClose();
+ tagProcessor.skipUntilClose();
}
- request.appendHtml("<div class=\"" + parameterObject.className + "-message\" >");
- request.appendAsHtmlEncoded(notUsable);
- request.appendHtml("</div>");
+ tagProcessor.appendHtml("<div class=\"" + parameterObject.className + "-message\" >");
+ tagProcessor.appendAsHtmlEncoded(notUsable);
+ tagProcessor.appendHtml("</div>");
return;
}
}
if (!MethodsUtils.isVisibleAndUsable(object, action, where)) {
if (!withoutProcessing) {
- request.skipUntilClose();
+ tagProcessor.skipUntilClose();
}
return;
}
@@ -113,7 +114,7 @@ public class ActionForm extends AbstractElementProcessor {
parameterObject.forwardResultTo == null ? null : new HiddenInputField("_" + VIEW, context.fullFilePath(parameterObject.forwardResultTo)), new HiddenInputField("_" + VOID, voidView), new HiddenInputField("_" + ERROR, errorView),
parameterObject.completionMessage == null ? null : new HiddenInputField("_" + MESSAGE, parameterObject.completionMessage), parameterObject.scope == null ? null : new HiddenInputField("_" + SCOPE, parameterObject.scope),
parameterObject.resultOverride == null ? null : new HiddenInputField("_" + RESULT_OVERRIDE, parameterObject.resultOverride), parameterObject.resultName == null ? null : new HiddenInputField("_" + RESULT_NAME, parameterObject.resultName),
- parameterObject.resultName == null ? null : new HiddenInputField(RequestContext.RESULT, (String) request.getContext().getVariable(RequestContext.RESULT)) };
+ parameterObject.resultName == null ? null : new HiddenInputField(Names.RESULT, (String) tagProcessor.getContext().getVariable(Names.RESULT)) };
// TODO when the block contains a selector tag it doesn't disable it if
// the field cannot be edited!!!
@@ -125,9 +126,9 @@ public class ActionForm extends AbstractElementProcessor {
return param.isOptional();
}
};
- request.setBlockContent(containedBlock);
+ tagProcessor.setBlockContent(containedBlock);
if (!withoutProcessing) {
- request.processUtilCloseTag();
+ tagProcessor.processUtilCloseTag();
}
final FormState entryState = (FormState) context.getVariable(ENTRY_FIELDS);
@@ -160,10 +161,10 @@ public class ActionForm extends AbstractElementProcessor {
buttonTitle = "Ok";
}
- HtmlFormBuilder.createForm(request, ActionAction.ACTION + ".app", hiddenFields, formFields, parameterObject.className,
+ HtmlFormBuilder.createForm(tagProcessor, ActionAction.ACTION + ".app", hiddenFields, formFields, parameterObject.className,
parameterObject.id, formTitle, parameterObject.labelDelimiter, action.getDescription(), action.getHelp(), buttonTitle, errors, parameterObject.cancelTo);
- request.popBlockContent();
+ tagProcessor.popBlockContent();
}
private static InputField[] createFields(final ObjectAction action, final ObjectAdapter object) {
@@ -175,7 +176,7 @@ public class ActionForm extends AbstractElementProcessor {
return fields;
}
- private static void initializeFields(final RequestContext context, final ObjectAdapter object, final ObjectAction action, final InputField[] fields) {
+ private static void initializeFields(final Request context, final ObjectAdapter object, final ObjectAction action, final InputField[] fields) {
final List<ObjectActionParameter> parameters = action.getParameters();
for (int i = 0; i < fields.length; i++) {
final InputField field = fields[i];
@@ -199,7 +200,7 @@ public class ActionForm extends AbstractElementProcessor {
*
* @param showIcon
*/
- private static void setDefaults(final RequestContext context, final ObjectAdapter object, final ObjectAction action, final InputField[] fields, final FormState entryState, final boolean showIcon) {
+ private static void setDefaults(final Request context, final ObjectAdapter object, final ObjectAction action, final InputField[] fields, final FormState entryState, final boolean showIcon) {
final ObjectAdapter[] defaultValues = action.getDefaults(object);
if (defaultValues == null) {
return;
@@ -225,7 +226,7 @@ public class ActionForm extends AbstractElementProcessor {
}
}
- private static void copyEntryState(final RequestContext context, final ObjectAdapter object, final ObjectAction action, final InputField[] fields, final FormState entryState) {
+ private static void copyEntryState(final Request context, final ObjectAdapter object, final ObjectAction action, final InputField[] fields, final FormState entryState) {
for (final InputField field : fields) {
final FieldEditState fieldState = entryState.getField(field.getName());
@@ -241,7 +242,7 @@ public class ActionForm extends AbstractElementProcessor {
}
}
- private static void overrideWithHtml(final RequestContext context, final FormFieldBlock containedBlock, final InputField[] formFields) {
+ private static void overrideWithHtml(final Request context, final FormFieldBlock containedBlock, final InputField[] formFields) {
for (int i = 0; i < formFields.length; i++) {
final String id = ActionAction.parameterName(i);
if (containedBlock.hasContent(id)) {
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/ActionLink.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/ActionLink.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/ActionLink.java
index 0f09e19..3a50cda 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/ActionLink.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/ActionLink.java
@@ -24,12 +24,12 @@ import java.net.URLEncoder;
import org.apache.isis.applib.annotation.Where;
import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
-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;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
import org.apache.isis.viewer.scimpi.dispatcher.util.MethodsUtils;
-import org.apache.isis.viewer.scimpi.dispatcher.view.HelpLink;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.other.HelpLink;
public class ActionLink extends AbstractElementProcessor {
@@ -37,43 +37,43 @@ public class ActionLink extends AbstractElementProcessor {
private final Where where = Where.OBJECT_FORMS;
@Override
- public void process(final Request request) {
- String objectId = request.getOptionalProperty(OBJECT);
- final String method = request.getOptionalProperty(METHOD);
- final String forwardResultTo = request.getOptionalProperty(VIEW);
- final String forwardVoidTo = request.getOptionalProperty(VOID);
- String resultOverride = request.getOptionalProperty(RESULT_OVERRIDE);
+ public void process(final TagProcessor tagProcessor) {
+ String objectId = tagProcessor.getOptionalProperty(OBJECT);
+ final String method = tagProcessor.getOptionalProperty(METHOD);
+ final String forwardResultTo = tagProcessor.getOptionalProperty(VIEW);
+ final String forwardVoidTo = tagProcessor.getOptionalProperty(VOID);
+ String resultOverride = tagProcessor.getOptionalProperty(RESULT_OVERRIDE);
- final String resultName = request.getOptionalProperty(RESULT_NAME);
+ final String resultName = tagProcessor.getOptionalProperty(RESULT_NAME);
final String resultNameSegment = resultName == null ? "" : "&" + RESULT_NAME + "=" + resultName;
- final String scope = request.getOptionalProperty(SCOPE);
+ final String scope = tagProcessor.getOptionalProperty(SCOPE);
final String scopeSegment = scope == null ? "" : "&" + SCOPE + "=" + scope;
- final String confirm = request.getOptionalProperty(CONFIRM);
- final String completionMessage = request.getOptionalProperty(MESSAGE);
+ final String confirm = tagProcessor.getOptionalProperty(CONFIRM);
+ final String completionMessage = tagProcessor.getOptionalProperty(MESSAGE);
// TODO need a mechanism for globally dealing with encoding; then use
// the new encode method
final String confirmSegment = confirm == null ? "" : "&" + "_" + CONFIRM + "=" + URLEncoder.encode(confirm);
final String messageSegment = completionMessage == null ? "" : "&" + "_" + MESSAGE + "=" + URLEncoder.encode(completionMessage);
- final RequestContext context = request.getContext();
+ final Request context = tagProcessor.getContext();
final ObjectAdapter object = MethodsUtils.findObject(context, objectId);
final String version = context.mapVersion(object);
final ObjectAction action = MethodsUtils.findAction(object, method);
- objectId = request.getContext().mapObject(object, Scope.REQUEST);
+ objectId = tagProcessor.getContext().mapObject(object, Scope.REQUEST);
final ActionContent parameterBlock = new ActionContent(action);
- request.setBlockContent(parameterBlock);
- request.pushNewBuffer();
- request.processUtilCloseTag();
- final String text = request.popBuffer();
+ tagProcessor.setBlockContent(parameterBlock);
+ tagProcessor.pushNewBuffer();
+ tagProcessor.processUtilCloseTag();
+ final String text = tagProcessor.popBuffer();
final String[] parameters = parameterBlock.getParameters();
final String target;
if (action.isContributed()) {
System.arraycopy(parameters, 0, parameters, 1, parameters.length - 1);
- parameters[0] = request.getContext().mapObject(object, Scope.REQUEST);
- target = request.getContext().mapObject(action.realTarget(object), Scope.REQUEST);
+ parameters[0] = tagProcessor.getContext().mapObject(object, Scope.REQUEST);
+ target = tagProcessor.getContext().mapObject(action.realTarget(object), Scope.REQUEST);
if (!action.hasReturn() && resultOverride == null) {
resultOverride = parameters[0];
}
@@ -82,14 +82,14 @@ public class ActionLink extends AbstractElementProcessor {
}
if (MethodsUtils.isVisibleAndUsable(object, action, where)) {
- writeLink(request, target, version, method, forwardResultTo, forwardVoidTo, resultNameSegment, resultOverride, scopeSegment,
+ writeLink(tagProcessor, target, version, method, forwardResultTo, forwardVoidTo, resultNameSegment, resultOverride, scopeSegment,
confirmSegment, messageSegment, context, action, parameters, text);
}
- request.popBlockContent();
+ tagProcessor.popBlockContent();
}
public static void writeLink(
- final Request request,
+ final TagProcessor tagProcessor,
final String objectId,
final String version,
final String method,
@@ -100,7 +100,7 @@ public class ActionLink extends AbstractElementProcessor {
final String scopeSegment,
final String confirmSegment,
final String messageSegment,
- final RequestContext context,
+ final Request context,
final ObjectAction action,
final String[] parameters,
String text) {
@@ -116,12 +116,12 @@ public class ActionLink extends AbstractElementProcessor {
final String resultOverrideSegment = resultOverride == null ? "" : "&" + "_" + RESULT_OVERRIDE + "=" + resultOverride;
final String voidView = context.fullFilePath(forwardVoidTo == null ? context.getResourceFile() : forwardVoidTo);
final String forwardVoidSegment = "&" + "_" + VOID + "=" + voidView;
- request.appendHtml("<a href=\"action.app?" + "_" + OBJECT + "=" + objectId + "&" + "_" + VERSION + "=" + version
+ tagProcessor.appendHtml("<a href=\"action.app?" + "_" + OBJECT + "=" + objectId + "&" + "_" + VERSION + "=" + version
+ "&" + "_" + METHOD + "=" + method + resultOverrideSegment + forwardResultSegment + forwardVoidSegment + resultNameSegment
+ parameterSegment + scopeSegment + confirmSegment + messageSegment + interactionParamters + "\">");
- request.appendHtml(text);
- request.appendHtml("</a>");
- HelpLink.append(request, action.getDescription(), action.getHelp());
+ tagProcessor.appendHtml(text);
+ tagProcessor.appendHtml("</a>");
+ HelpLink.append(tagProcessor, action.getDescription(), action.getHelp());
}
@Override
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/Methods.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/Methods.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/Methods.java
index 37e5ba4..7c334fb 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/Methods.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/Methods.java
@@ -28,11 +28,11 @@ import org.apache.isis.core.metamodel.spec.ObjectActionSet;
import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
import org.apache.isis.core.metamodel.spec.feature.ObjectActionContainer.Contributed;
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.context.RequestContext.Scope;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
+import org.apache.isis.viewer.scimpi.Names;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
import org.apache.isis.viewer.scimpi.dispatcher.util.MethodsUtils;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
import org.apache.isis.viewer.scimpi.dispatcher.view.field.InclusionList;
public class Methods extends AbstractElementProcessor {
@@ -45,33 +45,33 @@ public class Methods extends AbstractElementProcessor {
private final static Where where = Where.ANYWHERE;
@Override
- public void process(final Request request) {
- String objectId = request.getOptionalProperty(OBJECT);
- final String view = request.getOptionalProperty(VIEW, "_generic_action." + Dispatcher.EXTENSION);
- final String cancelTo = request.getOptionalProperty(CANCEL_TO);
- final boolean showForms = request.isRequested(FORMS, false);
- final ObjectAdapter object = MethodsUtils.findObject(request.getContext(), objectId);
+ public void process(final TagProcessor tagProcessor) {
+ String objectId = tagProcessor.getOptionalProperty(OBJECT);
+ final String view = tagProcessor.getOptionalProperty(VIEW, "_generic_action." + Names.EXTENSION);
+ // final String cancelTo = tagProcessor.getOptionalProperty(CANCEL_TO);
+ final boolean showForms = tagProcessor.isRequested(FORMS, false);
+ final ObjectAdapter object = MethodsUtils.findObject(tagProcessor.getContext(), objectId);
if (objectId == null) {
- objectId = request.getContext().mapObject(object, null);
+ objectId = tagProcessor.getContext().mapObject(object, null);
}
final InclusionList inclusionList = new InclusionList();
- request.setBlockContent(inclusionList);
- request.processUtilCloseTag();
+ tagProcessor.setBlockContent(inclusionList);
+ tagProcessor.processUtilCloseTag();
- request.appendHtml("<div class=\"actions\">");
+ tagProcessor.appendHtml("<div class=\"actions\">");
if (inclusionList.includes("edit") && !object.getSpecification().isService()) {
- request.appendHtml("<div class=\"action\">");
- request.appendHtml("<a class=\"button\" href=\"_generic_edit." + Dispatcher.EXTENSION + "?_result=" + objectId + "\">Edit...</a>");
- request.appendHtml("</div>");
+ tagProcessor.appendHtml("<div class=\"action\">");
+ tagProcessor.appendHtml("<a class=\"button\" href=\"_generic_edit." + Names.EXTENSION + "?_result=" + objectId + "\">Edit...</a>");
+ tagProcessor.appendHtml("</div>");
}
- writeMethods(request, objectId, object, showForms, inclusionList, view, "_generic.shtml?_result=" + objectId);
- request.popBlockContent();
- request.appendHtml("</div>");
+ writeMethods(tagProcessor, objectId, object, showForms, inclusionList, view, "_generic.shtml?_result=" + objectId);
+ tagProcessor.popBlockContent();
+ tagProcessor.appendHtml("</div>");
}
public static void writeMethods(
- final Request request,
+ final TagProcessor tagProcessor,
final String objectId,
final ObjectAdapter adapter,
final boolean showForms,
@@ -79,21 +79,21 @@ public class Methods extends AbstractElementProcessor {
final String view,
final String cancelTo) {
List<ObjectAction> actions = adapter.getSpecification().getObjectActions(ActionType.USER, Contributed.INCLUDED);
- writeMethods(request, adapter, actions, objectId, showForms, inclusionList, view, cancelTo);
+ writeMethods(tagProcessor, adapter, actions, objectId, showForms, inclusionList, view, cancelTo);
// TODO determine if system is set up to display exploration methods
if (true) {
actions = adapter.getSpecification().getObjectActions(ActionType.EXPLORATION, Contributed.INCLUDED);
- writeMethods(request, adapter, actions, objectId, showForms, inclusionList, view, cancelTo);
+ writeMethods(tagProcessor, adapter, actions, objectId, showForms, inclusionList, view, cancelTo);
}
// TODO determine if system is set up to display debug methods
if (true) {
actions = adapter.getSpecification().getObjectActions(ActionType.DEBUG, Contributed.INCLUDED);
- writeMethods(request, adapter, actions, objectId, showForms, inclusionList, view, cancelTo);
+ writeMethods(tagProcessor, adapter, actions, objectId, showForms, inclusionList, view, cancelTo);
}
}
private static void writeMethods(
- final Request request,
+ final TagProcessor tagProcessor,
final ObjectAdapter adapter,
List<ObjectAction> actions,
final String objectId,
@@ -105,32 +105,32 @@ public class Methods extends AbstractElementProcessor {
for (int j = 0; j < actions.size(); j++) {
final ObjectAction action = actions.get(j);
if (action instanceof ObjectActionSet) {
- request.appendHtml("<div class=\"actions\">");
- writeMethods(request, adapter, action.getActions(), objectId, showForms, inclusionList, view, cancelTo);
- request.appendHtml("</div>");
+ tagProcessor.appendHtml("<div class=\"actions\">");
+ writeMethods(tagProcessor, adapter, action.getActions(), objectId, showForms, inclusionList, view, cancelTo);
+ tagProcessor.appendHtml("</div>");
} else if (action.isContributed()) {
if (action.getParameterCount() == 1 && adapter.getSpecification().isOfType(action.getParameters().get(0).getSpecification())) {
if (objectId != null) {
- final ObjectAdapter target = request.getContext().getMappedObject(objectId);
+ final ObjectAdapter target = tagProcessor.getContext().getMappedObject(objectId);
final ObjectAdapter realTarget = action.realTarget(target);
- final String realTargetId = request.getContext().mapObject(realTarget, Scope.INTERACTION);
- writeMethod(request, adapter, new String[] { objectId }, action, realTargetId, showForms, view, cancelTo);
+ final String realTargetId = tagProcessor.getContext().mapObject(realTarget, Scope.INTERACTION);
+ writeMethod(tagProcessor, adapter, new String[] { objectId }, action, realTargetId, showForms, view, cancelTo);
} else {
- request.appendHtml("<div class=\"action\">");
- request.appendAsHtmlEncoded(action.getName());
- request.appendHtml("???</div>");
+ tagProcessor.appendHtml("<div class=\"action\">");
+ tagProcessor.appendAsHtmlEncoded(action.getName());
+ tagProcessor.appendHtml("???</div>");
}
} else if (!adapter.getSpecification().isService()) {
- writeMethod(request, adapter, new String[0], action, objectId, showForms, view, cancelTo);
+ writeMethod(tagProcessor, adapter, new String[0], action, objectId, showForms, view, cancelTo);
}
} else {
- writeMethod(request, adapter, new String[0], action, objectId, showForms, view, cancelTo);
+ writeMethod(tagProcessor, adapter, new String[0], action, objectId, showForms, view, cancelTo);
}
}
}
private static void writeMethod(
- final Request request,
+ final TagProcessor tagProcessor,
final ObjectAdapter adapter,
final String[] parameters,
final ObjectAction action,
@@ -142,11 +142,11 @@ public class Methods extends AbstractElementProcessor {
// action.isVisible(IsisContext.getSession(), adapter))
// {
if (action.isVisible(IsisContext.getAuthenticationSession(), adapter, where).isAllowed()) {
- request.appendHtml("<div class=\"action\">");
+ tagProcessor.appendHtml("<div class=\"action\">");
if (IsisContext.getSession() == null) {
- request.appendHtml("<span class=\"disabled\" title=\"no user logged in\">");
- request.appendAsHtmlEncoded(action.getName());
- request.appendHtml("</span>");
+ tagProcessor.appendHtml("<span class=\"disabled\" title=\"no user logged in\">");
+ tagProcessor.appendAsHtmlEncoded(action.getName());
+ tagProcessor.appendHtml("</span>");
/*
* } else if (action.isUsable(IsisContext.getSession(),
* null).isVetoed()) {
@@ -155,33 +155,33 @@ public class Methods extends AbstractElementProcessor {
* "\">"); request.appendHtml(action.getName());
* request.appendHtml("</span>");
*/} else if (action.isUsable(IsisContext.getAuthenticationSession(), adapter, where).isVetoed()) {
- request.appendHtml("<span class=\"disabled\" title=\"" + action.isUsable(IsisContext.getAuthenticationSession(), adapter, where).getReason() + "\">");
- request.appendAsHtmlEncoded(action.getName());
- request.appendHtml("</span>");
+ tagProcessor.appendHtml("<span class=\"disabled\" title=\"" + action.isUsable(IsisContext.getAuthenticationSession(), adapter, where).getReason() + "\">");
+ tagProcessor.appendAsHtmlEncoded(action.getName());
+ tagProcessor.appendHtml("</span>");
} else {
- final String version = request.getContext().mapVersion(adapter);
+ final String version = tagProcessor.getContext().mapVersion(adapter);
if (action.getParameterCount() == 0 || (action.isContributed() && action.getParameterCount() == 1)) {
- ActionButton.write(request, adapter, action, parameters, objectId, version, "_generic." + Dispatcher.EXTENSION, null, null, null, null, null, null, null, null, null);
+ ActionButton.write(tagProcessor, adapter, action, parameters, objectId, version, "_generic." + Names.EXTENSION, null, null, null, null, null, null, null, null, null);
} else if (showForms) {
final CreateFormParameter params = new CreateFormParameter();
params.objectId = objectId;
params.methodName = action.getId();
- params.forwardResultTo = "_generic." + Dispatcher.EXTENSION;
+ params.forwardResultTo = "_generic." + Names.EXTENSION;
params.buttonTitle = "OK";
params.formTitle = action.getName();
- ActionForm.createForm(request, params, true);
+ ActionForm.createForm(tagProcessor, params, true);
} else {
- request.appendHtml("<a class=\"button\" href=\"" + view + "?_result=" + objectId + "&_" + VERSION + "=" + version + "&_" + METHOD + "=" + action.getId());
+ tagProcessor.appendHtml("<a class=\"button\" href=\"" + view + "?_result=" + objectId + "&_" + VERSION + "=" + version + "&_" + METHOD + "=" + action.getId());
if (cancelTo != null) {
- request.appendHtml("&_cancel-to=");
- request.appendAsHtmlEncoded("cancel-to=\"" + cancelTo + "\"");
+ tagProcessor.appendHtml("&_cancel-to=");
+ tagProcessor.appendAsHtmlEncoded("cancel-to=\"" + cancelTo + "\"");
}
- request.appendHtml("\" title=\"" + action.getDescription() + "\">");
- request.appendAsHtmlEncoded(action.getName() + "...");
- request.appendHtml("</a>");
+ tagProcessor.appendHtml("\" title=\"" + action.getDescription() + "\">");
+ tagProcessor.appendAsHtmlEncoded(action.getName() + "...");
+ tagProcessor.appendHtml("</a>");
}
}
- request.appendHtml("</div>");
+ tagProcessor.appendHtml("</div>");
}
}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/Parameter.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/Parameter.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/Parameter.java
index 69be5c5..cbf7464 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/Parameter.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/Parameter.java
@@ -19,22 +19,22 @@
package org.apache.isis.viewer.scimpi.dispatcher.view.action;
-import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.BlockContent;
import org.apache.isis.viewer.scimpi.dispatcher.TagOrderException;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.BlockContent;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public class Parameter extends AbstractElementProcessor {
@Override
- public void process(final Request request) {
- final BlockContent blockContent = request.getBlockContent();
+ public void process(final TagProcessor tagProcessor) {
+ final BlockContent blockContent = tagProcessor.getBlockContent();
if (!(blockContent instanceof ActionContent)) {
- throw new TagOrderException(request);
+ throw new TagOrderException(tagProcessor);
}
- final String field = request.getOptionalProperty(PARAMETER_NUMBER);
- final String value = request.getRequiredProperty(VALUE);
+ final String field = tagProcessor.getOptionalProperty(PARAMETER_NUMBER);
+ final String value = tagProcessor.getRequiredProperty(VALUE);
final ActionContent block = (ActionContent) blockContent;
block.setParameter(field, value);
}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/RunAction.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/RunAction.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/RunAction.java
index 6aa2138..00d617c 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/RunAction.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/RunAction.java
@@ -25,12 +25,12 @@ import org.apache.isis.applib.annotation.Where;
import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
import org.apache.isis.core.metamodel.spec.feature.ObjectActionParameter;
-import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.ForbiddenException;
-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.ForbiddenException;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
import org.apache.isis.viewer.scimpi.dispatcher.util.MethodsUtils;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public class RunAction extends AbstractElementProcessor {
@@ -42,22 +42,22 @@ public class RunAction extends AbstractElementProcessor {
private final Where where = Where.ANYWHERE;
@Override
- public void process(final Request request) {
- final RequestContext context = request.getContext();
+ public void process(final TagProcessor tagProcessor) {
+ final Request context = tagProcessor.getContext();
- final String objectId = request.getOptionalProperty(OBJECT);
+ final String objectId = tagProcessor.getOptionalProperty(OBJECT);
final ObjectAdapter object = MethodsUtils.findObject(context, objectId);
- final String methodName = request.getRequiredProperty(METHOD);
+ final String methodName = tagProcessor.getRequiredProperty(METHOD);
final ObjectAction action = MethodsUtils.findAction(object, methodName);
- final String variableName = request.getOptionalProperty(RESULT_NAME);
- final String scopeName = request.getOptionalProperty(SCOPE);
+ final String variableName = tagProcessor.getOptionalProperty(RESULT_NAME);
+ final String scopeName = tagProcessor.getOptionalProperty(SCOPE);
final ActionContent parameterBlock = new ActionContent(action);
- request.setBlockContent(parameterBlock);
- request.processUtilCloseTag();
- final ObjectAdapter[] parameters = parameterBlock.getParameters(request);
+ tagProcessor.setBlockContent(parameterBlock);
+ tagProcessor.processUtilCloseTag();
+ final ObjectAdapter[] parameters = parameterBlock.getParameters(tagProcessor);
if (!MethodsUtils.isVisibleAndUsable(object, action, where)) {
throw new ForbiddenException(action, ForbiddenException.VISIBLE_AND_USABLE);
@@ -74,9 +74,9 @@ public class RunAction extends AbstractElementProcessor {
}
}
- final Scope scope = RequestContext.scope(scopeName, Scope.REQUEST);
+ final Scope scope = Request.scope(scopeName, Scope.REQUEST);
MethodsUtils.runMethod(context, action, object, parameters, variableName, scope);
- request.popBlockContent();
+ tagProcessor.popBlockContent();
}
@Override
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/Services.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/Services.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/Services.java
index 2a621f1..761b849 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/Services.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/action/Services.java
@@ -24,35 +24,35 @@ import java.util.List;
import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
import org.apache.isis.core.runtime.system.context.IsisContext;
import org.apache.isis.core.runtime.system.persistence.PersistenceSession;
-import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.Dispatcher;
-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.Names;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
import org.apache.isis.viewer.scimpi.dispatcher.view.field.InclusionList;
public class Services extends AbstractElementProcessor {
@Override
- public void process(final Request request) {
- final boolean showForms = request.isRequested(FORMS, false);
- final String view = request.getOptionalProperty(VIEW, "_generic_action." + Dispatcher.EXTENSION);
- final String cancelTo = request.getOptionalProperty(CANCEL_TO);
+ public void process(final TagProcessor tagProcessor) {
+ final boolean showForms = tagProcessor.isRequested(FORMS, false);
+ final String view = tagProcessor.getOptionalProperty(VIEW, "_generic_action." + Names.EXTENSION);
+ final String cancelTo = tagProcessor.getOptionalProperty(CANCEL_TO);
final InclusionList inclusionList = new InclusionList();
- request.setBlockContent(inclusionList);
- request.processUtilCloseTag();
+ tagProcessor.setBlockContent(inclusionList);
+ tagProcessor.processUtilCloseTag();
final List<ObjectAdapter> serviceAdapters = getPersistenceSession().getServices();
for (final ObjectAdapter adapter : serviceAdapters) {
- final String serviceId = request.getContext().mapObject(adapter, Scope.REQUEST);
- request.appendHtml("<div class=\"actions\">");
- request.appendHtml("<h3>");
- request.appendAsHtmlEncoded(adapter.titleString());
- request.appendHtml("</h3>");
- Methods.writeMethods(request, serviceId, adapter, showForms, inclusionList, view, cancelTo);
- request.appendHtml("</div>");
+ final String serviceId = tagProcessor.getContext().mapObject(adapter, Scope.REQUEST);
+ tagProcessor.appendHtml("<div class=\"actions\">");
+ tagProcessor.appendHtml("<h3>");
+ tagProcessor.appendAsHtmlEncoded(adapter.titleString());
+ tagProcessor.appendHtml("</h3>");
+ Methods.writeMethods(tagProcessor, serviceId, adapter, showForms, inclusionList, view, cancelTo);
+ tagProcessor.appendHtml("</div>");
}
- request.popBlockContent();
+ tagProcessor.popBlockContent();
}
@Override
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/collection/Collection.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/collection/Collection.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/collection/Collection.java
index 5a561b6..20e0cc9 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/collection/Collection.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/collection/Collection.java
@@ -25,24 +25,24 @@ import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacet;
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.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.processor.Request.RepeatMarker;
+import org.apache.isis.viewer.scimpi.ScimpiException;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor.RepeatMarker;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public class Collection extends AbstractElementProcessor {
@Override
- public void process(final Request request) {
- final RequestContext context = request.getContext();
+ public void process(final TagProcessor tagProcessor) {
+ final Request context = tagProcessor.getContext();
ObjectAdapter collection;
- final String field = request.getOptionalProperty(FIELD);
+ final String field = tagProcessor.getOptionalProperty(FIELD);
if (field != null) {
- final String id = request.getOptionalProperty(OBJECT);
+ final String id = tagProcessor.getOptionalProperty(OBJECT);
final ObjectAdapter object = context.getMappedObjectOrResult(id);
final ObjectAssociation objectField = object.getSpecification().getAssociation(field);
if (!objectField.isOneToManyAssociation()) {
@@ -51,16 +51,16 @@ public class Collection extends AbstractElementProcessor {
IsisContext.getPersistenceSession().resolveField(object, objectField);
collection = objectField.get(object);
} else {
- final String id = request.getOptionalProperty(COLLECTION);
+ final String id = tagProcessor.getOptionalProperty(COLLECTION);
collection = context.getMappedObjectOrResult(id);
}
- final RepeatMarker marker = request.createMarker();
+ final RepeatMarker marker = tagProcessor.createMarker();
- final String variable = request.getOptionalProperty(ELEMENT_NAME);
- final String scopeName = request.getOptionalProperty(SCOPE);
- final Scope scope = RequestContext.scope(scopeName, Scope.REQUEST);
- final String rowClassesList = request.getOptionalProperty(ROW_CLASSES, ODD_ROW_CLASS + "|" + EVEN_ROW_CLASS);
+ final String variable = tagProcessor.getOptionalProperty(ELEMENT_NAME);
+ final String scopeName = tagProcessor.getOptionalProperty(SCOPE);
+ final Scope scope = Request.scope(scopeName, Scope.REQUEST);
+ final String rowClassesList = tagProcessor.getOptionalProperty(ROW_CLASSES, ODD_ROW_CLASS + "|" + EVEN_ROW_CLASS);
String[] rowClasses = new String[0];
if (rowClassesList != null) {
rowClasses = rowClassesList.split("[,|/]");
@@ -68,7 +68,7 @@ public class Collection extends AbstractElementProcessor {
final CollectionFacet facet = collection.getSpecification().getFacet(CollectionFacet.class);
if (facet.size(collection) == 0) {
- request.skipUntilClose();
+ tagProcessor.skipUntilClose();
} else {
final Iterator<ObjectAdapter> iterator = facet.iterator(collection);
int row = 0;
@@ -80,7 +80,7 @@ public class Collection extends AbstractElementProcessor {
}
context.addVariable(variable, context.mapObject(element, scope), scope);
marker.repeat();
- request.processUtilCloseTag();
+ tagProcessor.processUtilCloseTag();
row++;
}
}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Debug.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Debug.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Debug.java
index c1a5562..d6754ef 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Debug.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Debug.java
@@ -28,6 +28,7 @@ import org.apache.isis.applib.filter.Filter;
import org.apache.isis.core.commons.debug.DebugBuilder;
import org.apache.isis.core.commons.debug.DebugHtmlString;
import org.apache.isis.core.commons.debug.DebugString;
+import org.apache.isis.core.commons.debug.Debuggable;
import org.apache.isis.core.commons.debug.DebuggableWithTitle;
import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
import org.apache.isis.core.metamodel.facetapi.Facet;
@@ -42,33 +43,32 @@ import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
import org.apache.isis.core.metamodel.spec.feature.ObjectMember;
import org.apache.isis.core.metamodel.util.Dump;
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.context.RequestContext;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public class Debug extends AbstractElementProcessor {
- private final Dispatcher dispatcher;
+ private final Debuggable dispatcher;
- public Debug(final Dispatcher dispatcher) {
+ public Debug(final Debuggable dispatcher) {
this.dispatcher = dispatcher;
}
@Override
- public void process(final Request request) {
- if (request.getContext().isDebugDisabled()) {
+ public void process(final TagProcessor tagProcessor) {
+ if (tagProcessor.getContext().isDebugDisabled()) {
return;
}
- final String type = request.getOptionalProperty(TYPE);
+ final String type = tagProcessor.getOptionalProperty(TYPE);
- final boolean alwaysShow = request.isRequested("force", false);
+ final boolean alwaysShow = tagProcessor.isRequested("force", false);
if (type != null) {
if (type.equals("system")) {
- displaySystem(request);
+ displaySystem(tagProcessor);
} else if (type.equals("session")) {
- displaySession(request);
+ displaySession(tagProcessor);
} else if (type.equals("test")) {
final DebugBuilder debug = new DebugHtmlString();
debug.appendTitle("Title");
@@ -106,153 +106,153 @@ public class Debug extends AbstractElementProcessor {
debug.appendln("A lot of text etc.");
debug.endSection();
- request.appendHtml(debug.toString());
+ tagProcessor.appendHtml(debug.toString());
//request.appendHtml("<pre>" + debug.toString() + "</pre>");
debug.close();
} else if (type.equals("variables")) {
- displayVariables(request);
+ displayVariables(tagProcessor);
} else if (type.equals("dispatcher")) {
- displayDispatcher(request);
+ displayDispatcher(tagProcessor);
} else if (type.equals("context")) {
- displayContext(request);
+ displayContext(tagProcessor);
} else if (type.equals("specifications")) {
- listSpecifications(request);
+ listSpecifications(tagProcessor);
} else if (type.equals("specification-for")) {
- specificationFor(request);
+ specificationFor(tagProcessor);
} else if (type.equals("specification")) {
- specification(request);
+ specification(tagProcessor);
} else if (type.equals("specification-graph")) {
- specificationGraph(request);
+ specificationGraph(tagProcessor);
} else if (type.equals("object-graph")) {
- objectGraph(request);
+ objectGraph(tagProcessor);
} else if (type.equals("object")) {
- final String value = request.getOptionalProperty(VALUE);
- final RequestContext context = request.getContext();
+ final String value = tagProcessor.getOptionalProperty(VALUE);
+ final Request context = tagProcessor.getContext();
final ObjectAdapter object = context.getMappedObject(value);
final DebugString str = new DebugString();
Dump.adapter(object, str);
Dump.graph(object, IsisContext.getAuthenticationSession(), str);
- request.appendHtml("<h2>" + object.getSpecification().getFullIdentifier() + "</h2>");
- request.appendHtml("<pre class=\"debug\">" + str + "</pre>");
+ tagProcessor.appendHtml("<h2>" + object.getSpecification().getFullIdentifier() + "</h2>");
+ tagProcessor.appendHtml("<pre class=\"debug\">" + str + "</pre>");
}
}
- if (alwaysShow || request.getContext().getDebug() == RequestContext.Debug.ON) {
+ if (alwaysShow || tagProcessor.getContext().getDebug() == Request.Debug.ON) {
- final RequestContext context = request.getContext();
+ final Request context = tagProcessor.getContext();
- final String id = request.getOptionalProperty("object");
+ final String id = tagProcessor.getOptionalProperty("object");
if (id != null) {
final ObjectAdapter object = context.getMappedObject(id);
if (object instanceof DebuggableWithTitle) {
final DebugString debug = new DebugString();
((DebuggableWithTitle) object).debugData(debug);
- request.appendHtml("<pre class=\"debug\">" + debug + "</pre>");
+ tagProcessor.appendHtml("<pre class=\"debug\">" + debug + "</pre>");
} else {
- request.appendHtml(object.toString());
+ tagProcessor.appendHtml(object.toString());
}
}
- final String variable = request.getOptionalProperty("variable");
+ final String variable = tagProcessor.getOptionalProperty("variable");
if (variable != null) {
final Object object = context.getVariable(variable);
- request.appendHtml(variable + " => " + (object == null ? "null" : object.toString()));
+ tagProcessor.appendHtml(variable + " => " + (object == null ? "null" : object.toString()));
}
- final String list = request.getOptionalProperty("list");
+ final String list = tagProcessor.getOptionalProperty("list");
if (list != null) {
final DebugString debug = new DebugString();
context.append(debug, list);
- request.appendHtml(debug.toString());
+ tagProcessor.appendHtml(debug.toString());
}
- final String uri = request.getOptionalProperty("uri");
+ final String uri = tagProcessor.getOptionalProperty("uri");
if (uri != null) {
- request.appendHtml("<pre class=\"debug\">");
- request.appendHtml(context.getUri());
- request.appendHtml("</pre>");
+ tagProcessor.appendHtml("<pre class=\"debug\">");
+ tagProcessor.appendHtml(context.getUri());
+ tagProcessor.appendHtml("</pre>");
}
}
}
- protected void objectGraph(final Request request) {
- final String id = request.getOptionalProperty(VALUE);
- final ObjectAdapter object = request.getContext().getMappedObjectOrResult(id);
- request.appendHtml("<h1>Object Graph - " + object + "</h1>");
- request.appendHtml("<pre>");
+ protected void objectGraph(final TagProcessor tagProcessor) {
+ final String id = tagProcessor.getOptionalProperty(VALUE);
+ final ObjectAdapter object = tagProcessor.getContext().getMappedObjectOrResult(id);
+ tagProcessor.appendHtml("<h1>Object Graph - " + object + "</h1>");
+ tagProcessor.appendHtml("<pre>");
final DebugBuilder debug = new DebugString();
Dump.graph(object, null, debug);
- request.appendHtml(debug.toString());
- request.appendHtml("</pre>");
+ tagProcessor.appendHtml(debug.toString());
+ tagProcessor.appendHtml("</pre>");
}
- protected void specificationFor(final Request request) {
- final String id = request.getOptionalProperty(VALUE);
- final ObjectAdapter object = request.getContext().getMappedObjectOrResult(id);
- specification(request, object.getSpecification());
+ protected void specificationFor(final TagProcessor tagProcessor) {
+ final String id = tagProcessor.getOptionalProperty(VALUE);
+ final ObjectAdapter object = tagProcessor.getContext().getMappedObjectOrResult(id);
+ specification(tagProcessor, object.getSpecification());
}
- protected void specification(final Request request) {
- final String name = request.getOptionalProperty(VALUE);
+ protected void specification(final TagProcessor tagProcessor) {
+ final String name = tagProcessor.getOptionalProperty(VALUE);
final ObjectSpecification spec = getSpecificationLoader().loadSpecification(name);
- specification(request, spec);
+ specification(tagProcessor, spec);
}
- private void specification(final Request request, final ObjectSpecification spec) {
- request.appendHtml("<h1>Specification - " + spec.getFullIdentifier() + "</h1>");
- request.appendHtml("<p><a href=\"./debug.shtml?type=specification-graph&value=" + spec.getFullIdentifier() + "\">Specification Graph</a></p>");
+ private void specification(final TagProcessor tagProcessor, final ObjectSpecification spec) {
+ tagProcessor.appendHtml("<h1>Specification - " + spec.getFullIdentifier() + "</h1>");
+ tagProcessor.appendHtml("<p><a href=\"./debug.shtml?type=specification-graph&value=" + spec.getFullIdentifier() + "\">Specification Graph</a></p>");
final DebugBuilder debug = new DebugHtmlString();
specification(spec, debug);
- request.appendHtml(debug.toString());
+ tagProcessor.appendHtml(debug.toString());
}
- protected void specificationGraph(final Request request) {
- final String name = request.getOptionalProperty(VALUE);
+ protected void specificationGraph(final TagProcessor tagProcessor) {
+ final String name = tagProcessor.getOptionalProperty(VALUE);
final ObjectSpecification spec = getSpecificationLoader().loadSpecification(name);
- request.appendHtml("<h1>Specification Graph - " + spec.getFullIdentifier() + "</h1>");
- request.appendHtml("<p><a href=\"./debug.shtml?type=specification&value=" + spec.getFullIdentifier() + "\">Full Specification</a></p>");
- request.appendHtml("<pre>");
+ tagProcessor.appendHtml("<h1>Specification Graph - " + spec.getFullIdentifier() + "</h1>");
+ tagProcessor.appendHtml("<p><a href=\"./debug.shtml?type=specification&value=" + spec.getFullIdentifier() + "\">Full Specification</a></p>");
+ tagProcessor.appendHtml("<pre>");
final DebugBuilder debug = new DebugString();
debug.appendln(spec.getFullIdentifier());
debug.indent();
specificationGraph(spec, debug, new ArrayList<ObjectSpecification>());
debug.unindent();
- request.appendHtml(debug.toString());
- request.appendHtml("</pre>");
+ tagProcessor.appendHtml(debug.toString());
+ tagProcessor.appendHtml("</pre>");
}
- private void displayContext(final Request request) {
- request.appendHtml("<h1>Context</h1>");
+ private void displayContext(final TagProcessor tagProcessor) {
+ tagProcessor.appendHtml("<h1>Context</h1>");
final DebugHtmlString debugString = new DebugHtmlString();
- request.getContext().append(debugString);
+ tagProcessor.getContext().append(debugString);
debugString.close();
- request.appendHtml(debugString.toString());
+ tagProcessor.appendHtml(debugString.toString());
}
- private void displayDispatcher(final Request request) {
- request.appendHtml("<h1>Dispatcher</h1>");
+ private void displayDispatcher(final TagProcessor tagProcessor) {
+ tagProcessor.appendHtml("<h1>Dispatcher</h1>");
final DebugHtmlString debugString = new DebugHtmlString();
- dispatcher.debug(debugString);
+ dispatcher.debugData(debugString);
debugString.close();
- request.appendHtml(debugString.toString());
+ tagProcessor.appendHtml(debugString.toString());
}
- protected void displayVariables(final Request request) {
- request.appendHtml("<h1>Variables</h1>");
+ protected void displayVariables(final TagProcessor tagProcessor) {
+ tagProcessor.appendHtml("<h1>Variables</h1>");
final DebugHtmlString debug = new DebugHtmlString();
- final RequestContext context = request.getContext();
+ final Request context = tagProcessor.getContext();
context.append(debug, "variables");
debug.close();
- request.appendHtml(debug.toString());
+ tagProcessor.appendHtml(debug.toString());
}
- protected void displaySystem(final Request request) {
- request.appendHtml("<h1>System</h1>");
+ protected void displaySystem(final TagProcessor tagProcessor) {
+ tagProcessor.appendHtml("<h1>System</h1>");
final DebuggableWithTitle[] debugItems = IsisContext.debugSystem();
for (final DebuggableWithTitle debug : debugItems) {
final DebugHtmlString debugBuffer = new DebugHtmlString();
@@ -260,12 +260,12 @@ public class Debug extends AbstractElementProcessor {
debug.debugData(debugBuffer);
debugBuffer.endSection();
debugBuffer.close();
- request.appendHtml(debugBuffer.toString());
+ tagProcessor.appendHtml(debugBuffer.toString());
}
}
- protected void displaySession(final Request request) {
- request.appendHtml("<h1>Session</h1>");
+ protected void displaySession(final TagProcessor tagProcessor) {
+ tagProcessor.appendHtml("<h1>Session</h1>");
final DebuggableWithTitle[] debugItems = IsisContext.debugSession();
for (final DebuggableWithTitle debug : debugItems) {
final DebugHtmlString debugBuffer = new DebugHtmlString();
@@ -273,12 +273,12 @@ public class Debug extends AbstractElementProcessor {
debug.debugData(debugBuffer);
debugBuffer.endSection();
debugBuffer.close();
- request.appendHtml(debugBuffer.toString());
+ tagProcessor.appendHtml(debugBuffer.toString());
}
}
- protected void listSpecifications(final Request request) {
- request.appendHtml("<h1>Specifications</h1>");
+ protected void listSpecifications(final TagProcessor tagProcessor) {
+ tagProcessor.appendHtml("<h1>Specifications</h1>");
final List<ObjectSpecification> fullIdentifierList = new ArrayList<ObjectSpecification>(getSpecificationLoader().allSpecifications());
Collections.sort(fullIdentifierList, ObjectSpecification.COMPARATOR_SHORT_IDENTIFIER_IGNORE_CASE);
final DebugHtmlString debug = new DebugHtmlString();
@@ -287,7 +287,7 @@ public class Debug extends AbstractElementProcessor {
debug.appendln(name, specificationLink(spec));
}
debug.close();
- request.appendHtml(debug.toString());
+ tagProcessor.appendHtml(debug.toString());
}
private String specificationLink(final ObjectSpecification specification) {
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/DebugAccessCheck.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/DebugAccessCheck.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/DebugAccessCheck.java
index 796faf0..f48fcad 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/DebugAccessCheck.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/DebugAccessCheck.java
@@ -19,15 +19,15 @@
package org.apache.isis.viewer.scimpi.dispatcher.view.debug;
-import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.ForbiddenException;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
+import org.apache.isis.viewer.scimpi.ForbiddenException;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public class DebugAccessCheck extends AbstractElementProcessor {
@Override
- public void process(final Request request) {
- if (request.getContext().isDebugDisabled()) {
+ public void process(final TagProcessor tagProcessor) {
+ if (tagProcessor.getContext().isDebugDisabled()) {
throw new ForbiddenException("Debug is disabled");
}
}
[14/24] Restructuring Scimpi to remove dependencies and enable easier
testing.
Posted by rm...@apache.org.
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/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 1572197..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/AbstractConditionalBlock.java
+++ /dev/null
@@ -1,562 +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.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.collections.modify.CollectionFacet;
-import org.apache.isis.core.metamodel.facets.typeof.TypeOfFacet;
-import org.apache.isis.core.metamodel.spec.ActionType;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
-import org.apache.isis.core.metamodel.spec.feature.ObjectActionContainer.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.ScimpiException;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.util.MethodsUtils;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
-
-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 TagProcessor tagProcessor) {
- final String id = tagProcessor.getOptionalProperty(OBJECT);
-
- boolean checkMade = false;
- boolean allConditionsMet = true;
-
- final String[] propertyNames = tagProcessor.getAttributes().getPropertyNames(new String[] { "object", "collection" });
- for (final String propertyName : propertyNames) {
- boolean result;
- if (propertyName.equals("set")) {
- result = tagProcessor.isPropertySet("set");
- } else {
- final Test test = tests.get(propertyName);
- if (test == null) {
- throw new ScimpiException("No such test: " + propertyName);
- }
- final String attributeValue = tagProcessor.getOptionalProperty(propertyName, false);
- result = test.test(tagProcessor, 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 = tagProcessor.getOptionalProperty("persistent");
- if (persistent != null) {
- final ObjectAdapter object = tagProcessor.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 (tagProcessor.isPropertySpecified("empty")) {
- if (tagProcessor.isPropertySet("empty")) {
- final String collection = tagProcessor.getOptionalProperty("empty");
- if (collection != null) {
- final ObjectAdapter object = tagProcessor.getContext().getMappedObjectOrResult(collection);
- final CollectionFacet facet = object.getSpecification().getFacet(CollectionFacet.class);
- checkMade = true;
- allConditionsMet &= facet.size(object) == 0;
- }
- } else {
- checkMade = true;
- allConditionsMet &= true;
- }
- }
-
- if (tagProcessor.isPropertySpecified("set")) {
- final boolean valuePresent = tagProcessor.isPropertySet("set");
- checkMade = true;
- allConditionsMet &= valuePresent;
- }
-
- if (checkMade) {
- processTags(allConditionsMet, tagProcessor);
- } else {
- throw new ScimpiException("No condition in " + getName());
- }
- }
-
- protected abstract void processTags(boolean isSet, TagProcessor tagProcessor);
-
-}
-
-abstract class Test {
- String name;
- boolean negateResult;
-
- abstract boolean test(TagProcessor tagProcessor, 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 TagProcessor tagProcessor, final String attributeName, final String targetId) {
- Object variable = tagProcessor.getContext().getVariable(attributeName);
- if (variable instanceof String && ((String) variable).equals("")) {
- return false;
- }
- return variable != null;
- }
-}
-
-class TestVariableTrue extends Test {
- @Override
- boolean test(final TagProcessor tagProcessor, final String attributeName, final String targetId) {
- final Object variable = tagProcessor.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 TagProcessor tagProcessor, final String attributeName, final String targetId) {
- final ObjectAdapter object = tagProcessor.getContext().getMappedObjectOrResult(attributeName);
- return object.representsPersistent();
- }
-}
-
-class TestObjectType extends TestObjectPersistent {
- @Override
- boolean test(final TagProcessor tagProcessor, final String attributeName, final String targetId) {
- final ObjectAdapter object = MethodsUtils.findObject(tagProcessor.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 TagProcessor tagProcessor, final String attributeName, final String targetId) {
- final ObjectAdapter object = MethodsUtils.findObject(tagProcessor.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 TagProcessor tagProcessor, final String attributeName, final String targetId) {
- final ObjectAdapter object = MethodsUtils.findObject(tagProcessor.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 TagProcessor tagProcessor, final String attributeName, final String targetId) {
- final ObjectAdapter object = MethodsUtils.findObject(tagProcessor.getContext(), targetId);
- final List<? extends ObjectAction> objectActions = object.getSpecification().getObjectActions(ActionType.USER, Contributed.INCLUDED);
- 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 TagProcessor tagProcessor, final String attributeName, final String targetId) {
- final ObjectAdapter object = MethodsUtils.findObject(tagProcessor.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 TagProcessor tagProcessor, final String attributeName, final String targetId) {
- final ObjectAdapter object = MethodsUtils.findObject(tagProcessor.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 TagProcessor tagProcessor, final String attributeName, final String targetId) {
- final ObjectAdapter object = MethodsUtils.findObject(tagProcessor.getContext(), targetId);
- final List<? extends ObjectAssociation> objectFields = object.getSpecification().getAssociations();
- 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 TagProcessor tagProcessor, final String attributeName, final String targetId) {
- final ObjectAdapter object = MethodsUtils.findObject(tagProcessor.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 TagProcessor tagProcessor, final String attributeName, final String targetId) {
- final ObjectAdapter object = MethodsUtils.findObject(tagProcessor.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 TagProcessor tagProcessor, final String attributeName, final String targetId) {
- final ObjectAdapter object = MethodsUtils.findObject(tagProcessor.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 TagProcessor tagProcessor, final String attributeName, final String targetId) {
- final ObjectAdapter object = MethodsUtils.findObject(tagProcessor.getContext(), targetId);
- final ObjectAssociation objectField = findProperty(attributeName, object);
- IsisContext.getPersistenceSession().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(TagProcessor tagProcessor, 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(tagProcessor.getContext(), targetId);
- final ObjectAssociation objectField = findProperty(fieldName, object);
- IsisContext.getPersistenceSession().resolveField(object, objectField);
- final ObjectAdapter fld = objectField.get(object);
-
- // TODO test for reference or value
- final ObjectAdapter object2 = MethodsUtils.findObject(tagProcessor.getContext(), fieldValue);
-
- if (fld == object2) {
- return true;
- }
- return false;
- }
-
-}
-
-class TestHasRole extends Test {
- @Override
- boolean test(final TagProcessor tagProcessor, 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 TagProcessor tagProcessor, final String attributeName, final String targetId) {
- final boolean valuePresent = tagProcessor.isPropertySet("set");
- return valuePresent;
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/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 b5777a4..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.ForbiddenException;
-import org.apache.isis.viewer.scimpi.Names;
-import org.apache.isis.viewer.scimpi.ScimpiException;
-import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
-import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.util.MethodsUtils;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
-
-public abstract class AbstractLink extends AbstractElementProcessor {
-
- @Override
- public void process(final TagProcessor tagProcessor) {
- final String title = tagProcessor.getOptionalProperty(FORM_TITLE);
- final String name = tagProcessor.getOptionalProperty(NAME);
- final boolean showAsButton = tagProcessor.isRequested("show-as-button", false);
- final String linkClass = tagProcessor.getOptionalProperty(CLASS, showAsButton ? "button" : defaultLinkClass());
- final String containerClass = tagProcessor.getOptionalProperty(CONTAINER_CLASS, "action");
- final String object = tagProcessor.getOptionalProperty(OBJECT);
- final Request context = tagProcessor.getContext();
- String objectId = object != null ? object : (String) context.getVariable(Names.RESULT);
- ObjectAdapter adapter = MethodsUtils.findObject(context, objectId);
-
- // REVIEW this is common used code
- final String fieldName = tagProcessor.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);
- }
- IsisContext.getPersistenceSession().resolveField(adapter, field);
- adapter = field.get(adapter);
- if (adapter != null) {
- objectId = context.mapObject(adapter, Scope.INTERACTION);
- }
- }
-
- if (adapter != null && valid(tagProcessor, adapter)) {
- final String variable = tagProcessor.getOptionalProperty("param-name", Names.RESULT);
- final String variableSegment = variable + "=" + objectId;
-
- String view = tagProcessor.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(tagProcessor);
- additionalSegment = additionalSegment == null ? "" : "&" + additionalSegment;
- if (showAsButton) {
- tagProcessor.appendHtml("<div class=\"" + containerClass + "\">");
- }
- tagProcessor.appendHtml("<a" + classSegment + titleSegment + " href=\"" + view + "?" + variableSegment + context.encodedInteractionParameters() + additionalSegment + "\">");
- tagProcessor.pushNewBuffer();
- tagProcessor.processUtilCloseTag();
- final String buffer = tagProcessor.popBuffer();
- if (buffer.trim().length() > 0) {
- tagProcessor.appendHtml(buffer);
- } else {
- tagProcessor.appendAsHtmlEncoded(linkLabel(name, adapter));
- }
- tagProcessor.appendHtml("</a>");
- if (showAsButton) {
- tagProcessor.appendHtml("</div>");
- }
- } else {
- tagProcessor.skipUntilClose();
- }
- }
-
- private String defaultLinkClass() {
- return "action";
- }
-
- protected abstract String linkLabel(String name, ObjectAdapter object);
-
- protected String additionalParameters(final TagProcessor tagProcessor) {
- return null;
- }
-
- protected abstract boolean valid(TagProcessor tagProcessor, ObjectAdapter adapter);
-
- protected abstract String defaultView();
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/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 8b7f645..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.context.Request.Scope;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor.RepeatMarker;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
-
-public class BlockDefine extends AbstractElementProcessor {
-
- @Override
- public String getName() {
- return "block";
- }
-
- @Override
- public void process(final TagProcessor tagProcessor) {
- final String name = tagProcessor.getOptionalProperty(NAME, "unamed");
- final RepeatMarker start = tagProcessor.createMarker();
- tagProcessor.skipUntilClose();
- tagProcessor.getContext().addVariable("_block-" + name, start, Scope.REQUEST);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/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 014daf2..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.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor.RepeatMarker;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
-
-public class BlockUse extends AbstractElementProcessor {
-
- @Override
- public String getName() {
- return "use-block";
- }
-
- @Override
- public void process(final TagProcessor tagProcessor) {
- final String name = tagProcessor.getOptionalProperty(NAME, "unamed");
- tagProcessor.closeEmpty();
- final RepeatMarker end = tagProcessor.createMarker();
-
- final RepeatMarker marker = (RepeatMarker) tagProcessor.getContext().getVariable("_block-" + name);
- marker.repeat();
-
- tagProcessor.processUtilCloseTag();
- end.repeat();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/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 b075bfc..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.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
-
-public class Commit extends AbstractElementProcessor {
-
- @Override
- public String getName() {
- return "commit";
- }
-
- @Override
- public void process(final TagProcessor tagProcessor) {
- // 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/7700b437/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 9374ebf..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.processor.ElementProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-
-public class ContentTag implements ElementProcessor {
-
- @Override
- public String getName() {
- return "content";
- }
-
- @Override
- public void process(final TagProcessor tagProcessor) {
- tagProcessor.appendHtml("<!-- apply content -->");
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/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 0799993..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.context.Request;
-import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
-
-public class CookieValue extends AbstractElementProcessor {
-
- @Override
- public void process(final TagProcessor tagProcessor) {
- String name = tagProcessor.getRequiredProperty(NAME);
- String resultName = tagProcessor.getOptionalProperty(RESULT_NAME, name);
- final String scopeName = tagProcessor.getOptionalProperty(SCOPE);
- final Scope scope = Request.scope(scopeName, Scope.REQUEST);
-
- String cookieString = tagProcessor.getContext().getCookie(name);
-
- tagProcessor.appendDebug(" " + resultName + " (" + scope + ") set to " + cookieString + " from cookie " + name);
- tagProcessor.getContext().addVariable(resultName, cookieString, scope);
- }
-
- @Override
- public String getName() {
- return "cookie-value";
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/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 1914385..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.context.Request;
-import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
-
-public class DefaultValue extends AbstractElementProcessor {
-
- @Override
- public void process(final TagProcessor tagProcessor) {
- // String sourceObjectId = objectOrResult(request);
- final String variableName = tagProcessor.getRequiredProperty(NAME);
- final String defaultValue = tagProcessor.getOptionalProperty(VALUE);
- final String scopeName = tagProcessor.getOptionalProperty(SCOPE);
- final Scope scope = Request.scope(scopeName, Scope.REQUEST);
-
- final Request context = tagProcessor.getContext();
- final Object currentValue = context.getVariable(variableName);
- if (currentValue == null) {
- tagProcessor.appendDebug(" " + variableName + " set to " + defaultValue + " (" + scope + ")");
- context.addVariable(variableName, defaultValue, scope);
- } else {
- tagProcessor.appendDebug(" " + variableName + " alreadt set to " + currentValue);
- }
- }
-
- @Override
- public String getName() {
- return "default";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/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 037d560..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.ObjectAssociation;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAssociationFilters;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.viewer.scimpi.Names;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-
-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 TagProcessor tagProcessor, final ObjectAdapter adapter) {
- final ObjectSpecification specification = adapter.getSpecification();
- final AuthenticationSession session = IsisContext.getAuthenticationSession();
- final List<ObjectAssociation> visibleFields = specification.getAssociations(ObjectAssociationFilters.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 Names.GENERIC + Names.EDIT + "." + Names.EXTENSION;
- }
-
- @Override
- public String getName() {
- return "edit-link";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/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 a5f15c8..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.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
-
-public class EndSession extends AbstractElementProcessor {
-
- @Override
- public void process(final TagProcessor tagProcessor) {
- tagProcessor.getContext().endHttpSession();
- }
-
- @Override
- public String getName() {
- return "end-session";
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/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 3e0150f..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.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
-
-public class Forward extends AbstractElementProcessor {
-
- @Override
- public String getName() {
- return "forward";
- }
-
- @Override
- public void process(final TagProcessor tagProcessor) {
- final String view = tagProcessor.getRequiredProperty(VIEW);
- tagProcessor.getContext().forward(view);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/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 414436b..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.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
-
-public class GetCookie extends AbstractElementProcessor {
-
- @Override
- public void process(final TagProcessor tagProcessor) {
- final String name = tagProcessor.getRequiredProperty("name");
- final String cookie = tagProcessor.getContext().getCookie(name);
-
- tagProcessor.appendHtml(cookie);
- }
-
- @Override
- public String getName() {
- return "get-cookie";
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/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 cbcaa55..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.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
-
-public class Import extends AbstractElementProcessor {
-
- @Override
- public void process(final TagProcessor tagProcessor) {
- tagProcessor.appendHtml("<!-- " + " import " + tagProcessor.getOptionalProperty("file") + " -->");
- }
-
- @Override
- public String getName() {
- return "import";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/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 520af0c..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/InitializeFromCookie.java
+++ /dev/null
@@ -1,81 +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.Names;
-import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
-import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
-
-public class InitializeFromCookie extends AbstractElementProcessor {
- private static final String SEVEN_DAYS = Integer.toString(60 * 24 * 7);
-
- @Override
- public void process(final TagProcessor tagProcessor) {
- final String name = tagProcessor.getRequiredProperty(NAME);
-
- final Request context = tagProcessor.getContext();
- if (context.getVariable(name) != null) {
- tagProcessor.skipUntilClose();
- } else {
- final String scopeName = tagProcessor.getOptionalProperty(SCOPE);
- final Scope scope = Request.scope(scopeName, Scope.SESSION);
-
- final String cookieName = tagProcessor.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) {
- tagProcessor.skipUntilClose();
- context.addVariable(name, cookieValue, scope);
- } else {
- final String expiresString = tagProcessor.getOptionalProperty("expires", SEVEN_DAYS);
- tagProcessor.pushNewBuffer();
- tagProcessor.processUtilCloseTag();
- tagProcessor.popBuffer();
- final String id = (String) context.getVariable(Names.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/7700b437/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 f3ba3bc..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/InitializeFromResult.java
+++ /dev/null
@@ -1,78 +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.Names;
-import org.apache.isis.viewer.scimpi.ScimpiException;
-import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
-import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
-
-public class InitializeFromResult extends AbstractElementProcessor {
-
- @Override
- public void process(final TagProcessor tagProcessor) {
- disallowSourceAndDefault(tagProcessor);
- final String sourceObjectId = objectOrResult(tagProcessor);
- final Class<?> cls = forClass(tagProcessor);
- final String variableName = tagProcessor.getRequiredProperty(NAME);
- final String defaultObjectId = tagProcessor.getOptionalProperty(DEFAULT);
- final String scopeName = tagProcessor.getOptionalProperty(SCOPE);
- final Scope scope = Request.scope(scopeName, Scope.REQUEST);
-
- final Request context = tagProcessor.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) {
- tagProcessor.appendDebug(" " + variableName + " set to " + sourceObjectId + " (" + scope + ")");
- context.addVariable(variableName, sourceObjectId, scope);
- } else {
- tagProcessor.appendDebug(" " + variableName + " set to " + sourceObjectId + " (" + scope + ")");
- if (defaultObjectId != null) {
- context.addVariable(variableName, defaultObjectId, scope);
- }
- context.changeScope(variableName, scope);
- }
- }
-
- private String objectOrResult(final TagProcessor tagProcessor) {
- final String sourceObjectId = tagProcessor.getOptionalProperty(OBJECT);
- if (sourceObjectId == null) {
- return (String) tagProcessor.getContext().getVariable(Names.RESULT);
- } else {
- return sourceObjectId;
- }
- }
-
- private void disallowSourceAndDefault(final TagProcessor tagProcessor) {
- if (tagProcessor.getOptionalProperty(DEFAULT) != null && tagProcessor.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/7700b437/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 fe69d9d..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.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
-
-/**
- * Displays the localization data for the current user.
- */
-public class Localization extends AbstractElementProcessor {
-
- @Override
- public void process(final TagProcessor tagProcessor) {
- tagProcessor.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();
-
- tagProcessor.appendAsHtmlEncoded(country + ", " + timeZone);
- } else {
- tagProcessor.appendAsHtmlEncoded("No localization data!");
- }
-
- Locale locale = Locale.getDefault();
- String country = locale.getDisplayName();
- // country = locale.toString();
- String timeZone = TimeZone.getDefault().getDisplayName();
-
- tagProcessor.appendAsHtmlEncoded("\n (Default " + country + ", " + timeZone +")");
-
- }
-
- @Override
- public String getName() {
- return "alpha-localization";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Mark.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Mark.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Mark.java
deleted file mode 100644
index 97660d2..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Mark.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.viewer.scimpi.dispatcher.view.simple;
-
-import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
-import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
-
-public class Mark extends AbstractElementProcessor {
-
- // TODO the return points should be pushed on to a stack so that there is
- // traceable history.
- @Override
- public void process(final TagProcessor tagProcessor) {
- // String name = request.getOptionalProperty(NAME);
- final Request context = tagProcessor.getContext();
- context.addVariable("_return-to", context.getUri(), Scope.SESSION);
- }
-
- @Override
- public String getName() {
- return "mark";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/NewActionLink.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/NewActionLink.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/NewActionLink.java
deleted file mode 100644
index edd0522..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/NewActionLink.java
+++ /dev/null
@@ -1,62 +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.ObjectAction;
-import org.apache.isis.viewer.scimpi.Names;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.util.MethodsUtils;
-
-public class NewActionLink extends AbstractLink {
-
- // REVIEW: confirm this rendering context
- private final Where where = Where.OBJECT_FORMS;
-
- @Override
- protected boolean valid(final TagProcessor tagProcessor, final ObjectAdapter object) {
- final String method = tagProcessor.getRequiredProperty(METHOD);
- final ObjectAction action = MethodsUtils.findAction(object, method);
- return MethodsUtils.isVisibleAndUsable(object, action, where);
- }
-
- @Override
- protected String linkLabel(final String name, final ObjectAdapter object) {
- return "run";
- }
-
- @Override
- protected String defaultView() {
- return "_generic_action." + Names.EXTENSION;
- }
-
- @Override
- protected String additionalParameters(final TagProcessor tagProcessor) {
- final String method = tagProcessor.getRequiredProperty(METHOD);
- return "method=" + method;
- }
-
- @Override
- public String getName() {
- return "new-action-link";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/ObjectLink.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/ObjectLink.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/ObjectLink.java
deleted file mode 100644
index 54e59ec..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/ObjectLink.java
+++ /dev/null
@@ -1,68 +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.Where;
-import org.apache.isis.core.commons.authentication.AuthenticationSession;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAssociationFilters;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.viewer.scimpi.Names;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-
-public class ObjectLink 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 TagProcessor tagProcessor, final ObjectAdapter object) {
- final AuthenticationSession session = IsisContext.getAuthenticationSession();
- final List<ObjectAssociation> visibleFields = object.getSpecification().getAssociations(ObjectAssociationFilters.dynamicallyVisible(session, object, where));
- return visibleFields.size() > 0;
- }
-
- @Override
- protected String linkLabel(final String name, final ObjectAdapter object) {
- if (name == null) {
- return object.titleString();
- } else {
- return name;
- }
- }
-
- @Override
- protected String defaultView() {
- return Names.GENERIC + "." + Names.EXTENSION;
- }
-
- @Override
- public String getName() {
- return "object-link";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/PageTitle.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/PageTitle.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/PageTitle.java
deleted file mode 100644
index 65443a3..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/PageTitle.java
+++ /dev/null
@@ -1,35 +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.context.Request.Scope;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-
-public class PageTitle extends Variable {
- @Override
- public void process(final TagProcessor tagProcessor) {
- process(tagProcessor, "title", null, null, false, Scope.REQUEST);
- }
-
- @Override
- public String getName() {
- return "page-title";
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Redirect.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Redirect.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Redirect.java
deleted file mode 100644
index 9b72f93..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Redirect.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.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
-
-public class Redirect extends AbstractElementProcessor {
-
- @Override
- public String getName() {
- return "redirect";
- }
-
- @Override
- public void process(final TagProcessor tagProcessor) {
- final String view = tagProcessor.getRequiredProperty(VIEW);
- tagProcessor.getContext().redirectTo(view);
- }
-
-}
[04/24] Restructuring Scimpi to remove dependencies and enable easier
testing.
Posted by rm...@apache.org.
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/ListView.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/ListView.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/ListView.java
index e2e6cdb..cf957fb 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/ListView.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/ListView.java
@@ -24,10 +24,11 @@ import java.util.Iterator;
import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacet;
import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
-import org.apache.isis.viewer.scimpi.dispatcher.AbstractObjectProcessor;
-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.Names;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractObjectProcessor;
import org.apache.isis.viewer.scimpi.dispatcher.view.field.LinkedObject;
public class ListView extends AbstractObjectProcessor {
@@ -38,24 +39,24 @@ public class ListView extends AbstractObjectProcessor {
}
@Override
- public void process(final Request request, final ObjectAdapter object) {
- final String linkRowView = request.getOptionalProperty(LINK_VIEW);
- final String linkObjectName = request.getOptionalProperty(ELEMENT_NAME, RequestContext.RESULT);
- final String linkObjectScope = request.getOptionalProperty(SCOPE, Scope.INTERACTION.toString());
+ public void process(final TagProcessor tagProcessor, final ObjectAdapter object) {
+ final String linkRowView = tagProcessor.getOptionalProperty(LINK_VIEW);
+ final String linkObjectName = tagProcessor.getOptionalProperty(ELEMENT_NAME, Names.RESULT);
+ final String linkObjectScope = tagProcessor.getOptionalProperty(SCOPE, Scope.INTERACTION.toString());
LinkedObject linkedRow = null;
if (linkRowView != null) {
- linkedRow = new LinkedObject(linkObjectName, linkObjectScope, request.getContext().fullUriPath(linkRowView));
+ linkedRow = new LinkedObject(linkObjectName, linkObjectScope, tagProcessor.getContext().fullUriPath(linkRowView));
}
- final String bulletType = request.getOptionalProperty("type");
- write(request, object, linkedRow, bulletType);
+ final String bulletType = tagProcessor.getOptionalProperty("type");
+ write(tagProcessor, object, linkedRow, bulletType);
}
- public static void write(final Request request, final ObjectAdapter collection, final LinkedObject linkRow, final String bulletType) {
+ public static void write(final TagProcessor tagProcessor, final ObjectAdapter collection, final LinkedObject linkRow, final String bulletType) {
if (bulletType == null) {
- request.appendHtml("<ol>");
+ tagProcessor.appendHtml("<ol>");
} else {
- request.appendHtml("<ul type=\"" + bulletType + "\">");
+ tagProcessor.appendHtml("<ul type=\"" + bulletType + "\">");
}
final CollectionFacet facet = collection.getSpecification().getFacet(CollectionFacet.class);
@@ -63,23 +64,23 @@ public class ListView extends AbstractObjectProcessor {
while (iterator.hasNext()) {
final ObjectAdapter element = iterator.next();
- request.appendHtml("<li>");
+ tagProcessor.appendHtml("<li>");
if (linkRow != null) {
- final Scope scope = linkRow == null ? Scope.INTERACTION : RequestContext.scope(linkRow.getScope());
- final String rowId = request.getContext().mapObject(element, scope);
- request.appendHtml("<a class=\"item-select\" href=\"" + linkRow.getForwardView() + "?" + linkRow.getVariable() + "=" + rowId + "\">");
+ final Scope scope = linkRow == null ? Scope.INTERACTION : Request.scope(linkRow.getScope());
+ final String rowId = tagProcessor.getContext().mapObject(element, scope);
+ tagProcessor.appendHtml("<a class=\"item-select\" href=\"" + linkRow.getForwardView() + "?" + linkRow.getVariable() + "=" + rowId + "\">");
}
- request.appendAsHtmlEncoded(element.titleString());
+ tagProcessor.appendAsHtmlEncoded(element.titleString());
if (linkRow != null) {
- request.appendHtml("</a>");
+ tagProcessor.appendHtml("</a>");
}
- request.appendHtml("</li>\n");
+ tagProcessor.appendHtml("</li>\n");
}
if (bulletType == null) {
- request.appendHtml("</ol>");
+ tagProcessor.appendHtml("</ol>");
} else {
- request.appendHtml("</ul>");
+ tagProcessor.appendHtml("</ul>");
}
}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/LongFormView.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/LongFormView.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/LongFormView.java
index 5bbb44f..a157858 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/LongFormView.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/LongFormView.java
@@ -26,18 +26,18 @@ import org.apache.isis.core.metamodel.spec.ObjectSpecification;
import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
import org.apache.isis.core.metamodel.spec.feature.ObjectAssociationFilters;
import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
import org.apache.isis.viewer.scimpi.dispatcher.view.display.TableView.SimpleTableBuilder;
import org.apache.isis.viewer.scimpi.dispatcher.view.field.LinkedObject;
public class LongFormView extends AbstractFormView {
@Override
- protected void addField(final Request request, final ObjectAdapter object, final ObjectAssociation field, final LinkedObject linkedObject, final boolean showIcons) {
+ protected void addField(final TagProcessor tagProcessor, final ObjectAdapter object, final ObjectAssociation field, final LinkedObject linkedObject, final boolean showIcons) {
if (field.isOneToManyAssociation()) {
- final String noColumnsString = request.getOptionalProperty("no-columns", "3");
- final String tableClass = request.getOptionalProperty("table-class");
- final String rowClassesList = request.getOptionalProperty("row-classes", ODD_ROW_CLASS + "|" + EVEN_ROW_CLASS);
+ final String noColumnsString = tagProcessor.getOptionalProperty("no-columns", "3");
+ final String tableClass = tagProcessor.getOptionalProperty("table-class");
+ final String rowClassesList = tagProcessor.getOptionalProperty("row-classes", ODD_ROW_CLASS + "|" + EVEN_ROW_CLASS);
String[] rowClasses = new String[0];
if (rowClassesList != null) {
rowClasses = rowClassesList.split("[,|/]");
@@ -71,9 +71,9 @@ public class LongFormView extends AbstractFormView {
final TableContentWriter rowBuilder =new SimpleTableBuilder(object.titleString(), true, false, "", noColumns, headers, fields, false,
showIcons, false, false, false, field.getName(), linkedFields, null);
- TableView.write(request, collection, summary, rowBuilder, null, tableClass, rowClasses);
+ TableView.write(tagProcessor, collection, summary, rowBuilder, null, tableClass, rowClasses);
} else {
- super.addField(request, object, field, linkedObject, showIcons);
+ super.addField(tagProcessor, object, field, linkedObject, showIcons);
}
}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/Messages.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/Messages.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/Messages.java
index a6c8213..21fae12 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/Messages.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/Messages.java
@@ -23,20 +23,20 @@ import java.util.List;
import org.apache.isis.core.runtime.system.context.IsisContext;
import org.apache.isis.core.runtime.system.transaction.MessageBroker;
-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.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public class Messages extends AbstractElementProcessor {
@Override
- public void process(final Request request) {
- final String cls = request.getOptionalProperty(CLASS);
+ public void process(final TagProcessor tagProcessor) {
+ final String cls = tagProcessor.getOptionalProperty(CLASS);
final StringBuffer buffer = new StringBuffer();
write(cls, buffer);
if (buffer.length() > 0) {
- request.appendHtml("<div class=\"feedback\">");
- request.appendHtml(buffer.toString());
- request.appendHtml("</div>");
+ tagProcessor.appendHtml("<div class=\"feedback\">");
+ tagProcessor.appendHtml(buffer.toString());
+ tagProcessor.appendHtml("</div>");
}
}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/SelectedObject.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/SelectedObject.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/SelectedObject.java
index 7af46ab..bba9d03 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/SelectedObject.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/SelectedObject.java
@@ -20,9 +20,9 @@
package org.apache.isis.viewer.scimpi.dispatcher.view.display;
import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-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.context.Request.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
/**
* <swf:selected name="selected" object="${action}" equals="${subaction}" />
@@ -30,21 +30,21 @@ import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
public class SelectedObject extends AbstractElementProcessor {
@Override
- public void process(final Request request) {
- final String name = request.getOptionalProperty(NAME, "selected");
- final String objectId = request.getRequiredProperty(OBJECT);
- final String equalsId = request.getOptionalProperty("equals");
- final String title = request.getOptionalProperty(BUTTON_TITLE);
+ public void process(final TagProcessor tagProcessor) {
+ final String name = tagProcessor.getOptionalProperty(NAME, "selected");
+ final String objectId = tagProcessor.getRequiredProperty(OBJECT);
+ final String equalsId = tagProcessor.getOptionalProperty("equals");
+ final String title = tagProcessor.getOptionalProperty(BUTTON_TITLE);
- final ObjectAdapter object = request.getContext().getMappedObjectOrResult(objectId);
- final ObjectAdapter other = request.getContext().getMappedObjectOrResult(equalsId);
+ final ObjectAdapter object = tagProcessor.getContext().getMappedObjectOrResult(objectId);
+ final ObjectAdapter other = tagProcessor.getContext().getMappedObjectOrResult(equalsId);
if (object == other || object.equals(title)) {
// TODO title is not being used!
- request.getContext().addVariable(ID, " id=\"" + name + "\" ", Scope.INTERACTION);
+ tagProcessor.getContext().addVariable(ID, " id=\"" + name + "\" ", Scope.INTERACTION);
} else {
- request.getContext().addVariable(ID, "", Scope.INTERACTION);
+ tagProcessor.getContext().addVariable(ID, "", Scope.INTERACTION);
}
- request.closeEmpty();
+ tagProcessor.closeEmpty();
}
@Override
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableBlock.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableBlock.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableBlock.java
index 2927fab..6fa85b9 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableBlock.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableBlock.java
@@ -20,8 +20,8 @@
package org.apache.isis.viewer.scimpi.dispatcher.view.display;
import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.viewer.scimpi.dispatcher.BlockContent;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request.RepeatMarker;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.BlockContent;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor.RepeatMarker;
public class TableBlock implements BlockContent {
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableBuilder.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableBuilder.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableBuilder.java
index e726e29..b1d526b 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableBuilder.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableBuilder.java
@@ -23,28 +23,28 @@ import java.util.List;
import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
-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.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
import org.apache.isis.viewer.scimpi.dispatcher.processor.PageWriter;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request.RepeatMarker;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor.RepeatMarker;
public class TableBuilder extends AbstractTableView {
@Override
- protected TableContentWriter createRowBuilder(final Request request, final RequestContext context, final String parent, final List<ObjectAssociation> allFields, final ObjectAdapter collection) {
+ protected TableContentWriter createRowBuilder(final TagProcessor tagProcessor, final Request context, final String parent, final List<ObjectAssociation> allFields, final ObjectAdapter collection) {
- final String title = request.getOptionalProperty(TABLE_TITLE);
- final String variable = request.getOptionalProperty(ELEMENT_NAME, ELEMENT);
- final String headerClass = request.getOptionalProperty("head-" + CLASS);
+ final String title = tagProcessor.getOptionalProperty(TABLE_TITLE);
+ final String variable = tagProcessor.getOptionalProperty(ELEMENT_NAME, ELEMENT);
+ final String headerClass = tagProcessor.getOptionalProperty("head-" + CLASS);
final TableBlock block = new TableBlock();
block.setCollection(collection);
block.setElementName(variable);
- request.setBlockContent(block);
- request.pushNewBuffer();
- request.processUtilCloseTag();
- final String headers = request.popBuffer();
+ tagProcessor.setBlockContent(block);
+ tagProcessor.pushNewBuffer();
+ tagProcessor.processUtilCloseTag();
+ final String headers = tagProcessor.popBuffer();
return new TableContentWriter() {
@Override
@@ -52,7 +52,7 @@ public class TableBuilder extends AbstractTableView {
}
public void tidyUp() {
- request.popBlockContent();
+ tagProcessor.popBlockContent();
}
@Override
@@ -73,12 +73,12 @@ public class TableBuilder extends AbstractTableView {
}
@Override
- public void writeElement(final Request request, final RequestContext context, final ObjectAdapter element) {
+ public void writeElement(final TagProcessor tagProcessor, final Request context, final ObjectAdapter element) {
context.addVariable(variable, context.mapObject(element, Scope.REQUEST), Scope.REQUEST);
- final RepeatMarker end = request.createMarker();
+ final RepeatMarker end = tagProcessor.createMarker();
final RepeatMarker marker = block.getMarker();
marker.repeat();
- request.processUtilCloseTag();
+ tagProcessor.processUtilCloseTag();
end.repeat();
}
};
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableCell.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableCell.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableCell.java
index 3f99218..80f1753 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableCell.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableCell.java
@@ -23,11 +23,12 @@ 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.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.Names;
+import org.apache.isis.viewer.scimpi.ScimpiException;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public class TableCell extends AbstractElementProcessor {
@@ -39,51 +40,51 @@ public class TableCell extends AbstractElementProcessor {
private final Where where = Where.ALL_TABLES;
@Override
- public void process(final Request request) {
- final TableBlock tableBlock = (TableBlock) request.getBlockContent();
- final String id = request.getOptionalProperty(OBJECT);
- final String fieldName = request.getRequiredProperty(FIELD);
- final String linkView = request.getOptionalProperty(LINK_VIEW);
- String className = request.getOptionalProperty(CLASS);
+ public void process(final TagProcessor tagProcessor) {
+ final TableBlock tableBlock = (TableBlock) tagProcessor.getBlockContent();
+ final String id = tagProcessor.getOptionalProperty(OBJECT);
+ final String fieldName = tagProcessor.getRequiredProperty(FIELD);
+ final String linkView = tagProcessor.getOptionalProperty(LINK_VIEW);
+ String className = tagProcessor.getOptionalProperty(CLASS);
className = className == null ? "" : " class=\"" + className + "\"";
- RequestContext context = request.getContext();
+ Request context = tagProcessor.getContext();
final ObjectAdapter object = context.getMappedObjectOrVariable(id, tableBlock.getElementName());
final ObjectAssociation field = object.getSpecification().getAssociation(fieldName);
if (field == null) {
throw new ScimpiException("No field " + fieldName + " in " + object.getSpecification().getFullIdentifier());
}
- request.appendHtml("<td" + className + ">");
+ tagProcessor.appendHtml("<td" + className + ">");
if (field.isVisible(IsisContext.getAuthenticationSession(), object, where).isAllowed()) {
final ObjectAdapter fieldReference = field.get(object);
final String source = fieldReference == null ? "" : context.mapObject(fieldReference, Scope.REQUEST);
- final String name = request.getOptionalProperty(RESULT_NAME, fieldName);
- context.addVariable(name, Request.getEncoder().encoder(source), Scope.REQUEST);
+ final String name = tagProcessor.getOptionalProperty(RESULT_NAME, fieldName);
+ context.addVariable(name, TagProcessor.getEncoder().encoder(source), Scope.REQUEST);
if (linkView != null) {
final String linkId = context.mapObject(object, Scope.REQUEST);
- final String linkName = request.getOptionalProperty(LINK_NAME, RequestContext.RESULT);
- final String linkObject = request.getOptionalProperty(LINK_OBJECT, linkId);
- request.appendHtml("<a href=\"" + linkView + "?" + linkName + "=" + linkObject + context.encodedInteractionParameters() + "\">");
+ final String linkName = tagProcessor.getOptionalProperty(LINK_NAME, Names.RESULT);
+ final String linkObject = tagProcessor.getOptionalProperty(LINK_OBJECT, linkId);
+ tagProcessor.appendHtml("<a href=\"" + linkView + "?" + linkName + "=" + linkObject + context.encodedInteractionParameters() + "\">");
} else if(tableBlock.getlinkView() != null) {
String linkObjectInVariable = tableBlock.getElementName();
final String linkId = (String) context.getVariable(linkObjectInVariable);
- request.appendHtml("<a href=\"" + tableBlock.getlinkView() + "?" + tableBlock.getlinkName() + "=" + linkId + context.encodedInteractionParameters() + "\">");
+ tagProcessor.appendHtml("<a href=\"" + tableBlock.getlinkView() + "?" + tableBlock.getlinkName() + "=" + linkId + context.encodedInteractionParameters() + "\">");
}
- request.pushNewBuffer();
- request.processUtilCloseTag();
- final String buffer = request.popBuffer();
+ tagProcessor.pushNewBuffer();
+ tagProcessor.processUtilCloseTag();
+ final String buffer = tagProcessor.popBuffer();
if (buffer.trim().length() == 0) {
- request.appendAsHtmlEncoded(fieldReference == null ? "" : fieldReference.titleString());
+ tagProcessor.appendAsHtmlEncoded(fieldReference == null ? "" : fieldReference.titleString());
} else {
- request.appendHtml(buffer);
+ tagProcessor.appendHtml(buffer);
}
if (linkView != null) {
- request.appendHtml("</a>");
+ tagProcessor.appendHtml("</a>");
}
} else {
- request.skipUntilClose();
+ tagProcessor.skipUntilClose();
}
- request.appendHtml("</td>");
+ tagProcessor.appendHtml("</td>");
}
@Override
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableContentWriter.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableContentWriter.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableContentWriter.java
index 10da109..92a9929 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableContentWriter.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableContentWriter.java
@@ -20,9 +20,9 @@
package org.apache.isis.viewer.scimpi.dispatcher.view.display;
import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
import org.apache.isis.viewer.scimpi.dispatcher.processor.PageWriter;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
public interface TableContentWriter {
@@ -32,7 +32,7 @@ public interface TableContentWriter {
void writeFooters(PageWriter writer);
- void writeElement(Request request, RequestContext context, ObjectAdapter element);
+ void writeElement(TagProcessor tagProcessor, Request context, ObjectAdapter element);
void tidyUp();
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableEmpty.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableEmpty.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableEmpty.java
index 5595207..145733f 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableEmpty.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableEmpty.java
@@ -21,27 +21,27 @@ package org.apache.isis.viewer.scimpi.dispatcher.view.display;
import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacet;
-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.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public class TableEmpty extends AbstractElementProcessor {
@Override
- public void process(final Request request) {
- final TableBlock tableBlock = (TableBlock) request.getBlockContent();
+ public void process(final TagProcessor tagProcessor) {
+ final TableBlock tableBlock = (TableBlock) tagProcessor.getBlockContent();
final ObjectAdapter collection = tableBlock.getCollection();
final CollectionFacet facet = collection.getSpecification().getFacet(CollectionFacet.class);
if (facet.size(collection) == 0) {
- String className = request.getOptionalProperty(CLASS);
+ String className = tagProcessor.getOptionalProperty(CLASS);
className = className == null ? "" : " class=\"" + className + "\"";
- request.appendHtml("<tr" + className + ">");
- request.pushNewBuffer();
- request.processUtilCloseTag();
- final String buffer = request.popBuffer();
- request.appendHtml(buffer);
- request.appendHtml("</td>");
+ tagProcessor.appendHtml("<tr" + className + ">");
+ tagProcessor.pushNewBuffer();
+ tagProcessor.processUtilCloseTag();
+ final String buffer = tagProcessor.popBuffer();
+ tagProcessor.appendHtml(buffer);
+ tagProcessor.appendHtml("</td>");
} else {
- request.skipUntilClose();
+ tagProcessor.skipUntilClose();
}
}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableHeader.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableHeader.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableHeader.java
index ff04389..22a8e7f 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableHeader.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableHeader.java
@@ -19,8 +19,8 @@
package org.apache.isis.viewer.scimpi.dispatcher.view.display;
-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.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public class TableHeader extends AbstractElementProcessor {
@@ -30,10 +30,10 @@ public class TableHeader extends AbstractElementProcessor {
}
@Override
- public void process(final Request request) {
- request.appendHtml("<thead><tr>");
- request.processUtilCloseTag();
- request.appendHtml("</tr></thead>");
+ public void process(final TagProcessor tagProcessor) {
+ tagProcessor.appendHtml("<thead><tr>");
+ tagProcessor.processUtilCloseTag();
+ tagProcessor.appendHtml("</tr></thead>");
}
}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableRow.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableRow.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableRow.java
index eb92656..e8ba18a 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableRow.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableRow.java
@@ -19,10 +19,10 @@
package org.apache.isis.viewer.scimpi.dispatcher.view.display;
-import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request.RepeatMarker;
+import org.apache.isis.viewer.scimpi.Names;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor.RepeatMarker;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public class TableRow extends AbstractElementProcessor {
@@ -32,18 +32,18 @@ public class TableRow extends AbstractElementProcessor {
}
@Override
- public void process(final Request request) {
- final TableBlock block = (TableBlock) request.getBlockContent();
+ public void process(final TagProcessor tagProcessor) {
+ final TableBlock block = (TableBlock) tagProcessor.getBlockContent();
- final RepeatMarker start = request.createMarker();
+ final RepeatMarker start = tagProcessor.createMarker();
block.setMarker(start);
- final String linkView = request.getOptionalProperty(LINK_VIEW);
+ final String linkView = tagProcessor.getOptionalProperty(LINK_VIEW);
if (linkView != null) {
block.setlinkView(linkView);
- block.setlinkName(request.getOptionalProperty(LINK_NAME, RequestContext.RESULT));
+ block.setlinkName(tagProcessor.getOptionalProperty(LINK_NAME, Names.RESULT));
}
- request.skipUntilClose();
+ tagProcessor.skipUntilClose();
}
}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableView.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableView.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableView.java
index caf984f..aa19f74 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableView.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableView.java
@@ -25,11 +25,11 @@ import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
import org.apache.isis.core.metamodel.facets.object.parseable.ParseableFacet;
import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
import org.apache.isis.core.runtime.persistence.ObjectNotFoundException;
-import org.apache.isis.viewer.scimpi.dispatcher.Dispatcher;
-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.Names;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
import org.apache.isis.viewer.scimpi.dispatcher.processor.PageWriter;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
import org.apache.isis.viewer.scimpi.dispatcher.view.field.LinkedFieldsBlock;
import org.apache.isis.viewer.scimpi.dispatcher.view.field.LinkedObject;
import org.apache.isis.viewer.scimpi.dispatcher.view.simple.RemoveElement;
@@ -137,120 +137,120 @@ public class TableView extends AbstractTableView {
}
@Override
- public void writeElement(final Request request, final RequestContext context, final ObjectAdapter element) {
+ public void writeElement(final TagProcessor tagProcessor, final Request context, final ObjectAdapter element) {
final String rowId = context.mapObject(element, Scope.INTERACTION);
final String scope = linkRow == null ? "" : "&" + SCOPE + "=" + linkRow.getScope();
String result = "";
result = context.encodedInteractionParameters();
if (noColumns == 0) {
- request.appendHtml("<td>");
+ tagProcessor.appendHtml("<td>");
if (linkRow != null) {
- request.appendHtml("<td><a href=\"" + linkRow.getForwardView() + "?" + linkRow.getVariable() + "=" + rowId + result + scope + "\">");
- request.appendAsHtmlEncoded(element.titleString());
- request.appendHtml("</a>");
+ tagProcessor.appendHtml("<td><a href=\"" + linkRow.getForwardView() + "?" + linkRow.getVariable() + "=" + rowId + result + scope + "\">");
+ tagProcessor.appendAsHtmlEncoded(element.titleString());
+ tagProcessor.appendHtml("</a>");
} else {
- request.appendAsHtmlEncoded(element.titleString());
+ tagProcessor.appendAsHtmlEncoded(element.titleString());
}
- request.appendHtml("</td>");
+ tagProcessor.appendHtml("</td>");
} else {
if (showTitle) {
- request.appendHtml("<td>");
- request.appendAsHtmlEncoded(element.titleString());
- request.appendHtml("</td>");
+ tagProcessor.appendHtml("<td>");
+ tagProcessor.appendAsHtmlEncoded(element.titleString());
+ tagProcessor.appendHtml("</td>");
}
for (int i = 0; i < noColumns; i++) {
if (fields.get(i).isOneToManyAssociation()) {
continue;
}
- request.appendHtml("<td>");
+ tagProcessor.appendHtml("<td>");
final ObjectAdapter field = fields.get(i).get(element);
if (field != null) {
if (showIcons && !fields.get(i).getSpecification().containsFacet(ParseableFacet.class)) {
- request.appendHtml("<img class=\"" + "small-icon" + "\" src=\"" + request.getContext().imagePath(field) + "\" alt=\"" + fields.get(i).getSpecification().getShortIdentifier() + "\"/>");
+ tagProcessor.appendHtml("<img class=\"" + "small-icon" + "\" src=\"" + tagProcessor.getContext().imagePath(field) + "\" alt=\"" + fields.get(i).getSpecification().getShortIdentifier() + "\"/>");
}
if (linkRow != null) {
- request.appendHtml("<a href=\"" + linkRow.getForwardView() + "?" + linkRow.getVariable() + "=" + rowId + result + scope + "\">");
+ tagProcessor.appendHtml("<a href=\"" + linkRow.getForwardView() + "?" + linkRow.getVariable() + "=" + rowId + result + scope + "\">");
} else if (linkedFields[i] != null) {
final ObjectAdapter fieldObject = fields.get(i).get(element);
final String id = context.mapObject(fieldObject, Scope.INTERACTION);
- request.appendHtml("<a href=\"" + linkedFields[i].getForwardView() + "?" + linkedFields[i].getVariable() + "=" + id + "\">");
- context.mapObject(fieldObject, RequestContext.scope(linkedFields[i].getScope()));
+ tagProcessor.appendHtml("<a href=\"" + linkedFields[i].getForwardView() + "?" + linkedFields[i].getVariable() + "=" + id + "\">");
+ context.mapObject(fieldObject, Request.scope(linkedFields[i].getScope()));
}
try {
- request.appendAsHtmlEncoded(field.titleString());
+ tagProcessor.appendAsHtmlEncoded(field.titleString());
} catch (final ObjectNotFoundException e) {
- request.appendAsHtmlEncoded(e.getMessage());
+ tagProcessor.appendAsHtmlEncoded(e.getMessage());
}
if (linkRow != null || linkedFields[i] != null) {
- request.appendHtml("</a>");
+ tagProcessor.appendHtml("</a>");
}
}
- request.appendHtml("</td>");
+ tagProcessor.appendHtml("</td>");
}
}
- request.appendHtml("<td class=\"controls\">");
+ tagProcessor.appendHtml("<td class=\"controls\">");
if (showSelectOption) {
- request.appendHtml("<a class=\"button element-select\" href=\"" + "_generic." + Dispatcher.EXTENSION + "?" + RequestContext.RESULT + "=" + rowId + result + scope + "\">view</a>");
+ tagProcessor.appendHtml("<a class=\"button element-select\" href=\"" + "_generic." + Names.EXTENSION + "?" + Names.RESULT + "=" + rowId + result + scope + "\">view</a>");
}
if (showEditOption) {
- request.appendHtml(" <a class=\"button element-edit\" href=\"" + "_generic_edit." + Dispatcher.EXTENSION + "?" + RequestContext.RESULT + "=" + rowId + result + scope + "\">edit</a>");
+ tagProcessor.appendHtml(" <a class=\"button element-edit\" href=\"" + "_generic_edit." + Names.EXTENSION + "?" + Names.RESULT + "=" + rowId + result + scope + "\">edit</a>");
}
if (showDeleteOption && parent != null) {
- String view = request.getViewPath();
+ String view = tagProcessor.getViewPath();
view = context.fullFilePath(view == null ? context.getResourceFile() : view);
- RemoveElement.write(request, context.getMappedObject(parent), fieldName, element, null, view, view, "delete", "action in-line element-delete confirm");
+ RemoveElement.write(tagProcessor, context.getMappedObject(parent), fieldName, element, null, view, view, "delete", "action in-line element-delete confirm");
}
- request.appendHtml("</td>");
+ tagProcessor.appendHtml("</td>");
}
}
@Override
protected TableContentWriter createRowBuilder(
- final Request request,
- final RequestContext context,
+ final TagProcessor tagProcessor,
+ final Request context,
final String parent,
final List<ObjectAssociation> allFields,
final ObjectAdapter collection) {
- final String fieldName = request.getOptionalProperty(FIELD);
- final String title = request.getOptionalProperty(FORM_TITLE);
- return rowBuilder(request, context, title, parent, fieldName, allFields, showIconByDefault());
+ final String fieldName = tagProcessor.getOptionalProperty(FIELD);
+ final String title = tagProcessor.getOptionalProperty(FORM_TITLE);
+ return rowBuilder(tagProcessor, context, title, parent, fieldName, allFields, showIconByDefault());
}
private static TableContentWriter rowBuilder(
- final Request request,
- final RequestContext context,
+ final TagProcessor tagProcessor,
+ final Request context,
final String title,
final String object,
final String fieldName,
final List<ObjectAssociation> allFields,
final boolean showIconByDefault) {
- final String linkRowView = request.getOptionalProperty(LINK_VIEW);
- final String linkObjectName = request.getOptionalProperty(ELEMENT_NAME, RequestContext.RESULT);
- final String linkObjectScope = request.getOptionalProperty(SCOPE, Scope.INTERACTION.toString());
+ final String linkRowView = tagProcessor.getOptionalProperty(LINK_VIEW);
+ final String linkObjectName = tagProcessor.getOptionalProperty(ELEMENT_NAME, Names.RESULT);
+ final String linkObjectScope = tagProcessor.getOptionalProperty(SCOPE, Scope.INTERACTION.toString());
final LinkedObject linkRow = linkRowView == null ? null : new LinkedObject(linkObjectName, linkObjectScope, context.fullUriPath(linkRowView));
- final boolean includeHeader = request.isRequested(HEADER, true);
- final boolean includeFooter = request.isRequested(FOOTER, false);
+ final boolean includeHeader = tagProcessor.isRequested(HEADER, true);
+ final boolean includeFooter = tagProcessor.isRequested(FOOTER, false);
- final boolean linkFields = request.isRequested("link-fields", true);
- final boolean showTitle = request.isRequested(SHOW_TITLE, false);
- final boolean showIcons = request.isRequested(SHOW_ICON, showIconByDefault);
- final boolean showSelectOption = request.isRequested(SHOW_SELECT, true);
- final boolean showEditOption = request.isRequested(SHOW_EDIT, true);
- final boolean showDeleteOption = request.isRequested(SHOW_DELETE, true);
+ final boolean linkFields = tagProcessor.isRequested("link-fields", true);
+ final boolean showTitle = tagProcessor.isRequested(SHOW_TITLE, false);
+ final boolean showIcons = tagProcessor.isRequested(SHOW_ICON, showIconByDefault);
+ final boolean showSelectOption = tagProcessor.isRequested(SHOW_SELECT, true);
+ final boolean showEditOption = tagProcessor.isRequested(SHOW_EDIT, true);
+ final boolean showDeleteOption = tagProcessor.isRequested(SHOW_DELETE, true);
- final String noColumnsString = request.getOptionalProperty("no-columns", "3");
+ final String noColumnsString = tagProcessor.getOptionalProperty("no-columns", "3");
final LinkedFieldsBlock block = new LinkedFieldsBlock();
- request.setBlockContent(block);
- request.processUtilCloseTag();
+ tagProcessor.setBlockContent(block);
+ tagProcessor.processUtilCloseTag();
final List<ObjectAssociation> fields = block.includedFields(allFields);
final LinkedObject[] linkedFields = block.linkedFields(fields);
for (int i = 0; i < linkedFields.length; i++) {
@@ -278,14 +278,14 @@ public class TableView extends AbstractTableView {
headers[h++] = fields.get(i).getName();
}
- request.popBlockContent();
+ tagProcessor.popBlockContent();
return new SimpleTableBuilder(object, includeHeader, includeFooter, title, noColumns, headers, fields, showTitle,
showIcons, showSelectOption, showDeleteOption, showEditOption, fieldName, linkedFields, linkRow);
}
public static void write(
- final Request request,
+ final TagProcessor tagProcessor,
final String summary,
final ObjectAdapter object,
final ObjectAssociation field,
@@ -315,10 +315,10 @@ public class TableView extends AbstractTableView {
headers[h++] = fields.get(i).getName();
}
- final RequestContext context = request.getContext();
- final TableContentWriter rowBuilder = rowBuilder(request, context, null, context.mapObject(object, Scope.REQUEST), field.getIdentifier().getMemberName(), fields,
+ final Request context = tagProcessor.getContext();
+ final TableContentWriter rowBuilder = rowBuilder(tagProcessor, context, null, context.mapObject(object, Scope.REQUEST), field.getIdentifier().getMemberName(), fields,
showIconByDefault);
- write(request, collection, summary, rowBuilder, null, null, null);
+ write(tagProcessor, collection, summary, rowBuilder, null, null, null);
}
@Override
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/Title.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/Title.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/Title.java
index d3b6904..76f8278 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/Title.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/Title.java
@@ -23,22 +23,22 @@ 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.processor.Request;
+import org.apache.isis.viewer.scimpi.ForbiddenException;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
import org.apache.isis.viewer.scimpi.dispatcher.util.MethodsUtils;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public class Title extends AbstractElementProcessor {
@Override
- public void process(final Request request) {
- final String id = request.getOptionalProperty(OBJECT);
- final String fieldName = request.getOptionalProperty(FIELD);
- final int truncateTo = Integer.valueOf(request.getOptionalProperty(TRUNCATE, "0")).intValue();
- final boolean isIconShowing = request.isRequested(SHOW_ICON, showIconByDefault());
- String className = request.getOptionalProperty(CLASS);
+ public void process(final TagProcessor tagProcessor) {
+ final String id = tagProcessor.getOptionalProperty(OBJECT);
+ final String fieldName = tagProcessor.getOptionalProperty(FIELD);
+ final int truncateTo = Integer.valueOf(tagProcessor.getOptionalProperty(TRUNCATE, "0")).intValue();
+ final boolean isIconShowing = tagProcessor.isRequested(SHOW_ICON, showIconByDefault());
+ String className = tagProcessor.getOptionalProperty(CLASS);
className = className == null ? "title-icon" : className;
- ObjectAdapter object = MethodsUtils.findObject(request.getContext(), id);
+ ObjectAdapter object = MethodsUtils.findObject(tagProcessor.getContext(), id);
if (fieldName != null) {
final ObjectAssociation field = object.getSpecification().getAssociation(fieldName);
if (field.isVisible(IsisContext.getAuthenticationSession(), object, Where.ANYWHERE).isVetoed()) {
@@ -48,16 +48,16 @@ public class Title extends AbstractElementProcessor {
}
if (object != null) {
- request.appendHtml("<span class=\"object\">");
+ tagProcessor.appendHtml("<span class=\"object\">");
IsisContext.getPersistenceSession().resolveImmediately(object);
if (isIconShowing) {
- final String iconPath = request.getContext().imagePath(object);
- request.appendHtml("<img class=\"" + className + "\" src=\"" + iconPath + "\" />");
+ final String iconPath = tagProcessor.getContext().imagePath(object);
+ tagProcessor.appendHtml("<img class=\"" + className + "\" src=\"" + iconPath + "\" />");
}
- request.appendTruncated(object.titleString(), truncateTo);
- request.appendHtml("</span>");
+ tagProcessor.appendTruncated(object.titleString(), truncateTo);
+ tagProcessor.appendHtml("</span>");
}
- request.closeEmpty();
+ tagProcessor.closeEmpty();
}
@Override
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/Warnings.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/Warnings.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/Warnings.java
index ca0becb..f6ea1a3 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/Warnings.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/Warnings.java
@@ -23,20 +23,20 @@ import java.util.List;
import org.apache.isis.core.runtime.system.context.IsisContext;
import org.apache.isis.core.runtime.system.transaction.MessageBroker;
-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.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public class Warnings extends AbstractElementProcessor {
@Override
- public void process(final Request request) {
- final String cls = request.getOptionalProperty(CLASS);
+ public void process(final TagProcessor tagProcessor) {
+ final String cls = tagProcessor.getOptionalProperty(CLASS);
final StringBuffer buffer = new StringBuffer();
write(cls, buffer);
if (buffer.length() > 0) {
- request.appendHtml("<div class=\"feedback\">");
- request.appendHtml(buffer.toString());
- request.appendHtml("</div>");
+ tagProcessor.appendHtml("<div class=\"feedback\">");
+ tagProcessor.appendHtml(buffer.toString());
+ tagProcessor.appendHtml("</div>");
}
}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/edit/EditObject.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/edit/EditObject.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/edit/EditObject.java
index 9ff4eff..468fc6a 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/edit/EditObject.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/edit/EditObject.java
@@ -33,16 +33,18 @@ import org.apache.isis.core.metamodel.spec.feature.ObjectAssociationFilters;
import org.apache.isis.core.progmodel.facets.object.choices.enums.EnumFacet;
import org.apache.isis.core.progmodel.facets.value.booleans.BooleanValueFacet;
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.EditAction;
-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.action.EditAction;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.structure.FieldEditState;
+import org.apache.isis.viewer.scimpi.dispatcher.structure.FormState;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
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;
+import org.apache.isis.viewer.scimpi.dispatcher.view.widget.FieldFactory;
+import org.apache.isis.viewer.scimpi.dispatcher.view.widget.FormFieldBlock;
public class EditObject extends AbstractElementProcessor {
@@ -50,30 +52,30 @@ public class EditObject extends AbstractElementProcessor {
private final Where where = Where.OBJECT_FORMS;
@Override
- public void process(final Request request) {
- final RequestContext context = request.getContext();
-
- final String objectId = request.getOptionalProperty(OBJECT);
- final String forwardEditedTo = request.getOptionalProperty(VIEW);
- final String forwardErrorTo = request.getOptionalProperty(ERROR);
- final String cancelTo = request.getOptionalProperty(CANCEL_TO);
- final boolean hideNonEditableFields = request.isRequested(HIDE_UNEDITABLE, false);
- final boolean showIcon = request.isRequested(SHOW_ICON, showIconByDefault());
- final String labelDelimiter = request.getOptionalProperty(LABEL_DELIMITER, ":");
- String buttonTitle = request.getOptionalProperty(BUTTON_TITLE);
- String formTitle = request.getOptionalProperty(FORM_TITLE);
- final String formId = request.getOptionalProperty(FORM_ID, request.nextFormId());
- final String variable = request.getOptionalProperty(RESULT_NAME);
- final String resultOverride = request.getOptionalProperty(RESULT_OVERRIDE);
- final String scope = request.getOptionalProperty(SCOPE);
- final String className = request.getOptionalProperty(CLASS, "edit full");
- final String completionMessage = request.getOptionalProperty(MESSAGE);
+ public void process(final TagProcessor tagProcessor) {
+ final Request context = tagProcessor.getContext();
+
+ final String objectId = tagProcessor.getOptionalProperty(OBJECT);
+ final String forwardEditedTo = tagProcessor.getOptionalProperty(VIEW);
+ final String forwardErrorTo = tagProcessor.getOptionalProperty(ERROR);
+ final String cancelTo = tagProcessor.getOptionalProperty(CANCEL_TO);
+ final boolean hideNonEditableFields = tagProcessor.isRequested(HIDE_UNEDITABLE, false);
+ final boolean showIcon = tagProcessor.isRequested(SHOW_ICON, showIconByDefault());
+ final String labelDelimiter = tagProcessor.getOptionalProperty(LABEL_DELIMITER, ":");
+ String buttonTitle = tagProcessor.getOptionalProperty(BUTTON_TITLE);
+ String formTitle = tagProcessor.getOptionalProperty(FORM_TITLE);
+ final String formId = tagProcessor.getOptionalProperty(FORM_ID, tagProcessor.nextFormId());
+ final String variable = tagProcessor.getOptionalProperty(RESULT_NAME);
+ final String resultOverride = tagProcessor.getOptionalProperty(RESULT_OVERRIDE);
+ final String scope = tagProcessor.getOptionalProperty(SCOPE);
+ final String className = tagProcessor.getOptionalProperty(CLASS, "edit full");
+ final String completionMessage = tagProcessor.getOptionalProperty(MESSAGE);
final ObjectAdapter object = context.getMappedObjectOrResult(objectId);
final String actualObjectId = context.mapObject(object, Scope.INTERACTION);
final String version = context.mapVersion(object);
- final String id = request.getOptionalProperty(ID, object.getSpecification().getShortIdentifier());
+ final String id = tagProcessor.getOptionalProperty(ID, object.getSpecification().getShortIdentifier());
final FormState entryState = (FormState) context.getVariable(ENTRY_FIELDS);
@@ -108,8 +110,8 @@ public class EditObject extends AbstractElementProcessor {
}
};
- request.setBlockContent(containedBlock);
- request.processUtilCloseTag();
+ tagProcessor.setBlockContent(containedBlock);
+ tagProcessor.processUtilCloseTag();
final AuthenticationSession session = IsisContext.getAuthenticationSession();
List<ObjectAssociation> viewFields = specification.getAssociations(ObjectAssociationFilters.dynamicallyVisible(session, object, where));
@@ -163,9 +165,9 @@ public class EditObject extends AbstractElementProcessor {
}
final HiddenInputField[] hiddenFieldArray = hiddenFields.toArray(new HiddenInputField[hiddenFields.size()]);
- HtmlFormBuilder.createForm(request, EditAction.ACTION + ".app", hiddenFieldArray, formFields, className, id, formTitle,
+ HtmlFormBuilder.createForm(tagProcessor, EditAction.ACTION + ".app", hiddenFieldArray, formFields, className, id, formTitle,
labelDelimiter, null, null, buttonTitle, errors, cancelTo);
- request.popBlockContent();
+ tagProcessor.popBlockContent();
}
private InputField[] createFields(final List<ObjectAssociation> fields) {
@@ -187,7 +189,7 @@ public class EditObject extends AbstractElementProcessor {
}
// TODO duplicated in ActionForm#initializeFields
- private void initializeFields(final RequestContext context, final ObjectAdapter object, final InputField[] formFields, final FormState entryState, final boolean includeUnusableFields) {
+ private void initializeFields(final Request context, final ObjectAdapter object, final InputField[] formFields, final FormState entryState, final boolean includeUnusableFields) {
for (final InputField formField : formFields) {
final String fieldId = formField.getName();
final ObjectAssociation field = object.getSpecification().getAssociation(fieldId);
@@ -210,7 +212,7 @@ public class EditObject extends AbstractElementProcessor {
}
}
- private void copyFieldContent(final RequestContext context, final ObjectAdapter object, final InputField[] formFields, final boolean showIcon) {
+ private void copyFieldContent(final Request context, final ObjectAdapter object, final InputField[] formFields, final boolean showIcon) {
for (final InputField inputField : formFields) {
final String fieldName = inputField.getName();
final ObjectAssociation field = object.getSpecification().getAssociation(fieldName);
@@ -243,7 +245,7 @@ public class EditObject extends AbstractElementProcessor {
}
}
- private void setDefaults(final RequestContext context, final ObjectAdapter object, final InputField[] formFields, final FormState entryState, final boolean showIcon) {
+ private void setDefaults(final Request context, final ObjectAdapter object, final InputField[] formFields, final FormState entryState, final boolean showIcon) {
for (final InputField formField : formFields) {
final String fieldId = formField.getName();
final ObjectAssociation field = object.getSpecification().getAssociation(fieldId);
@@ -268,7 +270,7 @@ public class EditObject extends AbstractElementProcessor {
}
}
- private void overrideWithHtml(final RequestContext context, final FormFieldBlock containedBlock, final InputField[] formFields) {
+ private void overrideWithHtml(final Request context, final FormFieldBlock containedBlock, final InputField[] formFields) {
for (final InputField formField : formFields) {
final String fieldId = formField.getName();
if (containedBlock.hasContent(fieldId)) {
@@ -282,7 +284,7 @@ public class EditObject extends AbstractElementProcessor {
}
}
- private void copyEntryState(final RequestContext context, final ObjectAdapter object, final InputField[] formFields, final FormState entryState) {
+ private void copyEntryState(final Request context, final ObjectAdapter object, final InputField[] formFields, final FormState entryState) {
for (final InputField formField : formFields) {
final String fieldId = formField.getName();
final ObjectAssociation field = object.getSpecification().getAssociation(fieldId);
@@ -296,7 +298,7 @@ public class EditObject extends AbstractElementProcessor {
}
}
- private String getValue(final RequestContext context, final ObjectAdapter field) {
+ private String getValue(final Request context, final ObjectAdapter field) {
if (field == null || field.isTransient()) {
return "";
}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/edit/FieldFactory.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/edit/FieldFactory.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/edit/FieldFactory.java
deleted file mode 100644
index 8a90db3..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/edit/FieldFactory.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.viewer.scimpi.dispatcher.view.edit;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.facets.help.HelpFacet;
-import org.apache.isis.core.metamodel.facets.maxlen.MaxLengthFacet;
-import org.apache.isis.core.metamodel.facets.multiline.MultiLineFacet;
-import org.apache.isis.core.metamodel.facets.object.parseable.ParseableFacet;
-import org.apache.isis.core.metamodel.facets.typicallen.TypicalLengthFacet;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.metamodel.spec.feature.ObjectFeature;
-import org.apache.isis.core.metamodel.spec.feature.ObjectMember;
-import org.apache.isis.core.progmodel.facets.value.booleans.BooleanValueFacet;
-import org.apache.isis.core.progmodel.facets.value.password.PasswordValueFacet;
-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.view.form.InputField;
-
-public class FieldFactory {
-
- public static void initializeField(final RequestContext context, final ObjectAdapter object, final ObjectFeature param, final ObjectAdapter[] optionsForParameter, final boolean isRequired, final InputField field) {
-
- field.setLabel(param.getName());
- field.setDescription(param.getDescription());
- field.setDataType(param.getSpecification().getShortIdentifier());
- if (param instanceof ObjectMember) {
- field.setHelpReference(((ObjectMember) param).getHelp());
- } else {
- final HelpFacet helpFacet = param.getFacet(HelpFacet.class);
- final String value = helpFacet.value();
- field.setHelpReference(value);
- }
- field.setRequired(isRequired);
- field.setHidden(false);
-
- if (param.getSpecification().getFacet(ParseableFacet.class) != null) {
- final int maxLength = param.getFacet(MaxLengthFacet.class).value();
- field.setMaxLength(maxLength);
-
- final TypicalLengthFacet typicalLengthFacet = param.getFacet(TypicalLengthFacet.class);
- if (typicalLengthFacet.isDerived() && maxLength > 0) {
- field.setWidth(maxLength);
- } else {
- field.setWidth(typicalLengthFacet.value());
- }
-
- final MultiLineFacet multiLineFacet = param.getFacet(MultiLineFacet.class);
- field.setHeight(multiLineFacet.numberOfLines());
- field.setWrapped(!multiLineFacet.preventWrapping());
-
- final ObjectSpecification spec = param.getSpecification();
- if (spec.containsFacet(BooleanValueFacet.class)) {
- field.setType(InputField.CHECKBOX);
- } else if (spec.containsFacet(PasswordValueFacet.class)) {
- field.setType(InputField.PASSWORD);
- } else {
- field.setType(InputField.TEXT);
- }
-
- } else {
- field.setType(InputField.REFERENCE);
- }
-
- if (optionsForParameter != null) {
- final int noOptions = optionsForParameter.length;
- final String[] optionValues = new String[noOptions];
- final String[] optionTitles = new String[noOptions];
- for (int j = 0; j < optionsForParameter.length; j++) {
- final int i = j; // + (field.isRequired() ? 0 : 1);
- optionValues[i] = getValue(context, optionsForParameter[j]);
- optionTitles[i] = optionsForParameter[j].titleString();
- }
- field.setOptions(optionTitles, optionValues);
- }
- }
-
- private static String getValue(final RequestContext context, final ObjectAdapter field) {
- if (field == null) {
- return "";
- }
- if (field.getSpecification().getFacet(ParseableFacet.class) == null) {
- return context.mapObject(field, Scope.INTERACTION);
- } else {
- return field.getObject().toString();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/edit/FormEntry.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/edit/FormEntry.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/edit/FormEntry.java
deleted file mode 100644
index 5d57740..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/edit/FormEntry.java
+++ /dev/null
@@ -1,44 +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.edit;
-
-import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
-
-public class FormEntry extends AbstractElementProcessor {
-
- @Override
- public void process(final Request request) {
- final FormFieldBlock block = (FormFieldBlock) request.getBlockContent();
- final String field = request.getRequiredProperty(FIELD);
- final String value = request.getRequiredProperty(VALUE);
- final boolean isHidden = request.isRequested(HIDDEN, true);
- block.exclude(field);
- // TODO this is replaced because the field is marked as hidden!
- final String content = "reference <input type=\"" + (isHidden ? "hidden" : "text") + "\" disabled=\"disabled\" name=\"" + field + "\" value=\"" + value + "\" />";
- block.replaceContent(field, content);
- }
-
- @Override
- public String getName() {
- return "form-entry";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/edit/FormField.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/edit/FormField.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/edit/FormField.java
deleted file mode 100644
index 55c7425..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/edit/FormField.java
+++ /dev/null
@@ -1,44 +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.edit;
-
-import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
-
-public class FormField extends AbstractElementProcessor {
-
- @Override
- public void process(final Request request) {
- final FormFieldBlock block = (FormFieldBlock) request.getBlockContent();
- final String field = request.getRequiredProperty(FIELD);
- if (block.isVisible(field)) {
- request.pushNewBuffer();
- request.processUtilCloseTag();
- final String content = request.popBuffer();
- block.replaceContent(field, content);
- }
- }
-
- @Override
- public String getName() {
- return "form-field";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/edit/FormFieldBlock.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/edit/FormFieldBlock.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/edit/FormFieldBlock.java
deleted file mode 100644
index 294a239..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/edit/FormFieldBlock.java
+++ /dev/null
@@ -1,68 +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.edit;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.viewer.scimpi.dispatcher.view.field.InclusionList;
-import org.apache.isis.viewer.scimpi.dispatcher.view.form.InputField;
-
-public class FormFieldBlock extends InclusionList {
- private final Map<String, String> content = new HashMap<String, String>();
- private final Map<String, String> values = new HashMap<String, String>();
-
- public void replaceContent(final String field, final String htmlString) {
- content.put(field, htmlString);
- }
-
- public boolean hasContent(final String name) {
- return content.containsKey(name);
- }
-
- public String getContent(final String name) {
- return content.get(name);
- }
-
- public boolean isVisible(final String name) {
- return true;
- }
-
- public boolean isNullable(final String name) {
- return true;
- }
-
- public ObjectAdapter getCurrent(final String name) {
- return null;
- }
-
- public void value(final String field, final String value) {
- values.put(field, value);
- }
-
- public void setUpValues(final InputField[] inputFields) {
- for (final InputField inputField : inputFields) {
- final String name = inputField.getName();
- inputField.setValue(values.get(name));
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/edit/HiddenField.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/edit/HiddenField.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/edit/HiddenField.java
deleted file mode 100644
index 71019ea..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/edit/HiddenField.java
+++ /dev/null
@@ -1,48 +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.edit;
-
-import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.BlockContent;
-import org.apache.isis.viewer.scimpi.dispatcher.TagOrderException;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
-
-public class HiddenField extends AbstractElementProcessor {
-
- @Override
- public void process(final Request request) {
- final BlockContent blockContent = request.getBlockContent();
- if (!(blockContent instanceof FormFieldBlock)) {
- throw new TagOrderException(request);
- }
-
- final String field = request.getOptionalProperty("name");
- final String value = request.getRequiredProperty("value");
- final FormFieldBlock block = (FormFieldBlock) blockContent;
- block.value(field, value);
- block.exclude(field);
- }
-
- @Override
- public String getName() {
- return "hidden-field";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/edit/RadioListField.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/edit/RadioListField.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/edit/RadioListField.java
deleted file mode 100644
index 7b3c1e6..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/edit/RadioListField.java
+++ /dev/null
@@ -1,70 +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.edit;
-
-import java.util.Iterator;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacet;
-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 RadioListField extends AbstractElementProcessor {
-
- @Override
- public void process(final Request request) {
- final FormFieldBlock block = (FormFieldBlock) request.getBlockContent();
- final String field = request.getRequiredProperty(FIELD);
- if (block.isVisible(field)) {
- final String id = request.getRequiredProperty(COLLECTION);
- final String exclude = request.getOptionalProperty("exclude");
-
- final ObjectAdapter collection = request.getContext().getMappedObjectOrResult(id);
-
- final RequestContext context = request.getContext();
- final CollectionFacet facet = collection.getSpecification().getFacet(CollectionFacet.class);
- final Iterator<ObjectAdapter> iterator = facet.iterator(collection);
-
- final StringBuffer buffer = new StringBuffer();
-
- while (iterator.hasNext()) {
- final ObjectAdapter element = iterator.next();
- final Scope scope = Scope.INTERACTION;
- final String elementId = context.mapObject(element, scope);
- if (exclude != null && context.getMappedObject(exclude) == element) {
- continue;
- }
- final String title = element.titleString();
- final String checked = "";
- buffer.append("<input type=\"radio\" name=\"" + field + "\" value=\"" + elementId + "\"" + checked + " />" + title + "</input><br/>\n");
- }
-
- block.replaceContent(field, buffer.toString());
- }
- }
-
- @Override
- public String getName() {
- return "radio-list";
- }
-
-}
[07/24] Restructuring Scimpi to remove dependencies and enable easier
testing.
Posted by rm...@apache.org.
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/ProcessorLookup.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/ProcessorLookup.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/ProcessorLookup.java
index 36c1920..132e1ac 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/ProcessorLookup.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/ProcessorLookup.java
@@ -25,216 +25,10 @@ import java.util.Map;
import java.util.TreeSet;
import org.apache.isis.core.commons.debug.DebugBuilder;
-import org.apache.isis.viewer.scimpi.dispatcher.ElementProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.debug.DebugUsersView;
-import org.apache.isis.viewer.scimpi.dispatcher.debug.ErrorDetails;
-import org.apache.isis.viewer.scimpi.dispatcher.debug.ErrorMessage;
-import org.apache.isis.viewer.scimpi.dispatcher.debug.ErrorReference;
-import org.apache.isis.viewer.scimpi.dispatcher.view.HelpLink;
-import org.apache.isis.viewer.scimpi.dispatcher.view.History;
-import org.apache.isis.viewer.scimpi.dispatcher.view.VersionNumber;
-import org.apache.isis.viewer.scimpi.dispatcher.view.action.ActionButton;
-import org.apache.isis.viewer.scimpi.dispatcher.view.action.ActionForm;
-import org.apache.isis.viewer.scimpi.dispatcher.view.action.ActionLink;
-import org.apache.isis.viewer.scimpi.dispatcher.view.action.Methods;
-import org.apache.isis.viewer.scimpi.dispatcher.view.action.Parameter;
-import org.apache.isis.viewer.scimpi.dispatcher.view.action.RunAction;
-import org.apache.isis.viewer.scimpi.dispatcher.view.action.Services;
-import org.apache.isis.viewer.scimpi.dispatcher.view.collection.Collection;
-import org.apache.isis.viewer.scimpi.dispatcher.view.debug.DebugAccessCheck;
-import org.apache.isis.viewer.scimpi.dispatcher.view.debug.DebugCollectionView;
-import org.apache.isis.viewer.scimpi.dispatcher.view.debug.DebugObjectView;
-import org.apache.isis.viewer.scimpi.dispatcher.view.debug.DebuggerLink;
-import org.apache.isis.viewer.scimpi.dispatcher.view.debug.Diagnostics;
-import org.apache.isis.viewer.scimpi.dispatcher.view.debug.Log;
-import org.apache.isis.viewer.scimpi.dispatcher.view.debug.LogLevel;
-import org.apache.isis.viewer.scimpi.dispatcher.view.debug.Members;
-import org.apache.isis.viewer.scimpi.dispatcher.view.debug.ShowDebug;
-import org.apache.isis.viewer.scimpi.dispatcher.view.debug.Specification;
-import org.apache.isis.viewer.scimpi.dispatcher.view.debug.ThrowException;
-import org.apache.isis.viewer.scimpi.dispatcher.view.display.AddMessage;
-import org.apache.isis.viewer.scimpi.dispatcher.view.display.AddWarning;
-import org.apache.isis.viewer.scimpi.dispatcher.view.display.Errors;
-import org.apache.isis.viewer.scimpi.dispatcher.view.display.Feedback;
-import org.apache.isis.viewer.scimpi.dispatcher.view.display.FieldLabel;
-import org.apache.isis.viewer.scimpi.dispatcher.view.display.FieldValue;
-import org.apache.isis.viewer.scimpi.dispatcher.view.display.GetField;
-import org.apache.isis.viewer.scimpi.dispatcher.view.display.IncludeObject;
-import org.apache.isis.viewer.scimpi.dispatcher.view.display.ListView;
-import org.apache.isis.viewer.scimpi.dispatcher.view.display.LongFormView;
-import org.apache.isis.viewer.scimpi.dispatcher.view.display.Messages;
-import org.apache.isis.viewer.scimpi.dispatcher.view.display.SelectedObject;
-import org.apache.isis.viewer.scimpi.dispatcher.view.display.ShortFormView;
-import org.apache.isis.viewer.scimpi.dispatcher.view.display.TableBuilder;
-import org.apache.isis.viewer.scimpi.dispatcher.view.display.TableCell;
-import org.apache.isis.viewer.scimpi.dispatcher.view.display.TableEmpty;
-import org.apache.isis.viewer.scimpi.dispatcher.view.display.TableHeader;
-import org.apache.isis.viewer.scimpi.dispatcher.view.display.TableRow;
-import org.apache.isis.viewer.scimpi.dispatcher.view.display.TableView;
-import org.apache.isis.viewer.scimpi.dispatcher.view.display.Title;
-import org.apache.isis.viewer.scimpi.dispatcher.view.display.Warnings;
-import org.apache.isis.viewer.scimpi.dispatcher.view.edit.EditObject;
-import org.apache.isis.viewer.scimpi.dispatcher.view.edit.FormEntry;
-import org.apache.isis.viewer.scimpi.dispatcher.view.edit.FormField;
-import org.apache.isis.viewer.scimpi.dispatcher.view.edit.HiddenField;
-import org.apache.isis.viewer.scimpi.dispatcher.view.edit.RadioListField;
-import org.apache.isis.viewer.scimpi.dispatcher.view.edit.Selector;
-import org.apache.isis.viewer.scimpi.dispatcher.view.field.ExcludeField;
-import org.apache.isis.viewer.scimpi.dispatcher.view.field.IncludeField;
-import org.apache.isis.viewer.scimpi.dispatcher.view.field.LinkField;
-import org.apache.isis.viewer.scimpi.dispatcher.view.logon.Logoff;
-import org.apache.isis.viewer.scimpi.dispatcher.view.logon.Logon;
-import org.apache.isis.viewer.scimpi.dispatcher.view.logon.RestrictAccess;
-import org.apache.isis.viewer.scimpi.dispatcher.view.logon.Secure;
-import org.apache.isis.viewer.scimpi.dispatcher.view.logon.User;
-import org.apache.isis.viewer.scimpi.dispatcher.view.simple.BlockDefine;
-import org.apache.isis.viewer.scimpi.dispatcher.view.simple.BlockUse;
-import org.apache.isis.viewer.scimpi.dispatcher.view.simple.Commit;
-import org.apache.isis.viewer.scimpi.dispatcher.view.simple.ContentTag;
-import org.apache.isis.viewer.scimpi.dispatcher.view.simple.CookieValue;
-import org.apache.isis.viewer.scimpi.dispatcher.view.simple.DefaultValue;
-import org.apache.isis.viewer.scimpi.dispatcher.view.simple.EditLink;
-import org.apache.isis.viewer.scimpi.dispatcher.view.simple.EndSession;
-import org.apache.isis.viewer.scimpi.dispatcher.view.simple.Forward;
-import org.apache.isis.viewer.scimpi.dispatcher.view.simple.GetCookie;
-import org.apache.isis.viewer.scimpi.dispatcher.view.simple.Import;
-import org.apache.isis.viewer.scimpi.dispatcher.view.simple.InitializeFromCookie;
-import org.apache.isis.viewer.scimpi.dispatcher.view.simple.InitializeFromResult;
-import org.apache.isis.viewer.scimpi.dispatcher.view.simple.Localization;
-import org.apache.isis.viewer.scimpi.dispatcher.view.simple.Mark;
-import org.apache.isis.viewer.scimpi.dispatcher.view.simple.NewActionLink;
-import org.apache.isis.viewer.scimpi.dispatcher.view.simple.ObjectLink;
-import org.apache.isis.viewer.scimpi.dispatcher.view.simple.PageTitle;
-import org.apache.isis.viewer.scimpi.dispatcher.view.simple.Redirect;
-import org.apache.isis.viewer.scimpi.dispatcher.view.simple.RemoveElement;
-import org.apache.isis.viewer.scimpi.dispatcher.view.simple.ScopeTag;
-import org.apache.isis.viewer.scimpi.dispatcher.view.simple.SetCookie;
-import org.apache.isis.viewer.scimpi.dispatcher.view.simple.SetCookieFromField;
-import org.apache.isis.viewer.scimpi.dispatcher.view.simple.SetFieldFromCookie;
-import org.apache.isis.viewer.scimpi.dispatcher.view.simple.SetLocalization;
-import org.apache.isis.viewer.scimpi.dispatcher.view.simple.SimpleButton;
-import org.apache.isis.viewer.scimpi.dispatcher.view.simple.StartSession;
-import org.apache.isis.viewer.scimpi.dispatcher.view.simple.TemplateTag;
-import org.apache.isis.viewer.scimpi.dispatcher.view.simple.Unless;
-import org.apache.isis.viewer.scimpi.dispatcher.view.simple.Variable;
-import org.apache.isis.viewer.scimpi.dispatcher.view.simple.When;
-import org.apache.isis.viewer.scimpi.dispatcher.view.value.ActionName;
-import org.apache.isis.viewer.scimpi.dispatcher.view.value.CountElements;
-import org.apache.isis.viewer.scimpi.dispatcher.view.value.ElementType;
-import org.apache.isis.viewer.scimpi.dispatcher.view.value.FieldName;
-import org.apache.isis.viewer.scimpi.dispatcher.view.value.ParameterName;
-import org.apache.isis.viewer.scimpi.dispatcher.view.value.TitleString;
-import org.apache.isis.viewer.scimpi.dispatcher.view.value.Type;
public class ProcessorLookup {
private final Map<String, ElementProcessor> swfElementProcessors = new HashMap<String, ElementProcessor>();
- public void init() {
- addElementProcessor(new ActionLink());
- addElementProcessor(new ActionButton());
- addElementProcessor(new ActionForm());
- addElementProcessor(new ActionName());
- addElementProcessor(new AddMessage());
- addElementProcessor(new AddWarning());
- addElementProcessor(new BlockDefine());
- addElementProcessor(new BlockUse());
- addElementProcessor(new History());
- addElementProcessor(new Collection());
- addElementProcessor(new Commit());
- addElementProcessor(new ContentTag());
- addElementProcessor(new CountElements());
- addElementProcessor(new Diagnostics());
- addElementProcessor(new DebugAccessCheck());
- addElementProcessor(new DebugCollectionView());
- addElementProcessor(new DebuggerLink());
- addElementProcessor(new DebugObjectView());
- addElementProcessor(new DebugUsersView());
- addElementProcessor(new DefaultValue());
- addElementProcessor(new EditLink());
- addElementProcessor(new EditObject());
- addElementProcessor(new ElementType());
- addElementProcessor(new Errors());
- addElementProcessor(new ErrorDetails());
- addElementProcessor(new ErrorMessage());
- addElementProcessor(new ErrorReference());
- addElementProcessor(new ExcludeField());
- addElementProcessor(new Feedback());
- addElementProcessor(new FieldLabel());
- addElementProcessor(new FieldName());
- addElementProcessor(new FieldValue());
- addElementProcessor(new FormField());
- addElementProcessor(new FormEntry());
- addElementProcessor(new Forward());
- addElementProcessor(new GetField());
- addElementProcessor(new HelpLink());
- addElementProcessor(new HiddenField());
- addElementProcessor(new Import());
- addElementProcessor(new IncludeObject());
- addElementProcessor(new IncludeField());
- addElementProcessor(new InitializeFromCookie());
- addElementProcessor(new InitializeFromResult());
- addElementProcessor(new Log());
- addElementProcessor(new LogLevel());
- addElementProcessor(new Logon());
- addElementProcessor(new Logoff());
- addElementProcessor(new LongFormView());
- addElementProcessor(new LinkField());
- addElementProcessor(new ListView());
- addElementProcessor(new NewActionLink());
- addElementProcessor(new Mark());
- addElementProcessor(new Members());
- addElementProcessor(new Messages());
- addElementProcessor(new Methods());
- addElementProcessor(new ObjectLink());
- addElementProcessor(new PageTitle());
- addElementProcessor(new Parameter());
- addElementProcessor(new ParameterName());
- addElementProcessor(new RadioListField());
- addElementProcessor(new Redirect());
- addElementProcessor(new RemoveElement());
- addElementProcessor(new VersionNumber());
- addElementProcessor(new RunAction());
- addElementProcessor(new RestrictAccess());
- addElementProcessor(new ScopeTag());
- addElementProcessor(new Secure());
- addElementProcessor(new SelectedObject());
- addElementProcessor(new Selector());
- addElementProcessor(new Services());
- addElementProcessor(new ShortFormView());
- addElementProcessor(new ShowDebug());
- addElementProcessor(new SimpleButton());
- addElementProcessor(new Specification());
- addElementProcessor(new TableCell());
- addElementProcessor(new TableView());
- addElementProcessor(new TableBuilder());
- addElementProcessor(new TableEmpty());
- addElementProcessor(new TableRow());
- addElementProcessor(new TableHeader());
- addElementProcessor(new TemplateTag());
- addElementProcessor(new Title());
- addElementProcessor(new TitleString());
- addElementProcessor(new ThrowException());
- addElementProcessor(new Type());
- addElementProcessor(new User());
- addElementProcessor(new Unless());
- addElementProcessor(new Variable());
- addElementProcessor(new Warnings());
- addElementProcessor(new When());
-
- addElementProcessor(new StartSession());
- addElementProcessor(new EndSession());
-
- addElementProcessor(new CookieValue());
- addElementProcessor(new SetCookie());
- addElementProcessor(new GetCookie());
- addElementProcessor(new SetCookieFromField());
- addElementProcessor(new SetFieldFromCookie());
-
- // new, alpha, processors
- addElementProcessor(new Localization());
- addElementProcessor(new SetLocalization());
- }
-
public void addElementProcessor(final ElementProcessor action) {
swfElementProcessors.put("SWF:" + action.getName().toUpperCase(), action);
}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/Request.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/Request.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/Request.java
deleted file mode 100644
index 7bca665..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/Request.java
+++ /dev/null
@@ -1,323 +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.processor;
-
-import java.util.Stack;
-
-import org.apache.log4j.Logger;
-
-import org.apache.isis.viewer.scimpi.dispatcher.BlockContent;
-import org.apache.isis.viewer.scimpi.dispatcher.ElementProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.ScimpiException;
-import org.apache.isis.viewer.scimpi.dispatcher.action.Attributes;
-import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext;
-import org.apache.isis.viewer.scimpi.dispatcher.view.HtmlSnippet;
-import org.apache.isis.viewer.scimpi.dispatcher.view.Snippet;
-import org.apache.isis.viewer.scimpi.dispatcher.view.SwfTag;
-
-public class Request implements PageWriter {
-
- public class RepeatMarker {
- private final int index;
-
- private RepeatMarker(final int index) {
- this.index = index;
- }
-
- public void repeat() {
- Request.this.index = index;
- }
- }
-
- private static Logger LOG = Logger.getLogger(Request.class);
- public static final boolean ENSURE_VARIABLES_EXIST = true;
- public static final boolean NO_VARIABLE_CHECKING = false;
- private static Encoder encoder;
-
- public static Encoder getEncoder() {
- return encoder;
- }
-
- private final RequestContext context;
- private final Stack<Snippet> snippets;
- private final Stack<StringBuffer> buffers;
- private final Stack<BlockContent> blocks;
- private final ProcessorLookup processors;
- private int nextFormId;
- private int index = -1;
- private final String path;
-
- public Request(final String path, final RequestContext context, final Encoder encoder, final Stack<Snippet> snippets, final ProcessorLookup processors) {
- this.path = path;
- this.context = context;
- Request.encoder = encoder;
- this.snippets = snippets;
- this.processors = processors;
-
- buffers = new Stack<StringBuffer>();
- blocks = new Stack<BlockContent>();
- pushNewBuffer();
- }
-
- public void processNextTag() {
- while (index < snippets.size() - 1) {
- index++;
- final Snippet snippet = snippets.get(index);
- if (snippet instanceof HtmlSnippet) {
- appendSnippet((HtmlSnippet) snippet);
- } else {
- final SwfTag tag = (SwfTag) snippet;
- final String name = tag.getName();
- final ElementProcessor processor = processors.getFor(name);
- process(tag, processor);
- if (context.isAborted()) {
- return;
- }
- }
- }
- }
-
- private void appendSnippet(final HtmlSnippet snippet) {
- String html = snippet.getHtml();
- try {
- if (snippet.isContainsVariable()) {
- html = context.replaceVariables(html);
- }
- appendHtml(html);
- } catch (final TagProcessingException e) {
- throw e;
- } catch (final RuntimeException e) {
- final String replace = "<";
- final String withReplacement = "<";
- html = html.replaceAll(replace, withReplacement);
-
- throw new TagProcessingException("Error while processing html block at " + snippet.errorAt() + " - " + e.getMessage(), html, e);
- }
- }
-
- @Override
- public void appendAsHtmlEncoded(final String string) {
- appendHtml(encodeHtml(string));
- // appendHtml(string);
- }
-
- @Override
- public void appendHtml(final String html) {
- final StringBuffer buffer = buffers.peek();
- buffer.append(html);
- }
-
- public void appendDebug(final String line) {
- context.appendDebugTrace(encodeHtml(line));
- }
-
- private String encodeHtml(final String text) {
- return encoder.encoder(text);
- }
-
- public void appendTruncated(String text, final int truncateTo) {
- if (truncateTo > 0 && text.length() > truncateTo) {
- text = text.substring(0, truncateTo) + "...";
- }
- appendAsHtmlEncoded(text);
- }
-
- private void process(final SwfTag tag, final ElementProcessor processor) {
- try {
- LOG.debug("processing " + processor.getName() + " " + tag);
- appendDebug("\n" + tag.debug());
- if (tag.getType() == SwfTag.END) {
- throw new TagProcessingException(tag.errorAt() + " - end tag mistaken for a start tag", tag.toString());
- }
- processor.process(this);
- } catch (final TagProcessingException e) {
- throw e;
- } catch (final RuntimeException e) {
- throw new TagProcessingException("Error while processing " + tag.getName().toLowerCase() + " element at " + tag.errorAt() + " - " + e.getMessage(), tag.toString(), e);
- }
- }
-
- public void processUtilCloseTag() {
- final SwfTag tag = getTag();
- if (tag.getType() == SwfTag.EMPTY) {
- return;
- }
- while (index < snippets.size() - 1) {
- index++;
- final Snippet snippet = snippets.get(index);
- if (snippet instanceof HtmlSnippet) {
- appendSnippet((HtmlSnippet) snippet);
- } else {
- final SwfTag nextTag = (SwfTag) snippet;
- if (tag.getName().equals(nextTag.getName())) {
- if (nextTag.getType() == SwfTag.START) {
- } else {
- return;
- }
- }
- final String name = nextTag.getName();
- if (nextTag.getType() == SwfTag.END && !tag.getName().equals(name)) {
- throw new TagProcessingException("Expected " + nextTag.getName().toLowerCase() + " tag but found " + tag.getName().toLowerCase() + " tag at " + nextTag.errorAt(), tag.toString());
- }
- final ElementProcessor processor = processors.getFor(name);
- process(nextTag, processor);
- }
- }
- }
-
- public void skipUntilClose() {
- final SwfTag tag = getTag();
- if (tag.getType() == SwfTag.EMPTY) {
- if (context.isDebug()) {
- appendHtml("<!-- " + "skipped " + tag + " -->");
- }
- return;
- }
- int depth = 1;
- while (index < snippets.size() - 1) {
- index++;
- final Snippet snippet = snippets.get(index);
- if (snippet instanceof SwfTag) {
- final SwfTag nextTag = (SwfTag) snippet;
- if (tag.getName().equals(nextTag.getName())) {
- if (nextTag.getType() == SwfTag.START) {
- depth++;
- } else {
- depth--;
- if (depth == 0) {
- return;
- }
- }
- }
- }
- }
- }
-
- public void closeEmpty() {
- final SwfTag tag = getTag();
- if (tag.getType() == SwfTag.EMPTY) {
- return;
- }
- if (index < snippets.size()) {
- final Snippet snippet = snippets.get(index);
- if (snippet instanceof SwfTag) {
- final SwfTag nextTag = (SwfTag) snippet;
- if (nextTag.getType() == SwfTag.EMPTY) {
- return;
- }
- }
- }
- throw new ScimpiException("Empty tag not closed");
- }
-
- public void pushNewBuffer() {
- final StringBuffer buffer = new StringBuffer();
- buffers.push(buffer);
- }
-
- public String popBuffer() {
- final String content = buffers.pop().toString();
- return content;
- }
-
- public SwfTag getTag() {
- return (SwfTag) snippets.get(index);
- }
-
- public RequestContext getContext() {
- return context;
- }
-
- // TODO rename to pushBlock()
- public void setBlockContent(final BlockContent content) {
- blocks.add(content);
- }
-
- public BlockContent popBlockContent() {
- return blocks.pop();
- }
-
- public BlockContent getBlockContent() {
- return blocks.peek();
- }
-
- public String getViewPath() {
- return path;
- }
-
- public String nextFormId() {
- return String.valueOf(nextFormId++);
- }
-
- public String getOptionalProperty(final String name, final String defaultValue) {
- return getOptionalProperty(name, defaultValue, true);
- }
-
- public String getOptionalProperty(final String name, final String defaultValue, final boolean ensureVariablesExists) {
- final Attributes attributes = getTag().getAttributes();
- return attributes.getOptionalProperty(name, defaultValue, ensureVariablesExists);
- }
-
- public String getOptionalProperty(final String name) {
- return getOptionalProperty(name, true);
- }
-
- public String getOptionalProperty(final String name, final boolean ensureVariablesExists) {
- final Attributes attributes = getTag().getAttributes();
- return attributes.getOptionalProperty(name, ensureVariablesExists);
- }
-
- public Attributes getAttributes() {
- return getTag().getAttributes();
- }
-
- public String getRequiredProperty(final String name) {
- return getRequiredProperty(name, true);
- }
-
- public String getRequiredProperty(final String name, final boolean ensureVariablesExists) {
- final Attributes attributes = getTag().getAttributes();
- return attributes.getRequiredProperty(name, ensureVariablesExists);
- }
-
- public boolean isRequested(final String name) {
- final Attributes attributes = getTag().getAttributes();
- return attributes.isRequested(name);
- }
-
- public boolean isRequested(final String name, final boolean defaultValue) {
- final Attributes attributes = getTag().getAttributes();
- return attributes.isRequested(name, defaultValue);
- }
-
- public boolean isPropertySet(final String name) {
- final Attributes attributes = getTag().getAttributes();
- return attributes.isPropertySet(name);
- }
-
- public boolean isPropertySpecified(final String name) {
- final Attributes attributes = getTag().getAttributes();
- return attributes.isPropertySpecified(name);
- }
-
- public RepeatMarker createMarker() {
- return new RepeatMarker(index);
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/RequiredPropertyException.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/RequiredPropertyException.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/RequiredPropertyException.java
new file mode 100644
index 0000000..85e9a09
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/RequiredPropertyException.java
@@ -0,0 +1,43 @@
+/*
+ * 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.processor;
+
+import org.apache.isis.viewer.scimpi.ScimpiException;
+
+public class RequiredPropertyException extends ScimpiException {
+ private static final long serialVersionUID = 1L;
+
+ public RequiredPropertyException() {
+ super();
+ }
+
+ public RequiredPropertyException(final String message, final Throwable cause) {
+ super(message, cause);
+ }
+
+ public RequiredPropertyException(final String message) {
+ super(message);
+ }
+
+ public RequiredPropertyException(final Throwable cause) {
+ super(cause);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/Snippet.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/Snippet.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/Snippet.java
new file mode 100644
index 0000000..9622fe4
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/Snippet.java
@@ -0,0 +1,27 @@
+/*
+ * 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.processor;
+
+public interface Snippet {
+
+ String getHtml();
+
+ String errorAt();
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/SwfTag.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/SwfTag.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/SwfTag.java
new file mode 100644
index 0000000..dd86d2b
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/SwfTag.java
@@ -0,0 +1,89 @@
+/*
+ * 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.processor;
+
+
+public class SwfTag implements Snippet {
+
+ public static final int END = 0;
+ public static final int EMPTY = 1;
+ public static final int START = 2;
+ private final String tagName;
+ private final int type;
+ private final Attributes attributes;
+ private final String lineNumbers;
+ private final String path;
+
+ public SwfTag(final String tagName, final Attributes attributes, final int type, final String lineNumbers, final String path) {
+ this.tagName = tagName;
+ this.attributes = attributes;
+ this.type = type;
+ this.lineNumbers = lineNumbers;
+ this.path = path;
+ }
+
+ @Override
+ public String getHtml() {
+ return tagName;
+ }
+
+ public String getPath() {
+ return path;
+ }
+
+ public int getType() {
+ return type;
+ }
+
+ public String getName() {
+ return tagName;
+ }
+
+ public Attributes getAttributes() {
+ return attributes;
+ }
+
+ @Override
+ public String errorAt() {
+ return path + ":" + lineNumbers;
+ }
+
+ public String debug() {
+ return path + ":" + lineNumbers + " - " + getAttributes();
+ }
+
+ @Override
+ public String toString() {
+ String t = null;
+ switch (type) {
+ case EMPTY:
+ t = "empty";
+ break;
+ case START:
+ t = "start";
+ break;
+ case END:
+ t = "end";
+ break;
+ }
+ return "SwfTag[name=" + tagName + ",path=" + path + ",line=" + lineNumbers + ",type=" + t + "]";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/TagProcessingException.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/TagProcessingException.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/TagProcessingException.java
index d9a8a60..4c0ae6a 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/TagProcessingException.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/TagProcessingException.java
@@ -19,7 +19,7 @@
package org.apache.isis.viewer.scimpi.dispatcher.processor;
-import org.apache.isis.viewer.scimpi.dispatcher.ScimpiException;
+import org.apache.isis.viewer.scimpi.ScimpiException;
public class TagProcessingException extends ScimpiException {
private static final long serialVersionUID = 1L;
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/TagProcessor.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/TagProcessor.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/TagProcessor.java
new file mode 100644
index 0000000..8caf2a5
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/TagProcessor.java
@@ -0,0 +1,317 @@
+/*
+ * 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.processor;
+
+import java.util.Stack;
+
+import org.apache.log4j.Logger;
+
+import org.apache.isis.viewer.scimpi.ScimpiException;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+
+public class TagProcessor implements PageWriter {
+
+ public class RepeatMarker {
+ private final int index;
+
+ private RepeatMarker(final int index) {
+ this.index = index;
+ }
+
+ public void repeat() {
+ TagProcessor.this.index = index;
+ }
+ }
+
+ private static Logger LOG = Logger.getLogger(TagProcessor.class);
+ public static final boolean ENSURE_VARIABLES_EXIST = true;
+ public static final boolean NO_VARIABLE_CHECKING = false;
+ private static Encoder encoder;
+
+ public static Encoder getEncoder() {
+ return encoder;
+ }
+
+ private final Request context;
+ private final Stack<Snippet> snippets;
+ private final Stack<StringBuffer> buffers;
+ private final Stack<BlockContent> blocks;
+ private final ProcessorLookup processors;
+ private int nextFormId;
+ private int index = -1;
+ private final String path;
+
+ public TagProcessor(final String path, final Request context, final Encoder encoder, final Stack<Snippet> snippets, final ProcessorLookup processors) {
+ this.path = path;
+ this.context = context;
+ TagProcessor.encoder = encoder;
+ this.snippets = snippets;
+ this.processors = processors;
+
+ buffers = new Stack<StringBuffer>();
+ blocks = new Stack<BlockContent>();
+ pushNewBuffer();
+ }
+
+ public void processNextTag() {
+ while (index < snippets.size() - 1) {
+ index++;
+ final Snippet snippet = snippets.get(index);
+ if (snippet instanceof HtmlSnippet) {
+ appendSnippet((HtmlSnippet) snippet);
+ } else {
+ final SwfTag tag = (SwfTag) snippet;
+ final String name = tag.getName();
+ final ElementProcessor processor = processors.getFor(name);
+ process(tag, processor);
+ if (context.isAborted()) {
+ return;
+ }
+ }
+ }
+ }
+
+ private void appendSnippet(final HtmlSnippet snippet) {
+ String html = snippet.getHtml();
+ try {
+ if (snippet.isContainsVariable()) {
+ html = context.replaceVariables(html);
+ }
+ appendHtml(html);
+ } catch (final TagProcessingException e) {
+ throw e;
+ } catch (final RuntimeException e) {
+ final String replace = "<";
+ final String withReplacement = "<";
+ html = html.replaceAll(replace, withReplacement);
+
+ throw new TagProcessingException("Error while processing html block at " + snippet.errorAt() + " - " + e.getMessage(), html, e);
+ }
+ }
+
+ @Override
+ public void appendAsHtmlEncoded(final String string) {
+ appendHtml(encodeHtml(string));
+ // appendHtml(string);
+ }
+
+ @Override
+ public void appendHtml(final String html) {
+ final StringBuffer buffer = buffers.peek();
+ buffer.append(html);
+ }
+
+ public void appendDebug(final String line) {
+ context.appendDebugTrace(encodeHtml(line));
+ }
+
+ private String encodeHtml(final String text) {
+ return encoder.encoder(text);
+ }
+
+ public void appendTruncated(String text, final int truncateTo) {
+ if (truncateTo > 0 && text.length() > truncateTo) {
+ text = text.substring(0, truncateTo) + "...";
+ }
+ appendAsHtmlEncoded(text);
+ }
+
+ private void process(final SwfTag tag, final ElementProcessor processor) {
+ try {
+ LOG.debug("processing " + processor.getName() + " " + tag);
+ appendDebug("\n" + tag.debug());
+ if (tag.getType() == SwfTag.END) {
+ throw new TagProcessingException(tag.errorAt() + " - end tag mistaken for a start tag", tag.toString());
+ }
+ processor.process(this);
+ } catch (final TagProcessingException e) {
+ throw e;
+ } catch (final RuntimeException e) {
+ throw new TagProcessingException("Error while processing " + tag.getName().toLowerCase() + " element at " + tag.errorAt() + " - " + e.getMessage(), tag.toString(), e);
+ }
+ }
+
+ public void processUtilCloseTag() {
+ final SwfTag tag = getTag();
+ if (tag.getType() == SwfTag.EMPTY) {
+ return;
+ }
+ while (index < snippets.size() - 1) {
+ index++;
+ final Snippet snippet = snippets.get(index);
+ if (snippet instanceof HtmlSnippet) {
+ appendSnippet((HtmlSnippet) snippet);
+ } else {
+ final SwfTag nextTag = (SwfTag) snippet;
+ if (tag.getName().equals(nextTag.getName())) {
+ if (nextTag.getType() == SwfTag.START) {
+ } else {
+ return;
+ }
+ }
+ final String name = nextTag.getName();
+ if (nextTag.getType() == SwfTag.END && !tag.getName().equals(name)) {
+ throw new TagProcessingException("Expected " + nextTag.getName().toLowerCase() + " tag but found " + tag.getName().toLowerCase() + " tag at " + nextTag.errorAt(), tag.toString());
+ }
+ final ElementProcessor processor = processors.getFor(name);
+ process(nextTag, processor);
+ }
+ }
+ }
+
+ public void skipUntilClose() {
+ final SwfTag tag = getTag();
+ if (tag.getType() == SwfTag.EMPTY) {
+ if (context.isDebug()) {
+ appendHtml("<!-- " + "skipped " + tag + " -->");
+ }
+ return;
+ }
+ int depth = 1;
+ while (index < snippets.size() - 1) {
+ index++;
+ final Snippet snippet = snippets.get(index);
+ if (snippet instanceof SwfTag) {
+ final SwfTag nextTag = (SwfTag) snippet;
+ if (tag.getName().equals(nextTag.getName())) {
+ if (nextTag.getType() == SwfTag.START) {
+ depth++;
+ } else {
+ depth--;
+ if (depth == 0) {
+ return;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ public void closeEmpty() {
+ final SwfTag tag = getTag();
+ if (tag.getType() == SwfTag.EMPTY) {
+ return;
+ }
+ if (index < snippets.size()) {
+ final Snippet snippet = snippets.get(index);
+ if (snippet instanceof SwfTag) {
+ final SwfTag nextTag = (SwfTag) snippet;
+ if (nextTag.getType() == SwfTag.EMPTY) {
+ return;
+ }
+ }
+ }
+ throw new ScimpiException("Empty tag not closed");
+ }
+
+ public void pushNewBuffer() {
+ final StringBuffer buffer = new StringBuffer();
+ buffers.push(buffer);
+ }
+
+ public String popBuffer() {
+ final String content = buffers.pop().toString();
+ return content;
+ }
+
+ public SwfTag getTag() {
+ return (SwfTag) snippets.get(index);
+ }
+
+ public Request getContext() {
+ return context;
+ }
+
+ // TODO rename to pushBlock()
+ public void setBlockContent(final BlockContent content) {
+ blocks.add(content);
+ }
+
+ public BlockContent popBlockContent() {
+ return blocks.pop();
+ }
+
+ public BlockContent getBlockContent() {
+ return blocks.peek();
+ }
+
+ public String getViewPath() {
+ return path;
+ }
+
+ public String nextFormId() {
+ return String.valueOf(nextFormId++);
+ }
+
+ public String getOptionalProperty(final String name, final String defaultValue) {
+ return getOptionalProperty(name, defaultValue, true);
+ }
+
+ public String getOptionalProperty(final String name, final String defaultValue, final boolean ensureVariablesExists) {
+ final Attributes attributes = getTag().getAttributes();
+ return attributes.getOptionalProperty(name, defaultValue, ensureVariablesExists);
+ }
+
+ public String getOptionalProperty(final String name) {
+ return getOptionalProperty(name, true);
+ }
+
+ public String getOptionalProperty(final String name, final boolean ensureVariablesExists) {
+ final Attributes attributes = getTag().getAttributes();
+ return attributes.getOptionalProperty(name, ensureVariablesExists);
+ }
+
+ public Attributes getAttributes() {
+ return getTag().getAttributes();
+ }
+
+ public String getRequiredProperty(final String name) {
+ return getRequiredProperty(name, true);
+ }
+
+ public String getRequiredProperty(final String name, final boolean ensureVariablesExists) {
+ final Attributes attributes = getTag().getAttributes();
+ return attributes.getRequiredProperty(name, ensureVariablesExists);
+ }
+
+ public boolean isRequested(final String name) {
+ final Attributes attributes = getTag().getAttributes();
+ return attributes.isRequested(name);
+ }
+
+ public boolean isRequested(final String name, final boolean defaultValue) {
+ final Attributes attributes = getTag().getAttributes();
+ return attributes.isRequested(name, defaultValue);
+ }
+
+ public boolean isPropertySet(final String name) {
+ final Attributes attributes = getTag().getAttributes();
+ return attributes.isPropertySet(name);
+ }
+
+ public boolean isPropertySpecified(final String name) {
+ final Attributes attributes = getTag().getAttributes();
+ return attributes.isPropertySpecified(name);
+ }
+
+ public RepeatMarker createMarker() {
+ return new RepeatMarker(index);
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/structure/FieldEditState.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/structure/FieldEditState.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/structure/FieldEditState.java
new file mode 100644
index 0000000..1ccf2bb
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/structure/FieldEditState.java
@@ -0,0 +1,57 @@
+/*
+ * 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.structure;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+
+public class FieldEditState {
+ private final String entry;
+ private String reason;
+ private ObjectAdapter value;
+
+ public FieldEditState(final String entry) {
+ this.entry = entry;
+ }
+
+ public void setError(final String reason) {
+ this.reason = reason;
+ }
+
+ public boolean isEntryValid() {
+ return reason == null;
+ }
+
+ public String getEntry() {
+ return entry;
+ }
+
+ public String getError() {
+ return reason;
+ }
+
+ public ObjectAdapter getValue() {
+ return value;
+ }
+
+ public void setValue(final ObjectAdapter value) {
+ this.value = value;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/structure/FormState.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/structure/FormState.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/structure/FormState.java
new file mode 100644
index 0000000..589ee29
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/structure/FormState.java
@@ -0,0 +1,67 @@
+/*
+ * 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.structure;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+public class FormState {
+ private final Map<String, FieldEditState> fields = new HashMap<String, FieldEditState>();
+ private String error;
+ private String formId;
+
+ public FieldEditState createField(final String name, final String entry) {
+ final FieldEditState fieldEditState = new FieldEditState(entry);
+ fields.put(name, fieldEditState);
+ return fieldEditState;
+ }
+
+ public boolean isValid() {
+ final Iterator<FieldEditState> iterator = fields.values().iterator();
+ while (iterator.hasNext()) {
+ if (!iterator.next().isEntryValid()) {
+ return false;
+ }
+ }
+ return error == null;
+ }
+
+ public FieldEditState getField(final String name) {
+ return fields.get(name);
+ }
+
+ public void setError(final String error) {
+ this.error = error;
+ }
+
+ public String getError() {
+ return error;
+ }
+
+ public void setForm(final String formId) {
+ this.formId = formId;
+ }
+
+ public boolean isForForm(final String formId) {
+ return this.formId == null || this.formId.equals(formId);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/util/MethodsUtils.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/util/MethodsUtils.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/util/MethodsUtils.java
index 49bfd9f..5d66630 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/util/MethodsUtils.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/util/MethodsUtils.java
@@ -32,13 +32,12 @@ import org.apache.isis.core.metamodel.spec.ActionType;
import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
import org.apache.isis.core.metamodel.spec.feature.ObjectActionContainer.Contributed;
import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.core.runtime.system.persistence.AdapterManagerSpi;
import org.apache.isis.core.runtime.system.persistence.PersistenceSession;
import org.apache.isis.core.runtime.system.session.IsisSession;
-import org.apache.isis.viewer.scimpi.dispatcher.DispatchException;
-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.Names;
+import org.apache.isis.viewer.scimpi.ScimpiException;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
public class MethodsUtils {
public static final String SERVICE_PREFIX = "service:";
@@ -48,9 +47,9 @@ public class MethodsUtils {
return consent;
}
- public static boolean runMethod(final RequestContext context, final ObjectAction action, final ObjectAdapter target, final ObjectAdapter[] parameters, String variable, Scope scope) {
+ public static boolean runMethod(final Request context, final ObjectAction action, final ObjectAdapter target, final ObjectAdapter[] parameters, String variable, Scope scope) {
scope = scope == null ? Scope.REQUEST : scope;
- variable = variable == null ? RequestContext.RESULT : variable;
+ variable = variable == null ? Names.RESULT : variable;
final ObjectAdapter result = action.execute(target, parameters == null ? new ObjectAdapter[0] : parameters);
if (result == null) {
@@ -64,7 +63,7 @@ public class MethodsUtils {
}
}
- public static boolean runMethod(final RequestContext context, final ObjectAction action, final ObjectAdapter target, final ObjectAdapter[] parameters) {
+ public static boolean runMethod(final Request context, final ObjectAction action, final ObjectAdapter target, final ObjectAdapter[] parameters) {
return runMethod(context, action, target, parameters, null, null);
}
@@ -82,7 +81,7 @@ public class MethodsUtils {
* findAction(actions, methodName); }
*/
if (action == null) {
- throw new DispatchException("Failed to find action " + methodName + " on " + object);
+ throw new ScimpiException("Failed to find action " + methodName + " on " + object);
}
return action;
}
@@ -104,9 +103,9 @@ public class MethodsUtils {
return null;
}
- public static ObjectAdapter findObject(final RequestContext context, String objectId) {
+ public static ObjectAdapter findObject(final Request context, String objectId) {
if (objectId == null) {
- objectId = context.getStringVariable(RequestContext.RESULT);
+ objectId = context.getStringVariable(Names.RESULT);
}
if (objectId != null && objectId.startsWith(SERVICE_PREFIX)) {
@@ -119,7 +118,7 @@ public class MethodsUtils {
return adapter;
}
}
- throw new DispatchException("Failed to find service " + serviceId);
+ throw new ScimpiException("Failed to find service " + serviceId);
} else {
return context.getMappedObject(objectId);
}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/AbstractElementProcessor.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/AbstractElementProcessor.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/AbstractElementProcessor.java
new file mode 100644
index 0000000..4885128
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/AbstractElementProcessor.java
@@ -0,0 +1,58 @@
+/*
+ * 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;
+
+import org.apache.isis.core.commons.config.ConfigurationConstants;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.viewer.scimpi.Names;
+import org.apache.isis.viewer.scimpi.ScimpiException;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.ElementProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+
+public abstract class AbstractElementProcessor implements ElementProcessor, Names {
+
+ private static final String SHOW_ICONS_BY_DEFAULT = ConfigurationConstants.ROOT + "scimpi.show-icons";
+
+ private final boolean showIconByDefault;
+
+ public AbstractElementProcessor() {
+ showIconByDefault = IsisContext.getConfiguration().getBoolean(SHOW_ICONS_BY_DEFAULT, false);
+ }
+
+ /**
+ * Return the Class for the class specified in the type attribute.
+ */
+ protected Class<?> forClass(final TagProcessor tagProcessor) {
+ Class<?> cls = null;
+ final String className = tagProcessor.getOptionalProperty(TYPE);
+ if (className != null) {
+ try {
+ cls = Class.forName(className);
+ } catch (final ClassNotFoundException e) {
+ throw new ScimpiException("No class for " + className, e);
+ }
+ }
+ return cls;
+ }
+
+ protected boolean showIconByDefault() {
+ return showIconByDefault;
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/AbstractObjectProcessor.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/AbstractObjectProcessor.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/AbstractObjectProcessor.java
new file mode 100644
index 0000000..b430594
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/AbstractObjectProcessor.java
@@ -0,0 +1,55 @@
+/*
+ * 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;
+
+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.ScimpiException;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+
+public abstract class AbstractObjectProcessor extends AbstractElementProcessor {
+
+ @Override
+ public void process(final TagProcessor tagProcessor) {
+ final String id = tagProcessor.getOptionalProperty(OBJECT);
+ ObjectAdapter object = tagProcessor.getContext().getMappedObjectOrResult(id);
+
+ final String field = tagProcessor.getOptionalProperty(FIELD);
+ if (field != null) {
+ final ObjectAssociation objectField = object.getSpecification().getAssociation(field);
+ final String error = checkFieldType(objectField);
+ if (error != null) {
+ throw new ScimpiException("Field " + objectField.getId() + " " + error);
+ }
+ IsisContext.getPersistenceSession().resolveField(object, objectField);
+ object = objectField.get(object);
+ }
+
+ process(tagProcessor, object);
+ }
+
+ protected String checkFieldType(final ObjectAssociation objectField) {
+ return null;
+ }
+
+ protected abstract void process(TagProcessor tagProcessor, ObjectAdapter object);
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/HelpLink.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/HelpLink.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/HelpLink.java
deleted file mode 100644
index 477828d..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/HelpLink.java
+++ /dev/null
@@ -1,72 +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;
-
-import org.apache.isis.core.commons.config.ConfigurationConstants;
-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 HelpLink extends AbstractElementProcessor {
-
- private static String site;
- private static String suffix;
-
- public static void append(final Request request, final String description, final String helpReference) {
- request.appendHtml(createHelpSegment(description, helpReference));
- }
-
- public static String createHelpSegment(final String description, final String helpReference) {
- if (site == null) {
- site = IsisContext.getConfiguration().getString(ConfigurationConstants.ROOT + "scimpi.help-site", "/help/");
- }
- if (suffix == null) {
- suffix = IsisContext.getConfiguration().getString(ConfigurationConstants.ROOT + "scimpi.help-suffix", "shtml");
- if (suffix == null || suffix.equals("")) {
- suffix = "";
- } else {
- suffix = "." + suffix;
- }
- }
-
- if (helpReference == null || helpReference.equals("No help available")) {
- return "";
- } else {
- final String elementClass = "help-link";
- final String link = site + helpReference + suffix;
- final String linkText = "Help";
- final String target = "scimpi-help";
- final String titleSection = description == null ? "" : ("\" title=\"" + description);
- return "<a class=\"" + elementClass + "\" href=\"" + link + "\" target=\"" + target + titleSection + "\"><img src=\"/images/help.png\" alt=\"" + linkText + "\" /></a>";
- }
- }
-
- @Override
- public String getName() {
- return "help";
- }
-
- @Override
- public void process(final Request request) {
- final String description = null;
- final String helpReference = request.getRequiredProperty("ref");
- append(request, description, helpReference);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/History.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/History.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/History.java
deleted file mode 100644
index 2f2a9b7..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/History.java
+++ /dev/null
@@ -1,150 +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;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-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;
-import org.apache.isis.viewer.scimpi.dispatcher.util.MethodsUtils;
-
-public class History extends AbstractElementProcessor {
-
- private static final String _HISTORY = "_history";
-
- static class Crumb {
- String name;
- String link;
- }
-
- static class Crumbs implements Serializable {
- private static final long serialVersionUID = 1L;
- private static final int MAXIMUM_SIZE = 10;
- private final List<Crumb> crumbs = new ArrayList<Crumb>();
-
- public void add(final String name, final String link) {
- for (final Crumb crumb : crumbs) {
- if (crumb.link.equals(link)) {
- crumbs.remove(crumb);
- crumbs.add(crumb);
- return;
- }
- }
-
- final Crumb crumb = new Crumb();
- crumb.name = name;
- crumb.link = link;
- crumbs.add(crumb);
-
- if (crumbs.size() > MAXIMUM_SIZE) {
- crumbs.remove(0);
- }
- }
-
- public void clear() {
- crumbs.clear();
- }
-
- public boolean isEmpty() {
- return crumbs.size() == 0;
- }
-
- public int size() {
- return crumbs.size();
- }
-
- public Iterable<Crumb> iterator() {
- return crumbs;
- }
-
- }
-
- @Override
- public String getName() {
- return "history";
- }
-
- @Override
- public void process(final Request request) {
- final String action = request.getOptionalProperty("action", "display");
- final Crumbs crumbs = getCrumbs(request);
- if (action.equals("display") && crumbs != null) {
- write(crumbs, request);
- } else if (action.equals("link")) {
- final String name = request.getRequiredProperty(NAME);
- final String link = request.getRequiredProperty(LINK_VIEW);
- crumbs.add(name, link);
- } else if (action.equals("object")) {
- final String id = request.getOptionalProperty(OBJECT);
- final ObjectAdapter object = MethodsUtils.findObject(request.getContext(), id);
- final String name = object.titleString();
- String link = request.getRequiredProperty(LINK_VIEW);
- link += "?_result=" + id;
- crumbs.add(name, link);
- } else if (action.equals("return")) {
-
- } else if (action.equals("clear")) {
- crumbs.clear();
- }
-
- }
-
- public void write(final Crumbs crumbs, final Request request) {
- if (crumbs.isEmpty()) {
- return;
- }
-
- request.appendHtml("<div id=\"history\">");
- int i = 0;
- final int length = crumbs.size();
- for (final Crumb crumb : crumbs.iterator()) {
- final String link = crumb.link;
- if (i > 0) {
- request.appendHtml("<span class=\"separator\"> | </span>");
- }
- if (i == length - 1 || link == null) {
- request.appendHtml("<span class=\"disabled\">");
- request.appendHtml(crumb.name);
- request.appendHtml("</span>");
- } else {
- request.appendHtml("<a class=\"linked\" href=\"" + link + "\">");
- request.appendHtml(crumb.name);
- request.appendHtml("</a>");
- }
- i++;
- }
- request.appendHtml("</div>");
- }
-
- private Crumbs getCrumbs(final Request request) {
- final RequestContext context = request.getContext();
- Crumbs crumbs = (Crumbs) context.getVariable(_HISTORY);
- if (crumbs == null) {
- crumbs = new Crumbs();
- context.addVariable(_HISTORY, crumbs, Scope.SESSION);
- }
- return crumbs;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/HtmlSnippet.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/HtmlSnippet.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/HtmlSnippet.java
deleted file mode 100644
index f1807df..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/HtmlSnippet.java
+++ /dev/null
@@ -1,51 +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;
-
-public class HtmlSnippet implements Snippet {
- private final StringBuffer html = new StringBuffer();
- private boolean containsVariable;
- private final String lineNumbers;
- private final String path;
-
- public HtmlSnippet(final String lineNumbers, final String path) {
- this.lineNumbers = lineNumbers;
- this.path = path;
- }
-
- public void append(final String html) {
- this.html.append(html);
- containsVariable |= html.indexOf("${") >= 0;
- }
-
- @Override
- public String getHtml() {
- return html.toString();
- }
-
- public boolean isContainsVariable() {
- return containsVariable;
- }
-
- @Override
- public String errorAt() {
- return path + ":" + lineNumbers;
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/Snippet.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/Snippet.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/Snippet.java
deleted file mode 100644
index b8a7b3e..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/Snippet.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.viewer.scimpi.dispatcher.view;
-
-public interface Snippet {
-
- String getHtml();
-
- String errorAt();
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/SwfTag.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/SwfTag.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/SwfTag.java
deleted file mode 100644
index 6b097bb..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/SwfTag.java
+++ /dev/null
@@ -1,90 +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;
-
-import org.apache.isis.viewer.scimpi.dispatcher.action.Attributes;
-
-public class SwfTag implements Snippet {
-
- public static final int END = 0;
- public static final int EMPTY = 1;
- public static final int START = 2;
- private final String tagName;
- private final int type;
- private final Attributes attributes;
- private final String lineNumbers;
- private final String path;
-
- public SwfTag(final String tagName, final Attributes attributes, final int type, final String lineNumbers, final String path) {
- this.tagName = tagName;
- this.attributes = attributes;
- this.type = type;
- this.lineNumbers = lineNumbers;
- this.path = path;
- }
-
- @Override
- public String getHtml() {
- return tagName;
- }
-
- public String getPath() {
- return path;
- }
-
- public int getType() {
- return type;
- }
-
- public String getName() {
- return tagName;
- }
-
- public Attributes getAttributes() {
- return attributes;
- }
-
- @Override
- public String errorAt() {
- return path + ":" + lineNumbers;
- }
-
- public String debug() {
- return path + ":" + lineNumbers + " - " + getAttributes();
- }
-
- @Override
- public String toString() {
- String t = null;
- switch (type) {
- case EMPTY:
- t = "empty";
- break;
- case START:
- t = "start";
- break;
- case END:
- t = "end";
- break;
- }
- return "SwfTag[name=" + tagName + ",path=" + path + ",line=" + lineNumbers + ",type=" + t + "]";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/VersionNumber.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/VersionNumber.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/VersionNumber.java
deleted file mode 100644
index 6b054b1..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/VersionNumber.java
+++ /dev/null
@@ -1,70 +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;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-
-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.processor.Request;
-
-public class VersionNumber extends AbstractElementProcessor {
-
- private static final String MARKER = "Implementation-Build: ";
- private static final String FILE = "/META-INF/MANIFEST.MF";
- private String version;
-
- @Override
- public String getName() {
- return "version-number";
- }
-
- @Override
- public void process(final Request request) {
- if (version == null) {
- version = "0000"; // default revision number
- loadRevisonNumber(request.getContext());
- }
- request.appendHtml(version);
- }
-
- private void loadRevisonNumber(final RequestContext context) {
- BufferedReader reader;
- try {
- String file = FILE;
-
- file = context.findFile(FILE);
- reader = new BufferedReader(new InputStreamReader(context.openStream(file)));
- String line;
- while ((line = reader.readLine()) != null) {
- if (line.startsWith(MARKER)) {
- version = line.substring(MARKER.length());
- break;
- }
- }
- reader.close();
- } catch (final IOException e) {
- throw new ScimpiException(e);
- }
- }
-
-}
[23/24] Restructuring Scimpi to remove dependencies and enable easier
testing.
Posted by rm...@apache.org.
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/debug/DebugUsersView.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/debug/DebugUsersView.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/debug/DebugUsersView.java
deleted file mode 100644
index 3243d92..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/debug/DebugUsersView.java
+++ /dev/null
@@ -1,50 +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.debug;
-
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
-
-public class DebugUsersView extends AbstractElementProcessor {
-
- @Override
- public String getName() {
- return "debug-users";
- }
-
- @Override
- public void process(final TagProcessor tagProcessor) {
- final String view = tagProcessor.getContext().getContextPath() + tagProcessor.getContext().getResourceParentPath() + tagProcessor.getContext().getResourceFile();
-
- tagProcessor.appendHtml("<form class=\"generic action\" action=\"debug-user.app\" method=\"post\" accept-charset=\"ISO-8859-1\">\n");
- tagProcessor.appendHtml("<div class=\"title\">Add Debug User</div>\n");
- tagProcessor.appendHtml("<div class=\"field\"><label>User Name:</label><input type=\"text\" name=\"name\" size=\"30\" /></div>\n");
- tagProcessor.appendHtml("<input type=\"hidden\" name=\"method\" value=\"add\" />\n");
- tagProcessor.appendHtml("<input type=\"hidden\" name=\"view\" value=\"" + view + "\" />\n");
- tagProcessor.appendHtml("<input class=\"button\" type=\"submit\" value=\"Add User\" />\n");
- tagProcessor.appendHtml("</form>\n");
-
- tagProcessor.appendHtml("<table class=\"debug\">\n<tr><th class=\"title\">Name</th><th class=\"title\"></th></tr>\n");
- for (final String name : tagProcessor.getContext().getDebugUsers()) {
- tagProcessor.appendHtml("<tr><th>" + name + "</th><th><a href=\"debug-user.app?method=remove&name=" + name + "&view=" + view + " \">remove</a></th></tr>\n");
- }
- tagProcessor.appendHtml("</table>\n");
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/debug/ErrorDetails.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/debug/ErrorDetails.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/debug/ErrorDetails.java
deleted file mode 100644
index 0459390..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/debug/ErrorDetails.java
+++ /dev/null
@@ -1,35 +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.debug;
-
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
-
-
-public class ErrorDetails extends AbstractElementProcessor {
-
- public String getName() {
- return "error-details";
- }
-
- public void process(final TagProcessor tagProcessor) {
- tagProcessor.appendHtml(tagProcessor.getContext().getErrorDetails());
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/debug/ErrorMessage.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/debug/ErrorMessage.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/debug/ErrorMessage.java
deleted file mode 100644
index dfc48cf..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/debug/ErrorMessage.java
+++ /dev/null
@@ -1,35 +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.debug;
-
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
-
-
-public class ErrorMessage extends AbstractElementProcessor {
-
- public String getName() {
- return "error-message";
- }
-
- public void process(final TagProcessor tagProcessor) {
- tagProcessor.appendAsHtmlEncoded(tagProcessor.getContext().getErrorMessage());
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/debug/ErrorReference.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/debug/ErrorReference.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/debug/ErrorReference.java
deleted file mode 100644
index 49e0b24..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/debug/ErrorReference.java
+++ /dev/null
@@ -1,35 +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.debug;
-
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
-
-
-public class ErrorReference extends AbstractElementProcessor {
-
- public String getName() {
- return "error-reference";
- }
-
- public void process(final TagProcessor tagProcessor) {
- tagProcessor.appendAsHtmlEncoded(tagProcessor.getContext().getErrorReference());
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/form/FieldEditState.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/form/FieldEditState.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/form/FieldEditState.java
new file mode 100644
index 0000000..db13178
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/form/FieldEditState.java
@@ -0,0 +1,57 @@
+/*
+ * 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.form;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+
+public class FieldEditState {
+ private final String entry;
+ private String reason;
+ private ObjectAdapter value;
+
+ public FieldEditState(final String entry) {
+ this.entry = entry;
+ }
+
+ public void setError(final String reason) {
+ this.reason = reason;
+ }
+
+ public boolean isEntryValid() {
+ return reason == null;
+ }
+
+ public String getEntry() {
+ return entry;
+ }
+
+ public String getError() {
+ return reason;
+ }
+
+ public ObjectAdapter getValue() {
+ return value;
+ }
+
+ public void setValue(final ObjectAdapter value) {
+ this.value = value;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/form/FormState.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/form/FormState.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/form/FormState.java
new file mode 100644
index 0000000..2bc81ec
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/form/FormState.java
@@ -0,0 +1,67 @@
+/*
+ * 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.form;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+public class FormState {
+ private final Map<String, FieldEditState> fields = new HashMap<String, FieldEditState>();
+ private String error;
+ private String formId;
+
+ public FieldEditState createField(final String name, final String entry) {
+ final FieldEditState fieldEditState = new FieldEditState(entry);
+ fields.put(name, fieldEditState);
+ return fieldEditState;
+ }
+
+ public boolean isValid() {
+ final Iterator<FieldEditState> iterator = fields.values().iterator();
+ while (iterator.hasNext()) {
+ if (!iterator.next().isEntryValid()) {
+ return false;
+ }
+ }
+ return error == null;
+ }
+
+ public FieldEditState getField(final String name) {
+ return fields.get(name);
+ }
+
+ public void setError(final String error) {
+ this.error = error;
+ }
+
+ public String getError() {
+ return error;
+ }
+
+ public void setForm(final String formId) {
+ this.formId = formId;
+ }
+
+ public boolean isForForm(final String formId) {
+ return this.formId == null || this.formId.equals(formId);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/Attributes.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/Attributes.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/Attributes.java
deleted file mode 100644
index 86fd17e..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/Attributes.java
+++ /dev/null
@@ -1,132 +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.processor;
-
-import java.util.Enumeration;
-import java.util.Vector;
-
-import org.htmlparser.Attribute;
-import org.htmlparser.nodes.TagNode;
-
-import org.apache.isis.viewer.scimpi.dispatcher.context.PropertyException;
-import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
-
-public class Attributes {
- private static final String TRUE = " true yes on ";
- private static final String FALSE = " false no off ";
- private final TagNode tagNode;
- private final Request context;
-
- public Attributes(final TagNode tagNode, final Request context) {
- this.tagNode = tagNode;
- this.context = context;
- }
-
- public boolean isPropertySet(final String name) {
- final String attribute = tagNode.getAttribute(name);
- int end = attribute.length() - 1;
- final int pos = attribute.indexOf(':');
- end = pos == -1 ? end : pos;
- final String variabelName = attribute.substring(2, end);
- final Object value = context.getVariable(variabelName);
- return value != null;
- // return attribute != null &&
- // !context.replaceVariables(attribute).equals("");
- }
-
- public boolean isPropertySpecified(final String name) {
- final String attribute = tagNode.getAttribute(name);
- return attribute != null;
- }
-
- public String getOptionalProperty(final String name, final boolean ensureVariablesExists) {
- return getOptionalProperty(name, null, ensureVariablesExists);
- }
-
- public String getOptionalProperty(final String name, final String defaultValue, final boolean ensureVariablesExists) {
- final String attribute = tagNode.getAttribute(name);
- return attribute == null ? defaultValue : context.replaceVariables(attribute);
- }
-
- public String getRequiredProperty(final String name, final boolean ensureVariablesExists) {
- final String attribute = tagNode.getAttribute(name);
- if (attribute == null) {
- throw new RequiredPropertyException("Missing property: " + name);
- } else if (attribute.equals("")) {
- throw new RequiredPropertyException("Property not set: " + name);
- } else {
- return context.replaceVariables(attribute);
- }
- }
-
- public String[] getPropertyNames(final String excluding[]) {
- final Vector attributes = tagNode.getAttributesEx();
- final String[] names = new String[attributes.size()];
- int i = 0;
- names: for (final Enumeration e = attributes.elements(); e.hasMoreElements();) {
- final String name = ((Attribute) e.nextElement()).getName();
- if (name == null) {
- continue;
- }
- for (int j = 0; j < excluding.length; j++) {
- if (name.equals(excluding[j])) {
- continue names;
- }
- }
- if (tagNode.getAttribute(name) != null) {
- names[i++] = name;
- }
- }
-
- final String[] array = new String[i];
- System.arraycopy(names, 0, array, 0, i);
- return array;
- }
-
- @Override
- public String toString() {
- return tagNode.toHtml(); // getAttributesEx().toString();
- }
-
- public boolean isRequested(final String name) {
- return isRequested(name, false);
- }
-
- public boolean isRequested(final String name, final boolean defaultValue) {
- final String flag = getOptionalProperty(name, true);
- if (flag == null) {
- return defaultValue;
- } else {
- return isTrue(flag);
- }
- }
-
- public static boolean isTrue(final String flag) {
- final String value = " " + flag.toLowerCase().trim() + " ";
- if (TRUE.indexOf(value) >= 0) {
- return true;
- } else if (FALSE.indexOf(value) >= 0) {
- return false;
- } else {
- throw new PropertyException("Illegal flag value: " + flag);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/BlockContent.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/BlockContent.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/BlockContent.java
index 0d91bdf..561bf5e 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/BlockContent.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/BlockContent.java
@@ -19,5 +19,10 @@
package org.apache.isis.viewer.scimpi.dispatcher.processor;
+/**
+ * BlockContent is an interface that proides a way of sharing information bettween elements. A parent element
+ * creates content object of its particular type and the sub element then picks up that object to access or
+ * set the data.
+ */
public interface BlockContent {
}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/ElementContentProcessor.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/ElementContentProcessor.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/ElementContentProcessor.java
deleted file mode 100644
index 65e0bcf..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/ElementContentProcessor.java
+++ /dev/null
@@ -1,25 +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.processor;
-
-
-public interface ElementContentProcessor extends ElementProcessor {
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/ElementProcessor.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/ElementProcessor.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/ElementProcessor.java
index 37fa0e1..91605c0 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/ElementProcessor.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/ElementProcessor.java
@@ -19,11 +19,22 @@
package org.apache.isis.viewer.scimpi.dispatcher.processor;
+import org.apache.isis.viewer.scimpi.ScimpiContext;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+
public interface ElementProcessor {
+ /**
+ * The name of the tag for the element to be processed by this processor.
+ */
String getName();
- void process(TagProcessor tagProcessor);
+ /**
+ * Called during initialisation of the Scimpi framework to allow each processor to set itself up.
+ */
+ void init(ScimpiContext context);
+
+ void process(TemplateProcessor templateProcessor, RequestState state);
}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/ElementProcessorLookup.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/ElementProcessorLookup.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/ElementProcessorLookup.java
new file mode 100644
index 0000000..8fd7af4
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/ElementProcessorLookup.java
@@ -0,0 +1,57 @@
+/*
+ * 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.processor;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.TreeSet;
+
+import org.apache.isis.core.commons.debug.DebugBuilder;
+import org.apache.isis.viewer.scimpi.ScimpiContext;
+
+public class ElementProcessorLookup {
+ private final Map<String, ElementProcessor> swfElementProcessors = new HashMap<String, ElementProcessor>();
+ private final ScimpiContext context;
+
+ public ElementProcessorLookup(ScimpiContext context){
+ this.context = context;
+ }
+
+ public void addElementProcessor(final ElementProcessor action) {
+ action.init(context);
+ swfElementProcessors.put("SWF:" + action.getName().toUpperCase(), action);
+ }
+
+ public void debug(final DebugBuilder debug) {
+ debug.startSection("Recognised tags");
+ final Iterator<String> it2 = new TreeSet<String>(swfElementProcessors.keySet()).iterator();
+ while (it2.hasNext()) {
+ final String name = it2.next();
+ debug.appendln(name.toLowerCase(), swfElementProcessors.get(name));
+ }
+ debug.endSection();
+ }
+
+ public ElementProcessor getFor(final String name) {
+ return swfElementProcessors.get(name);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/Encoder.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/Encoder.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/Encoder.java
deleted file mode 100644
index 1efe91e..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/Encoder.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.viewer.scimpi.dispatcher.processor;
-
-public interface Encoder {
-
- String encoder(String text);
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/HtmlEncoder.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/HtmlEncoder.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/HtmlEncoder.java
new file mode 100644
index 0000000..ca9389e
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/HtmlEncoder.java
@@ -0,0 +1,26 @@
+/*
+ * 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.processor;
+
+public interface HtmlEncoder {
+
+ String encodeHtml(String text);
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/HtmlFileParser.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/HtmlFileParser.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/HtmlFileParser.java
index 354af87..fd98c6d 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/HtmlFileParser.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/HtmlFileParser.java
@@ -38,9 +38,9 @@ import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
public class HtmlFileParser {
private static final Logger LOG = Logger.getLogger(HtmlFileParser.class);
- private final ProcessorLookup processors;
+ private final ElementProcessorLookup processors;
- public HtmlFileParser(final ProcessorLookup processors) {
+ public HtmlFileParser(final ElementProcessorLookup processors) {
this.processors = processors;
}
@@ -90,7 +90,7 @@ public class HtmlFileParser {
// TODO remove context & request from Attributes -- the tags
// will be re-used across
// requests
- final Attributes attributes = new Attributes(tagNode, context);
+ final TagAttributes tagAttributes = new TagAttributes(tagNode, context);
int type = 0;
if (tagNode.isEndTag()) {
type = SwfTag.END;
@@ -99,7 +99,7 @@ public class HtmlFileParser {
}
testForProcessorForTag(lexer, tagName);
lineNumbers = lineNumbering(node);
- final SwfTag tag = new SwfTag(tagName, attributes, type, lineNumbers, loadFile.getCanonicalPath());
+ final SwfTag tag = new SwfTag(tagName, tagAttributes, type, lineNumbers, loadFile.getCanonicalPath());
tags.push(tag);
if (tagName.equals("SWF:IMPORT")) {
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/ProcessorLookup.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/ProcessorLookup.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/ProcessorLookup.java
deleted file mode 100644
index 132e1ac..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/ProcessorLookup.java
+++ /dev/null
@@ -1,50 +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.processor;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.TreeSet;
-
-import org.apache.isis.core.commons.debug.DebugBuilder;
-
-public class ProcessorLookup {
- private final Map<String, ElementProcessor> swfElementProcessors = new HashMap<String, ElementProcessor>();
-
- public void addElementProcessor(final ElementProcessor action) {
- swfElementProcessors.put("SWF:" + action.getName().toUpperCase(), action);
- }
-
- public void debug(final DebugBuilder debug) {
- debug.startSection("Recognised tags");
- final Iterator<String> it2 = new TreeSet<String>(swfElementProcessors.keySet()).iterator();
- while (it2.hasNext()) {
- final String name = it2.next();
- debug.appendln(name.toLowerCase(), swfElementProcessors.get(name));
- }
- debug.endSection();
- }
-
- public ElementProcessor getFor(final String name) {
- return swfElementProcessors.get(name);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/SimpleEncoder.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/SimpleEncoder.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/SimpleEncoder.java
deleted file mode 100644
index 8b7a2d5..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/SimpleEncoder.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.viewer.scimpi.dispatcher.processor;
-
-import org.apache.commons.lang.StringEscapeUtils;
-
-public class SimpleEncoder implements Encoder {
-
- @Override
- public String encoder(final String text) {
- return StringEscapeUtils.escapeHtml(text);
- // text.replace("&", "&").replaceAll("<", "<").replaceAll(">",
- // ">").replace("\"", """);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/Snippet.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/Snippet.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/Snippet.java
index 9622fe4..0f3a77a 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/Snippet.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/Snippet.java
@@ -19,6 +19,10 @@
package org.apache.isis.viewer.scimpi.dispatcher.processor;
+/**
+ * A Snippet is a part of the template and will either be segment of HTML, which can be output directly (after variable
+ * substitution, or a SWF (a Scimpi) element that will typically be replaced by generated HTML code.
+ */
public interface Snippet {
String getHtml();
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/SwfTag.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/SwfTag.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/SwfTag.java
index dd86d2b..6a6b34d 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/SwfTag.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/SwfTag.java
@@ -27,13 +27,13 @@ public class SwfTag implements Snippet {
public static final int START = 2;
private final String tagName;
private final int type;
- private final Attributes attributes;
+ private final TagAttributes tagAttributes;
private final String lineNumbers;
private final String path;
- public SwfTag(final String tagName, final Attributes attributes, final int type, final String lineNumbers, final String path) {
+ public SwfTag(final String tagName, final TagAttributes tagAttributes, final int type, final String lineNumbers, final String path) {
this.tagName = tagName;
- this.attributes = attributes;
+ this.tagAttributes = tagAttributes;
this.type = type;
this.lineNumbers = lineNumbers;
this.path = path;
@@ -56,8 +56,8 @@ public class SwfTag implements Snippet {
return tagName;
}
- public Attributes getAttributes() {
- return attributes;
+ public TagAttributes getAttributes() {
+ return tagAttributes;
}
@Override
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/TagAttributes.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/TagAttributes.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/TagAttributes.java
new file mode 100644
index 0000000..78a477b
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/TagAttributes.java
@@ -0,0 +1,137 @@
+/*
+ * 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.processor;
+
+import java.util.Enumeration;
+import java.util.Vector;
+
+import org.htmlparser.Attribute;
+import org.htmlparser.nodes.TagNode;
+
+import org.apache.isis.viewer.scimpi.dispatcher.context.PropertyException;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+
+/**
+ * All the attributes provided by a tag.
+ */
+public class TagAttributes {
+ private static final String TRUE = " true yes on ";
+ private static final String FALSE = " false no off ";
+ private final TagNode tagNode;
+// private final Request context;
+
+ public TagAttributes(final TagNode tagNode, final Request context) {
+ this.tagNode = tagNode;
+ // this.context = context;
+ }
+
+ public boolean isPropertySet(Request context, final String name) {
+ final String attribute = tagNode.getAttribute(name);
+ int end = attribute.length() - 1;
+ final int pos = attribute.indexOf(':');
+ end = pos == -1 ? end : pos;
+ final String variabelName = attribute.substring(2, end);
+ final Object value = context.getVariable(variabelName);
+ return value != null;
+ // return attribute != null &&
+ // !context.replaceVariables(attribute).equals("");
+ }
+
+ public boolean isPropertySpecified(final String name) {
+ final String attribute = tagNode.getAttribute(name);
+ return attribute != null;
+ }
+
+ public String getOptionalProperty(final String name, final boolean ensureVariablesExists) {
+ return getOptionalProperty(name, null, ensureVariablesExists);
+ }
+
+ public String getOptionalProperty(final String name, final String defaultValue, final boolean ensureVariablesExists) {
+ final String attribute = tagNode.getAttribute(name);
+ return attribute == null ? defaultValue : attribute;
+// return attribute == null ? defaultValue : context.replaceVariables(attribute);
+ }
+
+ public String getRequiredProperty(RequestState context, final String name, final boolean ensureVariablesExists) {
+ final String attribute = tagNode.getAttribute(name);
+ if (attribute == null) {
+ throw new RequiredPropertyException("Missing property: " + name);
+ } else if (attribute.equals("")) {
+ throw new RequiredPropertyException("Property not set: " + name);
+ } else {
+ return context.replaceVariables(attribute);
+ }
+ }
+
+ public String[] getPropertyNames(final String excluding[]) {
+ final Vector attributes = tagNode.getAttributesEx();
+ final String[] names = new String[attributes.size()];
+ int i = 0;
+ names: for (final Enumeration e = attributes.elements(); e.hasMoreElements();) {
+ final String name = ((Attribute) e.nextElement()).getName();
+ if (name == null) {
+ continue;
+ }
+ for (int j = 0; j < excluding.length; j++) {
+ if (name.equals(excluding[j])) {
+ continue names;
+ }
+ }
+ if (tagNode.getAttribute(name) != null) {
+ names[i++] = name;
+ }
+ }
+
+ final String[] array = new String[i];
+ System.arraycopy(names, 0, array, 0, i);
+ return array;
+ }
+
+ @Override
+ public String toString() {
+ return tagNode.toHtml(); // getAttributesEx().toString();
+ }
+
+ public boolean isRequested(final String name) {
+ return isRequested(name, false);
+ }
+
+ public boolean isRequested(final String name, final boolean defaultValue) {
+ final String flag = getOptionalProperty(name, true);
+ if (flag == null) {
+ return defaultValue;
+ } else {
+ return isTrue(flag);
+ }
+ }
+
+ public static boolean isTrue(final String flag) {
+ final String value = " " + flag.toLowerCase().trim() + " ";
+ if (TRUE.indexOf(value) >= 0) {
+ return true;
+ } else if (FALSE.indexOf(value) >= 0) {
+ return false;
+ } else {
+ throw new PropertyException("Illegal flag value: " + flag);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/TagOrderException.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/TagOrderException.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/TagOrderException.java
new file mode 100644
index 0000000..d7ebf43
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/TagOrderException.java
@@ -0,0 +1,31 @@
+/*
+ * 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.processor;
+
+import org.apache.isis.viewer.scimpi.ScimpiException;
+
+public class TagOrderException extends ScimpiException {
+ private static final long serialVersionUID = 1L;
+
+ public TagOrderException(final TemplateProcessor templateProcessor) {
+ super("Invalid tag in this context: " + templateProcessor.getTag().getName());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/TagProcessingException.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/TagProcessingException.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/TagProcessingException.java
deleted file mode 100644
index 4c0ae6a..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/TagProcessingException.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.viewer.scimpi.dispatcher.processor;
-
-import org.apache.isis.viewer.scimpi.ScimpiException;
-
-public class TagProcessingException extends ScimpiException {
- private static final long serialVersionUID = 1L;
- private String context;
-
- public TagProcessingException() {
- super();
- }
-
- public TagProcessingException(final String message, final String context, final Throwable cause) {
- super(message, cause);
- this.context = context;
- }
-
- public TagProcessingException(final String message, final String context) {
- super(message);
- this.context = context;
- }
-
- public TagProcessingException(final Throwable cause) {
- super(cause);
- }
-
- public String getContext() {
- return context;
- }
-
- @Override
- public String getMessage() {
- return super.getMessage() + "\n" + getContext();
- }
-
- @Override
- public String getHtmlMessage() {
- return super.getMessage() + "<pre>" + getContext() + "</pre>";
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/TagProcessor.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/TagProcessor.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/TagProcessor.java
deleted file mode 100644
index 8caf2a5..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/TagProcessor.java
+++ /dev/null
@@ -1,317 +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.processor;
-
-import java.util.Stack;
-
-import org.apache.log4j.Logger;
-
-import org.apache.isis.viewer.scimpi.ScimpiException;
-import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
-
-public class TagProcessor implements PageWriter {
-
- public class RepeatMarker {
- private final int index;
-
- private RepeatMarker(final int index) {
- this.index = index;
- }
-
- public void repeat() {
- TagProcessor.this.index = index;
- }
- }
-
- private static Logger LOG = Logger.getLogger(TagProcessor.class);
- public static final boolean ENSURE_VARIABLES_EXIST = true;
- public static final boolean NO_VARIABLE_CHECKING = false;
- private static Encoder encoder;
-
- public static Encoder getEncoder() {
- return encoder;
- }
-
- private final Request context;
- private final Stack<Snippet> snippets;
- private final Stack<StringBuffer> buffers;
- private final Stack<BlockContent> blocks;
- private final ProcessorLookup processors;
- private int nextFormId;
- private int index = -1;
- private final String path;
-
- public TagProcessor(final String path, final Request context, final Encoder encoder, final Stack<Snippet> snippets, final ProcessorLookup processors) {
- this.path = path;
- this.context = context;
- TagProcessor.encoder = encoder;
- this.snippets = snippets;
- this.processors = processors;
-
- buffers = new Stack<StringBuffer>();
- blocks = new Stack<BlockContent>();
- pushNewBuffer();
- }
-
- public void processNextTag() {
- while (index < snippets.size() - 1) {
- index++;
- final Snippet snippet = snippets.get(index);
- if (snippet instanceof HtmlSnippet) {
- appendSnippet((HtmlSnippet) snippet);
- } else {
- final SwfTag tag = (SwfTag) snippet;
- final String name = tag.getName();
- final ElementProcessor processor = processors.getFor(name);
- process(tag, processor);
- if (context.isAborted()) {
- return;
- }
- }
- }
- }
-
- private void appendSnippet(final HtmlSnippet snippet) {
- String html = snippet.getHtml();
- try {
- if (snippet.isContainsVariable()) {
- html = context.replaceVariables(html);
- }
- appendHtml(html);
- } catch (final TagProcessingException e) {
- throw e;
- } catch (final RuntimeException e) {
- final String replace = "<";
- final String withReplacement = "<";
- html = html.replaceAll(replace, withReplacement);
-
- throw new TagProcessingException("Error while processing html block at " + snippet.errorAt() + " - " + e.getMessage(), html, e);
- }
- }
-
- @Override
- public void appendAsHtmlEncoded(final String string) {
- appendHtml(encodeHtml(string));
- // appendHtml(string);
- }
-
- @Override
- public void appendHtml(final String html) {
- final StringBuffer buffer = buffers.peek();
- buffer.append(html);
- }
-
- public void appendDebug(final String line) {
- context.appendDebugTrace(encodeHtml(line));
- }
-
- private String encodeHtml(final String text) {
- return encoder.encoder(text);
- }
-
- public void appendTruncated(String text, final int truncateTo) {
- if (truncateTo > 0 && text.length() > truncateTo) {
- text = text.substring(0, truncateTo) + "...";
- }
- appendAsHtmlEncoded(text);
- }
-
- private void process(final SwfTag tag, final ElementProcessor processor) {
- try {
- LOG.debug("processing " + processor.getName() + " " + tag);
- appendDebug("\n" + tag.debug());
- if (tag.getType() == SwfTag.END) {
- throw new TagProcessingException(tag.errorAt() + " - end tag mistaken for a start tag", tag.toString());
- }
- processor.process(this);
- } catch (final TagProcessingException e) {
- throw e;
- } catch (final RuntimeException e) {
- throw new TagProcessingException("Error while processing " + tag.getName().toLowerCase() + " element at " + tag.errorAt() + " - " + e.getMessage(), tag.toString(), e);
- }
- }
-
- public void processUtilCloseTag() {
- final SwfTag tag = getTag();
- if (tag.getType() == SwfTag.EMPTY) {
- return;
- }
- while (index < snippets.size() - 1) {
- index++;
- final Snippet snippet = snippets.get(index);
- if (snippet instanceof HtmlSnippet) {
- appendSnippet((HtmlSnippet) snippet);
- } else {
- final SwfTag nextTag = (SwfTag) snippet;
- if (tag.getName().equals(nextTag.getName())) {
- if (nextTag.getType() == SwfTag.START) {
- } else {
- return;
- }
- }
- final String name = nextTag.getName();
- if (nextTag.getType() == SwfTag.END && !tag.getName().equals(name)) {
- throw new TagProcessingException("Expected " + nextTag.getName().toLowerCase() + " tag but found " + tag.getName().toLowerCase() + " tag at " + nextTag.errorAt(), tag.toString());
- }
- final ElementProcessor processor = processors.getFor(name);
- process(nextTag, processor);
- }
- }
- }
-
- public void skipUntilClose() {
- final SwfTag tag = getTag();
- if (tag.getType() == SwfTag.EMPTY) {
- if (context.isDebug()) {
- appendHtml("<!-- " + "skipped " + tag + " -->");
- }
- return;
- }
- int depth = 1;
- while (index < snippets.size() - 1) {
- index++;
- final Snippet snippet = snippets.get(index);
- if (snippet instanceof SwfTag) {
- final SwfTag nextTag = (SwfTag) snippet;
- if (tag.getName().equals(nextTag.getName())) {
- if (nextTag.getType() == SwfTag.START) {
- depth++;
- } else {
- depth--;
- if (depth == 0) {
- return;
- }
- }
- }
- }
- }
- }
-
- public void closeEmpty() {
- final SwfTag tag = getTag();
- if (tag.getType() == SwfTag.EMPTY) {
- return;
- }
- if (index < snippets.size()) {
- final Snippet snippet = snippets.get(index);
- if (snippet instanceof SwfTag) {
- final SwfTag nextTag = (SwfTag) snippet;
- if (nextTag.getType() == SwfTag.EMPTY) {
- return;
- }
- }
- }
- throw new ScimpiException("Empty tag not closed");
- }
-
- public void pushNewBuffer() {
- final StringBuffer buffer = new StringBuffer();
- buffers.push(buffer);
- }
-
- public String popBuffer() {
- final String content = buffers.pop().toString();
- return content;
- }
-
- public SwfTag getTag() {
- return (SwfTag) snippets.get(index);
- }
-
- public Request getContext() {
- return context;
- }
-
- // TODO rename to pushBlock()
- public void setBlockContent(final BlockContent content) {
- blocks.add(content);
- }
-
- public BlockContent popBlockContent() {
- return blocks.pop();
- }
-
- public BlockContent getBlockContent() {
- return blocks.peek();
- }
-
- public String getViewPath() {
- return path;
- }
-
- public String nextFormId() {
- return String.valueOf(nextFormId++);
- }
-
- public String getOptionalProperty(final String name, final String defaultValue) {
- return getOptionalProperty(name, defaultValue, true);
- }
-
- public String getOptionalProperty(final String name, final String defaultValue, final boolean ensureVariablesExists) {
- final Attributes attributes = getTag().getAttributes();
- return attributes.getOptionalProperty(name, defaultValue, ensureVariablesExists);
- }
-
- public String getOptionalProperty(final String name) {
- return getOptionalProperty(name, true);
- }
-
- public String getOptionalProperty(final String name, final boolean ensureVariablesExists) {
- final Attributes attributes = getTag().getAttributes();
- return attributes.getOptionalProperty(name, ensureVariablesExists);
- }
-
- public Attributes getAttributes() {
- return getTag().getAttributes();
- }
-
- public String getRequiredProperty(final String name) {
- return getRequiredProperty(name, true);
- }
-
- public String getRequiredProperty(final String name, final boolean ensureVariablesExists) {
- final Attributes attributes = getTag().getAttributes();
- return attributes.getRequiredProperty(name, ensureVariablesExists);
- }
-
- public boolean isRequested(final String name) {
- final Attributes attributes = getTag().getAttributes();
- return attributes.isRequested(name);
- }
-
- public boolean isRequested(final String name, final boolean defaultValue) {
- final Attributes attributes = getTag().getAttributes();
- return attributes.isRequested(name, defaultValue);
- }
-
- public boolean isPropertySet(final String name) {
- final Attributes attributes = getTag().getAttributes();
- return attributes.isPropertySet(name);
- }
-
- public boolean isPropertySpecified(final String name) {
- final Attributes attributes = getTag().getAttributes();
- return attributes.isPropertySpecified(name);
- }
-
- public RepeatMarker createMarker() {
- return new RepeatMarker(index);
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/TemplateProcessingException.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/TemplateProcessingException.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/TemplateProcessingException.java
new file mode 100644
index 0000000..c1c0ac1
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/TemplateProcessingException.java
@@ -0,0 +1,59 @@
+/*
+ * 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.processor;
+
+import org.apache.isis.viewer.scimpi.ScimpiException;
+
+public class TemplateProcessingException extends ScimpiException {
+ private static final long serialVersionUID = 1L;
+ private String context;
+
+ public TemplateProcessingException() {
+ super();
+ }
+
+ public TemplateProcessingException(final String message, final String context, final Throwable cause) {
+ super(message, cause);
+ this.context = context;
+ }
+
+ public TemplateProcessingException(final String message, final String context) {
+ super(message);
+ this.context = context;
+ }
+
+ public TemplateProcessingException(final Throwable cause) {
+ super(cause);
+ }
+
+ public String getContext() {
+ return context;
+ }
+
+ @Override
+ public String getMessage() {
+ return super.getMessage() + "\n" + getContext();
+ }
+
+ @Override
+ public String getHtmlMessage() {
+ return super.getMessage() + "<pre>" + getContext() + "</pre>";
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/TemplateProcessor.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/TemplateProcessor.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/TemplateProcessor.java
new file mode 100644
index 0000000..5097e7e
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/TemplateProcessor.java
@@ -0,0 +1,318 @@
+/*
+ * 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.processor;
+
+import java.util.Stack;
+
+import org.apache.log4j.Logger;
+
+import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.isis.viewer.scimpi.ScimpiException;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+
+public class TemplateProcessor implements PageWriter, HtmlEncoder {
+
+ public class RepeatMarker {
+ private final int index;
+
+ private RepeatMarker(final int index) {
+ this.index = index;
+ }
+
+ public void repeat() {
+ TemplateProcessor.this.index = index;
+ }
+ }
+
+ private static Logger LOG = Logger.getLogger(TemplateProcessor.class);
+ public static final boolean ENSURE_VARIABLES_EXIST = true;
+ public static final boolean NO_VARIABLE_CHECKING = false;
+
+ private final RequestState state;
+ private final Request context;
+ private final Stack<Snippet> snippets;
+ private final Stack<StringBuffer> buffers;
+ private final Stack<BlockContent> blocks;
+ private final ElementProcessorLookup processors;
+ private int nextFormId;
+ private int index = 0;
+ private final String path;
+
+ public TemplateProcessor(final String path, final RequestState state, final Request context, final Stack<Snippet> snippets, final ElementProcessorLookup processors) {
+ this.path = path;
+ this.state = state;
+ this.context = context;
+ this.snippets = snippets;
+ this.processors = processors;
+
+ buffers = new Stack<StringBuffer>();
+ blocks = new Stack<BlockContent>();
+ pushNewBuffer();
+ }
+
+ public void processNextTag() {
+ while (index < snippets.size() - 1) {
+ index++;
+ final Snippet snippet = snippets.get(index);
+ if (snippet instanceof HtmlSnippet) {
+ appendSnippet((HtmlSnippet) snippet);
+ } else {
+ final SwfTag tag = (SwfTag) snippet;
+ final String name = tag.getName();
+ final ElementProcessor processor = processors.getFor(name);
+ process(tag, processor);
+ if (context.isAborted()) {
+ return;
+ }
+ }
+ }
+ }
+
+ private void appendSnippet(final HtmlSnippet snippet) {
+ String html = snippet.getHtml();
+ try {
+ if (snippet.isContainsVariable()) {
+ html = context.replaceVariables(html);
+ }
+ appendHtml(html);
+ } catch (final TemplateProcessingException e) {
+ throw e;
+ } catch (final RuntimeException e) {
+ final String replace = "<";
+ final String withReplacement = "<";
+ html = html.replaceAll(replace, withReplacement);
+
+ throw new TemplateProcessingException("Error while processing html block at " + snippet.errorAt() + " - " + e.getMessage(), html, e);
+ }
+ }
+
+ @Override
+ public void appendAsHtmlEncoded(final String string) {
+ appendHtml(encodeHtml(string));
+ // appendHtml(string);
+ }
+
+ @Override
+ public void appendHtml(final String html) {
+ final StringBuffer buffer = buffers.peek();
+ buffer.append(html);
+ }
+
+ public void appendDebug(final String line) {
+ context.appendDebugTrace(encodeHtml(line));
+ }
+
+ public String encodeHtml(final String text) {
+ return StringEscapeUtils.escapeHtml(text);
+ }
+
+ public void appendTruncated(String text, final int truncateTo) {
+ if (truncateTo > 0 && text.length() > truncateTo) {
+ text = text.substring(0, truncateTo) + "...";
+ }
+ appendAsHtmlEncoded(text);
+ }
+
+ private void process(final SwfTag tag, final ElementProcessor processor) {
+ try {
+ LOG.debug("processing " + processor.getName() + " " + tag);
+ appendDebug("\n" + tag.debug());
+ if (tag.getType() == SwfTag.END) {
+ throw new TemplateProcessingException(tag.errorAt() + " - end tag mistaken for a start tag", tag.toString());
+ }
+ processor.process(this, state);
+ } catch (final TemplateProcessingException e) {
+ throw e;
+ } catch (final RuntimeException e) {
+ throw new TemplateProcessingException("Error while processing " + tag.getName().toLowerCase() + " element at " + tag.errorAt() + " - " + e.getMessage(), tag.toString(), e);
+ }
+ }
+
+ public void processUtilCloseTag() {
+ final SwfTag tag = getTag();
+ if (tag.getType() == SwfTag.EMPTY) {
+ return;
+ }
+ while (index < snippets.size() - 1) {
+ index++;
+ final Snippet snippet = snippets.get(index);
+ if (snippet instanceof HtmlSnippet) {
+ appendSnippet((HtmlSnippet) snippet);
+ } else {
+ final SwfTag nextTag = (SwfTag) snippet;
+ if (tag.getName().equals(nextTag.getName())) {
+ if (nextTag.getType() == SwfTag.START) {
+ } else {
+ return;
+ }
+ }
+ final String name = nextTag.getName();
+ if (nextTag.getType() == SwfTag.END && !tag.getName().equals(name)) {
+ throw new TemplateProcessingException("Expected " + nextTag.getName().toLowerCase() + " tag but found " + tag.getName().toLowerCase() + " tag at " + nextTag.errorAt(), tag.toString());
+ }
+ final ElementProcessor processor = processors.getFor(name);
+ process(nextTag, processor);
+ }
+ }
+ }
+
+ public void skipUntilClose() {
+ final SwfTag tag = getTag();
+ if (tag.getType() == SwfTag.EMPTY) {
+ if (context.isDebug()) {
+ appendHtml("<!-- " + "skipped " + tag + " -->");
+ }
+ return;
+ }
+ int depth = 1;
+ while (index < snippets.size() - 1) {
+ index++;
+ final Snippet snippet = snippets.get(index);
+ if (snippet instanceof SwfTag) {
+ final SwfTag nextTag = (SwfTag) snippet;
+ if (tag.getName().equals(nextTag.getName())) {
+ if (nextTag.getType() == SwfTag.START) {
+ depth++;
+ } else {
+ depth--;
+ if (depth == 0) {
+ return;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ public void closeEmpty() {
+ final SwfTag tag = getTag();
+ if (tag.getType() == SwfTag.EMPTY) {
+ return;
+ }
+ if (index < snippets.size()) {
+ final Snippet snippet = snippets.get(index);
+ if (snippet instanceof SwfTag) {
+ final SwfTag nextTag = (SwfTag) snippet;
+ if (nextTag.getType() == SwfTag.EMPTY) {
+ return;
+ }
+ }
+ }
+ throw new ScimpiException("Empty tag not closed");
+ }
+
+ public void pushNewBuffer() {
+ final StringBuffer buffer = new StringBuffer();
+ buffers.push(buffer);
+ }
+
+ public String popBuffer() {
+ final String content = buffers.pop().toString();
+ return content;
+ }
+
+ public SwfTag getTag() {
+ return (SwfTag) snippets.get(index);
+ }
+
+ public Request getContext() {
+ return context;
+ }
+
+ public void pushBlock(final BlockContent content) {
+ blocks.add(content);
+ }
+
+ public BlockContent popBlock() {
+ return blocks.pop();
+ }
+
+ public BlockContent peekBlock() {
+ return blocks.peek();
+ }
+
+ public String getViewPath() {
+ return path;
+ }
+
+ public String nextFormId() {
+ return String.valueOf(nextFormId++);
+ }
+
+ public String getOptionalProperty(final String name, final String defaultValue) {
+ return getOptionalProperty(name, defaultValue, true);
+ }
+
+ public String getOptionalProperty(final String name, final String defaultValue, final boolean ensureVariablesExists) {
+ final TagAttributes tagAttributes = getTag().getAttributes();
+// return tagAttributes.getOptionalProperty(name, defaultValue, ensureVariablesExists);
+ String attribute = tagAttributes.getOptionalProperty(name, defaultValue, ensureVariablesExists);
+ return attribute == null ? null : state.replaceVariables(attribute);
+ }
+
+ public String getOptionalProperty(final String name) {
+ return getOptionalProperty(name, true);
+ }
+
+ public String getOptionalProperty(final String name, final boolean ensureVariablesExists) {
+ final TagAttributes tagAttributes = getTag().getAttributes();
+ // return tagAttributes.getOptionalProperty(name, ensureVariablesExists);
+ String attribute = tagAttributes.getOptionalProperty(name, ensureVariablesExists);
+ return attribute == null ? null : state.replaceVariables(attribute);
+ }
+
+ public TagAttributes getAttributes() {
+ return getTag().getAttributes();
+ }
+
+ public String getRequiredProperty(final String name) {
+ return getRequiredProperty(name, true);
+ }
+
+ public String getRequiredProperty(final String name, final boolean ensureVariablesExists) {
+ final TagAttributes tagAttributes = getTag().getAttributes();
+ return tagAttributes.getRequiredProperty(state, name, ensureVariablesExists);
+ }
+
+ public boolean isRequested(final String name) {
+ final TagAttributes tagAttributes = getTag().getAttributes();
+ return tagAttributes.isRequested(name);
+ }
+
+ public boolean isRequested(final String name, final boolean defaultValue) {
+ final TagAttributes tagAttributes = getTag().getAttributes();
+ return tagAttributes.isRequested(name, defaultValue);
+ }
+
+ public boolean isPropertySet(final String name) {
+ final TagAttributes tagAttributes = getTag().getAttributes();
+ return tagAttributes.isPropertySet(context, name);
+ }
+
+ public boolean isPropertySpecified(final String name) {
+ final TagAttributes tagAttributes = getTag().getAttributes();
+ return tagAttributes.isPropertySpecified(name);
+ }
+
+ public RepeatMarker createMarker() {
+ return new RepeatMarker(index);
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/structure/FieldEditState.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/structure/FieldEditState.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/structure/FieldEditState.java
deleted file mode 100644
index 1ccf2bb..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/structure/FieldEditState.java
+++ /dev/null
@@ -1,57 +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.structure;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-
-public class FieldEditState {
- private final String entry;
- private String reason;
- private ObjectAdapter value;
-
- public FieldEditState(final String entry) {
- this.entry = entry;
- }
-
- public void setError(final String reason) {
- this.reason = reason;
- }
-
- public boolean isEntryValid() {
- return reason == null;
- }
-
- public String getEntry() {
- return entry;
- }
-
- public String getError() {
- return reason;
- }
-
- public ObjectAdapter getValue() {
- return value;
- }
-
- public void setValue(final ObjectAdapter value) {
- this.value = value;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/structure/FormState.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/structure/FormState.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/structure/FormState.java
deleted file mode 100644
index 589ee29..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/structure/FormState.java
+++ /dev/null
@@ -1,67 +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.structure;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-public class FormState {
- private final Map<String, FieldEditState> fields = new HashMap<String, FieldEditState>();
- private String error;
- private String formId;
-
- public FieldEditState createField(final String name, final String entry) {
- final FieldEditState fieldEditState = new FieldEditState(entry);
- fields.put(name, fieldEditState);
- return fieldEditState;
- }
-
- public boolean isValid() {
- final Iterator<FieldEditState> iterator = fields.values().iterator();
- while (iterator.hasNext()) {
- if (!iterator.next().isEntryValid()) {
- return false;
- }
- }
- return error == null;
- }
-
- public FieldEditState getField(final String name) {
- return fields.get(name);
- }
-
- public void setError(final String error) {
- this.error = error;
- }
-
- public String getError() {
- return error;
- }
-
- public void setForm(final String formId) {
- this.formId = formId;
- }
-
- public boolean isForForm(final String formId) {
- return this.formId == null || this.formId.equals(formId);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/util/MethodsUtils.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/util/MethodsUtils.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/util/MethodsUtils.java
index 5d66630..f63a3bd 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/util/MethodsUtils.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/util/MethodsUtils.java
@@ -38,6 +38,7 @@ import org.apache.isis.viewer.scimpi.Names;
import org.apache.isis.viewer.scimpi.ScimpiException;
import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
public class MethodsUtils {
public static final String SERVICE_PREFIX = "service:";
@@ -103,7 +104,7 @@ public class MethodsUtils {
return null;
}
- public static ObjectAdapter findObject(final Request context, String objectId) {
+ public static ObjectAdapter findObject(final RequestState context, String objectId) {
if (objectId == null) {
objectId = context.getStringVariable(Names.RESULT);
}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/util/UserManager.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/util/UserManager.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/util/UserManager.java
new file mode 100644
index 0000000..3fc1e10
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/util/UserManager.java
@@ -0,0 +1,89 @@
+/*
+ * 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.util;
+
+import org.apache.isis.core.commons.authentication.AnonymousSession;
+import org.apache.isis.core.commons.authentication.AuthenticationSession;
+import org.apache.isis.core.runtime.authentication.AuthenticationManager;
+import org.apache.isis.core.runtime.authentication.AuthenticationRequestPassword;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.log4j.Logger;
+
+public class UserManager {
+
+ private static final Logger LOG = Logger.getLogger(UserManager.class);
+ private static UserManager instance;
+
+ private static AuthenticationManager getAuthenticationManager() {
+ if (instance == null) {
+ throw new IllegalStateException("Server initialisation failed, or not defined as a context listener");
+ }
+ return instance.authenticationManager;
+ }
+
+ public static AuthenticationSession startRequest(final AuthenticationSession session) {
+ AuthenticationSession useSession;
+ if (session == null) {
+ useSession = new AnonymousSession();
+ LOG.debug("start anonymous request: " + session);
+ } else {
+ useSession = session;
+ LOG.debug("start request for: " + session.getUserName());
+ }
+ IsisContext.closeSession();
+ IsisContext.openSession(useSession);
+ return useSession;
+ }
+
+ public static AuthenticationSession authenticate(final AuthenticationRequestPassword passwordAuthenticationRequest) {
+ final AuthenticationSession session = getAuthenticationManager().authenticate(passwordAuthenticationRequest);
+ if (session != null) {
+ LOG.info("log on user " + session.getUserName());
+ IsisContext.closeSession();
+ IsisContext.openSession(session);
+ }
+ return session;
+ }
+
+ public static void endRequest(final AuthenticationSession session) {
+ if (session == null) {
+ LOG.debug("end anonymous request");
+ } else {
+ LOG.debug("end request for: " + session.getUserName());
+ }
+ IsisContext.closeSession();
+ }
+
+ public static void logoffUser(final AuthenticationSession session) {
+ LOG.info("log off user " + session.getUserName());
+ IsisContext.closeSession();
+ getAuthenticationManager().closeSession(session);
+
+ final AnonymousSession replacementSession = new AnonymousSession();
+ IsisContext.openSession(replacementSession);
+ }
+
+ private final AuthenticationManager authenticationManager;
+
+ public UserManager(final AuthenticationManager authenticationManager) {
+ this.authenticationManager = authenticationManager;
+ UserManager.instance = this;
+ }
+}
[15/24] Restructuring Scimpi to remove dependencies and enable easier
testing.
Posted by rm...@apache.org.
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/object/FieldValue.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/object/FieldValue.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/object/FieldValue.java
new file mode 100644
index 0000000..fda2559
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/object/FieldValue.java
@@ -0,0 +1,119 @@
+/*
+ * 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.object;
+
+import org.apache.isis.applib.annotation.Where;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facets.object.parseable.ParseableFacet;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
+import org.apache.isis.core.progmodel.facets.value.booleans.BooleanValueFacet;
+import org.apache.isis.core.runtime.persistence.ObjectNotFoundException;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.viewer.scimpi.ForbiddenException;
+import org.apache.isis.viewer.scimpi.ScimpiException;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.determine.LinkedObject;
+
+public class FieldValue extends AbstractElementProcessor {
+
+ // 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
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ final String className = templateProcessor.getOptionalProperty(CLASS);
+ final String id = templateProcessor.getOptionalProperty(OBJECT);
+ final String fieldName = templateProcessor.getRequiredProperty(FIELD);
+ final ObjectAdapter object = templateProcessor.getContext().getMappedObjectOrResult(id);
+ final ObjectAssociation field = object.getSpecification().getAssociation(fieldName);
+ if (field == null) {
+ throw new ScimpiException("No field " + fieldName + " in " + object.getSpecification().getFullIdentifier());
+ }
+ if (field.isVisible(IsisContext.getAuthenticationSession(), object, where).isVetoed()) {
+ throw new ForbiddenException(field, ForbiddenException.VISIBLE);
+ }
+ final boolean isIconShowing = templateProcessor.isRequested(SHOW_ICON, showIconByDefault());
+ final int truncateTo = Integer.valueOf(templateProcessor.getOptionalProperty(TRUNCATE, "0")).intValue();
+
+ write(templateProcessor, object, field, null, className, isIconShowing, truncateTo);
+ }
+
+ @Override
+ public String getName() {
+ return "field";
+ }
+
+ public static void write(final TemplateProcessor templateProcessor, final ObjectAdapter object, final ObjectAssociation field, final LinkedObject linkedField, final String className, final boolean showIcon, final int truncateTo) {
+
+ final ObjectAdapter fieldReference = field.get(object);
+
+ if (fieldReference != null) {
+ final String classSection = "class=\"" + (className == null ? "value" : className) + "\"";
+ templateProcessor.appendHtml("<span " + classSection + ">");
+ if (field.isOneToOneAssociation()) {
+ try {
+ IsisContext.getPersistenceSession().resolveImmediately(fieldReference);
+ } catch (final ObjectNotFoundException e) {
+ templateProcessor.appendHtml(e.getMessage() + "</span>");
+ }
+ }
+
+ if (!field.getSpecification().containsFacet(ParseableFacet.class) && showIcon) {
+ templateProcessor.appendHtml("<img class=\"small-icon\" src=\"" + templateProcessor.getContext().imagePath(fieldReference) + "\" alt=\"" + field.getSpecification().getShortIdentifier() + "\"/>");
+ }
+
+ if (linkedField != null) {
+ final String id = templateProcessor.getContext().mapObject(fieldReference, linkedField.getScope(), Scope.INTERACTION);
+ templateProcessor.appendHtml("<a href=\"" + linkedField.getForwardView() + "?" + linkedField.getVariable() + "=" + id + templateProcessor.getContext().encodedInteractionParameters() + "\">");
+ }
+ String value = fieldReference == null ? "" : fieldReference.titleString();
+ if (truncateTo > 0 && value.length() > truncateTo) {
+ value = value.substring(0, truncateTo) + "...";
+ }
+
+ // TODO figure out a better way to determine if boolean or a
+ // password
+ final ObjectSpecification spec = field.getSpecification();
+ final BooleanValueFacet facet = spec.getFacet(BooleanValueFacet.class);
+ if (facet != null) {
+ final boolean flag = facet.isSet(fieldReference);
+ final String valueSegment = flag ? " checked=\"checked\"" : "";
+ final String disabled = " disabled=\"disabled\"";
+ templateProcessor.appendHtml("<input type=\"checkbox\"" + valueSegment + disabled + " />");
+ } else {
+ templateProcessor.appendAsHtmlEncoded(value);
+ }
+
+ if (linkedField != null) {
+ templateProcessor.appendHtml("</a>");
+ }
+ templateProcessor.appendHtml("</span>");
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/object/GetField.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/object/GetField.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/object/GetField.java
new file mode 100644
index 0000000..25b2fa0
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/object/GetField.java
@@ -0,0 +1,104 @@
+/*
+ * 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.object;
+
+import java.text.DecimalFormat;
+import java.text.Format;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+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.spec.feature.ObjectAssociation;
+import org.apache.isis.core.progmodel.facets.value.date.DateValueFacet;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.viewer.scimpi.ForbiddenException;
+import org.apache.isis.viewer.scimpi.ScimpiException;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+public class GetField extends AbstractElementProcessor {
+
+ // 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
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ final String id = templateProcessor.getOptionalProperty(OBJECT);
+ final String fieldName = templateProcessor.getRequiredProperty(FIELD);
+ final ObjectAdapter object = templateProcessor.getContext().getMappedObjectOrResult(id);
+ if (object == null) {
+ throw new ScimpiException("No object to get field for: " + fieldName + " - " + id);
+ }
+ final ObjectAssociation field = object.getSpecification().getAssociation(fieldName);
+ if (field == null) {
+ throw new ScimpiException("No field " + fieldName + " in " + object.getSpecification().getFullIdentifier());
+ }
+ final AuthenticationSession session = IsisContext.getAuthenticationSession();
+ if (field.isVisible(session, object, where).isVetoed()) {
+ throw new ForbiddenException(field, ForbiddenException.VISIBLE);
+ }
+
+ String pattern = templateProcessor.getOptionalProperty("decimal-format");
+ Format format = null;
+ if (pattern != null) {
+ format = new DecimalFormat(pattern);
+ }
+ pattern = templateProcessor.getOptionalProperty("date-format");
+ if (pattern != null) {
+ format = new SimpleDateFormat(pattern);
+ }
+
+ final String name = templateProcessor.getOptionalProperty(RESULT_NAME, fieldName);
+ final String scopeName = templateProcessor.getOptionalProperty(SCOPE);
+ final Scope scope = Request.scope(scopeName, Scope.REQUEST);
+
+ process(templateProcessor, object, field, format, name, scope);
+ }
+
+ protected void process(final TemplateProcessor templateProcessor, final ObjectAdapter object, final ObjectAssociation field, final Format format, final String name, final Scope scope) {
+ final ObjectAdapter fieldReference = field.get(object);
+ if (format != null && fieldReference.isValue()) {
+ final DateValueFacet facet = fieldReference.getSpecification().getFacet(DateValueFacet.class);
+ final Date date = facet.dateValue(fieldReference);
+ final String value = format.format(date);
+ templateProcessor.appendDebug(" " + object + " -> " + value);
+ templateProcessor.getContext().addVariable(name, templateProcessor.encodeHtml(value), scope);
+ } else {
+ final String source = fieldReference == null ? "" : templateProcessor.getContext().mapObject(fieldReference, scope);
+ templateProcessor.appendDebug(" " + object + " -> " + source);
+ templateProcessor.getContext().addVariable(name, source, scope);
+ }
+ }
+
+ @Override
+ public String getName() {
+ return "get-field";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/object/IncludeObject.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/object/IncludeObject.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/object/IncludeObject.java
new file mode 100644
index 0000000..ff322bb
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/object/IncludeObject.java
@@ -0,0 +1,108 @@
+/*
+ * 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.object;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
+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.ForbiddenException;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+/**
+ * Element to include another file that will display an object.
+ */
+public class IncludeObject extends AbstractElementProcessor {
+
+ // 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
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ final String path = templateProcessor.getOptionalProperty("file");
+ String id = templateProcessor.getOptionalProperty(OBJECT);
+ final String fieldName = templateProcessor.getOptionalProperty(FIELD);
+ ObjectAdapter object = templateProcessor.getContext().getMappedObjectOrResult(id);
+ if (fieldName != null) {
+ final ObjectAssociation field = object.getSpecification().getAssociation(fieldName);
+ if (field.isVisible(IsisContext.getAuthenticationSession(), object, where).isVetoed()) {
+ throw new ForbiddenException(field, ForbiddenException.VISIBLE);
+ }
+ object = field.get(object);
+ id = templateProcessor.getContext().mapObject(object, Scope.REQUEST);
+ }
+
+ if (object != null) {
+ IsisContext.getPersistenceSession().resolveImmediately(object);
+ templateProcessor.getContext().addVariable("_object", id, Scope.REQUEST);
+ importFile(templateProcessor, path);
+ }
+ templateProcessor.closeEmpty();
+ }
+
+ private static void importFile(final TemplateProcessor templateProcessor, final String path) {
+ // TODO load in file via HtmlFileParser
+ final File file = new File(path);
+ BufferedReader reader = null;
+ try {
+ if (file.exists()) {
+ reader = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
+ String line;
+ while ((line = reader.readLine()) != null) {
+ templateProcessor.appendHtml(line);
+ }
+ } else {
+ templateProcessor.appendHtml("<P classs=\"error\">File " + path + " not found to import</P>");
+ }
+ } catch (final FileNotFoundException e) {
+ throw new RuntimeException(e);
+ } catch (final IOException e) {
+ throw new RuntimeException(e);
+ } finally {
+ if (reader != null) {
+ try {
+ reader.close();
+ } catch (final IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+ }
+
+ @Override
+ public String getName() {
+ return "include-object";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/object/LinkAbstract.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/object/LinkAbstract.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/object/LinkAbstract.java
new file mode 100644
index 0000000..0356e48
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/object/LinkAbstract.java
@@ -0,0 +1,122 @@
+/*
+ * 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.object;
+
+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.ForbiddenException;
+import org.apache.isis.viewer.scimpi.Names;
+import org.apache.isis.viewer.scimpi.ScimpiException;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.util.MethodsUtils;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+public abstract class LinkAbstract extends AbstractElementProcessor {
+
+ @Override
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ final String title = templateProcessor.getOptionalProperty(FORM_TITLE);
+ final String name = templateProcessor.getOptionalProperty(NAME);
+ final boolean showAsButton = templateProcessor.isRequested("show-as-button", false);
+ final String linkClass = templateProcessor.getOptionalProperty(CLASS, showAsButton ? "button" : defaultLinkClass());
+ final String containerClass = templateProcessor.getOptionalProperty(CONTAINER_CLASS, "action");
+ final String object = templateProcessor.getOptionalProperty(OBJECT);
+ final Request context = templateProcessor.getContext();
+ String objectId = object != null ? object : (String) context.getVariable(Names.RESULT);
+ ObjectAdapter adapter = MethodsUtils.findObject(context, objectId);
+
+ // REVIEW this is common used code
+ final String fieldName = templateProcessor.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);
+ }
+ IsisContext.getPersistenceSession().resolveField(adapter, field);
+ adapter = field.get(adapter);
+ if (adapter != null) {
+ objectId = context.mapObject(adapter, Scope.INTERACTION);
+ }
+ }
+
+ if (adapter != null && valid(templateProcessor, adapter)) {
+ final String variable = templateProcessor.getOptionalProperty("param-name", Names.RESULT);
+ final String variableSegment = variable + "=" + objectId;
+
+ String view = templateProcessor.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(templateProcessor);
+ additionalSegment = additionalSegment == null ? "" : "&" + additionalSegment;
+ if (showAsButton) {
+ templateProcessor.appendHtml("<div class=\"" + containerClass + "\">");
+ }
+ templateProcessor.appendHtml("<a" + classSegment + titleSegment + " href=\"" + view + "?" + variableSegment + context.encodedInteractionParameters() + additionalSegment + "\">");
+ templateProcessor.pushNewBuffer();
+ templateProcessor.processUtilCloseTag();
+ final String buffer = templateProcessor.popBuffer();
+ if (buffer.trim().length() > 0) {
+ templateProcessor.appendHtml(buffer);
+ } else {
+ templateProcessor.appendAsHtmlEncoded(linkLabel(name, adapter));
+ }
+ templateProcessor.appendHtml("</a>");
+ if (showAsButton) {
+ templateProcessor.appendHtml("</div>");
+ }
+ } else {
+ templateProcessor.skipUntilClose();
+ }
+ }
+
+ private String defaultLinkClass() {
+ return "action";
+ }
+
+ protected abstract String linkLabel(String name, ObjectAdapter object);
+
+ protected String additionalParameters(final TemplateProcessor templateProcessor) {
+ return null;
+ }
+
+ protected abstract boolean valid(TemplateProcessor templateProcessor, ObjectAdapter adapter);
+
+ protected abstract String defaultView();
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/object/LongViewForm.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/object/LongViewForm.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/object/LongViewForm.java
new file mode 100644
index 0000000..ac2678b
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/object/LongViewForm.java
@@ -0,0 +1,87 @@
+/*
+ * 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.object;
+
+import java.util.List;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociationFilters;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.collection.TableContentWriter;
+import org.apache.isis.viewer.scimpi.dispatcher.view.collection.TableView;
+import org.apache.isis.viewer.scimpi.dispatcher.view.collection.TableView.SimpleTableBuilder;
+import org.apache.isis.viewer.scimpi.dispatcher.view.determine.LinkedObject;
+
+public class LongViewForm extends ViewFormAbstract {
+
+ @Override
+ protected void addField(final TemplateProcessor templateProcessor, final ObjectAdapter object, final ObjectAssociation field, final LinkedObject linkedObject, final boolean showIcons) {
+ if (field.isOneToManyAssociation()) {
+ final String noColumnsString = templateProcessor.getOptionalProperty("no-columns", "3");
+ final String tableClass = templateProcessor.getOptionalProperty("table-class");
+ final String rowClassesList = templateProcessor.getOptionalProperty("row-classes", ODD_ROW_CLASS + "|" + EVEN_ROW_CLASS);
+ String[] rowClasses = new String[0];
+ if (rowClassesList != null) {
+ rowClasses = rowClassesList.split("[,|/]");
+ }
+ int noColumns;
+ IsisContext.getPersistenceSession().resolveField(object, field);
+ final ObjectAdapter collection = field.get(object);
+ final ObjectSpecification elementSpec = collection.getElementSpecification();
+ final List<ObjectAssociation> fields = elementSpec.getAssociations(ObjectAssociationFilters.WHEN_VISIBLE_IRRESPECTIVE_OF_WHERE);
+ if (noColumnsString.equalsIgnoreCase("all")) {
+ noColumns = fields.size();
+ } else {
+ noColumns = Math.min(fields.size(), Integer.valueOf(noColumnsString));
+ }
+ // final boolean isFieldEditable = field.isUsable(IsisContext.getAuthenticationSession(), object).isAllowed();
+ final String summary = "Table of elements in " + field.getName();
+ // TableView.write(request, summary, object, field, collection, noColumns, fields, isFieldEditable, showIconByDefault(), tableClass, rowClasses, linkedObject);
+
+
+ final String headers[] = new String[fields.size()];
+ int h = 0;
+ for (int i = 0; i < noColumns; i++) {
+ if (fields.get(i).isOneToManyAssociation()) {
+ continue;
+ }
+ headers[h++] = fields.get(i).getName();
+ }
+
+ final LinkedObject[] linkedFields = new LinkedObject[fields.size()];
+
+
+ final TableContentWriter rowBuilder =new SimpleTableBuilder(object.titleString(), true, false, "", noColumns, headers, fields, false,
+ showIcons, false, false, false, field.getName(), linkedFields, null);
+ TableView.write(templateProcessor, collection, summary, rowBuilder, null, tableClass, rowClasses);
+ } else {
+ super.addField(templateProcessor, object, field, linkedObject, showIcons);
+ }
+ }
+
+ @Override
+ public String getName() {
+ return "long-form";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/object/ObjectLink.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/object/ObjectLink.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/object/ObjectLink.java
new file mode 100644
index 0000000..15f92d7
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/object/ObjectLink.java
@@ -0,0 +1,68 @@
+/*
+ * 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.object;
+
+import java.util.List;
+
+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.spec.feature.ObjectAssociation;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociationFilters;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.viewer.scimpi.Names;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+
+public class ObjectLink extends LinkAbstract {
+
+ // 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 TemplateProcessor templateProcessor, final ObjectAdapter object) {
+ final AuthenticationSession session = IsisContext.getAuthenticationSession();
+ final List<ObjectAssociation> visibleFields = object.getSpecification().getAssociations(ObjectAssociationFilters.dynamicallyVisible(session, object, where));
+ return visibleFields.size() > 0;
+ }
+
+ @Override
+ protected String linkLabel(final String name, final ObjectAdapter object) {
+ if (name == null) {
+ return object.titleString();
+ } else {
+ return name;
+ }
+ }
+
+ @Override
+ protected String defaultView() {
+ return Names.GENERIC + "." + Names.EXTENSION;
+ }
+
+ @Override
+ public String getName() {
+ return "object-link";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/object/SelectedObject.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/object/SelectedObject.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/object/SelectedObject.java
new file mode 100644
index 0000000..ec4c321
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/object/SelectedObject.java
@@ -0,0 +1,56 @@
+/*
+ * 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.object;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+/**
+ * <swf:selected name="selected" object="${action}" equals="${subaction}" />
+ */
+public class SelectedObject extends AbstractElementProcessor {
+
+ @Override
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ final String name = templateProcessor.getOptionalProperty(NAME, "selected");
+ final String objectId = templateProcessor.getRequiredProperty(OBJECT);
+ final String equalsId = templateProcessor.getOptionalProperty("equals");
+ final String title = templateProcessor.getOptionalProperty(BUTTON_TITLE);
+
+ final ObjectAdapter object = templateProcessor.getContext().getMappedObjectOrResult(objectId);
+ final ObjectAdapter other = templateProcessor.getContext().getMappedObjectOrResult(equalsId);
+ if (object == other || object.equals(title)) {
+ // TODO title is not being used!
+ templateProcessor.getContext().addVariable(ID, " id=\"" + name + "\" ", Scope.INTERACTION);
+ } else {
+ templateProcessor.getContext().addVariable(ID, "", Scope.INTERACTION);
+ }
+ templateProcessor.closeEmpty();
+ }
+
+ @Override
+ public String getName() {
+ return "selected";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/object/ShortViewForm.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/object/ShortViewForm.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/object/ShortViewForm.java
new file mode 100644
index 0000000..6ed7ff6
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/object/ShortViewForm.java
@@ -0,0 +1,36 @@
+/*
+ * 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.object;
+
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
+
+public class ShortViewForm extends ViewFormAbstract {
+
+ @Override
+ protected boolean ignoreField(final ObjectAssociation field) {
+ return field.isOneToManyAssociation();
+ }
+
+ @Override
+ public String getName() {
+ return "short-form";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/object/Title.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/object/Title.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/object/Title.java
new file mode 100644
index 0000000..bcff697
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/object/Title.java
@@ -0,0 +1,69 @@
+/*
+ * 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.object;
+
+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.ForbiddenException;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.util.MethodsUtils;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+public class Title extends AbstractElementProcessor {
+
+ @Override
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ final String id = templateProcessor.getOptionalProperty(OBJECT);
+ final String fieldName = templateProcessor.getOptionalProperty(FIELD);
+ final int truncateTo = Integer.valueOf(templateProcessor.getOptionalProperty(TRUNCATE, "0")).intValue();
+ final boolean isIconShowing = templateProcessor.isRequested(SHOW_ICON, showIconByDefault());
+ String className = templateProcessor.getOptionalProperty(CLASS);
+ className = className == null ? "title-icon" : className;
+ ObjectAdapter object = MethodsUtils.findObject(state, id);
+ if (fieldName != null) {
+ final ObjectAssociation field = object.getSpecification().getAssociation(fieldName);
+ if (field.isVisible(IsisContext.getAuthenticationSession(), object, Where.ANYWHERE).isVetoed()) {
+ throw new ForbiddenException(field, ForbiddenException.VISIBLE);
+ }
+ object = field.get(object);
+ }
+
+ if (object != null) {
+ templateProcessor.appendHtml("<span class=\"object title\">");
+ IsisContext.getPersistenceSession().resolveImmediately(object);
+ if (isIconShowing) {
+ final String iconPath = templateProcessor.getContext().imagePath(object);
+ templateProcessor.appendHtml("<img class=\"" + className + "\" src=\"" + iconPath + "\" />");
+ }
+ templateProcessor.appendTruncated(object.titleString(), truncateTo);
+ templateProcessor.appendHtml("</span>");
+ }
+ templateProcessor.closeEmpty();
+ }
+
+ @Override
+ public String getName() {
+ return "title";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/object/TitleString.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/object/TitleString.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/object/TitleString.java
new file mode 100644
index 0000000..7672281
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/object/TitleString.java
@@ -0,0 +1,69 @@
+/*
+ * 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.object;
+
+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.ForbiddenException;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+/**
+ *
+ */
+public class TitleString extends AbstractElementProcessor {
+
+ @Override
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ final String id = templateProcessor.getOptionalProperty(OBJECT);
+ final String fieldName = templateProcessor.getOptionalProperty(FIELD);
+ final int truncateTo = Integer.valueOf(templateProcessor.getOptionalProperty(TRUNCATE, "0")).intValue();
+ final ObjectAdapter object = templateProcessor.getContext().getMappedObjectOrResult(id);
+ if (object == null) {
+ return;
+ }
+ String titleString;
+ if (fieldName == null) {
+ titleString = object.titleString();
+ } else {
+ final ObjectAssociation field = object.getSpecification().getAssociation(fieldName);
+ if (field.isVisible(IsisContext.getAuthenticationSession(), object, Where.ANYWHERE).isVetoed()) {
+ throw new ForbiddenException(field, ForbiddenException.VISIBLE);
+ }
+ final ObjectAdapter fieldReference = field.get(object);
+ if (fieldReference != null) {
+ titleString = fieldReference.titleString();
+ } else {
+ titleString = "";
+ }
+ }
+ templateProcessor.appendDebug(" " + titleString);
+ templateProcessor.appendTruncated(titleString, truncateTo);
+ }
+
+ @Override
+ public String getName() {
+ return "title-string";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/object/Type.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/object/Type.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/object/Type.java
new file mode 100644
index 0000000..bce4000
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/object/Type.java
@@ -0,0 +1,58 @@
+/*
+ * 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.object;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+public class Type extends AbstractElementProcessor {
+
+ @Override
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ final Request context = templateProcessor.getContext();
+ final String showPlural = templateProcessor.getOptionalProperty(PLURAL);
+ final String id = templateProcessor.getOptionalProperty(OBJECT);
+ final String objectId = id != null ? id : (String) context.getVariable(RESULT);
+
+ ObjectAdapter object = context.getMappedObjectOrResult(objectId);
+ final String field = templateProcessor.getOptionalProperty(FIELD);
+ if (field != null) {
+ final ObjectAssociation objectField = object.getSpecification().getAssociation(field);
+ object = objectField.get(object);
+ }
+ templateProcessor.appendDebug(" for " + object);
+
+ final ObjectSpecification specification = object.getSpecification();
+ final String name = showPlural != null ? specification.getPluralName() : specification.getSingularName();
+
+ templateProcessor.appendAsHtmlEncoded(name);
+ }
+
+ @Override
+ public String getName() {
+ return "type";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/object/ViewFormAbstract.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/object/ViewFormAbstract.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/object/ViewFormAbstract.java
new file mode 100644
index 0000000..3d6e2f2
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/object/ViewFormAbstract.java
@@ -0,0 +1,142 @@
+/*
+ * 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.object;
+
+import java.util.List;
+
+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.parseable.ParseableFacet;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociationFilters;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractObjectProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.determine.LinkedFieldsBlock;
+import org.apache.isis.viewer.scimpi.dispatcher.view.determine.LinkedObject;
+import org.apache.isis.viewer.scimpi.dispatcher.view.other.HelpLink;
+
+public abstract class ViewFormAbstract extends AbstractObjectProcessor {
+
+ @Override
+ public String checkFieldType(final ObjectAssociation objectField) {
+ return objectField.isOneToOneAssociation() ? null : "is not an object";
+ }
+
+ @Override
+ public void process(final TemplateProcessor templateProcessor, final ObjectAdapter object) {
+ final LinkedFieldsBlock tag = new LinkedFieldsBlock();
+
+ if (object != null) {
+ final String id = templateProcessor.getOptionalProperty(ID, object.getSpecification().getShortIdentifier());
+ final String cls = templateProcessor.getOptionalProperty(CLASS, "form");
+ final String classString = " id=\"" + id + "\" class=\"" + cls + "\"";
+ String title = templateProcessor.getOptionalProperty(FORM_TITLE);
+ final String oddRowClass = templateProcessor.getOptionalProperty(ODD_ROW_CLASS);
+ final String evenRowClass = templateProcessor.getOptionalProperty(EVEN_ROW_CLASS);
+ final String labelDelimiter = templateProcessor.getOptionalProperty(LABEL_DELIMITER, ":");
+ final boolean showIcons = templateProcessor.isRequested(SHOW_ICON, showIconByDefault());
+ String linkAllView = templateProcessor.getOptionalProperty(LINK_VIEW);
+
+ templateProcessor.pushBlock(tag);
+ templateProcessor.processUtilCloseTag();
+
+ final AuthenticationSession session = IsisContext.getAuthenticationSession();
+ List<ObjectAssociation> associations = object.getSpecification().getAssociations(ObjectAssociationFilters.dynamicallyVisible(session, object, Where.OBJECT_FORMS));
+ final List<ObjectAssociation> fields = tag.includedFields(associations);
+ final LinkedObject[] linkFields = tag.linkedFields(fields);
+
+ if (linkAllView != null) {
+ linkAllView = templateProcessor.getContext().fullUriPath(linkAllView);
+ for (int i = 0; i < linkFields.length; i++) {
+ final boolean isObject = fields.get(i).isOneToOneAssociation();
+ final boolean isNotParseable = !fields.get(i).getSpecification().containsFacet(ParseableFacet.class);
+ linkFields[i] = isObject && isNotParseable ? new LinkedObject(linkAllView) : null;
+ }
+ }
+
+ if (title == null) {
+ title = object.getSpecification().getSingularName();
+ } else if (title.equals("")) {
+ title = null;
+ }
+
+ write(templateProcessor, object, fields, linkFields, classString, title, labelDelimiter, oddRowClass, evenRowClass, showIcons);
+ } else {
+ templateProcessor.skipUntilClose();
+ }
+ }
+
+ private void write(
+ final TemplateProcessor templateProcessor,
+ final ObjectAdapter object,
+ final List<ObjectAssociation> fields,
+ final LinkedObject[] linkFields,
+ final String classString,
+ final String title,
+ final String labelDelimiter,
+ final String oddRowClass,
+ final String evenRowClass,
+ final boolean showIcons) {
+ templateProcessor.appendHtml("<div" + classString + ">");
+ if (title != null) {
+ templateProcessor.appendHtml("<div class=\"title\">");
+ templateProcessor.appendAsHtmlEncoded(title);
+ templateProcessor.appendHtml("</div>");
+ HelpLink.append(templateProcessor, object.getSpecification().getDescription(), object.getSpecification().getHelp());
+ }
+ int row = 1;
+ for (int i = 0; i < fields.size(); i++) {
+ final ObjectAssociation field = fields.get(i);
+ if (ignoreField(field)) {
+ continue;
+ }
+ if (field.isVisible(IsisContext.getAuthenticationSession(), object, Where.OBJECT_FORMS).isVetoed()) {
+ continue;
+ }
+
+ final String description = field.getDescription().equals("") ? "" : "title=\"" + field.getDescription() + "\"";
+ String cls;
+ if (row++ % 2 == 1) {
+ cls = " class=\"field " + (oddRowClass == null ? ODD_ROW_CLASS : oddRowClass) + "\"";
+ } else {
+ cls = " class=\"field " + (evenRowClass == null ? EVEN_ROW_CLASS : evenRowClass) + "\"";
+ }
+ templateProcessor.appendHtml("<div " + cls + description + "><span class=\"label\">");
+ templateProcessor.appendAsHtmlEncoded(field.getName());
+ templateProcessor.appendHtml(labelDelimiter + "</span>");
+ final LinkedObject linkedObject = linkFields[i];
+ addField(templateProcessor, object, field, linkedObject, showIcons);
+ HelpLink.append(templateProcessor, field.getDescription(), field.getHelp());
+ templateProcessor.appendHtml("</div>");
+ }
+ templateProcessor.appendHtml("</div>");
+ }
+
+ protected void addField(final TemplateProcessor templateProcessor, final ObjectAdapter object, final ObjectAssociation field, final LinkedObject linkedObject, final boolean showIcons) {
+ FieldValue.write(templateProcessor, object, field, linkedObject, null, showIcons, 0);
+ }
+
+ protected boolean ignoreField(final ObjectAssociation objectField) {
+ return false;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/other/HelpLink.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/other/HelpLink.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/other/HelpLink.java
index 9bc5987..2dab703 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/other/HelpLink.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/other/HelpLink.java
@@ -20,7 +20,8 @@ package org.apache.isis.viewer.scimpi.dispatcher.view.other;
import org.apache.isis.core.commons.config.ConfigurationConstants;
import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public class HelpLink extends AbstractElementProcessor {
@@ -28,8 +29,8 @@ public class HelpLink extends AbstractElementProcessor {
private static String site;
private static String suffix;
- public static void append(final TagProcessor tagProcessor, final String description, final String helpReference) {
- tagProcessor.appendHtml(createHelpSegment(description, helpReference));
+ public static void append(final TemplateProcessor templateProcessor, final String description, final String helpReference) {
+ templateProcessor.appendHtml(createHelpSegment(description, helpReference));
}
public static String createHelpSegment(final String description, final String helpReference) {
@@ -63,10 +64,10 @@ public class HelpLink extends AbstractElementProcessor {
}
@Override
- public void process(final TagProcessor tagProcessor) {
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
final String description = null;
- final String helpReference = tagProcessor.getRequiredProperty("ref");
- append(tagProcessor, description, helpReference);
+ final String helpReference = templateProcessor.getRequiredProperty("ref");
+ append(templateProcessor, description, helpReference);
}
}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/other/History.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/other/History.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/other/History.java
index d328921..33bfaac 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/other/History.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/other/History.java
@@ -24,8 +24,9 @@ import java.util.List;
import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
import org.apache.isis.viewer.scimpi.dispatcher.util.MethodsUtils;
import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
@@ -86,20 +87,20 @@ public class History extends AbstractElementProcessor {
}
@Override
- public void process(final TagProcessor tagProcessor) {
- final String action = tagProcessor.getOptionalProperty("action", "display");
- final Crumbs crumbs = getCrumbs(tagProcessor);
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ final String action = templateProcessor.getOptionalProperty("action", "display");
+ final Crumbs crumbs = getCrumbs(templateProcessor);
if (action.equals("display") && crumbs != null) {
- write(crumbs, tagProcessor);
+ write(crumbs, templateProcessor);
} else if (action.equals("link")) {
- final String name = tagProcessor.getRequiredProperty(NAME);
- final String link = tagProcessor.getRequiredProperty(LINK_VIEW);
+ final String name = templateProcessor.getRequiredProperty(NAME);
+ final String link = templateProcessor.getRequiredProperty(LINK_VIEW);
crumbs.add(name, link);
} else if (action.equals("object")) {
- final String id = tagProcessor.getOptionalProperty(OBJECT);
- final ObjectAdapter object = MethodsUtils.findObject(tagProcessor.getContext(), id);
+ final String id = templateProcessor.getOptionalProperty(OBJECT);
+ final ObjectAdapter object = MethodsUtils.findObject(templateProcessor.getContext(), id);
final String name = object.titleString();
- String link = tagProcessor.getRequiredProperty(LINK_VIEW);
+ String link = templateProcessor.getRequiredProperty(LINK_VIEW);
link += "?_result=" + id;
crumbs.add(name, link);
} else if (action.equals("return")) {
@@ -110,35 +111,35 @@ public class History extends AbstractElementProcessor {
}
- public void write(final Crumbs crumbs, final TagProcessor tagProcessor) {
+ public void write(final Crumbs crumbs, final TemplateProcessor templateProcessor) {
if (crumbs.isEmpty()) {
return;
}
- tagProcessor.appendHtml("<div id=\"history\">");
+ templateProcessor.appendHtml("<div id=\"history\">");
int i = 0;
final int length = crumbs.size();
for (final Crumb crumb : crumbs.iterator()) {
final String link = crumb.link;
if (i > 0) {
- tagProcessor.appendHtml("<span class=\"separator\"> | </span>");
+ templateProcessor.appendHtml("<span class=\"separator\"> | </span>");
}
if (i == length - 1 || link == null) {
- tagProcessor.appendHtml("<span class=\"disabled\">");
- tagProcessor.appendHtml(crumb.name);
- tagProcessor.appendHtml("</span>");
+ templateProcessor.appendHtml("<span class=\"disabled\">");
+ templateProcessor.appendHtml(crumb.name);
+ templateProcessor.appendHtml("</span>");
} else {
- tagProcessor.appendHtml("<a class=\"linked\" href=\"" + link + "\">");
- tagProcessor.appendHtml(crumb.name);
- tagProcessor.appendHtml("</a>");
+ templateProcessor.appendHtml("<a class=\"linked\" href=\"" + link + "\">");
+ templateProcessor.appendHtml(crumb.name);
+ templateProcessor.appendHtml("</a>");
}
i++;
}
- tagProcessor.appendHtml("</div>");
+ templateProcessor.appendHtml("</div>");
}
- private Crumbs getCrumbs(final TagProcessor tagProcessor) {
- final Request context = tagProcessor.getContext();
+ private Crumbs getCrumbs(final TemplateProcessor templateProcessor) {
+ final Request context = templateProcessor.getContext();
Crumbs crumbs = (Crumbs) context.getVariable(_HISTORY);
if (crumbs == null) {
crumbs = new Crumbs();
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/other/VersionNumber.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/other/VersionNumber.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/other/VersionNumber.java
index 5ae6dff..5f8e8b0 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/other/VersionNumber.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/other/VersionNumber.java
@@ -24,7 +24,8 @@ import java.io.InputStreamReader;
import org.apache.isis.viewer.scimpi.ScimpiException;
import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public class VersionNumber extends AbstractElementProcessor {
@@ -39,12 +40,12 @@ public class VersionNumber extends AbstractElementProcessor {
}
@Override
- public void process(final TagProcessor tagProcessor) {
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
if (version == null) {
version = "0000"; // default revision number
- loadRevisonNumber(tagProcessor.getContext());
+ loadRevisonNumber(templateProcessor.getContext());
}
- tagProcessor.appendHtml(version);
+ templateProcessor.appendHtml(version);
}
private void loadRevisonNumber(final Request context) {
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/security/EndSession.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/security/EndSession.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/security/EndSession.java
new file mode 100644
index 0000000..e14a0bb
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/security/EndSession.java
@@ -0,0 +1,37 @@
+/*
+ * 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.security;
+
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+public class EndSession extends AbstractElementProcessor {
+
+ @Override
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ templateProcessor.getContext().endHttpSession();
+ }
+
+ @Override
+ public String getName() {
+ return "end-session";
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/security/Logoff.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/security/Logoff.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/security/Logoff.java
new file mode 100644
index 0000000..c0452f9
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/security/Logoff.java
@@ -0,0 +1,39 @@
+/*
+ * 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.security;
+
+import org.apache.isis.viewer.scimpi.dispatcher.action.LogoutAction;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+public class Logoff extends AbstractElementProcessor {
+
+ @Override
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ LogoutAction.logoutUser(templateProcessor.getContext());
+ }
+
+ @Override
+ public String getName() {
+ return "logoff";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/security/Logon.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/security/Logon.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/security/Logon.java
new file mode 100644
index 0000000..f1325cf
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/security/Logon.java
@@ -0,0 +1,51 @@
+/*
+ * 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.security;
+
+
+import org.apache.isis.core.commons.authentication.AnonymousSession;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.form.LogonFormAbstract;
+
+public class Logon extends LogonFormAbstract {
+
+ @Override
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ String view = templateProcessor.getOptionalProperty(VIEW);
+ Request context = templateProcessor.getContext();
+ if (view == null) {
+ view = (String) context.getVariable("login-path");
+ }
+
+ final boolean isNotLoggedIn = IsisContext.getSession().getAuthenticationSession() instanceof AnonymousSession;
+ if (isNotLoggedIn) {
+ loginForm(templateProcessor, view);
+ }
+ }
+
+ @Override
+ public String getName() {
+ return "logon";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/security/RestrictAccess.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/security/RestrictAccess.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/security/RestrictAccess.java
new file mode 100644
index 0000000..de7b352
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/security/RestrictAccess.java
@@ -0,0 +1,42 @@
+/*
+ * 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.security;
+
+import org.apache.isis.viewer.scimpi.Names;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+public class RestrictAccess extends AbstractElementProcessor {
+ private static final String LOGIN_VIEW = "login-view";
+ private static final String DEFAULT_LOGIN_VIEW = "login." + Names.EXTENSION;
+
+ public String getName() {
+ return "restrict-access";
+ }
+
+ public void process(TemplateProcessor templateProcessor, RequestState state) {
+ if (!templateProcessor.getContext().isUserAuthenticated()) {
+ final String view = templateProcessor.getOptionalProperty(LOGIN_VIEW, DEFAULT_LOGIN_VIEW);
+ templateProcessor.getContext().redirectTo(view);
+ }
+ }
+
+}
+
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/security/Secure.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/security/Secure.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/security/Secure.java
new file mode 100644
index 0000000..d312bf5
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/security/Secure.java
@@ -0,0 +1,46 @@
+/*
+ * 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.security;
+
+import org.apache.isis.core.commons.authentication.AnonymousSession;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+public class Secure extends AbstractElementProcessor {
+ private static final String LOGIN_VIEW = "login-view";
+
+ @Override
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ 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 = templateProcessor.getOptionalProperty(LOGIN_VIEW, "/login.shtml");
+ templateProcessor.getContext().redirectTo(view);
+ }
+ }
+
+ @Override
+ public String getName() {
+ return "secure";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/security/StartSession.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/security/StartSession.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/security/StartSession.java
new file mode 100644
index 0000000..dbc2b34
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/security/StartSession.java
@@ -0,0 +1,37 @@
+/*
+ * 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.security;
+
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+public class StartSession extends AbstractElementProcessor {
+
+ @Override
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ templateProcessor.getContext().startHttpSession();
+ }
+
+ @Override
+ public String getName() {
+ return "start-session";
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/security/User.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/security/User.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/security/User.java
new file mode 100644
index 0000000..3c7cb49
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/security/User.java
@@ -0,0 +1,78 @@
+/*
+ * 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.security;
+
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.viewer.scimpi.Names;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+public class User extends AbstractElementProcessor {
+ private static final String LOGIN_VIEW = "login-view";
+ private static final String DEFAULT_LOGIN_VIEW = "login." + Names.EXTENSION;
+ private static final String LOGOUT_VIEW = "logout-view";
+ private static final String DEFAULT_LOGOUT_VIEW = "logout." + Names.EXTENSION;
+
+ @Override
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ final boolean isAuthenticatedn = templateProcessor.getContext().isUserAuthenticated();
+ templateProcessor.appendHtml("<div class=\"user\">");
+ if (isAuthenticatedn) {
+ displayUserAndLogoutLink(templateProcessor);
+ } else {
+ displayLoginForm(templateProcessor);
+ }
+ templateProcessor.appendHtml("</div>");
+ }
+
+ public void displayLoginForm(final TemplateProcessor templateProcessor) {
+ String loginView = templateProcessor.getOptionalProperty(LOGIN_VIEW);
+ if (loginView == null) {
+ Logon.loginForm(templateProcessor, ".");
+ } else {
+ if (loginView.trim().length() == 0) {
+ loginView = DEFAULT_LOGIN_VIEW;
+ }
+ templateProcessor.appendHtml("<a div class=\"link\" href=\"" + loginView + "\">Log in</a>");
+ }
+ }
+
+ public void displayUserAndLogoutLink(final TemplateProcessor templateProcessor) {
+ String user = templateProcessor.getOptionalProperty(NAME);
+ if (user == null) {
+ user = (String) templateProcessor.getContext().getVariable("_username");
+ }
+ if (user == null) {
+ user = IsisContext.getAuthenticationSession().getUserName();
+ }
+ templateProcessor.appendHtml("Welcome <span class=\"name\">");
+ templateProcessor.appendAsHtmlEncoded(user);
+ templateProcessor.appendHtml("</span>, ");
+ final String logoutView = templateProcessor.getOptionalProperty(LOGOUT_VIEW, DEFAULT_LOGOUT_VIEW);
+ templateProcessor.appendHtml("<a class=\"link\" href=\"logout.app?view=" + logoutView + "\">Log out</a>");
+ }
+
+ @Override
+ public String getName() {
+ return "user";
+ }
+
+}
[02/24] Restructuring Scimpi to remove dependencies and enable easier
testing.
Posted by rm...@apache.org.
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/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
index 4106fd9..b075bfc 100644
--- 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
@@ -20,8 +20,8 @@ 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;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public class Commit extends AbstractElementProcessor {
@@ -31,7 +31,7 @@ public class Commit extends AbstractElementProcessor {
}
@Override
- public void process(final Request request) {
+ public void process(final TagProcessor tagProcessor) {
// Note - the session will have changed since the earlier call if a user
// has logged in or out in the action
// processing above.
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/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
index ddda339..9374ebf 100644
--- 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
@@ -18,8 +18,8 @@
*/
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;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.ElementProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
public class ContentTag implements ElementProcessor {
@@ -29,8 +29,8 @@ public class ContentTag implements ElementProcessor {
}
@Override
- public void process(final Request request) {
- request.appendHtml("<!-- apply content -->");
+ public void process(final TagProcessor tagProcessor) {
+ tagProcessor.appendHtml("<!-- apply content -->");
}
}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/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
index 09e56b0..0799993 100644
--- 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
@@ -19,24 +19,24 @@
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;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
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);
+ public void process(final TagProcessor tagProcessor) {
+ String name = tagProcessor.getRequiredProperty(NAME);
+ String resultName = tagProcessor.getOptionalProperty(RESULT_NAME, name);
+ final String scopeName = tagProcessor.getOptionalProperty(SCOPE);
+ final Scope scope = Request.scope(scopeName, Scope.REQUEST);
- String cookieString = request.getContext().getCookie(name);
+ String cookieString = tagProcessor.getContext().getCookie(name);
- request.appendDebug(" " + resultName + " (" + scope + ") set to " + cookieString + " from cookie " + name);
- request.getContext().addVariable(resultName, cookieString, scope);
+ tagProcessor.appendDebug(" " + resultName + " (" + scope + ") set to " + cookieString + " from cookie " + name);
+ tagProcessor.getContext().addVariable(resultName, cookieString, scope);
}
@Override
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/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
index 2cd9593..1914385 100644
--- 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
@@ -19,28 +19,28 @@
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;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public class DefaultValue extends AbstractElementProcessor {
@Override
- public void process(final Request request) {
+ public void process(final TagProcessor tagProcessor) {
// 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 String variableName = tagProcessor.getRequiredProperty(NAME);
+ final String defaultValue = tagProcessor.getOptionalProperty(VALUE);
+ final String scopeName = tagProcessor.getOptionalProperty(SCOPE);
+ final Scope scope = Request.scope(scopeName, Scope.REQUEST);
- final RequestContext context = request.getContext();
+ final Request context = tagProcessor.getContext();
final Object currentValue = context.getVariable(variableName);
if (currentValue == null) {
- request.appendDebug(" " + variableName + " set to " + defaultValue + " (" + scope + ")");
+ tagProcessor.appendDebug(" " + variableName + " set to " + defaultValue + " (" + scope + ")");
context.addVariable(variableName, defaultValue, scope);
} else {
- request.appendDebug(" " + variableName + " alreadt set to " + currentValue);
+ tagProcessor.appendDebug(" " + variableName + " alreadt set to " + currentValue);
}
}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/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
index 3a8f7b0..037d560 100644
--- 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
@@ -30,8 +30,8 @@ import org.apache.isis.core.metamodel.spec.ObjectSpecification;
import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
import org.apache.isis.core.metamodel.spec.feature.ObjectAssociationFilters;
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;
+import org.apache.isis.viewer.scimpi.Names;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
public class EditLink extends AbstractLink {
@@ -43,7 +43,7 @@ public class EditLink extends AbstractLink {
private final Where where = Where.ANYWHERE;
@Override
- protected boolean valid(final Request request, final ObjectAdapter adapter) {
+ protected boolean valid(final TagProcessor tagProcessor, final ObjectAdapter adapter) {
final ObjectSpecification specification = adapter.getSpecification();
final AuthenticationSession session = IsisContext.getAuthenticationSession();
final List<ObjectAssociation> visibleFields = specification.getAssociations(ObjectAssociationFilters.dynamicallyVisible(session, adapter, where));
@@ -60,7 +60,7 @@ public class EditLink extends AbstractLink {
@Override
protected String defaultView() {
- return Dispatcher.GENERIC + Dispatcher.EDIT + "." + Dispatcher.EXTENSION;
+ return Names.GENERIC + Names.EDIT + "." + Names.EXTENSION;
}
@Override
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/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
index 1a37f99..a5f15c8 100644
--- 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
@@ -19,14 +19,14 @@
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.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public class EndSession extends AbstractElementProcessor {
@Override
- public void process(final Request request) {
- request.getContext().endHttpSession();
+ public void process(final TagProcessor tagProcessor) {
+ tagProcessor.getContext().endHttpSession();
}
@Override
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/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
index e63ec92..3e0150f 100644
--- 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
@@ -18,8 +18,8 @@
*/
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.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public class Forward extends AbstractElementProcessor {
@@ -29,9 +29,9 @@ public class Forward extends AbstractElementProcessor {
}
@Override
- public void process(final Request request) {
- final String view = request.getRequiredProperty(VIEW);
- request.getContext().forward(view);
+ public void process(final TagProcessor tagProcessor) {
+ final String view = tagProcessor.getRequiredProperty(VIEW);
+ tagProcessor.getContext().forward(view);
}
}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/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
index f58b13f..414436b 100644
--- 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
@@ -19,17 +19,17 @@
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.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
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);
+ public void process(final TagProcessor tagProcessor) {
+ final String name = tagProcessor.getRequiredProperty("name");
+ final String cookie = tagProcessor.getContext().getCookie(name);
- request.appendHtml(cookie);
+ tagProcessor.appendHtml(cookie);
}
@Override
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/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
index 1b66290..cbcaa55 100644
--- 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
@@ -19,14 +19,14 @@
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.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public class Import extends AbstractElementProcessor {
@Override
- public void process(final Request request) {
- request.appendHtml("<!-- " + " import " + request.getOptionalProperty("file") + " -->");
+ public void process(final TagProcessor tagProcessor) {
+ tagProcessor.appendHtml("<!-- " + " import " + tagProcessor.getOptionalProperty("file") + " -->");
}
@Override
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/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
index 1e3f47e..520af0c 100644
--- 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
@@ -21,26 +21,27 @@ 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;
+import org.apache.isis.viewer.scimpi.Names;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
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);
+ public void process(final TagProcessor tagProcessor) {
+ final String name = tagProcessor.getRequiredProperty(NAME);
- final RequestContext context = request.getContext();
+ final Request context = tagProcessor.getContext();
if (context.getVariable(name) != null) {
- request.skipUntilClose();
+ tagProcessor.skipUntilClose();
} else {
- final String scopeName = request.getOptionalProperty(SCOPE);
- final Scope scope = RequestContext.scope(scopeName, Scope.SESSION);
+ final String scopeName = tagProcessor.getOptionalProperty(SCOPE);
+ final Scope scope = Request.scope(scopeName, Scope.SESSION);
- final String cookieName = request.getOptionalProperty("cookie", name);
+ final String cookieName = tagProcessor.getOptionalProperty("cookie", name);
final String cookieValue = context.getCookie(cookieName);
boolean hasObject;
if (cookieValue != null) {
@@ -55,14 +56,14 @@ public class InitializeFromCookie extends AbstractElementProcessor {
}
if (hasObject) {
- request.skipUntilClose();
+ tagProcessor.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 String expiresString = tagProcessor.getOptionalProperty("expires", SEVEN_DAYS);
+ tagProcessor.pushNewBuffer();
+ tagProcessor.processUtilCloseTag();
+ tagProcessor.popBuffer();
+ final String id = (String) context.getVariable(Names.RESULT);
final ObjectAdapter variable = context.getMappedObject(id);
if (variable != null) {
context.addCookie(cookieName, id, Integer.valueOf(expiresString));
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/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
index 375fdd2..f3ba3bc 100644
--- 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
@@ -20,33 +20,34 @@
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;
+import org.apache.isis.viewer.scimpi.Names;
+import org.apache.isis.viewer.scimpi.ScimpiException;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
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);
+ public void process(final TagProcessor tagProcessor) {
+ disallowSourceAndDefault(tagProcessor);
+ final String sourceObjectId = objectOrResult(tagProcessor);
+ final Class<?> cls = forClass(tagProcessor);
+ final String variableName = tagProcessor.getRequiredProperty(NAME);
+ final String defaultObjectId = tagProcessor.getOptionalProperty(DEFAULT);
+ final String scopeName = tagProcessor.getOptionalProperty(SCOPE);
+ final Scope scope = Request.scope(scopeName, Scope.REQUEST);
- final RequestContext context = request.getContext();
+ final Request context = tagProcessor.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 + ")");
+ tagProcessor.appendDebug(" " + variableName + " set to " + sourceObjectId + " (" + scope + ")");
context.addVariable(variableName, sourceObjectId, scope);
} else {
- request.appendDebug(" " + variableName + " set to " + sourceObjectId + " (" + scope + ")");
+ tagProcessor.appendDebug(" " + variableName + " set to " + sourceObjectId + " (" + scope + ")");
if (defaultObjectId != null) {
context.addVariable(variableName, defaultObjectId, scope);
}
@@ -54,17 +55,17 @@ public class InitializeFromResult extends AbstractElementProcessor {
}
}
- private String objectOrResult(final Request request) {
- final String sourceObjectId = request.getOptionalProperty(OBJECT);
+ private String objectOrResult(final TagProcessor tagProcessor) {
+ final String sourceObjectId = tagProcessor.getOptionalProperty(OBJECT);
if (sourceObjectId == null) {
- return (String) request.getContext().getVariable(RequestContext.RESULT);
+ return (String) tagProcessor.getContext().getVariable(Names.RESULT);
} else {
return sourceObjectId;
}
}
- private void disallowSourceAndDefault(final Request request) {
- if (request.getOptionalProperty(DEFAULT) != null && request.getOptionalProperty(OBJECT) != null) {
+ private void disallowSourceAndDefault(final TagProcessor tagProcessor) {
+ if (tagProcessor.getOptionalProperty(DEFAULT) != null && tagProcessor.getOptionalProperty(OBJECT) != null) {
throw new ScimpiException("Cannot specify both " + OBJECT + " and " + DEFAULT + " for the " + getName() + " element");
}
}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/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
index fe1474b..fe69d9d 100644
--- 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
@@ -23,8 +23,8 @@ 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;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
/**
* Displays the localization data for the current user.
@@ -32,8 +32,8 @@ import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
public class Localization extends AbstractElementProcessor {
@Override
- public void process(final Request request) {
- request.closeEmpty();
+ public void process(final TagProcessor tagProcessor) {
+ tagProcessor.closeEmpty();
org.apache.isis.applib.profiles.Localization localization = IsisContext.getLocalization();
if (localization != null) {
@@ -42,9 +42,9 @@ public class Localization extends AbstractElementProcessor {
// country = locale.toString();
String timeZone = localization.getTimeZone().getDisplayName();
- request.appendAsHtmlEncoded(country + ", " + timeZone);
+ tagProcessor.appendAsHtmlEncoded(country + ", " + timeZone);
} else {
- request.appendAsHtmlEncoded("No localization data!");
+ tagProcessor.appendAsHtmlEncoded("No localization data!");
}
Locale locale = Locale.getDefault();
@@ -52,7 +52,7 @@ public class Localization extends AbstractElementProcessor {
// country = locale.toString();
String timeZone = TimeZone.getDefault().getDisplayName();
- request.appendAsHtmlEncoded("\n (Default " + country + ", " + timeZone +")");
+ tagProcessor.appendAsHtmlEncoded("\n (Default " + country + ", " + timeZone +")");
}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Mark.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Mark.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Mark.java
index febafb6..97660d2 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Mark.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Mark.java
@@ -19,19 +19,19 @@
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;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public class Mark extends AbstractElementProcessor {
// TODO the return points should be pushed on to a stack so that there is
// traceable history.
@Override
- public void process(final Request request) {
+ public void process(final TagProcessor tagProcessor) {
// String name = request.getOptionalProperty(NAME);
- final RequestContext context = request.getContext();
+ final Request context = tagProcessor.getContext();
context.addVariable("_return-to", context.getUri(), Scope.SESSION);
}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/NewActionLink.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/NewActionLink.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/NewActionLink.java
index 5929f81..edd0522 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/NewActionLink.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/NewActionLink.java
@@ -22,8 +22,8 @@ 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.ObjectAction;
-import org.apache.isis.viewer.scimpi.dispatcher.Dispatcher;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
+import org.apache.isis.viewer.scimpi.Names;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
import org.apache.isis.viewer.scimpi.dispatcher.util.MethodsUtils;
public class NewActionLink extends AbstractLink {
@@ -32,8 +32,8 @@ public class NewActionLink extends AbstractLink {
private final Where where = Where.OBJECT_FORMS;
@Override
- protected boolean valid(final Request request, final ObjectAdapter object) {
- final String method = request.getRequiredProperty(METHOD);
+ protected boolean valid(final TagProcessor tagProcessor, final ObjectAdapter object) {
+ final String method = tagProcessor.getRequiredProperty(METHOD);
final ObjectAction action = MethodsUtils.findAction(object, method);
return MethodsUtils.isVisibleAndUsable(object, action, where);
}
@@ -45,12 +45,12 @@ public class NewActionLink extends AbstractLink {
@Override
protected String defaultView() {
- return "_generic_action." + Dispatcher.EXTENSION;
+ return "_generic_action." + Names.EXTENSION;
}
@Override
- protected String additionalParameters(final Request request) {
- final String method = request.getRequiredProperty(METHOD);
+ protected String additionalParameters(final TagProcessor tagProcessor) {
+ final String method = tagProcessor.getRequiredProperty(METHOD);
return "method=" + method;
}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/ObjectLink.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/ObjectLink.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/ObjectLink.java
index 8b18731..54e59ec 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/ObjectLink.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/ObjectLink.java
@@ -27,8 +27,8 @@ import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
import org.apache.isis.core.metamodel.spec.feature.ObjectAssociationFilters;
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;
+import org.apache.isis.viewer.scimpi.Names;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
public class ObjectLink extends AbstractLink {
@@ -40,7 +40,7 @@ public class ObjectLink extends AbstractLink {
private final Where where = Where.ANYWHERE;
@Override
- protected boolean valid(final Request request, final ObjectAdapter object) {
+ protected boolean valid(final TagProcessor tagProcessor, final ObjectAdapter object) {
final AuthenticationSession session = IsisContext.getAuthenticationSession();
final List<ObjectAssociation> visibleFields = object.getSpecification().getAssociations(ObjectAssociationFilters.dynamicallyVisible(session, object, where));
return visibleFields.size() > 0;
@@ -57,7 +57,7 @@ public class ObjectLink extends AbstractLink {
@Override
protected String defaultView() {
- return Dispatcher.GENERIC + "." + Dispatcher.EXTENSION;
+ return Names.GENERIC + "." + Names.EXTENSION;
}
@Override
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/PageTitle.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/PageTitle.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/PageTitle.java
index 10c3b13..65443a3 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/PageTitle.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/PageTitle.java
@@ -19,13 +19,13 @@
package org.apache.isis.viewer.scimpi.dispatcher.view.simple;
-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.context.Request.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
public class PageTitle extends Variable {
@Override
- public void process(final Request request) {
- process(request, "title", null, null, false, Scope.REQUEST);
+ public void process(final TagProcessor tagProcessor) {
+ process(tagProcessor, "title", null, null, false, Scope.REQUEST);
}
@Override
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Redirect.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Redirect.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Redirect.java
index 6f3b0d8..9b72f93 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Redirect.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Redirect.java
@@ -18,8 +18,8 @@
*/
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.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public class Redirect extends AbstractElementProcessor {
@@ -29,9 +29,9 @@ public class Redirect extends AbstractElementProcessor {
}
@Override
- public void process(final Request request) {
- final String view = request.getRequiredProperty(VIEW);
- request.getContext().redirectTo(view);
+ public void process(final TagProcessor tagProcessor) {
+ final String view = tagProcessor.getRequiredProperty(VIEW);
+ tagProcessor.getContext().redirectTo(view);
}
}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/RemoveElement.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/RemoveElement.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/RemoveElement.java
index 828e9b7..a9b9800 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/RemoveElement.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/RemoveElement.java
@@ -30,15 +30,15 @@ import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
import org.apache.isis.core.metamodel.spec.feature.ObjectAssociationFilters;
import org.apache.isis.core.metamodel.spec.feature.OneToManyAssociation;
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.ForbiddenException;
-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.edit.RemoveAction;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
+import org.apache.isis.viewer.scimpi.ForbiddenException;
+import org.apache.isis.viewer.scimpi.Names;
+import org.apache.isis.viewer.scimpi.ScimpiException;
+import org.apache.isis.viewer.scimpi.dispatcher.action.RemoveAction;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
import org.apache.isis.viewer.scimpi.dispatcher.util.MethodsUtils;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public class RemoveElement extends AbstractElementProcessor {
@@ -50,28 +50,28 @@ public class RemoveElement extends AbstractElementProcessor {
private final static Where where = Where.ANYWHERE;
@Override
- public void process(final Request request) {
- final String title = request.getOptionalProperty(BUTTON_TITLE, "Remove From List");
- final String cls = request.getOptionalProperty(CLASS, "action in-line delete confirm");
- final String object = request.getOptionalProperty(OBJECT);
- final String resultOverride = request.getOptionalProperty(RESULT_OVERRIDE);
- final RequestContext context = request.getContext();
- final String objectId = object != null ? object : (String) context.getVariable(RequestContext.RESULT);
+ public void process(final TagProcessor tagProcessor) {
+ final String title = tagProcessor.getOptionalProperty(BUTTON_TITLE, "Remove From List");
+ final String cls = tagProcessor.getOptionalProperty(CLASS, "action in-line delete confirm");
+ final String object = tagProcessor.getOptionalProperty(OBJECT);
+ final String resultOverride = tagProcessor.getOptionalProperty(RESULT_OVERRIDE);
+ final Request context = tagProcessor.getContext();
+ final String objectId = object != null ? object : (String) context.getVariable(Names.RESULT);
final ObjectAdapter adapter = MethodsUtils.findObject(context, objectId);
- final String element = request.getOptionalProperty(ELEMENT, (String) context.getVariable(ELEMENT));
+ final String element = tagProcessor.getOptionalProperty(ELEMENT, (String) context.getVariable(ELEMENT));
final ObjectAdapter elementId = MethodsUtils.findObject(context, element);
- final String fieldName = request.getRequiredProperty(FIELD);
+ final String fieldName = tagProcessor.getRequiredProperty(FIELD);
- String view = request.getOptionalProperty(VIEW);
+ String view = tagProcessor.getOptionalProperty(VIEW);
view = context.fullFilePath(view == null ? context.getResourceFile() : view);
- String error = request.getOptionalProperty(ERROR);
+ String error = tagProcessor.getOptionalProperty(ERROR);
error = context.fullFilePath(error == null ? context.getResourceFile() : error);
- request.processUtilCloseTag();
+ tagProcessor.processUtilCloseTag();
- write(request, adapter, fieldName, elementId, resultOverride, view, error, title, cls);
+ write(tagProcessor, adapter, fieldName, elementId, resultOverride, view, error, title, cls);
}
@Override
@@ -79,7 +79,7 @@ public class RemoveElement extends AbstractElementProcessor {
return "remove-element";
}
- public static void write(final Request request, final ObjectAdapter adapter, final String fieldName, final ObjectAdapter element, final String resultOverride, final String view, final String error, final String title, final String cssClass) {
+ public static void write(final TagProcessor tagProcessor, final ObjectAdapter adapter, final String fieldName, final ObjectAdapter element, final String resultOverride, final String view, final String error, final String title, final String cssClass) {
final ObjectAssociation field = adapter.getSpecification().getAssociation(fieldName);
if (field == null) {
throw new ScimpiException("No field " + fieldName + " in " + adapter.getSpecification().getFullIdentifier());
@@ -98,36 +98,36 @@ public class RemoveElement extends AbstractElementProcessor {
}
if (usable.isVetoed()) {
- request.appendHtml("<div class=\"" + cssClass + " disabled-form\">");
- request.appendHtml("<div class=\"button disabled\" title=\"");
- request.appendAsHtmlEncoded(usable.getReason());
- request.appendHtml("\" >" + title);
- request.appendHtml("</div>");
- request.appendHtml("</div>");
+ tagProcessor.appendHtml("<div class=\"" + cssClass + " disabled-form\">");
+ tagProcessor.appendHtml("<div class=\"button disabled\" title=\"");
+ tagProcessor.appendAsHtmlEncoded(usable.getReason());
+ tagProcessor.appendHtml("\" >" + title);
+ tagProcessor.appendHtml("</div>");
+ tagProcessor.appendHtml("</div>");
} else {
- if (valid(request, adapter)) {
+ if (valid(tagProcessor, adapter)) {
final String classSegment = " class=\"" + cssClass + "\"";
- final String objectId = request.getContext().mapObject(adapter, Scope.INTERACTION);
- final String elementId = request.getContext().mapObject(element, Scope.INTERACTION);
- final String action = RemoveAction.ACTION + Dispatcher.COMMAND_ROOT;
- request.appendHtml("<form" + classSegment + " method=\"post\" action=\"" + action + "\" >");
- request.appendHtml("<input type=\"hidden\" name=\"" + OBJECT + "\" value=\"" + objectId + "\" />");
- request.appendHtml("<input type=\"hidden\" name=\"" + FIELD + "\" value=\"" + fieldName + "\" />");
- request.appendHtml("<input type=\"hidden\" name=\"" + ELEMENT + "\" value=\"" + elementId + "\" />");
+ final String objectId = tagProcessor.getContext().mapObject(adapter, Scope.INTERACTION);
+ final String elementId = tagProcessor.getContext().mapObject(element, Scope.INTERACTION);
+ final String action = RemoveAction.ACTION + Names.COMMAND_ROOT;
+ tagProcessor.appendHtml("<form" + classSegment + " method=\"post\" action=\"" + action + "\" >");
+ tagProcessor.appendHtml("<input type=\"hidden\" name=\"" + OBJECT + "\" value=\"" + objectId + "\" />");
+ tagProcessor.appendHtml("<input type=\"hidden\" name=\"" + FIELD + "\" value=\"" + fieldName + "\" />");
+ tagProcessor.appendHtml("<input type=\"hidden\" name=\"" + ELEMENT + "\" value=\"" + elementId + "\" />");
if (resultOverride != null) {
- request.appendHtml("<input type=\"hidden\" name=\"" + RESULT_OVERRIDE + "\" value=\"" + resultOverride + "\" />");
+ tagProcessor.appendHtml("<input type=\"hidden\" name=\"" + RESULT_OVERRIDE + "\" value=\"" + resultOverride + "\" />");
}
- request.appendHtml("<input type=\"hidden\" name=\"" + VIEW + "\" value=\"" + view + "\" />");
- request.appendHtml("<input type=\"hidden\" name=\"" + ERROR + "\" value=\"" + error + "\" />");
- request.appendHtml(request.getContext().interactionFields());
- request.appendHtml("<input class=\"button\" type=\"submit\" value=\"" + title + "\" />");
- request.appendHtml("</form>");
+ tagProcessor.appendHtml("<input type=\"hidden\" name=\"" + VIEW + "\" value=\"" + view + "\" />");
+ tagProcessor.appendHtml("<input type=\"hidden\" name=\"" + ERROR + "\" value=\"" + error + "\" />");
+ tagProcessor.appendHtml(tagProcessor.getContext().interactionFields());
+ tagProcessor.appendHtml("<input class=\"button\" type=\"submit\" value=\"" + title + "\" />");
+ tagProcessor.appendHtml("</form>");
}
}
}
- private static boolean valid(final Request request, final ObjectAdapter adapter) {
+ private static boolean valid(final TagProcessor tagProcessor, final ObjectAdapter adapter) {
// TODO is this check valid/necessary?
// TODO check is valid to remove element
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/ScopeTag.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/ScopeTag.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/ScopeTag.java
index 2dced50..ece1d68 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/ScopeTag.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/ScopeTag.java
@@ -19,27 +19,27 @@
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;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public class ScopeTag extends AbstractElementProcessor {
@Override
- public void process(final Request request) {
- final String name = request.getRequiredProperty(NAME);
- final String scopeName = request.getRequiredProperty(SCOPE);
- final Scope scope = RequestContext.scope(scopeName);
- request.processUtilCloseTag();
- changeScope(request, name, scope);
+ public void process(final TagProcessor tagProcessor) {
+ final String name = tagProcessor.getRequiredProperty(NAME);
+ final String scopeName = tagProcessor.getRequiredProperty(SCOPE);
+ final Scope scope = Request.scope(scopeName);
+ tagProcessor.processUtilCloseTag();
+ changeScope(tagProcessor, name, scope);
}
- protected static void changeScope(final Request request, final String name, final Scope scope) {
- request.getContext().changeScope(name, scope);
- final Object value = request.getContext().getVariable(name);
+ protected static void changeScope(final TagProcessor tagProcessor, final String name, final Scope scope) {
+ tagProcessor.getContext().changeScope(name, scope);
+ final Object value = tagProcessor.getContext().getVariable(name);
if (value != null) {
- request.getContext().addVariable(name, value, scope);
+ tagProcessor.getContext().addVariable(name, value, scope);
}
}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/SetCookie.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/SetCookie.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/SetCookie.java
index 1014280..2ecb0cf 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/SetCookie.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/SetCookie.java
@@ -19,29 +19,29 @@
package org.apache.isis.viewer.scimpi.dispatcher.view.simple;
-import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.action.RequiredPropertyException;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.RequiredPropertyException;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public class SetCookie extends AbstractElementProcessor {
@Override
- public void process(final Request request) {
- final String name = request.getRequiredProperty("name");
- final String value = request.getOptionalProperty("value");
- final boolean isClear = request.getOptionalProperty("action", "set").equals("clear");
- final String expiresString = request.getOptionalProperty("expires", "-1");
+ public void process(final TagProcessor tagProcessor) {
+ final String name = tagProcessor.getRequiredProperty("name");
+ final String value = tagProcessor.getOptionalProperty("value");
+ final boolean isClear = tagProcessor.getOptionalProperty("action", "set").equals("clear");
+ final String expiresString = tagProcessor.getOptionalProperty("expires", "-1");
if (!isClear && value == null) {
throw new RequiredPropertyException("Property not set: " + value);
}
if (isClear) {
- request.appendDebug("cookie: " + name + " (cleared)");
- request.getContext().addCookie(name, null, 0);
+ tagProcessor.appendDebug("cookie: " + name + " (cleared)");
+ tagProcessor.getContext().addCookie(name, null, 0);
} else {
if (value.length() > 0) {
- request.appendDebug("cookie: " + name + " set to"+ value);
- request.getContext().addCookie(name, value, Integer.valueOf(expiresString));
+ tagProcessor.appendDebug("cookie: " + name + " set to"+ value);
+ tagProcessor.getContext().addCookie(name, value, Integer.valueOf(expiresString));
}
}
}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/SetCookieFromField.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/SetCookieFromField.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/SetCookieFromField.java
index b91261c..6e422d6 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/SetCookieFromField.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/SetCookieFromField.java
@@ -20,13 +20,13 @@
package org.apache.isis.viewer.scimpi.dispatcher.view.simple;
import org.apache.isis.core.commons.exceptions.NotYetImplementedException;
-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.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public class SetCookieFromField extends AbstractElementProcessor {
@Override
- public void process(final Request request) {
+ public void process(final TagProcessor tagProcessor) {
throw new NotYetImplementedException("3.1");
/*
* String objectId = request.getOptionalProperty(OBJECT); String
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/SetFieldFromCookie.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/SetFieldFromCookie.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/SetFieldFromCookie.java
index 89702fa..11c3861 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/SetFieldFromCookie.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/SetFieldFromCookie.java
@@ -20,13 +20,13 @@
package org.apache.isis.viewer.scimpi.dispatcher.view.simple;
import org.apache.isis.core.commons.exceptions.NotYetImplementedException;
-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.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public class SetFieldFromCookie extends AbstractElementProcessor {
@Override
- public void process(final Request request) {
+ public void process(final TagProcessor tagProcessor) {
throw new NotYetImplementedException("3.1");
/*
* String name = request.getRequiredProperty(NAME); String cookieString
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/SetLocalization.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/SetLocalization.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/SetLocalization.java
index 11e8664..f241e2e 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/SetLocalization.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/SetLocalization.java
@@ -24,8 +24,8 @@ import java.util.TimeZone;
import org.apache.isis.core.runtime.system.context.IsisContext;
import org.apache.isis.core.runtime.userprofile.UserLocalization;
-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.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
/**
* Displays the localization data for the current user.
@@ -33,11 +33,11 @@ import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
public class SetLocalization extends AbstractElementProcessor {
@Override
- public void process(final Request request) {
- request.closeEmpty();
+ public void process(final TagProcessor tagProcessor) {
+ tagProcessor.closeEmpty();
- final String localeCode = request.getRequiredProperty("locale");
- final String timeZone = request.getRequiredProperty("time-zone");
+ final String localeCode = tagProcessor.getRequiredProperty("locale");
+ final String timeZone = tagProcessor.getRequiredProperty("time-zone");
String country;
String language;
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/SimpleButton.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/SimpleButton.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/SimpleButton.java
index 1efd7bf..e6ab245 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/SimpleButton.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/SimpleButton.java
@@ -19,17 +19,17 @@
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.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public class SimpleButton extends AbstractElementProcessor {
@Override
- public void process(final Request request) {
- final String href = request.getRequiredProperty("href");
- request.pushNewBuffer();
- request.processUtilCloseTag();
- final String text = request.popBuffer();
- request.appendHtml("<div class=\"action\"><a class=\"button\" href=\"" + href + "\">" + text + "</a></div>");
+ public void process(final TagProcessor tagProcessor) {
+ final String href = tagProcessor.getRequiredProperty("href");
+ tagProcessor.pushNewBuffer();
+ tagProcessor.processUtilCloseTag();
+ final String text = tagProcessor.popBuffer();
+ tagProcessor.appendHtml("<div class=\"action\"><a class=\"button\" href=\"" + href + "\">" + text + "</a></div>");
}
@Override
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/StartSession.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/StartSession.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/StartSession.java
index 493c33a..82d0242 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/StartSession.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/StartSession.java
@@ -19,14 +19,14 @@
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.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public class StartSession extends AbstractElementProcessor {
@Override
- public void process(final Request request) {
- request.getContext().startHttpSession();
+ public void process(final TagProcessor tagProcessor) {
+ tagProcessor.getContext().startHttpSession();
}
@Override
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/TemplateTag.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/TemplateTag.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/TemplateTag.java
index 8860780..071814d 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/TemplateTag.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/TemplateTag.java
@@ -18,8 +18,8 @@
*/
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;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.ElementProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
public class TemplateTag implements ElementProcessor {
@@ -29,7 +29,7 @@ public class TemplateTag implements ElementProcessor {
}
@Override
- public void process(final Request request) {
+ public void process(final TagProcessor tagProcessor) {
// REVIEW this make IE8 render poorly as the browser doesn't think a
// DOCTYPE is provided, causing it to run in
// quirk mode
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Unless.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Unless.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Unless.java
index 9dcf810..3de6348 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Unless.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Unless.java
@@ -19,17 +19,17 @@
package org.apache.isis.viewer.scimpi.dispatcher.view.simple;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
public class Unless extends AbstractConditionalBlock {
@Override
- protected void processTags(final boolean isSet, final Request request) {
+ protected void processTags(final boolean isSet, final TagProcessor tagProcessor) {
if (isSet) {
- request.skipUntilClose();
- request.appendDebug(" skipping segment");
+ tagProcessor.skipUntilClose();
+ tagProcessor.appendDebug(" skipping segment");
} else {
- request.processUtilCloseTag();
+ tagProcessor.processUtilCloseTag();
}
}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Variable.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Variable.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Variable.java
index 960fc6b..559e0e1 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Variable.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Variable.java
@@ -19,31 +19,31 @@
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;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public class Variable extends AbstractElementProcessor {
@Override
- public void process(final Request request) {
- final String name = request.getOptionalProperty(NAME);
- final String value = request.getOptionalProperty(VALUE);
- final String defaultTo = request.getOptionalProperty(DEFAULT);
- final String scopeName = request.getOptionalProperty(SCOPE);
- final boolean isClear = request.getOptionalProperty("action", "set").equals("clear");
- final Scope scope = RequestContext.scope(scopeName, isClear ? Scope.SESSION : Scope.REQUEST);
- process(request, name, value, defaultTo, isClear, scope);
+ public void process(final TagProcessor tagProcessor) {
+ final String name = tagProcessor.getOptionalProperty(NAME);
+ final String value = tagProcessor.getOptionalProperty(VALUE);
+ final String defaultTo = tagProcessor.getOptionalProperty(DEFAULT);
+ final String scopeName = tagProcessor.getOptionalProperty(SCOPE);
+ final boolean isClear = tagProcessor.getOptionalProperty("action", "set").equals("clear");
+ final Scope scope = Request.scope(scopeName, isClear ? Scope.SESSION : Scope.REQUEST);
+ process(tagProcessor, name, value, defaultTo, isClear, scope);
}
- protected void process(final Request request, final String name, final String value, final String defaultTo, final boolean isClear, final Scope scope) {
- request.pushNewBuffer();
- request.processUtilCloseTag();
- String source = request.popBuffer();
+ protected void process(final TagProcessor tagProcessor, final String name, final String value, final String defaultTo, final boolean isClear, final Scope scope) {
+ tagProcessor.pushNewBuffer();
+ tagProcessor.processUtilCloseTag();
+ String source = tagProcessor.popBuffer();
if (isClear) {
- request.appendDebug("variable: " + name + " (cleared)");
- request.getContext().clearVariable(name, scope);
+ tagProcessor.appendDebug("variable: " + name + " (cleared)");
+ tagProcessor.getContext().clearVariable(name, scope);
} else {
if (source.length() == 0 && value != null) {
source = value;
@@ -51,8 +51,8 @@ public class Variable extends AbstractElementProcessor {
if (source.length() == 0) {
source = defaultTo;
}
- request.appendDebug(" " + name + " (" + scope + ") set to " + source);
- request.getContext().addVariable(name, source, scope);
+ tagProcessor.appendDebug(" " + name + " (" + scope + ") set to " + source);
+ tagProcessor.getContext().addVariable(name, source, scope);
}
}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/When.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/When.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/When.java
index cc1fd09..459faaa 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/When.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/When.java
@@ -19,17 +19,17 @@
package org.apache.isis.viewer.scimpi.dispatcher.view.simple;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
public class When extends AbstractConditionalBlock {
@Override
- protected void processTags(final boolean isSet, final Request request) {
+ protected void processTags(final boolean isSet, final TagProcessor tagProcessor) {
if (isSet) {
- request.processUtilCloseTag();
+ tagProcessor.processUtilCloseTag();
} else {
- request.appendDebug(" skipping segment");
- request.skipUntilClose();
+ tagProcessor.appendDebug(" skipping segment");
+ tagProcessor.skipUntilClose();
}
}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/ActionName.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/ActionName.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/ActionName.java
index 119a453..43264ad 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/ActionName.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/ActionName.java
@@ -21,22 +21,22 @@ package org.apache.isis.viewer.scimpi.dispatcher.view.value;
import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
-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.TagProcessor;
import org.apache.isis.viewer.scimpi.dispatcher.util.MethodsUtils;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
// TODO do the same for description and help, and for fields
public class ActionName extends AbstractElementProcessor {
@Override
- public void process(final Request request) {
- final String objectId = request.getOptionalProperty(OBJECT);
- final String methodName = request.getRequiredProperty(METHOD);
+ public void process(final TagProcessor tagProcessor) {
+ final String objectId = tagProcessor.getOptionalProperty(OBJECT);
+ final String methodName = tagProcessor.getRequiredProperty(METHOD);
- final ObjectAdapter object = MethodsUtils.findObject(request.getContext(), objectId);
+ final ObjectAdapter object = MethodsUtils.findObject(tagProcessor.getContext(), objectId);
final ObjectAction action = MethodsUtils.findAction(object, methodName);
- request.appendAsHtmlEncoded(action.getName());
+ tagProcessor.appendAsHtmlEncoded(action.getName());
}
@Override
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/CountElements.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/CountElements.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/CountElements.java
index debaa49..d22fc44 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/CountElements.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/CountElements.java
@@ -22,22 +22,22 @@ package org.apache.isis.viewer.scimpi.dispatcher.view.value;
import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacet;
import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
-import org.apache.isis.viewer.scimpi.dispatcher.AbstractObjectProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractObjectProcessor;
public class CountElements extends AbstractObjectProcessor {
@Override
- protected void process(final Request request, final ObjectAdapter collection) {
+ protected void process(final TagProcessor tagProcessor, final ObjectAdapter collection) {
final CollectionFacet facet = collection.getSpecification().getFacet(CollectionFacet.class);
final int size = facet.size(collection);
if (size == 0) {
- request.appendHtml(request.getOptionalProperty("none", "0"));
+ tagProcessor.appendHtml(tagProcessor.getOptionalProperty("none", "0"));
} else if (size == 1) {
- request.appendHtml(request.getOptionalProperty("one", "1"));
+ tagProcessor.appendHtml(tagProcessor.getOptionalProperty("one", "1"));
} else {
- final String text = request.getOptionalProperty("many", "" + size);
- request.appendHtml(String.format(text, size));
+ final String text = tagProcessor.getOptionalProperty("many", "" + size);
+ tagProcessor.appendHtml(String.format(text, size));
}
}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/ElementType.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/ElementType.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/ElementType.java
index c7284a0..b15c107 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/ElementType.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/ElementType.java
@@ -22,20 +22,20 @@ package org.apache.isis.viewer.scimpi.dispatcher.view.value;
import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
import org.apache.isis.core.metamodel.spec.ObjectSpecification;
import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
-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.processor.Request;
+import org.apache.isis.viewer.scimpi.ScimpiException;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public class ElementType extends AbstractElementProcessor {
@Override
- public void process(final Request request) {
+ public void process(final TagProcessor tagProcessor) {
ObjectAdapter collection;
- final String field = request.getOptionalProperty(FIELD);
- final RequestContext context = request.getContext();
+ final String field = tagProcessor.getOptionalProperty(FIELD);
+ final Request context = tagProcessor.getContext();
if (field != null) {
- final String id = request.getRequiredProperty(OBJECT);
+ final String id = tagProcessor.getRequiredProperty(OBJECT);
final ObjectAdapter object = context.getMappedObjectOrResult(id);
final ObjectAssociation objectField = object.getSpecification().getAssociation(field);
if (!objectField.isOneToManyAssociation()) {
@@ -43,14 +43,14 @@ public class ElementType extends AbstractElementProcessor {
}
collection = objectField.get(object);
} else {
- final String id = request.getOptionalProperty(COLLECTION);
+ final String id = tagProcessor.getOptionalProperty(COLLECTION);
collection = context.getMappedObjectOrResult(id);
}
final ObjectSpecification elementSpecification = collection.getElementSpecification();
final String name = elementSpecification.getSingularName();
- request.appendAsHtmlEncoded(name);
+ tagProcessor.appendAsHtmlEncoded(name);
}
@Override
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/FieldName.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/FieldName.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/FieldName.java
index ed054a1..1fefdf3 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/FieldName.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/FieldName.java
@@ -23,10 +23,10 @@ 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.ScimpiException;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
+import org.apache.isis.viewer.scimpi.ForbiddenException;
+import org.apache.isis.viewer.scimpi.ScimpiException;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public class FieldName extends AbstractElementProcessor {
@@ -38,10 +38,10 @@ public class FieldName extends AbstractElementProcessor {
private final Where where = Where.ANYWHERE;
@Override
- public void process(final Request request) {
- final String id = request.getOptionalProperty(OBJECT);
- final String fieldName = request.getRequiredProperty(FIELD);
- final ObjectAdapter object = request.getContext().getMappedObjectOrResult(id);
+ public void process(final TagProcessor tagProcessor) {
+ final String id = tagProcessor.getOptionalProperty(OBJECT);
+ final String fieldName = tagProcessor.getRequiredProperty(FIELD);
+ final ObjectAdapter object = tagProcessor.getContext().getMappedObjectOrResult(id);
final ObjectAssociation field = object.getSpecification().getAssociation(fieldName);
if (field == null) {
throw new ScimpiException("No field " + fieldName + " in " + object.getSpecification().getFullIdentifier());
@@ -49,7 +49,7 @@ public class FieldName extends AbstractElementProcessor {
if (field.isVisible(IsisContext.getAuthenticationSession(), object, where).isVetoed()) {
throw new ForbiddenException(field, ForbiddenException.VISIBLE);
}
- request.appendAsHtmlEncoded(field.getName());
+ tagProcessor.appendAsHtmlEncoded(field.getName());
}
@Override
@@ -57,7 +57,7 @@ public class FieldName extends AbstractElementProcessor {
return "field-name";
}
- public static void write(final Request content, final ObjectAssociation field) {
+ public static void write(final TagProcessor content, final ObjectAssociation field) {
content.appendHtml("<span class=\"label\" title=\"" + field.getDescription() + "\">");
content.appendHtml("</span>");
}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/ParameterName.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/ParameterName.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/ParameterName.java
index 84e2204..029b819 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/ParameterName.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/ParameterName.java
@@ -24,20 +24,20 @@ import java.util.List;
import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
import org.apache.isis.core.metamodel.spec.feature.ObjectActionParameter;
-import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.ScimpiException;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
+import org.apache.isis.viewer.scimpi.ScimpiException;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
import org.apache.isis.viewer.scimpi.dispatcher.util.MethodsUtils;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
public class ParameterName extends AbstractElementProcessor {
@Override
- public void process(final Request request) {
- final String objectId = request.getOptionalProperty(OBJECT);
- final String methodName = request.getRequiredProperty(METHOD);
- final String field = request.getOptionalProperty(PARAMETER_NUMBER);
+ public void process(final TagProcessor tagProcessor) {
+ final String objectId = tagProcessor.getOptionalProperty(OBJECT);
+ final String methodName = tagProcessor.getRequiredProperty(METHOD);
+ final String field = tagProcessor.getOptionalProperty(PARAMETER_NUMBER);
- final ObjectAdapter object = MethodsUtils.findObject(request.getContext(), objectId);
+ final ObjectAdapter object = MethodsUtils.findObject(tagProcessor.getContext(), objectId);
final ObjectAction action = MethodsUtils.findAction(object, methodName);
final List<ObjectActionParameter> parameters = action.getParameters();
@@ -51,7 +51,7 @@ public class ParameterName extends AbstractElementProcessor {
throw new ScimpiException("Parameter numbers should be between 1 and " + parameters.size() + ": " + index);
}
- request.appendAsHtmlEncoded(parameters.get(index).getName());
+ tagProcessor.appendAsHtmlEncoded(parameters.get(index).getName());
}
@Override
[09/24] Restructuring Scimpi to remove dependencies and enable easier
testing.
Posted by rm...@apache.org.
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/ErrorCollator.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/ErrorCollator.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/ErrorCollator.java
new file mode 100644
index 0000000..7fc980a
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/ErrorCollator.java
@@ -0,0 +1,145 @@
+/*
+ * 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.context;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.PrintWriter;
+import java.util.List;
+
+import org.apache.isis.core.commons.config.ConfigurationConstants;
+import org.apache.isis.core.commons.debug.DebugBuilder;
+import org.apache.isis.core.commons.debug.DebugHtmlString;
+import org.apache.isis.core.commons.debug.DebugString;
+import org.apache.isis.core.commons.debug.DebugTee;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.viewer.scimpi.DebugHtmlWriter;
+import org.apache.log4j.Logger;
+
+public class ErrorCollator {
+ private static final Logger LOG = Logger.getLogger(ErrorCollator.class);
+
+ private String errorRef;
+ private String message;
+ private final DebugString debugText = new DebugString();
+ private final DebugHtmlString debugHtml = new DebugHtmlString();
+ private final DebugBuilder debug = new DebugTee(debugText, debugHtml);
+
+ public void missingFile(String message) {
+ this.message = message;
+ }
+
+ public void message(final Throwable exception) {
+ LOG.debug(exception.getMessage(), exception);
+ message = exception.getMessage();
+ debug.appendPreformatted(message);
+ }
+
+ public void exception(final Throwable exception) {
+ String messageText = exception.getMessage();
+ LOG.debug(messageText, exception);
+ try {
+ debug.startSection("Exception");
+ debug.appendException(exception);
+ debug.endSection();
+ } catch (final RuntimeException e) {
+ debug.appendln("NOTE - an exception occurred while dumping an exception!");
+ debug.appendException(e);
+ }
+ message = messageText == null ? exception.getClass().getName() : messageText;
+ }
+
+ public DebugBuilder getDebug() {
+ return debug;
+ }
+
+ public void compileError(final Request request) {
+ errorRef = Long.toString(System.currentTimeMillis(), 36).toUpperCase();
+ LOG.info("error " + errorRef);
+
+ captureWarningsAndMessages();
+ dumpDebugDetails(request);
+ writeErrorFile();
+ }
+
+ private void captureWarningsAndMessages() {
+ // Capture warnings/messages
+ if (IsisContext.getCurrentTransaction() != null) {
+ final List<String> messages = IsisContext.getMessageBroker().getMessages();
+ final List<String> warnings = IsisContext.getMessageBroker().getWarnings();
+ if (messages.size() > 0 || messages.size() > 0) {
+ debug.startSection("Warnings/Messages");
+ for (final String message : messages) {
+ debug.appendln("message", message);
+ }
+ for (final String message : warnings) {
+ debug.appendln("warning", message);
+ }
+ }
+ }
+ }
+
+ private void dumpDebugDetails(final Request request) {
+ // Dump page debug details
+ request.append(debug);
+
+ debug.startSection("Processing Trace");
+ debug.appendPreformatted(request.getDebugTrace());
+ debug.endSection();
+ debug.close();
+ }
+
+ private void writeErrorFile() {
+ LOG.error(message + "\n" + debugText.toString());
+
+
+ PrintWriter writer;
+ try {
+ final String directory =
+ IsisContext.getConfiguration().getString(ConfigurationConstants.ROOT + "scimpi.error-snapshots", ".");
+ File dir = new File(directory);
+ if (!dir.exists()) {
+ dir.mkdirs();
+ }
+ writer = new PrintWriter(new File(dir, "error_" + errorRef + ".html"));
+ final DebugHtmlWriter writer2 = new DebugHtmlWriter(writer, true);
+ writer2.concat(debugHtml);
+ writer2.close();
+ writer.close();
+ } catch (final FileNotFoundException e) {
+ LOG.error("Failed to archive error page", e);
+ }
+ }
+
+ public String getReference() {
+ return errorRef;
+ }
+
+ public String getDetails() {
+ return debugHtml.toString();
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+
+}
+
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/IndirectObjectMapping.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/IndirectObjectMapping.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/IndirectObjectMapping.java
index 3d88a44..e138b99 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/IndirectObjectMapping.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/IndirectObjectMapping.java
@@ -21,7 +21,6 @@ package org.apache.isis.viewer.scimpi.dispatcher.context;
import java.util.HashMap;
import java.util.Iterator;
-import java.util.LinkedHashMap;
import java.util.Map;
import java.util.TreeSet;
@@ -30,7 +29,7 @@ import com.google.common.collect.Maps;
import org.apache.isis.core.commons.debug.DebugBuilder;
import org.apache.isis.core.commons.exceptions.NotYetImplementedException;
import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
public class IndirectObjectMapping implements ObjectMapping {
private final Map<Scope, Map<String, Mapping>> scopedMappings = Maps.newLinkedHashMap();
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/ObjectMapping.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/ObjectMapping.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/ObjectMapping.java
index 9fe4013..abd89cf 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/ObjectMapping.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/ObjectMapping.java
@@ -21,7 +21,7 @@ package org.apache.isis.viewer.scimpi.dispatcher.context;
import org.apache.isis.core.commons.debug.DebugBuilder;
import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
public interface ObjectMapping {
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/PropertyException.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/PropertyException.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/PropertyException.java
new file mode 100644
index 0000000..fee7c0a
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/PropertyException.java
@@ -0,0 +1,44 @@
+/*
+ * 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.context;
+
+import org.apache.isis.viewer.scimpi.ScimpiException;
+
+public class PropertyException extends ScimpiException {
+
+ private static final long serialVersionUID = 1L;
+
+ public PropertyException() {
+ super();
+ }
+
+ public PropertyException(final String message, final Throwable cause) {
+ super(message, cause);
+ }
+
+ public PropertyException(final String message) {
+ super(message);
+ }
+
+ public PropertyException(final Throwable cause) {
+ super(cause);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/Request.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/Request.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/Request.java
new file mode 100644
index 0000000..605bb65
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/Request.java
@@ -0,0 +1,864 @@
+/*
+ * 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.context;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.PrintWriter;
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.TreeSet;
+
+import com.google.common.collect.Maps;
+
+import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.log4j.Logger;
+
+import org.apache.isis.core.commons.authentication.AuthenticationSession;
+import org.apache.isis.core.commons.debug.DebugBuilder;
+import org.apache.isis.core.commons.factory.InstanceUtil;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.adapter.oid.AggregatedOid;
+import org.apache.isis.core.metamodel.adapter.oid.OidMarshaller;
+import org.apache.isis.core.metamodel.adapter.oid.RootOid;
+import org.apache.isis.core.metamodel.adapter.oid.TypedOid;
+import org.apache.isis.core.metamodel.adapter.version.Version;
+import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacet;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.core.runtime.system.persistence.Persistor;
+import org.apache.isis.viewer.scimpi.Names;
+import org.apache.isis.viewer.scimpi.ScimpiException;
+import org.apache.isis.viewer.scimpi.security.DebugUsers;
+
+public abstract class Request {
+ private static final Logger LOG = Logger.getLogger(Request.class);
+ static final String TRANSIENT_OBJECT_OID_MARKER = "~";
+
+ public enum Scope {
+ GLOBAL, SESSION, INTERACTION, REQUEST, ERROR
+ };
+
+ public enum Debug {
+ ON, OFF, PAGE
+ }
+
+ public static Scope scope(final String scopeName) {
+ final String name = scopeName.toUpperCase();
+ if (name.equals(Scope.GLOBAL.toString())) {
+ return Scope.GLOBAL;
+ } else if (name.equals(Scope.SESSION.toString())) {
+ return Scope.SESSION;
+ } else if (name.equals(Scope.INTERACTION.toString())) {
+ return Scope.INTERACTION;
+ } else if (name.equals(Scope.REQUEST.toString())) {
+ return Scope.REQUEST;
+ }
+ throw new IllegalArgumentException("Invalid scope name: " + scopeName);
+ }
+
+ public static Scope scope(final String scopeName, final Scope defaultScope) {
+ if (scopeName == null || scopeName.trim().equals("")) {
+ return defaultScope;
+ } else {
+ return scope(scopeName);
+ }
+ }
+
+
+ @Deprecated
+ public static final String RESULT = "_result";
+ @Deprecated
+ public static final String ERROR = "_error";
+ @Deprecated
+ public static final String BACK_TO = "_back_to";
+ private static final Map<String, Object> globalVariables = new HashMap<String, Object>();
+ private static final Scope[] SCOPES = new Scope[] { Scope.ERROR, Scope.REQUEST, Scope.INTERACTION, Scope.SESSION, Scope.GLOBAL };
+
+ private final OidMarshaller oidMarshaller = new OidMarshaller();
+
+
+ private final ObjectMapping objectMapping;
+ private final VersionMapping versionMapping;
+ private final Map<Scope, Map<String, Object>> variables;
+ private final StringBuffer debugTrace = new StringBuffer();
+ private final DebugUsers debugUsers;
+
+ private String forwardTo;
+ private String requestedFile;
+ private String requestedParentPath;
+ private AuthenticationSession session;
+ private Debug debug;
+ private String resourceFile;
+ private String resourceParentPath;
+ private ObjectAdapter collection;
+ private boolean isUserAuthenticated;
+
+ public Request(final DebugUsers debugUsers) {
+ this.debugUsers = debugUsers;
+
+ String className = IsisContext.getConfiguration().getString("scimpi.object-mapping.class", DefaultOidObjectMapping.class.getName());
+ objectMapping = InstanceUtil.createInstance(className, ObjectMapping.class);
+ className = IsisContext.getConfiguration().getString("scimpi.version-mapping.class", DefaultVersionMapping.class.getName());
+ versionMapping = InstanceUtil.createInstance(className, VersionMapping.class);
+ variables = new HashMap<Scope, Map<String, Object>>();
+
+ variables.put(Scope.GLOBAL, globalVariables);
+ variables.put(Scope.SESSION, Maps.<String, Object>newHashMap());
+ variables.put(Scope.INTERACTION, Maps.<String, Object>newHashMap());
+ variables.put(Scope.REQUEST, Maps.<String, Object>newHashMap());
+ variables.put(Scope.ERROR, Maps.<String, Object>newHashMap());
+ }
+
+ public void endHttpSession() {
+ objectMapping.endSession();
+ variables.get(Scope.SESSION).clear();
+ session = null;
+ clearSession();
+ }
+
+ // //////////////////////////////////////////////////////////////////
+ // Mapped objects
+ // //////////////////////////////////////////////////////////////////
+
+ public ObjectAdapter getMappedObject(final String oidStr) {
+ if (oidStr == null || oidStr.trim().equals("") || oidStr.trim().equals("null")) {
+ return null;
+ }
+ if (oidStr.equals("collection")) {
+ return collection;
+ }
+ final ObjectAdapter adapter = mappedObject(oidStr);
+ if (adapter == null) {
+ throw new ScimpiException("No object for " + oidStr);
+ }
+ return adapter;
+ }
+
+ public ObjectAdapter getMappedObjectOrResult(final String id) {
+ return getMappedObjectOrVariable(id, RESULT);
+ }
+
+ public ObjectAdapter getMappedObjectOrVariable(String idOrData, final String name) {
+ if (idOrData == null) {
+ idOrData = (String) getVariable(name);
+ if (idOrData == null) {
+ throw new ScimpiException("No variable for " + name);
+ }
+ }
+ if (idOrData.equals("collection")) {
+ return collection;
+ }
+ return getMappedObject(idOrData);
+ }
+
+ public String mapObject(final ObjectAdapter object, final String scopeName, final Scope defaultScope) {
+ final Scope scope = scopeName == null ? defaultScope : scope(scopeName);
+ LOG.debug("mapping " + object + " " + scope);
+ return objectMapping.mapObject(object, scope);
+ }
+
+ private ObjectAdapter mappedObject(String dataOrOid) {
+ if (dataOrOid != null && dataOrOid.equals("")) {
+ return null;
+ }
+ if (dataOrOid == null) {
+ dataOrOid = RESULT;
+ }
+
+ if (dataOrOid.startsWith(TRANSIENT_OBJECT_OID_MARKER + "{")) {
+ return objectMapping.mappedTransientObject(StringEscapeUtils.unescapeHtml(dataOrOid.substring(TRANSIENT_OBJECT_OID_MARKER.length())));
+ }
+
+ final String oidStr = dataOrOid;
+ final TypedOid typedOid = getOidMarshaller().unmarshal(oidStr, TypedOid.class);
+ if(typedOid instanceof RootOid) {
+// final String[] idParts = dataOrOid.split("@");
+// if (idParts.length == 2) {
+ final ObjectAdapter mappedObject = objectMapping.mappedObject(oidStr);
+ if (mappedObject != null) {
+ getPersistenceSession().resolveImmediately(mappedObject);
+ }
+ return mappedObject;
+ }
+
+ //
+ // else, handle aggregate
+ //
+ AggregatedOid aggregatedOid = (AggregatedOid) typedOid;
+ final TypedOid parentOid = aggregatedOid.getParentOid();
+
+ //final ObjectAdapter parentAdapter = objectMapping.mappedObject(idParts[0] + "@" + idParts[1]);
+ final ObjectAdapter parentAdapter = objectMapping.mappedObject(parentOid.enString(getOidMarshaller()));
+ getPersistenceSession().resolveImmediately(parentAdapter);
+
+ //ObjectSpecId objectType = null;
+ //final AggregatedOid aggregatedOid = new AggregatedOid(objectType, (TypedOid) parentAdapter.getOid(), idParts[2]);
+
+ ObjectAdapter aggregatedAdapter = null;
+ outer: for (final ObjectAssociation association : parentAdapter.getSpecification().getAssociations()) {
+ if (association.getSpecification().isParented()) {
+ final ObjectAdapter objectAdapter = association.get(parentAdapter);
+ if (objectAdapter == null) {
+ continue;
+ }
+ if (association.isOneToManyAssociation()) {
+ final ObjectAdapter coll = objectAdapter;
+ final CollectionFacet facet = coll.getSpecification().getFacet(CollectionFacet.class);
+ for (final ObjectAdapter element : facet.iterable(coll)) {
+ if (element.getOid().equals(aggregatedOid)) {
+ aggregatedAdapter = element;
+ break outer;
+ }
+ }
+ } else {
+ if (objectAdapter.getOid().equals(aggregatedOid)) {
+ aggregatedAdapter = objectAdapter;
+ break;
+ }
+ }
+ } else if (association.isOneToManyAssociation()) {
+ if (association.getId().equals(aggregatedOid.getLocalId())) {
+ //if (association.getId().equals(idParts[2])) {
+ return association.get(parentAdapter);
+ }
+ }
+ }
+ return aggregatedAdapter;
+ }
+
+
+ public boolean isInternalRequest() {
+ final String referrer = getHeader("Referer"); // Note spelling mistake
+ // is intentional
+ return referrer != null && referrer.contains("localhost"); // TODO need
+ // to look
+ // for actual
+ // domain
+ }
+
+ // //////////////////////////////////////////////////////////////////
+ // Version
+ // //////////////////////////////////////////////////////////////////
+
+ public String mapVersion(final ObjectAdapter object) {
+ final Version version = object.getVersion();
+ return version == null ? "" : versionMapping.mapVersion(version);
+ }
+
+ public Version getVersion(final String id) {
+ if (id.equals("")) {
+ return null;
+ }
+ return versionMapping.getVersion(id);
+ }
+
+ // ////////////////////////////
+ // Debug
+ // ////////////////////////////
+ public void append(final DebugBuilder debug) {
+ debug.startSection("Scimpi Request");
+
+ debug.appendTitle("User");
+ final AuthenticationSession session = getSession();
+ debug.appendln("Authentication Session", session);
+ if (session != null) {
+ debug.appendln("Name", session.getUserName());
+ debug.appendln("Roles", session.getRoles());
+ }
+
+ debug.appendTitle("context");
+ debug.appendln("Parent request path", requestedParentPath);
+ debug.appendln("Requested file", requestedFile);
+ debug.appendln("Parent resource path", resourceParentPath);
+ debug.appendln("Resource file", resourceFile);
+ debug.endSection();
+
+ debug.startSection("Variables");
+ append(debug, Scope.GLOBAL);
+ append(debug, Scope.SESSION);
+ append(debug, Scope.INTERACTION);
+ append(debug, Scope.REQUEST);
+ append(debug, Scope.ERROR);
+ debug.endSection();
+
+ debug.startSection("Object Mapping");
+ objectMapping.append(debug);
+ debug.endSection();
+ }
+
+ private void append(final DebugBuilder view, final Scope scope) {
+ final Map<String, Object> map = variables.get(scope);
+ final Iterator<String> keys = new TreeSet<String>(map.keySet()).iterator();
+ if (keys.hasNext()) {
+ view.appendTitle(scope + " scoped variables");
+ while (keys.hasNext()) {
+ final String key = keys.next();
+ final Object object = map.get(key);
+ final String mappedTo = "";
+ view.appendln(key, object + mappedTo);
+ }
+ }
+ }
+
+ public void append(final DebugBuilder debug, final String list) {
+ if (list.equals("variables")) {
+ appendVariables(debug, Scope.GLOBAL);
+ appendVariables(debug, Scope.SESSION);
+ appendVariables(debug, Scope.INTERACTION);
+ appendVariables(debug, Scope.REQUEST);
+ appendVariables(debug, Scope.ERROR);
+ } else if (list.equals("mappings")) {
+ objectMapping.appendMappings(debug);
+ }
+ }
+
+ private void appendVariables(final DebugBuilder debug, final Scope scope) {
+ final Map<String, Object> map = variables.get(scope);
+ final Iterator<String> names = new TreeSet(map.keySet()).iterator();
+ if (names.hasNext()) {
+ debug.startSection(scope.toString());
+ while (names.hasNext()) {
+ final String name = names.next();
+ try {
+ final Object object = map.get(name);
+ String details = "";
+ if (object instanceof String) {
+ final ObjectAdapter mappedObject = mappedObject((String) object);
+ if (mappedObject != null) {
+ details = mappedObject.toString();
+ }
+ }
+ debug.appendln(name, object + " " + details);
+ } catch (final Exception e) {
+ debug.appendln(name, map.get(name));
+ }
+ }
+ debug.endSection();
+ }
+ }
+
+ public List<String> getDebugUsers() {
+ return debugUsers.getNames();
+ }
+
+ // ////////////////////////////
+ // Variables
+ // ////////////////////////////
+
+ public void clearVariables(final Scope scope) {
+ variables.get(scope).clear();
+ }
+
+ public void changeScope(final String name, final Scope newScope) {
+ for (final Scope element : SCOPES) {
+ final Map<String, Object> map = variables.get(element);
+ final Object object = map.get(name);
+ if (object != null) {
+ map.remove(name);
+ addVariable(name, object, newScope);
+ return;
+ }
+ }
+ }
+
+ public void clearVariable(String name, final Scope scope) {
+ name = name != null ? name : RESULT;
+ variables.get(scope).remove(name);
+ }
+
+ public void addVariable(final String name, final Object value, final String scope) {
+ addVariable(name, value, scope(scope));
+ }
+
+ public void addVariable(String name, final Object value, final Scope scope) {
+ name = name != null ? name : RESULT;
+ if (scope == Scope.SESSION && value != null && !(value instanceof Serializable)) {
+ throw new ScimpiException("SESSION scoped variable (" + name + ") must be serializable: " + value);
+ }
+ removeExistingVariable(name);
+ variables.get(scope).put(name, value);
+ }
+
+ private void removeExistingVariable(final String name) {
+ for (final Scope element : SCOPES) {
+ final Map<String, Object> map = variables.get(element);
+ final Object object = map.get(name);
+ if (object != null) {
+ map.remove(name);
+ break;
+ }
+ }
+ }
+
+ public String getStringVariable(final String name) {
+ final String value = (String) getVariable(name);
+ if (value == null) {
+ return null;
+ } else {
+ return replaceVariables(value);
+ }
+ }
+
+ public Object getVariable(final String name) {
+ for (final Scope element : SCOPES) {
+ final Map<String, Object> map = variables.get(element);
+ final Object object = map.get(name);
+ if (object != null) {
+ return object;
+ }
+ }
+ return null;
+ }
+
+ public String replaceVariables(String value) {
+ final int start = value.indexOf("${");
+ if (start == -1) {
+ return value;
+ } else {
+ final int end = value.indexOf('}');
+ if (end == -1) {
+ throw new PropertyException("No closing brace in " + value.substring(start));
+ } else if (end < start) {
+ throw new PropertyException("Closing brace before opening brace in " + value.substring(end));
+ }
+ final String name = value.substring(start + 2, end);
+ if (name != null) {
+ final int pos = name.indexOf(":");
+ final String variableName = pos == -1 ? name : name.substring(0, pos);
+ final String qualifier = pos == -1 ? "none" : name.substring(pos);
+ Object replacementValue;
+ final boolean embed = qualifier.indexOf("embed") > -1;
+ if (embed) {
+ replacementValue = "${" + variableName + "}";
+ } else {
+ replacementValue = getParameter(variableName);
+ if (replacementValue == null) {
+ replacementValue = getVariable(variableName);
+ }
+ if (replacementValue == null) {
+ replacementValue = getBuiltIn(variableName);
+ }
+
+ if (replacementValue == null) {
+ final boolean ensureExists = qualifier.indexOf("optional") == -1;
+ if (ensureExists) {
+ throw new PropertyException("No value for the variable " + value.substring(start, end + 1));
+ } else {
+ replacementValue = "";
+ }
+ }
+ }
+ final boolean repeat = qualifier.indexOf("repeat") > -1;
+ if (repeat) {
+ value = value.substring(0, start) + replacementValue + value.substring(end + 1);
+ return replaceVariables(value);
+ } else {
+ final String remainder = replaceVariables(value.substring(end + 1));
+ value = value.substring(0, start) + replacementValue + remainder;
+ return value;
+ }
+
+ } else {
+ throw new PropertyException("No variable name speceified");
+ }
+ }
+ }
+
+ private Object getBuiltIn(final String name) {
+ if (name.equals("_session")) {
+ return getSessionId();
+ } else if (name.equals("_context")) {
+ return getContextPath();
+ } else if (name.equals("_this")) {
+ return resourceFile;
+ } else if (name.equals("_directory")) {
+ return resourceParentPath;
+ } else if (name.equals("_base")) {
+ return getUrlBase() + getContextPath() + resourceParentPath + resourceFile;
+ // return "http://localhost:8080" + resourceParentPath +
+ // resourceFile;
+ }
+ return null;
+ }
+
+ public String encodedInteractionParameters() {
+ final StringBuffer buffer = new StringBuffer();
+ final Map<String, Object> map = variables.get(Scope.INTERACTION);
+ final Iterator<Entry<String, Object>> iterator = map.entrySet().iterator();
+ while (iterator.hasNext()) {
+ final Entry<String, Object> entry = iterator.next();
+ buffer.append("&" + entry.getKey() + "=" + entry.getValue());
+ }
+ return buffer.toString();
+ }
+
+ public String interactionFields() {
+ final StringBuffer buffer = new StringBuffer();
+ final Map<String, Object> map = variables.get(Scope.INTERACTION);
+ final Iterator<Entry<String, Object>> iterator = map.entrySet().iterator();
+ while (iterator.hasNext()) {
+ final Entry<String, Object> entry = iterator.next();
+ buffer.append("<input type=\"hidden\" name=\"" + entry.getKey() + "\" value=\"" + entry.getValue() + "\" />\n");
+ }
+ return buffer.toString();
+ }
+
+ protected abstract String getSessionId();
+
+ public abstract void addCookie(String name, String value, int minutesUtilExpires);
+
+ public abstract String getCookie(String name);
+
+
+
+ // /////////////////////////////////////////////////
+ // Start/end request
+ // /////////////////////////////////////////////////
+
+ public void endRequest() throws IOException {
+ getWriter().close();
+ objectMapping.clear();
+ variables.get(Scope.ERROR).clear();
+ variables.get(Scope.REQUEST).clear();
+ variables.get(Scope.INTERACTION).clear();
+ }
+
+ public void startRequest() {
+ debugTrace.setLength(0);
+ objectMapping.reloadIdentityMap();
+ final String debugParameter = getParameter("debug");
+ if (debugParameter != null) {
+ if (debugParameter.equals("off")) {
+ debug = Debug.OFF;
+ } else if (debugParameter.equals("on")) {
+ debug = Debug.ON;
+ } else if (debugParameter.equals("page")) {
+ debug = Debug.PAGE;
+ }
+ }
+ }
+
+ public abstract PrintWriter getWriter();
+
+ // /////////////////////////////
+ // Forwarding
+ // /////////////////////////////
+ public void forwardTo(final String forwardTo) {
+ this.forwardTo = "/" + forwardTo;
+ }
+
+ public String forwardTo() {
+ final String returnForwardTo = forwardTo;
+ forwardTo = null;
+ return returnForwardTo;
+ }
+
+ // /////////////////////////////
+ // Parameters
+ // /////////////////////////////
+ public void addParameter(final String name, final String parameter) {
+ if (name == null) {
+ throw new ScimpiException("Name must be specified for parameter " + parameter);
+ }
+ addVariable(name, parameter, Scope.REQUEST);
+ }
+
+ public String getParameter(final String name) {
+ final Object variable = getVariable(name);
+ if (variable instanceof String || variable == null) {
+ return (String) variable;
+ } else {
+ return variable.toString();
+ }
+ }
+
+ public Iterator<Entry<String, Object>> interactionParameters() {
+ final Map<String, Object> map = variables.get(Scope.REQUEST);
+ final Iterator<Entry<String, Object>> iterator = map.entrySet().iterator();
+ return iterator;
+ }
+
+ // ///////////////////////////////////////
+ // Requested file
+ // ///////////////////////////////////////
+
+ /**
+ * The requested file is the file that the browser requested. This may or
+ * may not be the file that is actually processed and returned; that is the
+ * {@link #getResourceFile()}.
+ */
+ public String getRequestedFile() {
+ return requestedFile;
+ }
+
+ public void setRequestPath(final String filePath) {
+ setRequestPath(filePath, null);
+ }
+
+ public void setRequestPath(final String filePath, String defaultGenericPath) {
+ if (filePath == null) {
+ defaultGenericPath = defaultGenericPath == null ? "" : defaultGenericPath;
+ this.requestedFile = Names.GENERIC + defaultGenericPath + "." + Names.EXTENSION;
+ } else if (filePath.startsWith("_generic")) {
+ this.requestedParentPath = "/";
+ LOG.debug("generic file, requested path cleared");
+ this.requestedFile = filePath;
+ LOG.debug("requested file set = " + filePath);
+
+ } else {
+ final int lastSlash = filePath.lastIndexOf('/');
+ if (lastSlash == -1) {
+ throw new ScimpiException("No slash in request path: " + filePath);
+ }
+ final String path = filePath.substring(0, lastSlash + 1);
+ LOG.debug("requested path set = " + path);
+ this.requestedParentPath = path;
+
+ final String file = filePath.substring(lastSlash + 1);
+ LOG.debug("requested file set = " + file);
+ this.requestedFile = file;
+ }
+ }
+
+ public void clearRequestedPath() {
+ this.requestedParentPath = null;
+ this.requestedFile = null;
+ }
+
+ /**
+ * Returns the absolute file system path to the specified resource based on
+ * the path used for the current request during the call to
+ * {@link #setRequestPath(String)}. The return path can then be used to
+ * access the specified resource. If the resource has a leading slash (/)
+ * then that resource string is returned as the path.
+ */
+ public String requestedFilePath(final String resource) {
+ if (resource.startsWith("/")) {
+ return resource;
+ } else {
+ return requestedParentPath + resource;
+ }
+ }
+
+ // ///////////////////////////////////////
+ // Resource file
+ // ///////////////////////////////////////
+
+ /**
+ * The resource file is the file on disk that is processed and returned to
+ * the browser. This may or may not be the file that was actually requested
+ * by the browser; that is the {@link #getRequestedFile()}.
+ */
+ public String getResourceFile() {
+ return resourceFile;
+ }
+
+ public String getResourceParentPath() {
+ return resourceParentPath;
+ }
+
+ public void setResourcePath(final String filePath) {
+ if (filePath == null) {
+ throw new ScimpiException("Path must be specified");
+ } else {
+ final int lastSlash = filePath.lastIndexOf('/');
+ if (lastSlash == -1) {
+ throw new ScimpiException("No slash in request path: " + filePath);
+ }
+ final String path = /* getContextPath() + */filePath.substring(0, lastSlash + 1);
+ LOG.debug("resource path set = " + path);
+ this.resourceParentPath = path;
+
+ final String file = filePath.substring(lastSlash + 1);
+ LOG.debug("resource file set = " + file);
+ this.resourceFile = file;
+ }
+ }
+
+ /**
+ * Returns a uri for the specified resource based on the path used for the
+ * current request (as set up during the call to
+ * {@link #setResourcePath(String)}). Such a uri when used by the browser
+ * will allow access to the specified resource. If the resource has a
+ * leading slash (/) or the resource is for a generic page (starts with
+ * "_generic") then that resource string is returned as the path.
+ */
+ public String fullUriPath(final String resource) {
+ if (resource.startsWith("/") || resource.startsWith("_generic")) {
+ return resource;
+ } else {
+ return getContextPath() + resourceParentPath + resource;
+ }
+ }
+
+ /**
+ * Returns the absolute file system path to the specified resource based on
+ * the path used for the current request (as set up during the call to
+ * {@link #setResourcePath(String)}). The return path can then be used to
+ * access the specified resource. If the resource has a leading slash (/) or
+ * the resource is for a generic page (starts with "_generic") then that
+ * resource string is returned as the path.
+ */
+ public String fullFilePath(final String resource) {
+ if (resource.startsWith("/") || resource.startsWith("_generic")) {
+ return resource;
+ } else {
+ return resourceParentPath + resource;
+ }
+ }
+
+ // //////////////////////////////////////////////////////////////////
+ //
+ // //////////////////////////////////////////////////////////////////
+
+ public String mapObject(final ObjectAdapter object, final Scope scope) {
+ if (object.isValue()) {
+ return object.titleString();
+ } else if (scope == Scope.INTERACTION && object.isTransient()) {
+ return objectMapping.mapTransientObject(object);
+ } else if (object.getOid() != null) {
+ return objectMapping.mapObject(object, scope);
+ } else {
+ collection = object;
+ return "collection";
+ }
+ }
+
+ public void unmapObject(final ObjectAdapter object, final Scope scope) {
+ objectMapping.unmapObject(object, scope);
+ }
+
+ public abstract String findFile(String fileName);
+
+ public abstract InputStream openStream(String path);
+
+ public abstract String imagePath(ObjectAdapter object);
+
+ public abstract String imagePath(ObjectSpecification specification);
+
+ public abstract void forward(String view);
+
+ public abstract void redirectTo(String view);
+
+ public abstract String getContextPath();
+
+ public abstract String getUrlBase();
+
+ public abstract String getHeader(String name);
+
+ public abstract String getQueryString();
+
+ public abstract void startHttpSession();
+
+ public abstract String clearSession();
+
+ public abstract boolean isAborted();
+
+ public abstract String getErrorReference();
+
+ public abstract String getErrorMessage();
+
+ public abstract String getErrorDetails();
+
+ public void setSession(final AuthenticationSession session) {
+ this.session = session;
+ addVariable("_auth_session", session, Scope.SESSION);
+ }
+
+ public AuthenticationSession getSession() {
+ return session;
+ }
+
+ public abstract String getUri();
+
+ public void raiseError(final int status, final ErrorCollator errorDetails) {
+ }
+
+ public void setContentType(final String string) {
+ }
+
+ public void setSessionData(final Map<String, Object> hashMap) {
+ variables.put(Scope.SESSION, hashMap);
+ session = (AuthenticationSession) getVariable("_auth_session");
+ Boolean authenticated = (Boolean) getVariable("_authenticated");
+ isUserAuthenticated = authenticated != null && authenticated.booleanValue();
+ }
+
+ public Map<String, Object> getSessionData() {
+ return variables.get(Scope.SESSION);
+ }
+
+ public Debug getDebug() {
+ return debug;
+ }
+
+ public boolean isDebugDisabled() {
+ return !debugUsers.isDebugEnabled(getSession());
+ }
+
+ public boolean isDebug() {
+ return getDebug() == Debug.ON;
+ }
+
+ public boolean showDebugData() {
+ final Boolean variable = (Boolean) getVariable("debug-on");
+ return variable != null && variable.booleanValue();
+ }
+
+ public String getDebugTrace() {
+ return debugTrace.toString().replace('<', '[').replace('>', ']');
+ }
+
+ public void appendDebugTrace(final String line) {
+ debugTrace.append(line);
+ }
+
+ public void clearTransientVariables() {
+ objectMapping.endSession();
+ }
+
+ public void reset() {
+ }
+
+ public boolean isUserAuthenticated() {
+ return isUserAuthenticated;
+ }
+
+ public void setUserAuthenticated(boolean isUserAuthenticated) {
+ this.isUserAuthenticated = isUserAuthenticated;
+ addVariable("_authenticated", isUserAuthenticated, Scope.SESSION);
+ }
+
+
+ protected Persistor getPersistenceSession() {
+ return IsisContext.getPersistenceSession();
+ }
+
+ protected OidMarshaller getOidMarshaller() {
+ return oidMarshaller;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/RequestContext.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/RequestContext.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/RequestContext.java
deleted file mode 100644
index d33affe..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/RequestContext.java
+++ /dev/null
@@ -1,862 +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.context;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.PrintWriter;
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.TreeSet;
-
-import com.google.common.collect.Maps;
-
-import org.apache.commons.lang.StringEscapeUtils;
-import org.apache.log4j.Logger;
-
-import org.apache.isis.core.commons.authentication.AuthenticationSession;
-import org.apache.isis.core.commons.debug.DebugBuilder;
-import org.apache.isis.core.commons.factory.InstanceUtil;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.adapter.oid.AggregatedOid;
-import org.apache.isis.core.metamodel.adapter.oid.OidMarshaller;
-import org.apache.isis.core.metamodel.adapter.oid.RootOid;
-import org.apache.isis.core.metamodel.adapter.oid.TypedOid;
-import org.apache.isis.core.metamodel.adapter.version.Version;
-import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacet;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.core.runtime.system.persistence.Persistor;
-import org.apache.isis.viewer.scimpi.dispatcher.Dispatcher;
-import org.apache.isis.viewer.scimpi.dispatcher.ErrorCollator;
-import org.apache.isis.viewer.scimpi.dispatcher.ScimpiException;
-import org.apache.isis.viewer.scimpi.dispatcher.action.PropertyException;
-import org.apache.isis.viewer.scimpi.dispatcher.debug.DebugUsers;
-
-public abstract class RequestContext {
- private static final Logger LOG = Logger.getLogger(RequestContext.class);
- static final String TRANSIENT_OBJECT_OID_MARKER = "~";
-
- public enum Scope {
- GLOBAL, SESSION, INTERACTION, REQUEST, ERROR
- };
-
- public enum Debug {
- ON, OFF, PAGE
- }
-
- public static Scope scope(final String scopeName) {
- final String name = scopeName.toUpperCase();
- if (name.equals(Scope.GLOBAL.toString())) {
- return Scope.GLOBAL;
- } else if (name.equals(Scope.SESSION.toString())) {
- return Scope.SESSION;
- } else if (name.equals(Scope.INTERACTION.toString())) {
- return Scope.INTERACTION;
- } else if (name.equals(Scope.REQUEST.toString())) {
- return Scope.REQUEST;
- }
- throw new IllegalArgumentException("Invalid scope name: " + scopeName);
- }
-
- public static Scope scope(final String scopeName, final Scope defaultScope) {
- if (scopeName == null || scopeName.trim().equals("")) {
- return defaultScope;
- } else {
- return scope(scopeName);
- }
- }
-
- public static final String RESULT = "_result";
- public static final String ERROR = "_error";
- public static final String BACK_TO = "_back_to";
- private static final Map<String, Object> globalVariables = new HashMap<String, Object>();
- private static final Scope[] SCOPES = new Scope[] { Scope.ERROR, Scope.REQUEST, Scope.INTERACTION, Scope.SESSION, Scope.GLOBAL };
-
- private final OidMarshaller oidMarshaller = new OidMarshaller();
-
-
- private final ObjectMapping objectMapping;
- private final VersionMapping versionMapping;
- private final Map<Scope, Map<String, Object>> variables;
- private final StringBuffer debugTrace = new StringBuffer();
- private final DebugUsers debugUsers;
-
- private String forwardTo;
- private String requestedFile;
- private String requestedParentPath;
- private AuthenticationSession session;
- private Debug debug;
- private String resourceFile;
- private String resourceParentPath;
- private ObjectAdapter collection;
- private boolean isUserAuthenticated;
-
- public RequestContext(final DebugUsers debugUsers) {
- this.debugUsers = debugUsers;
-
- String className = IsisContext.getConfiguration().getString("scimpi.object-mapping.class", DefaultOidObjectMapping.class.getName());
- objectMapping = InstanceUtil.createInstance(className, ObjectMapping.class);
- className = IsisContext.getConfiguration().getString("scimpi.version-mapping.class", DefaultVersionMapping.class.getName());
- versionMapping = InstanceUtil.createInstance(className, VersionMapping.class);
- variables = new HashMap<Scope, Map<String, Object>>();
-
- variables.put(Scope.GLOBAL, globalVariables);
- variables.put(Scope.SESSION, Maps.<String, Object>newHashMap());
- variables.put(Scope.INTERACTION, Maps.<String, Object>newHashMap());
- variables.put(Scope.REQUEST, Maps.<String, Object>newHashMap());
- variables.put(Scope.ERROR, Maps.<String, Object>newHashMap());
- }
-
- public void endHttpSession() {
- objectMapping.endSession();
- variables.get(Scope.SESSION).clear();
- session = null;
- clearSession();
- }
-
- // //////////////////////////////////////////////////////////////////
- // Mapped objects
- // //////////////////////////////////////////////////////////////////
-
- public ObjectAdapter getMappedObject(final String oidStr) {
- if (oidStr == null || oidStr.trim().equals("") || oidStr.trim().equals("null")) {
- return null;
- }
- if (oidStr.equals("collection")) {
- return collection;
- }
- final ObjectAdapter adapter = mappedObject(oidStr);
- if (adapter == null) {
- throw new ScimpiException("No object for " + oidStr);
- }
- return adapter;
- }
-
- public ObjectAdapter getMappedObjectOrResult(final String id) {
- return getMappedObjectOrVariable(id, RESULT);
- }
-
- public ObjectAdapter getMappedObjectOrVariable(String idOrData, final String name) {
- if (idOrData == null) {
- idOrData = (String) getVariable(name);
- if (idOrData == null) {
- throw new ScimpiException("No variable for " + name);
- }
- }
- if (idOrData.equals("collection")) {
- return collection;
- }
- return getMappedObject(idOrData);
- }
-
- public String mapObject(final ObjectAdapter object, final String scopeName, final Scope defaultScope) {
- final Scope scope = scopeName == null ? defaultScope : scope(scopeName);
- LOG.debug("mapping " + object + " " + scope);
- return objectMapping.mapObject(object, scope);
- }
-
- private ObjectAdapter mappedObject(String dataOrOid) {
- if (dataOrOid != null && dataOrOid.equals("")) {
- return null;
- }
- if (dataOrOid == null) {
- dataOrOid = RESULT;
- }
-
- if (dataOrOid.startsWith(TRANSIENT_OBJECT_OID_MARKER + "{")) {
- return objectMapping.mappedTransientObject(StringEscapeUtils.unescapeHtml(dataOrOid.substring(TRANSIENT_OBJECT_OID_MARKER.length())));
- }
-
- final String oidStr = dataOrOid;
- final TypedOid typedOid = getOidMarshaller().unmarshal(oidStr, TypedOid.class);
- if(typedOid instanceof RootOid) {
-// final String[] idParts = dataOrOid.split("@");
-// if (idParts.length == 2) {
- final ObjectAdapter mappedObject = objectMapping.mappedObject(oidStr);
- if (mappedObject != null) {
- getPersistenceSession().resolveImmediately(mappedObject);
- }
- return mappedObject;
- }
-
- //
- // else, handle aggregate
- //
- AggregatedOid aggregatedOid = (AggregatedOid) typedOid;
- final TypedOid parentOid = aggregatedOid.getParentOid();
-
- //final ObjectAdapter parentAdapter = objectMapping.mappedObject(idParts[0] + "@" + idParts[1]);
- final ObjectAdapter parentAdapter = objectMapping.mappedObject(parentOid.enString(getOidMarshaller()));
- getPersistenceSession().resolveImmediately(parentAdapter);
-
- //ObjectSpecId objectType = null;
- //final AggregatedOid aggregatedOid = new AggregatedOid(objectType, (TypedOid) parentAdapter.getOid(), idParts[2]);
-
- ObjectAdapter aggregatedAdapter = null;
- outer: for (final ObjectAssociation association : parentAdapter.getSpecification().getAssociations()) {
- if (association.getSpecification().isParented()) {
- final ObjectAdapter objectAdapter = association.get(parentAdapter);
- if (objectAdapter == null) {
- continue;
- }
- if (association.isOneToManyAssociation()) {
- final ObjectAdapter coll = objectAdapter;
- final CollectionFacet facet = coll.getSpecification().getFacet(CollectionFacet.class);
- for (final ObjectAdapter element : facet.iterable(coll)) {
- if (element.getOid().equals(aggregatedOid)) {
- aggregatedAdapter = element;
- break outer;
- }
- }
- } else {
- if (objectAdapter.getOid().equals(aggregatedOid)) {
- aggregatedAdapter = objectAdapter;
- break;
- }
- }
- } else if (association.isOneToManyAssociation()) {
- if (association.getId().equals(aggregatedOid.getLocalId())) {
- //if (association.getId().equals(idParts[2])) {
- return association.get(parentAdapter);
- }
- }
- }
- return aggregatedAdapter;
- }
-
-
- public boolean isInternalRequest() {
- final String referrer = getHeader("Referer"); // Note spelling mistake
- // is intentional
- return referrer != null && referrer.contains("localhost"); // TODO need
- // to look
- // for actual
- // domain
- }
-
- // //////////////////////////////////////////////////////////////////
- // Version
- // //////////////////////////////////////////////////////////////////
-
- public String mapVersion(final ObjectAdapter object) {
- final Version version = object.getVersion();
- return version == null ? "" : versionMapping.mapVersion(version);
- }
-
- public Version getVersion(final String id) {
- if (id.equals("")) {
- return null;
- }
- return versionMapping.getVersion(id);
- }
-
- // ////////////////////////////
- // Debug
- // ////////////////////////////
- public void append(final DebugBuilder debug) {
- debug.startSection("Scimpi Request");
-
- debug.appendTitle("User");
- final AuthenticationSession session = getSession();
- debug.appendln("Authentication Session", session);
- if (session != null) {
- debug.appendln("Name", session.getUserName());
- debug.appendln("Roles", session.getRoles());
- }
-
- debug.appendTitle("context");
- debug.appendln("Parent request path", requestedParentPath);
- debug.appendln("Requested file", requestedFile);
- debug.appendln("Parent resource path", resourceParentPath);
- debug.appendln("Resource file", resourceFile);
- debug.endSection();
-
- debug.startSection("Variables");
- append(debug, Scope.GLOBAL);
- append(debug, Scope.SESSION);
- append(debug, Scope.INTERACTION);
- append(debug, Scope.REQUEST);
- append(debug, Scope.ERROR);
- debug.endSection();
-
- debug.startSection("Object Mapping");
- objectMapping.append(debug);
- debug.endSection();
- }
-
- private void append(final DebugBuilder view, final Scope scope) {
- final Map<String, Object> map = variables.get(scope);
- final Iterator<String> keys = new TreeSet<String>(map.keySet()).iterator();
- if (keys.hasNext()) {
- view.appendTitle(scope + " scoped variables");
- while (keys.hasNext()) {
- final String key = keys.next();
- final Object object = map.get(key);
- final String mappedTo = "";
- view.appendln(key, object + mappedTo);
- }
- }
- }
-
- public void append(final DebugBuilder debug, final String list) {
- if (list.equals("variables")) {
- appendVariables(debug, Scope.GLOBAL);
- appendVariables(debug, Scope.SESSION);
- appendVariables(debug, Scope.INTERACTION);
- appendVariables(debug, Scope.REQUEST);
- appendVariables(debug, Scope.ERROR);
- } else if (list.equals("mappings")) {
- objectMapping.appendMappings(debug);
- }
- }
-
- private void appendVariables(final DebugBuilder debug, final Scope scope) {
- final Map<String, Object> map = variables.get(scope);
- final Iterator<String> names = new TreeSet(map.keySet()).iterator();
- if (names.hasNext()) {
- debug.startSection(scope.toString());
- while (names.hasNext()) {
- final String name = names.next();
- try {
- final Object object = map.get(name);
- String details = "";
- if (object instanceof String) {
- final ObjectAdapter mappedObject = mappedObject((String) object);
- if (mappedObject != null) {
- details = mappedObject.toString();
- }
- }
- debug.appendln(name, object + " " + details);
- } catch (final Exception e) {
- debug.appendln(name, map.get(name));
- }
- }
- debug.endSection();
- }
- }
-
- public List<String> getDebugUsers() {
- return debugUsers.getNames();
- }
-
- // ////////////////////////////
- // Variables
- // ////////////////////////////
-
- public void clearVariables(final Scope scope) {
- variables.get(scope).clear();
- }
-
- public void changeScope(final String name, final Scope newScope) {
- for (final Scope element : SCOPES) {
- final Map<String, Object> map = variables.get(element);
- final Object object = map.get(name);
- if (object != null) {
- map.remove(name);
- addVariable(name, object, newScope);
- return;
- }
- }
- }
-
- public void clearVariable(String name, final Scope scope) {
- name = name != null ? name : RESULT;
- variables.get(scope).remove(name);
- }
-
- public void addVariable(final String name, final Object value, final String scope) {
- addVariable(name, value, scope(scope));
- }
-
- public void addVariable(String name, final Object value, final Scope scope) {
- name = name != null ? name : RESULT;
- if (scope == Scope.SESSION && value != null && !(value instanceof Serializable)) {
- throw new ScimpiException("SESSION scoped variable (" + name + ") must be serializable: " + value);
- }
- removeExistingVariable(name);
- variables.get(scope).put(name, value);
- }
-
- private void removeExistingVariable(final String name) {
- for (final Scope element : SCOPES) {
- final Map<String, Object> map = variables.get(element);
- final Object object = map.get(name);
- if (object != null) {
- map.remove(name);
- break;
- }
- }
- }
-
- public String getStringVariable(final String name) {
- final String value = (String) getVariable(name);
- if (value == null) {
- return null;
- } else {
- return replaceVariables(value);
- }
- }
-
- public Object getVariable(final String name) {
- for (final Scope element : SCOPES) {
- final Map<String, Object> map = variables.get(element);
- final Object object = map.get(name);
- if (object != null) {
- return object;
- }
- }
- return null;
- }
-
- public String replaceVariables(String value) {
- final int start = value.indexOf("${");
- if (start == -1) {
- return value;
- } else {
- final int end = value.indexOf('}');
- if (end == -1) {
- throw new PropertyException("No closing brace in " + value.substring(start));
- } else if (end < start) {
- throw new PropertyException("Closing brace before opening brace in " + value.substring(end));
- }
- final String name = value.substring(start + 2, end);
- if (name != null) {
- final int pos = name.indexOf(":");
- final String variableName = pos == -1 ? name : name.substring(0, pos);
- final String qualifier = pos == -1 ? "none" : name.substring(pos);
- Object replacementValue;
- final boolean embed = qualifier.indexOf("embed") > -1;
- if (embed) {
- replacementValue = "${" + variableName + "}";
- } else {
- replacementValue = getParameter(variableName);
- if (replacementValue == null) {
- replacementValue = getVariable(variableName);
- }
- if (replacementValue == null) {
- replacementValue = getBuiltIn(variableName);
- }
-
- if (replacementValue == null) {
- final boolean ensureExists = qualifier.indexOf("optional") == -1;
- if (ensureExists) {
- throw new PropertyException("No value for the variable " + value.substring(start, end + 1));
- } else {
- replacementValue = "";
- }
- }
- }
- final boolean repeat = qualifier.indexOf("repeat") > -1;
- if (repeat) {
- value = value.substring(0, start) + replacementValue + value.substring(end + 1);
- return replaceVariables(value);
- } else {
- final String remainder = replaceVariables(value.substring(end + 1));
- value = value.substring(0, start) + replacementValue + remainder;
- return value;
- }
-
- } else {
- throw new PropertyException("No variable name speceified");
- }
- }
- }
-
- private Object getBuiltIn(final String name) {
- if (name.equals("_session")) {
- return getSessionId();
- } else if (name.equals("_context")) {
- return getContextPath();
- } else if (name.equals("_this")) {
- return resourceFile;
- } else if (name.equals("_directory")) {
- return resourceParentPath;
- } else if (name.equals("_base")) {
- return getUrlBase() + getContextPath() + resourceParentPath + resourceFile;
- // return "http://localhost:8080" + resourceParentPath +
- // resourceFile;
- }
- return null;
- }
-
- public String encodedInteractionParameters() {
- final StringBuffer buffer = new StringBuffer();
- final Map<String, Object> map = variables.get(Scope.INTERACTION);
- final Iterator<Entry<String, Object>> iterator = map.entrySet().iterator();
- while (iterator.hasNext()) {
- final Entry<String, Object> entry = iterator.next();
- buffer.append("&" + entry.getKey() + "=" + entry.getValue());
- }
- return buffer.toString();
- }
-
- public String interactionFields() {
- final StringBuffer buffer = new StringBuffer();
- final Map<String, Object> map = variables.get(Scope.INTERACTION);
- final Iterator<Entry<String, Object>> iterator = map.entrySet().iterator();
- while (iterator.hasNext()) {
- final Entry<String, Object> entry = iterator.next();
- buffer.append("<input type=\"hidden\" name=\"" + entry.getKey() + "\" value=\"" + entry.getValue() + "\" />\n");
- }
- return buffer.toString();
- }
-
- protected abstract String getSessionId();
-
- public abstract void addCookie(String name, String value, int minutesUtilExpires);
-
- public abstract String getCookie(String name);
-
-
-
- // /////////////////////////////////////////////////
- // Start/end request
- // /////////////////////////////////////////////////
-
- public void endRequest() throws IOException {
- getWriter().close();
- objectMapping.clear();
- variables.get(Scope.ERROR).clear();
- variables.get(Scope.REQUEST).clear();
- variables.get(Scope.INTERACTION).clear();
- }
-
- public void startRequest() {
- debugTrace.setLength(0);
- objectMapping.reloadIdentityMap();
- final String debugParameter = getParameter("debug");
- if (debugParameter != null) {
- if (debugParameter.equals("off")) {
- debug = Debug.OFF;
- } else if (debugParameter.equals("on")) {
- debug = Debug.ON;
- } else if (debugParameter.equals("page")) {
- debug = Debug.PAGE;
- }
- }
- }
-
- public abstract PrintWriter getWriter();
-
- // /////////////////////////////
- // Forwarding
- // /////////////////////////////
- public void forwardTo(final String forwardTo) {
- this.forwardTo = "/" + forwardTo;
- }
-
- public String forwardTo() {
- final String returnForwardTo = forwardTo;
- forwardTo = null;
- return returnForwardTo;
- }
-
- // /////////////////////////////
- // Parameters
- // /////////////////////////////
- public void addParameter(final String name, final String parameter) {
- if (name == null) {
- throw new ScimpiException("Name must be specified for parameter " + parameter);
- }
- addVariable(name, parameter, Scope.REQUEST);
- }
-
- public String getParameter(final String name) {
- final Object variable = getVariable(name);
- if (variable instanceof String || variable == null) {
- return (String) variable;
- } else {
- return variable.toString();
- }
- }
-
- public Iterator<Entry<String, Object>> interactionParameters() {
- final Map<String, Object> map = variables.get(Scope.REQUEST);
- final Iterator<Entry<String, Object>> iterator = map.entrySet().iterator();
- return iterator;
- }
-
- // ///////////////////////////////////////
- // Requested file
- // ///////////////////////////////////////
-
- /**
- * The requested file is the file that the browser requested. This may or
- * may not be the file that is actually processed and returned; that is the
- * {@link #getResourceFile()}.
- */
- public String getRequestedFile() {
- return requestedFile;
- }
-
- public void setRequestPath(final String filePath) {
- setRequestPath(filePath, null);
- }
-
- public void setRequestPath(final String filePath, String defaultGenericPath) {
- if (filePath == null) {
- defaultGenericPath = defaultGenericPath == null ? "" : defaultGenericPath;
- this.requestedFile = Dispatcher.GENERIC + defaultGenericPath + "." + Dispatcher.EXTENSION;
- } else if (filePath.startsWith("_generic")) {
- this.requestedParentPath = "/";
- LOG.debug("generic file, requested path cleared");
- this.requestedFile = filePath;
- LOG.debug("requested file set = " + filePath);
-
- } else {
- final int lastSlash = filePath.lastIndexOf('/');
- if (lastSlash == -1) {
- throw new ScimpiException("No slash in request path: " + filePath);
- }
- final String path = filePath.substring(0, lastSlash + 1);
- LOG.debug("requested path set = " + path);
- this.requestedParentPath = path;
-
- final String file = filePath.substring(lastSlash + 1);
- LOG.debug("requested file set = " + file);
- this.requestedFile = file;
- }
- }
-
- public void clearRequestedPath() {
- this.requestedParentPath = null;
- this.requestedFile = null;
- }
-
- /**
- * Returns the absolute file system path to the specified resource based on
- * the path used for the current request during the call to
- * {@link #setRequestPath(String)}. The return path can then be used to
- * access the specified resource. If the resource has a leading slash (/)
- * then that resource string is returned as the path.
- */
- public String requestedFilePath(final String resource) {
- if (resource.startsWith("/")) {
- return resource;
- } else {
- return requestedParentPath + resource;
- }
- }
-
- // ///////////////////////////////////////
- // Resource file
- // ///////////////////////////////////////
-
- /**
- * The resource file is the file on disk that is processed and returned to
- * the browser. This may or may not be the file that was actually requested
- * by the browser; that is the {@link #getRequestedFile()}.
- */
- public String getResourceFile() {
- return resourceFile;
- }
-
- public String getResourceParentPath() {
- return resourceParentPath;
- }
-
- public void setResourcePath(final String filePath) {
- if (filePath == null) {
- throw new ScimpiException("Path must be specified");
- } else {
- final int lastSlash = filePath.lastIndexOf('/');
- if (lastSlash == -1) {
- throw new ScimpiException("No slash in request path: " + filePath);
- }
- final String path = /* getContextPath() + */filePath.substring(0, lastSlash + 1);
- LOG.debug("resource path set = " + path);
- this.resourceParentPath = path;
-
- final String file = filePath.substring(lastSlash + 1);
- LOG.debug("resource file set = " + file);
- this.resourceFile = file;
- }
- }
-
- /**
- * Returns a uri for the specified resource based on the path used for the
- * current request (as set up during the call to
- * {@link #setResourcePath(String)}). Such a uri when used by the browser
- * will allow access to the specified resource. If the resource has a
- * leading slash (/) or the resource is for a generic page (starts with
- * "_generic") then that resource string is returned as the path.
- */
- public String fullUriPath(final String resource) {
- if (resource.startsWith("/") || resource.startsWith("_generic")) {
- return resource;
- } else {
- return getContextPath() + resourceParentPath + resource;
- }
- }
-
- /**
- * Returns the absolute file system path to the specified resource based on
- * the path used for the current request (as set up during the call to
- * {@link #setResourcePath(String)}). The return path can then be used to
- * access the specified resource. If the resource has a leading slash (/) or
- * the resource is for a generic page (starts with "_generic") then that
- * resource string is returned as the path.
- */
- public String fullFilePath(final String resource) {
- if (resource.startsWith("/") || resource.startsWith("_generic")) {
- return resource;
- } else {
- return resourceParentPath + resource;
- }
- }
-
- // //////////////////////////////////////////////////////////////////
- //
- // //////////////////////////////////////////////////////////////////
-
- public String mapObject(final ObjectAdapter object, final Scope scope) {
- if (object.isValue()) {
- return object.titleString();
- } else if (scope == Scope.INTERACTION && object.isTransient()) {
- return objectMapping.mapTransientObject(object);
- } else if (object.getOid() != null) {
- return objectMapping.mapObject(object, scope);
- } else {
- collection = object;
- return "collection";
- }
- }
-
- public void unmapObject(final ObjectAdapter object, final Scope scope) {
- objectMapping.unmapObject(object, scope);
- }
-
- public abstract String findFile(String fileName);
-
- public abstract InputStream openStream(String path);
-
- public abstract String imagePath(ObjectAdapter object);
-
- public abstract String imagePath(ObjectSpecification specification);
-
- public abstract void forward(String view);
-
- public abstract void redirectTo(String view);
-
- public abstract String getContextPath();
-
- public abstract String getUrlBase();
-
- public abstract String getHeader(String name);
-
- public abstract String getQueryString();
-
- public abstract void startHttpSession();
-
- public abstract String clearSession();
-
- public abstract boolean isAborted();
-
- public abstract String getErrorReference();
-
- public abstract String getErrorMessage();
-
- public abstract String getErrorDetails();
-
- public void setSession(final AuthenticationSession session) {
- this.session = session;
- addVariable("_auth_session", session, Scope.SESSION);
- }
-
- public AuthenticationSession getSession() {
- return session;
- }
-
- public abstract String getUri();
-
- public void raiseError(final int status, final ErrorCollator errorDetails) {
- }
-
- public void setContentType(final String string) {
- }
-
- public void setSessionData(final Map<String, Object> hashMap) {
- variables.put(Scope.SESSION, hashMap);
- session = (AuthenticationSession) getVariable("_auth_session");
- Boolean authenticated = (Boolean) getVariable("_authenticated");
- isUserAuthenticated = authenticated != null && authenticated.booleanValue();
- }
-
- public Map<String, Object> getSessionData() {
- return variables.get(Scope.SESSION);
- }
-
- public Debug getDebug() {
- return debug;
- }
-
- public boolean isDebugDisabled() {
- return !debugUsers.isDebugEnabled(getSession());
- }
-
- public boolean isDebug() {
- return getDebug() == Debug.ON;
- }
-
- public boolean showDebugData() {
- final Boolean variable = (Boolean) getVariable("debug-on");
- return variable != null && variable.booleanValue();
- }
-
- public String getDebugTrace() {
- return debugTrace.toString().replace('<', '[').replace('>', ']');
- }
-
- public void appendDebugTrace(final String line) {
- debugTrace.append(line);
- }
-
- public void clearTransientVariables() {
- objectMapping.endSession();
- }
-
- public void reset() {
- }
-
- public boolean isUserAuthenticated() {
- return isUserAuthenticated;
- }
-
- public void setUserAuthenticated(boolean isUserAuthenticated) {
- this.isUserAuthenticated = isUserAuthenticated;
- addVariable("_authenticated", isUserAuthenticated, Scope.SESSION);
- }
-
-
- protected Persistor getPersistenceSession() {
- return IsisContext.getPersistenceSession();
- }
-
- protected OidMarshaller getOidMarshaller() {
- return oidMarshaller;
- }
-
-}
[10/24] Restructuring Scimpi to remove dependencies and enable easier
testing.
Posted by rm...@apache.org.
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/Names.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/Names.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/Names.java
deleted file mode 100644
index 29b15e5..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/Names.java
+++ /dev/null
@@ -1,91 +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;
-
-public interface Names {
- static final String PREFIX = "_logon-";
-
- static final String BUTTON_TITLE = "button-title";
- static final String CANCEL_TO = "cancel-to";
- static final String COLLECTION = "collection";
- static final String CONFIRM = "confirm";
- static final String CLASS = "class";
- static final String CONTAINER_CLASS = "container-" + CLASS;
- static final String DEFAULT = "default";
- static final String ELEMENT_NAME = "element-name";
- static final String ELEMENT = "element";
- static final String EVEN_ROW_CLASS = "even-row";
- static final String FALSE = "false";
- static final String ERROR = "error";
- static final String FIELD = "field";
- static final String FIELD_NAME = "field-name";
- static final String FOOTER = "footer";
- static final String FORM_ID = "form-id";
- static final String FORM_TITLE = "title";
- static final String FORMS = "show-forms";
- static final String HEADER = "header";
- static final String ICON_CLASS = "icon";
- static final String HIDDEN = "hidden";
- static final String HIDE_UNEDITABLE = "hide-uneditable";
- static final String HEADER_LEVEL = "header";
- static final String ID = "id";
- static final String LABEL_DELIMITER = "label";
- static final String LINK_VIEW = "link-view";
- static final String LINK_NAME = "link-name";
- static final String LINK_OBJECT = "link-object";
- static final String METHOD = "method";
- static final String MESSAGE = "message";
- static final String NAME = "name";
- static final String ODD_ROW_CLASS = "odd-row";
- static final String OBJECT = "object";
- static final String PARAMETER = "param";
- static final String PARAMETER_NUMBER = "number";
- static final String PLURAL = "plural";
- static final String REFERENCE_NAME = "reference-name";
- static final String RESULT_NAME = "result-name";
- static final String RESULT_OVERRIDE = "result-override";
- static final String ROW_CLASSES = "row-classes";
- static final String SCOPE = "scope";
- static final String SHOW_ICON = "icon";
- static final String SHOW_SELECT = "select";
- static final String SHOW_EDIT = "edit";
- static final String SHOW_DELETE = "delete";
- static final String SHOW_MESSAGE = "show-message";
- static final String SHOW_TITLE = "show-title";
- static final String TRUNCATE = "truncate";
- static final String TABLE_TITLE = "title";
- static final String TYPE = "type";
- static final String VIEW = "view";
- static final String VALUE = "value";
- static final String VERSION = "version";
- static final String USER = "user";
- static final String VOID = "void";
- static final String WHEN = "when";
- static final String ENTRY_FIELDS = "entry-fields";
-
-
- static final String LOGON_OBJECT = PREFIX + OBJECT;
- static final String LOGON_METHOD = PREFIX + METHOD;
- static final String LOGON_SCOPE = PREFIX + SCOPE;
- static final String LOGON_RESULT_NAME = PREFIX + RESULT_NAME;
- static final String LOGON_FORM_ID = PREFIX + "form-id";
-
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/NotLoggedInException.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/NotLoggedInException.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/NotLoggedInException.java
deleted file mode 100644
index 9cd54a3..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/NotLoggedInException.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.viewer.scimpi.dispatcher;
-
-/**
- * Indicates that request could not complete as a user was not logged in.
- */
-public class NotLoggedInException extends ScimpiException {
- private static final long serialVersionUID = 1L;
-
- public NotLoggedInException() {
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/Response.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/Response.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/Response.java
new file mode 100644
index 0000000..173378e
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/Response.java
@@ -0,0 +1,6 @@
+package org.apache.isis.viewer.scimpi.dispatcher;
+
+public interface Response {
+
+}
+
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/ScimpiException.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/ScimpiException.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/ScimpiException.java
deleted file mode 100644
index 18e7646..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/ScimpiException.java
+++ /dev/null
@@ -1,44 +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;
-
-public class ScimpiException extends RuntimeException {
- private static final long serialVersionUID = 1L;
-
- public ScimpiException() {
- }
-
- public ScimpiException(final String message) {
- super(message);
- }
-
- public ScimpiException(final Throwable cause) {
- super(cause);
- }
-
- public ScimpiException(final String message, final Throwable cause) {
- super(message, cause);
- }
-
- public String getHtmlMessage() {
- return getMessage();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/ScimpiNotFoundException.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/ScimpiNotFoundException.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/ScimpiNotFoundException.java
index 6b1e77a..e448293 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/ScimpiNotFoundException.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/ScimpiNotFoundException.java
@@ -19,6 +19,8 @@
package org.apache.isis.viewer.scimpi.dispatcher;
+import org.apache.isis.viewer.scimpi.ScimpiException;
+
public class ScimpiNotFoundException extends ScimpiException {
public ScimpiNotFoundException() {
super();
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/TagOrderException.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/TagOrderException.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/TagOrderException.java
index 97e00e4..543d57b 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/TagOrderException.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/TagOrderException.java
@@ -19,13 +19,14 @@
package org.apache.isis.viewer.scimpi.dispatcher;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
+import org.apache.isis.viewer.scimpi.ScimpiException;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
public class TagOrderException extends ScimpiException {
private static final long serialVersionUID = 1L;
- public TagOrderException(final Request request) {
- super("Invalid tag in this context: " + request.getTag().getName());
+ public TagOrderException(final TagProcessor tagProcessor) {
+ super("Invalid tag in this context: " + tagProcessor.getTag().getName());
}
}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/UserManager.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/UserManager.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/UserManager.java
deleted file mode 100644
index 5009998..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/UserManager.java
+++ /dev/null
@@ -1,90 +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;
-
-import org.apache.log4j.Logger;
-
-import org.apache.isis.core.commons.authentication.AnonymousSession;
-import org.apache.isis.core.commons.authentication.AuthenticationSession;
-import org.apache.isis.core.runtime.authentication.AuthenticationManager;
-import org.apache.isis.core.runtime.authentication.AuthenticationRequestPassword;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext;
-
-public class UserManager {
-
- private static final Logger LOG = Logger.getLogger(UserManager.class);
- private static UserManager instance;
-
- private static AuthenticationManager getAuthenticationManager() {
- if (instance == null) {
- throw new IllegalStateException("Server initialisation failed, or not defined as a context listener");
- }
- return instance.authenticationManager;
- }
-
- public static AuthenticationSession startRequest(final RequestContext context) {
- AuthenticationSession session = context.getSession();
- if (session == null) {
- session = new AnonymousSession();
- LOG.debug("start anonymous request: " + session);
- } else {
- LOG.debug("start request for: " + session.getUserName());
- }
- IsisContext.closeSession();
- IsisContext.openSession(session);
- return session;
- }
-
- public static AuthenticationSession authenticate(final AuthenticationRequestPassword passwordAuthenticationRequest) {
- final AuthenticationSession session = getAuthenticationManager().authenticate(passwordAuthenticationRequest);
- if (session != null) {
- LOG.info("log on user " + session.getUserName());
- IsisContext.closeSession();
- IsisContext.openSession(session);
- }
- return session;
- }
-
- public static void endRequest(final AuthenticationSession session) {
- if (session == null) {
- LOG.debug("end anonymous request");
- } else {
- LOG.debug("end request for: " + session.getUserName());
- }
- IsisContext.closeSession();
- }
-
- public static void logoffUser(final AuthenticationSession session) {
- LOG.info("log off user " + session.getUserName());
- IsisContext.closeSession();
- getAuthenticationManager().closeSession(session);
-
- final AnonymousSession replacementSession = new AnonymousSession();
- IsisContext.openSession(replacementSession);
- }
-
- private final AuthenticationManager authenticationManager;
-
- public UserManager(final AuthenticationManager authenticationManager) {
- this.authenticationManager = authenticationManager;
- UserManager.instance = this;
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/ActionAction.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/ActionAction.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/ActionAction.java
index 9ef481d..9b30d48 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/ActionAction.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/ActionAction.java
@@ -39,12 +39,11 @@ import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
import org.apache.isis.core.metamodel.spec.feature.ObjectActionParameter;
import org.apache.isis.core.runtime.system.context.IsisContext;
import org.apache.isis.core.runtime.system.transaction.MessageBroker;
-import org.apache.isis.viewer.scimpi.dispatcher.Action;
-import org.apache.isis.viewer.scimpi.dispatcher.Dispatcher;
-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.context.Action;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.structure.FieldEditState;
+import org.apache.isis.viewer.scimpi.dispatcher.structure.FormState;
import org.apache.isis.viewer.scimpi.dispatcher.util.MethodsUtils;
public class ActionAction implements Action {
@@ -67,7 +66,7 @@ public class ActionAction implements Action {
* REVIEW - this and EditAction are very similar - refactor out common code.
*/
@Override
- public void process(final RequestContext context) throws IOException {
+ public void process(final Request context) throws IOException {
final String objectId = context.getParameter("_" + OBJECT);
final String version = context.getParameter("_" + VERSION);
final String formId = context.getParameter("_" + FORM_ID);
@@ -75,7 +74,7 @@ public class ActionAction implements Action {
final String override = context.getParameter("_" + RESULT_OVERRIDE);
String resultName = context.getParameter("_" + RESULT_NAME);
final String message = context.getParameter("_" + MESSAGE);
- resultName = resultName == null ? RequestContext.RESULT : resultName;
+ resultName = resultName == null ? RESULT : resultName;
FormState entryState = null;
try {
@@ -125,7 +124,7 @@ public class ActionAction implements Action {
}
final String error = entryState.getError();
final String view = context.getParameter("_" + ERROR);
- context.setRequestPath(view, Dispatcher.ACTION);
+ context.setRequestPath(view, "_" + ACTION);
final MessageBroker messageBroker = getMessageBroker();
messageBroker.addWarning(error);
@@ -145,11 +144,11 @@ public class ActionAction implements Action {
}
final String error = entryState.getError();
if (error != null) {
- context.addVariable(RequestContext.ERROR, error, Scope.REQUEST);
+ context.addVariable("_" + ERROR, error, Scope.REQUEST);
}
- final String view = context.getParameter("_" + ERROR);
- context.setRequestPath(view, Dispatcher.ACTION);
+ final String view = context.getParameter(ERROR_PARAM);
+ context.setRequestPath(view, "_" + ACTION);
} catch (final RuntimeException e) {
getMessageBroker().getMessages();
@@ -160,11 +159,11 @@ public class ActionAction implements Action {
}
}
- private boolean invokeMethod(final RequestContext context, final String variable, final ObjectAdapter object, final ObjectAction action, final FormState entryState) {
+ private boolean invokeMethod(final Request context, final String variable, final ObjectAdapter object, final ObjectAction action, final FormState entryState) {
final ObjectAdapter[] parameters = getParameters(action, entryState);
final String scopeName = context.getParameter("_" + SCOPE);
- final Scope scope = RequestContext.scope(scopeName, Scope.REQUEST);
+ final Scope scope = Request.scope(scopeName, Scope.REQUEST);
return MethodsUtils.runMethod(context, action, object, parameters, variable, scope);
}
@@ -177,7 +176,7 @@ public class ActionAction implements Action {
return parameters;
}
- private FormState validateParameters(final RequestContext context, final ObjectAction action, final ObjectAdapter object) {
+ private FormState validateParameters(final Request context, final ObjectAction action, final ObjectAdapter object) {
final FormState formState = new FormState();
final List<ObjectActionParameter> parameters2 = action.getParameters();
final int parameterCount = action.getParameterCount();
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/Attributes.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/Attributes.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/Attributes.java
deleted file mode 100644
index 67d13e2..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/Attributes.java
+++ /dev/null
@@ -1,131 +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.action;
-
-import java.util.Enumeration;
-import java.util.Vector;
-
-import org.htmlparser.Attribute;
-import org.htmlparser.nodes.TagNode;
-
-import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext;
-
-public class Attributes {
- private static final String TRUE = " true yes on ";
- private static final String FALSE = " false no off ";
- private final TagNode tagNode;
- private final RequestContext context;
-
- public Attributes(final TagNode tagNode, final RequestContext context) {
- this.tagNode = tagNode;
- this.context = context;
- }
-
- public boolean isPropertySet(final String name) {
- final String attribute = tagNode.getAttribute(name);
- int end = attribute.length() - 1;
- final int pos = attribute.indexOf(':');
- end = pos == -1 ? end : pos;
- final String variabelName = attribute.substring(2, end);
- final Object value = context.getVariable(variabelName);
- return value != null;
- // return attribute != null &&
- // !context.replaceVariables(attribute).equals("");
- }
-
- public boolean isPropertySpecified(final String name) {
- final String attribute = tagNode.getAttribute(name);
- return attribute != null;
- }
-
- public String getOptionalProperty(final String name, final boolean ensureVariablesExists) {
- return getOptionalProperty(name, null, ensureVariablesExists);
- }
-
- public String getOptionalProperty(final String name, final String defaultValue, final boolean ensureVariablesExists) {
- final String attribute = tagNode.getAttribute(name);
- return attribute == null ? defaultValue : context.replaceVariables(attribute);
- }
-
- public String getRequiredProperty(final String name, final boolean ensureVariablesExists) {
- final String attribute = tagNode.getAttribute(name);
- if (attribute == null) {
- throw new RequiredPropertyException("Missing property: " + name);
- } else if (attribute.equals("")) {
- throw new RequiredPropertyException("Property not set: " + name);
- } else {
- return context.replaceVariables(attribute);
- }
- }
-
- public String[] getPropertyNames(final String excluding[]) {
- final Vector attributes = tagNode.getAttributesEx();
- final String[] names = new String[attributes.size()];
- int i = 0;
- names: for (final Enumeration e = attributes.elements(); e.hasMoreElements();) {
- final String name = ((Attribute) e.nextElement()).getName();
- if (name == null) {
- continue;
- }
- for (int j = 0; j < excluding.length; j++) {
- if (name.equals(excluding[j])) {
- continue names;
- }
- }
- if (tagNode.getAttribute(name) != null) {
- names[i++] = name;
- }
- }
-
- final String[] array = new String[i];
- System.arraycopy(names, 0, array, 0, i);
- return array;
- }
-
- @Override
- public String toString() {
- return tagNode.toHtml(); // getAttributesEx().toString();
- }
-
- public boolean isRequested(final String name) {
- return isRequested(name, false);
- }
-
- public boolean isRequested(final String name, final boolean defaultValue) {
- final String flag = getOptionalProperty(name, true);
- if (flag == null) {
- return defaultValue;
- } else {
- return isTrue(flag);
- }
- }
-
- public static boolean isTrue(final String flag) {
- final String value = " " + flag.toLowerCase().trim() + " ";
- if (TRUE.indexOf(value) >= 0) {
- return true;
- } else if (FALSE.indexOf(value) >= 0) {
- return false;
- } else {
- throw new PropertyException("Illegal flag value: " + flag);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/DebugAction.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/DebugAction.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/DebugAction.java
new file mode 100644
index 0000000..00535d0
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/DebugAction.java
@@ -0,0 +1,244 @@
+/*
+ * 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.action;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import org.apache.isis.core.commons.debug.DebugBuilder;
+import org.apache.isis.core.commons.debug.DebugString;
+import org.apache.isis.core.commons.debug.Debuggable;
+import org.apache.isis.core.commons.debug.DebuggableWithTitle;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.SpecificationLoaderSpi;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
+import org.apache.isis.core.metamodel.spec.feature.ObjectActionContainer.Contributed;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
+import org.apache.isis.core.metamodel.util.Dump;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.viewer.scimpi.DebugHtmlWriter;
+import org.apache.isis.viewer.scimpi.ForbiddenException;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Action;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Collections2;
+import com.google.common.collect.Lists;
+
+public class DebugAction implements Action {
+ private final Debuggable dispatcher;
+
+ public DebugAction(final Debuggable dispatcher) {
+ this.dispatcher = dispatcher;
+ }
+
+ @Override
+ public String getName() {
+ return "debug";
+ }
+
+ @Override
+ public void debug(final DebugBuilder debug) {
+ }
+
+ @Override
+ public void process(final Request context) throws IOException {
+ if (context.isDebugDisabled()) {
+ throw new ForbiddenException("Can't access debug action when debug is disabled");
+ }
+
+ final String action = context.getParameter("action");
+ if ("list-i18n".equals(action)) {
+ i18n(context, null);
+ } else if ("list-authorization".equals(action)) {
+ authorization(context, null);
+ } else if (context.getParameter("mode") != null) {
+ final boolean isDebugOn = context.getParameter("mode").equals("debug");
+ context.addVariable("debug-on", isDebugOn, Scope.SESSION);
+ // TODO need to use configuration to find path
+ context.setRequestPath("/debug/debug.shtml");
+ } else {
+
+ // TODO remove - replaced by Debug tag
+ final DebugHtmlWriter view = new DebugHtmlWriter(context.getWriter(), true);
+ view.appendln("<div class=\"links\">");
+ view.appendln("<a href=\"debug.app?action=system\">System</a>");
+ view.appendln(" | <a href=\"debug.app?action=specifications\">List specifications</a>");
+ view.appendln(" | <a href=\"debug.app?action=list-i18n\">I18N File</a>");
+ view.appendln(" | <a href=\"debug.app?action=list-authorization\">Authorization File</a>");
+ view.appendln(" | <a href=\"debug.app?action=context\">Context</a>");
+ view.appendln(" | <a href=\"debug.app?action=dispatcher\">Dispatcher</a>");
+ view.appendln("</div>");
+
+ if ("specifications".equals(action)) {
+ listSpecifications(view);
+ } else if ("specification".equals(action)) {
+ // specification(context, view);
+ } else if ("object".equals(action)) {
+ object(context, view);
+ } else if ("system".equals(action)) {
+ system(context, view);
+ } else if ("context".equals(action)) {
+ context.append(view);
+ } else if ("dispatcher".equals(action)) {
+ dispatcher.debugData(view);
+ }
+
+ context.clearRequestedPath();
+ }
+ }
+
+ private void object(final Request context, final DebugHtmlWriter view) {
+ final ObjectAdapter object = context.getMappedObjectOrResult(context.getParameter("object"));
+ final DebugString str = new DebugString();
+ Dump.adapter(object, str);
+ Dump.graph(object, IsisContext.getAuthenticationSession(), str);
+ view.appendTitle(object.getSpecification().getFullIdentifier());
+ view.appendln("<pre class=\"debug\">" + str + "</pre>");
+ }
+
+ private void system(final Request context, final DebugHtmlWriter view) {
+ final DebuggableWithTitle[] debug = IsisContext.debugSystem();
+ view.appendTitle("System");
+ for (final DebuggableWithTitle element2 : debug) {
+ final DebugString str = new DebugString();
+ element2.debugData(str);
+ view.appendTitle(element2.debugTitle());
+ view.appendln("<pre class=\"debug\">" + str + "</pre>");
+ }
+ }
+
+ private void i18n(final Request context, final DebugHtmlWriter view) {
+ final Collection<ObjectSpecification> allSpecifications = getSpecificationLoader().allSpecifications();
+ final List<ObjectSpecification> specs = Lists.newArrayList(allSpecifications);
+ Collections.sort(specs, new Comparator<ObjectSpecification>() {
+ @Override
+ public int compare(final ObjectSpecification o1, final ObjectSpecification o2) {
+ return o1.getShortIdentifier().compareTo(o2.getShortIdentifier());
+ }
+ });
+ final Function<ObjectSpecification, String> className = ObjectSpecification.FUNCTION_FULLY_QUALIFIED_CLASS_NAME;
+ final List<String> fullIdentifierList = Lists.newArrayList(Collections2.transform(specs, className));
+ for (final String fullIdentifier : fullIdentifierList) {
+ final ObjectSpecification spec = getSpecificationLoader().loadSpecification(fullIdentifier);
+ if (spec.getAssociations().size() == 0 && spec.getObjectActions(Contributed.EXCLUDED).size() == 0) {
+ continue;
+ }
+ final String name = spec.getIdentifier().toClassIdentityString();
+ context.getWriter().append("# " + spec.getShortIdentifier() + "\n");
+ for (final ObjectAssociation assoc : spec.getAssociations()) {
+ context.getWriter().append("#" + name + ".property." + assoc.getId() + ".name" + "=\n");
+ context.getWriter().append("#" + name + ".property." + assoc.getId() + ".description" + "=\n");
+ context.getWriter().append("#" + name + ".property." + assoc.getId() + ".help" + "=\n");
+ }
+ for (final ObjectAction action : spec.getObjectActions(Contributed.EXCLUDED)) {
+ context.getWriter().append("#" + name + ".action." + action.getId() + ".name" + "=\n");
+ context.getWriter().append("#" + name + ".action." + action.getId() + ".description" + "=\n");
+ context.getWriter().append("#" + name + ".action." + action.getId() + ".help" + "=\n");
+ }
+ context.getWriter().append("\n");
+ }
+ }
+
+ private void authorization(final Request context, final DebugHtmlWriter view) {
+ final Collection<ObjectSpecification> allSpecifications = getSpecificationLoader().allSpecifications();
+ final List<ObjectSpecification> specs = Lists.newArrayList(allSpecifications);
+ Collections.sort(specs, new Comparator<ObjectSpecification>() {
+ @Override
+ public int compare(final ObjectSpecification o1, final ObjectSpecification o2) {
+ return o1.getShortIdentifier().compareTo(o2.getShortIdentifier());
+ }
+ });
+ final Function<ObjectSpecification, String> className = ObjectSpecification.FUNCTION_FULLY_QUALIFIED_CLASS_NAME;
+ final List<String> fullIdentifierList = Lists.newArrayList(Collections2.transform(specs, className));
+ for (final String fullIdentifier : fullIdentifierList) {
+ final ObjectSpecification spec = getSpecificationLoader().loadSpecification(fullIdentifier);
+ if (spec.getAssociations().size() == 0 && spec.getObjectActions(Contributed.EXCLUDED).size() == 0) {
+ continue;
+ }
+ final String name = spec.getIdentifier().toClassIdentityString();
+ context.getWriter().append("# " + spec.getShortIdentifier() + "\n");
+ context.getWriter().append("" + name + ":roles\n");
+ for (final ObjectAssociation assoc : spec.getAssociations()) {
+ context.getWriter().append("#" + name + "#" + assoc.getId() + ":roles\n");
+ // context.getWriter().append("#" + name + ".property." +
+ // assoc.getId() + ".description" + "=\n");
+ // context.getWriter().append("#" + name + ".property." +
+ // assoc.getId() + ".help" + "=\n");
+ }
+ for (final ObjectAction action : spec.getObjectActions(Contributed.EXCLUDED)) {
+ context.getWriter().append("#" + name + "#" + action.getId() + "():roles\n");
+ // context.getWriter().append("#" + name + ".action." +
+ // action.getId() + ".description" + "=\n");
+ // context.getWriter().append("#" + name + ".action." +
+ // action.getId() + ".help" + "=\n");
+ }
+ context.getWriter().append("\n");
+ }
+ }
+
+ private void listSpecifications(final DebugHtmlWriter view) {
+ final List<ObjectSpecification> fullIdentifierList = new ArrayList<ObjectSpecification>(getSpecificationLoader().allSpecifications());
+ Collections.sort(fullIdentifierList, ObjectSpecification.COMPARATOR_SHORT_IDENTIFIER_IGNORE_CASE);
+ view.appendTitle("Specifications");
+ for (final ObjectSpecification spec : fullIdentifierList) {
+ final String name = spec.getSingularName();
+ view.appendln(name, "");
+ // view.appendln(name, specificationLink(spec));
+ }
+
+ /*
+ * new Comparator<ObjectSpecification>() { public int
+ * compare(ObjectSpecification o1, ObjectSpecification o2) { return
+ * o1.getSingularName().compareTo(o2.getSingularName()); }});
+ *
+ * /* Collection<ObjectSpecification> allSpecifications =
+ * getSpecificationLoader().allSpecifications(); Collection<String> list
+ * = Collections2.transform(allSpecifications,
+ * ObjectSpecification.COMPARATOR_SHORT_IDENTIFIER_IGNORE_CASE); final
+ * List<String> fullIdentifierList = Lists.newArrayList(list); /*
+ * Collections.sort(fullIdentifierList, new
+ * Comparator<ObjectSpecification>() { public int
+ * compare(ObjectSpecification o1, ObjectSpecification o2) { return
+ * o1.getSingularName().compareTo(o2.getSingularName()); }});
+ */
+ /*
+ * view.divider("Specifications"); for (String fullIdentifier :
+ * fullIdentifierList) { ObjectSpecification spec =
+ * getSpecificationLoader().loadSpecification(fullIdentifier); String
+ * name = spec.getSingularName(); view.appendRow(name,
+ * specificationLink(spec)); }
+ */
+ }
+
+ protected SpecificationLoaderSpi getSpecificationLoader() {
+ return IsisContext.getSpecificationLoader();
+ }
+
+ @Override
+ public void init() {
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/DebugUserAction.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/DebugUserAction.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/DebugUserAction.java
new file mode 100644
index 0000000..c314b01
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/DebugUserAction.java
@@ -0,0 +1,72 @@
+/*
+ * 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.action;
+
+import java.io.IOException;
+
+import org.apache.isis.core.commons.debug.DebugBuilder;
+import org.apache.isis.viewer.scimpi.ForbiddenException;
+import org.apache.isis.viewer.scimpi.ScimpiException;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Action;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.security.DebugUsers;
+
+public class DebugUserAction implements Action {
+
+ private final DebugUsers debugUsers;
+
+ public DebugUserAction(final DebugUsers debugUsers) {
+ this.debugUsers = debugUsers;
+ }
+
+ @Override
+ public String getName() {
+ return "debug-user";
+ }
+
+ @Override
+ public void debug(final DebugBuilder debug) {
+ }
+
+ @Override
+ public void process(final Request context) throws IOException {
+ if (context.isDebugDisabled()) {
+ throw new ForbiddenException("Can't access debug action when debug is disabled");
+ }
+
+ final String method = context.getParameter(METHOD);
+ final String name = context.getParameter(NAME);
+ final String view = context.getParameter(VIEW);
+
+ if (method != null && method.equals("add")) {
+ debugUsers.add(name);
+ } else if (method != null && method.equals("remove")) {
+ debugUsers.remove(name);
+ } else {
+ throw new ScimpiException("Invalid debug-user action");
+ }
+
+ context.setRequestPath(view);
+ }
+
+ @Override
+ public void init() {
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/EditAction.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/EditAction.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/EditAction.java
new file mode 100644
index 0000000..86b7046
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/EditAction.java
@@ -0,0 +1,271 @@
+/*
+ * 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.action;
+
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.isis.applib.annotation.Where;
+import org.apache.isis.applib.profiles.Localization;
+import org.apache.isis.core.commons.authentication.AnonymousSession;
+import org.apache.isis.core.commons.authentication.AuthenticationSession;
+import org.apache.isis.core.commons.debug.DebugBuilder;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.adapter.version.Version;
+import org.apache.isis.core.metamodel.consent.Consent;
+import org.apache.isis.core.metamodel.consent.Veto;
+import org.apache.isis.core.metamodel.facets.object.parseable.ParseableFacet;
+import org.apache.isis.core.metamodel.facets.object.parseable.TextEntryParseException;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociationFilters;
+import org.apache.isis.core.metamodel.spec.feature.OneToOneAssociation;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.core.runtime.system.transaction.MessageBroker;
+import org.apache.isis.viewer.scimpi.Names;
+import org.apache.isis.viewer.scimpi.NotLoggedInException;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Action;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.structure.FieldEditState;
+import org.apache.isis.viewer.scimpi.dispatcher.structure.FormState;
+
+public class EditAction implements Action {
+ public static final String ACTION = "edit";
+
+ // 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
+ public String getName() {
+ return ACTION;
+ }
+
+ @Override
+ public void process(final Request context) throws IOException {
+ AuthenticationSession session = context.getSession();
+ if (session == null) {
+ session = new AnonymousSession();
+ }
+
+ try {
+ final String objectId = context.getParameter("_" + OBJECT);
+ final String version = context.getParameter("_" + VERSION);
+ final String formId = context.getParameter("_" + FORM_ID);
+ String resultName = context.getParameter("_" + RESULT_NAME);
+ resultName = resultName == null ? Names.RESULT : resultName;
+ final String override = context.getParameter("_" + RESULT_OVERRIDE);
+ String message = context.getParameter("_" + MESSAGE);
+
+ final ObjectAdapter adapter = context.getMappedObject(objectId);
+
+ final List<ObjectAssociation> fields = adapter.getSpecification().getAssociations(ObjectAssociationFilters.dynamicallyVisible(session, adapter, where));
+
+ for (final ObjectAssociation objectAssociation : fields) {
+ if (objectAssociation.isVisible(session, adapter, where).isVetoed()) {
+ throw new NotLoggedInException();
+ }
+ }
+
+ final FormState entryState = validateObject(context, adapter, fields);
+ final Version adapterVersion = adapter.getVersion();
+ final Version formVersion = context.getVersion(version);
+ if (formVersion != null && adapterVersion.different(formVersion)) {
+
+ IsisContext.getMessageBroker().addMessage("The " + adapter.getSpecification().getSingularName() + " was edited " + "by another user (" + adapterVersion.getUser() + "). Please make your changes based on their changes.");
+
+ final String view = context.getParameter("_" + ERROR);
+ context.setRequestPath(view, Names.EDIT);
+
+ entryState.setForm(formId);
+ context.addVariable(ENTRY_FIELDS, entryState, Scope.REQUEST);
+ context.addVariable(resultName, objectId, Scope.REQUEST);
+ if (override != null) {
+ context.addVariable(resultName, override, Scope.REQUEST);
+ }
+
+ } else if (entryState.isValid()) {
+ changeObject(context, adapter, entryState, fields);
+
+ if (adapter.isTransient()) {
+ IsisContext.getPersistenceSession().makePersistent(adapter);
+ context.unmapObject(adapter, Scope.REQUEST);
+ }
+
+ String view = context.getParameter("_" + VIEW);
+
+ final String id = context.mapObject(adapter, Scope.REQUEST);
+ context.addVariable(resultName, id, Scope.REQUEST);
+ if (override != null) {
+ context.addVariable(resultName, override, Scope.REQUEST);
+ }
+
+ final int questionMark = view == null ? -1 : view.indexOf("?");
+ if (questionMark > -1) {
+ final String params = view.substring(questionMark + 1);
+ final int equals = params.indexOf("=");
+ context.addVariable(params.substring(0, equals), params.substring(equals + 1), Scope.REQUEST);
+ view = view.substring(0, questionMark);
+ }
+ context.setRequestPath(view);
+ if (message == null) {
+ message = "Saved changes to " + adapter.getSpecification().getSingularName();
+ } else if (message.equals("")) {
+ message = null;
+ }
+ if (message != null) {
+ final MessageBroker messageBroker = IsisContext.getMessageBroker();
+ messageBroker.addMessage(message);
+ }
+
+ } else {
+ final String view = context.getParameter("_" + ERROR);
+ context.setRequestPath(view, Names.EDIT);
+
+ entryState.setForm(formId);
+ context.addVariable(ENTRY_FIELDS, entryState, Scope.REQUEST);
+ context.addVariable(resultName, objectId, Scope.REQUEST);
+ if (override != null) {
+ context.addVariable(resultName, override, Scope.REQUEST);
+ }
+
+ final MessageBroker messageBroker = IsisContext.getMessageBroker();
+ messageBroker.addWarning(entryState.getError());
+ }
+
+ } catch (final RuntimeException e) {
+ IsisContext.getMessageBroker().getMessages();
+ IsisContext.getMessageBroker().getWarnings();
+ IsisContext.getUpdateNotifier().clear();
+ IsisContext.getUpdateNotifier().clear();
+ throw e;
+ }
+ }
+
+ private FormState validateObject(final Request context, final ObjectAdapter object, final List<ObjectAssociation> fields) {
+ final FormState formState = new FormState();
+ for (int i = 0; i < fields.size(); i++) {
+ final ObjectAssociation field = fields.get(i);
+ final String fieldId = field.getId();
+ String newEntry = context.getParameter(fieldId);
+ if (fields.get(i).isOneToManyAssociation()) {
+ continue;
+ }
+ if (fields.get(i).isVisible(IsisContext.getAuthenticationSession(), object, where).isVetoed()) {
+ continue;
+ }
+ if (field.isUsable(IsisContext.getAuthenticationSession(), object, where).isVetoed()) {
+ continue;
+ }
+
+ if (newEntry != null && newEntry.equals("-OTHER-")) {
+ newEntry = context.getParameter(fieldId + "-other");
+ }
+
+ if (newEntry == null) {
+ // TODO duplicated in EditObject; line 97
+ final ObjectSpecification spec = field.getSpecification();
+ if (spec.isOfType(IsisContext.getSpecificationLoader().loadSpecification(boolean.class)) || spec.isOfType(IsisContext.getSpecificationLoader().loadSpecification(Boolean.class))) {
+ newEntry = FALSE;
+ } else {
+ continue;
+ }
+ }
+ final FieldEditState fieldState = formState.createField(fieldId, newEntry);
+
+ Consent consent = null;
+ if (field.isMandatory() && (newEntry.equals("") || newEntry.equals("NULL"))) {
+ consent = new Veto(field.getName() + " required");
+ formState.setError("Not all fields have been set");
+ } else if (field.getSpecification().containsFacet(ParseableFacet.class)) {
+ try {
+ final ParseableFacet facet = field.getSpecification().getFacet(ParseableFacet.class);
+ final ObjectAdapter originalValue = field.get(object);
+ Localization localization = IsisContext.getLocalization();
+ final ObjectAdapter newValue = facet.parseTextEntry(originalValue, newEntry, localization);
+ consent = ((OneToOneAssociation) field).isAssociationValid(object, newValue);
+ fieldState.setValue(newValue);
+ } catch (final TextEntryParseException e) {
+ consent = new Veto(e.getMessage());
+ // formState.setError("Not all fields have been entered correctly");
+ }
+
+ } else {
+ final ObjectAdapter associate = newEntry.equals("null") ? null : context.getMappedObject(newEntry);
+ if (associate != null) {
+ IsisContext.getPersistenceSession().resolveImmediately(associate);
+ }
+ consent = ((OneToOneAssociation) field).isAssociationValid(object, associate);
+ fieldState.setValue(associate);
+
+ }
+ if (consent.isVetoed()) {
+ fieldState.setError(consent.getReason());
+ formState.setError("Not all fields have been entered correctly");
+ }
+ }
+
+ // TODO check the state of the complete object.
+ return formState;
+ }
+
+ private void changeObject(final Request context, final ObjectAdapter object, final FormState editState, final List<ObjectAssociation> fields) {
+ for (int i = 0; i < fields.size(); i++) {
+ final FieldEditState field = editState.getField(fields.get(i).getId());
+ if (field == null) {
+ continue;
+ }
+ final String newEntry = field.getEntry();
+ final ObjectAdapter originalValue = fields.get(i).get(object);
+ final boolean isVisible = fields.get(i).isVisible(IsisContext.getAuthenticationSession(), object, where).isAllowed();
+ final boolean isUsable = fields.get(i).isUsable(IsisContext.getAuthenticationSession(), object, where).isAllowed();
+ final boolean bothEmpty = originalValue == null && newEntry.equals("");
+ final boolean bothSame = newEntry.equals(originalValue == null ? "" : originalValue.titleString());
+ if ((!isVisible || !isUsable) || bothEmpty || bothSame) {
+ if (fields.get(i).getSpecification().getFacet(ParseableFacet.class) == null) {
+ // REVIEW restores object to loader
+ context.getMappedObject(newEntry);
+ }
+ continue;
+ }
+
+ if (fields.get(i).getSpecification().containsFacet(ParseableFacet.class)) {
+ final ParseableFacet facet = fields.get(i).getSpecification().getFacet(ParseableFacet.class);
+ Localization localization = IsisContext.getLocalization();
+ final ObjectAdapter newValue = facet.parseTextEntry(originalValue, newEntry, localization);
+ ((OneToOneAssociation) fields.get(i)).set(object, newValue);
+ } else {
+ ((OneToOneAssociation) fields.get(i)).set(object, field.getValue());
+ }
+ }
+ }
+
+ @Override
+ public void init() {
+ }
+
+ @Override
+ public void debug(final DebugBuilder debug) {
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/LogAction.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/LogAction.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/LogAction.java
new file mode 100644
index 0000000..dd0e425
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/LogAction.java
@@ -0,0 +1,76 @@
+/*
+ * 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.action;
+
+import java.io.IOException;
+
+import org.apache.log4j.Level;
+import org.apache.log4j.LogManager;
+import org.apache.log4j.Logger;
+
+import org.apache.isis.core.commons.authentication.AuthenticationSession;
+import org.apache.isis.core.commons.debug.DebugBuilder;
+import org.apache.isis.viewer.scimpi.NotLoggedInException;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Action;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+
+public class LogAction implements Action {
+
+ private static final Logger LOG = Logger.getLogger(LogAction.class);
+
+ @Override
+ public void process(final Request context) throws IOException {
+
+ final AuthenticationSession session = context.getSession();
+ if (session == null) {
+ throw new NotLoggedInException();
+ }
+
+ final String levelName = (String) context.getVariable("level");
+
+ final Level level = Level.toLevel(levelName);
+ boolean changeLogged = false;
+ if (Level.INFO.isGreaterOrEqual(LogManager.getRootLogger().getLevel())) {
+ LOG.info("log level changed to " + level);
+ changeLogged = true;
+ }
+ LogManager.getRootLogger().setLevel(level);
+ if (!changeLogged) {
+ LOG.info("log level changed to " + level);
+ }
+ final String view = (String) context.getVariable("view");
+ context.setRequestPath(view);
+
+ }
+
+ @Override
+ public String getName() {
+ return "log";
+ }
+
+ @Override
+ public void init() {
+ }
+
+ @Override
+ public void debug(final DebugBuilder debug) {
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/LogonAction.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/LogonAction.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/LogonAction.java
new file mode 100644
index 0000000..ea158f1
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/LogonAction.java
@@ -0,0 +1,146 @@
+/*
+ * 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.action;
+
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.isis.applib.profiles.Localization;
+import org.apache.isis.core.commons.authentication.AuthenticationSession;
+import org.apache.isis.core.commons.debug.DebugBuilder;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facets.object.parseable.ParseableFacet;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
+import org.apache.isis.core.metamodel.spec.feature.ObjectActionParameter;
+import org.apache.isis.core.runtime.authentication.AuthenticationRequestPassword;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.viewer.scimpi.ScimpiException;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Action;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.structure.FieldEditState;
+import org.apache.isis.viewer.scimpi.dispatcher.structure.FormState;
+import org.apache.isis.viewer.scimpi.dispatcher.util.MethodsUtils;
+import org.apache.isis.viewer.scimpi.security.UserManager;
+
+
+// TODO this should work like EditAction so that logon page is repopulated
+public class LogonAction implements Action {
+
+ @Override
+ public void process(final Request context) throws IOException {
+ final String username = context.getParameter("username");
+ final String password = context.getParameter("password");
+ final String actualFormId = context.getParameter("_" + FORM_ID);
+ final String expectedFormId = context.getParameter(LOGON_FORM_ID);
+ boolean isDomainLogon = expectedFormId != null && expectedFormId.equals(actualFormId);
+ boolean isValid;
+
+ AuthenticationSession session = null;
+ if (username.length() == 0 || password.length() == 0) {
+ isValid = false;
+ } else {
+ if (isDomainLogon) {
+ final String objectId = context.getParameter(LOGON_OBJECT);
+ final String scope = context.getParameter(LOGON_SCOPE);
+ final String methodName = context.getParameter(LOGON_METHOD);
+ String resultName = context.getParameter(LOGON_RESULT_NAME);
+ resultName = resultName == null ? "_" + USER : resultName;
+
+ final ObjectAdapter object = MethodsUtils.findObject(context, objectId);
+ final ObjectAction action = MethodsUtils.findAction(object, methodName);
+ final int parameterCount = action.getParameterCount();
+ final ObjectAdapter[] parameters = new ObjectAdapter[parameterCount];
+ List<ObjectActionParameter> parameters2 = action.getParameters();
+ if (parameters.length != 2) {
+ throw new ScimpiException("Expected two parameters for the log-on method: " + methodName);
+ }
+
+ Localization localization = IsisContext.getLocalization();
+ ParseableFacet facet = parameters2.get(0).getSpecification().getFacet(ParseableFacet.class);
+ parameters[0] = facet.parseTextEntry(null, username, localization);
+ facet = parameters2.get(1).getSpecification().getFacet(ParseableFacet.class);
+ parameters[1] = facet.parseTextEntry(null, password, localization);
+ final ObjectAdapter result = action.execute(object, parameters);
+ isValid = result != null;
+ if (isValid) {
+ Scope scope2 = scope == null ? Scope.SESSION : Request.scope(scope);
+ final String resultId = context.mapObject(result, scope2);
+ context.addVariable(resultName, resultId, scope);
+ context.addVariable("_username", username, Scope.SESSION);
+
+ context.clearVariable(LOGON_OBJECT, Scope.SESSION);
+ context.clearVariable(LOGON_METHOD, Scope.SESSION);
+ context.clearVariable(LOGON_RESULT_NAME, Scope.SESSION);
+ context.clearVariable(LOGON_SCOPE, Scope.SESSION);
+ context.clearVariable(PREFIX + "isis-user", Scope.SESSION);
+ context.clearVariable(LOGON_FORM_ID, Scope.SESSION);
+ }
+ session = context.getSession();
+ } else {
+ session = UserManager.authenticate(new AuthenticationRequestPassword(username, password));
+ isValid = session != null;
+ }
+ }
+
+ String view;
+ if (!isValid) {
+ final FormState formState = new FormState();
+ formState.setForm(actualFormId);
+ formState.setError("Failed to login. Check the username and ensure that your password was entered correctly");
+ FieldEditState fieldState = formState.createField("username", username);
+ if (username.length() == 0) {
+ fieldState.setError("User Name required");
+ }
+ fieldState = formState.createField("password", password);
+ if (password.length() == 0) {
+ fieldState.setError("Password required");
+ }
+ if (username.length() == 0 || password.length() == 0) {
+ formState.setError("Both the user name and password must be entered");
+ }
+ context.addVariable(ENTRY_FIELDS, formState, Scope.REQUEST);
+
+ view = context.getParameter(ERROR);
+ context.setRequestPath("/" + view, ACTION);
+ } else {
+ context.setSession(session);
+ context.startHttpSession();
+ context.setUserAuthenticated(true);
+ view = context.getParameter(VIEW);
+ if (view == null) {
+ // REVIEW this is duplicated in Logon.java
+ view = "start." + EXTENSION;
+ }
+ context.redirectTo(view);
+ }
+ }
+
+ @Override
+ public String getName() {
+ return "logon";
+ }
+
+ @Override
+ public void init() {}
+
+ @Override
+ public void debug(final DebugBuilder debug) {}
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/LogoutAction.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/LogoutAction.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/LogoutAction.java
new file mode 100644
index 0000000..af8581a
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/LogoutAction.java
@@ -0,0 +1,71 @@
+/*
+ * 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.action;
+
+import java.io.IOException;
+
+import org.apache.isis.core.commons.authentication.AuthenticationSession;
+import org.apache.isis.core.commons.debug.DebugBuilder;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Action;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
+import org.apache.isis.viewer.scimpi.security.UserManager;
+
+public class LogoutAction implements Action {
+
+ public static void logoutUser(final Request context) {
+ if (context.isUserAuthenticated()) {
+ final AuthenticationSession session = context.getSession();
+ if (session != null) {
+ IsisContext.getUpdateNotifier().clear();
+ UserManager.logoffUser(session);
+ }
+ context.endHttpSession();
+ context.setUserAuthenticated(false);
+ }
+ context.clearVariables(Scope.SESSION);
+ }
+
+ @Override
+ public String getName() {
+ return "logout";
+ }
+
+ @Override
+ public void init() {
+ }
+
+ @Override
+ public void process(final Request request) throws IOException {
+ logoutUser(request);
+
+ String view = request.getParameter("view");
+ if (view == null) {
+ view = request.getContextPath();
+ }
+ request.redirectTo(view);
+ }
+
+ @Override
+ public void debug(final DebugBuilder debug) {
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/PropertyException.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/PropertyException.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/PropertyException.java
deleted file mode 100644
index 2e42188..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/PropertyException.java
+++ /dev/null
@@ -1,44 +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.action;
-
-import org.apache.isis.viewer.scimpi.dispatcher.ScimpiException;
-
-public class PropertyException extends ScimpiException {
-
- private static final long serialVersionUID = 1L;
-
- public PropertyException() {
- super();
- }
-
- public PropertyException(final String message, final Throwable cause) {
- super(message, cause);
- }
-
- public PropertyException(final String message) {
- super(message);
- }
-
- public PropertyException(final Throwable cause) {
- super(cause);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/RemoveAction.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/RemoveAction.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/RemoveAction.java
new file mode 100644
index 0000000..4c05a5a
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/RemoveAction.java
@@ -0,0 +1,117 @@
+/*
+ * 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.action;
+
+import java.io.IOException;
+
+import org.apache.isis.applib.annotation.Where;
+import org.apache.isis.core.commons.authentication.AnonymousSession;
+import org.apache.isis.core.commons.authentication.AuthenticationSession;
+import org.apache.isis.core.commons.debug.DebugBuilder;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
+import org.apache.isis.core.metamodel.spec.feature.OneToManyAssociation;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.viewer.scimpi.ForbiddenException;
+import org.apache.isis.viewer.scimpi.Names;
+import org.apache.isis.viewer.scimpi.ScimpiException;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Action;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
+
+/**
+ * Remove an element from a collection.
+ */
+public class RemoveAction implements Action {
+ public static final String ACTION = "remove";
+
+ // REVIEW: confirm this rendering context
+ private final Where where = Where.OBJECT_FORMS;
+
+ @Override
+ public String getName() {
+ return ACTION;
+ }
+
+ @Override
+ public void process(final Request context) throws IOException {
+ AuthenticationSession session = context.getSession();
+ if (session == null) {
+ session = new AnonymousSession();
+ }
+
+ final String parentId = context.getParameter(OBJECT);
+ final String rowId = context.getParameter(ELEMENT);
+
+ try {
+ final ObjectAdapter parent = context.getMappedObject(parentId);
+ final ObjectAdapter row = context.getMappedObject(rowId);
+
+ final String fieldName = context.getParameter(FIELD);
+ final ObjectAssociation field = parent.getSpecification().getAssociation(fieldName);
+ if (field == null) {
+ throw new ScimpiException("No field " + fieldName + " in " + parent.getSpecification().getFullIdentifier());
+ }
+ if (field.isVisible(IsisContext.getAuthenticationSession(), parent, where).isVetoed()) {
+ throw new ForbiddenException(field, ForbiddenException.VISIBLE);
+ }
+
+ ((OneToManyAssociation) field).removeElement(parent, row);
+
+ // TODO duplicated in EditAction
+ String view = context.getParameter(VIEW);
+ final String override = context.getParameter(RESULT_OVERRIDE);
+
+ String resultName = context.getParameter(RESULT_NAME);
+ resultName = resultName == null ? Names.RESULT : resultName;
+
+ final String id = context.mapObject(parent, Scope.REQUEST);
+ context.addVariable(resultName, id, Scope.REQUEST);
+ if (override != null) {
+ context.addVariable(resultName, override, Scope.REQUEST);
+ }
+
+ final int questionMark = view == null ? -1 : view.indexOf("?");
+ if (questionMark > -1) {
+ final String params = view.substring(questionMark + 1);
+ final int equals = params.indexOf("=");
+ context.addVariable(params.substring(0, equals), params.substring(equals + 1), Scope.REQUEST);
+ view = view.substring(0, questionMark);
+ }
+ context.setRequestPath(view);
+ // TODO end of duplication
+
+ } catch (final RuntimeException e) {
+ IsisContext.getMessageBroker().getMessages();
+ IsisContext.getMessageBroker().getWarnings();
+ IsisContext.getUpdateNotifier().clear();
+ IsisContext.getUpdateNotifier().clear();
+ throw e;
+ }
+ }
+
+ @Override
+ public void init() {
+ }
+
+ @Override
+ public void debug(final DebugBuilder debug) {
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/RequiredPropertyException.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/RequiredPropertyException.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/RequiredPropertyException.java
deleted file mode 100644
index 20430d3..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/RequiredPropertyException.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.viewer.scimpi.dispatcher.action;
-
-import org.apache.isis.viewer.scimpi.dispatcher.ScimpiException;
-
-public class RequiredPropertyException extends ScimpiException {
- private static final long serialVersionUID = 1L;
-
- public RequiredPropertyException() {
- super();
- }
-
- public RequiredPropertyException(final String message, final Throwable cause) {
- super(message, cause);
- }
-
- public RequiredPropertyException(final String message) {
- super(message);
- }
-
- public RequiredPropertyException(final Throwable cause) {
- super(cause);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/Action.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/Action.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/Action.java
new file mode 100644
index 0000000..c1c613b
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/Action.java
@@ -0,0 +1,37 @@
+/*
+ * 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.context;
+
+import java.io.IOException;
+
+import org.apache.isis.core.commons.debug.DebugBuilder;
+import org.apache.isis.viewer.scimpi.Names;
+
+public interface Action extends Names {
+
+ void process(Request request) throws IOException;
+
+ String getName();
+
+ void init();
+
+ void debug(DebugBuilder debug);
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/49518c89/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/DefaultOidObjectMapping.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/DefaultOidObjectMapping.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/DefaultOidObjectMapping.java
index cbf6ea8..8fc4544 100644
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/DefaultOidObjectMapping.java
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/DefaultOidObjectMapping.java
@@ -50,8 +50,8 @@ import org.apache.isis.core.metamodel.spec.feature.OneToManyAssociation;
import org.apache.isis.core.metamodel.spec.feature.OneToOneAssociation;
import org.apache.isis.core.runtime.system.context.IsisContext;
import org.apache.isis.core.runtime.system.persistence.PersistenceSession;
-import org.apache.isis.viewer.scimpi.dispatcher.ScimpiException;
-import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext.Scope;
+import org.apache.isis.viewer.scimpi.ScimpiException;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
public class DefaultOidObjectMapping implements ObjectMapping {
@@ -99,7 +99,7 @@ public class DefaultOidObjectMapping implements ObjectMapping {
try {
final List<ObjectAdapter> savedObject = Lists.newArrayList();
final JSONObject data = encodeTransientData(adapter, savedObject);
- return RequestContext.TRANSIENT_OBJECT_OID_MARKER + data.toString(4);
+ return Request.TRANSIENT_OBJECT_OID_MARKER + data.toString(4);
} catch (final JSONException e) {
throw new ScimpiException(e);
}
[16/24] Restructuring Scimpi to remove dependencies and enable easier
testing.
Posted by rm...@apache.org.
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/global/Methods.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/global/Methods.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/global/Methods.java
new file mode 100644
index 0000000..f71de08
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/global/Methods.java
@@ -0,0 +1,197 @@
+/*
+ * 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.global;
+
+import java.util.List;
+
+import org.apache.isis.applib.annotation.Where;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.spec.ActionType;
+import org.apache.isis.core.metamodel.spec.ObjectActionSet;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
+import org.apache.isis.core.metamodel.spec.feature.ObjectActionContainer.Contributed;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.viewer.scimpi.Names;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.util.MethodsUtils;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.action.ActionButton;
+import org.apache.isis.viewer.scimpi.dispatcher.view.action.ActionForm;
+import org.apache.isis.viewer.scimpi.dispatcher.view.determine.InclusionList;
+import org.apache.isis.viewer.scimpi.dispatcher.view.form.CreateFormParameter;
+
+public class Methods extends AbstractElementProcessor {
+
+ // 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 static Where where = Where.ANYWHERE;
+
+ @Override
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ String objectId = templateProcessor.getOptionalProperty(OBJECT);
+ final String view = templateProcessor.getOptionalProperty(VIEW, "_generic_action." + Names.EXTENSION);
+ // final String cancelTo = tagProcessor.getOptionalProperty(CANCEL_TO);
+ final boolean showForms = templateProcessor.isRequested(FORMS, false);
+ final ObjectAdapter object = MethodsUtils.findObject(templateProcessor.getContext(), objectId);
+ if (objectId == null) {
+ objectId = templateProcessor.getContext().mapObject(object, null);
+ }
+
+ final InclusionList inclusionList = new InclusionList();
+ templateProcessor.pushBlock(inclusionList);
+ templateProcessor.processUtilCloseTag();
+
+ templateProcessor.appendHtml("<div class=\"actions\">");
+ if (inclusionList.includes("edit") && !object.getSpecification().isService()) {
+ templateProcessor.appendHtml("<div class=\"action\">");
+ templateProcessor.appendHtml("<a class=\"button\" href=\"_generic_edit." + Names.EXTENSION + "?_result=" + objectId + "\">Edit...</a>");
+ templateProcessor.appendHtml("</div>");
+ }
+ writeMethods(templateProcessor, objectId, object, showForms, inclusionList, view, "_generic.shtml?_result=" + objectId);
+ templateProcessor.popBlock();
+ templateProcessor.appendHtml("</div>");
+ }
+
+ public static void writeMethods(
+ final TemplateProcessor templateProcessor,
+ final String objectId,
+ final ObjectAdapter adapter,
+ final boolean showForms,
+ final InclusionList inclusionList,
+ final String view,
+ final String cancelTo) {
+ List<ObjectAction> actions = adapter.getSpecification().getObjectActions(ActionType.USER, Contributed.INCLUDED);
+ writeMethods(templateProcessor, adapter, actions, objectId, showForms, inclusionList, view, cancelTo);
+ // TODO determine if system is set up to display exploration methods
+ if (true) {
+ actions = adapter.getSpecification().getObjectActions(ActionType.EXPLORATION, Contributed.INCLUDED);
+ writeMethods(templateProcessor, adapter, actions, objectId, showForms, inclusionList, view, cancelTo);
+ }
+ // TODO determine if system is set up to display debug methods
+ if (true) {
+ actions = adapter.getSpecification().getObjectActions(ActionType.DEBUG, Contributed.INCLUDED);
+ writeMethods(templateProcessor, adapter, actions, objectId, showForms, inclusionList, view, cancelTo);
+ }
+ }
+
+ private static void writeMethods(
+ final TemplateProcessor templateProcessor,
+ final ObjectAdapter adapter,
+ List<ObjectAction> actions,
+ final String objectId,
+ final boolean showForms,
+ final InclusionList inclusionList,
+ final String view,
+ final String cancelTo) {
+ actions = inclusionList.includedActions(actions);
+ for (int j = 0; j < actions.size(); j++) {
+ final ObjectAction action = actions.get(j);
+ if (action instanceof ObjectActionSet) {
+ templateProcessor.appendHtml("<div class=\"actions\">");
+ writeMethods(templateProcessor, adapter, action.getActions(), objectId, showForms, inclusionList, view, cancelTo);
+ templateProcessor.appendHtml("</div>");
+ } else if (action.isContributed()) {
+ if (action.getParameterCount() == 1 && adapter.getSpecification().isOfType(action.getParameters().get(0).getSpecification())) {
+ if (objectId != null) {
+ final ObjectAdapter target = templateProcessor.getContext().getMappedObject(objectId);
+ final ObjectAdapter realTarget = action.realTarget(target);
+ final String realTargetId = templateProcessor.getContext().mapObject(realTarget, Scope.INTERACTION);
+ writeMethod(templateProcessor, adapter, new String[] { objectId }, action, realTargetId, showForms, view, cancelTo);
+ } else {
+ templateProcessor.appendHtml("<div class=\"action\">");
+ templateProcessor.appendAsHtmlEncoded(action.getName());
+ templateProcessor.appendHtml("???</div>");
+ }
+ } else if (!adapter.getSpecification().isService()) {
+ writeMethod(templateProcessor, adapter, new String[0], action, objectId, showForms, view, cancelTo);
+ }
+ } else {
+ writeMethod(templateProcessor, adapter, new String[0], action, objectId, showForms, view, cancelTo);
+ }
+ }
+ }
+
+ private static void writeMethod(
+ final TemplateProcessor templateProcessor,
+ final ObjectAdapter adapter,
+ final String[] parameters,
+ final ObjectAction action,
+ final String objectId,
+ final boolean showForms,
+ final String view,
+ final String cancelTo) {
+ // if (action.isVisible(IsisContext.getSession(), null) &&
+ // action.isVisible(IsisContext.getSession(), adapter))
+ // {
+ if (action.isVisible(IsisContext.getAuthenticationSession(), adapter, where).isAllowed()) {
+ templateProcessor.appendHtml("<div class=\"action\">");
+ if (IsisContext.getSession() == null) {
+ templateProcessor.appendHtml("<span class=\"disabled\" title=\"no user logged in\">");
+ templateProcessor.appendAsHtmlEncoded(action.getName());
+ templateProcessor.appendHtml("</span>");
+ /*
+ * } else if (action.isUsable(IsisContext.getSession(),
+ * null).isVetoed()) {
+ * request.appendHtml("<span class=\"disabled\" title=\"" +
+ * action.isUsable(IsisContext.getSession(), null).getReason() +
+ * "\">"); request.appendHtml(action.getName());
+ * request.appendHtml("</span>");
+ */} else if (action.isUsable(IsisContext.getAuthenticationSession(), adapter, where).isVetoed()) {
+ templateProcessor.appendHtml("<span class=\"disabled\" title=\"" + action.isUsable(IsisContext.getAuthenticationSession(), adapter, where).getReason() + "\">");
+ templateProcessor.appendAsHtmlEncoded(action.getName());
+ templateProcessor.appendHtml("</span>");
+ } else {
+ final String version = templateProcessor.getContext().mapVersion(adapter);
+ if (action.getParameterCount() == 0 || (action.isContributed() && action.getParameterCount() == 1)) {
+ ActionButton.write(templateProcessor, adapter, action, parameters, objectId, version, "_generic." + Names.EXTENSION, null, null, null, null, null, null, null, null, null);
+ } else if (showForms) {
+ final CreateFormParameter params = new CreateFormParameter();
+ params.objectId = objectId;
+ params.methodName = action.getId();
+ params.forwardResultTo = "_generic." + Names.EXTENSION;
+ params.buttonTitle = "OK";
+ params.formTitle = action.getName();
+ ActionForm.createForm(templateProcessor, params, true);
+ } else {
+ templateProcessor.appendHtml("<a class=\"button\" href=\"" + view + "?_result=" + objectId + "&_" + VERSION + "=" + version + "&_" + METHOD + "=" + action.getId());
+ if (cancelTo != null) {
+ templateProcessor.appendHtml("&_cancel-to=");
+ templateProcessor.appendAsHtmlEncoded("cancel-to=\"" + cancelTo + "\"");
+ }
+ templateProcessor.appendHtml("\" title=\"" + action.getDescription() + "\">");
+ templateProcessor.appendAsHtmlEncoded(action.getName() + "...");
+ templateProcessor.appendHtml("</a>");
+ }
+ }
+ templateProcessor.appendHtml("</div>");
+ }
+ }
+
+ @Override
+ public String getName() {
+ return "methods";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/global/Services.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/global/Services.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/global/Services.java
new file mode 100644
index 0000000..e4bc52e
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/global/Services.java
@@ -0,0 +1,68 @@
+/*
+ * 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.global;
+
+import java.util.List;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.core.runtime.system.persistence.PersistenceSession;
+import org.apache.isis.viewer.scimpi.Names;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.determine.InclusionList;
+
+public class Services extends AbstractElementProcessor {
+
+ @Override
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ final boolean showForms = templateProcessor.isRequested(FORMS, false);
+ final String view = templateProcessor.getOptionalProperty(VIEW, "_generic_action." + Names.EXTENSION);
+ final String cancelTo = templateProcessor.getOptionalProperty(CANCEL_TO);
+
+ final InclusionList inclusionList = new InclusionList();
+ templateProcessor.pushBlock(inclusionList);
+ templateProcessor.processUtilCloseTag();
+
+ final List<ObjectAdapter> serviceAdapters = getPersistenceSession().getServices();
+ for (final ObjectAdapter adapter : serviceAdapters) {
+ final String serviceId = templateProcessor.getContext().mapObject(adapter, Scope.REQUEST);
+ templateProcessor.appendHtml("<div class=\"actions\">");
+ templateProcessor.appendHtml("<h3>");
+ templateProcessor.appendAsHtmlEncoded(adapter.titleString());
+ templateProcessor.appendHtml("</h3>");
+ Methods.writeMethods(templateProcessor, serviceId, adapter, showForms, inclusionList, view, cancelTo);
+ templateProcessor.appendHtml("</div>");
+ }
+ templateProcessor.popBlock();
+ }
+
+ @Override
+ public String getName() {
+ return "services";
+ }
+
+ private static PersistenceSession getPersistenceSession() {
+ return IsisContext.getPersistenceSession();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/localization/Localization.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/localization/Localization.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/localization/Localization.java
new file mode 100644
index 0000000..433ee07
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/localization/Localization.java
@@ -0,0 +1,65 @@
+/*
+ * 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.localization;
+
+import java.util.Locale;
+import java.util.TimeZone;
+
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+/**
+ * Displays the localization data for the current user.
+ */
+public class Localization extends AbstractElementProcessor {
+
+ @Override
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ templateProcessor.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();
+
+ templateProcessor.appendAsHtmlEncoded(country + ", " + timeZone);
+ } else {
+ templateProcessor.appendAsHtmlEncoded("No localization data!");
+ }
+
+ Locale locale = Locale.getDefault();
+ String country = locale.getDisplayName();
+ // country = locale.toString();
+ String timeZone = TimeZone.getDefault().getDisplayName();
+
+ templateProcessor.appendAsHtmlEncoded("\n (Default " + country + ", " + timeZone +")");
+
+ }
+
+ @Override
+ public String getName() {
+ return "alpha-localization";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/localization/SetLocalization.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/localization/SetLocalization.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/localization/SetLocalization.java
new file mode 100644
index 0000000..ff6c894
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/localization/SetLocalization.java
@@ -0,0 +1,65 @@
+/*
+ * 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.localization;
+
+import java.util.Locale;
+import java.util.TimeZone;
+
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.core.runtime.userprofile.UserLocalization;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+/**
+ * Displays the localization data for the current user.
+ */
+public class SetLocalization extends AbstractElementProcessor {
+
+ @Override
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ templateProcessor.closeEmpty();
+
+ final String localeCode = templateProcessor.getRequiredProperty("locale");
+ final String timeZone = templateProcessor.getRequiredProperty("time-zone");
+
+ String country;
+ String language;
+ int pos = localeCode.indexOf('_');
+ if (pos == 1) {
+ language = localeCode;
+ country = "";
+ } else {
+ language = localeCode.substring(0, pos);
+ country = localeCode.substring(pos + 1);
+ }
+
+ Locale l = new Locale(language, country);
+ TimeZone t = TimeZone.getTimeZone(timeZone);
+ IsisContext.getUserProfile().setLocalization(new UserLocalization(l, t));
+
+ }
+
+ @Override
+ public String getName() {
+ return "alpha-set-localization";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/logon/Logoff.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/logon/Logoff.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/logon/Logoff.java
deleted file mode 100644
index 0fa8e84..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/logon/Logoff.java
+++ /dev/null
@@ -1,38 +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.action.LogoutAction;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
-
-public class Logoff extends AbstractElementProcessor {
-
- @Override
- public void process(final TagProcessor tagProcessor) {
- LogoutAction.logoutUser(tagProcessor.getContext());
- }
-
- @Override
- public String getName() {
- return "logoff";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/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 63a47ee..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/logon/Logon.java
+++ /dev/null
@@ -1,124 +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.context.Request;
-import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.structure.FieldEditState;
-import org.apache.isis.viewer.scimpi.dispatcher.structure.FormState;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
-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 TagProcessor tagProcessor) {
- String view = tagProcessor.getOptionalProperty(VIEW);
- Request context = tagProcessor.getContext();
- if (view == null) {
- view = (String) context.getVariable("login-path");
- }
-
- final boolean isNotLoggedIn = IsisContext.getSession().getAuthenticationSession() instanceof AnonymousSession;
- if (isNotLoggedIn) {
- loginForm(tagProcessor, view);
- }
- }
-
- public static void loginForm(final TagProcessor tagProcessor, final String view) {
- final String object = tagProcessor.getOptionalProperty(OBJECT);
- final String method = tagProcessor.getOptionalProperty(METHOD, "logon");
- final String result = tagProcessor.getOptionalProperty(RESULT_NAME, "_user");
- final String resultScope = tagProcessor.getOptionalProperty(SCOPE, Scope.SESSION.name());
- final String isisUser = tagProcessor.getOptionalProperty("isis-user", "_web_default");
- final String formId = tagProcessor.getOptionalProperty(FORM_ID, tagProcessor.nextFormId());
- final String labelDelimiter = tagProcessor.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) {
- Request context = tagProcessor.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 + "isis-user", isisUser, Scope.SESSION);
- context.addVariable(LOGON_FORM_ID, formId, Scope.SESSION);
- }
-
- final String error = tagProcessor.getOptionalProperty(ERROR, tagProcessor.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) tagProcessor.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 = tagProcessor.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 = tagProcessor.getOptionalProperty(FORM_TITLE);
- final String loginButtonTitle = tagProcessor.getOptionalProperty(BUTTON_TITLE, "Log in");
- final String className = tagProcessor.getOptionalProperty(CLASS, "login");
- final String id = tagProcessor.getOptionalProperty(ID, "logon");
-
- HtmlFormBuilder.createForm(tagProcessor, "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/7700b437/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 baf7eef..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.Names;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
-
-public class RestrictAccess extends AbstractElementProcessor {
- private static final String LOGIN_VIEW = "login-view";
- private static final String DEFAULT_LOGIN_VIEW = "login." + Names.EXTENSION;
-
- public String getName() {
- return "restrict-access";
- }
-
- public void process(TagProcessor tagProcessor) {
- if (!tagProcessor.getContext().isUserAuthenticated()) {
- final String view = tagProcessor.getOptionalProperty(LOGIN_VIEW, DEFAULT_LOGIN_VIEW);
- tagProcessor.getContext().redirectTo(view);
- }
- }
-
-}
-
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/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 85c9a23..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.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
-
-public class Secure extends AbstractElementProcessor {
- private static final String LOGIN_VIEW = "login-view";
-
- @Override
- public void process(final TagProcessor tagProcessor) {
- 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 = tagProcessor.getOptionalProperty(LOGIN_VIEW, "/login.shtml");
- tagProcessor.getContext().redirectTo(view);
- }
- }
-
- @Override
- public String getName() {
- return "secure";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/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 2a0a1e8..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.Names;
-import org.apache.isis.viewer.scimpi.dispatcher.processor.TagProcessor;
-import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
-
-public class User extends AbstractElementProcessor {
- private static final String LOGIN_VIEW = "login-view";
- private static final String DEFAULT_LOGIN_VIEW = "login." + Names.EXTENSION;
- private static final String LOGOUT_VIEW = "logout-view";
- private static final String DEFAULT_LOGOUT_VIEW = "logout." + Names.EXTENSION;
-
- @Override
- public void process(final TagProcessor tagProcessor) {
- final boolean isAuthenticatedn = tagProcessor.getContext().isUserAuthenticated();
- tagProcessor.appendHtml("<div class=\"user\">");
- if (isAuthenticatedn) {
- displayUserAndLogoutLink(tagProcessor);
- } else {
- displayLoginForm(tagProcessor);
- }
- tagProcessor.appendHtml("</div>");
- }
-
- public void displayLoginForm(final TagProcessor tagProcessor) {
- String loginView = tagProcessor.getOptionalProperty(LOGIN_VIEW);
- if (loginView == null) {
- Logon.loginForm(tagProcessor, ".");
- } else {
- if (loginView.trim().length() == 0) {
- loginView = DEFAULT_LOGIN_VIEW;
- }
- tagProcessor.appendHtml("<a div class=\"link\" href=\"" + loginView + "\">Log in</a>");
- }
- }
-
- public void displayUserAndLogoutLink(final TagProcessor tagProcessor) {
- String user = tagProcessor.getOptionalProperty(NAME);
- if (user == null) {
- user = (String) tagProcessor.getContext().getVariable("_username");
- }
- if (user == null) {
- user = IsisContext.getAuthenticationSession().getUserName();
- }
- tagProcessor.appendHtml("Welcome <span class=\"name\">");
- tagProcessor.appendAsHtmlEncoded(user);
- tagProcessor.appendHtml("</span>, ");
- final String logoutView = tagProcessor.getOptionalProperty(LOGOUT_VIEW, DEFAULT_LOGOUT_VIEW);
- tagProcessor.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/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/message/AddMessage.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/message/AddMessage.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/message/AddMessage.java
new file mode 100644
index 0000000..bc1717c
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/message/AddMessage.java
@@ -0,0 +1,45 @@
+/*
+ * 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.message;
+
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.core.runtime.system.transaction.MessageBroker;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+public class AddMessage extends AbstractElementProcessor {
+
+ @Override
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ templateProcessor.pushNewBuffer();
+ templateProcessor.processUtilCloseTag();
+ final String content = templateProcessor.popBuffer();
+
+ final MessageBroker messageBroker = IsisContext.getMessageBroker();
+ messageBroker.addMessage(content);
+ }
+
+ @Override
+ public String getName() {
+ return "add-message";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/message/AddWarning.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/message/AddWarning.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/message/AddWarning.java
new file mode 100644
index 0000000..0c305c9
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/message/AddWarning.java
@@ -0,0 +1,45 @@
+/*
+ * 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.message;
+
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.core.runtime.system.transaction.MessageBroker;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+public class AddWarning extends AbstractElementProcessor {
+
+ @Override
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ templateProcessor.pushNewBuffer();
+ templateProcessor.processUtilCloseTag();
+ final String content = templateProcessor.popBuffer();
+
+ final MessageBroker messageBroker = IsisContext.getMessageBroker();
+ messageBroker.addWarning(content);
+ }
+
+ @Override
+ public String getName() {
+ return "add-warning";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/message/ErrorDetails.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/message/ErrorDetails.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/message/ErrorDetails.java
new file mode 100644
index 0000000..6e70998
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/message/ErrorDetails.java
@@ -0,0 +1,36 @@
+/*
+ * 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.message;
+
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+
+public class ErrorDetails extends AbstractElementProcessor {
+
+ public String getName() {
+ return "error-details";
+ }
+
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ templateProcessor.appendHtml(templateProcessor.getContext().getErrorDetails());
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/message/ErrorMessage.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/message/ErrorMessage.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/message/ErrorMessage.java
new file mode 100644
index 0000000..8e210cd
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/message/ErrorMessage.java
@@ -0,0 +1,37 @@
+/*
+ * 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.message;
+
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+
+public class ErrorMessage extends AbstractElementProcessor {
+
+ public String getName() {
+ return "error-message";
+ }
+
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+// templateProcessor.appendAsHtmlEncoded(templateProcessor.getContext().getErrorMessage());
+ templateProcessor.appendAsHtmlEncoded(state.getErrorMessage());
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/message/ErrorReference.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/message/ErrorReference.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/message/ErrorReference.java
new file mode 100644
index 0000000..6129a92
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/message/ErrorReference.java
@@ -0,0 +1,36 @@
+/*
+ * 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.message;
+
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+
+public class ErrorReference extends AbstractElementProcessor {
+
+ public String getName() {
+ return "error-reference";
+ }
+
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ templateProcessor.appendAsHtmlEncoded(templateProcessor.getContext().getErrorReference());
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/message/Errors.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/message/Errors.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/message/Errors.java
new file mode 100644
index 0000000..d2b59c9
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/message/Errors.java
@@ -0,0 +1,66 @@
+/*
+ * 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.message;
+
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+public class Errors extends AbstractElementProcessor {
+
+ @Override
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ final String cls = templateProcessor.getOptionalProperty(CLASS);
+ final StringBuffer buffer = new StringBuffer();
+ write(templateProcessor, cls, buffer);
+ if (buffer.length() > 0) {
+ templateProcessor.appendHtml("<div class=\"error\">");
+ templateProcessor.appendHtml(buffer.toString());
+ templateProcessor.appendHtml("</div>");
+ }
+ }
+
+ public static void write(final TemplateProcessor templateProcessor, String cls, final StringBuffer buffer) {
+ if (cls == null) {
+ cls = "error";
+ }
+ final String message = (String) templateProcessor.getContext().getVariable("_error-message");
+ if (message != null) {
+ buffer.append(message);
+ }
+ final String details = (String) templateProcessor.getContext().getVariable("_error-details");
+ if (details != null) {
+ buffer.append(details);
+ }
+
+ /*
+ * final MessageBroker messageBroker = IsisContext.getMessageBroker();
+ * final List<String> warnings = messageBroker.getWarnings(); for (final
+ * String warning : warnings) { buffer.append("<div class=\"" + cls +
+ * "\">" + warning + "</div>"); }
+ */
+ }
+
+ @Override
+ public String getName() {
+ return "errors";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/message/Feedback.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/message/Feedback.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/message/Feedback.java
new file mode 100644
index 0000000..f6a58e6
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/message/Feedback.java
@@ -0,0 +1,47 @@
+/*
+ * 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.message;
+
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+public class Feedback extends AbstractElementProcessor {
+
+ @Override
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ final String cls = templateProcessor.getOptionalProperty(CLASS);
+ final StringBuffer buffer = new StringBuffer();
+ Errors.write(templateProcessor, cls, buffer);
+ Warnings.write(cls, buffer);
+ Messages.write(cls, buffer);
+ if (buffer.length() > 0) {
+ templateProcessor.appendHtml("<div class=\"feedback\">");
+ templateProcessor.appendHtml(buffer.toString());
+ templateProcessor.appendHtml("</div>");
+ }
+ }
+
+ @Override
+ public String getName() {
+ return "feedback";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/message/Messages.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/message/Messages.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/message/Messages.java
new file mode 100644
index 0000000..f5a9c13
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/message/Messages.java
@@ -0,0 +1,61 @@
+/*
+ * 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.message;
+
+import java.util.List;
+
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.core.runtime.system.transaction.MessageBroker;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+public class Messages extends AbstractElementProcessor {
+
+ @Override
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ final String cls = templateProcessor.getOptionalProperty(CLASS);
+ final StringBuffer buffer = new StringBuffer();
+ write(cls, buffer);
+ if (buffer.length() > 0) {
+ templateProcessor.appendHtml("<div class=\"feedback\">");
+ templateProcessor.appendHtml(buffer.toString());
+ templateProcessor.appendHtml("</div>");
+ }
+
+ }
+
+ public static void write(String cls, final StringBuffer buffer) {
+ if (cls == null) {
+ cls = "message";
+ }
+ final MessageBroker messageBroker = IsisContext.getMessageBroker();
+ final List<String> messages = messageBroker.getMessages();
+ for (final String message : messages) {
+ buffer.append("<div class=\"" + cls + "\">" + message + "</div>");
+ }
+ }
+
+ @Override
+ public String getName() {
+ return "messages";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/message/Warnings.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/message/Warnings.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/message/Warnings.java
new file mode 100644
index 0000000..3b61ea0
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/message/Warnings.java
@@ -0,0 +1,60 @@
+/*
+ * 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.message;
+
+import java.util.List;
+
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.core.runtime.system.transaction.MessageBroker;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+public class Warnings extends AbstractElementProcessor {
+
+ @Override
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ final String cls = templateProcessor.getOptionalProperty(CLASS);
+ final StringBuffer buffer = new StringBuffer();
+ write(cls, buffer);
+ if (buffer.length() > 0) {
+ templateProcessor.appendHtml("<div class=\"feedback\">");
+ templateProcessor.appendHtml(buffer.toString());
+ templateProcessor.appendHtml("</div>");
+ }
+ }
+
+ public static void write(String cls, final StringBuffer buffer) {
+ if (cls == null) {
+ cls = "warning";
+ }
+ final MessageBroker messageBroker = IsisContext.getMessageBroker();
+ final List<String> warnings = messageBroker.getWarnings();
+ for (final String warning : warnings) {
+ buffer.append("<div class=\"" + cls + "\">" + warning + "</div>");
+ }
+ }
+
+ @Override
+ public String getName() {
+ return "warnings";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/object/EditLink.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/object/EditLink.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/object/EditLink.java
new file mode 100644
index 0000000..31bfac3
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/object/EditLink.java
@@ -0,0 +1,71 @@
+/*
+ * 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.object;
+
+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.ObjectAssociation;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociationFilters;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.viewer.scimpi.Names;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+
+public class EditLink extends LinkAbstract {
+
+ // 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 TemplateProcessor templateProcessor, final ObjectAdapter adapter) {
+ final ObjectSpecification specification = adapter.getSpecification();
+ final AuthenticationSession session = IsisContext.getAuthenticationSession();
+ final List<ObjectAssociation> visibleFields = specification.getAssociations(ObjectAssociationFilters.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 Names.GENERIC + Names.EDIT + "." + Names.EXTENSION;
+ }
+
+ @Override
+ public String getName() {
+ return "edit-link";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/object/EditObject.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/object/EditObject.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/object/EditObject.java
new file mode 100644
index 0000000..814f693
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/object/EditObject.java
@@ -0,0 +1,171 @@
+/*
+ * 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.object;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.isis.core.commons.authentication.AuthenticationSession;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociationFilters;
+import org.apache.isis.core.progmodel.facets.value.booleans.BooleanValueFacet;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.viewer.scimpi.dispatcher.action.EditAction;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.context.Request.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.form.FieldEditState;
+import org.apache.isis.viewer.scimpi.dispatcher.form.FormState;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.form.EditFormAbstract;
+import org.apache.isis.viewer.scimpi.dispatcher.view.form.FormFieldBlock;
+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 EditObject extends EditFormAbstract {
+
+ @Override
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ final Request context = templateProcessor.getContext();
+
+ final String objectId = templateProcessor.getOptionalProperty(OBJECT);
+ final String forwardEditedTo = templateProcessor.getOptionalProperty(VIEW);
+ final String forwardErrorTo = templateProcessor.getOptionalProperty(ERROR);
+ final String cancelTo = templateProcessor.getOptionalProperty(CANCEL_TO);
+ final boolean hideNonEditableFields = templateProcessor.isRequested(HIDE_UNEDITABLE, false);
+ final boolean showIcon = templateProcessor.isRequested(SHOW_ICON, showIconByDefault());
+ final String labelDelimiter = templateProcessor.getOptionalProperty(LABEL_DELIMITER, ":");
+ String buttonTitle = templateProcessor.getOptionalProperty(BUTTON_TITLE);
+ String formTitle = templateProcessor.getOptionalProperty(FORM_TITLE);
+ final String formId = templateProcessor.getOptionalProperty(FORM_ID, templateProcessor.nextFormId());
+ final String variable = templateProcessor.getOptionalProperty(RESULT_NAME);
+ final String resultOverride = templateProcessor.getOptionalProperty(RESULT_OVERRIDE);
+ final String scope = templateProcessor.getOptionalProperty(SCOPE);
+ final String className = templateProcessor.getOptionalProperty(CLASS, "edit full");
+ final String completionMessage = templateProcessor.getOptionalProperty(MESSAGE);
+
+ final ObjectAdapter object = context.getMappedObjectOrResult(objectId);
+ final String actualObjectId = context.mapObject(object, Scope.INTERACTION);
+ final String version = context.mapVersion(object);
+
+ final String id = templateProcessor.getOptionalProperty(ID, object.getSpecification().getShortIdentifier());
+
+ final FormState entryState = (FormState) context.getVariable(ENTRY_FIELDS);
+
+ final ObjectSpecification specification = object.getSpecification();
+ final FormFieldBlock containedBlock = new FormFieldBlock() {
+ @Override
+ public boolean isVisible(final String name) {
+ final ObjectAssociation fld = specification.getAssociation(name);
+ final boolean isVisible = fld.isVisible(IsisContext.getAuthenticationSession(), object, where).isAllowed();
+ final boolean isUseable = fld.isUsable(IsisContext.getAuthenticationSession(), object, where).isAllowed();
+ return isVisible && isUseable;
+ }
+
+ @Override
+ public ObjectAdapter getCurrent(final String name) {
+ ObjectAdapter value = null;
+ if (entryState != null) {
+ final FieldEditState field2 = entryState.getField(name);
+ value = field2.getValue();
+ }
+ if (value == null) {
+ final ObjectAssociation fld = specification.getAssociation(name);
+ value = fld.get(object);
+ }
+ return value;
+ }
+
+ @Override
+ public boolean isNullable(final String name) {
+ final ObjectAssociation fld = specification.getAssociation(name);
+ return !fld.isMandatory();
+ }
+ };
+
+ templateProcessor.pushBlock(containedBlock);
+ templateProcessor.processUtilCloseTag();
+
+ final AuthenticationSession session = IsisContext.getAuthenticationSession();
+ List<ObjectAssociation> viewFields = specification.getAssociations(ObjectAssociationFilters.dynamicallyVisible(session, object, where));
+ viewFields = containedBlock.includedFields(viewFields);
+ final InputField[] formFields = createFields(viewFields);
+
+ initializeFields(context, object, formFields, entryState, !hideNonEditableFields);
+ setDefaults(context, object, formFields, entryState, showIcon);
+
+ copyFieldContent(context, object, formFields, showIcon);
+ overrideWithHtml(context, containedBlock, formFields);
+ String errors = null;
+ if (entryState != null && entryState.isForForm(formId)) {
+ copyEntryState(context, object, formFields, entryState);
+ errors = entryState.getError();
+ }
+
+ final String errorView = context.fullFilePath(forwardErrorTo == null ? context.getResourceFile() : forwardErrorTo);
+ final List<HiddenInputField> hiddenFields = new ArrayList<HiddenInputField>();
+ hiddenFields.add(new HiddenInputField("_" + OBJECT, actualObjectId));
+ hiddenFields.add(new HiddenInputField("_" + VERSION, version));
+ hiddenFields.add(new HiddenInputField("_" + FORM_ID, formId));
+ hiddenFields.add(completionMessage == null ? null : new HiddenInputField("_" + MESSAGE, completionMessage));
+ hiddenFields.add(forwardEditedTo == null ? null : new HiddenInputField("_" + VIEW, context.fullFilePath(forwardEditedTo)));
+ hiddenFields.add(new HiddenInputField("_" + ERROR, errorView));
+ hiddenFields.add(variable == null ? null : new HiddenInputField("_" + RESULT_NAME, variable));
+ hiddenFields.add(resultOverride == null ? null : new HiddenInputField("_" + RESULT_OVERRIDE, resultOverride));
+ hiddenFields.add(scope == null ? null : new HiddenInputField("_" + SCOPE, scope));
+
+ if (!object.isTransient()) {
+ // ensure all booleans are included so the pass back TRUE if set.
+ final List<ObjectAssociation> fields2 = object.getSpecification().getAssociations();
+ for (int i = 0; i < fields2.size(); i++) {
+ final ObjectAssociation field = fields2.get(i);
+ if (!viewFields.contains(field) && field.getSpecification().containsFacet(BooleanValueFacet.class)) {
+ final String fieldId = field.getId();
+ final String value = getValue(context, field.get(object));
+ hiddenFields.add(new HiddenInputField(fieldId, value));
+ }
+ }
+ }
+
+ if (formTitle == null) {
+ formTitle = specification.getSingularName();
+ }
+
+ if (buttonTitle == null) {
+ buttonTitle = "Save " + specification.getSingularName();
+ } else if (buttonTitle.equals("")) {
+ buttonTitle = "Save";
+ }
+
+ final HiddenInputField[] hiddenFieldArray = hiddenFields.toArray(new HiddenInputField[hiddenFields.size()]);
+ HtmlFormBuilder.createForm(templateProcessor, EditAction.ACTION + ".app", hiddenFieldArray, formFields, className, id, formTitle,
+ labelDelimiter, null, null, buttonTitle, errors, cancelTo);
+ templateProcessor.popBlock();
+ }
+
+ @Override
+ public String getName() {
+ return "edit";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/object/FieldLabel.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/object/FieldLabel.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/object/FieldLabel.java
new file mode 100644
index 0000000..4fc1793
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/object/FieldLabel.java
@@ -0,0 +1,78 @@
+/*
+ * 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.object;
+
+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.ForbiddenException;
+import org.apache.isis.viewer.scimpi.ScimpiException;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+public class FieldLabel extends AbstractElementProcessor {
+
+ // 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
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ final String id = templateProcessor.getOptionalProperty(OBJECT);
+ final String fieldName = templateProcessor.getRequiredProperty(FIELD);
+ final ObjectAdapter object = templateProcessor.getContext().getMappedObjectOrResult(id);
+ final ObjectAssociation field = object.getSpecification().getAssociation(fieldName);
+ if (field == null) {
+ throw new ScimpiException("No field " + fieldName + " in " + object.getSpecification().getFullIdentifier());
+ }
+ if (field.isVisible(IsisContext.getAuthenticationSession(), object, where).isVetoed()) {
+ throw new ForbiddenException(field, ForbiddenException.VISIBLE);
+ }
+ String delimiter = templateProcessor.getOptionalProperty("delimiter");
+ if (delimiter == null) {
+ delimiter = ": ";
+ } else if (delimiter.equals("")) {
+ delimiter = null;
+ }
+ write(templateProcessor, field, delimiter);
+ }
+
+ @Override
+ public String getName() {
+ return "label";
+ }
+
+ public static void write(final TemplateProcessor content, final ObjectAssociation field, final String delimiter) {
+ final String description = field.getDescription();
+ final String titleSegment = description == null || description.equals("") ? null : ("title=\"" + description + "\"");
+ content.appendHtml("<span class=\"label\"" + titleSegment + ">");
+ content.appendAsHtmlEncoded(field.getName());
+ if (delimiter != null) {
+ content.appendHtml("<span class=\"delimiter\">" + delimiter + "</span>");
+ }
+ content.appendHtml("</span>");
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7700b437/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/object/FieldName.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/object/FieldName.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/object/FieldName.java
new file mode 100644
index 0000000..efe6aaf
--- /dev/null
+++ b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/object/FieldName.java
@@ -0,0 +1,66 @@
+/*
+ * 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.object;
+
+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.ForbiddenException;
+import org.apache.isis.viewer.scimpi.ScimpiException;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestState;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.TemplateProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.view.AbstractElementProcessor;
+
+public class FieldName extends AbstractElementProcessor {
+
+ // 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
+ public void process(final TemplateProcessor templateProcessor, RequestState state) {
+ final String id = templateProcessor.getOptionalProperty(OBJECT);
+ final String fieldName = templateProcessor.getRequiredProperty(FIELD);
+ final ObjectAdapter object = templateProcessor.getContext().getMappedObjectOrResult(id);
+ final ObjectAssociation field = object.getSpecification().getAssociation(fieldName);
+ if (field == null) {
+ throw new ScimpiException("No field " + fieldName + " in " + object.getSpecification().getFullIdentifier());
+ }
+ if (field.isVisible(IsisContext.getAuthenticationSession(), object, where).isVetoed()) {
+ throw new ForbiddenException(field, ForbiddenException.VISIBLE);
+ }
+ templateProcessor.appendAsHtmlEncoded(field.getName());
+ }
+
+ @Override
+ public String getName() {
+ return "field-name";
+ }
+
+ public static void write(final TemplateProcessor content, final ObjectAssociation field) {
+ content.appendHtml("<span class=\"label\" title=\"" + field.getDescription() + "\">");
+ content.appendHtml("</span>");
+ }
+
+}