You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by rm...@apache.org on 2012/10/17 15:26:09 UTC
svn commit: r1399230 -
/incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/SetCookie.java
Author: rmatthews
Date: Wed Oct 17 13:26:09 2012
New Revision: 1399230
URL: http://svn.apache.org/viewvc?rev=1399230&view=rev
Log:
ISIS-162 - Cookies can now be cleared.
Modified:
incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/SetCookie.java
Modified: incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/SetCookie.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/SetCookie.java?rev=1399230&r1=1399229&r2=1399230&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/SetCookie.java (original)
+++ incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/SetCookie.java Wed Oct 17 13:26:09 2012
@@ -20,6 +20,7 @@
package org.apache.isis.viewer.scimpi.dispatcher.view.simple;
import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.action.RequiredPropertyException;
import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
public class SetCookie extends AbstractElementProcessor {
@@ -27,11 +28,21 @@ public class SetCookie extends AbstractE
@Override
public void process(final Request request) {
final String name = request.getRequiredProperty("name");
- final String value = request.getRequiredProperty("value");
+ final String value = request.getOptionalProperty("value");
+ final boolean isClear = request.getOptionalProperty("action", "set").equals("clear");
final String expiresString = request.getOptionalProperty("expires", "-1");
- if (value.length() > 0) {
- request.getContext().addCookie(name, value, Integer.valueOf(expiresString));
+ if (!isClear && value == null) {
+ throw new RequiredPropertyException("Property not set: " + value);
+ }
+ if (isClear) {
+ request.appendDebug("cookie: " + name + " (cleared)");
+ request.getContext().addCookie(name, null, 0);
+ } else {
+ if (value.length() > 0) {
+ request.appendDebug("cookie: " + name + " set to"+ value);
+ request.getContext().addCookie(name, value, Integer.valueOf(expiresString));
+ }
}
}