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:45:04 UTC
[07/24] Restructuring Scimpi to remove dependencies and enable easier
testing.
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);
- }
- }
-
-}