You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2015/03/30 14:56:48 UTC
[19/22] isis git commit: ISIS-720: mothballing scimpi
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/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/2c7cfbfe/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 919ccc2..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/edit/RemoveAction.java
+++ /dev/null
@@ -1,114 +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();
- throw e;
- }
- }
-
- @Override
- public void init() {
- }
-
- @Override
- public void debug(final DebugBuilder debug) {
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/logon/DomainSession.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/logon/DomainSession.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/logon/DomainSession.java
deleted file mode 100644
index 55809e0..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/logon/DomainSession.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.logon;
-
-import java.io.IOException;
-import java.util.List;
-
-import org.apache.isis.core.commons.authentication.AuthenticationSessionAbstract;
-import org.apache.isis.core.commons.encoding.DataInputExtended;
-
-public class DomainSession extends AuthenticationSessionAbstract {
-
- private static final long serialVersionUID = 1L;
-
- private static final String CODE = "";
-
- public DomainSession(final String username, final List<String> roles) {
- super(username, roles, CODE);
- }
-
- public DomainSession(final DataInputExtended input) throws IOException {
- super(input);
- }
-}
-
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/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 e90740a..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/logon/LogonAction.java
+++ /dev/null
@@ -1,175 +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.ArrayList;
-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.ObjectSpecification;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
-import org.apache.isis.core.metamodel.spec.feature.ObjectActionParameter;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
-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;
-
-
-public class LogonAction implements Action {
-
- @Override
- public void process(final RequestContext context) throws IOException {
- String username = context.getParameter("username");
- 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;
-
- if (username == null || password == null) {
- context.redirectTo("/");
- return;
- }
- 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 loginMethodName = context.getParameter(LOGON_METHOD);
- final String roleFieldName = context.getParameter(PREFIX + "roles-field");
- String resultName = context.getParameter(LOGON_RESULT_NAME);
- resultName = resultName == null ? "_" + USER : resultName;
-
- final ObjectAdapter object = MethodsUtils.findObject(context, objectId);
- final ObjectAction loginAction = MethodsUtils.findAction(object, loginMethodName);
- final int parameterCount = loginAction.getParameterCount();
- final ObjectAdapter[] parameters = new ObjectAdapter[parameterCount];
- List<ObjectActionParameter> parameters2 = loginAction.getParameters();
- if (parameters.length != 2) {
- throw new ScimpiException("Expected two parameters for the log-on method: " + loginMethodName);
- }
-
- 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 = loginAction.execute(object, parameters);
- isValid = result != null;
- if (isValid) {
- ObjectSpecification specification = result.getSpecification();
- ObjectAssociation association = specification.getAssociation(roleFieldName);
- if (association == null) {
- throw new ScimpiException("Expected a role name field called: " + roleFieldName);
- }
- ObjectAdapter role = association.get(result);
- List<String> roles = new ArrayList<String>();
- if (role != null) {
- String[] split = role.titleString().split("\\|");
- for (String r : split) {
- roles.add(r);
- }
- }
- //String domainRoleName = role == null ? "" : role.titleString();
-
-
- 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 + "roles-field", Scope.SESSION);
- // context.clearVariable(PREFIX + "isis-user", Scope.SESSION);
- context.clearVariable(LOGON_FORM_ID, Scope.SESSION);
-
- session = new DomainSession(result.titleString(), roles);
- } else {
- 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/2c7cfbfe/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 a6f4730..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/logon/LogoutAction.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.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) {
- 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/2c7cfbfe/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/2c7cfbfe/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
deleted file mode 100644
index 6730510..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/HtmlFileParser.java
+++ /dev/null
@@ -1,205 +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.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-import java.util.Stack;
-
-import org.htmlparser.Node;
-import org.htmlparser.Remark;
-import org.htmlparser.lexer.Lexer;
-import org.htmlparser.lexer.Page;
-import org.htmlparser.nodes.TagNode;
-import org.htmlparser.util.ParserException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-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 HtmlFileParser {
- private static final Logger LOG = LoggerFactory.getLogger(HtmlFileParser.class);
- private final ProcessorLookup processors;
-
- public HtmlFileParser(final ProcessorLookup processors) {
- this.processors = processors;
- }
-
- public Stack<Snippet> parseHtmlFile(final String filePath, final RequestContext 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) {
- LOG.debug("parent/file: " + parentPath + " & " + filePath);
- final File directory = filePath.startsWith("/") ? new File(".") : new File(parentPath);
- final File loadFile = new File(directory.getParentFile(), filePath);
- final String loadPath = loadFile.getPath().replace('\\', '/');
- LOG.debug("loading template '" + loadPath + "'");
- final InputStream in = context.openStream(loadPath);
-
- Page page;
- try {
- page = new Page(in, null);
- } catch (final UnsupportedEncodingException e) {
- throw new ScimpiException(e);
- }
- final Lexer lexer = new Lexer(page);
-
- Node node = null;
- try {
- Stack<Snippet> tags = allTags;
- String lineNumbers = "1";
- String template = null;
- tags.push(new HtmlSnippet(lineNumbers, filePath));
-
- // NOTE done like this the tags can be cached for faster processing
- while ((node = lexer.nextNode()) != null) {
- if (node instanceof Remark) {
- // TODO need to pick up on comments within tags; at the
- // moment this splits a tag into two causing a
- // failure later
- continue;
-
- } else if (node instanceof TagNode && ((TagNode) node).getTagName().startsWith("SWF:")) {
- final TagNode tagNode = (TagNode) node;
- final String tagName = tagNode.getTagName().toUpperCase();
- LOG.debug(tagName);
-
- // TODO remove context & request from Attributes -- the tags
- // will be re-used across
- // requests
- final Attributes attributes = new Attributes(tagNode, context);
- int type = 0;
- if (tagNode.isEndTag()) {
- type = SwfTag.END;
- } else {
- type = tagNode.isEmptyXmlTag() ? SwfTag.EMPTY : SwfTag.START;
- }
- testForProcessorForTag(lexer, tagName);
- lineNumbers = lineNumbering(node);
- final SwfTag tag = new SwfTag(tagName, attributes, type, lineNumbers, loadFile.getCanonicalPath());
- tags.push(tag);
-
- if (tagName.equals("SWF:IMPORT")) {
- if (!tagNode.isEmptyXmlTag()) {
- throw new ScimpiException("Import tag must be empty");
- }
- String importFile = tagNode.getAttribute("file");
- if (context.isDebug()) {
- context.getWriter().println("<!-- " + "import file " + importFile + " -->");
- }
- importFile = context.replaceVariables(importFile);
- parseHtmlFile(loadPath, importFile, context, tags, tagsForPreviousTemplate);
- }
-
- if (tagName.equals("SWF:TEMPLATE")) {
- if (!tagNode.isEmptyXmlTag()) {
- throw new ScimpiException("Template tag must be empty");
- }
- if (template != null) {
- throw new ScimpiException("Template tag can only be used once within a file");
- }
- template = tagNode.getAttribute("file");
- template = context.replaceVariables(template);
- if (context.isDebug()) {
- context.getWriter().println("<!-- " + "apply template " + template + " -->");
- }
- tags = new Stack<Snippet>();
- }
-
- if (tagName.equals("SWF:CONTENT")) {
- if (!tagNode.isEmptyXmlTag()) {
- throw new ScimpiException("Content tag must be empty");
- }
- if (context.isDebug()) {
- context.getWriter().println("<!-- " + "insert content into template -->");
- }
- tags.addAll(tagsForPreviousTemplate);
- }
- } else {
- final Snippet snippet = tags.size() == 0 ? null : tags.peek();
- if (snippet instanceof HtmlSnippet) {
- ((HtmlSnippet) snippet).append(node.toHtml());
- } else {
- final HtmlSnippet htmlSnippet = new HtmlSnippet(lineNumbers, filePath);
- htmlSnippet.append(node.toHtml());
- tags.push(htmlSnippet);
- }
- }
-
- }
- in.close();
-
- if (template != null) {
- final String filePathRoot = loadPath.startsWith("/") ? "" : "/";
- parseHtmlFile(filePathRoot + loadPath, template, context, allTags, tags);
- }
-
- } catch (final ParserException e) {
- exception(loadPath, node, e);
- // throw new ScimpiException(e);
- } catch (final RuntimeException e) {
- // TODO: extend to deal with other exceptions
- exception(loadPath, node, e);
- } catch (final IOException e) {
- throw new ScimpiException(e);
- }
- }
-
- private void exception(final String filePath, final Node node, final Exception e) {
- String lineNumbers = "";
- String element = ("" + node).toLowerCase();
- if (node instanceof TagNode) {
- lineNumbers = ":" + lineNumbering(node);
- element = "tag <" + node.getText() + ">";
- }
- throw new ScimpiException("Error processing " + element + " in " + filePath + lineNumbers, e);
- }
-
- private String lineNumbering(final Node node) {
- String lineNumbers;
- final int startingLine = ((TagNode) node).getStartingLineNumber() + 1;
- final int endingLine = ((TagNode) node).getStartingLineNumber() + 1;
- if (startingLine == endingLine) {
- lineNumbers = "" + startingLine;
- } else {
- lineNumbers = startingLine + "-" + endingLine;
- }
- return lineNumbers;
- }
-
- private void testForProcessorForTag(final Lexer lexer, final String tagName) {
- final ElementProcessor elementProcessor = processors.getFor(tagName);
- if (elementProcessor == null) {
- throw new ScimpiException("No processor for tag " + tagName.toLowerCase());
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/PageWriter.java
----------------------------------------------------------------------
diff --git a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/PageWriter.java b/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/PageWriter.java
deleted file mode 100644
index 4e11481..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/PageWriter.java
+++ /dev/null
@@ -1,28 +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 PageWriter {
-
- void appendAsHtmlEncoded(String string);
-
- void appendHtml(String string);
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/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 36c1920..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/ProcessorLookup.java
+++ /dev/null
@@ -1,256 +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;
-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);
- }
-
- 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/2c7cfbfe/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 118ff9b..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/Request.java
+++ /dev/null
@@ -1,324 +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.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-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 = LoggerFactory.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/2c7cfbfe/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/2c7cfbfe/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 d9a8a60..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.dispatcher.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/2c7cfbfe/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
deleted file mode 100644
index a6ae574..0000000
--- a/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/util/MethodsUtils.java
+++ /dev/null
@@ -1,154 +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.util;
-
-import java.util.Arrays;
-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.adapter.mgr.AdapterManager;
-import org.apache.isis.core.metamodel.consent.Consent;
-import org.apache.isis.core.metamodel.services.ServiceUtil;
-import org.apache.isis.core.metamodel.spec.ActionType;
-import org.apache.isis.core.metamodel.spec.feature.Contributed;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
-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.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;
-
-public class MethodsUtils {
- public static final String SERVICE_PREFIX = "service:";
-
- public static Consent canRunMethod(final ObjectAdapter target, final ObjectAction action, final ObjectAdapter[] parameters) {
- final Consent consent = action.isProposedArgumentSetValid(target, parameters == null ? new ObjectAdapter[0] : parameters);
- return consent;
- }
-
- public static boolean runMethod(final RequestContext 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;
-
- final ObjectAdapter result = action.execute(target, parameters == null ? new ObjectAdapter[0] : parameters);
- if (result == null) {
- return false;
- } else {
- final String mappedId = context.mapObject(result, scope);
- context.addVariable(variable, mappedId, scope);
- // context.addVariable(variable + "_type",
- // action.getFacet(TypeOfFacet.class), scope);
- return true;
- }
- }
-
- public static boolean runMethod(final RequestContext context, final ObjectAction action, final ObjectAdapter target, final ObjectAdapter[] parameters) {
- return runMethod(context, action, target, parameters, null, null);
- }
-
- public static ObjectAction findAction(final ObjectAdapter object, final String methodName) {
- if (object == null) {
- throw new ScimpiException("Object not specified when looking for " + methodName);
- }
-
- final List<ObjectAction> actions = object.getSpecification().getObjectActions(Contributed.INCLUDED);
- final ObjectAction action = findAction(actions, methodName);
- /*
- * if (action == null) { actions =
- * object.getSpecification().getServiceActionsFor(ObjectActionType.USER,
- * ObjectActionType.EXPLORATION, ObjectActionType.DEBUG); action =
- * findAction(actions, methodName); }
- */
- if (action == null) {
- throw new DispatchException("Failed to find action " + methodName + " on " + object);
- }
- return action;
- }
-
- private static ObjectAction findAction(final List<ObjectAction> actions, final String methodName) {
- for (int i = 0; i < actions.size(); i++) {
- final ObjectAction objectAction = actions.get(i);
- if (objectAction.getId().equals(methodName)) {
- return objectAction;
- }
- }
- return null;
- }
-
- public static ObjectAdapter findObject(final RequestContext context, String objectId) {
- if (objectId == null) {
- objectId = context.getStringVariable(RequestContext.RESULT);
- }
-
- if (objectId != null && objectId.startsWith(SERVICE_PREFIX)) {
- final String serviceId = objectId.substring(SERVICE_PREFIX.length());
- final List<ObjectAdapter> serviceAdapters = getPersistenceSession().getServices();
- for (final ObjectAdapter serviceAdapter : serviceAdapters) {
- final Object service = serviceAdapter.getObject();
- if (ServiceUtil.id(service).equals(serviceId.trim())) {
- final ObjectAdapter adapter = getAdapterManager().getAdapterFor(service);
- return adapter;
- }
- }
- throw new DispatchException("Failed to find service " + serviceId);
- } else {
- return context.getMappedObject(objectId);
- }
- }
-
- public static boolean isVisible(final ObjectAdapter object, final ObjectAction action, Where where) {
- return action.isVisible(getAuthenticationSession(), object, where).isAllowed();
- }
-
- public static String isUsable(final ObjectAdapter object, final ObjectAction action, Where where) {
- final Consent usable = action.isUsable(getAuthenticationSession(), object, where);
- final boolean isUsable = getSession() != null && usable.isAllowed();
- return isUsable ? null : usable.getReason();
- }
-
- public static boolean isVisibleAndUsable(final ObjectAdapter object, final ObjectAction action, Where where) {
- AuthenticationSession authenticatedSession = getAuthenticationSession();
- final boolean isVisible = action.isVisible(authenticatedSession, object, where).isAllowed();
- final boolean isUsable = getSession() != null && action.isUsable(authenticatedSession, object, where).isAllowed();
- final boolean isVisibleAndUsable = isVisible && isUsable;
- return isVisibleAndUsable;
- }
-
- private static AuthenticationSession getAuthenticationSession() {
- return IsisContext.getAuthenticationSession();
- }
-
- private static IsisSession getSession() {
- return IsisContext.getSession();
- }
-
- private static AdapterManager getAdapterManager() {
- return getPersistenceSession().getAdapterManager();
- }
-
- private static PersistenceSession getPersistenceSession() {
- return IsisContext.getPersistenceSession();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/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/2c7cfbfe/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/2c7cfbfe/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/2c7cfbfe/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();
-}