incubator-isis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmatth...@apache.org
Subject svn commit: r1097566 - in /incubator/isis/trunk/viewer/scimpi: dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/ dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/ dispatcher/src/main/java/org/apache/isis/viewer...
Date Thu, 28 Apr 2011 18:08:13 GMT
Author: rmatthews
Date: Thu Apr 28 18:08:12 2011
New Revision: 1097566

URL: http://svn.apache.org/viewvc?rev=1097566&view=rev
Log:
- Improved debugging/exceptions
- Added elements to forward and redirect requests

Added:
    incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Commit.java
  (with props)
    incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Forward.java
  (with props)
    incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Redirect.java
  (with props)
Modified:
    incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/Dispatcher.java
    incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/ForbiddenException.java
    incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/RequestContext.java
    incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/debug/DebugAction.java
    incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/ProcessorLookup.java
    incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/DebuggerLink.java
    incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/PrintAuthorizationClause.java
    incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/RemoveElement.java
    incubator/isis/trunk/viewer/scimpi/servlet/src/main/java/org/apache/isis/viewer/scimpi/servlet/ServletRequestContext.java

Modified: incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/Dispatcher.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/Dispatcher.java?rev=1097566&r1=1097565&r2=1097566&view=diff
==============================================================================
--- incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/Dispatcher.java
(original)
+++ incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/Dispatcher.java
Thu Apr 28 18:08:12 2011
@@ -20,7 +20,6 @@
 
 package org.apache.isis.viewer.scimpi.dispatcher;
 
-import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.IOException;
@@ -38,6 +37,7 @@ import java.util.Stack;
 import org.apache.isis.core.commons.authentication.AuthenticationSession;
 import org.apache.isis.core.commons.config.ConfigurationConstants;
 import org.apache.isis.core.commons.debug.DebugBuilder;
+import org.apache.isis.core.commons.debug.DebugHtmlString;
 import org.apache.isis.core.commons.debug.DebugString;
 import org.apache.isis.core.commons.debug.DebugTee;
 import org.apache.isis.core.commons.exceptions.IsisException;
@@ -73,8 +73,6 @@ import org.dom4j.DocumentException;
 import org.dom4j.Element;
 import org.dom4j.io.SAXReader;
 
-import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMessages;
-
 
 public class Dispatcher {
     public static final String ACTION = "_action";
@@ -135,10 +133,7 @@ public class Dispatcher {
             LOG.info("error " + errorRef);
             LOG.debug(e.getMessage(), e);
             
-            DebugString error = new DebugString();
-            generateErrorPage(e, context, error, errorRef);
-            String message = "failed while processing " + servletPath;
-            LOG.error(message + " (#" + errorRef + ")\n" + error + "\n" + message);
+            prepareErrorDetails(e, context, errorRef, servletPath);
              
             PersistenceSession checkSession = IsisContext.getPersistenceSession();
             IsisTransactionManager transactionManager = checkSession.getTransactionManager();
@@ -149,15 +144,19 @@ public class Dispatcher {
 
             Throwable ex = e instanceof TagProcessingException ? e.getCause() : e;
             if (ex instanceof ForbiddenException) {
-                context.addVariable("_security_error", ex.getMessage(), Scope.REQUEST); 
-                context.addVariable("_security_identifier", ((ForbiddenException) ex).getIdentifier(),
Scope.REQUEST);
-                context.addVariable("_security_roles", ((ForbiddenException) ex).getRoles(),
Scope.REQUEST);
+                context.addVariable("_security-context", ((TagProcessingException) e).getContext(),
Scope.ERROR); 
+                context.addVariable("_security-error", ex.getMessage(), Scope.ERROR); 
+                context.addVariable("_security-identifier", ((ForbiddenException) ex).getIdentifier(),
Scope.ERROR);
+                context.addVariable("_security-roles", ((ForbiddenException) ex).getRoles(),
Scope.ERROR);
 
                 // TODO allow these values to be got configuration
                 // context.raiseError(403);
                 // context.setRequestPath("/error/security_403.shtml");
-                IsisContext.getMessageBroker().addWarning("You did not have the right permissions
to perform this (#" + errorRef + ")");
+                IsisContext.getMessageBroker().addWarning("You don't have the right permissions
to perform this (#" + errorRef + ")" + 
+                        "<span class=\"debug-link\" onclick=\"$('#security-dump').toggle()\"
> ...</span>");
+                context.clearVariables(Scope.REQUEST);
                 context.setRequestPath("/index.shtml");
+                context.setRequestPath("/error/security_403.shtml");
                 try {
                     processTheView(context);
                 } catch (IOException e1) {
@@ -167,16 +166,21 @@ public class Dispatcher {
                 // TODO allow these values to be got configuration
                 // context.raiseError(500);    
                // context.setRequestPath("/error/server_500.shtml");
-                IsisContext.getMessageBroker().addWarning("There was a error while processing
this request (#" + errorRef + ")");
+                
+                String message = "There was a error while processing this request (#" + errorRef
+ ")" + 
+                        "<span class=\"debug-link\" onclick=\"$('#error-dump').toggle()\"
> ...</span>";
+                IsisContext.getMessageBroker().addWarning(message);
                 context.clearVariables(Scope.REQUEST);
                 context.setRequestPath("/index.shtml");
                 try {
+                    context.reset();
                     processTheView(context);
                 } catch (TagProcessingException e1) {
-                    IsisContext.getMessageBroker().addWarning("There was a error while processing
this request (#" + errorRef + ")");
+                    IsisContext.getMessageBroker().addWarning(message);
                     context.clearVariables(Scope.REQUEST);
                     context.setRequestPath("/error.shtml");
                     try {
+                        context.reset();
                         processTheView(context);
                     } catch (IOException e2) {
                         throw new ScimpiException(e2);
@@ -184,6 +188,8 @@ public class Dispatcher {
                 } catch (IOException e1) {
                     throw new ScimpiException(e1);
                 }
+                
+   //             context.forward("/error.shtml");
             }
         } finally {
             try {
@@ -212,29 +218,50 @@ public class Dispatcher {
     }
 
 
-    private void generateErrorPage(Throwable exception, RequestContext requestContext, DebugString
error, String errorRef) {
+    private void prepareErrorDetails(Throwable exception, RequestContext requestContext,
String errorRef, String servletPath) {
+        DebugString debugText = new DebugString();
+        DebugHtmlString debugHtml = new DebugHtmlString();
+        DebugBuilder debug = new DebugTee(debugText, debugHtml);
+        
+        try {
+            debug.startSection("Exception");
+            debug.appendException(exception);
+            debug.endSection();
+        } catch (RuntimeException e) {
+            debug.appendln("NOTE - an exception occurred while dumping an exception!");
+            debug.appendException(e);
+        }
+
         if (IsisContext.getCurrentTransaction() != null) {
             List<String> messages =  IsisContext.getMessageBroker().getMessages();
-            for (String message : messages) {
-                requestContext.getWriter().append("<div class=\"message\">message:
" + message + "</div>");
-                error.appendln("message", message);
-            }
-            messages =  IsisContext.getMessageBroker().getWarnings();
-            for (String message : messages) {
-                requestContext.getWriter().append("<div class=\"message\">warning:
" + message + "</div>");
-                error.appendln("warning", message);
+            List<String> warnings = IsisContext.getMessageBroker().getWarnings();
+            if (messages.size() > 0 || messages.size() > 0) {
+                debug.startSection("Warnings/Messages");
+                for (String message : messages) {
+                    debug.appendln("message", message);
+                }
+                for (String message : warnings) {
+                    debug.appendln("warning", message);
+                }
             }
         }
         
-        ByteArrayOutputStream out = new ByteArrayOutputStream();
-        writeErrorContent(requestContext, exception, error, new PrintWriter(out), false);
+        requestContext.append(debug);
+
+        debug.startSection("Processing Trace"); 
+        debug.appendPreformatted(requestContext.getDebugTrace()); 
+        debug.endSection();
+        debug.close();
         
+           
         PrintWriter writer;
         try {
-            requestContext.addVariable("_error-ref", errorRef, Scope.INTERACTION);
             String directory = IsisContext.getConfiguration().getString(ConfigurationConstants.ROOT
+ "scimpi.error-snapshots", ".");
             writer = new PrintWriter(new File(directory, "error_" + errorRef + ".html"));
-            writeErrorContent(requestContext, exception, new DebugString(), writer, true);
+            DebugWriter writer2 = new DebugWriter(writer, true);
+            writer2.concat(debugHtml);
+            writer2.close();
+            writer.close();
         } catch (FileNotFoundException e) {
             LOG.error("Failed to archive error page", e);
         }
@@ -242,33 +269,15 @@ public class Dispatcher {
         String replace = "";
         String withReplacement = "";
         String message = exception.getMessage();
-        requestContext.addVariable("_error-message", message == null ? "" : message.replaceAll(replace,
withReplacement), Scope.INTERACTION);
-        requestContext.addVariable("_error-details", out.toString().replaceAll(replace, withReplacement),
Scope.INTERACTION);
+        requestContext.addVariable("_error-message", message == null ? "" : message.replaceAll(replace,
withReplacement), Scope.ERROR);
+        requestContext.addVariable("_error-details", debugHtml.toString().replaceAll(replace,
withReplacement), Scope.ERROR);
+        requestContext.addVariable("_error-ref", errorRef, Scope.ERROR);
         requestContext.clearTransientVariables();
+        
+        String msg = "failed during request for " + servletPath ;
+        LOG.error(msg +  " (#" + errorRef + ")\n" + message +"\n" + debugText + "\n" + msg);
     }
 
-
-    public void writeErrorContent(
-            RequestContext requestContext,
-            Throwable exception,
-            DebugString error,
-            PrintWriter writer,
-            boolean includeHeader) {
-        DebugBuilder errorView = new DebugTee(error, new DebugWriter(writer, includeHeader));
-        try {
-            errorView.appendException(exception);
-            requestContext.append(errorView);
-        } catch (RuntimeException e) {
-            errorView.appendln("NOTE - an exception occurred while dumping an exception!");
-            errorView.appendException(e);
-        }
-        errorView.appendTitle("Processing"); 
-        errorView.appendln("<pre>" + requestContext.getDebugTrace() + "</pre>");

-        errorView.close();
-        writer.close();
-    }
-
-    
     public void addParameter(String name, String value) {
         parameters.put(name, value);
     }

Modified: incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/ForbiddenException.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/ForbiddenException.java?rev=1097566&r1=1097565&r2=1097566&view=diff
==============================================================================
--- incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/ForbiddenException.java
(original)
+++ incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/ForbiddenException.java
Thu Apr 28 18:08:12 2011
@@ -54,7 +54,7 @@ public class ForbiddenException extends 
 
     private ForbiddenException(Identifier identifier, AuthenticationSession session, boolean
isVisibleAndUsabable) {
         super((identifier.getType() == Identifier.Type.PROPERTY_OR_COLLECTION ? "Field" :
"Action") + " '"
-                + identifier.getMemberName() + "' in " + identifier.getClassNaturalName()
+ " is not "
+                + identifier.getMemberName() + "' in " + identifier.getClassName() + " is
not "
                 + (isVisibleAndUsabable ? "visible/usable " : "visible") + " for " + session.getUserName()
+ " "
                 + session.getRoles());
         this.identifier = identifier;

Modified: incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/RequestContext.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/RequestContext.java?rev=1097566&r1=1097565&r2=1097566&view=diff
==============================================================================
--- incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/RequestContext.java
(original)
+++ incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/RequestContext.java
Thu Apr 28 18:08:12 2011
@@ -50,7 +50,7 @@ public abstract class RequestContext {
     private static final Logger LOG = Logger.getLogger(RequestContext.class);
 
     public enum Scope {
-        GLOBAL, SESSION, INTERACTION, REQUEST
+        GLOBAL, SESSION, INTERACTION, REQUEST, ERROR
     };
 
     public enum Debug {
@@ -87,7 +87,7 @@ public abstract class RequestContext {
     public static final String ERROR = "_error";
     public static final String BACK_TO = "_back_to";
     private static final Map<String, Object> globalVariables = new HashMap<String,
Object>();
-    private static final Scope[] SCOPES = new Scope[] { Scope.REQUEST, Scope.INTERACTION,
Scope.SESSION, Scope.GLOBAL };
+    private static final Scope[] SCOPES = new Scope[] { Scope.ERROR, Scope.REQUEST, Scope.INTERACTION,
Scope.SESSION, Scope.GLOBAL };
     private static DebugMode debugMode = null;
 
     private ObjectMapping objectMapping;
@@ -117,6 +117,7 @@ public abstract class RequestContext {
         variables.put(Scope.SESSION, new HashMap<String, Object>());
         variables.put(Scope.INTERACTION, new HashMap<String, Object>());
         variables.put(Scope.REQUEST, new HashMap<String, Object>());
+        variables.put(Scope.ERROR, new HashMap<String, Object>());
     }
 
     public void endHttpSession() {
@@ -253,29 +254,34 @@ public abstract class RequestContext {
     // ////////////////////////////
     // Debug
     // ////////////////////////////
-    public void append(DebugBuilder view) {
-        view.appendTitle("User");
+    public void append(DebugBuilder debug) {
+        debug.startSection("Request");
+        debug.appendTitle("User");
         AuthenticationSession session = getSession();
-        view.appendln("Session", session);
+        debug.appendln("Session", session);
         if (session != null) {
-            view.appendln("Name", session.getUserName());
-            view.appendln("Roles", session.getRoles());
+            debug.appendln("Name", session.getUserName());
+            debug.appendln("Roles", session.getRoles());
         }
 
-        view.appendTitle("context");
-        view.appendln("Parent request path", requestedParentPath);
-        view.appendln("Requested file", requestedFile);
-        view.appendln("Parent resource path", resourceParentPath);
-        view.appendln("Resource file", resourceFile);
-
-        append(view, Scope.GLOBAL);
-        append(view, Scope.SESSION);
-        append(view, Scope.INTERACTION);
-        append(view, Scope.REQUEST);
-        view.endSection();
-
-        view.startSection("Object Mapping");
-        objectMapping.append(view);
+        debug.appendTitle("context");
+        debug.appendln("Parent request path", requestedParentPath);
+        debug.appendln("Requested file", requestedFile);
+        debug.appendln("Parent resource path", resourceParentPath);
+        debug.appendln("Resource file", resourceFile);
+        debug.endSection();
+        
+        debug.startSection("Variables");
+        append(debug, Scope.GLOBAL);
+        append(debug, Scope.SESSION);
+        append(debug, Scope.INTERACTION);
+        append(debug, Scope.REQUEST);
+        append(debug, Scope.ERROR);
+        debug.endSection();
+
+        debug.startSection("Object Mapping");
+        objectMapping.append(debug);
+        debug.endSection();
     }
 
     private void append(DebugBuilder view, Scope scope) {
@@ -301,6 +307,8 @@ public abstract class RequestContext {
             appendVariables(content, Scope.INTERACTION);
             content.blankLine();
             appendVariables(content, Scope.REQUEST);
+            content.blankLine();
+            appendVariables(content, Scope.ERROR);
         } else if (list.equals("mappings")) {
             objectMapping.appendMappings(content);
         }
@@ -503,6 +511,7 @@ public abstract class RequestContext {
     public void endRequest() throws IOException {
         getWriter().close();
         objectMapping.clear();
+        variables.get(Scope.ERROR).clear();
         variables.get(Scope.REQUEST).clear();
         variables.get(Scope.INTERACTION).clear();
     }
@@ -709,6 +718,8 @@ public abstract class RequestContext {
 
     public abstract String imagePath(ObjectSpecification specification);
 
+    public abstract void forward(String view);
+
     public abstract void redirectTo(String view);
 
     public abstract String getContextPath();
@@ -792,4 +803,6 @@ public abstract class RequestContext {
     public void clearTransientVariables() {
         objectMapping.endSession();
     }
+
+    public void reset() {}
 }

Modified: incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/debug/DebugAction.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/debug/DebugAction.java?rev=1097566&r1=1097565&r2=1097566&view=diff
==============================================================================
--- incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/debug/DebugAction.java
(original)
+++ incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/debug/DebugAction.java
Thu Apr 28 18:08:12 2011
@@ -88,8 +88,8 @@ public class DebugAction implements Acti
             view.appendln("<div class=\"links\">");
             view.appendln("<a href=\"debug.app?action=system\">System</a>");
             view.appendln(" | <a href=\"debug.app?action=specifications\">List specifications</a>");
-            view.appendln(" | <a href=\"debug.app?action=i18n\">I18N File</a>");
-            view.appendln(" | <a href=\"debug.app?action=authorization\">Authorization
File</a>");
+            view.appendln(" | <a href=\"debug.app?action=list-i18n\">I18N File</a>");
+            view.appendln(" | <a href=\"debug.app?action=list-authorization\">Authorization
File</a>");
             view.appendln(" | <a href=\"debug.app?action=context\">Context</a>");
             view.appendln(" | <a href=\"debug.app?action=dispatcher\">Dispatcher</a>");
             view.appendln("</div>");

Modified: incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/ProcessorLookup.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/ProcessorLookup.java?rev=1097566&r1=1097565&r2=1097566&view=diff
==============================================================================
--- incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/ProcessorLookup.java
(original)
+++ incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/processor/ProcessorLookup.java
Thu Apr 28 18:08:12 2011
@@ -80,10 +80,12 @@ import org.apache.isis.viewer.scimpi.dis
 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.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;
@@ -92,6 +94,7 @@ import org.apache.isis.viewer.scimpi.dis
 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;
@@ -124,6 +127,7 @@ public class ProcessorLookup {
         addElementProcessor(new BlockUse());
         addElementProcessor(new History());
         addElementProcessor(new Collection());
+        addElementProcessor(new Commit()); 
         addElementProcessor(new ContentTag()); 
         addElementProcessor(new CountElements());
         addElementProcessor(new Diagnostics());
@@ -140,6 +144,7 @@ public class ProcessorLookup {
         addElementProcessor(new FieldValue());
         addElementProcessor(new FormField());
         addElementProcessor(new FormEntry());
+        addElementProcessor(new Forward());
         addElementProcessor(new GetField());
         addElementProcessor(new HiddenField());
         addElementProcessor(new Import());
@@ -163,6 +168,7 @@ public class ProcessorLookup {
         addElementProcessor(new ParameterName());
         addElementProcessor(new PrintAuthorizationClause());
         addElementProcessor(new RadioListField());
+        addElementProcessor(new Redirect());
         addElementProcessor(new RemoveElement());
         addElementProcessor(new RevisionNumber());
         addElementProcessor(new RunAction());

Modified: incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/DebuggerLink.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/DebuggerLink.java?rev=1097566&r1=1097565&r2=1097566&view=diff
==============================================================================
--- incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/DebuggerLink.java
(original)
+++ incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/DebuggerLink.java
Thu Apr 28 18:08:12 2011
@@ -34,7 +34,7 @@ public class DebuggerLink extends Abstra
         RequestContext context = request.getContext();
         Object result = context.getVariable(RequestContext.RESULT); 
         request.appendHtml("<div class=\"debug\">");
-        request.appendHtml("<a href=\"/debug/debug.shtml\" target=\"debug\" title=\"debug\"
>...</a>");
+        request.appendHtml("<a class=\"debug-link\" href=\"/debug/debug.shtml\" target=\"debug\"
title=\"debug\" >...</a>");
         if (result != null) {
             request.appendHtml(" <a href=\"/debug/object.shtml?_result=" + result + "\"
target=\"debug\"  title=\"debug instance\">...</a>");
         }

Modified: incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/PrintAuthorizationClause.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/PrintAuthorizationClause.java?rev=1097566&r1=1097565&r2=1097566&view=diff
==============================================================================
--- incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/PrintAuthorizationClause.java
(original)
+++ incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/PrintAuthorizationClause.java
Thu Apr 28 18:08:12 2011
@@ -19,8 +19,8 @@ public class PrintAuthorizationClause ex
             return;
         }
         
-        Identifier identifier = (Identifier) context.getVariable("_security_identifier");
-        List<String> roles =  (List<String>) context.getVariable("_security_roles");
+        Identifier identifier = (Identifier) context.getVariable("_security-identifier");
+        List<String> roles =  (List<String>) context.getVariable("_security-roles");
         StringBuffer roleList = new StringBuffer();
         for (String role : roles) {
             if (roleList.length() > 0) {
@@ -31,7 +31,8 @@ public class PrintAuthorizationClause ex
         
         request.appendHtml("<pre>" );
         request.appendHtml(identifier.toClassIdentityString() + ":" + roleList + "\n");
-        request.appendHtml(identifier.toString() + ":" + roleList);
+        request.appendHtml(identifier.toClassAndNameIdentityString() + ":" + roleList + "\n");
+        request.appendHtml(identifier.toFullIdentityString() + ":" + roleList + "\n");
         request.appendHtml( "</pre>");
     }
 

Added: incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Commit.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Commit.java?rev=1097566&view=auto
==============================================================================
--- incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Commit.java
(added)
+++ incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Commit.java
Thu Apr 28 18:08:12 2011
@@ -0,0 +1,24 @@
+package org.apache.isis.viewer.scimpi.dispatcher.view.simple;
+
+import org.apache.isis.runtimes.dflt.runtime.context.IsisContext;
+import org.apache.isis.runtimes.dflt.runtime.transaction.IsisTransactionManager;
+import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
+
+public class Commit extends AbstractElementProcessor {
+
+    public String getName() {
+        return "commit";
+    }
+
+    public void process(Request request) {
+        // Note - the session will have changed since the earlier call if a user has logged
in or out in the action processing above.
+        IsisTransactionManager transactionManager = IsisContext.getPersistenceSession().getTransactionManager();
+        if (transactionManager.getTransaction().getState().canCommit()) {
+            transactionManager.endTransaction();
+            transactionManager.startTransaction();
+        }
+    }
+
+}
+

Propchange: incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Commit.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Forward.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Forward.java?rev=1097566&view=auto
==============================================================================
--- incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Forward.java
(added)
+++ incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Forward.java
Thu Apr 28 18:08:12 2011
@@ -0,0 +1,18 @@
+package org.apache.isis.viewer.scimpi.dispatcher.view.simple;
+
+import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
+
+public class Forward extends AbstractElementProcessor {
+
+    public String getName() {
+        return "forward";
+    }
+
+    public void process(Request request) {
+        String view = request.getRequiredProperty(VIEW);
+        request.getContext().forward(view);
+    }
+
+}
+

Propchange: incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Forward.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Redirect.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Redirect.java?rev=1097566&view=auto
==============================================================================
--- incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Redirect.java
(added)
+++ incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Redirect.java
Thu Apr 28 18:08:12 2011
@@ -0,0 +1,18 @@
+package org.apache.isis.viewer.scimpi.dispatcher.view.simple;
+
+import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
+
+public class Redirect extends AbstractElementProcessor {
+
+    public String getName() {
+        return "redirect";
+    }
+
+    public void process(Request request) {
+        String view = request.getRequiredProperty(VIEW);
+        request.getContext().redirectTo(view);
+    }
+
+}
+

Propchange: incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/Redirect.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/RemoveElement.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/RemoveElement.java?rev=1097566&r1=1097565&r2=1097566&view=diff
==============================================================================
--- incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/RemoveElement.java
(original)
+++ incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/RemoveElement.java
Thu Apr 28 18:08:12 2011
@@ -25,8 +25,10 @@ import java.util.List;
 import org.apache.isis.applib.filter.Filter;
 import org.apache.isis.core.commons.authentication.AuthenticationSession;
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.consent.Consent;
 import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
 import org.apache.isis.core.metamodel.spec.feature.ObjectAssociationFilters;
+import org.apache.isis.core.metamodel.spec.feature.OneToManyAssociation;
 import org.apache.isis.runtimes.dflt.runtime.context.IsisContext;
 import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
 import org.apache.isis.viewer.scimpi.dispatcher.Dispatcher;
@@ -77,12 +79,23 @@ public class RemoveElement extends Abstr
         if (field == null) {
             throw new ScimpiException("No field " + fieldName + " in " + adapter.getSpecification().getFullIdentifier());
         }
+        if (!field.isOneToManyAssociation()) {
+            throw new ScimpiException("Field " + fieldName + " not a collection, in " + adapter.getSpecification().getFullIdentifier());
+        }
         if (field.isVisible(IsisContext.getAuthenticationSession(), adapter).isVetoed())
{
             throw new ForbiddenException(field, ForbiddenException.VISIBLE);
         }
         IsisContext.getPersistenceSession().resolveField(adapter, field);
 
-        if (field.isUsable(IsisContext.getAuthenticationSession(), adapter).isAllowed())
{
+        
+        Consent usable = field.isUsable(IsisContext.getAuthenticationSession(), adapter);
+        if (usable.isAllowed()) {
+            usable = ((OneToManyAssociation) field).isValidToRemove(adapter, element);
+        }
+        
+        if (usable.isVetoed()) {
+            request.appendHtml("<span class=\"veto\">" + usable.getReason() + "</span>");
+        } else {
             if (valid(request, adapter)) {
                 String classSegment = " class=\"" + cssClass + "\"";
     
@@ -116,6 +129,8 @@ public class RemoveElement extends Abstr
             return false;
         }
         
+        
+        
         return true;
     }
 }

Modified: incubator/isis/trunk/viewer/scimpi/servlet/src/main/java/org/apache/isis/viewer/scimpi/servlet/ServletRequestContext.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/scimpi/servlet/src/main/java/org/apache/isis/viewer/scimpi/servlet/ServletRequestContext.java?rev=1097566&r1=1097565&r2=1097566&view=diff
==============================================================================
--- incubator/isis/trunk/viewer/scimpi/servlet/src/main/java/org/apache/isis/viewer/scimpi/servlet/ServletRequestContext.java
(original)
+++ incubator/isis/trunk/viewer/scimpi/servlet/src/main/java/org/apache/isis/viewer/scimpi/servlet/ServletRequestContext.java
Thu Apr 28 18:08:12 2011
@@ -28,6 +28,7 @@ import java.util.Enumeration;
 import java.util.Map;
 
 import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
 import javax.servlet.http.Cookie;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
@@ -219,6 +220,26 @@ public class ServletRequestContext exten
         return null;
     }
     
+    public void reset() {
+        try {
+            response.getWriter().print("<h1>RESET</h1>");
+        } catch (IOException e) {
+            throw new DispatchException(e);
+        }
+        response.reset();
+    }
+    
+    public void forward(String view) {
+        try {
+            isAborted = true;
+            getRequest().getRequestDispatcher(view).forward(getRequest(), getResponse());
+        } catch (IOException e) {
+            throw new DispatchException(e);
+        } catch (ServletException e) {
+            throw new DispatchException(e);
+        }
+    }
+
     public void redirectTo(String view) {
         try {
             isAborted = true;



Mime
View raw message