gatein SVN: r5360 - portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata.
by do-not-reply@jboss.org
Author: julien_viet
Date: 2010-11-29 17:39:20 -0500 (Mon, 29 Nov 2010)
New Revision: 5360
Modified:
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RouteDescriptor.java
Log:
path should always be there for a route descriptor
Modified: portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RouteDescriptor.java
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RouteDescriptor.java 2010-11-29 22:35:18 UTC (rev 5359)
+++ portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RouteDescriptor.java 2010-11-29 22:39:20 UTC (rev 5360)
@@ -55,6 +55,12 @@
public RouteDescriptor(String path)
{
+ if (path == null)
+ {
+ throw new NullPointerException("Was not expecting a null path");
+ }
+
+ //
this.path = path;
this.routeParams = new HashMap<QualifiedName, RouteParamDescriptor>();
this.pathParams = new HashMap<QualifiedName, PathParamDescriptor>();
14 years
gatein SVN: r5359 - in portal/branches/navcontroller/component/web/controller/src: main/java/org/exoplatform/web/controller/router and 1 other directories.
by do-not-reply@jboss.org
Author: julien_viet
Date: 2010-11-29 17:35:18 -0500 (Mon, 29 Nov 2010)
New Revision: 5359
Modified:
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/DescriptorBuilder.java
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/PathParamDescriptor.java
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RequestParamDescriptor.java
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RouteDescriptor.java
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RouteParamDescriptor.java
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RouterDescriptor.java
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/RequestParam.java
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/Route.java
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestBuildRoute.java
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestDescriptorBuilder.java
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestHierarchy.java
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestLegacyPortal.java
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestMatch.java
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPathParamEncoding.java
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPortal.java
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPortalConfiguration.java
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestRender.java
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestRequestParam.java
Log:
simplify configuration for unit test
Modified: portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/DescriptorBuilder.java
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/DescriptorBuilder.java 2010-11-29 21:08:43 UTC (rev 5358)
+++ portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/DescriptorBuilder.java 2010-11-29 22:35:18 UTC (rev 5359)
@@ -19,7 +19,6 @@
package org.exoplatform.web.controller.metadata;
-import org.exoplatform.web.controller.QualifiedName;
import org.exoplatform.web.controller.router.EncodingMode;
import javax.xml.namespace.QName;
@@ -35,6 +34,21 @@
public class DescriptorBuilder
{
+ public static PathParamDescriptor pathParam(String qualifiedName)
+ {
+ return new PathParamDescriptor(qualifiedName);
+ }
+
+ public static RequestParamDescriptor requestParam(String qualifiedName)
+ {
+ return new RequestParamDescriptor(qualifiedName);
+ }
+
+ public static RouteParamDescriptor routeParam(String qualifiedName)
+ {
+ return new RouteParamDescriptor(qualifiedName);
+ }
+
/** . */
private static final QName routeQN = new QName("http://www.gatein.org/xml/ns/gatein_router_1_0", "route");
@@ -47,9 +61,19 @@
/** . */
private static final QName pathParamQN = new QName("http://www.gatein.org/xml/ns/gatein_router_1_0", "path-param");
+ public static RouteDescriptor route(String path)
+ {
+ return new RouteDescriptor(path);
+ }
+
+ public static RouterDescriptor router()
+ {
+ return new RouterDescriptor();
+ }
+
public RouterDescriptor build(XMLStreamReader reader) throws Exception
{
- RouterDescriptor routerDesc = new RouterDescriptor();
+ RouterDescriptor routerDesc = router();
//
while (true)
@@ -76,7 +100,7 @@
private void build(XMLStreamReader reader, List<RouteDescriptor> descriptors) throws XMLStreamException
{
String path = reader.getAttributeValue(null, "path");
- RouteDescriptor routeDesc = new RouteDescriptor(path);
+ RouteDescriptor routeDesc = route(path);
//
while (true)
@@ -93,25 +117,25 @@
{
if (paramQN.equals(reader.getName()))
{
- String name = reader.getAttributeValue(null, "qname");
+ String qualifiedName = reader.getAttributeValue(null, "qname");
String value = reader.getAttributeValue(null, "value");
- routeDesc.addRouteParam(QualifiedName.parse(name), value);
+ routeDesc.add(new RouteParamDescriptor(qualifiedName).withValue(value));
}
else if (requestParamQN.equals(reader.getName()))
{
- String name = reader.getAttributeValue(null, "qname");
- String matchName = reader.getAttributeValue(null, "name");
- String matchValue = reader.getAttributeValue(null, "value");
+ String qualifiedName = reader.getAttributeValue(null, "qname");
+ String name = reader.getAttributeValue(null, "name");
+ String value = reader.getAttributeValue(null, "value");
String optional = reader.getAttributeValue(null, "required");
- routeDesc.addRequestParam(QualifiedName.parse(name), matchName, matchValue, "true".equals(optional));
+ routeDesc.add(new RequestParamDescriptor(qualifiedName).withName(name).withValue(value).required("true".equals(optional)));
}
else if (pathParamQN.equals(reader.getName()))
{
- String name = reader.getAttributeValue(null, "qname");
+ String qualifiedName = reader.getAttributeValue(null, "qname");
String pattern = reader.getAttributeValue(null, "pattern");
String encoded = reader.getAttributeValue(null, "encoding");
EncodingMode encodingMode = "preserve-path".equals(encoded) ? EncodingMode.PRESERVE_PATH : EncodingMode.FORM;
- routeDesc.addPathParam(QualifiedName.parse(name), pattern, encodingMode);
+ routeDesc.add(new PathParamDescriptor(qualifiedName).withPattern(pattern).withEncodingMode(encodingMode));
}
else if (routeQN.equals(reader.getName()))
{
Modified: portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/PathParamDescriptor.java
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/PathParamDescriptor.java 2010-11-29 21:08:43 UTC (rev 5358)
+++ portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/PathParamDescriptor.java 2010-11-29 22:35:18 UTC (rev 5359)
@@ -30,32 +30,65 @@
{
/** . */
- private final QualifiedName name;
+ private final QualifiedName qualifiedName;
/** . */
- private final String pattern;
+ private String pattern;
/** . */
- private final EncodingMode encodingMode;
+ private EncodingMode encodingMode = EncodingMode.FORM;
- public PathParamDescriptor(QualifiedName name, String pattern, EncodingMode encodingMode)
+ public PathParamDescriptor(QualifiedName qualifiedName)
{
- if (name == null)
+ if (qualifiedName == null)
{
throw new NullPointerException("No null name accepted");
}
//
- this.name = name;
+ this.qualifiedName = qualifiedName;
+ }
+
+ public PathParamDescriptor(String qualifiedName)
+ {
+ if (qualifiedName == null)
+ {
+ throw new NullPointerException("No null name accepted");
+ }
+
+ //
+ this.qualifiedName = QualifiedName.parse(qualifiedName);
+ }
+
+ public PathParamDescriptor withPattern(String pattern)
+ {
this.pattern = pattern;
+ return this;
+ }
+
+ public PathParamDescriptor withEncodingMode(EncodingMode encodingMode)
+ {
this.encodingMode = encodingMode;
+ return this;
}
- public QualifiedName getName()
+ public PathParamDescriptor preservingPath()
{
- return name;
+ this.encodingMode = EncodingMode.PRESERVE_PATH;
+ return this;
}
+ public PathParamDescriptor form()
+ {
+ this.encodingMode = EncodingMode.FORM;
+ return this;
+ }
+
+ public QualifiedName getQualifiedName()
+ {
+ return qualifiedName;
+ }
+
public String getPattern()
{
return pattern;
Modified: portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RequestParamDescriptor.java
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RequestParamDescriptor.java 2010-11-29 21:08:43 UTC (rev 5358)
+++ portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RequestParamDescriptor.java 2010-11-29 22:35:18 UTC (rev 5359)
@@ -29,48 +29,78 @@
{
/** . */
- private final QualifiedName name;
+ private final QualifiedName qualifiedName;
/** . */
- private final String matchName;
+ private String name;
/** . */
- private final String matchValue;
+ private String value;
/** . */
- private final boolean required;
+ private boolean required;
- public RequestParamDescriptor(QualifiedName name, String matchName, String matchValue, boolean required)
+ public RequestParamDescriptor(QualifiedName qualifiedName)
{
- if (name == null)
+ if (qualifiedName == null)
{
- throw new NullPointerException("No null name accepted");
+ throw new NullPointerException("No null qualified name accepted");
}
- if (matchName == null)
+
+ //
+ this.qualifiedName = qualifiedName;
+ this.value = null;
+ this.required = false;
+ }
+
+ public RequestParamDescriptor(String qualifiedName)
+ {
+ if (qualifiedName == null)
{
- throw new NullPointerException("No null match name accepted");
+ throw new NullPointerException("No null qualified name accepted");
}
//
+ this.qualifiedName = QualifiedName.parse(qualifiedName);
+ }
+
+ public RequestParamDescriptor withName(String name)
+ {
this.name = name;
- this.matchName = matchName;
- this.matchValue = matchValue;
+ return this;
+ }
+
+ public RequestParamDescriptor withValue(String value)
+ {
+ this.value = value;
+ return this;
+ }
+
+ public RequestParamDescriptor required()
+ {
+ this.required = true;
+ return this;
+ }
+
+ public RequestParamDescriptor required(boolean required)
+ {
this.required = required;
+ return this;
}
- public QualifiedName getName()
+ public QualifiedName getQualifiedName()
{
- return name;
+ return qualifiedName;
}
- public String getMatchName()
+ public String getName()
{
- return matchName;
+ return name;
}
- public String getMatchValue()
+ public String getValue()
{
- return matchValue;
+ return value;
}
public boolean isRequired()
Modified: portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RouteDescriptor.java
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RouteDescriptor.java 2010-11-29 21:08:43 UTC (rev 5358)
+++ portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RouteDescriptor.java 2010-11-29 22:35:18 UTC (rev 5359)
@@ -67,17 +67,6 @@
return path;
}
- public RouteDescriptor addRouteParam(QualifiedName name, String value)
- {
- routeParams.put(name, new RouteParamDescriptor(name, value));
- return this;
- }
-
- public RouteDescriptor addRouteParam(String name, String value)
- {
- return addRouteParam(QualifiedName.parse(name), value);
- }
-
public Set<QualifiedName> getRouteParamNames()
{
return routeParams.keySet();
@@ -93,37 +82,21 @@
return routeParams.get(name);
}
- public RouteDescriptor addRequestParam(QualifiedName name, String matchName, String matchValue, boolean required)
+ public RouteDescriptor add(RouteParamDescriptor routeParam)
{
- return addRequestParam(new RequestParamDescriptor(name, matchName, matchValue, required));
+ routeParams.put(routeParam.getQualifiedName(), routeParam);
+ return this;
}
- public RouteDescriptor addRequestParam(RequestParamDescriptor requestParam)
+ public RouteDescriptor add(RequestParamDescriptor requestParam)
{
- requestParams.put(requestParam.getMatchName(), requestParam);
+ requestParams.put(requestParam.getName(), requestParam);
return this;
}
- /**
- * Add a path param with the {@link EncodingMode#FORM} encoding.
- *
- * @param name the name
- * @param pattern the pattern
- * @return this object
- */
- public RouteDescriptor addPathParam(QualifiedName name, String pattern)
+ public RouteDescriptor add(PathParamDescriptor pathParam)
{
- return addPathParam(name, pattern, EncodingMode.FORM);
- }
-
- public RouteDescriptor addPathParam(QualifiedName name, String pattern, EncodingMode encodingMode)
- {
- return addPathParam(new PathParamDescriptor(name, pattern, encodingMode));
- }
-
- public RouteDescriptor addPathParam(PathParamDescriptor pathParam)
- {
- pathParams.put(pathParam.getName(), pathParam);
+ pathParams.put(pathParam.getQualifiedName(), pathParam);
return this;
}
@@ -147,7 +120,7 @@
return pathParams;
}
- public RouteDescriptor addRoute(RouteDescriptor child)
+ public RouteDescriptor add(RouteDescriptor child)
{
children.add(child);
return this;
Modified: portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RouteParamDescriptor.java
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RouteParamDescriptor.java 2010-11-29 21:08:43 UTC (rev 5358)
+++ portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RouteParamDescriptor.java 2010-11-29 22:35:18 UTC (rev 5359)
@@ -29,30 +29,30 @@
{
/** . */
- private final QualifiedName name;
+ private final QualifiedName qualifiedName;
/** . */
- private final String value;
+ private String value;
- public RouteParamDescriptor(QualifiedName name, String value)
+ public RouteParamDescriptor(QualifiedName qualifiedName)
{
- if (name == null)
- {
- throw new NullPointerException("No null name accepted");
- }
- if (value == null)
- {
- throw new NullPointerException("No null value accepted");
- }
+ this.qualifiedName = qualifiedName;
+ }
- //
- this.name = name;
+ public RouteParamDescriptor(String qualifiedName)
+ {
+ this.qualifiedName = QualifiedName.parse(qualifiedName);
+ }
+
+ public RouteParamDescriptor withValue(String value)
+ {
this.value = value;
+ return this;
}
- public QualifiedName getName()
+ public QualifiedName getQualifiedName()
{
- return name;
+ return qualifiedName;
}
public String getValue()
Modified: portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RouterDescriptor.java
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RouterDescriptor.java 2010-11-29 21:08:43 UTC (rev 5358)
+++ portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RouterDescriptor.java 2010-11-29 22:35:18 UTC (rev 5359)
@@ -19,6 +19,8 @@
package org.exoplatform.web.controller.metadata;
+import org.exoplatform.web.controller.router.Router;
+
import java.util.ArrayList;
import java.util.List;
@@ -39,7 +41,7 @@
this.routes = new ArrayList<RouteDescriptor>();
}
- public RouterDescriptor addRoute(RouteDescriptor controller)
+ public RouterDescriptor add(RouteDescriptor controller)
{
if (controller == null)
{
@@ -57,4 +59,9 @@
{
return routes;
}
+
+ public Router build()
+ {
+ return new Router(this);
+ }
}
Modified: portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/RequestParam.java
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/RequestParam.java 2010-11-29 21:08:43 UTC (rev 5358)
+++ portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/RequestParam.java 2010-11-29 22:35:18 UTC (rev 5359)
@@ -52,12 +52,12 @@
//
Pattern matchValue = null;
- if (descriptor.getMatchValue() != null)
+ if (descriptor.getValue() != null)
{
PatternBuilder matchValueBuilder = new PatternBuilder();
matchValueBuilder.expr("^");
int level = 0;
- for (char c : descriptor.getMatchValue().toCharArray())
+ for (char c : descriptor.getValue().toCharArray())
{
switch (c)
{
@@ -91,8 +91,8 @@
}
//
- this.name = descriptor.getName();
- this.matchName = descriptor.getMatchName();
+ this.name = descriptor.getQualifiedName();
+ this.matchName = descriptor.getName();
this.matchValue = matchValue;
this.required = descriptor.isRequired();
}
Modified: portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/Route.java
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/Route.java 2010-11-29 21:08:43 UTC (rev 5358)
+++ portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/Route.java 2010-11-29 22:35:18 UTC (rev 5359)
@@ -529,14 +529,14 @@
Map<QualifiedName, RouteParam> routeParams = new HashMap<QualifiedName, RouteParam>();
for (RouteParamDescriptor routeParamDesc : descriptor.getRouteParams())
{
- routeParams.put(routeParamDesc.getName(), new RouteParam(routeParamDesc.getName(), routeParamDesc.getValue()));
+ routeParams.put(routeParamDesc.getQualifiedName(), new RouteParam(routeParamDesc.getQualifiedName(), routeParamDesc.getValue()));
}
//
Map<String, RequestParam> requestParams = new HashMap<String, RequestParam>();
for (RequestParamDescriptor requestParamDesc : descriptor.getRequestParams())
{
- requestParams.put(requestParamDesc.getMatchName(), new RequestParam(requestParamDesc));
+ requestParams.put(requestParamDesc.getName(), new RequestParam(requestParamDesc));
}
//
Modified: portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestBuildRoute.java
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestBuildRoute.java 2010-11-29 21:08:43 UTC (rev 5358)
+++ portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestBuildRoute.java 2010-11-29 22:35:18 UTC (rev 5359)
@@ -21,8 +21,7 @@
import junit.framework.TestCase;
import org.exoplatform.web.controller.QualifiedName;
-import org.exoplatform.web.controller.metadata.RouteDescriptor;
-import org.exoplatform.web.controller.metadata.RouterDescriptor;
+import static org.exoplatform.web.controller.metadata.DescriptorBuilder.*;
/**
* @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
@@ -36,9 +35,7 @@
String[] paths = {"/",""};
for (String path : paths)
{
- RouterDescriptor routerMD = new RouterDescriptor();
- routerMD.addRoute(new RouteDescriptor(path));
- Router router = new Router(routerMD);
+ Router router = new Router(router().add(route(path)));
Route expectedRoute = new Route();
assertEquals(expectedRoute, router.root);
}
@@ -49,9 +46,7 @@
String[] paths = {"/a","a"};
for (String path : paths)
{
- RouterDescriptor routerMD = new RouterDescriptor();
- routerMD.addRoute(new RouteDescriptor(path));
- Router router = new Router(routerMD);
+ Router router = new Router(router().add(route(path)));
Route expectedRoute = new Route();
expectedRoute.add(new SegmentRoute("a"));
assertEquals(expectedRoute, router.root);
@@ -63,9 +58,7 @@
String[] paths = {"/{a}","{a}"};
for (String path : paths)
{
- RouterDescriptor routerMD = new RouterDescriptor();
- routerMD.addRoute(new RouteDescriptor(path));
- Router router = new Router(routerMD);
+ Router router = new Router(router().add(route(path)));
//
assertEquals(0, router.root.getSegmentNames().size());
@@ -87,9 +80,7 @@
String[] paths = {"/{q:a}","{q:a}"};
for (String path : paths)
{
- RouterDescriptor routerMD = new RouterDescriptor();
- routerMD.addRoute(new RouteDescriptor(path));
- Router router = new Router(routerMD);
+ Router router = new Router(router().add(route(path)));
//
assertEquals(0, router.root.getSegmentNames().size());
@@ -111,9 +102,7 @@
String[] paths = {"/{a}","{a}"};
for (String path : paths)
{
- RouterDescriptor routerMD = new RouterDescriptor();
- routerMD.addRoute(new RouteDescriptor(path).addPathParam(QualifiedName.parse("a"), ".*", EncodingMode.FORM));
- Router router = new Router(routerMD);
+ Router router = new Router(router().add(route(path).add(pathParam("a").withPattern(".*"))));
//
assertEquals(0, router.root.getSegmentNames().size());
@@ -132,12 +121,7 @@
public void testSamePrefix()
{
- RouterDescriptor routerMD = new RouterDescriptor();
- routerMD.addRoute(new RouteDescriptor("/public/foo"));
- routerMD.addRoute(new RouteDescriptor("/public/bar"));
-
- //
- Router router = new Router(routerMD);
+ Router router = router().add(route("/public/foo")).add(route("/public/bar")).build();
assertEquals(2, router.root.getSegmentSize("public"));
Route publicRoute1 = router.root.getSegment("public", 0);
assertEquals(1, publicRoute1.getSegmentSize("foo"));
Modified: portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestDescriptorBuilder.java
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestDescriptorBuilder.java 2010-11-29 21:08:43 UTC (rev 5358)
+++ portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestDescriptorBuilder.java 2010-11-29 22:35:18 UTC (rev 5359)
@@ -55,10 +55,10 @@
RouteDescriptor route1 = i.next();
assertEquals("/public/{gtn:sitetype}/{gtn:sitename}{gtn:path}", route1.getPath());
assertEquals(Collections.singleton(WebAppController.HANDLER_PARAM), route1.getRouteParamNames());
- assertEquals(WebAppController.HANDLER_PARAM, route1.getRouteParam(WebAppController.HANDLER_PARAM).getName());
+ assertEquals(WebAppController.HANDLER_PARAM, route1.getRouteParam(WebAppController.HANDLER_PARAM).getQualifiedName());
assertEquals("portal", route1.getRouteParam(WebAppController.HANDLER_PARAM).getValue());
assertEquals(Collections.singleton(QualifiedName.parse("gtn:path")), route1.getPathParams().keySet());
- assertEquals(QualifiedName.parse("gtn:path"), route1.getPathParams().get(QualifiedName.parse("gtn:path")).getName());
+ assertEquals(QualifiedName.parse("gtn:path"), route1.getPathParams().get(QualifiedName.parse("gtn:path")).getQualifiedName());
assertEquals(".*", route1.getPathParams().get(QualifiedName.parse("gtn:path")).getPattern());
assertEquals(EncodingMode.FORM, route1.getPathParams().get(QualifiedName.parse("gtn:path")).getEncodingMode());
@@ -67,10 +67,10 @@
RouteDescriptor route2 = i.next();
assertEquals("/private/{gtn:sitetype}/{gtn:sitename}{gtn:path}", route2.getPath());
assertEquals(Collections.singleton(WebAppController.HANDLER_PARAM), route2.getRouteParamNames());
- assertEquals(WebAppController.HANDLER_PARAM, route2.getRouteParam(WebAppController.HANDLER_PARAM).getName());
+ assertEquals(WebAppController.HANDLER_PARAM, route2.getRouteParam(WebAppController.HANDLER_PARAM).getQualifiedName());
assertEquals("portal", route2.getRouteParam(WebAppController.HANDLER_PARAM).getValue());
assertEquals(Collections.singleton(QualifiedName.parse("gtn:path")), route2.getPathParams().keySet());
- assertEquals(QualifiedName.parse("gtn:path"), route2.getPathParams().get(QualifiedName.parse("gtn:path")).getName());
+ assertEquals(QualifiedName.parse("gtn:path"), route2.getPathParams().get(QualifiedName.parse("gtn:path")).getQualifiedName());
assertEquals(".*", route2.getPathParams().get(QualifiedName.parse("gtn:path")).getPattern());
assertEquals(EncodingMode.PRESERVE_PATH, route2.getPathParams().get(QualifiedName.parse("gtn:path")).getEncodingMode());
@@ -79,7 +79,7 @@
RouteDescriptor route3 = i.next();
assertEquals("/upload", route3.getPath());
assertEquals(Collections.singleton(WebAppController.HANDLER_PARAM), route3.getRouteParamNames());
- assertEquals(WebAppController.HANDLER_PARAM, route3.getRouteParam(WebAppController.HANDLER_PARAM).getName());
+ assertEquals(WebAppController.HANDLER_PARAM, route3.getRouteParam(WebAppController.HANDLER_PARAM).getQualifiedName());
assertEquals("upload", route3.getRouteParam(WebAppController.HANDLER_PARAM).getValue());
//
@@ -87,7 +87,7 @@
RouteDescriptor route4 = i.next();
assertEquals("/download", route4.getPath());
assertEquals(Collections.singleton(WebAppController.HANDLER_PARAM), route4.getRouteParamNames());
- assertEquals(WebAppController.HANDLER_PARAM, route4.getRouteParam(WebAppController.HANDLER_PARAM).getName());
+ assertEquals(WebAppController.HANDLER_PARAM, route4.getRouteParam(WebAppController.HANDLER_PARAM).getQualifiedName());
assertEquals("download", route4.getRouteParam(WebAppController.HANDLER_PARAM).getValue());
//
@@ -95,13 +95,13 @@
RouteDescriptor route5 = i.next();
assertEquals("/a", route5.getPath());
assertEquals(Collections.singleton(QualifiedName.create("a")), route5.getRouteParamNames());
- assertEquals(QualifiedName.create("a"), route5.getRouteParam(QualifiedName.create("a")).getName());
+ assertEquals(QualifiedName.create("a"), route5.getRouteParam(QualifiedName.create("a")).getQualifiedName());
assertEquals("a_value", route5.getRouteParam(QualifiedName.create("a")).getValue());
assertEquals(1, route5.getChildren().size());
RouteDescriptor route5_1 = route5.getChildren().get(0);
assertEquals("/b", route5_1.getPath());
assertEquals(Collections.singleton(QualifiedName.create("b")), route5_1.getRouteParamNames());
- assertEquals(QualifiedName.create("b"), route5_1.getRouteParam(QualifiedName.create("b")).getName());
+ assertEquals(QualifiedName.create("b"), route5_1.getRouteParam(QualifiedName.create("b")).getQualifiedName());
assertEquals("b_value", route5_1.getRouteParam(QualifiedName.create("b")).getValue());
//
@@ -109,17 +109,17 @@
RouteDescriptor route6 = i.next();
assertEquals("/b", route6.getPath());
assertEquals(new HashSet<String>(Arrays.asList("foo", "bar", "juu")), route6.getRequestParamMatchNames());
- assertEquals(QualifiedName.parse("foo"), route6.getRequestParam("foo").getName());
- assertEquals("foo", route6.getRequestParam("foo").getMatchName());
- assertEquals(null, route6.getRequestParam("foo").getMatchValue());
+ assertEquals(QualifiedName.parse("foo"), route6.getRequestParam("foo").getQualifiedName());
+ assertEquals("foo", route6.getRequestParam("foo").getName());
+ assertEquals(null, route6.getRequestParam("foo").getValue());
assertEquals(false, route6.getRequestParam("foo").isRequired());
- assertEquals(QualifiedName.parse("bar"), route6.getRequestParam("bar").getName());
- assertEquals("bar", route6.getRequestParam("bar").getMatchName());
- assertEquals("bar", route6.getRequestParam("bar").getMatchValue());
+ assertEquals(QualifiedName.parse("bar"), route6.getRequestParam("bar").getQualifiedName());
+ assertEquals("bar", route6.getRequestParam("bar").getName());
+ assertEquals("bar", route6.getRequestParam("bar").getValue());
assertEquals(false, route6.getRequestParam("bar").isRequired());
- assertEquals(QualifiedName.parse("juu"), route6.getRequestParam("juu").getName());
- assertEquals("juu", route6.getRequestParam("juu").getMatchName());
- assertEquals("juu", route6.getRequestParam("juu").getMatchValue());
+ assertEquals(QualifiedName.parse("juu"), route6.getRequestParam("juu").getQualifiedName());
+ assertEquals("juu", route6.getRequestParam("juu").getName());
+ assertEquals("juu", route6.getRequestParam("juu").getValue());
assertEquals(true, route6.getRequestParam("juu").isRequired());
//
Modified: portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestHierarchy.java
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestHierarchy.java 2010-11-29 21:08:43 UTC (rev 5358)
+++ portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestHierarchy.java 2010-11-29 22:35:18 UTC (rev 5359)
@@ -20,8 +20,7 @@
package org.exoplatform.web.controller.router;
import org.exoplatform.web.controller.QualifiedName;
-import org.exoplatform.web.controller.metadata.RouteDescriptor;
-import org.exoplatform.web.controller.metadata.RouterDescriptor;
+import static org.exoplatform.web.controller.metadata.DescriptorBuilder.*;
import java.util.Collections;
import java.util.HashMap;
@@ -36,15 +35,12 @@
public void testFoo() throws Exception
{
+ Router router = router().
+ add(route("/a").add(routeParam("foo").withValue("bar")).
+ add(route("/b").add(routeParam("juu").withValue("daa")))).
+ build();
- RouteDescriptor descriptor = new RouteDescriptor("/a").
- addRouteParam("foo", "bar").
- addRoute(new RouteDescriptor("/b").addRouteParam("juu", "daa"));
-
//
- Router router = new Router(new RouterDescriptor().addRoute(descriptor));
-
- //
assertEquals(Collections.singletonMap(QualifiedName.create("foo"), "bar"), router.route("/a"));
//
Modified: portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestLegacyPortal.java
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestLegacyPortal.java 2010-11-29 21:08:43 UTC (rev 5358)
+++ portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestLegacyPortal.java 2010-11-29 22:35:18 UTC (rev 5359)
@@ -21,8 +21,7 @@
import junit.framework.TestCase;
import org.exoplatform.web.controller.QualifiedName;
-import org.exoplatform.web.controller.metadata.RouteDescriptor;
-import org.exoplatform.web.controller.metadata.RouterDescriptor;
+import static org.exoplatform.web.controller.metadata.DescriptorBuilder.*;
import java.util.Collections;
import java.util.HashMap;
@@ -41,27 +40,19 @@
@Override
protected void setUp() throws Exception
{
- RouterDescriptor routerMD = new RouterDescriptor();
-
- RouteDescriptor portal = new RouteDescriptor("/").
- addRouteParam(QualifiedName.parse("gtn:handler"), "portal").
- addRequestParam(QualifiedName.parse("gtn:componentid"), "portal:componentId", null, false).
- addRequestParam(QualifiedName.parse("gtn:action"), "portal:action", null, false).
- addRequestParam(QualifiedName.parse("gtn:objectid"), "portal:objectId", null, false).
- addRoute(
- new RouteDescriptor("/public/{gtn:sitename}{gtn:path}").
- addRouteParam(QualifiedName.parse("gtn:access"), "public")).
- addPathParam(QualifiedName.parse("gtn:path"), ".*", EncodingMode.PRESERVE_PATH).
- addRoute(
- new RouteDescriptor("/private/{gtn:sitename}{gtn:path}").
- addPathParam(QualifiedName.parse("gtn:path"), ".*", EncodingMode.PRESERVE_PATH).
- addRouteParam(QualifiedName.parse("gtn:access"), "private"));
-
- //
- routerMD.addRoute(portal);
-
- //
- this.router = new Router(routerMD);
+ this.router = router().
+ add(route("/").
+ add(routeParam("gtn:handler").withValue("portal")).
+ add(requestParam("gtn:componentid").withName("portal:componentId")).
+ add(requestParam("gtn:action").withName("portal:action")).
+ add(requestParam("gtn:objectid").withName("portal:objectId")).
+ add(route("/public/{gtn:sitename}{gtn:path}").
+ add(routeParam("gtn:access").withValue("public")).
+ add(pathParam("gtn:path").withPattern(".*").preservingPath())).
+ add(route("/private/{gtn:sitename}{gtn:path}").
+ add(routeParam("gtn:access").withValue("private")).
+ add(pathParam("gtn:path").withPattern(".*").preservingPath()))).
+ build();
}
public void testPrivateClassicComponent() throws Exception
Modified: portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestMatch.java
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestMatch.java 2010-11-29 21:08:43 UTC (rev 5358)
+++ portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestMatch.java 2010-11-29 22:35:18 UTC (rev 5359)
@@ -20,8 +20,7 @@
package org.exoplatform.web.controller.router;
import org.exoplatform.web.controller.QualifiedName;
-import org.exoplatform.web.controller.metadata.RouteDescriptor;
-import org.exoplatform.web.controller.metadata.RouterDescriptor;
+import static org.exoplatform.web.controller.metadata.DescriptorBuilder.*;
import java.util.Collections;
import java.util.HashMap;
@@ -36,9 +35,7 @@
public void testRoot() throws Exception
{
- RouterDescriptor routerMD = new RouterDescriptor();
- routerMD.addRoute(new RouteDescriptor("/"));
- Router router = new Router(routerMD);
+ Router router = router().add(route("/")).build();
//
assertNull(router.route(""));
@@ -49,9 +46,7 @@
public void testA() throws Exception
{
- RouterDescriptor routerMD = new RouterDescriptor();
- routerMD.addRoute(new RouteDescriptor("/a"));
- Router router = new Router(routerMD);
+ Router router = router().add(route("/a")).build();
//
assertEquals(Collections.<QualifiedName, String>emptyMap(), router.route("/a"));
@@ -67,9 +62,7 @@
public void testAB() throws Exception
{
- RouterDescriptor routerMD = new RouterDescriptor();
- routerMD.addRoute(new RouteDescriptor("/a/b"));
- Router router = new Router( routerMD);
+ Router router = router().add(route("/a/b")).build();
//
assertNull(router.route("a/b"));
@@ -85,9 +78,7 @@
public void testParameter() throws Exception
{
- RouterDescriptor routerMD = new RouterDescriptor();
- routerMD.addRoute(new RouteDescriptor("/{p}"));
- Router router = new Router(routerMD);
+ Router router = router().add(route("/{p}")).build();
//
assertEquals(Collections.singletonMap(QualifiedName.create("p"), "a"), router.route("/a"));
@@ -95,10 +86,9 @@
public void testParameterPropagationToDescendants() throws Exception
{
- RouterDescriptor routerMD = new RouterDescriptor();
- routerMD.addRoute(new RouteDescriptor("/").addRouteParam("p", "a"));
- routerMD.addRoute(new RouteDescriptor("/a"));
- Router router = new Router(routerMD);
+ Router router = router().
+ add(route("/").add(routeParam("p").withValue("a"))).
+ add(route("/a")).build();
//
assertEquals(Collections.singletonMap(QualifiedName.create("p"), "a"), router.route("/a"));
@@ -106,9 +96,7 @@
public void testSimplePattern() throws Exception
{
- RouterDescriptor routerMD = new RouterDescriptor();
- routerMD.addRoute(new RouteDescriptor("/{p}").addPathParam(QualifiedName.parse("p"), "a", EncodingMode.FORM));
- Router router = new Router(routerMD);
+ Router router = router().add(route("/{p}").add(pathParam("p").withPattern("a"))).build();
//
assertEquals(Collections.singletonMap(QualifiedName.create("p"), "a"), router.route("/a"));
@@ -119,10 +107,10 @@
public void testPrecedence() throws Exception
{
- RouterDescriptor routerMD = new RouterDescriptor();
- routerMD.addRoute(new RouteDescriptor("/a"));
- routerMD.addRoute(new RouteDescriptor("/{p}/b").addPathParam(QualifiedName.parse("p"), "a"));
- Router router = new Router(routerMD);
+ Router router = router().
+ add(route("/a")).
+ add(route("/{p}/b").add(pathParam("p").withPattern("a"))).
+ build();
//
assertNull(router.route("a"));
@@ -133,10 +121,10 @@
public void testTwoRules1() throws Exception
{
- RouterDescriptor routerMD = new RouterDescriptor();
- routerMD.addRoute(new RouteDescriptor("/a").addRouteParam("b", "b"));
- routerMD.addRoute(new RouteDescriptor("/a/b"));
- Router router = new Router(routerMD);
+ Router router = router().
+ add(route("/a").add(routeParam("b").withValue("b"))).
+ add(route("/a/b")).
+ build();
//
assertEquals(Collections.singletonMap(QualifiedName.create("b"), "b"), router.route("/a"));
@@ -145,10 +133,10 @@
public void testTwoRules2() throws Exception
{
- RouterDescriptor routerMD = new RouterDescriptor();
- routerMD.addRoute(new RouteDescriptor("/{a}").addRouteParam("b", "b"));
- routerMD.addRoute(new RouteDescriptor("/{a}/b"));
- Router router = new Router(routerMD);
+ Router router = router().
+ add(route("/{a}").add(routeParam("b").withValue("b"))).
+ add(route("/{a}/b")).
+ build();
//
Map<QualifiedName, String> expectedParameters = new HashMap<QualifiedName, String>();
@@ -160,9 +148,9 @@
public void testLang() throws Exception
{
- RouterDescriptor routerMD = new RouterDescriptor();
- routerMD.addRoute(new RouteDescriptor("/{a}b").addPathParam(QualifiedName.parse("a"), "(([A-Za-z]{2})/)?", EncodingMode.PRESERVE_PATH));
- Router router = new Router(routerMD);
+ Router router = router().
+ add(route("/{a}b").add(pathParam("a").withPattern("(([A-Za-z]{2})/)?").preservingPath())).
+ build();
//
assertEquals(Collections.singletonMap(QualifiedName.create("a"), "fr/"), router.route("/fr/b"));
Modified: portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPathParamEncoding.java
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPathParamEncoding.java 2010-11-29 21:08:43 UTC (rev 5358)
+++ portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPathParamEncoding.java 2010-11-29 22:35:18 UTC (rev 5359)
@@ -20,8 +20,7 @@
package org.exoplatform.web.controller.router;
import org.exoplatform.web.controller.QualifiedName;
-import org.exoplatform.web.controller.metadata.RouteDescriptor;
-import org.exoplatform.web.controller.metadata.RouterDescriptor;
+import static org.exoplatform.web.controller.metadata.DescriptorBuilder.*;
import java.util.Collections;
@@ -34,9 +33,7 @@
public void testDefaultForm() throws Exception
{
- RouterDescriptor routerMD = new RouterDescriptor();
- routerMD.addRoute(new RouteDescriptor("/{p}").addPathParam(QualifiedName.parse("p"), ".+", EncodingMode.FORM));
- Router router = new Router(routerMD);
+ Router router = router().add(route("/{p}").add(pathParam("p").withPattern(".+"))).build();
// Route
assertEquals(Collections.singletonMap(QualifiedName.create("p"), "/"), router.route("/_"));
@@ -47,9 +44,7 @@
public void testPreservePath() throws Exception
{
- RouterDescriptor routerMD = new RouterDescriptor();
- routerMD.addRoute(new RouteDescriptor("/{p}").addPathParam(QualifiedName.parse("p"), "[^/]+", EncodingMode.PRESERVE_PATH));
- Router router = new Router(routerMD);
+ Router router = router().add(route("/{p}").add(pathParam("p").withPattern("[^/]+").preservingPath())).build();
// Route
assertEquals(Collections.singletonMap(QualifiedName.create("p"), "_"), router.route("/_"));
@@ -61,10 +56,10 @@
public void testD() throws Exception
{
- RouterDescriptor routerMD = new RouterDescriptor();
- routerMD.addRoute(new RouteDescriptor("/{p}").
- addPathParam(QualifiedName.parse("p"), "/[a-z]+/[a-z]+/?", EncodingMode.FORM));
- Router router = new Router(routerMD);
+ Router router = router().
+ add(route("/{p}").
+ add(pathParam("p").withPattern("/[a-z]+/[a-z]+/?"))).
+ build();
// Route
assertEquals(Collections.singletonMap(QualifiedName.create("p"), "/platform/administrator"), router.route("/_platform_administrator"));
@@ -80,9 +75,7 @@
public void testWildcardPathParamWithPreservePath() throws Exception
{
- RouterDescriptor routerMD = new RouterDescriptor();
- routerMD.addRoute(new RouteDescriptor("/{p}").addPathParam(QualifiedName.parse("p"), ".*", EncodingMode.PRESERVE_PATH));
- Router router = new Router(routerMD);
+ Router router = router().add(route("/{p}").add(pathParam("p").withPattern(".*").preservingPath())).build();
// Render
assertEquals("/", router.render(Collections.singletonMap(QualifiedName.create("p"), "")));
@@ -99,9 +92,7 @@
public void testWildcardParamPathWithDefaultForm() throws Exception
{
- RouterDescriptor routerMD = new RouterDescriptor();
- routerMD.addRoute(new RouteDescriptor("/{p}").addPathParam(QualifiedName.parse("p"), ".*", EncodingMode.FORM));
- Router router = new Router(routerMD);
+ Router router = router().add(route("/{p}").add(pathParam("p").withPattern(".*"))).build();
//
assertEquals("/_", router.render(Collections.singletonMap(QualifiedName.create("p"), "/")));
Modified: portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPortal.java
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPortal.java 2010-11-29 21:08:43 UTC (rev 5358)
+++ portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPortal.java 2010-11-29 22:35:18 UTC (rev 5359)
@@ -20,7 +20,8 @@
package org.exoplatform.web.controller.router;
import org.exoplatform.web.controller.QualifiedName;
-import org.exoplatform.web.controller.metadata.RouteDescriptor;
+import static org.exoplatform.web.controller.metadata.DescriptorBuilder.*;
+
import org.exoplatform.web.controller.metadata.RouterDescriptor;
import java.util.Collections;
@@ -34,9 +35,9 @@
public void testLanguage1() throws Exception
{
- RouterDescriptor routerMD = new RouterDescriptor().addRoute(
- new RouteDescriptor("/public{gtn:lang}").addPathParam(
- QualifiedName.parse("gtn:lang"), "(/[A-Za-z][A-Za-z])?", EncodingMode.PRESERVE_PATH)
+ RouterDescriptor routerMD = router().add(
+ route("/public{gtn:lang}").add(
+ pathParam("gtn:lang").withPattern("(/[A-Za-z][A-Za-z])?").preservingPath())
);
Router router = new Router(routerMD);
assertEquals(Collections.singletonMap(QualifiedName.parse("gtn:lang"), ""), router.route("/public"));
@@ -45,9 +46,9 @@
public void testLanguage2() throws Exception
{
- RouterDescriptor routerMD = new RouterDescriptor().addRoute(
- new RouteDescriptor("/{gtn:lang}public").addPathParam(
- QualifiedName.parse("gtn:lang"), "([A-Za-z]{2}/)?", EncodingMode.PRESERVE_PATH)
+ RouterDescriptor routerMD = router().add(
+ route("/{gtn:lang}public").add(
+ pathParam("gtn:lang").withPattern("([A-Za-z]{2}/)?").preservingPath())
);
Router router = new Router(routerMD);
assertEquals(Collections.singletonMap(QualifiedName.parse("gtn:lang"), ""), router.route("/public"));
@@ -56,11 +57,10 @@
public void testLanguage3() throws Exception
{
- RouterDescriptor routerMD = new RouterDescriptor().
- addRoute(new RouteDescriptor("/public")).
- addRoute(new RouteDescriptor("/{gtn:lang}/public").
- addPathParam(QualifiedName.parse("gtn:lang"), "([A-Za-z]{2})", EncodingMode.FORM
- )
+ RouterDescriptor routerMD = router().
+ add(route("/public")).
+ add(route("/{gtn:lang}/public").
+ add(pathParam("gtn:lang").withPattern("([A-Za-z]{2})"))
);
Router router = new Router(routerMD);
assertEquals(Collections.<QualifiedName, String>emptyMap(), router.route("/public"));
Modified: portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPortalConfiguration.java
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPortalConfiguration.java 2010-11-29 21:08:43 UTC (rev 5358)
+++ portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPortalConfiguration.java 2010-11-29 22:35:18 UTC (rev 5359)
@@ -20,8 +20,7 @@
package org.exoplatform.web.controller.router;
import org.exoplatform.web.controller.QualifiedName;
-import org.exoplatform.web.controller.metadata.RouteDescriptor;
-import org.exoplatform.web.controller.metadata.RouterDescriptor;
+import static org.exoplatform.web.controller.metadata.DescriptorBuilder.*;
import java.util.Collections;
import java.util.HashMap;
@@ -40,35 +39,22 @@
@Override
protected void setUp() throws Exception
{
- RouterDescriptor routerMD = new RouterDescriptor();
-
- //
- RouteDescriptor portalRouteMD = new RouteDescriptor("/private/{gtn:sitetype}/{gtn:sitename}{gtn:path}");
- portalRouteMD.addRouteParam(QualifiedName.create("gtn", "controller"), "site");
- portalRouteMD.addRequestParam(QualifiedName.create("gtn", "componentid"), "portal:componentId", null, false);
- portalRouteMD.addPathParam(QualifiedName.create("gtn", "path"), ".*", EncodingMode.PRESERVE_PATH);
- routerMD.addRoute(portalRouteMD);
-
- //
- RouteDescriptor portalRouteMD2 = new RouteDescriptor("/private/{gtn:sitetype}/{gtn:sitename}{gtn:path}");
- portalRouteMD2.addRouteParam(QualifiedName.create("gtn", "controller"), "site");
- portalRouteMD2.addPathParam(QualifiedName.create("gtn", "path"), ".*", EncodingMode.PRESERVE_PATH);
- routerMD.addRoute(portalRouteMD2);
-
- //
- RouteDescriptor groupRouteMD = new RouteDescriptor("/groups/{gtn:sitetype}/{gtn:sitename}{gtn:path}");
- groupRouteMD.addRouteParam(QualifiedName.create("gtn", "controller"), "site");
- groupRouteMD.addPathParam(QualifiedName.create("gtn", "path"), ".*", EncodingMode.PRESERVE_PATH);
- routerMD.addRoute(groupRouteMD);
-
- //
- RouteDescriptor userRouteMD = new RouteDescriptor("/users/{gtn:sitetype}/{gtn:sitename}{gtn:path}");
- userRouteMD.addRouteParam(QualifiedName.create("gtn", "controller"), "site");
- userRouteMD.addPathParam(QualifiedName.create("gtn", "path"), ".*", EncodingMode.PRESERVE_PATH);
- routerMD.addRoute(userRouteMD);
-
- //
- this.router = new Router(routerMD);
+ this.router = router().
+ add(route("/private/{gtn:sitetype}/{gtn:sitename}{gtn:path}").
+ add(routeParam("gtn:controller").withValue("site")).
+ add(routeParam("gtn:controller").withValue("site")).
+ add(requestParam("gtn:componentid").withName("portal:componentId")).
+ add(pathParam("gtn:path").withPattern(".*").preservingPath())).
+ add(route("/private/{gtn:sitetype}/{gtn:sitename}{gtn:path}").
+ add(routeParam("gtn:controller").withValue("site")).
+ add(pathParam("gtn:path").withPattern(".*").preservingPath())).
+ add(route("/groups/{gtn:sitetype}/{gtn:sitename}{gtn:path}").
+ add(routeParam("gtn:controller").withValue("site")).
+ add(pathParam("gtn:path").withPattern(".*").preservingPath())).
+ add(route("/users/{gtn:sitetype}/{gtn:sitename}{gtn:path}").
+ add(routeParam("gtn:controller").withValue("site")).
+ add(pathParam("gtn:path").withPattern(".*").preservingPath())).
+ build();
}
public void testComponent() throws Exception
Modified: portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestRender.java
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestRender.java 2010-11-29 21:08:43 UTC (rev 5358)
+++ portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestRender.java 2010-11-29 22:35:18 UTC (rev 5359)
@@ -20,8 +20,7 @@
package org.exoplatform.web.controller.router;
import org.exoplatform.web.controller.QualifiedName;
-import org.exoplatform.web.controller.metadata.RouteDescriptor;
-import org.exoplatform.web.controller.metadata.RouterDescriptor;
+import static org.exoplatform.web.controller.metadata.DescriptorBuilder.*;
import java.util.Collections;
@@ -34,9 +33,7 @@
public void testRoot() throws Exception
{
- RouterDescriptor routerMD = new RouterDescriptor();
- routerMD.addRoute(new RouteDescriptor("/"));
- Router router = new Router(routerMD);
+ Router router = router().add(route("/")).build();
//
assertEquals("/", router.render(Collections.<QualifiedName, String>emptyMap()));
@@ -44,9 +41,7 @@
public void testA() throws Exception
{
- RouterDescriptor routerMD = new RouterDescriptor();
- routerMD.addRoute(new RouteDescriptor("/a"));
- Router router = new Router(routerMD);
+ Router router = router().add(route("/a")).build();
//
assertEquals("/a", router.render(Collections.<QualifiedName, String>emptyMap()));
@@ -54,9 +49,7 @@
public void testAB() throws Exception
{
- RouterDescriptor routerMD = new RouterDescriptor();
- routerMD.addRoute(new RouteDescriptor("/a/b"));
- Router router = new Router( routerMD);
+ Router router = router().add(route("/a/b")).build();
//
assertEquals("/a/b", router.render(Collections.<QualifiedName, String>emptyMap()));
@@ -64,9 +57,7 @@
public void testPathParam() throws Exception
{
- RouterDescriptor routerMD = new RouterDescriptor();
- routerMD.addRoute(new RouteDescriptor("/{p}"));
- Router router = new Router(routerMD);
+ Router router = router().add(route("/{p}")).build();
//
assertEquals("/a", router.render(Collections.singletonMap(QualifiedName.create("p"), "a")));
@@ -75,9 +66,7 @@
public void testSimplePatternPathParam() throws Exception
{
- RouterDescriptor routerMD = new RouterDescriptor();
- routerMD.addRoute(new RouteDescriptor("/{p}").addPathParam(QualifiedName.parse("p"), "a"));
- Router router = new Router(routerMD);
+ Router router = router().add(route("/{p}").add(pathParam("p").withPattern("a"))).build();
//
assertEquals("/a", router.render(Collections.singletonMap(QualifiedName.create("p"), "a")));
@@ -86,10 +75,11 @@
public void testPrecedence() throws Exception
{
- RouterDescriptor routerMD = new RouterDescriptor();
- routerMD.addRoute(new RouteDescriptor("/a"));
- routerMD.addRoute(new RouteDescriptor("/{p}/b").addPathParam(QualifiedName.parse("p"), "a"));
- Router router = new Router(routerMD);
+ Router router = router().
+ add(route("/a")).
+ add(route("/{p}/b").
+ add(pathParam("p").withPattern("a"))).
+ build();
//
assertEquals("/a", router.render(Collections.<QualifiedName, String>emptyMap()));
@@ -100,9 +90,10 @@
public void testLang() throws Exception
{
- RouterDescriptor routerMD = new RouterDescriptor();
- routerMD.addRoute(new RouteDescriptor("/{a}b").addPathParam(QualifiedName.parse("a"), "(([A-Za-z]{2})/)?", EncodingMode.PRESERVE_PATH));
- Router router = new Router(routerMD);
+ Router router = router().
+ add(route("/{a}b").
+ add(pathParam("a").withPattern("(([A-Za-z]{2})/)?").preservingPath())).
+ build();
//
assertEquals("/fr/b", router.render(Collections.singletonMap(QualifiedName.parse("a"), "fr/")));
Modified: portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestRequestParam.java
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestRequestParam.java 2010-11-29 21:08:43 UTC (rev 5358)
+++ portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestRequestParam.java 2010-11-29 22:35:18 UTC (rev 5359)
@@ -20,8 +20,7 @@
package org.exoplatform.web.controller.router;
import org.exoplatform.web.controller.QualifiedName;
-import org.exoplatform.web.controller.metadata.RouteDescriptor;
-import org.exoplatform.web.controller.metadata.RouterDescriptor;
+import static org.exoplatform.web.controller.metadata.DescriptorBuilder.*;
import java.util.Collections;
import java.util.HashMap;
@@ -36,9 +35,7 @@
public void testRoot() throws Exception
{
- RouterDescriptor descriptor = new RouterDescriptor();
- descriptor.addRoute(new RouteDescriptor("/").addRequestParam(QualifiedName.parse("foo"), "a", "a", true));
- Router router = new Router(descriptor);
+ Router router = router().add(route("/").add(requestParam("foo").withName("a").withValue("a").required())).build();
//
assertNull(router.route("/"));
@@ -54,9 +51,7 @@
public void testSegment() throws Exception
{
- RouterDescriptor descriptor = new RouterDescriptor();
- descriptor.addRoute(new RouteDescriptor("/a").addRequestParam(QualifiedName.parse("foo"), "a", "a", true));
- Router router = new Router(descriptor);
+ Router router = router().add(route("/a").add(requestParam("foo").withName("a").withValue("a").required())).build();
//
assertNull(router.route("/a"));
@@ -72,9 +67,7 @@
public void testValuePattern() throws Exception
{
- RouterDescriptor descriptor = new RouterDescriptor();
- descriptor.addRoute(new RouteDescriptor("/a").addRequestParam(QualifiedName.parse("foo"), "a", "{[0-9]+}", true));
- Router router = new Router(descriptor);
+ Router router = router().add(route("/a").add(requestParam("foo").withName("a").withValue("{[0-9]+}").required())).build();
//
assertNull(router.route("/a"));
@@ -92,10 +85,10 @@
public void testPrecedence() throws Exception
{
- RouterDescriptor descriptor = new RouterDescriptor();
- descriptor.addRoute(new RouteDescriptor("/a").addRequestParam(QualifiedName.parse("foo"), "a", "a", true));
- descriptor.addRoute(new RouteDescriptor("/a").addRequestParam(QualifiedName.parse("bar"), "b", "b", true));
- Router router = new Router(descriptor);
+ Router router = router().
+ add(route("/a").add(requestParam("foo").withName("a").withValue("a").required())).
+ add(route("/a").add(requestParam("bar").withName("b").withValue("b").required())).
+ build();
//
assertNull(router.route("/a"));
@@ -116,9 +109,11 @@
public void testInheritance() throws Exception
{
- RouterDescriptor descriptor = new RouterDescriptor();
- descriptor.addRoute(new RouteDescriptor("/a").addRequestParam(QualifiedName.parse("foo"), "a", "a", true).addRoute(new RouteDescriptor("/b").addRequestParam(QualifiedName.parse("bar"), "b", "b", true)));
- Router router = new Router(descriptor);
+ Router router = router().add(route("/a").
+ add(requestParam("foo").withName("a").withValue("a").required()).
+ add(route("/b").
+ add(requestParam("bar").withName("b").withValue("b").required()))).
+ build();
//
assertNull(router.route("/a"));
@@ -149,9 +144,8 @@
public void testOptional() throws Exception
{
- RouterDescriptor descriptor = new RouterDescriptor();
- descriptor.addRoute(new RouteDescriptor("/").addRequestParam(QualifiedName.parse("foo"), "a", "a", false));
- Router router = new Router(descriptor);
+ Router router = router().add(route("/").
+ add(requestParam("foo").withName("a").withValue("a"))).build();
//
assertEquals(Collections.<QualifiedName, String>emptyMap(), router.route("/", Collections.<String, String[]>emptyMap()));
@@ -170,14 +164,12 @@
public void testMatchDescendantOfRootParameters() throws Exception
{
- RouterDescriptor descriptor = new RouterDescriptor();
- descriptor.
- addRoute(new RouteDescriptor("/").
- addRequestParam(QualifiedName.parse("foo"), "a", "a", false).
- addRoute(new RouteDescriptor("/a").
- addRequestParam(QualifiedName.parse("bar"), "b", "b", false))
- );
- Router router = new Router(descriptor);
+ Router router = router().
+ add(route("/").
+ add(requestParam("foo").withName("a").withValue("a")).
+ add(route("/a").
+ add(requestParam("bar").withName("b").withValue("b")))
+ ).build();
//
SimpleRenderContext renderContext = new SimpleRenderContext();
14 years
gatein SVN: r5358 - in portal/branches/navcontroller/component/web/controller/src: main/java/org/exoplatform/web/controller/router and 1 other directories.
by do-not-reply@jboss.org
Author: julien_viet
Date: 2010-11-29 16:08:43 -0500 (Mon, 29 Nov 2010)
New Revision: 5358
Added:
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/RE.java
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/regexp/TestRE.java
Modified:
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/RegExpParser.java
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/PatternBuilder.java
Log:
class for handling RegExp related static methods
Added: portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/RE.java
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/RE.java (rev 0)
+++ portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/RE.java 2010-11-29 21:08:43 UTC (rev 5358)
@@ -0,0 +1,147 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller.regexp;
+
+import org.gatein.common.io.UndeclaredIOException;
+
+import java.io.IOException;
+
+/**
+ * Various utilities related to the regular expression package.
+ *
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class RE
+{
+
+ private RE()
+ {
+ }
+
+ /**
+ * Appends a char sequence to an appendable. Chars are appended as is unless they are regular expression meta
+ * characters. Meta characters are escaped by appending a <i>\</i> character before the actual character.
+ *
+ * @param appendable the appendable
+ * @param s the char sequence
+ * @param start the start offset
+ * @param end the end offset
+ * @throws UndeclaredIOException any io exception
+ * @throws IndexOutOfBoundsException when index go out of bounds
+ * @return the appendable argument
+ * @param <A> the appendable parameter type
+ */
+ public static <A extends Appendable> A appendLiteral(A appendable, CharSequence s, int start, int end) throws UndeclaredIOException, IndexOutOfBoundsException
+ {
+ if (appendable == null)
+ {
+ throw new NullPointerException("No null appendable argument");
+ }
+ if (s == null)
+ {
+ throw new NullPointerException("No null char sequence argument");
+ }
+ try
+ {
+ while (start < end)
+ {
+ char c = s.charAt(start++);
+ if (isMeta(c))
+ {
+ appendable.append('\\');
+ }
+ appendable.append(c);
+ }
+ }
+ catch (IOException e)
+ {
+ throw new UndeclaredIOException(e);
+ }
+ return appendable;
+ }
+
+ /**
+ * @see #appendLiteral(Appendable, CharSequence, int, int)
+ * @param appendable the appendable
+ * @param s the char sequence
+ * @throws UndeclaredIOException any io exception
+ * @throws IndexOutOfBoundsException when index go out of bounds
+ * @return the appendable argument
+ * @param <A> the appendable parameter type
+ */
+ public static <A extends Appendable> A appendLiteral(A appendable, CharSequence s) throws UndeclaredIOException, IndexOutOfBoundsException
+ {
+ if (s == null)
+ {
+ throw new NullPointerException("No null char sequence argument");
+ }
+ return appendLiteral(appendable, s, 0, s.length());
+ }
+
+ /**
+ * @see #appendLiteral(Appendable, CharSequence, int, int)
+ * @param appendable the appendable
+ * @param c the char to append
+ * @throws UndeclaredIOException any io exception
+ * @throws IndexOutOfBoundsException when index go out of bounds
+ * @return the appendable argument
+ * @param <A> the appendable parameter type
+ */
+ public static <A extends Appendable> A appendLiteral(A appendable, char c) throws UndeclaredIOException
+ {
+ if (appendable == null)
+ {
+ throw new NullPointerException("No null appendable argument");
+ }
+ try
+ {
+ if (isMeta(c))
+ {
+ appendable.append('\\');
+ }
+ appendable.append(c);
+ }
+ catch (IOException e)
+ {
+ throw new UndeclaredIOException(e);
+ }
+ return appendable;
+ }
+
+ /**
+ * Returns a regular expression meta character.
+ *
+ * @param c the char to test
+ * @return true for a meta character, false otherwise
+ */
+ public static boolean isMeta(char c)
+ {
+ return c >= '(' && c <= '+' // ()*+
+ || c == '?'
+ || c == '{'
+ || c == '|'
+ || c == '$'
+ || c == '^'
+ || c == '.'
+ || c == '['
+ || c == '\\';
+ }
+}
Modified: portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/RegExpParser.java
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/RegExpParser.java 2010-11-29 19:02:26 UTC (rev 5357)
+++ portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/RegExpParser.java 2010-11-29 21:08:43 UTC (rev 5358)
@@ -19,8 +19,6 @@
package org.exoplatform.web.controller.regexp;
-import java.util.HashSet;
-import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -32,17 +30,6 @@
{
/** . */
- private static final Set<Character> ESCAPABLE = new HashSet<Character>();
-
- static
- {
- for (char c : "^.[$()|*+?{\\".toCharArray())
- {
- ESCAPABLE.add(c);
- }
- }
-
- /** . */
private static final Pattern pattern = Pattern.compile("^([0-9]+)" + "(?:" + "(,)([0-9]+)?" + ")?$");
/** . */
@@ -210,7 +197,7 @@
{
index++;
char escaped = s.charAt(index);
- if (!ESCAPABLE.contains(escaped))
+ if (!RE.isMeta(escaped))
{
throw new SyntaxException();
}
@@ -396,7 +383,7 @@
}
else
{
- throw new UnsupportedOperationException();
+ throw new UnsupportedOperationException("not yet implemented");
}
}
}
Modified: portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/PatternBuilder.java
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/PatternBuilder.java 2010-11-29 19:02:26 UTC (rev 5357)
+++ portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/PatternBuilder.java 2010-11-29 21:08:43 UTC (rev 5358)
@@ -19,6 +19,8 @@
package org.exoplatform.web.controller.router;
+import org.exoplatform.web.controller.regexp.RE;
+
import java.util.regex.Pattern;
/**
@@ -63,7 +65,7 @@
}
if (from < to)
{
- buffer.append(Pattern.quote(s.substring(from, to)));
+ RE.appendLiteral(buffer, s, from, to);
}
return this;
}
Added: portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/regexp/TestRE.java
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/regexp/TestRE.java (rev 0)
+++ portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/regexp/TestRE.java 2010-11-29 21:08:43 UTC (rev 5358)
@@ -0,0 +1,159 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller.regexp;
+
+import org.exoplatform.component.test.BaseGateInTest;
+import org.gatein.common.io.UndeclaredIOException;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.io.Writer;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class TestRE extends BaseGateInTest
+{
+
+ public void testAppendLiteral1()
+ {
+ StringBuilder sb = new StringBuilder();
+ assertSame(sb, RE.appendLiteral(sb, "a\\b"));
+ assertEquals("a\\\\b", sb.toString());
+ }
+
+ public void testAppendLiteral2()
+ {
+ StringBuilder sb = new StringBuilder();
+ assertSame(sb, RE.appendLiteral(sb, "a\\b", 0, 2));
+ assertEquals("a\\\\", sb.toString());
+ }
+
+ public void testAppendLiteral3()
+ {
+ StringBuilder sb = new StringBuilder();
+ assertSame(sb, RE.appendLiteral(sb, 'a'));
+ assertSame(sb, RE.appendLiteral(sb, '\\'));
+ assertEquals("a\\\\", sb.toString());
+ }
+
+ public void testAppendLiteralThrowsIOOBE()
+ {
+ try
+ {
+ RE.appendLiteral(new StringBuilder(), "a\\b", -1, 2);
+ fail();
+ }
+ catch (IndexOutOfBoundsException expected)
+ {
+ }
+ try
+ {
+ RE.appendLiteral(new StringBuilder(), "a\\b", 1, 4);
+ fail();
+ }
+ catch (IndexOutOfBoundsException expected)
+ {
+ }
+ }
+
+ public void testAppendLiteralThrowsNPE()
+ {
+ try
+ {
+ RE.appendLiteral(null, "a", 0, 1);
+ fail();
+ }
+ catch (NullPointerException expected)
+ {
+ }
+ try
+ {
+ RE.appendLiteral(new StringBuilder(), null, 0, 1);
+ fail();
+ }
+ catch (NullPointerException expected)
+ {
+ }
+ try
+ {
+ RE.appendLiteral(null, "a");
+ fail();
+ }
+ catch (NullPointerException expected)
+ {
+ }
+ try
+ {
+ RE.appendLiteral(new StringBuilder(), null);
+ fail();
+ }
+ catch (NullPointerException expected)
+ {
+ }
+ try
+ {
+ RE.appendLiteral(null, 'a');
+ fail();
+ }
+ catch (NullPointerException expected)
+ {
+ }
+ }
+
+ public void testAppendLiteralThrowsIOE()
+ {
+ final IOException e = new IOException();
+ Writer appendable = new Writer()
+ {
+ public void write(char[] cbuf, int off, int len) throws IOException { throw e; }
+ public void flush() throws IOException { }
+ public void close() throws IOException { }
+ };
+ try
+ {
+ RE.appendLiteral(appendable, "a", 0, 1);
+ fail();
+ }
+ catch (UndeclaredIOException expected)
+ {
+ assertSame(e, expected.getCause());
+ }
+ try
+ {
+ RE.appendLiteral(appendable, "a");
+ fail();
+ }
+ catch (UndeclaredIOException expected)
+ {
+ assertSame(e, expected.getCause());
+ }
+ try
+ {
+ RE.appendLiteral(appendable, 'a');
+ fail();
+ }
+ catch (UndeclaredIOException expected)
+ {
+ assertSame(e, expected.getCause());
+ }
+ }
+}
14 years
gatein SVN: r5357 - in portal/branches/navcontroller: component/web/controller/src/main/java/org/exoplatform/web/controller/metadata and 2 other directories.
by do-not-reply@jboss.org
Author: julien_viet
Date: 2010-11-29 14:02:26 -0500 (Mon, 29 Nov 2010)
New Revision: 5357
Modified:
portal/branches/navcontroller/component/web/controller/src/main/java/gatein_router_1_0.xsd
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/DescriptorBuilder.java
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/router.xml
portal/branches/navcontroller/web/portal/src/main/webapp/WEB-INF/conf/default-router.xml
portal/branches/navcontroller/web/portal/src/main/webapp/WEB-INF/conf/proto-router-1.xml
Log:
more convenient name in XML schema
Modified: portal/branches/navcontroller/component/web/controller/src/main/java/gatein_router_1_0.xsd
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/main/java/gatein_router_1_0.xsd 2010-11-29 16:47:37 UTC (rev 5356)
+++ portal/branches/navcontroller/component/web/controller/src/main/java/gatein_router_1_0.xsd 2010-11-29 19:02:26 UTC (rev 5357)
@@ -49,12 +49,12 @@
</xs:complexType>
<xs:complexType name="routeParamType">
- <xs:attribute name="name" type="xs:string" use="required"/>
+ <xs:attribute name="qname" type="xs:string" use="required"/>
<xs:attribute name="value" type="xs:string" use="required"/>
</xs:complexType>
<xs:complexType name="pathParamType">
- <xs:attribute name="name" type="xs:string" use="required"/>
+ <xs:attribute name="qname" type="xs:string" use="required"/>
<xs:attribute name="pattern" type="xs:string" use="optional"/>
<xs:attribute name="encoding" use="optional">
<xs:simpleType>
@@ -67,9 +67,9 @@
</xs:complexType>
<xs:complexType name="requestParamType">
+ <xs:attribute name="qname" type="xs:string" use="required"/>
<xs:attribute name="name" type="xs:string" use="required"/>
- <xs:attribute name="matchName" type="xs:string" use="required"/>
- <xs:attribute name="matchValue" type="xs:string" use="optional"/>
+ <xs:attribute name="value" type="xs:string" use="optional"/>
<xs:attribute name="required" type="xs:boolean" use="optional"/>
</xs:complexType>
Modified: portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/DescriptorBuilder.java
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/DescriptorBuilder.java 2010-11-29 16:47:37 UTC (rev 5356)
+++ portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/DescriptorBuilder.java 2010-11-29 19:02:26 UTC (rev 5357)
@@ -93,21 +93,21 @@
{
if (paramQN.equals(reader.getName()))
{
- String name = reader.getAttributeValue(null, "name");
+ String name = reader.getAttributeValue(null, "qname");
String value = reader.getAttributeValue(null, "value");
routeDesc.addRouteParam(QualifiedName.parse(name), value);
}
else if (requestParamQN.equals(reader.getName()))
{
- String name = reader.getAttributeValue(null, "name");
- String matchName = reader.getAttributeValue(null, "matchName");
- String matchValue = reader.getAttributeValue(null, "matchValue");
+ String name = reader.getAttributeValue(null, "qname");
+ String matchName = reader.getAttributeValue(null, "name");
+ String matchValue = reader.getAttributeValue(null, "value");
String optional = reader.getAttributeValue(null, "required");
routeDesc.addRequestParam(QualifiedName.parse(name), matchName, matchValue, "true".equals(optional));
}
else if (pathParamQN.equals(reader.getName()))
{
- String name = reader.getAttributeValue(null, "name");
+ String name = reader.getAttributeValue(null, "qname");
String pattern = reader.getAttributeValue(null, "pattern");
String encoded = reader.getAttributeValue(null, "encoding");
EncodingMode encodingMode = "preserve-path".equals(encoded) ? EncodingMode.PRESERVE_PATH : EncodingMode.FORM;
Modified: portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/router.xml
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/router.xml 2010-11-29 16:47:37 UTC (rev 5356)
+++ portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/router.xml 2010-11-29 19:02:26 UTC (rev 5357)
@@ -4,34 +4,34 @@
xmlns="http://www.gatein.org/xml/ns/gatein_router_1_0">
<route path="/public/{gtn:sitetype}/{gtn:sitename}{gtn:path}">
- <route-param name="gtn:handler" value="portal"/>
- <path-param name="gtn:path" pattern=".*"/>
+ <route-param qname="gtn:handler" value="portal"/>
+ <path-param qname="gtn:path" pattern=".*"/>
</route>
<route path="/private/{gtn:sitetype}/{gtn:sitename}{gtn:path}">
- <route-param name="gtn:handler" value="portal"/>
- <path-param name="gtn:path" pattern=".*" encoding="preserve-path"/>
+ <route-param qname="gtn:handler" value="portal"/>
+ <path-param qname="gtn:path" pattern=".*" encoding="preserve-path"/>
</route>
<route path="/upload">
- <route-param name="gtn:handler" value="upload"/>
+ <route-param qname="gtn:handler" value="upload"/>
</route>
<route path="/download">
- <route-param name="gtn:handler" value="download"/>
+ <route-param qname="gtn:handler" value="download"/>
</route>
<route path="/a">
- <route-param name="a" value="a_value"/>
+ <route-param qname="a" value="a_value"/>
<route path="/b">
- <route-param name="b" value="b_value"/>
+ <route-param qname="b" value="b_value"/>
</route>
</route>
<route path="/b">
- <request-param name="foo" matchName="foo"/>
- <request-param name="bar" matchName="bar" matchValue="bar"/>
- <request-param name="juu" matchName="juu" matchValue="juu" required="true"/>
+ <request-param qname="foo" name="foo"/>
+ <request-param qname="bar" name="bar" value="bar"/>
+ <request-param qname="juu" name="juu" value="juu" required="true"/>
</route>
</router>
\ No newline at end of file
Modified: portal/branches/navcontroller/web/portal/src/main/webapp/WEB-INF/conf/default-router.xml
===================================================================
--- portal/branches/navcontroller/web/portal/src/main/webapp/WEB-INF/conf/default-router.xml 2010-11-29 16:47:37 UTC (rev 5356)
+++ portal/branches/navcontroller/web/portal/src/main/webapp/WEB-INF/conf/default-router.xml 2010-11-29 19:02:26 UTC (rev 5357)
@@ -6,49 +6,49 @@
<route path="/">
<!-- Use the portal handler -->
- <route-param name="gtn:handler" value="portal"/>
+ <route-param qname="gtn:handler" value="portal"/>
<!-- Webui parameters -->
- <request-param name="gtn:componentid" matchName="portal:componentId" required="false"/>
- <request-param name="gtn:action" matchName="portal:action" required="false"/>
- <request-param name="gtn:objectid" matchName="objectId" required="false"/>
+ <request-param qname="gtn:componentid" name="portal:componentId" required="false"/>
+ <request-param qname="gtn:action" name="portal:action" required="false"/>
+ <request-param qname="gtn:objectid" name="objectId" required="false"/>
<!-- The public access -->
<route path="/public/{gtn:sitename}{gtn:path}">
- <route-param name="gtn:access" value="public"/>
- <route-param name="gtn:sitetype" value="portal"/>
- <path-param name="gtn:path" pattern=".*" encoding="preserve-path"/>
+ <route-param qname="gtn:access" value="public"/>
+ <route-param qname="gtn:sitetype" value="portal"/>
+ <path-param qname="gtn:path" pattern=".*" encoding="preserve-path"/>
</route>
<!-- The private access -->
<route path="/private/{gtn:sitename}{gtn:path}">
- <route-param name="gtn:access" value="private"/>
- <route-param name="gtn:sitetype" value="portal"/>
- <path-param name="gtn:path" pattern=".*" encoding="preserve-path"/>
+ <route-param qname="gtn:access" value="private"/>
+ <route-param qname="gtn:sitetype" value="portal"/>
+ <path-param qname="gtn:path" pattern=".*" encoding="preserve-path"/>
</route>
<!-- The group access -->
<route path="/groups/{gtn:sitename}{gtn:path}">
- <route-param name="gtn:access" value="private"/>
- <route-param name="gtn:sitetype" value="group"/>
- <path-param name="gtn:path" pattern=".*" encoding="preserve-path"/>
+ <route-param qname="gtn:access" value="private"/>
+ <route-param qname="gtn:sitetype" value="group"/>
+ <path-param qname="gtn:path" pattern=".*" encoding="preserve-path"/>
</route>
<!-- The user access -->
<route path="/users/{gtn:sitename}{gtn:path}">
- <route-param name="gtn:access" value="private"/>
- <route-param name="gtn:sitetype" value="user"/>
- <path-param name="gtn:path" pattern=".*" encoding="preserve-path"/>
+ <route-param qname="gtn:access" value="private"/>
+ <route-param qname="gtn:sitetype" value="user"/>
+ <path-param qname="gtn:path" pattern=".*" encoding="preserve-path"/>
</route>
</route>
<route path="/upload">
- <route-param name="gtn:handler" value="upload"/>
+ <route-param qname="gtn:handler" value="upload"/>
</route>
<route path="/download">
- <route-param name="gtn:handler" value="download"/>
+ <route-param qname="gtn:handler" value="download"/>
</route>
</router>
\ No newline at end of file
Modified: portal/branches/navcontroller/web/portal/src/main/webapp/WEB-INF/conf/proto-router-1.xml
===================================================================
--- portal/branches/navcontroller/web/portal/src/main/webapp/WEB-INF/conf/proto-router-1.xml 2010-11-29 16:47:37 UTC (rev 5356)
+++ portal/branches/navcontroller/web/portal/src/main/webapp/WEB-INF/conf/proto-router-1.xml 2010-11-29 19:02:26 UTC (rev 5357)
@@ -8,33 +8,33 @@
<route path="/">
<!-- Use the portal handler -->
- <route-param name="gtn:handler" value="portal"/>
+ <route-param qname="gtn:handler" value="portal"/>
<!-- Webui parameters -->
- <request-param name="gtn:componentid" matchName="portal:componentId" required="false"/>
- <request-param name="gtn:action" matchName="portal:action" required="false"/>
- <request-param name="gtn:objectid" matchName="objectId" required="false"/>
+ <request-param qname="gtn:componentid" name="portal:componentId" required="false"/>
+ <request-param qname="gtn:action" name="portal:action" required="false"/>
+ <request-param qname="gtn:objectid" name="objectId" required="false"/>
<!-- The public access -->
<route path="/public/{gtn:sitename}{gtn:path}.html">
- <route-param name="gtn:access" value="public"/>
- <path-param name="gtn:path" pattern=".*" encoding="preserve-path"/>
+ <route-param qname="gtn:access" value="public"/>
+ <path-param qname="gtn:path" pattern=".*" encoding="preserve-path"/>
</route>
<!-- The private access -->
<route path="/private/{gtn:sitename}{gtn:path}.html">
- <route-param name="gtn:access" value="private"/>
- <path-param name="gtn:path" pattern=".*" encoding="preserve-path"/>
+ <route-param qname="gtn:access" value="private"/>
+ <path-param qname="gtn:path" pattern=".*" encoding="preserve-path"/>
</route>
</route>
<route path="/upload">
- <route-param name="gtn:handler" value="upload"/>
+ <route-param qname="gtn:handler" value="upload"/>
</route>
<route path="/download">
- <route-param name="gtn:handler" value="download"/>
+ <route-param qname="gtn:handler" value="download"/>
</route>
</router>
\ No newline at end of file
14 years
gatein SVN: r5356 - in portal/branches/wci: component/application-registry/src/main/java/org/exoplatform/application/gadget and 43 other directories.
by do-not-reply@jboss.org
Author: alain_defrance
Date: 2010-11-29 11:47:37 -0500 (Mon, 29 Nov 2010)
New Revision: 5356
Added:
portal/branches/wci/component/application-registry/src/main/java/org/exoplatform/application/gadget/GadgetImporter.java
portal/branches/wci/component/application-registry/src/main/java/org/exoplatform/application/gadget/RemoteImporter.java
portal/branches/wci/component/identity/src/main/java/org/exoplatform/services/organization/idm/Tools.java
portal/branches/wci/component/portal/src/main/java/org/exoplatform/portal/pom/config/cache/PortalNamesCache.java
portal/branches/wci/component/portal/src/test/java/org/exoplatform/portal/config/TestConcurrencyDataStorage.java
portal/branches/wci/component/web/security/src/main/java/org/exoplatform/web/security/security/AbstractCodec.java
portal/branches/wci/component/web/security/src/main/java/org/exoplatform/web/security/security/ToThrowAwayCodec.java
portal/branches/wci/docs/reference-guide/en/modules/PortalDevelopment/LocalizationConfiguration.xml
Removed:
portal/branches/wci/component/application-registry/src/main/java/org/exoplatform/application/gadget/LocalImporter.java
Modified:
portal/branches/wci/component/application-registry/src/main/java/org/exoplatform/application/gadget/GadgetDeployer.java
portal/branches/wci/component/application-registry/src/main/java/org/exoplatform/application/gadget/GadgetRegistryService.java
portal/branches/wci/component/application-registry/src/main/java/org/exoplatform/application/gadget/ServletLocalImporter.java
portal/branches/wci/component/application-registry/src/main/java/org/exoplatform/application/gadget/impl/GadgetRegistryServiceImpl.java
portal/branches/wci/component/identity/src/main/java/org/exoplatform/services/organization/idm/GroupDAOImpl.java
portal/branches/wci/component/identity/src/main/java/org/exoplatform/services/organization/idm/IDMUserListAccess.java
portal/branches/wci/component/identity/src/main/java/org/exoplatform/services/organization/idm/IntegrationCache.java
portal/branches/wci/component/identity/src/main/java/org/exoplatform/services/organization/idm/MembershipDAOImpl.java
portal/branches/wci/component/identity/src/main/java/org/exoplatform/services/organization/idm/MembershipImpl.java
portal/branches/wci/component/identity/src/main/java/org/exoplatform/services/organization/idm/MembershipTypeDAOImpl.java
portal/branches/wci/component/identity/src/main/java/org/exoplatform/services/organization/idm/UserDAOImpl.java
portal/branches/wci/component/portal/src/main/java/org/exoplatform/portal/config/model/Page.java
portal/branches/wci/component/portal/src/main/java/org/exoplatform/portal/config/model/PortalConfig.java
portal/branches/wci/component/portal/src/main/java/org/exoplatform/portal/pom/config/GlobalKey.java
portal/branches/wci/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSession.java
portal/branches/wci/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSessionManager.java
portal/branches/wci/component/portal/src/test/java/org/exoplatform/portal/config/TestCache.java
portal/branches/wci/component/portal/src/test/java/org/exoplatform/portal/config/TestDataStorage.java
portal/branches/wci/component/scripting/src/main/java/org/exoplatform/groovyscript/GroovyTemplate.java
portal/branches/wci/component/web/controller/src/main/java/org/exoplatform/web/WebAppController.java
portal/branches/wci/component/web/resources/src/main/java/org/exoplatform/portal/application/Image.java
portal/branches/wci/component/web/resources/src/main/java/org/exoplatform/portal/application/ResourceRequestFilter.java
portal/branches/wci/component/web/resources/src/main/java/org/exoplatform/portal/resource/CachedStylesheet.java
portal/branches/wci/component/web/resources/src/main/java/org/exoplatform/portal/resource/SkinService.java
portal/branches/wci/component/web/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptConfigService.java
portal/branches/wci/component/web/security/src/main/java/org/exoplatform/web/security/security/CookieTokenService.java
portal/branches/wci/component/web/security/src/main/java/org/exoplatform/web/security/security/TokenContainer.java
portal/branches/wci/component/web/server/src/main/java/org/exoplatform/upload/UploadService.java
portal/branches/wci/docs/reference-guide/en/modules/PortalDevelopment.xml
portal/branches/wci/examples/portal/war/src/main/webapp/WEB-INF/web.xml
portal/branches/wci/gadgets/core/src/main/java/org/exoplatform/portal/gadget/core/ProxyServletFilter.java
portal/branches/wci/gadgets/eXoGadgets/src/main/webapp/gadgets/rssAggregator/script.js
portal/branches/wci/packaging/tomcat/integration/
portal/branches/wci/pom.xml
portal/branches/wci/portlet/dashboard/src/main/java/org/exoplatform/gadget/webui/component/UIGadgetPortlet.java
portal/branches/wci/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/UIUserToolBarGroupPortlet.java
portal/branches/wci/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/UIUserToolBarSitePortlet.java
portal/branches/wci/portlet/exoadmin/src/main/webapp/groovy/applicationregistry/webui/component/UIGadgetInfo.gtmpl
portal/branches/wci/portlet/exoadmin/src/main/webapp/skin/organization/webui/component/UIOrganizationPortlet/DefaultStylesheet.css
portal/branches/wci/portlet/web/src/main/webapp/groovy/portal/webui/component/UIPortalNavigation.gtmpl
portal/branches/wci/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/NewSnifftest/Test_SNF_PRL_37_ManageNavigationOfGroup.html
portal/branches/wci/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/NewSnifftest/Test_SNF_PRL_49_ChangeApplicationWhenEditPagePropertiesOfNode.html
portal/branches/wci/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_PRL_03_01_001_CheckShowingGroupManagementForm.html
portal/branches/wci/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_PRL_03_05_012_AddSomeUsersIntoGroupInCaseAfterCommaHasSpace.html
portal/branches/wci/testsuite/testdefinitions/GateIn_v3.2.x_MainFunctions_TestDefinition.ods
portal/branches/wci/web/eXoResources/src/main/webapp/skin/DefaultSkin/portal/webui/component/customization/UIPageBrowser/Stylesheet.css
portal/branches/wci/web/portal/src/main/webapp/WEB-INF/conf/organization/picketlink-idm/jboss-cache-cluster.xml
portal/branches/wci/web/portal/src/main/webapp/WEB-INF/web.xml
portal/branches/wci/web/portal/src/main/webapp/groovy/portal/webui/workspace/UIPortalApplication.gtmpl
portal/branches/wci/web/portal/src/main/webapp/index.jsp
portal/branches/wci/web/rest/src/main/webapp/WEB-INF/web.xml
portal/branches/wci/webui/eXo/src/main/java/org/exoplatform/webui/organization/account/UIUserSelector.java
portal/branches/wci/webui/framework/src/main/java/org/exoplatform/webui/core/UIComponentDecorator.java
portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/application/localization/LocalizationFilter.java
portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletActionListener.java
portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/container/UIContainerActionListener.java
portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/container/UIContainerForm.java
portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/javascript/JavascriptServlet.java
portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/PageNavigationUtils.java
portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UINavigationNodeSelector.java
portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UIPortalNavigation.java
portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageActionListener.java
portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageBrowser.java
portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageForm.java
portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIMaskWorkspace.java
portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIPortalApplicationLifecycle.java
portal/branches/wci/webui/portlet/src/main/java/org/exoplatform/webui/application/portlet/PortletApplicationController.java
Log:
merged from trunk 5342
Modified: portal/branches/wci/component/application-registry/src/main/java/org/exoplatform/application/gadget/GadgetDeployer.java
===================================================================
--- portal/branches/wci/component/application-registry/src/main/java/org/exoplatform/application/gadget/GadgetDeployer.java 2010-11-29 15:35:58 UTC (rev 5355)
+++ portal/branches/wci/component/application-registry/src/main/java/org/exoplatform/application/gadget/GadgetDeployer.java 2010-11-29 16:47:37 UTC (rev 5356)
@@ -19,8 +19,6 @@
package org.exoplatform.application.gadget;
import org.exoplatform.application.gadget.impl.GadgetRegistryServiceImpl;
-import org.exoplatform.commons.chromattic.ChromatticLifeCycle;
-import org.exoplatform.commons.chromattic.SessionContext;
import org.exoplatform.commons.xml.DocumentSource;
import org.exoplatform.commons.xml.XMLValidator;
import org.exoplatform.container.ExoContainerContext;
@@ -40,11 +38,10 @@
import org.w3c.dom.NodeList;
import javax.servlet.ServletContext;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
/**
* @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
@@ -115,28 +112,27 @@
private void handle(ServletContext scontext, URL gadgetsURL)
{
- ChromatticLifeCycle lifeCycle = gadgetRegistryService.getChromatticLifeCycle();
- lifeCycle.openContext();
try
{
+ List<GadgetImporter> importers = new ArrayList<GadgetImporter>();
Document docXML = validator.validate(DocumentSource.create(gadgetsURL));
NodeList nodeList = docXML.getElementsByTagName("gadget");
for (int i = 0; i < nodeList.getLength(); i++)
{
Element gadgetElement = (Element)nodeList.item(i);
String gadgetName = gadgetElement.getAttribute("name");
- log.debug("About to import gadget " + gadgetName);
+
+ //
+ log.debug("About to parse gadget " + gadgetName);
Element pathElt = XMLTools.getUniqueChild(gadgetElement, "path", false);
+ GadgetImporter importer = null;
if (pathElt != null)
{
String path = XMLTools.asString(pathElt, true);
- ServletLocalImporter importer = new ServletLocalImporter(
+ importer = new ServletLocalImporter(
gadgetName,
- gadgetRegistryService.getRegistry(),
path,
- scontext,
- true);
- importer.doImport();
+ scontext);
}
else
{
@@ -144,24 +140,26 @@
if (urlElt != null)
{
String url = XMLTools.asString(urlElt, true);
- ServletLocalImporter importer = new ServletLocalImporter(
+ importer = new RemoteImporter(
gadgetName,
- gadgetRegistryService.getRegistry(),
- url,
- scontext,
- false);
- importer.doImport();
+ url);
}
}
+
+ //
+ if (importer != null)
+ {
+ importers.add(importer);
+ log.debug("Add gadget " + gadgetName + " to gadget imports");
+ }
}
+
+ // Import everything
+ gadgetRegistryService.deploy(importers);
}
catch (Exception e)
{
log.error("Could not process gadget file " + gadgetsURL, e);
}
- finally
- {
- lifeCycle.closeContext(true);
- }
}
}
Copied: portal/branches/wci/component/application-registry/src/main/java/org/exoplatform/application/gadget/GadgetImporter.java (from rev 5342, portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/GadgetImporter.java)
===================================================================
--- portal/branches/wci/component/application-registry/src/main/java/org/exoplatform/application/gadget/GadgetImporter.java (rev 0)
+++ portal/branches/wci/component/application-registry/src/main/java/org/exoplatform/application/gadget/GadgetImporter.java 2010-11-29 16:47:37 UTC (rev 5356)
@@ -0,0 +1,133 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.application.gadget;
+
+import org.apache.shindig.common.uri.Uri;
+import org.apache.shindig.gadgets.spec.GadgetSpec;
+import org.apache.shindig.gadgets.spec.ModulePrefs;
+import org.exoplatform.application.gadget.impl.GadgetDefinition;
+import org.gatein.common.logging.Logger;
+import org.gatein.common.logging.LoggerFactory;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public abstract class GadgetImporter
+{
+
+ /** . */
+ private static final Logger log = LoggerFactory.getLogger(GadgetImporter.class);
+
+ /** The gadget name as seen by GateIn. */
+ private String gadgetName;
+
+ /** The gadget uri. */
+ private String gadgetURI;
+
+ protected GadgetImporter(
+ String gadgetName,
+ String gadgetURI)
+ {
+ this.gadgetName = gadgetName;
+ this.gadgetURI = gadgetURI;
+ }
+
+ public String getGadgetName()
+ {
+ return gadgetName;
+ }
+
+ public String getGadgetURI()
+ {
+ return gadgetURI;
+ }
+
+ protected abstract byte[] getGadgetBytes(String gadgetURI) throws IOException;
+
+ protected abstract String getGadgetURL(String gadgetURI) throws Exception;
+
+ protected abstract void process(String gadgetURI, GadgetDefinition def) throws Exception;
+
+ private String getGadgetTitle(ModulePrefs prefs, String defaultValue)
+ {
+ String title = prefs.getDirectoryTitle();
+ if (title == null || title.trim().length() < 1)
+ {
+ title = prefs.getTitle();
+ }
+ if (title == null || title.trim().length() < 1)
+ {
+ return defaultValue;
+ }
+ return title;
+ }
+
+ public void doImport(GadgetDefinition def) throws Exception
+ {
+ // Get bytes
+ byte[] bytes = getGadgetBytes(gadgetURI);
+ if (bytes == null)
+ {
+ log.error("Cannot import gadget " + gadgetURI + " because its data could not be found");
+ return;
+ }
+
+ // Get encoding
+ String encoding = EncodingDetector.detect(new ByteArrayInputStream(bytes));
+
+ //
+ String gadget = new String(bytes, encoding);
+
+ //
+ String gadgetURL = getGadgetURL(gadgetURI);
+ GadgetSpec spec = new GadgetSpec(Uri.parse(gadgetURL), gadget);
+ ModulePrefs prefs = spec.getModulePrefs();
+
+
+ //
+ String description = prefs.getDescription();
+ String thumbnail = prefs.getThumbnail().toString();
+ String title = getGadgetTitle(prefs, gadgetName);
+ String referenceURL = prefs.getTitleUrl().toString();
+
+ //
+ log.info("Importing gadget name=" + gadgetName + " description=" + description + " thumbnail=" + thumbnail + " title=" +
+ thumbnail + " title=" + title);
+
+ //
+ def.setDescription(description);
+ def.setThumbnail(thumbnail); // Do something better than that
+ def.setTitle(title);
+ def.setReferenceURL(referenceURL);
+
+ //
+ process(gadgetURI, def);
+ }
+
+ @Override
+ public String toString()
+ {
+ return getClass().getSimpleName() + "[name=" + getGadgetName() + ",path=" + getGadgetURI() + "]";
+ }
+}
Modified: portal/branches/wci/component/application-registry/src/main/java/org/exoplatform/application/gadget/GadgetRegistryService.java
===================================================================
--- portal/branches/wci/component/application-registry/src/main/java/org/exoplatform/application/gadget/GadgetRegistryService.java 2010-11-29 15:35:58 UTC (rev 5355)
+++ portal/branches/wci/component/application-registry/src/main/java/org/exoplatform/application/gadget/GadgetRegistryService.java 2010-11-29 16:47:37 UTC (rev 5356)
@@ -33,6 +33,13 @@
{
/**
+ * Deploy a set of gadgets.
+ *
+ * @param gadgets the gadgets to deploy
+ */
+ public void deploy(Iterable<GadgetImporter> gadgets);
+
+ /**
* Return Gadget object retrieved from database by its name.
*
* @param name the name of gadget
Deleted: portal/branches/wci/component/application-registry/src/main/java/org/exoplatform/application/gadget/LocalImporter.java
===================================================================
--- portal/branches/wci/component/application-registry/src/main/java/org/exoplatform/application/gadget/LocalImporter.java 2010-11-29 15:35:58 UTC (rev 5355)
+++ portal/branches/wci/component/application-registry/src/main/java/org/exoplatform/application/gadget/LocalImporter.java 2010-11-29 16:47:37 UTC (rev 5356)
@@ -1,247 +0,0 @@
-/*
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.application.gadget;
-
-import org.apache.shindig.common.uri.Uri;
-import org.apache.shindig.gadgets.spec.GadgetSpec;
-import org.apache.shindig.gadgets.spec.ModulePrefs;
-import org.chromattic.ext.ntdef.NTFolder;
-import org.chromattic.ext.ntdef.Resource;
-import org.exoplatform.application.gadget.impl.GadgetDefinition;
-import org.exoplatform.application.gadget.impl.GadgetRegistry;
-import org.exoplatform.application.gadget.impl.LocalGadgetData;
-import org.exoplatform.application.gadget.impl.RemoteGadgetData;
-import org.gatein.common.logging.Logger;
-import org.gatein.common.logging.LoggerFactory;
-import org.gatein.common.net.URLTools;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.net.URL;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public abstract class LocalImporter
-{
-
- /** . */
- private static final Logger log = LoggerFactory.getLogger(LocalImporter.class);
-
- /** The gadget name as seen by GateIn. */
- private String name;
-
- /** The gadget registry. */
- private GadgetRegistry registry;
-
- /** The gadget path. */
- private String gadgetPath;
-
- /** . */
- private boolean local;
-
- /** Used temporarily when importing resources. */
- private NTFolder folder;
-
- protected LocalImporter(
- String name,
- GadgetRegistry registry,
- String gadgetPath,
- boolean local)
- {
- this.name = name;
- this.registry = registry;
- this.gadgetPath = gadgetPath;
- this.local = local;
- }
-
- private byte[] getGadgetBytes() throws IOException
- {
- if (local)
- {
- return getContent(gadgetPath);
- }
- else
- {
- URL url = new URL(gadgetPath);
- return URLTools.getContent(url, 5000, 5000);
- }
- }
-
- private String getGadgetURL() throws Exception
- {
- if (local)
- {
- return "http://www.gatein.org";
- }
- else
- {
- return gadgetPath;
- }
- }
-
- private String getGadgetTitle(ModulePrefs prefs, String defaultValue)
- {
- String title = prefs.getDirectoryTitle();
- if (title == null || title.trim().length() < 1)
- {
- title = prefs.getTitle();
- }
- if (title == null || title.trim().length() < 1)
- {
- return defaultValue;
- }
- return title;
- }
-
- public void doImport() throws Exception
- {
- if (registry.getGadget(name) != null)
- {
- log.debug("Will not import existing gagdet " + name);
- return;
- }
-
- // Get bytes
- byte[] bytes = getGadgetBytes();
- if (bytes == null)
- {
- log.error("Cannot import gadget " + gadgetPath + " because its data could not be found");
- return;
- }
-
- // Get encoding
- String encoding = EncodingDetector.detect(new ByteArrayInputStream(bytes));
-
- //
- String gadget = new String(bytes, encoding);
-
- //
- String gadgetURL = getGadgetURL();
- GadgetSpec spec = new GadgetSpec(Uri.parse(gadgetURL), gadget);
- ModulePrefs prefs = spec.getModulePrefs();
-
- //
- GadgetDefinition def = registry.addGadget(name);
-
- //
- String description = prefs.getDescription();
- String thumbnail = prefs.getThumbnail().toString();
- String title = getGadgetTitle(prefs, name);
- String referenceURL = prefs.getTitleUrl().toString();
-
- //
- log.info("Importing gadget name=" + name + " description=" + description + " thumbnail=" + thumbnail + " title=" +
- thumbnail + " title=" + title);
-
- //
- def.setDescription(description);
- def.setThumbnail(thumbnail); // Do something better than that
- def.setTitle(title);
- def.setReferenceURL(referenceURL);
- def.setLocal(local);
-
- //
- if (local)
- {
- LocalGadgetData data = (LocalGadgetData)def.getData();
-
- //
- String fileName = getName(gadgetPath);
- data.setFileName(fileName);
-
- // Import resource
- folder = data.getResources();
- String folderPath = getParent(gadgetPath);
- visitChildren(folderPath);
- folder = null;
- }
- else
- {
- RemoteGadgetData data = (RemoteGadgetData)def.getData();
-
- // Set remote URL
- data.setURL(gadgetPath);
- }
- }
-
- private void visit(String resourcePath) throws Exception
- {
- String name = getName(resourcePath);
- if (isFile(resourcePath))
- {
- byte[] content = getContent(resourcePath);
-
- //
- if (content != null)
- {
- String mimeType = getMimeType(name);
-
- //
- if (mimeType == null)
- {
- mimeType = "application/octet-stream";
- }
-
- // We can detect encoding for XML files
- String encoding = null;
- if ("application/xml".equals(mimeType))
- {
- encoding = EncodingDetector.detect(new ByteArrayInputStream(content));
- }
-
- // Correct mime type for gadgets
- if (resourcePath.equals(gadgetPath)) {
- mimeType = LocalGadgetData.GADGET_MIME_TYPE;
- }
-
- //
- folder.createFile(name, new Resource(mimeType, encoding, content));
- }
- }
- else
- {
- folder = folder.createFolder(name);
- visitChildren(resourcePath);
- folder = folder.getParent();
- }
- }
-
- private void visitChildren(String folderPath) throws Exception
- {
- for (String childPath : getChildren(folderPath))
- {
- visit(childPath);
- }
- }
-
- public abstract String getName(String resourcePath) throws IOException;
-
- public abstract String getParent(String resourcePath) throws IOException;
-
- public abstract byte[] getContent(String filePath) throws IOException;
-
- public abstract Iterable<String> getChildren(String folderPath) throws IOException;
-
- public abstract boolean isFile(String resourcePath) throws IOException;
-
- public abstract String getMimeType(String fileName);
-}
Copied: portal/branches/wci/component/application-registry/src/main/java/org/exoplatform/application/gadget/RemoteImporter.java (from rev 5342, portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/RemoteImporter.java)
===================================================================
--- portal/branches/wci/component/application-registry/src/main/java/org/exoplatform/application/gadget/RemoteImporter.java (rev 0)
+++ portal/branches/wci/component/application-registry/src/main/java/org/exoplatform/application/gadget/RemoteImporter.java 2010-11-29 16:47:37 UTC (rev 5356)
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.application.gadget;
+
+import org.exoplatform.application.gadget.impl.GadgetDefinition;
+import org.exoplatform.application.gadget.impl.RemoteGadgetData;
+import org.gatein.common.net.URLTools;
+
+import java.io.IOException;
+import java.net.URL;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class RemoteImporter extends GadgetImporter
+{
+
+ public RemoteImporter(String name, String gadgetPath)
+ {
+ super(name, gadgetPath);
+ }
+
+ @Override
+ protected byte[] getGadgetBytes(String gadgetURI) throws IOException
+ {
+ URL url = new URL(gadgetURI);
+ return URLTools.getContent(url, 5000, 5000);
+ }
+
+ @Override
+ protected String getGadgetURL(String gadgetURI) throws Exception
+ {
+ return "http://www.gatein.org";
+ }
+
+ @Override
+ protected void process(String gadgetURI, GadgetDefinition def) throws Exception
+ {
+ def.setLocal(false);
+
+ //
+ RemoteGadgetData data = (RemoteGadgetData)def.getData();
+
+ // Set remote URL
+ data.setURL(gadgetURI);
+ }
+}
Modified: portal/branches/wci/component/application-registry/src/main/java/org/exoplatform/application/gadget/ServletLocalImporter.java
===================================================================
--- portal/branches/wci/component/application-registry/src/main/java/org/exoplatform/application/gadget/ServletLocalImporter.java 2010-11-29 15:35:58 UTC (rev 5355)
+++ portal/branches/wci/component/application-registry/src/main/java/org/exoplatform/application/gadget/ServletLocalImporter.java 2010-11-29 16:47:37 UTC (rev 5356)
@@ -18,12 +18,16 @@
*/
package org.exoplatform.application.gadget;
-import org.exoplatform.application.gadget.impl.GadgetRegistry;
+import org.chromattic.ext.ntdef.NTFolder;
+import org.chromattic.ext.ntdef.Resource;
+import org.exoplatform.application.gadget.impl.GadgetDefinition;
+import org.exoplatform.application.gadget.impl.LocalGadgetData;
import org.gatein.common.io.IOTools;
import org.gatein.common.logging.Logger;
import org.gatein.common.logging.LoggerFactory;
import javax.servlet.ServletContext;
+import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Set;
@@ -32,7 +36,7 @@
* @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
* @version $Revision$
*/
-public class ServletLocalImporter extends LocalImporter
+public class ServletLocalImporter extends GadgetImporter
{
/** . */
@@ -41,22 +45,103 @@
/** . */
private final ServletContext servletContext;
+ /** Used temporarily when importing resources. */
+ private NTFolder folder;
+
public ServletLocalImporter(
String name,
- GadgetRegistry registry,
String gadgetPath,
- ServletContext servletContext,
- boolean local)
+ ServletContext servletContext)
{
- super(name, registry, gadgetPath, local);
+ super(name, gadgetPath);
//
this.servletContext = servletContext;
}
@Override
- public String getName(String resourcePath) throws IOException
+ protected byte[] getGadgetBytes(String gadgetURI) throws IOException
{
+ return getContent(gadgetURI);
+ }
+
+ @Override
+ protected String getGadgetURL(String gadgetURI) throws Exception
+ {
+ return gadgetURI;
+ }
+
+ @Override
+ protected void process(String gadgetURI, GadgetDefinition def) throws Exception
+ {
+ def.setLocal(true);
+
+ //
+ LocalGadgetData data = (LocalGadgetData)def.getData();
+
+ //
+ String fileName = getName(gadgetURI);
+ data.setFileName(fileName);
+
+ // Import resource
+ folder = data.getResources();
+ String folderPath = getParent(gadgetURI);
+ visitChildren(gadgetURI, folderPath);
+ folder = null;
+ }
+
+ private void visit(String uri, String resourcePath) throws Exception
+ {
+ String name = getName(resourcePath);
+ if (isFile(resourcePath))
+ {
+ byte[] content = getContent(resourcePath);
+
+ //
+ if (content != null)
+ {
+ String mimeType = getMimeType(name);
+
+ //
+ if (mimeType == null)
+ {
+ mimeType = "application/octet-stream";
+ }
+
+ // We can detect encoding for XML files
+ String encoding = null;
+ if ("application/xml".equals(mimeType))
+ {
+ encoding = EncodingDetector.detect(new ByteArrayInputStream(content));
+ }
+
+ // Correct mime type for gadgets
+ if (resourcePath.equals(uri)) {
+ mimeType = LocalGadgetData.GADGET_MIME_TYPE;
+ }
+
+ //
+ folder.createFile(name, new Resource(mimeType, encoding, content));
+ }
+ }
+ else
+ {
+ folder = folder.createFolder(name);
+ visitChildren(uri, resourcePath);
+ folder = folder.getParent();
+ }
+ }
+
+ private void visitChildren(String gadgetURI, String folderPath) throws Exception
+ {
+ for (String childPath : getChildren(folderPath))
+ {
+ visit(gadgetURI, childPath);
+ }
+ }
+
+ private String getName(String resourcePath) throws IOException
+ {
// It's a directory, remove the trailing '/'
if (resourcePath.endsWith("/"))
{
@@ -70,8 +155,7 @@
return resourcePath.substring(index + 1);
}
- @Override
- public String getParent(String resourcePath) throws IOException
+ private String getParent(String resourcePath) throws IOException
{
// It's a directory, remove the trailing '/'
if (resourcePath.endsWith("/"))
@@ -86,8 +170,7 @@
return resourcePath.substring(0, index + 1);
}
- @Override
- public byte[] getContent(String filePath) throws IOException
+ private byte[] getContent(String filePath) throws IOException
{
InputStream in = servletContext.getResourceAsStream(filePath);
if (in == null)
@@ -101,21 +184,18 @@
}
}
- @Override
- public Iterable<String> getChildren(String folderPath) throws IOException
+ private Iterable<String> getChildren(String folderPath) throws IOException
{
- @SuppressWarnings("unchecked") Set resourcePaths = servletContext.getResourcePaths(folderPath);
+ @SuppressWarnings("unchecked") Set<String> resourcePaths = servletContext.getResourcePaths(folderPath);
return resourcePaths;
}
- @Override
- public boolean isFile(String resourcePath) throws IOException
+ private boolean isFile(String resourcePath) throws IOException
{
return !resourcePath.endsWith("/");
}
- @Override
- public String getMimeType(String fileName)
+ private String getMimeType(String fileName)
{
return servletContext.getMimeType(fileName);
}
Modified: portal/branches/wci/component/application-registry/src/main/java/org/exoplatform/application/gadget/impl/GadgetRegistryServiceImpl.java
===================================================================
--- portal/branches/wci/component/application-registry/src/main/java/org/exoplatform/application/gadget/impl/GadgetRegistryServiceImpl.java 2010-11-29 15:35:58 UTC (rev 5355)
+++ portal/branches/wci/component/application-registry/src/main/java/org/exoplatform/application/gadget/impl/GadgetRegistryServiceImpl.java 2010-11-29 16:47:37 UTC (rev 5356)
@@ -23,6 +23,7 @@
import org.chromattic.ext.ntdef.Resource;
import org.exoplatform.application.gadget.Gadget;
import org.exoplatform.application.gadget.GadgetRegistryService;
+import org.exoplatform.application.gadget.GadgetImporter;
import org.exoplatform.application.registry.impl.ApplicationRegistryChromatticLifeCycle;
import org.exoplatform.commons.chromattic.ChromatticLifeCycle;
import org.exoplatform.commons.chromattic.ChromatticManager;
@@ -30,11 +31,14 @@
import org.exoplatform.container.xml.InitParams;
import org.exoplatform.container.xml.PropertiesParam;
import org.exoplatform.container.xml.ValueParam;
+import org.gatein.common.logging.Logger;
+import org.gatein.common.logging.LoggerFactory;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
+import java.util.concurrent.Callable;
/**
* @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
@@ -44,6 +48,9 @@
{
/** . */
+ private final Logger log = LoggerFactory.getLogger(GadgetRegistryServiceImpl.class);
+
+ /** . */
private static final String DEFAULT_DEVELOPER_GROUP = "/platform/administrators";
/** . */
@@ -120,13 +127,23 @@
return registry;
}
- public ChromatticLifeCycle getChromatticLifeCycle()
+ // ***************
+
+ public void deploy(Iterable<GadgetImporter> gadgets)
{
- return chromatticLifeCycle;
+ for (GadgetImporter importer : gadgets)
+ {
+ try
+ {
+ new DeployTask(importer).call();
+ }
+ catch (Exception e)
+ {
+ log.error("Could not process gadget file " + importer, e);
+ }
+ }
}
- // ***************
-
public Gadget getGadget(String name) throws Exception
{
GadgetRegistry registry = getRegistry();
@@ -285,4 +302,40 @@
{
return hostName;
}
+
+ private class DeployTask implements Callable<Boolean>
+ {
+
+ /** . */
+ private final GadgetImporter importer;
+
+ private DeployTask(GadgetImporter importer)
+ {
+ this.importer = importer;
+ }
+
+ public Boolean call() throws Exception
+ {
+ chromatticLifeCycle.openContext();
+ try
+ {
+ boolean done = false;
+ if (getRegistry().getGadget(importer.getGadgetName()) == null)
+ {
+ GadgetDefinition def = getRegistry().addGadget(importer.getGadgetName());
+ importer.doImport(def);
+ done = true;
+ }
+ else
+ {
+ log.debug("Will not import existing gagdet " + importer.getGadgetName());
+ }
+ return done;
+ }
+ finally
+ {
+ chromatticLifeCycle.closeContext(true);
+ }
+ }
+ }
}
Modified: portal/branches/wci/component/identity/src/main/java/org/exoplatform/services/organization/idm/GroupDAOImpl.java
===================================================================
--- portal/branches/wci/component/identity/src/main/java/org/exoplatform/services/organization/idm/GroupDAOImpl.java 2010-11-29 15:35:58 UTC (rev 5355)
+++ portal/branches/wci/component/identity/src/main/java/org/exoplatform/services/organization/idm/GroupDAOImpl.java 2010-11-29 16:47:37 UTC (rev 5356)
@@ -22,6 +22,9 @@
import org.exoplatform.services.organization.Group;
import org.exoplatform.services.organization.GroupEventListener;
import org.exoplatform.services.organization.GroupHandler;
+import org.gatein.common.logging.LogLevel;
+import org.gatein.common.logging.Logger;
+import org.gatein.common.logging.LoggerFactory;
import org.picketlink.idm.api.Attribute;
import org.picketlink.idm.api.IdentitySession;
import org.picketlink.idm.impl.api.SimpleAttribute;
@@ -35,10 +38,10 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+
+
/*
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
*/
@@ -73,16 +76,50 @@
final public Group createGroupInstance()
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "createGroupInstance",
+ null
+ );
+ }
return new ExtGroup();
}
public void createGroup(Group group, boolean broadcast) throws Exception
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "createGroup",
+ new Object[]{
+ "broadcast", broadcast
+ }
+ );
+ }
addChild(null, group, broadcast);
}
public void addChild(Group parent, Group child, boolean broadcast) throws Exception
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "addChild",
+ new Object[]{
+ "parent", parent,
+ "child", child,
+ "broadcast", broadcast
+ }
+ );
+ }
+
org.picketlink.idm.api.Group parentGroup = null;
String childPLGroupName = getPLIDMGroupName(child.getGroupName());
@@ -148,6 +185,19 @@
public void saveGroup(Group group, boolean broadcast) throws Exception
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "saveGroup",
+ new Object[]{
+ "group", group,
+ "broadcast", broadcast
+ }
+ );
+ }
+
if (broadcast)
{
preSave(group, false);
@@ -161,6 +211,19 @@
public Group removeGroup(Group group, boolean broadcast) throws Exception
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "removeGroup",
+ new Object[]{
+ "group", group,
+ "broadcast", broadcast
+ }
+ );
+ }
+
if (broadcast)
{
preDelete(group);
@@ -228,6 +291,19 @@
public Collection findGroupByMembership(String userName, String membershipType) throws Exception
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "findGroupsByMembership",
+ new Object[]{
+ "userName", membershipType
+ }
+ );
+ }
+
+
Collection<org.picketlink.idm.api.Role> allRoles = new HashSet();
try
@@ -272,25 +348,84 @@
}
// UI has hardcoded casts to List
- return new LinkedList<Group>(exoGroups);
+ Collection result = new LinkedList<Group>(exoGroups);
+
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodOut(
+ log,
+ LogLevel.TRACE,
+ "findGroupByMembership",
+ result
+ );
+ }
+
+ return result;
}
//
public Group findGroupById(String groupId) throws Exception
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "findGroupById",
+ new Object[]{
+ "groupId", groupId
+ }
+ );
+ }
+
org.picketlink.idm.api.Group jbidGroup = orgService.getJBIDMGroup(groupId);
if (jbidGroup == null)
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodOut(
+ log,
+ LogLevel.TRACE,
+ "findGroupById",
+ null
+ );
+ }
+
return null;
}
- return convertGroup(jbidGroup);
+ Group result = convertGroup(jbidGroup);
+
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodOut(
+ log,
+ LogLevel.TRACE,
+ "findGroupById",
+ result
+ );
+ }
+
+ return result;
+
}
public Collection findGroups(Group parent) throws Exception
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "findGroups",
+ new Object[]{
+ "parent", parent
+ }
+ );
+ }
+
org.picketlink.idm.api.Group jbidGroup = null;
if (parent == null)
@@ -396,6 +531,16 @@
Collections.sort(results);
}
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodOut(
+ log,
+ LogLevel.TRACE,
+ "findGroups",
+ results
+ );
+ }
+
return results;
}
@@ -403,6 +548,19 @@
public Collection findGroupsOfUser(String user) throws Exception
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "findGroupsOfUser",
+ new Object[]{
+ "user", user
+ }
+ );
+ }
+
+
if (user == null)
{
// julien : integration bug
@@ -415,6 +573,17 @@
// at org.exoplatform.organization.webui.component.GroupManagement.isMemberOfGroup(GroupManagement.java:72)
// at org.exoplatform.organization.webui.component.GroupManagement.isAdministrator(GroupManagement.java:125)
// at org.exoplatform.organization.webui.component.UIGroupExplorer.<init>(UIGroupExplorer.java:57)
+
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodOut(
+ log,
+ LogLevel.TRACE,
+ "findGroupsOfUser",
+ Collections.emptyList()
+ );
+ }
+
return Collections.emptyList();
}
@@ -439,12 +608,32 @@
}
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodOut(
+ log,
+ LogLevel.TRACE,
+ "findGroupsOfUser",
+ exoGroups
+ );
+ }
+
return exoGroups;
}
public Collection getAllGroups() throws Exception
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "getAllGroups",
+ null
+ );
+ }
+
Set<org.picketlink.idm.api.Group> plGroups = new HashSet<org.picketlink.idm.api.Group>();
try
@@ -490,7 +679,19 @@
}
// UI has hardcoded casts to List
- return new LinkedList<Group>(exoGroups);
+ Collection result = new LinkedList<Group>(exoGroups);
+
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodOut(
+ log,
+ LogLevel.TRACE,
+ "getAllGroups",
+ result
+ );
+ }
+
+ return result;
}
@@ -529,6 +730,18 @@
protected Group convertGroup(org.picketlink.idm.api.Group jbidGroup) throws Exception
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "convertGroup",
+ new Object[]{
+ "jbidGroup", jbidGroup
+ }
+ );
+ }
+
Map<String, Attribute> attrs = new HashMap();
try
@@ -562,6 +775,16 @@
// Resolve full ID
String id = getGroupId(jbidGroup, null);
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodOut(
+ log,
+ LogLevel.TRACE,
+ "getGroupId",
+ id
+ );
+ }
+
exoGroup.setId(id);
// child of root
@@ -575,6 +798,16 @@
exoGroup.setParentId(id.substring(0, id.lastIndexOf("/")));
}
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodOut(
+ log,
+ LogLevel.TRACE,
+ "convertGroup",
+ exoGroup
+ );
+ }
+
return exoGroup;
}
@@ -589,6 +822,20 @@
private String getGroupId(org.picketlink.idm.api.Group jbidGroup,
List<org.picketlink.idm.api.Group> processed) throws Exception
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "getGroupId",
+ new Object[]{
+ "jbidGroup", jbidGroup,
+ "processed", processed
+ }
+ );
+ }
+
+
// Check in cache
if (getIntegrationCache() != null)
{
@@ -633,6 +880,10 @@
// Check if there is cross reference so we ended in a loop and break the process.
if (parents.size() > 0 && processed.contains(parents.iterator().next()))
{
+ if (log.isTraceEnabled())
+ {
+ log.trace("Detected looped relationship between groups!!!");
+ }
processed.remove(processed.size() - 1);
return CYCLIC_ID;
}
Modified: portal/branches/wci/component/identity/src/main/java/org/exoplatform/services/organization/idm/IDMUserListAccess.java
===================================================================
--- portal/branches/wci/component/identity/src/main/java/org/exoplatform/services/organization/idm/IDMUserListAccess.java 2010-11-29 15:35:58 UTC (rev 5355)
+++ portal/branches/wci/component/identity/src/main/java/org/exoplatform/services/organization/idm/IDMUserListAccess.java 2010-11-29 16:47:37 UTC (rev 5356)
@@ -21,10 +21,14 @@
import org.exoplatform.commons.utils.ListAccess;
import org.exoplatform.services.organization.User;
+import org.gatein.common.logging.LogLevel;
+import org.gatein.common.logging.Logger;
+import org.gatein.common.logging.LoggerFactory;
import org.picketlink.idm.api.SortOrder;
import org.picketlink.idm.api.query.UserQuery;
import org.picketlink.idm.api.query.UserQueryBuilder;
+
import java.util.List;
/*
@@ -32,6 +36,8 @@
*/
public class IDMUserListAccess implements ListAccess<User>
{
+ private static Logger log = LoggerFactory.getLogger(IDMUserListAccess.class);
+
private final UserDAOImpl userDAO;
private final PicketLinkIDMService idmService;
@@ -54,6 +60,19 @@
public User[] load(int index, int length) throws Exception, IllegalArgumentException
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "load",
+ new Object[]{
+ "index", index,
+ "length", length
+ }
+ );
+ }
+
userQueryBuilder.page(index, length);
UserQuery query = userQueryBuilder.sort(SortOrder.ASCENDING).createQuery();
List<org.picketlink.idm.api.User> users = idmService.getIdentitySession().list(query);
@@ -67,21 +86,55 @@
exoUsers[i] = UserDAOImpl.getPopulatedUser(user.getId(), idmService.getIdentitySession());
}
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodOut(
+ log,
+ LogLevel.TRACE,
+ "load",
+ exoUsers
+ );
+ }
+
return exoUsers;
}
public int getSize() throws Exception
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "getSize",
+ null
+ );
+ }
+
+ int result;
+
if (countAll)
{
- return idmService.getIdentitySession().getPersistenceManager().getUserCount();
+ result = idmService.getIdentitySession().getPersistenceManager().getUserCount();
}
else
{
userQueryBuilder.page(0, 0);
UserQuery query = userQueryBuilder.sort(SortOrder.ASCENDING).createQuery();
- return idmService.getIdentitySession().execute(query).size();
+ result = idmService.getIdentitySession().execute(query).size();
}
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodOut(
+ log,
+ LogLevel.TRACE,
+ "getSize",
+ result
+ );
+ }
+
+ return result;
+
}
}
Modified: portal/branches/wci/component/identity/src/main/java/org/exoplatform/services/organization/idm/IntegrationCache.java
===================================================================
--- portal/branches/wci/component/identity/src/main/java/org/exoplatform/services/organization/idm/IntegrationCache.java 2010-11-29 15:35:58 UTC (rev 5355)
+++ portal/branches/wci/component/identity/src/main/java/org/exoplatform/services/organization/idm/IntegrationCache.java 2010-11-29 16:47:37 UTC (rev 5356)
@@ -149,15 +149,17 @@
Node ioNode = getCache().getRoot().addChild(nodeFqn);
- ioNode.put(NODE_OBJECT_KEY, id);
-
- if (log.isLoggable(Level.FINER))
+ if (ioNode != null)
{
+ ioNode.put(NODE_OBJECT_KEY, id);
- log.finer(this.toString() + "GateIn group id cached. PLIDM group id: " + pLIDMId +
- "GateIn group id: " + id + ";namespace=" + ns);
+ if (log.isLoggable(Level.FINER))
+ {
+
+ log.finer(this.toString() + "GateIn group id cached. PLIDM group id: " + pLIDMId +
+ "GateIn group id: " + id + ";namespace=" + ns);
+ }
}
-
}
/**
@@ -201,14 +203,16 @@
Node ioNode = getCache().getRoot().addChild(nodeFqn);
- ioNode.put(NODE_OBJECT_KEY, rootGroup);
-
- if (log.isLoggable(Level.FINER))
+ if (ioNode != null)
{
+ ioNode.put(NODE_OBJECT_KEY, rootGroup);
- log.finer(this.toString() + "GateIn root group stored in cache" + ";namespace=" + ns);
+ if (log.isLoggable(Level.FINER))
+ {
+
+ log.finer(this.toString() + "GateIn root group stored in cache" + ";namespace=" + ns);
+ }
}
-
}
/**
Modified: portal/branches/wci/component/identity/src/main/java/org/exoplatform/services/organization/idm/MembershipDAOImpl.java
===================================================================
--- portal/branches/wci/component/identity/src/main/java/org/exoplatform/services/organization/idm/MembershipDAOImpl.java 2010-11-29 15:35:58 UTC (rev 5355)
+++ portal/branches/wci/component/identity/src/main/java/org/exoplatform/services/organization/idm/MembershipDAOImpl.java 2010-11-29 16:47:37 UTC (rev 5356)
@@ -26,12 +26,14 @@
import org.exoplatform.services.organization.MembershipHandler;
import org.exoplatform.services.organization.MembershipType;
import org.exoplatform.services.organization.User;
+import org.gatein.common.logging.LogLevel;
+import org.gatein.common.logging.Logger;
+import org.gatein.common.logging.LoggerFactory;
import org.picketlink.idm.api.IdentitySession;
import org.picketlink.idm.api.Role;
import org.picketlink.idm.api.RoleType;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
@@ -74,6 +76,19 @@
public void createMembership(Membership m, boolean broadcast) throws Exception
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "createMembership",
+ new Object[]{
+ "membership", m,
+ "broadcast", broadcast,
+ }
+ );
+ }
+
if (broadcast)
{
preSave(m, true);
@@ -90,6 +105,21 @@
public void linkMembership(User user, Group g, MembershipType mt, boolean broadcast) throws Exception
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "linkMembership",
+ new Object[]{
+ "user", user,
+ "group", g,
+ "membershipType", mt,
+ "broadcast", broadcast
+ }
+ );
+ }
+
if (g == null)
{
throw new InvalidNameException("Can not create membership record for " + user.getUserName()
@@ -154,7 +184,20 @@
public void saveMembership(Membership m, boolean broadcast) throws Exception
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "saveMembership",
+ new Object[]{
+ "membership", m,
+ "broadcast", broadcast
+ }
+ );
+ }
+
String plGroupName = getPLIDMGroupName(getGroupNameFromId(m.getGroupId()));
String groupId =
@@ -222,7 +265,20 @@
public Membership removeMembership(String id, boolean broadcast) throws Exception
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "removeMembership",
+ new Object[]{
+ "id", id,
+ "broadcast", broadcast
+ }
+ );
+ }
+
Membership m = new MembershipImpl(id);
String plGroupName = getPLIDMGroupName(getGroupNameFromId(m.getGroupId()));
@@ -308,6 +364,20 @@
public Collection removeMembershipByUser(String userName, boolean broadcast) throws Exception
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "removeMembershipByUser",
+ new Object[]{
+ "userName", userName,
+ "broadcast", broadcast
+ }
+ );
+ }
+
+
Collection<Role> roles = new HashSet();
try
@@ -388,6 +458,22 @@
public Membership findMembershipByUserGroupAndType(String userName, String groupId, String type) throws Exception
{
+
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "findMembershipByUserAndType",
+ new Object[]{
+ "userName", userName,
+ "groupId", groupId,
+ "type", type,
+ }
+ );
+ }
+
+
String plGroupName = getPLIDMGroupName(getGroupNameFromId(groupId));
String gid =
@@ -437,6 +523,8 @@
hasMembership = true;
}
+ Membership result = null;
+
if (hasMembership)
{
@@ -446,16 +534,51 @@
m.setUserName(userName);
m.setMembershipType(type);
- return m;
+ result = m;
}
- return null;
+
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodOut(
+ log,
+ LogLevel.TRACE,
+ "findMembershipByUserGroupAndType",
+ result
+ );
+ }
+
+ return result;
}
public Collection findMembershipsByUserAndGroup(String userName, String groupId) throws Exception
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "findMembershipByUserAndGroup",
+ new Object[]{
+ "userName", userName,
+ "groupId", groupId,
+ }
+ );
+ }
+
if (userName == null)
{
// julien fix : if user name is null, need to check if we do need to return a special group
+
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodOut(
+ log,
+ LogLevel.TRACE,
+ "findMembershipByUserAndGroup",
+ Collections.emptyList()
+ );
+ }
+
return Collections.emptyList();
}
@@ -515,11 +638,36 @@
}
//TODO: Exo UI has hardcoded casts to List
- return new LinkedList(memberships);
+ Collection result = new LinkedList(memberships);
+
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodOut(
+ log,
+ LogLevel.TRACE,
+ "findMembershipByUserAndGroup",
+ result
+ );
+ }
+
+ return result;
}
public Collection findMembershipsByUser(String userName) throws Exception
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "findMembershipsByUser",
+ new Object[]{
+ "userName", userName
+ }
+ );
+ }
+
+
Collection<Role> roles = new HashSet();
try
@@ -577,7 +725,19 @@
}
- return new LinkedList(memberships);
+ Collection result = new LinkedList(memberships);
+
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodOut(
+ log,
+ LogLevel.TRACE,
+ "findMembershipsByUser",
+ result
+ );
+ }
+
+ return result;
}
public Collection findMembershipsByGroup(Group group) throws Exception
@@ -587,6 +747,18 @@
public Collection findMembershipsByGroupId(String groupId) throws Exception
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "findMembershipsByGroup",
+ new Object[]{
+ "groupId", groupId
+ }
+ );
+ }
+
String plGroupName = getPLIDMGroupName(getGroupNameFromId(groupId));
String gid =
@@ -656,11 +828,34 @@
Collections.sort(results);
}
+
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodOut(
+ log,
+ LogLevel.TRACE,
+ "findMembershipsByGroupId",
+ results
+ );
+ }
+
return results;
}
public Membership findMembership(String id) throws Exception
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "findMembership",
+ new Object[]{
+ "id", id
+ }
+ );
+ }
+
Membership m = new MembershipImpl(id);
String plGroupName = getPLIDMGroupName(getGroupNameFromId(m.getGroupId()));
@@ -675,6 +870,15 @@
if (isCreateMembership(m.getMembershipType()) &&
getIdentitySession().getRoleManager().hasRole(m.getUserName(), groupId, m.getMembershipType()))
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodOut(
+ log,
+ LogLevel.TRACE,
+ "findMembership",
+ m
+ );
+ }
return m;
}
}
@@ -690,6 +894,16 @@
if (isAssociationMapped() && getAssociationMapping().equals(m.getMembershipType()) &&
getIdentitySession().getRelationshipManager().isAssociatedByKeys(groupId, m.getUserName()))
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodOut(
+ log,
+ LogLevel.TRACE,
+ "findMembership",
+ m
+ );
+ }
+
return m;
}
}
@@ -700,6 +914,15 @@
}
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodOut(
+ log,
+ LogLevel.TRACE,
+ "findMembership",
+ null
+ );
+ }
return null;
}
Modified: portal/branches/wci/component/identity/src/main/java/org/exoplatform/services/organization/idm/MembershipImpl.java
===================================================================
--- portal/branches/wci/component/identity/src/main/java/org/exoplatform/services/organization/idm/MembershipImpl.java 2010-11-29 15:35:58 UTC (rev 5355)
+++ portal/branches/wci/component/identity/src/main/java/org/exoplatform/services/organization/idm/MembershipImpl.java 2010-11-29 16:47:37 UTC (rev 5356)
@@ -157,4 +157,14 @@
return userName.compareTo(m.getUserName());
}
+
+ @Override
+ public String toString()
+ {
+ return "MembershipImpl{" +
+ "membershipType='" + membershipType + '\'' +
+ ", userName='" + userName + '\'' +
+ ", groupId='" + groupId + '\'' +
+ '}';
+ }
}
Modified: portal/branches/wci/component/identity/src/main/java/org/exoplatform/services/organization/idm/MembershipTypeDAOImpl.java
===================================================================
--- portal/branches/wci/component/identity/src/main/java/org/exoplatform/services/organization/idm/MembershipTypeDAOImpl.java 2010-11-29 15:35:58 UTC (rev 5355)
+++ portal/branches/wci/component/identity/src/main/java/org/exoplatform/services/organization/idm/MembershipTypeDAOImpl.java 2010-11-29 16:47:37 UTC (rev 5356)
@@ -22,6 +22,7 @@
import org.exoplatform.services.organization.MembershipType;
import org.exoplatform.services.organization.MembershipTypeHandler;
import org.exoplatform.services.organization.impl.MembershipTypeImpl;
+import org.gatein.common.logging.LogLevel;
import org.gatein.common.logging.Logger;
import org.gatein.common.logging.LoggerFactory;
import org.picketlink.idm.api.IdentitySession;
@@ -71,6 +72,20 @@
public MembershipType createMembershipType(MembershipType mt, boolean broadcast) throws Exception
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "createMembershipType",
+ new Object[]{
+ "membershipType", mt,
+ "broadcast", broadcast
+ }
+ );
+ }
+
+
Date now = new Date();
mt.setCreatedDate(now);
mt.setModifiedDate(now);
@@ -83,6 +98,18 @@
public MembershipType saveMembershipType(MembershipType mt, boolean broadcast) throws Exception
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "saveMembershipType",
+ new Object[]{
+ "membershipType", mt,
+ "broadcast", broadcast
+ }
+ );
+ }
Date now = new Date();
mt.setModifiedDate(now);
updateMembershipType(mt);
@@ -91,6 +118,18 @@
public MembershipType findMembershipType(String name) throws Exception
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "findMembershipType",
+ new Object[]{
+ "name", name
+ }
+ );
+ }
+
RoleType rt = getIdentitySession().getRoleManager().getRoleType(name);
MembershipType mt = null;
@@ -101,11 +140,35 @@
populateMembershipType(mt);
}
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodOut(
+ log,
+ LogLevel.TRACE,
+ "findMembershipType",
+ mt
+ );
+ }
+
return mt;
}
public MembershipType removeMembershipType(String name, boolean broadcast) throws Exception
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "removeMembershipType",
+ new Object[]{
+ "name", name,
+ "broadcast", broadcast
+ }
+ );
+ }
+
+
MembershipType mt = findMembershipType(name);
if (mt != null)
@@ -119,6 +182,15 @@
public Collection findMembershipTypes() throws Exception
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "findMembershipTypes",
+ null
+ );
+ }
Collection<RoleType> rts = getIdentitySession().getRoleManager().findRoleTypes();
@@ -131,6 +203,16 @@
mts.add(mt);
}
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodOut(
+ log,
+ LogLevel.TRACE,
+ "findMembershipTypes",
+ mts
+ );
+ }
+
return mts;
}
Copied: portal/branches/wci/component/identity/src/main/java/org/exoplatform/services/organization/idm/Tools.java (from rev 5342, portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/Tools.java)
===================================================================
--- portal/branches/wci/component/identity/src/main/java/org/exoplatform/services/organization/idm/Tools.java (rev 0)
+++ portal/branches/wci/component/identity/src/main/java/org/exoplatform/services/organization/idm/Tools.java 2010-11-29 16:47:37 UTC (rev 5356)
@@ -0,0 +1,106 @@
+package org.exoplatform.services.organization.idm;
+
+import org.gatein.common.logging.LogLevel;
+import org.gatein.common.logging.Logger;
+
+import java.util.Arrays;
+import java.util.Collection;
+
+/*
+* JBoss, a division of Red Hat
+* Copyright 2010, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+
+/**
+ * Some helper methods
+ */
+public class Tools
+{
+ public static void logMethodIn(Logger log, LogLevel level, String methodName, Object[] args)
+ {
+ try
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.append("Method '")
+ .append(methodName)
+ .append("' called with arguments: ");
+
+ if (args != null)
+ {
+ for (Object arg : args)
+ {
+ if (arg != null && arg instanceof Object[])
+ {
+ sb.append(Arrays.toString((Object[])arg))
+ .append("; ");
+ }
+ else
+ {
+ sb.append(arg)
+ .append("; ");
+ }
+ }
+ }
+ else
+ {
+ sb.append(args);
+ }
+
+ log.log(level, sb.toString());
+ }
+ catch (Throwable t)
+ {
+ log.log(level, "Error in logging code block (not related to application code): ", t);
+ }
+
+ }
+
+ public static void logMethodOut(Logger log, LogLevel level, String methodName, Object result)
+ {
+ try
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.append("Method '")
+ .append(methodName)
+ .append("' returning object: ");
+
+ if (result != null && result instanceof Collection)
+ {
+ sb.append("Collection of size: ").append(((Collection)result).size());
+ }
+ else
+ {
+ if (result != null)
+ {
+ sb.append("[").append(result.getClass().getCanonicalName()).append("]");
+ }
+ sb.append(result);
+ }
+
+ log.log(level, sb.toString());
+
+ }
+ catch (Throwable t)
+ {
+ log.log(level, "Error in logging code block (not related to application code): ", t);
+ }
+ }
+
+}
Modified: portal/branches/wci/component/identity/src/main/java/org/exoplatform/services/organization/idm/UserDAOImpl.java
===================================================================
--- portal/branches/wci/component/identity/src/main/java/org/exoplatform/services/organization/idm/UserDAOImpl.java 2010-11-29 15:35:58 UTC (rev 5355)
+++ portal/branches/wci/component/identity/src/main/java/org/exoplatform/services/organization/idm/UserDAOImpl.java 2010-11-29 16:47:37 UTC (rev 5356)
@@ -28,6 +28,7 @@
import org.exoplatform.services.organization.UserEventListener;
import org.exoplatform.services.organization.UserHandler;
import org.exoplatform.services.organization.impl.UserImpl;
+import org.gatein.common.logging.LogLevel;
import org.gatein.common.logging.Logger;
import org.gatein.common.logging.LoggerFactory;
import org.picketlink.idm.api.Attribute;
@@ -122,6 +123,20 @@
public void createUser(User user, boolean broadcast) throws Exception
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "createUser",
+ new Object[]{
+ "user", user,
+ "broadcast", broadcast
+ }
+ );
+ }
+
+
IdentitySession session = service_.getIdentitySession();
if (broadcast)
{
@@ -149,6 +164,20 @@
public void saveUser(User user, boolean broadcast) throws Exception
{
+
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "saveUser",
+ new Object[]{
+ "user", user,
+ "broadcast", broadcast
+ }
+ );
+ }
+
IdentitySession session = service_.getIdentitySession();
if (broadcast)
{
@@ -165,6 +194,20 @@
public User removeUser(String userName, boolean broadcast) throws Exception
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "removeUser",
+ new Object[]{
+ "userName", userName,
+ "broadcast", broadcast
+ }
+ );
+ }
+
+
IdentitySession session = service_.getIdentitySession();
org.picketlink.idm.api.User foundUser = null;
@@ -223,15 +266,49 @@
//
public User findUserByName(String userName) throws Exception
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "findUserByName",
+ new Object[]{
+ "userName", userName,
+ }
+ );
+ }
+
IdentitySession session = service_.getIdentitySession();
User user = getPopulatedUser(userName, session);
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodOut(
+ log,
+ LogLevel.TRACE,
+ "findUserByName",
+ user
+ );
+ }
+
return user;
}
public LazyPageList getUserPageList(int pageSize) throws Exception
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "getUserPagetList",
+ new Object[]{
+ "pageSize", pageSize
+ }
+ );
+ }
+
UserQueryBuilder qb = service_.getIdentitySession().createUserQueryBuilder();
return new LazyPageList(new IDMUserListAccess(this, service_, qb, pageSize, true), pageSize);
@@ -245,9 +322,32 @@
//
public boolean authenticate(String username, String password) throws Exception
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "authenticate",
+ new Object[]{
+ "userName", username,
+ "password", "****"
+ }
+ );
+ }
+
User user = findUserByName(username);
if (user == null)
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodOut(
+ log,
+ LogLevel.TRACE,
+ "authenticate",
+ false
+ );
+ }
+
return false;
}
@@ -279,12 +379,35 @@
userImpl.setLastLoginTime(Calendar.getInstance().getTime());
saveUser(userImpl, false);
}
+
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodOut(
+ log,
+ LogLevel.TRACE,
+ "authenticate",
+ authenticated
+ );
+ }
+
return authenticated;
}
public LazyPageList findUsers(Query q) throws Exception
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "findUsers",
+ new Object[]{
+ "q", q
+ }
+ );
+ }
+
UserQueryBuilder qb = service_.getIdentitySession().createUserQueryBuilder();
if (q.getUserName() != null)
@@ -319,6 +442,19 @@
public LazyPageList findUsersByGroup(String groupId) throws Exception
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "findUsersByGroup",
+ new Object[]{
+ "groupId", groupId
+ }
+ );
+ }
+
+
UserQueryBuilder qb = service_.getIdentitySession().createUserQueryBuilder();
org.picketlink.idm.api.Group jbidGroup = null;
@@ -339,6 +475,18 @@
public User findUserByEmail(String email) throws Exception
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "findUserByEmail",
+ new Object[]{
+ "findUserByEmail", email
+ }
+ );
+ }
+
IdentitySession session = service_.getIdentitySession();
@@ -363,6 +511,16 @@
}
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodOut(
+ log,
+ LogLevel.TRACE,
+ "findUserByEmail",
+ user
+ );
+ }
+
return user;
}
Modified: portal/branches/wci/component/portal/src/main/java/org/exoplatform/portal/config/model/Page.java
===================================================================
--- portal/branches/wci/component/portal/src/main/java/org/exoplatform/portal/config/model/Page.java 2010-11-29 15:35:58 UTC (rev 5355)
+++ portal/branches/wci/component/portal/src/main/java/org/exoplatform/portal/config/model/Page.java 2010-11-29 16:47:37 UTC (rev 5356)
@@ -50,6 +50,13 @@
{
}
+ public Page(String ownerType, String ownerId, String name)
+ {
+ this.ownerType = ownerType;
+ this.ownerId = ownerId;
+ this.name = name;
+ }
+
public Page(PageData data)
{
super(data);
Modified: portal/branches/wci/component/portal/src/main/java/org/exoplatform/portal/config/model/PortalConfig.java
===================================================================
--- portal/branches/wci/component/portal/src/main/java/org/exoplatform/portal/config/model/PortalConfig.java 2010-11-29 15:35:58 UTC (rev 5355)
+++ portal/branches/wci/component/portal/src/main/java/org/exoplatform/portal/config/model/PortalConfig.java 2010-11-29 16:47:37 UTC (rev 5356)
@@ -67,6 +67,16 @@
this(PORTAL_TYPE);
}
+ public PortalConfig(String type)
+ {
+ this(type, null);
+ }
+
+ public PortalConfig(String type, String ownerId)
+ {
+ this(type, ownerId, null);
+ }
+
public PortalConfig(String type, String ownerId, String storageId)
{
super(storageId);
@@ -74,16 +84,9 @@
//
this.type = type;
this.name = ownerId;
+ this.portalLayout = new Container();
}
- public PortalConfig(String type)
- {
- this.type = type;
-
- //
- setPortalLayout(new Container());
- }
-
public PortalConfig(PortalData data)
{
super(data.getStorageId());
@@ -99,14 +102,6 @@
this.portalLayout = new Container(data.getPortalLayout());
}
- PortalConfig(String storageId, String type)
- {
- super(storageId);
-
- //
- this.type = type;
- }
-
public String getType()
{
return type;
Modified: portal/branches/wci/component/portal/src/main/java/org/exoplatform/portal/pom/config/GlobalKey.java
===================================================================
--- portal/branches/wci/component/portal/src/main/java/org/exoplatform/portal/pom/config/GlobalKey.java 2010-11-29 15:35:58 UTC (rev 5355)
+++ portal/branches/wci/component/portal/src/main/java/org/exoplatform/portal/pom/config/GlobalKey.java 2010-11-29 16:47:37 UTC (rev 5356)
@@ -55,6 +55,16 @@
this.localKey = localKey;
}
+ public String getRepositoryId()
+ {
+ return repositoryId;
+ }
+
+ public Serializable getLocalKey()
+ {
+ return localKey;
+ }
+
@Override
public int hashCode()
{
Modified: portal/branches/wci/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSession.java
===================================================================
--- portal/branches/wci/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSession.java 2010-11-29 15:35:58 UTC (rev 5355)
+++ portal/branches/wci/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSession.java 2010-11-29 16:47:37 UTC (rev 5356)
@@ -55,7 +55,7 @@
* @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
* @version $Revision$
*/
-public class POMSession
+public final class POMSession
{
/** . */
@@ -361,20 +361,40 @@
}
public void afterSynchronization(SynchronizationStatus status)
{
- if (status == SynchronizationStatus.SAVED && staleKeys != null)
+ if (status == SynchronizationStatus.SAVED)
{
- if (log.isTraceEnabled())
- {
- log.trace("Session commit about to evict entries " + staleKeys);
- }
- for (Serializable key : staleKeys)
- {
- mgr.cacheRemove(key);
- }
+ reset();
}
}
};
+ /**
+ * Reset the session and set its state like it was a newly created session.
+ */
+ private void reset()
+ {
+ // Evict entries from the shared cache if any
+ if (staleKeys != null && staleKeys.size() > 0)
+ {
+ if (log.isTraceEnabled())
+ {
+ log.trace("About to evict entries " + staleKeys);
+ }
+ for (Serializable key : staleKeys)
+ {
+ mgr.cacheRemove(key);
+ }
+ staleKeys.clear();
+ }
+
+ // Reset modified flag
+ if (log.isTraceEnabled())
+ {
+ log.trace("Setting modified flag to false");
+ }
+ modified = false;
+ }
+
public <V> V execute(POMTask<V> task) throws Exception
{
if (isInTask)
@@ -404,7 +424,11 @@
{
if (!markedForRollback)
{
+ // Trigger persistent save
model.save();
+
+ // Reset modified state
+ reset();
}
else
{
Modified: portal/branches/wci/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSessionManager.java
===================================================================
--- portal/branches/wci/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSessionManager.java 2010-11-29 15:35:58 UTC (rev 5355)
+++ portal/branches/wci/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSessionManager.java 2010-11-29 16:47:37 UTC (rev 5356)
@@ -23,8 +23,13 @@
import org.exoplatform.commons.chromattic.ChromatticManager;
import org.exoplatform.commons.chromattic.SessionContext;
import org.exoplatform.portal.pom.config.cache.DataCache;
+import org.exoplatform.portal.pom.config.cache.PortalNamesCache;
+import org.exoplatform.portal.pom.data.OwnerKey;
+import org.exoplatform.portal.pom.data.PortalKey;
import org.exoplatform.services.cache.CacheService;
+import org.exoplatform.services.cache.CachedObjectSelector;
import org.exoplatform.services.cache.ExoCache;
+import org.exoplatform.services.cache.ObjectCacheInfo;
import org.exoplatform.services.jcr.RepositoryService;
import org.gatein.common.logging.Logger;
import org.gatein.common.logging.LoggerFactory;
@@ -69,7 +74,7 @@
this.manager = manager;
this.cache = cacheService.getCacheInstance("MOPSessionManager");
this.pomService = null;
- this.executor = new DataCache(new ExecutorDispatcher());
+ this.executor = new PortalNamesCache(new DataCache(new ExecutorDispatcher()));
}
public void cachePut(Serializable key, Object value)
@@ -105,7 +110,7 @@
public void cacheRemove(Serializable key)
{
- GlobalKey globalKey = GlobalKey.wrap(configurator.getRepositoryName(), key);
+ final GlobalKey globalKey = GlobalKey.wrap(configurator.getRepositoryName(), key);
//
if (log.isTraceEnabled())
@@ -114,7 +119,47 @@
}
//
- cache.remove(globalKey);
+ if (key instanceof PortalKey)
+ {
+ // This code seems complex but actually it tries to find all objects in cache that have the same
+ // owner key than the portal key, for instance if we remove (portal,classic) then all pages
+ // related to (portal,classic) are also evicted
+ final PortalKey portalKey = (PortalKey)key;
+ try
+ {
+ cache.select(new CachedObjectSelector<GlobalKey, Object>()
+ {
+ public boolean select(GlobalKey selectedGlobalKey, ObjectCacheInfo<?> ocinfo)
+ {
+ if (globalKey.getRepositoryId().equals(selectedGlobalKey.getRepositoryId()))
+ {
+ Serializable selectedLocalKey = selectedGlobalKey.getLocalKey();
+ if (selectedLocalKey instanceof OwnerKey)
+ {
+ OwnerKey selectedOwnerKey = (OwnerKey)selectedLocalKey;
+ if (selectedOwnerKey.getType().equals(portalKey.getType()) && selectedOwnerKey.getId().equals(portalKey.getId()))
+ {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+ public void onSelect(ExoCache<? extends GlobalKey, ?> exoCache, GlobalKey key, ObjectCacheInfo<?> ocinfo) throws Exception
+ {
+ cache.remove(key);
+ }
+ });
+ }
+ catch (Exception e)
+ {
+ log.error("Unexpected error when clearing pom cache", e);
+ }
+ }
+ else
+ {
+ cache.remove(globalKey);
+ }
}
public void start()
Copied: portal/branches/wci/component/portal/src/main/java/org/exoplatform/portal/pom/config/cache/PortalNamesCache.java (from rev 5342, portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/cache/PortalNamesCache.java)
===================================================================
--- portal/branches/wci/component/portal/src/main/java/org/exoplatform/portal/pom/config/cache/PortalNamesCache.java (rev 0)
+++ portal/branches/wci/component/portal/src/main/java/org/exoplatform/portal/pom/config/cache/PortalNamesCache.java 2010-11-29 16:47:37 UTC (rev 5356)
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.portal.pom.config.cache;
+
+import org.exoplatform.commons.utils.LazyPageList;
+import org.exoplatform.commons.utils.ListAccessImpl;
+import org.exoplatform.portal.pom.config.POMSession;
+import org.exoplatform.portal.pom.config.POMTask;
+import org.exoplatform.portal.pom.config.TaskExecutionDecorator;
+import org.exoplatform.portal.pom.config.TaskExecutor;
+import org.exoplatform.portal.pom.config.tasks.PortalConfigTask;
+import org.exoplatform.portal.pom.config.tasks.SearchTask;
+import org.exoplatform.portal.pom.data.PortalKey;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class PortalNamesCache extends TaskExecutionDecorator
+{
+
+ public PortalNamesCache(TaskExecutor next)
+ {
+ super(next);
+ }
+
+ @Override
+ public <V> V execute(POMSession session, POMTask<V> task) throws Exception
+ {
+ if (!session.isModified())
+ {
+ if (task instanceof SearchTask.FindSiteKey)
+ {
+ List<PortalKey> data = (List<PortalKey>)session.getFromCache(SearchTask.FindSiteKey.class);
+ if (data == null)
+ {
+ V result = super.execute(session, task);
+ LazyPageList<PortalKey> list = (LazyPageList<PortalKey>)result;
+ session.putInCache(SearchTask.FindSiteKey.class, Collections.unmodifiableList(new ArrayList<PortalKey>(list.getAll())));
+ return result;
+ }
+ else
+ {
+ return (V)new LazyPageList<PortalKey>(new ListAccessImpl<PortalKey>(PortalKey.class, data), 10);
+ }
+ }
+ else if (task instanceof PortalConfigTask.Save || task instanceof PortalConfigTask.Remove)
+ {
+ V result = super.execute(session, task);
+ session.scheduleForEviction(SearchTask.FindSiteKey.class);
+ return result;
+ }
+ }
+
+ //
+ return super.execute(session, task);
+ }
+}
Modified: portal/branches/wci/component/portal/src/test/java/org/exoplatform/portal/config/TestCache.java
===================================================================
--- portal/branches/wci/component/portal/src/test/java/org/exoplatform/portal/config/TestCache.java 2010-11-29 15:35:58 UTC (rev 5355)
+++ portal/branches/wci/component/portal/src/test/java/org/exoplatform/portal/config/TestCache.java 2010-11-29 16:47:37 UTC (rev 5356)
@@ -20,9 +20,9 @@
import org.exoplatform.container.PortalContainer;
import org.exoplatform.portal.config.model.Page;
+import org.exoplatform.portal.config.model.PortalConfig;
import org.exoplatform.portal.pom.config.POMSession;
import org.exoplatform.portal.pom.config.POMSessionManager;
-
import java.util.concurrent.atomic.AtomicBoolean;
/**
@@ -128,4 +128,48 @@
//
end();
}
+
+ public void testGetPageFromRemovedPortal() throws Exception
+ {
+ // Create what we need for the test
+ begin();
+ session = mgr.openSession();
+ PortalConfig portalConfig = new PortalConfig("portal", "testGetPageFromRemovedPortal");
+ storage_.create(portalConfig);
+ storage_.create(new Page("portal", "testGetPageFromRemovedPortal", "home"));
+ end(true);
+
+ // Clear cache
+ mgr.clearCache();
+
+ // The first transaction
+ begin();
+ session = mgr.openSession();
+
+ // Get page from JCR and it should be stored in cache
+ Page page = storage_.getPage("portal::testGetPageFromRemovedPortal::home");
+ assertNotNull(page);
+
+ // Now remove the portal
+ PortalConfig portal = storage_.getPortalConfig("portal", "testGetPageFromRemovedPortal");
+ storage_.remove(portal);
+
+ // Terminate the first transaction
+ end(true);
+
+ // The second transaction
+ begin();
+ session = mgr.openSession();
+
+ // The portal should be null
+ portal = storage_.getPortalConfig("portal", "testGetPageFromRemovedPortal");
+ assertNull(portal);
+
+ // The portal home page should also be null
+ page = storage_.getPage("portal::testGetPageFromRemovedPortal::home");
+ assertNull(page);
+
+ // End second transaction
+ end(true);
+ }
}
Copied: portal/branches/wci/component/portal/src/test/java/org/exoplatform/portal/config/TestConcurrencyDataStorage.java (from rev 5342, portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestConcurrencyDataStorage.java)
===================================================================
--- portal/branches/wci/component/portal/src/test/java/org/exoplatform/portal/config/TestConcurrencyDataStorage.java (rev 0)
+++ portal/branches/wci/component/portal/src/test/java/org/exoplatform/portal/config/TestConcurrencyDataStorage.java 2010-11-29 16:47:37 UTC (rev 5356)
@@ -0,0 +1,138 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.portal.config;
+
+import java.util.concurrent.CountDownLatch;
+
+import org.exoplatform.container.PortalContainer;
+import org.exoplatform.portal.config.model.Page;
+import org.exoplatform.portal.config.model.PortalConfig;
+import org.exoplatform.portal.pom.config.POMSessionManager;
+
+/**
+ * @author <a href="mailto:hoang281283@gmail.com">Minh Hoang TO</a>
+ * Nov 10, 2010
+ */
+
+public class TestConcurrencyDataStorage extends AbstractPortalTest
+{
+
+ private DataStorage storage_;
+
+ private POMSessionManager mgr;
+
+ public TestConcurrencyDataStorage(String name)
+ {
+ super(name);
+ }
+
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ begin();
+ PortalContainer container = PortalContainer.getInstance();
+ storage_ = (DataStorage)container.getComponentInstanceOfType(DataStorage.class);
+ mgr = (POMSessionManager)container.getComponentInstanceOfType(POMSessionManager.class);
+
+ }
+
+ public void testCreatePageConcurrently() throws Exception
+ {
+ CountDownLatch startSignal = new CountDownLatch(1);
+
+ for (int i = 0; i < 5; i++)
+ {
+ Thread thread = new Thread(new CreatePageTask(mgr, storage_, startSignal, "test" + i, "foo" + i));
+ thread.start();
+ }
+
+ startSignal.countDown();
+ }
+
+ public void testCreatePageSequentially() throws Exception
+ {
+ for (int i = 5; i < 10; i++)
+ {
+ Thread thread = new Thread(new CreatePageTask(mgr, storage_, null, "test" + i, "foo" + i));
+ thread.start();
+ thread.join();
+ }
+ }
+
+ protected void tearDown() throws Exception
+ {
+ end();
+ super.tearDown();
+ }
+
+ public class CreatePageTask implements Runnable
+ {
+ private DataStorage dataStorage;
+
+ private POMSessionManager sessionManager;
+
+ private String pageName;
+
+ private String pageTitle;
+
+ private CountDownLatch startSignal;
+
+ public CreatePageTask(POMSessionManager _sessionManager, DataStorage _dataStorage, CountDownLatch _startSignal, String _pageName, String _pageTitle)
+ {
+ dataStorage = _dataStorage;
+ pageName = _pageName;
+ pageTitle = _pageTitle;
+ sessionManager = _sessionManager;
+ startSignal = _startSignal;
+ }
+
+ @Override
+ public void run()
+ {
+ try
+ {
+ if(startSignal != null)
+ startSignal.await();
+
+ sessionManager.openSession();
+
+ Page page = new Page();
+ page.setOwnerType(PortalConfig.PORTAL_TYPE);
+ page.setOwnerId("test");
+ page.setTitle(pageTitle);
+ page.setName(pageName);
+
+ dataStorage.create(page);
+
+ Page createdPage = dataStorage.getPage(page.getPageId());
+ assertNotNull(createdPage);
+ assertEquals(pageName, createdPage.getName());
+ assertEquals(pageTitle, createdPage.getTitle());
+
+ System.out.println("Current POMSession: " + sessionManager.getSession().toString());
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ System.out.println("Could not create the page: " + pageName + " , " + pageTitle);
+ }
+ }
+ }
+
+}
Modified: portal/branches/wci/component/portal/src/test/java/org/exoplatform/portal/config/TestDataStorage.java
===================================================================
--- portal/branches/wci/component/portal/src/test/java/org/exoplatform/portal/config/TestDataStorage.java 2010-11-29 15:35:58 UTC (rev 5355)
+++ portal/branches/wci/component/portal/src/test/java/org/exoplatform/portal/config/TestDataStorage.java 2010-11-29 16:47:37 UTC (rev 5356)
@@ -21,6 +21,7 @@
import static org.exoplatform.portal.pom.config.Utils.split;
+import org.exoplatform.commons.utils.LazyPageList;
import org.exoplatform.container.PortalContainer;
import org.exoplatform.portal.application.PortletPreferences;
import org.exoplatform.portal.application.Preference;
@@ -36,7 +37,11 @@
import org.exoplatform.services.listener.ListenerService;
import java.util.*;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.atomic.AtomicReference;
+import junit.framework.AssertionFailedError;
+
/**
* Created by The eXo Platform SARL Author : Tung Pham thanhtungty(a)gmail.com Nov
* 13, 2007
@@ -45,9 +50,12 @@
{
/** . */
- private final String testPage = "portal::classic::testPage";
+ private static final String CLASSIC_HOME = "portal::classic::homepage";
/** . */
+ private static final String CLASSIC_TEST = "portal::classic::testPage";
+
+ /** . */
private final String testPortletPreferences = "portal#classic:/web/BannerPortlet/testPortletPreferences";
/** . */
@@ -297,7 +305,7 @@
assertEquals(1, events.size());
//
- page = storage_.getPage(testPage);
+ page = storage_.getPage(CLASSIC_TEST);
assertNull(page);
}
@@ -868,7 +876,137 @@
gadgetApp = (Application<Gadget>)row0.getChildren().get(0);
assertEquals("foo", storage_.getId(gadgetApp.getState()));
}
+
+ public void testRemoveAndFindPage() throws Exception
+ {
+ Page page = storage_.getPage(CLASSIC_HOME);
+ assertNotNull(page);
+ storage_.remove(page);
+ // This will trigger a save
+ Query<Page> query = new Query<Page>(null, null, null, null, Page.class);
+ LazyPageList<Page> list = storage_.find(query);
+ assertNotNull(list);
+
+ // We check is now seen as removed
+ assertNull(storage_.getPage(CLASSIC_HOME));
+ }
+
+ public void testGetAllPortalNames() throws Exception
+ {
+ final List<String> names = storage_.getAllPortalNames();
+
+ // Create new portal
+ storage_.create(new PortalConfig("portal", "testGetAllPortalNames"));
+
+ // Test during tx we see the good names
+ List<String> transientNames = storage_.getAllPortalNames();
+ assertTrue(transientNames.containsAll(names));
+ transientNames.removeAll(names);
+ assertEquals(Collections.singletonList("testGetAllPortalNames"), transientNames);
+
+ // Test we have not seen anything yet outside of tx
+ final CountDownLatch addSync = new CountDownLatch(1);
+ final AtomicReference<Throwable> error = new AtomicReference<Throwable>();
+ new Thread()
+ {
+ @Override
+ public void run()
+ {
+ begin();
+ try
+ {
+ List<String> isolatedNames = storage_.getAllPortalNames();
+ assertEquals(new HashSet<String>(names), new HashSet<String>(isolatedNames));
+ }
+ catch (Throwable t)
+ {
+ error.set(t);
+ }
+ finally
+ {
+ addSync.countDown();
+ end();
+ }
+ }
+ }.start();
+
+ //
+ addSync.await();
+ if (error.get() != null)
+ {
+ AssertionFailedError afe = new AssertionFailedError();
+ afe.initCause(error.get());
+ throw afe;
+ }
+
+ // Now commit tx
+ session.close(true);
+ end(true);
+
+ // We test we observe the change
+ begin();
+ session = mgr.openSession();
+ List<String> afterNames = storage_.getAllPortalNames();
+ assertTrue(afterNames.containsAll(names));
+ afterNames.removeAll(names);
+ assertEquals(Collections.singletonList("testGetAllPortalNames"), afterNames);
+
+ // Then we remove the newly created portal
+ storage_.remove(new PortalConfig("portal", "testGetAllPortalNames"));
+
+ // Test we are syeing the transient change
+ transientNames.clear();
+ transientNames = storage_.getAllPortalNames();
+ assertEquals(names, transientNames);
+
+ // Test we have not seen anything yet outside of tx
+ error.set(null);
+ final CountDownLatch removeSync = new CountDownLatch(1);
+ new Thread()
+ {
+ public void run()
+ {
+ begin();
+ try
+ {
+ List<String> isolatedNames = storage_.getAllPortalNames();
+ assertTrue(isolatedNames.containsAll(names));
+ isolatedNames.removeAll(names);
+ assertEquals(Collections.singletonList("testGetAllPortalNames"), isolatedNames);
+ }
+ catch (Throwable t)
+ {
+ error.set(t);
+ }
+ finally
+ {
+ removeSync.countDown();
+ end();
+ }
+ }
+ }.start();
+
+ //
+ removeSync.await();
+ if (error.get() != null)
+ {
+ AssertionFailedError afe = new AssertionFailedError();
+ afe.initCause(error.get());
+ throw afe;
+ }
+
+ //
+ session.close(true);
+ end(true);
+
+ // Now test it is still removed
+ begin();
+ session = mgr.openSession();
+ afterNames = storage_.getAllPortalNames();
+ assertEquals(new HashSet<String>(names), new HashSet<String>(afterNames));
+ }
+
private Application<Portlet> create(String instanceId)
{
int i0 = instanceId.indexOf("#");
Modified: portal/branches/wci/component/scripting/src/main/java/org/exoplatform/groovyscript/GroovyTemplate.java
===================================================================
--- portal/branches/wci/component/scripting/src/main/java/org/exoplatform/groovyscript/GroovyTemplate.java 2010-11-29 15:35:58 UTC (rev 5355)
+++ portal/branches/wci/component/scripting/src/main/java/org/exoplatform/groovyscript/GroovyTemplate.java 2010-11-29 16:47:37 UTC (rev 5356)
@@ -34,6 +34,7 @@
public class GroovyTemplate
{
+ // todo : move that to {@link org.gatein.common.io.IOTools}
private static String read(Reader reader) throws IOException
{
StringBuilder builder = new StringBuilder();
Modified: portal/branches/wci/component/web/controller/src/main/java/org/exoplatform/web/WebAppController.java
===================================================================
--- portal/branches/wci/component/web/controller/src/main/java/org/exoplatform/web/WebAppController.java 2010-11-29 15:35:58 UTC (rev 5355)
+++ portal/branches/wci/component/web/controller/src/main/java/org/exoplatform/web/WebAppController.java 2010-11-29 16:47:37 UTC (rev 5356)
@@ -49,7 +49,7 @@
private HashMap<String, Object> attributes_;
- private HashMap<String, Application> applications_;
+ private volatile HashMap<String, Application> applications_;
private HashMap<String, WebRequestHandler> handlers_;
@@ -89,16 +89,42 @@
return applications;
}
- public void removeApplication(String appId)
+ public synchronized void removeApplication(String appId)
{
applications_.remove(appId);
}
- public void addApplication(Application app)
+ /**
+ * Add application (portlet, gadget) to the global application map if and only if it has
+ * not been registered yet.
+ *
+ * @param <T>
+ * @param app
+ * @return
+ */
+ public <T extends Application> T addApplication(T app)
{
- applications_.put(app.getApplicationId(), app);
+ Application result = getApplication(app.getApplicationId());
+
+ //Double-check block
+ if(result == null)
+ {
+ synchronized(this)
+ {
+ result = getApplication(app.getApplicationId());
+ if(result == null)
+ {
+ HashMap<String, Application> temporalApplicationsMap = new HashMap<String, Application>(applications_);
+ temporalApplicationsMap.put(app.getApplicationId(), app);
+ this.applications_ = temporalApplicationsMap;
+ result = app;
+ }
+ }
+ }
+
+ return (T)result;
}
-
+
public void register(WebRequestHandler handler) throws Exception
{
for (String path : handler.getPath())
Modified: portal/branches/wci/component/web/resources/src/main/java/org/exoplatform/portal/application/Image.java
===================================================================
--- portal/branches/wci/component/web/resources/src/main/java/org/exoplatform/portal/application/Image.java 2010-11-29 15:35:58 UTC (rev 5355)
+++ portal/branches/wci/component/web/resources/src/main/java/org/exoplatform/portal/application/Image.java 2010-11-29 16:47:37 UTC (rev 5356)
@@ -19,6 +19,8 @@
package org.exoplatform.portal.application;
+import java.util.Date;
+
/**
* @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
* @version $Revision$
@@ -29,10 +31,19 @@
final ImageType type;
final byte[] bytes;
+
+ final long lastModified;
public Image(ImageType type, byte[] bytes)
{
this.type = type;
this.bytes = bytes;
+// Remove miliseconds because string of date retrieve from Http header doesn't have miliseconds
+ lastModified = (new Date().getTime() / 1000) * 1000;
}
+
+ public long getLastModified()
+ {
+ return lastModified;
+ }
}
Modified: portal/branches/wci/component/web/resources/src/main/java/org/exoplatform/portal/application/ResourceRequestFilter.java
===================================================================
--- portal/branches/wci/component/web/resources/src/main/java/org/exoplatform/portal/application/ResourceRequestFilter.java 2010-11-29 15:35:58 UTC (rev 5355)
+++ portal/branches/wci/component/web/resources/src/main/java/org/exoplatform/portal/application/ResourceRequestFilter.java 2010-11-29 16:47:37 UTC (rev 5356)
@@ -36,6 +36,7 @@
import java.io.OutputStream;
import java.net.URLDecoder;
import java.nio.charset.Charset;
+import java.util.Date;
import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
@@ -64,6 +65,10 @@
private ConcurrentMap<String, FutureTask<Image>> mirroredImageCache = new ConcurrentHashMap<String, FutureTask<Image>>();
+ public static final String IF_MODIFIED_SINCE = "If-Modified-Since";
+
+ public static final String LAST_MODIFIED = "Last-Modified";
+
public void afterInit(FilterConfig filterConfig)
{
cfg = filterConfig;
@@ -77,11 +82,19 @@
final String uri = URLDecoder.decode(httpRequest.getRequestURI(), "UTF-8");
final HttpServletResponse httpResponse = (HttpServletResponse)response;
ExoContainer portalContainer = getContainer();
- SkinService skinService = (SkinService)portalContainer.getComponentInstanceOfType(SkinService.class);
+ final SkinService skinService = (SkinService) portalContainer.getComponentInstanceOfType(SkinService.class);
+ long ifModifiedSince = httpRequest.getDateHeader(IF_MODIFIED_SINCE);
//
if (uri.endsWith(".css"))
{
+// Check if cached resource has not been modifed, return 304 code
+ long cssLastModified = skinService.getLastModified(uri);
+ if (isNotModified(ifModifiedSince, cssLastModified)) {
+ httpResponse.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
+ return;
+ }
+
final OutputStream out = response.getOutputStream();
final BinaryOutput output = new BinaryOutput()
{
@@ -118,6 +131,9 @@
{
httpResponse.setHeader("Cache-Control", "no-cache");
}
+
+ long lastModified = skinService.getLastModified(uri);
+ processIfModified(lastModified, httpResponse);
}
};
@@ -192,8 +208,16 @@
Image img = futureImg.get();
if (img != null)
{
+ //Check if cached resource has not been modifed, return 304 code
+ long imgLastModified = img.getLastModified();
+ if (isNotModified(ifModifiedSince, imgLastModified)) {
+ httpResponse.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
+ return;
+ }
httpResponse.setContentType(img.type.getMimeType());
httpResponse.setContentLength(img.bytes.length);
+ processIfModified(imgLastModified, httpResponse);
+
OutputStream out = httpResponse.getOutputStream();
out.write(img.bytes);
out.close();
@@ -238,6 +262,30 @@
}
}
+ /**
+ * Add Last-Modified Http header to HttpServetResponse
+ */
+ public void processIfModified(long lastModified, HttpServletResponse httpResponse) {
+ httpResponse.setDateHeader(ResourceRequestFilter.LAST_MODIFIED, lastModified);
+ }
+
+ /**
+ * If cached resource has not changed since date in http header (If_Modified_Since), return true
+ * Else return false;
+ * @param ifModifedSince - String, and HttpHeader element
+ * @param lastModified
+ * @param httpResponse
+ * @return
+ */
+ public boolean isNotModified(long ifModifedSince, long lastModified) {
+ if (!PropertyManager.isDevelopping()) {
+ if (ifModifedSince >= lastModified) {
+ return true;
+ }
+ }
+ return false;
+ }
+
public void destroy()
{
}
Modified: portal/branches/wci/component/web/resources/src/main/java/org/exoplatform/portal/resource/CachedStylesheet.java
===================================================================
--- portal/branches/wci/component/web/resources/src/main/java/org/exoplatform/portal/resource/CachedStylesheet.java 2010-11-29 15:35:58 UTC (rev 5355)
+++ portal/branches/wci/component/web/resources/src/main/java/org/exoplatform/portal/resource/CachedStylesheet.java 2010-11-29 16:47:37 UTC (rev 5356)
@@ -24,6 +24,7 @@
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.lang.reflect.UndeclaredThrowableException;
+import java.util.Date;
/**
* @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
@@ -40,6 +41,8 @@
/** . */
private final byte[] bytes;
+
+ private long lastModified;
public CachedStylesheet(String text)
{
@@ -59,11 +62,18 @@
//
this.text = text;
this.bytes = bytes;
+// Remove miliseconds because string of date retrieve from Http header doesn't have miliseconds
+ lastModified = (new Date().getTime() / 1000) * 1000;
}
public String getText()
{
return text;
+ }
+
+ public long getLastModified()
+ {
+ return lastModified;
}
public void writeTo(BinaryOutput output) throws IOException
Modified: portal/branches/wci/component/web/resources/src/main/java/org/exoplatform/portal/resource/SkinService.java
===================================================================
--- portal/branches/wci/component/web/resources/src/main/java/org/exoplatform/portal/resource/SkinService.java 2010-11-29 15:35:58 UTC (rev 5355)
+++ portal/branches/wci/component/web/resources/src/main/java/org/exoplatform/portal/resource/SkinService.java 2010-11-29 16:47:37 UTC (rev 5356)
@@ -51,6 +51,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
+import java.util.Date;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.HashSet;
@@ -455,6 +456,9 @@
// Try cache first
if (!PropertyManager.isDevelopping())
{
+ //
+ FutureExoCache<String, CachedStylesheet, Orientation> cache = orientation == Orientation.LT ? ltCache : rtCache;
+ CachedStylesheet cachedCss = cache.get(orientation, path);
if (path.startsWith("/" + portalContainerName + "/resource"))
{
@@ -464,11 +468,7 @@
{
renderer.setExpiration(ONE_HOUR);
}
-
- //
- FutureExoCache<String, CachedStylesheet, Orientation> cache = orientation == Orientation.LT ? ltCache : rtCache;
- CachedStylesheet cachedCss = cache.get(orientation, path);
-
+
cachedCss.writeTo(renderer.getOutput());
}
else
@@ -546,6 +546,41 @@
}
/**
+ * Return last modifed date of cached css
+ * Return null if cached css can not be found
+ * @param path - path must not be null
+ */
+ public long getLastModified(String path)
+ {
+ if (path == null)
+ {
+ throw new IllegalArgumentException("path must not be null");
+ }
+
+ FutureExoCache<String, CachedStylesheet, Orientation> cache = ltCache;
+ Orientation orientation = Orientation.LT;
+ if (path.endsWith("-lt.css"))
+ {
+ path = path.substring(0, path.length() - "-lt.css".length()) + ".css";
+ }
+ else if (path.endsWith("-rt.css"))
+ {
+ path = path.substring(0, path.length() - "-rt.css".length()) + ".css";
+ orientation = Orientation.RT;
+ }
+
+ CachedStylesheet cachedCSS = cache.get(orientation, path);
+ if (cachedCSS == null)
+ {
+ return Long.MAX_VALUE;
+ }
+ else
+ {
+ return cachedCSS.getLastModified();
+ }
+ }
+
+ /**
* Remove SkinConfig from Portal Skin Configs by module and skin name
* @param module
* @param skinName
Modified: portal/branches/wci/component/web/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptConfigService.java
===================================================================
--- portal/branches/wci/component/web/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptConfigService.java 2010-11-29 15:35:58 UTC (rev 5355)
+++ portal/branches/wci/component/web/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptConfigService.java 2010-11-29 16:47:37 UTC (rev 5356)
@@ -40,6 +40,7 @@
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
+import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -64,6 +65,8 @@
private HashMap<String, String> extendedJavascripts;
private byte[] jsBytes = null;
+
+ private long lastModified = Long.MAX_VALUE;
/** . */
private JavascriptDeployer deployer;
@@ -278,6 +281,18 @@
*/
public void writeMergedJavascript(OutputStream out) throws IOException
{
+ jsBytes = getMergedJavascript();
+
+ //
+ out.write(jsBytes);
+ }
+
+ /**
+ * Return merged javascript in byte array
+ * @return byte[]
+ */
+ public byte[] getMergedJavascript()
+ {
if (jsBytes == null)
{
// Generate javascript in a buffer
@@ -314,10 +329,15 @@
log.error("Error when generating minified javascript, will use normal javascript instead", e);
jsBytes = bytes;
}
+// Remove miliseconds because string of date retrieve from Http header doesn't have miliseconds
+ lastModified = (new Date().getTime() / 1000) * 1000;
}
+ return jsBytes;
+ }
- //
- out.write(jsBytes);
+ public long getLastModified()
+ {
+ return lastModified;
}
/**
@@ -374,4 +394,4 @@
DefaultServletContainerFactory.getInstance().getServletContainer().removeWebAppListener(removal);
}
-}
\ No newline at end of file
+}
Copied: portal/branches/wci/component/web/security/src/main/java/org/exoplatform/web/security/security/AbstractCodec.java (from rev 5342, portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/security/AbstractCodec.java)
===================================================================
--- portal/branches/wci/component/web/security/src/main/java/org/exoplatform/web/security/security/AbstractCodec.java (rev 0)
+++ portal/branches/wci/component/web/security/src/main/java/org/exoplatform/web/security/security/AbstractCodec.java 2010-11-29 16:47:37 UTC (rev 5356)
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.web.security.security;
+
+import org.exoplatform.container.component.BaseComponentPlugin;
+
+/**
+ * Abstract codec used to encode/decode password stored/loaded on/from token entry
+ *
+ * @author <a href="mailto:hoang281283@gmail.com">Minh Hoang TO</a>
+ * Nov 19, 2010
+ */
+
+public abstract class AbstractCodec extends BaseComponentPlugin
+{
+
+ public String getName()
+ {
+ return this.getClass().toString();
+ }
+
+ public abstract String encode(String plainInput);
+
+ public abstract String decode(String encodedInput);
+
+}
Modified: portal/branches/wci/component/web/security/src/main/java/org/exoplatform/web/security/security/CookieTokenService.java
===================================================================
--- portal/branches/wci/component/web/security/src/main/java/org/exoplatform/web/security/security/CookieTokenService.java 2010-11-29 15:35:58 UTC (rev 5355)
+++ portal/branches/wci/component/web/security/src/main/java/org/exoplatform/web/security/security/CookieTokenService.java 2010-11-29 16:47:37 UTC (rev 5356)
@@ -24,6 +24,7 @@
import org.exoplatform.commons.chromattic.ChromatticManager;
import org.exoplatform.commons.chromattic.ContextualTask;
import org.exoplatform.commons.chromattic.SessionContext;
+import org.exoplatform.container.component.ComponentPlugin;
import org.exoplatform.container.xml.InitParams;
import org.exoplatform.web.security.GateInToken;
import org.gatein.wci.security.Credentials;
@@ -47,6 +48,9 @@
/** . */
private String lifecycleName="autologin";
+ //TODO: Introduce the concept of priority and store the plugins in a map structure
+ private AbstractCodec codec;
+
public CookieTokenService(InitParams initParams, ChromatticManager chromatticManager)
{
super(initParams);
@@ -56,8 +60,19 @@
lifecycleName = (String)initParams.getValuesParam(SERVICE_CONFIG).getValues().get(3);
}
this.chromatticLifeCycle = chromatticManager.getLifeCycle(lifecycleName);
+
+ //Set the default codec
+ this.codec = new ToThrowAwayCodec();
}
+ public final void setupCodec(ComponentPlugin codecPlugin)
+ {
+ if(codecPlugin instanceof AbstractCodec)
+ {
+ this.codec = (AbstractCodec)codecPlugin;
+ }
+ }
+
public String createToken(final Credentials credentials)
{
if (validityMillis < 0)
@@ -76,7 +91,9 @@
long expirationTimeMillis = System.currentTimeMillis() + validityMillis;
GateInToken token = new GateInToken(expirationTimeMillis, credentials);
TokenContainer container = getTokenContainer();
- container.saveToken(tokenId, token.getPayload(), new Date(token.getExpirationTimeMillis()));
+
+ //Save the token, password is encoded thanks to the codec
+ container.encodeAndSaveToken(tokenId, token.getPayload(), new Date(expirationTimeMillis), codec);
return tokenId;
}
}.executeWith(chromatticLifeCycle);
@@ -89,7 +106,8 @@
@Override
protected GateInToken execute()
{
- return getTokenContainer().getToken((String)id);
+ //Get the token, encoded password is decoded thanks to codec
+ return getTokenContainer().getTokenAndDecode(id, codec);
}
}.executeWith(chromatticLifeCycle);
}
Copied: portal/branches/wci/component/web/security/src/main/java/org/exoplatform/web/security/security/ToThrowAwayCodec.java (from rev 5342, portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/security/ToThrowAwayCodec.java)
===================================================================
--- portal/branches/wci/component/web/security/src/main/java/org/exoplatform/web/security/security/ToThrowAwayCodec.java (rev 0)
+++ portal/branches/wci/component/web/security/src/main/java/org/exoplatform/web/security/security/ToThrowAwayCodec.java 2010-11-29 16:47:37 UTC (rev 5356)
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.web.security.security;
+
+/**
+ * @author <a href="mailto:hoang281283@gmail.com">Minh Hoang TO</a>
+ * Nov 19, 2010
+ */
+
+public class ToThrowAwayCodec extends AbstractCodec
+{
+
+ @Override
+ public String decode(String encodedInput)
+ {
+ return encodedInput;
+ }
+
+ @Override
+ public String encode(String plainInput)
+ {
+ return plainInput;
+ }
+
+}
Modified: portal/branches/wci/component/web/security/src/main/java/org/exoplatform/web/security/security/TokenContainer.java
===================================================================
--- portal/branches/wci/component/web/security/src/main/java/org/exoplatform/web/security/security/TokenContainer.java 2010-11-29 15:35:58 UTC (rev 5355)
+++ portal/branches/wci/component/web/security/src/main/java/org/exoplatform/web/security/security/TokenContainer.java 2010-11-29 16:47:37 UTC (rev 5356)
@@ -84,5 +84,37 @@
entry.setExpirationTime(expirationTime);
return entry.getToken();
}
+
+ public GateInToken encodeAndSaveToken(String tokenId, Credentials credentials, Date expirationTime, AbstractCodec codec)
+ {
+ Map<String, TokenEntry> tokens = getTokens();
+ TokenEntry entry = tokens.get(tokenId);
+ if (entry == null)
+ {
+ entry = createToken();
+ tokens.put(tokenId, entry);
+ entry.setUserName(credentials.getUsername());
+ entry.setPassword(codec.encode(credentials.getPassword()));
+ }
+ entry.setExpirationTime(expirationTime);
+ return entry.getToken();
+ }
+
+ public GateInToken getTokenAndDecode(String tokenId, AbstractCodec codec)
+ {
+ Map<String, TokenEntry> tokens = getTokens();
+ TokenEntry entry = tokens.get(tokenId);
+ if(entry != null)
+ {
+ GateInToken gateInToken = entry.getToken();
+ Credentials payload = gateInToken.getPayload();
+
+ //Return a cloned GateInToken
+ return new GateInToken(gateInToken.getExpirationTimeMillis(), new Credentials(payload.getUsername(), codec
+ .decode(payload.getPassword())));
+ }
+ return null;
+ }
+
}
Modified: portal/branches/wci/component/web/server/src/main/java/org/exoplatform/upload/UploadService.java
===================================================================
--- portal/branches/wci/component/web/server/src/main/java/org/exoplatform/upload/UploadService.java 2010-11-29 15:35:58 UTC (rev 5355)
+++ portal/branches/wci/component/web/server/src/main/java/org/exoplatform/upload/UploadService.java 2010-11-29 16:47:37 UTC (rev 5356)
@@ -109,6 +109,9 @@
DiskFileItem fileItem = (DiskFileItem)itemList.get(0);
String fileName = fileItem.getName();
+ if (fileName == null)
+ fileName = uploadId;
+ fileName = fileName.substring(fileName.lastIndexOf('\\') + 1);
String storeLocation = uploadLocation_ + "/" + uploadId + "." + fileName;
// commons-fileupload will store the temp file with name *.tmp
Copied: portal/branches/wci/docs/reference-guide/en/modules/PortalDevelopment/LocalizationConfiguration.xml (from rev 5342, portal/trunk/docs/reference-guide/en/modules/PortalDevelopment/LocalizationConfiguration.xml)
===================================================================
--- portal/branches/wci/docs/reference-guide/en/modules/PortalDevelopment/LocalizationConfiguration.xml (rev 0)
+++ portal/branches/wci/docs/reference-guide/en/modules/PortalDevelopment/LocalizationConfiguration.xml 2010-11-29 16:47:37 UTC (rev 5356)
@@ -0,0 +1,274 @@
+<?xml version='1.0' encoding='utf-8' ?>
+<!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
+<!ENTITY % BOOK_ENTITIES SYSTEM "../../Reference_Guide.ent">
+%BOOK_ENTITIES;
+]>
+
+<section id="sect-Reference_Guide-Localization_Configuration-Pluggable_Locale_Policy">
+ <title>Pluggable Locale Policy</title>
+
+ <para>Every request processed by every portlet is invoked within a context of current <literal>Locale</literal>.
+ Current <literal>Locale</literal> can be retrieved by calling <literal>getLocale()</literal> method of
+ <literal>javax.portlet.PortletRequest</literal> interface.
+ </para>
+ <para>The exact algorithm for determining the current <literal>Locale</literal> is not specified by Portlet Specification,
+ and is left to portlet containers to implement the way they deem most appropriate.
+ </para>
+ <para>In &PRODUCT; each portal instance has a default language which can be used to present content for new users.
+ Another option is to use each user’s browser language preference, provided it matches one of the available
+ localizations that &PRODUCT; supports, and only fallback to portal default language if no match is found.
+ Every user, while visiting a portal, has an option to change the language of the user interface by using a Language chooser.
+ The choice can be remembered for the duration of the session, or it can be remembered for a longer period using a browser cookie,
+ or - for registered and logged-in users - it can be saved into user’s profile.
+ </para>
+ <para>So, we can see that there is more than one way to determine the <literal>Locale</literal> to be used for displaying a portal page
+ to the user. For this reason the mechanism for determining the current <literal>Locale</literal> of the request
+ is pluggable in &PRODUCT;, so the exact algorithm can be customized.
+ </para>
+
+ <section id="sect-Reference_Guide-Localization_Configuration-Pluggable_Locale_Policy-Locale_Policy_API">
+ <title>LocalePolicy API</title>
+
+ <para>Customization is achieved by using LocalePolicy API, which is a simple API consisting of one interface,
+ and one class:
+ </para>
+ <itemizedlist>
+ <listitem>
+ <para><literal>org.exoplatform.services.resources.LocalePolicy</literal> interface</para>
+ </listitem>
+ <listitem>
+ <para><literal>org.exoplatform.services.resources.LocaleContextInfo</literal> class</para>
+ </listitem>
+ </itemizedlist>
+
+ <para><literal>LocalePolicy</literal> interface defines a single method that’s invoked on the installed
+ <literal>LocalePolicy</literal> service implementation:
+ </para>
+
+ <programlisting><![CDATA[public interface LocalePolicy
+{
+ public Locale determineLocale(LocaleContextInfo localeContext);
+}]]>
+ </programlisting>
+ <para><literal>Locale</literal> returned by determineLocale() method is the <literal>Locale</literal>
+ that will be returned to portlets when they call <literal>javax.portlet.PortletRequest.getLocale()</literal> method.
+ </para>
+ <para>The returned <literal>Locale</literal> has to be one of the locales supported by portal,
+ otherwise it will fallback to portal-default <literal>Locale</literal>.
+ </para>
+
+ <para>The supported locales are listed in <filename>gatein.ear/02portal.war/WEB-INF/conf/common/locales-config.xml</filename> file
+ as described in <xref linkend="sect-Reference_Guide-Internationalization_Configuration-Locales_configuration"/> .
+ </para>
+
+ <para>The <literal>determineLocale()</literal> method takes a parameter of type <literal>LocaleContextInfo</literal>,
+ which represents a compilation of preferred locales from different sources - user’s profile, portal default,
+ browser language settings, current session, browser cookie … All these different sources of <literal>Locale</literal>
+ configuration or preference are used as input to <literal>LocalePolicy</literal> implementation
+ that decides which <literal>Locale</literal> should be used.
+ </para>
+
+ </section>
+ <section id="sect-Reference_Guide-Localization_Configuration-Pluggable_Locale_Policy-Default_LocalePolicy">
+ <title>Default <literal>LocalePolicy</literal></title>
+ <para>By default, <literal>org.exoplatform.portal.application.localization.DefaultLocalePolicyService</literal> - an implementation
+ of <literal>LocalePolicy</literal> - is installed to provide the default behaviour.
+ This, however, can easily be extended and overriden. A completely new implementation can also be written from scratch.
+ </para>
+ <para><literal>DefaultLocalePolicyService</literal> treats logged-in users slightly differently than anonymous users.
+ Logged-in users have a profile that can contain language preference, while anonymous users don't.
+ </para>
+ <para>Here is an algorithm used for anonymous users.</para>
+ <procedure>
+ <title>An algorithm for anonymous users</title>
+ <step>
+ <para>
+ Iterate over <literal>LocaleContextInfo</literal> properties in the following order:
+ </para>
+ <itemizedlist>
+ <listitem>
+ <para><literal>cookieLocales</literal></para>
+ </listitem>
+ <listitem>
+ <para><literal>sessionLocale</literal></para>
+ </listitem>
+ <listitem>
+ <para><literal>browserLocales</literal></para>
+ </listitem>
+ <listitem>
+ <para><literal>portalLocale</literal></para>
+ </listitem>
+ </itemizedlist>
+ </step>
+ <step>
+ <para>Get each property's value - if it's a collection, get the first value.
+ </para>
+ </step>
+ <step>
+ <para>If value is one of the supported locales return it as a result.
+ </para>
+ </step>
+ <step>
+ <para>If value is not in the supported locales set, try to remove country information,
+ and check if a language matching locale is in the list of supported locales.
+ If so, return it as a result.
+ </para>
+ </step>
+ <step>
+ <para>Otherwise, continue with the next property.
+ </para>
+ </step>
+ </procedure>
+ <para>If no supported locale is found the return locale eventually defaults to <literal>portalLocale</literal>.
+ </para>
+ <para>The algorithm for logged-in users is virtually the same except that the first <literal>Locale</literal>
+ source checked is user's profile.</para>
+ <procedure>
+ <title>An algorithm for logged-in users</title>
+ <step>
+ <para>
+ Iterate over <literal>LocaleContextInfo</literal> properties in the following order:
+ </para>
+ <itemizedlist>
+ <listitem>
+ <para><literal>userProfile</literal></para>
+ </listitem>
+ <listitem>
+ <para><literal>cookieLocales</literal></para>
+ </listitem>
+ <listitem>
+ <para><literal>sessionLocale</literal></para>
+ </listitem>
+ <listitem>
+ <para><literal>browserLocales</literal></para>
+ </listitem>
+ <listitem>
+ <para><literal>portalLocale</literal></para>
+ </listitem>
+ </itemizedlist>
+ </step>
+ <step>
+ <para>The rest is the same as for anonymous users ...</para>
+ </step>
+ </procedure>
+
+ </section>
+ <section id="sect-Reference_Guide-Localization_Configuration-Pluggable_Locale_Policy-Custom_LocalePolicy">
+ <title>Custom <literal>LocalePolicy</literal></title>
+ <para>The easiest way to customize the <literal>LocalePolicy</literal> is to extend <literal>DefaultLocalePolicyService</literal>.
+ The study of its source code will be required. There is ample JavaDoc that provides thorough information.
+ Most customizations will involve simply overriding one or more of its protected methods.
+ </para>
+ <para>
+ An example of a customization is an already provided <literal>NoBrowserLocalePolicyService</literal>.
+ By overriding just one method, it skips any use of browser language preference.
+ </para>
+ <programlisting><![CDATA[public class NoBrowserLocalePolicyService extends DefaultLocalePolicyService
+{
+ /**
+ * Override super method with no-op.
+ *
+ * @param context locale context info available to implementations in order to determine appropriate Locale
+ * @return null
+ */
+ @Override
+ protected Locale getLocaleConfigFromBrowser(LocaleContextInfo context)
+ {
+ return null;
+ }
+}]]>
+ </programlisting>
+ </section>
+
+ <section id="sect-Reference_Guide-Localization_Configuration-Pluggable_Locale_Policy-Configuration">
+ <title>LocalePolicy Configuration</title>
+
+ <para>The <literal>LocalePolicy</literal> framework is enabled for portlets by configuring LocalizationLifecycle class in portal's webui configuration file:
+ <filename>gatein.ear/02portal.war/WEB-INF/webui-configuration.xml</filename>:</para>
+
+ <programlisting role="XML"><![CDATA[ <application-lifecycle-listeners>
+ ...
+ <listener>org.exoplatform.portal.application.localization.LocalizationLifecycle</listener>
+ </application-lifecycle-listeners>]]>
+ </programlisting>
+
+ <para>The default <literal>LocalePolicy</literal> implementation is installed as GateIn Kernel portal service via
+ <filename>gatein.ear/lib/exo.portal.webui.portal-VERSION.jar/conf/portal/configuration.xml</filename>.
+ </para>
+ <para>The following fragment is responsible for installing the service:
+ </para>
+ <programlisting role="XML"><![CDATA[ <component>
+ <key>org.exoplatform.services.resources.LocalePolicy</key>
+ <type>org.exoplatform.portal.application.localization.DefaultLocalePolicyService</type>
+ </component>]]>
+ </programlisting>
+ <para>Besides implementing <literal>LocalePolicy</literal>, the service class also needs to implement
+ <literal>org.picocontainer.Startable</literal> interface in order to get installed.
+ </para>
+ <para>This configuration file should not be changed. The configuration in it can be overriden by placing it into portal's .war file:
+ <filename>gatein.ear/02portal.war/WEB-INF/conf/configuration.xml</filename> (usually as another file included into this one).
+ </para>
+ </section>
+
+ <section id="sect-Reference_Guide-Localization_Configuration-Pluggable_Locale_Policy-Non_bridged">
+ <title>Keeping non-bridged resources in sync with current Locale</title>
+ <para>In portals all the resources that are not portlets themselves but are accessed through portlets - reading
+ data through <literal>PortletRequest</literal>, and writing to <literal>PortletResponse</literal> - are
+ referred to as 'bridged'. Any resources that are accessed directly, bypassing portal filters and servlets,
+ are referred to as 'non-bridged'.
+ </para>
+ <para>Non-bridged servlets, and .jsps have no access to <literal>PortalRequest</literal>. They don't use
+ <literal>PortletRequest.getLocale()</literal> to determine current <literal>Locale</literal>.
+ Instead, they use <literal>ServletRequest.getLocale()</literal> which is subject to precise semantics
+ defined by Servlet specification - it reflects browser's language preference.
+ </para>
+ <para>In other words, non-bridged resources don't have a notion of current <literal>Locale</literal>
+ in the same sense that portlets do. The result is that when mixing portlets and non-bridged resources there
+ may be a localization mismatch - an inconsistency in the language used by different resources composing your portal
+ page.
+ </para>
+ <para>This problem is addressed by <literal>LocalizationFilter</literal>. This is a filter that changes the behaviour
+ of <literal>ServletRequest.getLocale()</literal> method so that it behaves the same way as
+ <literal>PortletRequest.getLocale()</literal>. That way even localization of servlets, and .jsps
+ accessed in a non-bridged manner can stay in sync with portlet localization.
+ </para>
+ <para><literal>LocalizationFilter</literal> is installed through portal's web.xml file: <filename>gatein.ear/02portal.war/WEB-INF/web.xml</filename>
+ </para>
+ <programlisting role="XML"><![CDATA[ <filter>
+ <filter-name>LocalizationFilter</filter-name>
+ <filter-class>org.exoplatform.portal.application.localization.LocalizationFilter</filter-class>
+ </filter>
+
+ ...
+
+ <filter-mapping>
+ <filter-name>LocalizationFilter</filter-name>
+ <url-pattern>/*</url-pattern>
+ <dispatcher>INCLUDE</dispatcher>
+ <dispatcher>FORWARD</dispatcher>
+ <dispatcher>REQUEST</dispatcher>
+ <dispatcher>ERROR</dispatcher>
+ </filter-mapping>]]>
+ </programlisting>
+ <para>There is a tiny limitation with this mechanism in that it is unable to determine the current portal,
+ and consequently its default language. As a result the portalLocale defaults to <literal>English</literal>, but can be configured
+ to something else by using filter's <literal>PortalLocale</literal> init param. For example:
+ </para>
+ <programlisting role="XML"><![CDATA[ <filter>
+ <filter-name>LocalizationFilter</filter-name>
+ <filter-class>org.exoplatform.portal.application.localization.LocalizationFilter</filter-class>
+ <init-param>
+ <param-name>PortalLocale</param-name>
+ <param-value>fr_FR</param-value>
+ </init-param>
+ </filter> ]]>
+ </programlisting>
+ <para>By default, <literal>LocalizationFilter</literal> is applied very broadly to cover all the resources automatically.
+ &PRODUCT; uses some non-bridged .jsps that require <literal>LocalizationFilter</literal>, so narrowing
+ the mapping to *.jsp is enough for &PRODUCT; to still function correctly. Additionally deployed portlets,
+ and portal applications, however, may require broader mapping to cover their non-bridged resources.
+ </para>
+ <para>Narrowing the mapping might improve performance. This is something to consider, when optimizing for speed.
+ </para>
+ </section>
+ </section>
\ No newline at end of file
Modified: portal/branches/wci/docs/reference-guide/en/modules/PortalDevelopment.xml
===================================================================
--- portal/branches/wci/docs/reference-guide/en/modules/PortalDevelopment.xml 2010-11-29 15:35:58 UTC (rev 5355)
+++ portal/branches/wci/docs/reference-guide/en/modules/PortalDevelopment.xml 2010-11-29 16:47:37 UTC (rev 5356)
@@ -11,6 +11,7 @@
<xi:include href="PortalDevelopment/DefaultPortalPermissionConfiguration.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
<xi:include href="PortalDevelopment/DefaultPortalNavigationConfiguration.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
<xi:include href="PortalDevelopment/InternationalizationConfiguration.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
+ <xi:include href="PortalDevelopment/LocalizationConfiguration.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
<xi:include href="PortalDevelopment/RTLFramework.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
<xi:include href="PortalDevelopment/XMLResourceBundles.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
<xi:include href="PortalDevelopment/JavascriptInterApplicationCommunication.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
Modified: portal/branches/wci/examples/portal/war/src/main/webapp/WEB-INF/web.xml
===================================================================
--- portal/branches/wci/examples/portal/war/src/main/webapp/WEB-INF/web.xml 2010-11-29 15:35:58 UTC (rev 5355)
+++ portal/branches/wci/examples/portal/war/src/main/webapp/WEB-INF/web.xml 2010-11-29 16:47:37 UTC (rev 5356)
@@ -252,10 +252,6 @@
<url-pattern>/gateinservlet</url-pattern>
</servlet-mapping>
- <session-config>
- <session-timeout>30</session-timeout>
- </session-config>
-
<!-- The Welcome File List for IBM WebSphere -->
<welcome-file-list>
Modified: portal/branches/wci/gadgets/core/src/main/java/org/exoplatform/portal/gadget/core/ProxyServletFilter.java
===================================================================
--- portal/branches/wci/gadgets/core/src/main/java/org/exoplatform/portal/gadget/core/ProxyServletFilter.java 2010-11-29 15:35:58 UTC (rev 5355)
+++ portal/branches/wci/gadgets/core/src/main/java/org/exoplatform/portal/gadget/core/ProxyServletFilter.java 2010-11-29 16:47:37 UTC (rev 5356)
@@ -22,6 +22,9 @@
import org.exoplatform.container.PortalContainer;
import org.exoplatform.web.security.proxy.ProxyFilterService;
+import org.gatein.common.logging.LoggerFactory;
+import org.gatein.common.logging.Logger;
+
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
@@ -57,6 +60,9 @@
/** . */
private ServletContext ctx;
+ /** . */
+ private static final Logger logger = LoggerFactory.getLogger(ProxyServletFilter.class);
+
public void init(FilterConfig cfg) throws ServletException
{
this.ctx = cfg.getServletContext();
@@ -90,14 +96,23 @@
}
else
{
- URI uri = URI.create(url);
- if (!service.accept(hreq, container, uri))
+ try
{
- hresp.sendError(HttpServletResponse.SC_FORBIDDEN, "Gadget " + url + " is blacklisted");
+ URI uri = URI.create(url);
+ if (!service.accept(hreq, container, uri))
+ {
+ hresp.sendError(HttpServletResponse.SC_FORBIDDEN, "Gadget " + url + " is blacklisted");
+ }
+ else
+ {
+ chain.doFilter(req, resp);
+ }
+
}
- else
+ catch (java.lang.IllegalArgumentException e)
{
- chain.doFilter(req, resp);
+ // It happens that some URLs can be wrong, I've seen this with "http://" as URL in one of the Google Gadgets
+ logger.debug("Invalid URL: " + url);
}
}
}
Modified: portal/branches/wci/gadgets/eXoGadgets/src/main/webapp/gadgets/rssAggregator/script.js
===================================================================
--- portal/branches/wci/gadgets/eXoGadgets/src/main/webapp/gadgets/rssAggregator/script.js 2010-11-29 15:35:58 UTC (rev 5355)
+++ portal/branches/wci/gadgets/eXoGadgets/src/main/webapp/gadgets/rssAggregator/script.js 2010-11-29 16:47:37 UTC (rev 5356)
@@ -43,7 +43,7 @@
if (isNaN(B)) {
return "an indeterminate amount of time ago"
}
- time = (new Date().getTime() 1000 - B) / 1000;
+ time = (new Date().getTime()*1000 - B) / 1000;
if (time < 60) {
return "less than a minute ago"
} else {
Property changes on: portal/branches/wci/packaging/tomcat/integration
___________________________________________________________________
Name: svn:ignore
+ target
Modified: portal/branches/wci/pom.xml
===================================================================
--- portal/branches/wci/pom.xml 2010-11-29 15:35:58 UTC (rev 5355)
+++ portal/branches/wci/pom.xml 2010-11-29 16:47:37 UTC (rev 5356)
@@ -47,8 +47,8 @@
<org.gatein.common.version>2.0.3-GA</org.gatein.common.version>
<org.gatein.wci.version>2.1.0-Alpha01-SNAPSHOT</org.gatein.wci.version>
<org.gatein.pc.version>2.2.0-GA</org.gatein.pc.version>
- <org.picketlink.idm>1.1.7.CR01</org.picketlink.idm>
- <org.gatein.wsrp.version>2.0.0-CR02</org.gatein.wsrp.version>
+ <org.picketlink.idm>1.1.7.GA</org.picketlink.idm>
+ <org.gatein.wsrp.version>2.0.0-CR03</org.gatein.wsrp.version>
<org.gatein.mop.version>1.0.3-GA</org.gatein.mop.version>
<org.slf4j.version>1.5.6</org.slf4j.version>
<rhino.version>1.6R5</rhino.version>
@@ -1346,6 +1346,12 @@
<version>5.1.6</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.14</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
<plugins>
Modified: portal/branches/wci/portlet/dashboard/src/main/java/org/exoplatform/gadget/webui/component/UIGadgetPortlet.java
===================================================================
--- portal/branches/wci/portlet/dashboard/src/main/java/org/exoplatform/gadget/webui/component/UIGadgetPortlet.java 2010-11-29 15:35:58 UTC (rev 5355)
+++ portal/branches/wci/portlet/dashboard/src/main/java/org/exoplatform/gadget/webui/component/UIGadgetPortlet.java 2010-11-29 16:47:37 UTC (rev 5356)
@@ -20,8 +20,8 @@
package org.exoplatform.gadget.webui.component;
import org.exoplatform.application.gadget.Gadget;
+import org.exoplatform.application.gadget.GadgetImporter;
import org.exoplatform.application.gadget.GadgetRegistryService;
-import org.exoplatform.application.gadget.LocalImporter;
import org.exoplatform.container.ExoContainer;
import org.exoplatform.container.ExoContainerContext;
import org.exoplatform.portal.webui.application.GadgetUtil;
@@ -50,7 +50,7 @@
{
final static public String LOCAL_STRING = "local://";
- private static final Logger log = LoggerFactory.getLogger(LocalImporter.class);
+ private static final Logger log = LoggerFactory.getLogger(GadgetImporter.class);
public UIGadgetPortlet() throws Exception
{
Modified: portal/branches/wci/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/UIUserToolBarGroupPortlet.java
===================================================================
--- portal/branches/wci/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/UIUserToolBarGroupPortlet.java 2010-11-29 15:35:58 UTC (rev 5355)
+++ portal/branches/wci/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/UIUserToolBarGroupPortlet.java 2010-11-29 16:47:37 UTC (rev 5356)
@@ -55,7 +55,7 @@
{
if (navigation.getOwnerType().equals(PortalConfig.GROUP_TYPE))
{
- navigations.add(PageNavigationUtils.filter(navigation, remoteUser));
+ navigations.add(PageNavigationUtils.filterNavigation(navigation, remoteUser, false, true));
}
}
return navigations;
Modified: portal/branches/wci/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/UIUserToolBarSitePortlet.java
===================================================================
--- portal/branches/wci/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/UIUserToolBarSitePortlet.java 2010-11-29 15:35:58 UTC (rev 5355)
+++ portal/branches/wci/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/UIUserToolBarSitePortlet.java 2010-11-29 16:47:37 UTC (rev 5356)
@@ -68,7 +68,7 @@
{
PageNavigation navi = getPageNavigation(PortalConfig.PORTAL_TYPE + "::" + getCurrentPortal());
String remoteUser = Util.getPortalRequestContext().getRemoteUser();
- return PageNavigationUtils.filter(navi, remoteUser);
+ return PageNavigationUtils.filterNavigation(navi, remoteUser, false, true);
}
private PageNavigation getPageNavigation(String owner) throws Exception
Modified: portal/branches/wci/portlet/exoadmin/src/main/webapp/groovy/applicationregistry/webui/component/UIGadgetInfo.gtmpl
===================================================================
--- portal/branches/wci/portlet/exoadmin/src/main/webapp/groovy/applicationregistry/webui/component/UIGadgetInfo.gtmpl 2010-11-29 15:35:58 UTC (rev 5355)
+++ portal/branches/wci/portlet/exoadmin/src/main/webapp/groovy/applicationregistry/webui/component/UIGadgetInfo.gtmpl 2010-11-29 16:47:37 UTC (rev 5356)
@@ -11,6 +11,9 @@
if(gadgetThumbnail == null || gadgetThumbnail.length() == 0){
gadgetThumbnail = srcBGError ;
}
+ def viewURL = uicomponent.getViewUrl();
+ def editURL = uicomponent.getEditUrl();
+ def refURL = gadget.getReferenceUrl();
%>
<div class="UIGadgetInfo" id="$uicomponent.id">
<div class="UIBreadcumb">
@@ -21,7 +24,7 @@
<div class="Refresh16x16Icon ControlIcon" title="<%=_ctx.appRes("UIGadgetInfo.title.refresh")%>" onclick="<%= uicomponent.event("Refresh") %>"><span></span></div>
<div class="ClearBoth"><span></span></div>
</div>
- <div class="Application ClearFix">
+ <div class="Application">
<div class="PortletIcons">
<img src="$gadgetThumbnail" onError="src='$srcBGError'" alt=""/>
</div>
@@ -41,12 +44,12 @@
<table>
<tr>
<td class="LeftLabel"><%=_ctx.appRes("UIGadgetInfo.label.viewUrl")%></td>
- <td class="RightLabel" title=" <%= uicomponent.getViewUrl() %> "><%= uicomponent.getViewUrl() %></td>
+ <td class="RightLabel" title=" <%=viewURL %> "><a href="<%=viewURL %>" target="_blank">$viewURL</a></td>
</tr>
<% if(gadget.isLocal()) {%>
<tr>
<td class="LeftLabel"><%=_ctx.appRes("UIGadgetInfo.label.editUrl")%></td>
- <td class="RightLabel"><%= uicomponent.getEditUrl() %></td>
+ <td class="RightLabel"><a href="<%=editURL %>" target="_blank">$editURL</a></td>
</tr>
<% } %>
</table>
@@ -54,7 +57,7 @@
<tr>
<td class="LeftLabel"><%=_ctx.appRes("UIGadgetInfo.label.reference")%></td>
<td class="RightLabel">
- <%= gadget.getReferenceUrl() %>
+ <a href="<%=refURL %>" target="_blank">$refURL</a>
</td>
</tr>
</table>
Modified: portal/branches/wci/portlet/exoadmin/src/main/webapp/skin/organization/webui/component/UIOrganizationPortlet/DefaultStylesheet.css
===================================================================
--- portal/branches/wci/portlet/exoadmin/src/main/webapp/skin/organization/webui/component/UIOrganizationPortlet/DefaultStylesheet.css 2010-11-29 15:35:58 UTC (rev 5355)
+++ portal/branches/wci/portlet/exoadmin/src/main/webapp/skin/organization/webui/component/UIOrganizationPortlet/DefaultStylesheet.css 2010-11-29 16:47:37 UTC (rev 5356)
@@ -168,6 +168,7 @@
float: left; /* orientation=lt */
float: right; /* orientation=rt */
height: auto;
+ width: 100%;
}
.UIOrganizationPortlet .UISearch .UISearchForm .QuickSet {
Modified: portal/branches/wci/portlet/web/src/main/webapp/groovy/portal/webui/component/UIPortalNavigation.gtmpl
===================================================================
--- portal/branches/wci/portlet/web/src/main/webapp/groovy/portal/webui/component/UIPortalNavigation.gtmpl 2010-11-29 15:35:58 UTC (rev 5355)
+++ portal/branches/wci/portlet/web/src/main/webapp/groovy/portal/webui/component/UIPortalNavigation.gtmpl 2010-11-29 16:47:37 UTC (rev 5356)
@@ -95,7 +95,7 @@
<div class="MenuItem $tabStyleNavigation">
<div class="$arrowIcon" title="$title">
<div class="ItemIcon $icon">
- <a href="$pageURI">$label</a>
+ <a href="#">$label</a>
</div>
</div>
""";
Modified: portal/branches/wci/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/NewSnifftest/Test_SNF_PRL_37_ManageNavigationOfGroup.html
===================================================================
--- portal/branches/wci/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/NewSnifftest/Test_SNF_PRL_37_ManageNavigationOfGroup.html 2010-11-29 15:35:58 UTC (rev 5355)
+++ portal/branches/wci/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/NewSnifftest/Test_SNF_PRL_37_ManageNavigationOfGroup.html 2010-11-29 16:47:37 UTC (rev 5356)
@@ -118,12 +118,12 @@
</tr>
<tr>
<td>waitForElementPresent</td>
- <td>//div[@id='UIAddGroupNavigationGrid']/table[1]/tbody/tr/td[2]/a</td>
+ <td>//div[@id='UIAddGroupNavigationGrid']/table[2]/tbody/tr/td[2]/a</td>
<td></td>
</tr>
<tr>
<td>click</td>
- <td>//div[@id='UIAddGroupNavigationGrid']/table[1]/tbody/tr/td[2]/a</td>
+ <td>//div[@id='UIAddGroupNavigationGrid']/table[2]/tbody/tr/td[2]/a</td>
<td></td>
</tr>
<tr>
@@ -138,12 +138,12 @@
</tr>
<tr>
<td>waitForTextPresent</td>
- <td>Operations</td>
+ <td>Organization</td>
<td></td>
</tr>
<tr>
<td>verifyTextPresent</td>
- <td>Operations</td>
+ <td>Organization</td>
<td></td>
</tr>
<tr>
@@ -153,12 +153,12 @@
</tr>
<tr>
<td>waitForElementPresent</td>
- <td>//div[@id='UIGroupNavigationGrid']/table[2]/tbody/tr/td[3]/a[3]</td>
+ <td>link=Delete Navigation</td>
<td></td>
</tr>
<tr>
<td>click</td>
- <td>//div[@id='UIGroupNavigationGrid']/table[2]/tbody/tr/td[3]/a[3]</td>
+ <td>link=Delete Navigation</td>
<td></td>
</tr>
<tr>
@@ -173,12 +173,12 @@
</tr>
<tr>
<td>waitForTextNotPresent</td>
- <td>Operations</td>
+ <td>Organization</td>
<td></td>
</tr>
<tr>
<td>verifyTextNotPresent</td>
- <td>Operations</td>
+ <td>Organization</td>
<td></td>
</tr>
<tr>
Modified: portal/branches/wci/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/NewSnifftest/Test_SNF_PRL_49_ChangeApplicationWhenEditPagePropertiesOfNode.html
===================================================================
--- portal/branches/wci/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/NewSnifftest/Test_SNF_PRL_49_ChangeApplicationWhenEditPagePropertiesOfNode.html 2010-11-29 15:35:58 UTC (rev 5355)
+++ portal/branches/wci/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/NewSnifftest/Test_SNF_PRL_49_ChangeApplicationWhenEditPagePropertiesOfNode.html 2010-11-29 16:47:37 UTC (rev 5356)
@@ -503,7 +503,7 @@
</tr>
<tr>
<td>mouseOver</td>
- <td>//div[2]/div/div[2]/div/div/div[2]/div/div/div/div/div/div/div[2]</td>
+ <td>//div/div/div[2]/div/div/div/div/div/div/div[2]</td>
<td>Test_SNF_PRL_49</td>
</tr>
<tr>
@@ -538,17 +538,17 @@
</tr>
<tr>
<td>mouseOver</td>
- <td>//div[2]/div/div[2]/div/div/div[2]/div/div/div/div/div/div/div[2]</td>
+ <td>//div/div/div[2]/div/div/div/div/div/div/div[2]</td>
<td>Test_SNF_PRL_49</td>
</tr>
<tr>
<td>waitForElementPresent</td>
- <td>//div[2]/div/div[2]/div/div/div[2]/div/div/div/div/div/div/a[2]</td>
+ <td>//div/div/div[2]/div/div/div/div/div/div/a[2]</td>
<td></td>
</tr>
<tr>
<td>click</td>
- <td>//div[2]/div/div[2]/div/div/div[2]/div/div/div/div/div/div/a[2]</td>
+ <td>//div/div/div[2]/div/div/div/div/div/div/a[2]</td>
<td></td>
</tr>
<tr>
Modified: portal/branches/wci/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_PRL_03_01_001_CheckShowingGroupManagementForm.html
===================================================================
--- portal/branches/wci/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_PRL_03_01_001_CheckShowingGroupManagementForm.html 2010-11-29 15:35:58 UTC (rev 5355)
+++ portal/branches/wci/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_PRL_03_01_001_CheckShowingGroupManagementForm.html 2010-11-29 16:47:37 UTC (rev 5356)
@@ -123,13 +123,13 @@
</tr>
<tr>
<td>waitForTextPresent</td>
- <td>//div[@id='UIOrganizationPortlet']/div[2]/div[2]/div[1]/div[2]/div[1]/div[2]/div/div/div/div[3]/div[1]/a</td>
+ <td>Organization</td>
<td></td>
</tr>
<tr>
- <td>verifyText</td>
- <td>//div[@id='UIOrganizationPortlet']/div[2]/div[2]/div[1]/div[2]/div[1]/div[2]/div/div/div/div[3]/div[1]/a</td>
+ <td>verifyTextPresent</td>
<td>Organization</td>
+ <td></td>
</tr>
<tr>
<td>echo</td>
@@ -183,12 +183,12 @@
</tr>
<tr>
<td>waitForTextPresent</td>
- <td>link=Customers</td>
+ <td>Customers</td>
<td></td>
</tr>
<tr>
<td>verifyTextPresent</td>
- <td>link=Customers</td>
+ <td>Customers</td>
<td></td>
</tr>
<tr>
@@ -207,12 +207,12 @@
<td></td>
</tr>
<tr>
- <td>waitForTextPresent</td>
+ <td>waitForElementPresent</td>
<td>//div[1]/div[2]/div/div/div/div[1]/a</td>
<td></td>
</tr>
<tr>
- <td>verifyTextPresent</td>
+ <td>verifyElementPresent</td>
<td>//div[1]/div[2]/div/div/div/div[1]/a</td>
<td></td>
</tr>
Modified: portal/branches/wci/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_PRL_03_05_012_AddSomeUsersIntoGroupInCaseAfterCommaHasSpace.html
===================================================================
--- portal/branches/wci/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_PRL_03_05_012_AddSomeUsersIntoGroupInCaseAfterCommaHasSpace.html 2010-11-29 15:35:58 UTC (rev 5355)
+++ portal/branches/wci/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_PRL_03_05_012_AddSomeUsersIntoGroupInCaseAfterCommaHasSpace.html 2010-11-29 16:47:37 UTC (rev 5356)
@@ -102,6 +102,11 @@
<td>root, john, demo</td>
</tr>
<tr>
+ <td>echo</td>
+ <td>-- http://jira.exoplatform.org/browse/SELEGEN-37 --</td>
+ <td></td>
+</tr>
+<tr>
<td>waitForElementPresent</td>
<td>membership</td>
<td></td>
Modified: portal/branches/wci/testsuite/testdefinitions/GateIn_v3.2.x_MainFunctions_TestDefinition.ods
===================================================================
(Binary files differ)
Modified: portal/branches/wci/web/eXoResources/src/main/webapp/skin/DefaultSkin/portal/webui/component/customization/UIPageBrowser/Stylesheet.css
===================================================================
--- portal/branches/wci/web/eXoResources/src/main/webapp/skin/DefaultSkin/portal/webui/component/customization/UIPageBrowser/Stylesheet.css 2010-11-29 15:35:58 UTC (rev 5355)
+++ portal/branches/wci/web/eXoResources/src/main/webapp/skin/DefaultSkin/portal/webui/component/customization/UIPageBrowser/Stylesheet.css 2010-11-29 16:47:37 UTC (rev 5356)
@@ -29,7 +29,7 @@
.UIPageBrowser .UIGrid {
width: 99.7%;
!width: 98%;
- margin: auto;
+ margin: 0px;
}
.UIPageBrowser .UIGrid .Text {
Modified: portal/branches/wci/web/portal/src/main/webapp/WEB-INF/conf/organization/picketlink-idm/jboss-cache-cluster.xml
===================================================================
--- portal/branches/wci/web/portal/src/main/webapp/WEB-INF/conf/organization/picketlink-idm/jboss-cache-cluster.xml 2010-11-29 15:35:58 UTC (rev 5355)
+++ portal/branches/wci/web/portal/src/main/webapp/WEB-INF/conf/organization/picketlink-idm/jboss-cache-cluster.xml 2010-11-29 16:47:37 UTC (rev 5356)
@@ -8,10 +8,11 @@
<!-- Eviction configuration -->
<eviction wakeUpInterval="5000">
- <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm"
+ <default algorithmClass="org.jboss.cache.eviction.ExpirationAlgorithm"
eventQueueSize="1000000">
- <property name="maxNodes" value="1000000" />
+ <property name="maxNodes" value="100000" />
<property name="timeToLive" value="120000" />
+ <property name="warnNoExpirationKey" value="false" />
</default>
</eviction>
Modified: portal/branches/wci/web/portal/src/main/webapp/WEB-INF/web.xml
===================================================================
--- portal/branches/wci/web/portal/src/main/webapp/WEB-INF/web.xml 2010-11-29 15:35:58 UTC (rev 5355)
+++ portal/branches/wci/web/portal/src/main/webapp/WEB-INF/web.xml 2010-11-29 16:47:37 UTC (rev 5356)
@@ -292,10 +292,6 @@
<url-pattern>/gateinservlet</url-pattern>
</servlet-mapping>
- <session-config>
- <session-timeout>30</session-timeout>
- </session-config>
-
<!-- The Welcome File List for IBM WebSphere -->
<welcome-file-list>
Modified: portal/branches/wci/web/portal/src/main/webapp/groovy/portal/webui/workspace/UIPortalApplication.gtmpl
===================================================================
--- portal/branches/wci/web/portal/src/main/webapp/groovy/portal/webui/workspace/UIPortalApplication.gtmpl 2010-11-29 15:35:58 UTC (rev 5355)
+++ portal/branches/wci/web/portal/src/main/webapp/groovy/portal/webui/workspace/UIPortalApplication.gtmpl 2010-11-29 16:47:37 UTC (rev 5356)
@@ -47,10 +47,12 @@
<link id="${portletSkin.id}" rel="stylesheet" type="text/css" href= "$url" />
<%}%>
<script type="text/javascript">
+ <%
// This variable must be used only to initialize other variables otherwise
// please use eXo.env.portal.context or eXo.env.portal.context instead
// Those 2 last variables cannot be used to initialize variables because
// we cannot be sure that they will be initialized before initializing your script
+ %>
var currentContext = '<%=docBase%>' ;
</script>
<%if(org.exoplatform.commons.utils.PropertyManager.isDevelopping()) {
Modified: portal/branches/wci/web/portal/src/main/webapp/index.jsp
===================================================================
--- portal/branches/wci/web/portal/src/main/webapp/index.jsp 2010-11-29 15:35:58 UTC (rev 5355)
+++ portal/branches/wci/web/portal/src/main/webapp/index.jsp 2010-11-29 16:47:37 UTC (rev 5356)
@@ -22,8 +22,14 @@
<%@ page import="org.exoplatform.container.PortalContainer"%>
<%@ page import="org.exoplatform.portal.config.UserPortalConfigService"%>
<%
- PortalContainer manager = PortalContainer.getCurrentInstance(session.getServletContext()) ;
- UserPortalConfigService userPortalConfigService = (UserPortalConfigService) manager.getComponentInstanceOfType(UserPortalConfigService.class) ;
- response.sendRedirect(request.getContextPath() + "/public/"+userPortalConfigService.getDefaultPortal()+"/");
+ PortalContainer manager = PortalContainer.getCurrentInstance(session.getServletContext());
+ UserPortalConfigService userPortalConfigService = (UserPortalConfigService)manager.getComponentInstanceOfType(UserPortalConfigService.class);
+ String remoteUser = request.getRemoteUser();
+ String accessMode = "public";
+ if (remoteUser != null && remoteUser.trim().length() > 0)
+ {
+ accessMode = "private";
+ }
+ response.sendRedirect(request.getContextPath() + "/" + accessMode + "/" + userPortalConfigService.getDefaultPortal() + "/");
%>
Modified: portal/branches/wci/web/rest/src/main/webapp/WEB-INF/web.xml
===================================================================
--- portal/branches/wci/web/rest/src/main/webapp/WEB-INF/web.xml 2010-11-29 15:35:58 UTC (rev 5355)
+++ portal/branches/wci/web/rest/src/main/webapp/WEB-INF/web.xml 2010-11-29 16:47:37 UTC (rev 5356)
@@ -84,10 +84,6 @@
<url-pattern>/*</url-pattern>
</servlet-mapping>
- <session-config>
- <session-timeout>30</session-timeout>
- </session-config>
-
<security-constraint>
<web-resource-collection>
<web-resource-name>rest</web-resource-name>
Modified: portal/branches/wci/webui/eXo/src/main/java/org/exoplatform/webui/organization/account/UIUserSelector.java
===================================================================
--- portal/branches/wci/webui/eXo/src/main/java/org/exoplatform/webui/organization/account/UIUserSelector.java 2010-11-29 15:35:58 UTC (rev 5355)
+++ portal/branches/wci/webui/eXo/src/main/java/org/exoplatform/webui/organization/account/UIUserSelector.java 2010-11-29 16:47:37 UTC (rev 5356)
@@ -412,7 +412,9 @@
uiSelectUserForm.setSelectedGroup(groupId);
OrganizationService service = uiSelectGroupForm.getApplicationComponent(OrganizationService.class);
PageList users = uiSelectUserForm.removeDuplicate(service.getUserHandler().findUsersByGroup(groupId));
+ users.setPageSize(10);
uiSelectUserForm.uiIterator_.setPageList(users);
+ uiSelectUserForm.setKeyword(null);
event.getRequestContext().addUIComponentToUpdateByAjax(uiSelectUserForm);
}
}
@@ -423,17 +425,23 @@
{
UIUserSelector uiSelectUserForm = event.getSource();
String groupId = uiSelectUserForm.getSelectedGroup();
- uiSelectUserForm.setSelectedGroup(groupId);
OrganizationService service = uiSelectUserForm.getApplicationComponent(OrganizationService.class);
+
+ PageList users = PageList.EMPTY_LIST;
if (groupId != null && groupId.trim().length() != 0)
{
- PageList users = uiSelectUserForm.removeDuplicate(service.getUserHandler().findUsersByGroup(groupId));
- uiSelectUserForm.uiIterator_.setPageList(users);
+ if (service.getGroupHandler().findGroupById(groupId) != null)
+ {
+ users = uiSelectUserForm.removeDuplicate(service.getUserHandler().findUsersByGroup(groupId));
+ }
}
else
{
- uiSelectUserForm.uiIterator_.setPageList(service.getUserHandler().findUsers(new Query()));
+ users = service.getUserHandler().findUsers(new Query());
}
+ users.setPageSize(10);
+ uiSelectUserForm.uiIterator_.setPageList(users);
+ uiSelectUserForm.setKeyword(null);
event.getRequestContext().addUIComponentToUpdateByAjax(uiSelectUserForm);
}
}
Modified: portal/branches/wci/webui/framework/src/main/java/org/exoplatform/webui/core/UIComponentDecorator.java
===================================================================
--- portal/branches/wci/webui/framework/src/main/java/org/exoplatform/webui/core/UIComponentDecorator.java 2010-11-29 15:35:58 UTC (rev 5355)
+++ portal/branches/wci/webui/framework/src/main/java/org/exoplatform/webui/core/UIComponentDecorator.java 2010-11-29 16:47:37 UTC (rev 5356)
@@ -48,14 +48,22 @@
return uicomponent_;
}
- public void setUIComponent(UIComponent uicomponent)
+ public UIComponent setUIComponent(UIComponent uicomponent)
{
+ UIComponent oldOne = uicomponent_;
if (uicomponent_ != null)
- uicomponent_.setRendered(false);
+ uicomponent_.setParent(null);
uicomponent_ = uicomponent;
- if (uicomponent_ == null)
- return;
- uicomponent_.setParent(this);
+ if (uicomponent_ != null)
+ {
+ UIComponent oldParent = uicomponent_.getParent();
+ if (oldParent != null && oldParent != this && oldParent instanceof UIComponentDecorator)
+ {
+ ((UIComponentDecorator)oldParent).setUIComponent(null);
+ }
+ uicomponent_.setParent(this);
+ }
+ return oldOne;
}
@SuppressWarnings("unchecked")
Modified: portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/application/localization/LocalizationFilter.java
===================================================================
--- portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/application/localization/LocalizationFilter.java 2010-11-29 15:35:58 UTC (rev 5355)
+++ portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/application/localization/LocalizationFilter.java 2010-11-29 16:47:37 UTC (rev 5356)
@@ -56,15 +56,27 @@
* override for extra-portlet requests (i.e. unbridged .jsp). Thanks to it dynamic resources can be localized
* to keep in sync with the rest of the portal. This filter is re-entrant, and can safely be installed for
* INCLUDE, FORWARD, and ERROR dispatch methods.
- *
+ * <p>
* A concrete example of re-entrant use is login/jsp/login.jsp used when authentication fails at portal login.
- *
+ * <p>
* By default {@link HttpServletRequest#getLocale()} and {@link HttpServletRequest#getLocales()} reflect
* browser language preference. When using this filter these two calls employ the same Locale determination algorithm
- * as LocalizationLifecycle does.
- *
+ * as {@link LocalizationLifecycle} does.
+ * <p>
* This filter can be activated / deactivated via portal module's web.xml
- *
+ * <p>
+ * If default portal language is other than English, it can be configured for the filter by using PortalLocale init param:
+ * <p>
+ * <pre><filter>
+ * <filter-name>LocalizationFilter</filter-name>
+ * <filter-class>org.exoplatform.portal.application.localization.LocalizationFilter</filter-class>
+ * <init-param>
+ * <param-name>PortalLocale</param-name>
+ * <param-value>fr_FR</param-value>
+ * </init-param>
+ * </filter>
+ * </pre>
+ *
* @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
*/
public class LocalizationFilter implements Filter
@@ -73,8 +85,14 @@
private static ThreadLocal<Locale> currentLocale = new ThreadLocal<Locale>();
+ private Locale portalLocale = Locale.ENGLISH;
+
public void init(FilterConfig filterConfig) throws ServletException
{
+ String locale = filterConfig.getInitParameter("PortalLocale");
+ locale = locale != null ? locale.trim() : null;
+ if (locale != null && locale.length() > 0)
+ portalLocale = LocaleContextInfo.getLocale(locale);
}
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException
@@ -141,7 +159,7 @@
localeCtx.setUserProfileLocale(getUserProfileLocale(container, req.getRemoteUser()));
localeCtx.setRemoteUser(req.getRemoteUser());
- localeCtx.setPortalLocale(Locale.ENGLISH);
+ localeCtx.setPortalLocale(checkPortalLocaleSupported(portalLocale, supportedLocales));
Locale locale = localePolicy.determineLocale(localeCtx);
boolean supported = supportedLocales.contains(locale);
@@ -170,6 +188,27 @@
}
}
+ private Locale checkPortalLocaleSupported(Locale portalLocale, Set<Locale> supportedLocales)
+ {
+ if (supportedLocales.contains(portalLocale))
+ return portalLocale;
+ if ("".equals(portalLocale.getCountry()) == false)
+ {
+ Locale loc = new Locale(portalLocale.getLanguage());
+ if (supportedLocales.contains(loc))
+ {
+ log.warn("portalLocale not supported: " + LocaleContextInfo.getLocaleAsString(portalLocale)
+ + ". Falling back to '" + portalLocale.getLanguage()+ "'.");
+ this.portalLocale = loc;
+ return loc;
+ }
+ }
+
+ log.warn("portalLocale not supported: " + LocaleContextInfo.getLocaleAsString(portalLocale) + ". Falling back to Locale.ENGLISH.");
+ this.portalLocale = Locale.ENGLISH;
+ return portalLocale;
+ }
+
private Locale getUserProfileLocale(ExoContainer container, String user)
{
UserProfile userProfile = null;
Modified: portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletActionListener.java
===================================================================
--- portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletActionListener.java 2010-11-29 15:35:58 UTC (rev 5355)
+++ portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletActionListener.java 2010-11-29 16:47:37 UTC (rev 5356)
@@ -854,8 +854,7 @@
{
public void execute(Event<UIPortlet> event) throws Exception
{
- UIPortal uiPortal = Util.getUIPortal();
- UIPortalApplication uiApp = uiPortal.getAncestorOfType(UIPortalApplication.class);
+ UIPortalApplication uiApp = Util.getUIPortalApplication();
UIMaskWorkspace uiMaskWS = uiApp.getChildById(UIPortalApplication.UI_MASK_WS_ID);
uiMaskWS.setUpdated(true);
UIPortlet uiPortlet = event.getSource();
Modified: portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/container/UIContainerActionListener.java
===================================================================
--- portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/container/UIContainerActionListener.java 2010-11-29 15:35:58 UTC (rev 5355)
+++ portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/container/UIContainerActionListener.java 2010-11-29 16:47:37 UTC (rev 5356)
@@ -39,8 +39,7 @@
{
UIContainer uiContainer = event.getSource();
- UIPortal uiPortal = Util.getUIPortal();
- UIPortalApplication uiApp = uiPortal.getAncestorOfType(UIPortalApplication.class);
+ UIPortalApplication uiApp = Util.getUIPortalApplication();
UIMaskWorkspace uiMaskWS = uiApp.getChildById(UIPortalApplication.UI_MASK_WS_ID);
UIContainerForm containerForm = uiMaskWS.createUIComponent(UIContainerForm.class, null, null);
containerForm.setValues(uiContainer);
Modified: portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/container/UIContainerForm.java
===================================================================
--- portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/container/UIContainerForm.java 2010-11-29 15:35:58 UTC (rev 5355)
+++ portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/container/UIContainerForm.java 2010-11-29 16:47:37 UTC (rev 5356)
@@ -141,7 +141,7 @@
event.getRequestContext().addUIComponentToUpdateByAjax(uiMaskWorkspace);
- UIPortalApplication uiPortalApp = uiForm.getAncestorOfType(UIPortalApplication.class);
+ UIPortalApplication uiPortalApp = Util.getUIPortalApplication();
UIWorkingWorkspace uiWorkingWS = uiPortalApp.getChildById(UIPortalApplication.UI_WORKING_WS_ID);
pcontext.getJavascriptManager().addJavascript("eXo.portal.UIPortal.changeComposerSaveButton();");
pcontext.addUIComponentToUpdateByAjax(uiWorkingWS);
Modified: portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/javascript/JavascriptServlet.java
===================================================================
--- portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/javascript/JavascriptServlet.java 2010-11-29 15:35:58 UTC (rev 5355)
+++ portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/javascript/JavascriptServlet.java 2010-11-29 16:47:37 UTC (rev 5356)
@@ -19,10 +19,14 @@
package org.exoplatform.portal.webui.javascript;
+import org.exoplatform.commons.utils.PropertyManager;
import org.exoplatform.container.ExoContainerContext;
+import org.exoplatform.portal.application.ResourceRequestFilter;
import org.exoplatform.web.application.javascript.JavascriptConfigService;
import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Date;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
@@ -55,14 +59,23 @@
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException,
IOException
{
- JavascriptConfigService service =
+ final JavascriptConfigService service =
(JavascriptConfigService)ExoContainerContext.getCurrentContainer().getComponentInstanceOfType(
JavascriptConfigService.class);
-
+ long lastModified = service.getLastModified();
+ long ifModifiedSince = request.getDateHeader(ResourceRequestFilter.IF_MODIFIED_SINCE);
+
// Julien: should we also set charset along with the content type ?
response.setContentType("application/x-javascript");
- ServletOutputStream stream = response.getOutputStream();
- service.writeMergedJavascript(stream);
+ if (!PropertyManager.isDevelopping()) {
+ if (ifModifiedSince >= lastModified) {
+ response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
+ return;
+ }
+ }
+
+ byte[] jsBytes = service.getMergedJavascript();
+ response.setDateHeader(ResourceRequestFilter.LAST_MODIFIED, lastModified);
+ response.getOutputStream().write(jsBytes);
}
-
}
Modified: portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/PageNavigationUtils.java
===================================================================
--- portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/PageNavigationUtils.java 2010-11-29 15:35:58 UTC (rev 5355)
+++ portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/PageNavigationUtils.java 2010-11-29 16:47:37 UTC (rev 5356)
@@ -367,6 +367,12 @@
}
PageNode cloneStartNode = startNode.clone();
+
+ // Check if page reference isn't existing, page reference value of node is setted null too.
+ if (pageReference != null && userService.getPage(pageReference) == null)
+ {
+ cloneStartNode.setPageReference(null);
+ }
ArrayList<PageNode> filteredChildren = new ArrayList<PageNode>();
List<PageNode> children = startNode.getChildren();
Modified: portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UINavigationNodeSelector.java
===================================================================
--- portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UINavigationNodeSelector.java 2010-11-29 15:35:58 UTC (rev 5355)
+++ portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UINavigationNodeSelector.java 2010-11-29 16:47:37 UTC (rev 5356)
@@ -26,7 +26,6 @@
import org.exoplatform.portal.config.model.PageNode;
import org.exoplatform.portal.config.model.PortalConfig;
import org.exoplatform.portal.mop.Visibility;
-import org.exoplatform.portal.webui.navigation.ParentChildPair;
import org.exoplatform.portal.webui.page.UIPage;
import org.exoplatform.portal.webui.page.UIPageNodeForm;
import org.exoplatform.portal.webui.portal.UIPortalComposer;
@@ -447,7 +446,6 @@
uiToolPanel.setWorkingComponent(UIPage.class, null);
UIPage uiPage = (UIPage)uiToolPanel.getUIComponent();
- WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
if(selectPage.getTitle() == null)
selectPage.setTitle(selectedPageNode.getLabel());
@@ -535,46 +533,48 @@
{
public void execute(Event<UIRightClickPopupMenu> event) throws Exception
{
- String uri = event.getRequestContext().getRequestParameter(UIComponent.OBJECTID);
- WebuiRequestContext pcontext = event.getRequestContext();
- UIApplication uiApp = pcontext.getUIApplication();
- UINavigationNodeSelector uiNodeSelector = event.getSource().getAncestorOfType(UINavigationNodeSelector.class);
- UINavigationManagement uiManagement = uiNodeSelector.getParent();
- Class<?>[] childrenToRender = new Class<?>[]{UINavigationNodeSelector.class};
- uiManagement.setRenderedChildrenOfTypes(childrenToRender);
- event.getRequestContext().addUIComponentToUpdateByAjax(uiManagement);
+ String uri = event.getRequestContext().getRequestParameter(UIComponent.OBJECTID);
+ WebuiRequestContext pcontext = event.getRequestContext();
+ UIApplication uiApp = pcontext.getUIApplication();
+ UINavigationNodeSelector uiNodeSelector = event.getSource().getAncestorOfType(UINavigationNodeSelector.class);
+ UINavigationManagement uiManagement = uiNodeSelector.getParent();
+ Class<?>[] childrenToRender = new Class<?>[]{UINavigationNodeSelector.class};
+ uiManagement.setRenderedChildrenOfTypes(childrenToRender);
+ event.getRequestContext().addUIComponentToUpdateByAjax(uiManagement);
- PageNavigation nav = uiNodeSelector.getEdittedNavigation();
- if (nav == null)
- {
- return;
- }
-
- PageNode[] pageNodes = PageNavigationUtils.searchPageNodesByUri(nav, uri);
- if (pageNodes == null)
- {
- return;
- }
-
- for (PageNode pageNode : pageNodes) {
- if(pageNode != null && pageNode.isSystem()) {
- uiApp.addMessage(new ApplicationMessage("UINavigationNodeSelector.msg.systemnode-move", null));
- return;
- }
- }
-
- TreeNodeData selectedNode = new TreeNodeData(nav, pageNodes[0], pageNodes[1]);
- selectedNode.setDeleteNode(false);
- uiNodeSelector.setCopyNode(selectedNode);
- event.getSource().setActions(
- new String[]{"AddNode", "EditPageNode", "EditSelectedNode", "CopyNode", "CloneNode", "CutNode",
- "PasteNode", "DeleteNode", "MoveUp", "MoveDown"});
+ PageNavigation nav = uiNodeSelector.getEdittedNavigation();
+ if (nav == null)
+ {
+ return;
+ }
- if (uiNodeSelector.getCopyNode() == null)
- {
- return;
- }
- uiNodeSelector.getCopyNode().setDeleteNode(true);
+ ParentChildPair parentChildPair = PageNavigationUtils.searchParentChildPairByUri(nav, uri);
+ if (parentChildPair == null)
+ {
+ return;
+ }
+
+ PageNode parentNode = parentChildPair.getParentNode();
+ PageNode childNode = parentChildPair.getChildNode();
+
+ if (childNode != null && childNode.isSystem())
+ {
+ uiApp.addMessage(new ApplicationMessage("UINavigationNodeSelector.msg.systemnode-move", null));
+ return;
+ }
+
+ TreeNodeData selectedNode = new TreeNodeData(nav, parentNode, childNode);
+ selectedNode.setDeleteNode(false);
+ uiNodeSelector.setCopyNode(selectedNode);
+ event.getSource().setActions(
+ new String[]{"AddNode", "EditPageNode", "EditSelectedNode", "CopyNode", "CloneNode", "CutNode",
+ "PasteNode", "DeleteNode", "MoveUp", "MoveDown"});
+
+ if (uiNodeSelector.getCopyNode() == null)
+ {
+ return;
+ }
+ uiNodeSelector.getCopyNode().setDeleteNode(true);
}
}
Modified: portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UIPortalNavigation.java
===================================================================
--- portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UIPortalNavigation.java 2010-11-29 15:35:58 UTC (rev 5355)
+++ portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UIPortalNavigation.java 2010-11-29 16:47:37 UTC (rev 5356)
@@ -113,7 +113,7 @@
if (context.getRemoteUser() != null)
{
- result.add(PageNavigationUtils.filter(getSelectedNavigation(), context.getRemoteUser()));
+ result.add(PageNavigationUtils.filterNavigation(getSelectedNavigation(), context.getRemoteUser(), false, true));
}
else
{
@@ -121,7 +121,7 @@
{
if (!showUserNavigation && nav.getOwnerType().equals("user"))
continue;
- result.add(PageNavigationUtils.filter(nav, null));
+ result.add(PageNavigationUtils.filterNavigation(nav, null, false, true));
}
}
return result;
Modified: portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageActionListener.java
===================================================================
--- portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageActionListener.java 2010-11-29 15:35:58 UTC (rev 5355)
+++ portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageActionListener.java 2010-11-29 16:47:37 UTC (rev 5356)
@@ -59,7 +59,7 @@
public void execute(Event<UIPortal> event) throws Exception
{
UIPortal showedUIPortal = event.getSource();
- UIPortalApplication uiPortalApp = showedUIPortal.getAncestorOfType(UIPortalApplication.class);
+ UIPortalApplication uiPortalApp = Util.getUIPortalApplication();
//This code snippet is to make sure that Javascript/Skin is fully loaded at the first request
UIWorkingWorkspace uiWorkingWS = uiPortalApp.getChildById(UIPortalApplication.UI_WORKING_WS_ID);
Modified: portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageBrowser.java
===================================================================
--- portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageBrowser.java 2010-11-29 15:35:58 UTC (rev 5355)
+++ portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageBrowser.java 2010-11-29 16:47:37 UTC (rev 5356)
@@ -309,6 +309,12 @@
if(page.getOwnerType().equals(PortalConfig.USER_TYPE)){
removePageNode(page, event);
}
+
+ UIWorkingWorkspace uiWorkingWorkspace = uiPortalApp.getChild(UIWorkingWorkspace.class);
+ uiWorkingWorkspace.updatePortletsByName("UserToolbarSitePortlet");
+ uiWorkingWorkspace.updatePortletsByName("UserToolbarGroupPortlet");
+ uiWorkingWorkspace.updatePortletsByName("UserToolbarDashboardPortlet");
+ uiWorkingWorkspace.updatePortletsByName("NavigationPortlet");
}
/**
Modified: portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageForm.java
===================================================================
--- portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageForm.java 2010-11-29 15:35:58 UTC (rev 5355)
+++ portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageForm.java 2010-11-29 16:47:37 UTC (rev 5356)
@@ -125,12 +125,12 @@
addUIFormInput(uiSettingSet);
setSelectedTab(uiSettingSet.getId());
- WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
- Param param = initParams.getParam("PageTemplate");
- List<SelectItemCategory> itemCategories = (List<SelectItemCategory>)param.getMapGroovyObject(context);
- UIFormInputItemSelector uiTemplate = new UIFormInputItemSelector("Template", "template");
- uiTemplate.setItemCategories(itemCategories);
- addUIFormInput(uiTemplate);
+ //WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
+ //Param param = initParams.getParam("PageTemplate");
+ //List<SelectItemCategory> itemCategories = (List<SelectItemCategory>)param.getMapGroovyObject(context);
+ //UIFormInputItemSelector uiTemplate = new UIFormInputItemSelector("Template", "template");
+ //uiTemplate.setItemCategories(itemCategories);
+ //addUIFormInput(uiTemplate);
uiPermissionSetting = createUIComponent(UIFormInputSet.class, "PermissionSetting", null);
UIListPermissionSelector uiListPermissionSelector = createUIComponent(UIListPermissionSelector.class, null, null);
Modified: portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIMaskWorkspace.java
===================================================================
--- portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIMaskWorkspace.java 2010-11-29 15:35:58 UTC (rev 5355)
+++ portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIMaskWorkspace.java 2010-11-29 16:47:37 UTC (rev 5356)
@@ -93,10 +93,11 @@
return createUIComponent(clazz, null, null);
}
- public void setUIComponent(UIComponent uicomponent)
+ public UIComponent setUIComponent(UIComponent uicomponent)
{
- super.setUIComponent(uicomponent);
+ UIComponent oldOne = super.setUIComponent(uicomponent);
setShow(uicomponent != null);
+ return oldOne;
}
static public class CloseActionListener extends EventListener<UIComponent>
Modified: portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIPortalApplicationLifecycle.java
===================================================================
--- portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIPortalApplicationLifecycle.java 2010-11-29 15:35:58 UTC (rev 5355)
+++ portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIPortalApplicationLifecycle.java 2010-11-29 16:47:37 UTC (rev 5356)
@@ -44,7 +44,12 @@
return;
UIComponent uiTarget = uicomponent.findComponentById(componentId);
if (uiTarget == null)
+ {
+ context.addUIComponentToUpdateByAjax(uicomponent.<UIComponent>getChildById(UIPortalApplication.UI_WORKING_WS_ID));
+ context.addUIComponentToUpdateByAjax(uicomponent.getChild(UIMaskWorkspace.class));
+ ((PortalRequestContext)context).setFullRender(true);
return;
+ }
if (uiTarget == uicomponent)
super.processDecode(uicomponent, context);
uiTarget.processDecode(context);
Modified: portal/branches/wci/webui/portlet/src/main/java/org/exoplatform/webui/application/portlet/PortletApplicationController.java
===================================================================
--- portal/branches/wci/webui/portlet/src/main/java/org/exoplatform/webui/application/portlet/PortletApplicationController.java 2010-11-29 15:35:58 UTC (rev 5355)
+++ portal/branches/wci/webui/portlet/src/main/java/org/exoplatform/webui/application/portlet/PortletApplicationController.java 2010-11-29 16:47:37 UTC (rev 5356)
@@ -133,7 +133,7 @@
{
application = new PortletApplication(getPortletConfig());
application.onInit();
- controller.addApplication(application);
+ application = controller.addApplication(application);
}
return application;
}
14 years
gatein SVN: r5355 - portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router.
by do-not-reply@jboss.org
Author: julien_viet
Date: 2010-11-29 10:35:58 -0500 (Mon, 29 Nov 2010)
New Revision: 5355
Modified:
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPathParamEncoding.java
Log:
complete unit test for render
Modified: portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPathParamEncoding.java
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPathParamEncoding.java 2010-11-29 15:32:23 UTC (rev 5354)
+++ portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPathParamEncoding.java 2010-11-29 15:35:58 UTC (rev 5355)
@@ -72,7 +72,10 @@
assertEquals(Collections.singletonMap(QualifiedName.create("p"), "/platform/administrator/"), router.route("/_platform_administrator_"));
assertEquals(Collections.singletonMap(QualifiedName.create("p"), "/platform/administrator/"), router.route("/_platform_administrator_/"));
- // todo : render
+ // Render
+ assertEquals("/_platform_administrator", router.render(Collections.singletonMap(QualifiedName.create("p"), "/platform/administrator")));
+ assertEquals("/_platform_administrator_", router.render(Collections.singletonMap(QualifiedName.create("p"), "/platform/administrator/")));
+ assertEquals(null, router.render(Collections.singletonMap(QualifiedName.create("p"), "/platform/administrator//")));
}
public void testWildcardPathParamWithPreservePath() throws Exception
14 years
gatein SVN: r5354 - in portal/branches/wci: component/web/security/src/main/java/org/exoplatform/web/security and 17 other directories.
by do-not-reply@jboss.org
Author: alain_defrance
Date: 2010-11-29 10:32:23 -0500 (Mon, 29 Nov 2010)
New Revision: 5354
Added:
portal/branches/wci/gadgets/eXoGadgets/src/main/webapp/META-INF/
portal/branches/wci/gadgets/eXoGadgets/src/main/webapp/META-INF/context.xml
portal/branches/wci/web/eXoResources/src/main/webapp/META-INF/
portal/branches/wci/web/eXoResources/src/main/webapp/META-INF/context.xml
portal/branches/wci/web/portal/src/main/webapp/META-INF/
portal/branches/wci/web/portal/src/main/webapp/META-INF/context.xml
portal/branches/wci/web/rest/src/main/webapp/META-INF/
portal/branches/wci/web/rest/src/main/webapp/META-INF/context.xml
Removed:
portal/branches/wci/packaging/tomcat/pkg/src/main/resources/tomcat/conf/Catalina/localhost/eXoGadgetServer.xml
portal/branches/wci/packaging/tomcat/pkg/src/main/resources/tomcat/conf/Catalina/localhost/eXoResources.xml
portal/branches/wci/packaging/tomcat/pkg/src/main/resources/tomcat/conf/Catalina/localhost/portal.xml
portal/branches/wci/packaging/tomcat/pkg/src/main/resources/tomcat/conf/Catalina/localhost/rest.xml
portal/branches/wci/packaging/tomcat/pkg/src/main/resources/tomcat/conf/producer.server.xml
portal/branches/wci/web/portal/src/main/resources/
Modified:
portal/branches/wci/component/web/security/src/main/java/org/exoplatform/web/login/ErrorLoginServlet.java
portal/branches/wci/component/web/security/src/main/java/org/exoplatform/web/login/InitiateLoginServlet.java
portal/branches/wci/component/web/security/src/main/java/org/exoplatform/web/security/PortalLoginController.java
portal/branches/wci/examples/extension/war/src/main/webapp/login/jsp/login.jsp
portal/branches/wci/examples/extension/war/src/main/webapp/templates/groovy/webui/component/UIHomePagePortlet.gtmpl
portal/branches/wci/examples/portal/war/src/main/webapp/login/jsp/login.jsp
portal/branches/wci/examples/portal/war/src/main/webapp/templates/groovy/webui/component/UIHomePagePortlet.gtmpl
portal/branches/wci/web/portal/src/main/webapp/groovy/portal/webui/UILoginForm.gtmpl
portal/branches/wci/web/portal/src/main/webapp/login/jsp/login.jsp
Log:
merge commit from branch-GTNPORTAL
Modified: portal/branches/wci/component/web/security/src/main/java/org/exoplatform/web/login/ErrorLoginServlet.java
===================================================================
--- portal/branches/wci/component/web/security/src/main/java/org/exoplatform/web/login/ErrorLoginServlet.java 2010-11-29 15:22:49 UTC (rev 5353)
+++ portal/branches/wci/component/web/security/src/main/java/org/exoplatform/web/login/ErrorLoginServlet.java 2010-11-29 15:32:23 UTC (rev 5354)
@@ -71,9 +71,34 @@
resp.setContentType("text/html; charset=UTF-8");
// This allows the customer to define another login page without changing the portal
- context.getRequestDispatcher("/login/jsp/login.jsp").include(req, resp);
+ //context.getRequestDispatcher("/login/jsp/login.jsp").include(req, resp);
+ showLoginForm(req, resp);
}
+ private void showLoginForm(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
+ {
+ String initialURI = (String)req.getAttribute("javax.servlet.forward.request_uri");
+ if (initialURI == null)
+ {
+ throw new IllegalStateException("request attribute javax.servlet.forward.request_uri should not be null here");
+ }
+ int jsecurityIndex = initialURI.lastIndexOf("/j_security_check");
+ if (jsecurityIndex != -1)
+ {
+ initialURI = initialURI.substring(0, jsecurityIndex);
+ }
+
+ try
+ {
+ req.setAttribute("org.gatein.portal.login.initial_uri", initialURI);
+ getServletContext().getRequestDispatcher("/login/jsp/login.jsp").include(req, resp);
+ }
+ finally
+ {
+ req.removeAttribute("org.gatein.portal.login.initial_uri");
+ }
+ }
+
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
{
doGet(req, resp);
Modified: portal/branches/wci/component/web/security/src/main/java/org/exoplatform/web/login/InitiateLoginServlet.java
===================================================================
--- portal/branches/wci/component/web/security/src/main/java/org/exoplatform/web/login/InitiateLoginServlet.java 2010-11-29 15:22:49 UTC (rev 5353)
+++ portal/branches/wci/component/web/security/src/main/java/org/exoplatform/web/login/InitiateLoginServlet.java 2010-11-29 15:32:23 UTC (rev 5354)
@@ -96,7 +96,8 @@
// Send authentication request
log.debug("Login initiated with no credentials in session but found token " + token + " with existing credentials, " +
"performing authentication");
- sendAuth(resp, credentials.getUsername(), token);
+ //sendAuth(resp, credentials.getUsername(), token);
+ sendAuth(req, resp, credentials.getUsername(), token);
}
}
else
@@ -127,11 +128,12 @@
private void showLoginForm(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
{
- String initialURI = (String)req.getAttribute("javax.servlet.forward.request_uri");
+ /*String initialURI = (String)req.getAttribute("javax.servlet.forward.request_uri");
if (initialURI == null)
{
throw new IllegalStateException("request attribute javax.servlet.forward.request_uri should not be null here");
- }
+ }*/
+ String initialURI = getInitialURI(req);
try
{
String queryString = (String)req.getAttribute("javax.servlet.forward.query_string");
@@ -139,23 +141,45 @@
{
initialURI = initialURI + "?" + queryString;
}
+ //req.setAttribute("org.gatein.portal.login.initial_uri", initialURI);
+ //req.getSession(true).setAttribute("org.gatein.portal.login.initial_uri", initialURI);
req.setAttribute("org.gatein.portal.login.initial_uri", initialURI);
getServletContext().getRequestDispatcher("/login/jsp/login.jsp").include(req, resp);
}
finally
{
+ //req.removeAttribute("org.gatein.portal.login.initial_uri");
+ //req.getSession(true).removeAttribute("org.gatein.portal.login.initial_uri");
req.removeAttribute("org.gatein.portal.login.initial_uri");
}
}
+ private String getInitialURI(HttpServletRequest req)
+ {
+ String initialURI = (String)req.getAttribute("javax.servlet.forward.request_uri");
+ if (initialURI == null)
+ {
+ throw new IllegalStateException("request attribute javax.servlet.forward.request_uri should not be null here");
+ }
+ return initialURI;
+ }
+
+
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
{
doGet(req, resp);
}
- private void sendAuth(HttpServletResponse resp, String jUsername, String jPassword) throws IOException
+ //private void sendAuth(HttpServletResponse resp, String jUsername, String jPassword) throws IOException
+ private void sendAuth(HttpServletRequest req, HttpServletResponse resp, String jUsername, String jPassword) throws IOException
{
- String url = "j_security_check?j_username=" + jUsername + "&j_password=" + jPassword;
+ //String url = "j_security_check?j_username=" + jUsername + "&j_password=" + jPassword;
+ String initialURI = getInitialURI(req);
+ if (!initialURI.endsWith("/"))
+ {
+ initialURI += "/";
+ }
+ String url = initialURI + "j_security_check?j_username=" + jUsername + "&j_password=" + jPassword;
url = resp.encodeRedirectURL(url);
resp.sendRedirect(url);
}
Modified: portal/branches/wci/component/web/security/src/main/java/org/exoplatform/web/security/PortalLoginController.java
===================================================================
--- portal/branches/wci/component/web/security/src/main/java/org/exoplatform/web/security/PortalLoginController.java 2010-11-29 15:22:49 UTC (rev 5353)
+++ portal/branches/wci/component/web/security/src/main/java/org/exoplatform/web/security/PortalLoginController.java 2010-11-29 15:32:23 UTC (rev 5354)
@@ -51,12 +51,14 @@
// otherwise compute one
if (uri == null || uri.length() == 0)
{
- uri = req.getContextPath() + "/private/classic";
+ //uri = req.getContextPath() + "/private/classic";
+ uri = req.getContextPath();
log.debug("No initial URI found, will use default " + uri + " instead ");
}
else
{
log.debug("Found initial URI " + uri);
+ //req.getSession(true).setAttribute("org.gatein.portal.login.initial_uri", uri);
}
// if we do have a remember me
@@ -74,7 +76,8 @@
"in the next response");
Cookie cookie = new Cookie(InitiateLoginServlet.COOKIE_NAME, cookieToken);
cookie.setPath(req.getContextPath());
- cookie.setMaxAge((int)tokenService.getValidityTime() / 1000);
+ //cookie.setMaxAge((int)tokenService.getValidityTime() / 1000);
+ cookie.setMaxAge((int)tokenService.getValidityTime());
resp.addCookie(cookie);
}
}
Modified: portal/branches/wci/examples/extension/war/src/main/webapp/login/jsp/login.jsp
===================================================================
--- portal/branches/wci/examples/extension/war/src/main/webapp/login/jsp/login.jsp 2010-11-29 15:22:49 UTC (rev 5353)
+++ portal/branches/wci/examples/extension/war/src/main/webapp/login/jsp/login.jsp 2010-11-29 15:32:23 UTC (rev 5354)
@@ -26,6 +26,7 @@
<%@ page import="java.util.ResourceBundle"%>
<%@ page import="org.exoplatform.web.login.InitiateLoginServlet"%>
<%@ page import="org.gatein.common.text.EntityEncoder"%>
+<%--<%@ page import="javax.servlet.http.HttpSession"%>--%>
<%@ page language="java" %>
<%@ page contentType="text/html; charset=utf-8" %>
<%
@@ -40,6 +41,10 @@
ResourceBundleService service = (ResourceBundleService) portalContainer.getComponentInstanceOfType(ResourceBundleService.class);
ResourceBundle res = service.getResourceBundle(service.getSharedResourceBundleNames(), request.getLocale()) ;
+ //String uri = (String)request.getAttribute("org.gatein.portal.login.initial_uri");
+ /*HttpSession httpSession = request.getSession(true);
+ String uri = (String)httpSession.getAttribute("org.gatein.portal.login.initial_uri");
+ httpSession.removeAttribute("org.gatein.portal.login.initial_uri");*/
String uri = (String)request.getAttribute("org.gatein.portal.login.initial_uri");
Cookie cookie = new Cookie(InitiateLoginServlet.COOKIE_NAME, "");
Modified: portal/branches/wci/examples/extension/war/src/main/webapp/templates/groovy/webui/component/UIHomePagePortlet.gtmpl
===================================================================
--- portal/branches/wci/examples/extension/war/src/main/webapp/templates/groovy/webui/component/UIHomePagePortlet.gtmpl 2010-11-29 15:22:49 UTC (rev 5353)
+++ portal/branches/wci/examples/extension/war/src/main/webapp/templates/groovy/webui/component/UIHomePagePortlet.gtmpl 2010-11-29 15:32:23 UTC (rev 5354)
@@ -1,3 +1,6 @@
+<%
+ String initialURI = _ctx.getRequestContext().getParentAppRequestContext().getRequestContextPath() + "/private/" + _ctx.getRequestContext().getParentAppRequestContext().getPortalOwner();
+%>
<div class="UIHomePagePortlet" id="$uicomponent.id">
<div class="TRContainer">
<div class="PortletDecoration">
@@ -28,7 +31,7 @@
<div class="AccountsContainerDeco">
<div class="AccountBlock AdministratorUser">
<div class="AccountInfos">
- <div class="AccountTitle"><a href="${_ctx.getPortalContextPath()}/login?username=root&password=gtn"><%=_ctx.appRes("UIHomePagePortlet.Label.Administrator")%></a></div>
+ <div class="AccountTitle"><a href="${_ctx.getPortalContextPath()}/login?username=root&password=gtn&initialURI=<%=initialURI%>"><%=_ctx.appRes("UIHomePagePortlet.Label.Administrator")%></a></div>
<div class="Username">
<div class="Lable"><%=_ctx.appRes("UIHomePagePortlet.Label.Username")%></div><span>root</span>
<div class="ClearBoth"><span></span></div>
@@ -42,7 +45,7 @@
<div class="SeparatorLine"><span></span></div>
<div class="AccountBlock ManagerUser">
<div class="AccountInfos">
- <div class="AccountTitle"><a href="${_ctx.getPortalContextPath()}/login?username=john&password=gtn"><%=_ctx.appRes("UIHomePagePortlet.Label.Manager")%></a></div>
+ <div class="AccountTitle"><a href="${_ctx.getPortalContextPath()}/login?username=john&password=gtn&initialURI=<%=initialURI%>"><%=_ctx.appRes("UIHomePagePortlet.Label.Manager")%></a></div>
<div class="Username">
<div class="Lable"><%=_ctx.appRes("UIHomePagePortlet.Label.Username")%></div><span>john</span>
<div class="ClearBoth"><span></span></div>
@@ -56,7 +59,7 @@
<div class="SeparatorLine"><span></span></div>
<div class="AccountBlock NormalUser">
<div class="AccountInfos">
- <div class="AccountTitle"><a href="${_ctx.getPortalContextPath()}/login?username=mary&password=gtn"><%=_ctx.appRes("UIHomePagePortlet.Label.User")%></a></div>
+ <div class="AccountTitle"><a href="${_ctx.getPortalContextPath()}/login?username=mary&password=gtn&initialURI=<%=initialURI%>"><%=_ctx.appRes("UIHomePagePortlet.Label.User")%></a></div>
<div class="Username">
<div class="Lable"><%=_ctx.appRes("UIHomePagePortlet.Label.Username")%></div><span>mary</span>
<div class="ClearBoth"><span></span></div>
@@ -70,7 +73,7 @@
<div class="SeparatorLine"><span></span></div>
<div class="AccountBlock DemoUser" style="margin-right: 0px;">
<div class="AccountInfos">
- <div class="AccountTitle"><a href="${_ctx.getPortalContextPath()}/login?username=demo&password=gtn"><%=_ctx.appRes("UIHomePagePortlet.Label.Demo")%></a></div>
+ <div class="AccountTitle"><a href="${_ctx.getPortalContextPath()}/login?username=demo&password=gtn&initialURI=<%=initialURI%>"><%=_ctx.appRes("UIHomePagePortlet.Label.Demo")%></a></div>
<div class="Username">
<div class="Lable"><%=_ctx.appRes("UIHomePagePortlet.Label.Username")%></div><span>demo</span>
<div class="ClearBoth"><span></span></div>
Modified: portal/branches/wci/examples/portal/war/src/main/webapp/login/jsp/login.jsp
===================================================================
--- portal/branches/wci/examples/portal/war/src/main/webapp/login/jsp/login.jsp 2010-11-29 15:22:49 UTC (rev 5353)
+++ portal/branches/wci/examples/portal/war/src/main/webapp/login/jsp/login.jsp 2010-11-29 15:32:23 UTC (rev 5354)
@@ -26,6 +26,7 @@
<%@ page import="java.util.ResourceBundle"%>
<%@ page import="org.exoplatform.web.login.InitiateLoginServlet"%>
<%@ page import="org.gatein.common.text.EntityEncoder"%>
+<%--<%@ page import="javax.servlet.http.HttpSession"%>--%>
<%@ page language="java" %>
<%@ page contentType="text/html; charset=utf-8" %>
<%
@@ -40,6 +41,10 @@
ResourceBundleService service = (ResourceBundleService) portalContainer.getComponentInstanceOfType(ResourceBundleService.class);
ResourceBundle res = service.getResourceBundle(service.getSharedResourceBundleNames(), request.getLocale()) ;
+ //String uri = (String)request.getAttribute("org.gatein.portal.login.initial_uri");
+ /*HttpSession httpSession = request.getSession(true);
+ String uri = (String)httpSession.getAttribute("org.gatein.portal.login.initial_uri");
+ httpSession.removeAttribute("org.gatein.portal.login.initial_uri");*/
String uri = (String)request.getAttribute("org.gatein.portal.login.initial_uri");
Cookie cookie = new Cookie(InitiateLoginServlet.COOKIE_NAME, "");
Modified: portal/branches/wci/examples/portal/war/src/main/webapp/templates/groovy/webui/component/UIHomePagePortlet.gtmpl
===================================================================
--- portal/branches/wci/examples/portal/war/src/main/webapp/templates/groovy/webui/component/UIHomePagePortlet.gtmpl 2010-11-29 15:22:49 UTC (rev 5353)
+++ portal/branches/wci/examples/portal/war/src/main/webapp/templates/groovy/webui/component/UIHomePagePortlet.gtmpl 2010-11-29 15:32:23 UTC (rev 5354)
@@ -1,3 +1,6 @@
+<%
+ String initialURI = _ctx.getRequestContext().getParentAppRequestContext().getRequestContextPath() + "/private/" + _ctx.getRequestContext().getParentAppRequestContext().getPortalOwner();
+%>
<div class="UIHomePagePortlet" id="$uicomponent.id">
<div class="TRContainer">
<div class="PortletDecoration">
@@ -33,7 +36,7 @@
<div class="AccountsContainerDeco">
<div class="AccountBlock AdministratorUser">
<div class="AccountInfos">
- <div class="AccountTitle"><a href="${_ctx.getPortalContextPath()}/login?username=root&password=gtn"><%=_ctx.appRes("UIHomePagePortlet.Label.Administrator")%></a></div>
+ <div class="AccountTitle"><a href="${_ctx.getPortalContextPath()}/login?username=root&password=gtn&initialURI=<%=initialURI%>"><%=_ctx.appRes("UIHomePagePortlet.Label.Administrator")%></a></div>
<div class="Username">
<div class="Lable"><%=_ctx.appRes("UIHomePagePortlet.Label.Username")%></div><span>root</span>
<div class="ClearBoth"><span></span></div>
@@ -47,7 +50,7 @@
<div class="SeparatorLine"><span></span></div>
<div class="AccountBlock ManagerUser">
<div class="AccountInfos">
- <div class="AccountTitle"><a href="${_ctx.getPortalContextPath()}/login?username=john&password=gtn"><%=_ctx.appRes("UIHomePagePortlet.Label.Manager")%></a></div>
+ <div class="AccountTitle"><a href="${_ctx.getPortalContextPath()}/login?username=john&password=gtn&initialURI=<%=initialURI%>"><%=_ctx.appRes("UIHomePagePortlet.Label.Manager")%></a></div>
<div class="Username">
<div class="Lable"><%=_ctx.appRes("UIHomePagePortlet.Label.Username")%></div><span>john</span>
<div class="ClearBoth"><span></span></div>
@@ -61,7 +64,7 @@
<div class="SeparatorLine"><span></span></div>
<div class="AccountBlock NormalUser">
<div class="AccountInfos">
- <div class="AccountTitle"><a href="${_ctx.getPortalContextPath()}/login?username=mary&password=gtn"><%=_ctx.appRes("UIHomePagePortlet.Label.User")%></a></div>
+ <div class="AccountTitle"><a href="${_ctx.getPortalContextPath()}/login?username=mary&password=gtn&initialURI=<%=initialURI%>"><%=_ctx.appRes("UIHomePagePortlet.Label.User")%></a></div>
<div class="Username">
<div class="Lable"><%=_ctx.appRes("UIHomePagePortlet.Label.Username")%></div><span>mary</span>
<div class="ClearBoth"><span></span></div>
@@ -75,7 +78,7 @@
<div class="SeparatorLine"><span></span></div>
<div class="AccountBlock DemoUser" style="margin-right: 0px;">
<div class="AccountInfos">
- <div class="AccountTitle"><a href="${_ctx.getPortalContextPath()}/login?username=demo&password=gtn"><%=_ctx.appRes("UIHomePagePortlet.Label.Demo")%></a></div>
+ <div class="AccountTitle"><a href="${_ctx.getPortalContextPath()}/login?username=demo&password=gtn&initialURI=<%=initialURI%>"><%=_ctx.appRes("UIHomePagePortlet.Label.Demo")%></a></div>
<div class="Username">
<div class="Lable"><%=_ctx.appRes("UIHomePagePortlet.Label.Username")%></div><span>demo</span>
<div class="ClearBoth"><span></span></div>
Added: portal/branches/wci/gadgets/eXoGadgets/src/main/webapp/META-INF/context.xml
===================================================================
--- portal/branches/wci/gadgets/eXoGadgets/src/main/webapp/META-INF/context.xml (rev 0)
+++ portal/branches/wci/gadgets/eXoGadgets/src/main/webapp/META-INF/context.xml 2010-11-29 15:32:23 UTC (rev 5354)
@@ -0,0 +1,22 @@
+<!--
+
+ Copyright (C) 2009 eXo Platform SAS.
+
+ This is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+
+-->
+
+<Context path="/eXoResources" docBase="eXoResources" debug="0" reloadable="true" crossContext="true"/>
\ No newline at end of file
Deleted: portal/branches/wci/packaging/tomcat/pkg/src/main/resources/tomcat/conf/Catalina/localhost/eXoGadgetServer.xml
===================================================================
--- portal/branches/wci/packaging/tomcat/pkg/src/main/resources/tomcat/conf/Catalina/localhost/eXoGadgetServer.xml 2010-11-29 15:22:49 UTC (rev 5353)
+++ portal/branches/wci/packaging/tomcat/pkg/src/main/resources/tomcat/conf/Catalina/localhost/eXoGadgetServer.xml 2010-11-29 15:32:23 UTC (rev 5354)
@@ -1,22 +0,0 @@
-<!--
-
- Copyright (C) 2009 eXo Platform SAS.
-
- This is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of
- the License, or (at your option) any later version.
-
- This software is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this software; if not, write to the Free
- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-
--->
-
-<Context path="/eXoGadgetServer" docBase="eXoGadgetServer" debug="0" reloadable="true" crossContext="true"/>
Deleted: portal/branches/wci/packaging/tomcat/pkg/src/main/resources/tomcat/conf/Catalina/localhost/eXoResources.xml
===================================================================
--- portal/branches/wci/packaging/tomcat/pkg/src/main/resources/tomcat/conf/Catalina/localhost/eXoResources.xml 2010-11-29 15:22:49 UTC (rev 5353)
+++ portal/branches/wci/packaging/tomcat/pkg/src/main/resources/tomcat/conf/Catalina/localhost/eXoResources.xml 2010-11-29 15:32:23 UTC (rev 5354)
@@ -1,22 +0,0 @@
-<!--
-
- Copyright (C) 2009 eXo Platform SAS.
-
- This is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of
- the License, or (at your option) any later version.
-
- This software is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this software; if not, write to the Free
- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-
--->
-
-<Context path="/eXoResources" docBase="eXoResources" debug="0" reloadable="true" crossContext="true"/>
Deleted: portal/branches/wci/packaging/tomcat/pkg/src/main/resources/tomcat/conf/Catalina/localhost/portal.xml
===================================================================
--- portal/branches/wci/packaging/tomcat/pkg/src/main/resources/tomcat/conf/Catalina/localhost/portal.xml 2010-11-29 15:22:49 UTC (rev 5353)
+++ portal/branches/wci/packaging/tomcat/pkg/src/main/resources/tomcat/conf/Catalina/localhost/portal.xml 2010-11-29 15:32:23 UTC (rev 5354)
@@ -1,32 +0,0 @@
-<!--
-
- Copyright (C) 2009 eXo Platform SAS.
-
- This is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of
- the License, or (at your option) any later version.
-
- This software is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this software; if not, write to the Free
- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-
--->
-
-<Context path='/portal' docBase='portal' debug='0' reloadable='true' crossContext='true' privileged='true'>
- <Logger className='org.apache.catalina.logger.SystemOutLogger'
- prefix='localhost_portal_log.' suffix='.txt' timestamp='true'/>
- <Manager className='org.apache.catalina.session.PersistentManager' saveOnRestart='false'/>
- <Realm className='org.apache.catalina.realm.JAASRealm'
- appName='gatein-domain'
- userClassNames='org.exoplatform.services.security.jaas.UserPrincipal'
- roleClassNames='org.exoplatform.services.security.jaas.RolePrincipal'
- debug='0' cache='false'/>
- <Valve className='org.apache.catalina.authenticator.FormAuthenticator' characterEncoding='UTF-8'/>
-</Context>
Deleted: portal/branches/wci/packaging/tomcat/pkg/src/main/resources/tomcat/conf/Catalina/localhost/rest.xml
===================================================================
--- portal/branches/wci/packaging/tomcat/pkg/src/main/resources/tomcat/conf/Catalina/localhost/rest.xml 2010-11-29 15:22:49 UTC (rev 5353)
+++ portal/branches/wci/packaging/tomcat/pkg/src/main/resources/tomcat/conf/Catalina/localhost/rest.xml 2010-11-29 15:32:23 UTC (rev 5354)
@@ -1,32 +0,0 @@
-<!--
-
- Copyright (C) 2009 eXo Platform SAS.
-
- This is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of
- the License, or (at your option) any later version.
-
- This software is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this software; if not, write to the Free
- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-
--->
-
-<Context path="/rest" docBase="rest" reloadable="true" crossContext="false">
-
- <Logger className='org.apache.catalina.logger.SystemOutLogger'
- prefix='localhost_portal_log.' suffix='.txt' timestamp='true'/>
- <Manager className='org.apache.catalina.session.PersistentManager' saveOnRestart='false'/>
- <Realm className='org.apache.catalina.realm.JAASRealm'
- appName='gatein-domain'
- userClassNames="org.exoplatform.services.security.jaas.UserPrincipal"
- roleClassNames="org.exoplatform.services.security.jaas.RolePrincipal"
- debug='0' cache='false'/>
-</Context>
Deleted: portal/branches/wci/packaging/tomcat/pkg/src/main/resources/tomcat/conf/producer.server.xml
===================================================================
--- portal/branches/wci/packaging/tomcat/pkg/src/main/resources/tomcat/conf/producer.server.xml 2010-11-29 15:22:49 UTC (rev 5353)
+++ portal/branches/wci/packaging/tomcat/pkg/src/main/resources/tomcat/conf/producer.server.xml 2010-11-29 15:32:23 UTC (rev 5354)
@@ -1,387 +0,0 @@
-<!--
-
- Copyright (C) 2009 eXo Platform SAS.
-
- This is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of
- the License, or (at your option) any later version.
-
- This software is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this software; if not, write to the Free
- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-
--->
-
-<!-- Example Server Configuration File -->
-<!-- Note that component elements are nested corresponding to their
- parent-child relationships with each other -->
-
-<!-- A "Server" is a singleton element that represents the entire JVM,
- which may contain one or more "Service" instances. The Server
- listens for a shutdown command on the indicated port.
-
- Note: A "Server" is not itself a "Container", so you may not
- define subcomponents such as "Valves" or "Loggers" at this level.
- -->
-
-<Server port="8006" shutdown="SHUTDOWN" debug="0">
-
-
- <!-- Comment these entries out to disable JMX MBeans support -->
- <!-- You may also configure custom components (e.g. Valves/Realms) by
- including your own mbean-descriptor file(s), and setting the
- "descriptors" attribute to point to a ';' seperated list of paths
- (in the ClassLoader sense) of files to add to the default list.
- e.g. descriptors="/com/myfirm/mypackage/mbean-descriptor.xml"
- -->
- <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"
- debug="0"/>
- <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"
- debug="0"/>
-
- <!-- Global JNDI resources -->
- <GlobalNamingResources>
-
- <!-- Test entry for demonstration purposes -->
- <Environment name="simpleValue" type="java.lang.Integer" value="30"/>
-
- <!-- Editable user database that can also be used by
- UserDatabaseRealm to authenticate users -->
- <Resource name="UserDatabase" auth="Container"
- type="org.apache.catalina.UserDatabase"
- description="User database that can be updated and saved">
- </Resource>
- <ResourceParams name="UserDatabase">
- <parameter>
- <name>factory</name>
- <value>org.apache.catalina.users.MemoryUserDatabaseFactory</value>
- </parameter>
- <parameter>
- <name>pathname</name>
- <value>conf/tomcat-users.xml</value>
- </parameter>
- </ResourceParams>
-
- </GlobalNamingResources>
-
- <!-- A "Service" is a collection of one or more "Connectors" that share
- a single "Container" (and therefore the web applications visible
- within that Container). Normally, that Container is an "Engine",
- but this is not required.
-
- Note: A "Service" is not itself a "Container", so you may not
- define subcomponents such as "Valves" or "Loggers" at this level.
- -->
-
- <!-- Define the Tomcat Stand-Alone Service -->
- <Service name="Catalina">
-
- <!-- A "Connector" represents an endpoint by which requests are received
- and responses are returned. Each Connector passes requests on to the
- associated "Container" (normally an Engine) for processing.
-
- By default, a non-SSL HTTP/1.1 Connector is established on port 8080.
- You can also enable an SSL HTTP/1.1 Connector on port 8443 by
- following the instructions below and uncommenting the second Connector
- entry. SSL support requires the following steps (see the SSL Config
- HOWTO in the Tomcat 5 documentation bundle for more detailed
- instructions):
- * If your JDK version 1.3 or prior, download and install JSSE 1.0.2 or
- later, and put the JAR files into "$JAVA_HOME/jre/lib/ext".
- * Execute:
- %JAVA_HOME%\bin\keytool -genkey -alias tomcat -keyalg RSA (Windows)
- $JAVA_HOME/bin/keytool -genkey -alias tomcat -keyalg RSA (Unix)
- with a password value of "changeit" for both the certificate and
- the keystore itself.
-
- By default, DNS lookups are enabled when a web application calls
- request.getRemoteHost(). This can have an adverse impact on
- performance, so you can disable it by setting the
- "enableLookups" attribute to "false". When DNS lookups are disabled,
- request.getRemoteHost() will return the String version of the
- IP address of the remote client.
- -->
-
- <!-- Define a non-SSL Coyote HTTP/1.1 Connector on port 8080 -->
- <Connector port="8081"
- maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
- enableLookups="false" redirectPort="8444" acceptCount="100"
- debug="0" connectionTimeout="20000"
- disableUploadTimeout="true" />
- <!-- Note : To disable connection timeouts, set connectionTimeout value
- to -1 -->
-
- <!-- Note : To use gzip compression you could set the following properties :
-
- compression="on"
- compressionMinSize="2048"
- noCompressionUserAgents="gozilla, traviata"
- compressableMimeType="text/html,text/xml"
- -->
-
- <!-- Define a SSL Coyote HTTP/1.1 Connector on port 8443 -->
- <!--
- <Connector port="8444"
- maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
- enableLookups="false" disableUploadTimeout="true"
- acceptCount="100" debug="0" scheme="https" secure="true"
- clientAuth="false" sslProtocol="TLS" />
- -->
-
- <!-- Define a Coyote/JK2 AJP 1.3 Connector on port 8009 -->
- <Connector port="8010"
- enableLookups="false" redirectPort="8444" debug="0"
- protocol="AJP/1.3" />
-
- <!-- Define a Proxied HTTP/1.1 Connector on port 8082 -->
- <!-- See proxy documentation for more information about using this. -->
- <!--
- <Connector port="8083"
- maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
- enableLookups="false"
- acceptCount="100" debug="0" connectionTimeout="20000"
- proxyPort="81" disableUploadTimeout="true" />
- -->
-
- <!-- An Engine represents the entry point (within Catalina) that processes
- every request. The Engine implementation for Tomcat stand alone
- analyzes the HTTP headers included with the request, and passes them
- on to the appropriate Host (virtual host). -->
-
- <!-- You should set jvmRoute to support load-balancing via JK/JK2 ie :
- <Engine name="Standalone" defaultHost="localhost" debug="0" jvmRoute="jvm1">
- -->
-
- <!-- Define the top level container in our container hierarchy -->
- <Engine name="Catalina" defaultHost="localhost" debug="0">
-
- <!-- The request dumper valve dumps useful debugging information about
- the request headers and cookies that were received, and the response
- headers and cookies that were sent, for all requests received by
- this instance of Tomcat. If you care only about requests to a
- particular virtual host, or a particular application, nest this
- element inside the corresponding <Host> or <Context> entry instead.
-
- For a similar mechanism that is portable to all Servlet 2.4
- containers, check out the "RequestDumperFilter" Filter in the
- example application (the source for this filter may be found in
- "$CATALINA_HOME/webapps/examples/WEB-INF/classes/filters").
-
- Request dumping is disabled by default. Uncomment the following
- element to enable it. -->
- <!--
- <Valve className="org.apache.catalina.valves.RequestDumperValve"/>
- -->
-
- <!-- Global logger unless overridden at lower levels -->
- <Logger className="org.apache.catalina.logger.FileLogger"
- prefix="catalina_log." suffix=".txt"
- timestamp="true"/>
-
- <!-- Because this Realm is here, an instance will be shared globally -->
-
- <!-- This Realm uses the UserDatabase configured in the global JNDI
- resources under the key "UserDatabase". Any edits
- that are performed against this UserDatabase are immediately
- available for use by the Realm. -->
- <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
- debug="0" resourceName="UserDatabase"/>
-
- <!-- Comment out the old realm but leave here for now in case we
- need to go back quickly -->
- <!--
- <Realm className="org.apache.catalina.realm.MemoryRealm" />
- -->
-
- <!-- Replace the above Realm with one of the following to get a Realm
- stored in a database and accessed via JDBC -->
-
- <!--
- <Realm className="org.apache.catalina.realm.JDBCRealm" debug="99"
- driverName="org.gjt.mm.mysql.Driver"
- connectionURL="jdbc:mysql://localhost/authority"
- connectionName="test" connectionPassword="test"
- userTable="users" userNameCol="user_name" userCredCol="user_pass"
- userRoleTable="user_roles" roleNameCol="role_name" />
- -->
-
- <!--
- <Realm className="org.apache.catalina.realm.JDBCRealm" debug="99"
- driverName="oracle.jdbc.driver.OracleDriver"
- connectionURL="jdbc:oracle:thin:@ntserver:1521:ORCL"
- connectionName="scott" connectionPassword="tiger"
- userTable="users" userNameCol="user_name" userCredCol="user_pass"
- userRoleTable="user_roles" roleNameCol="role_name" />
- -->
-
- <!--
- <Realm className="org.apache.catalina.realm.JDBCRealm" debug="99"
- driverName="sun.jdbc.odbc.JdbcOdbcDriver"
- connectionURL="jdbc:odbc:CATALINA"
- userTable="users" userNameCol="user_name" userCredCol="user_pass"
- userRoleTable="user_roles" roleNameCol="role_name" />
- -->
-
- <!-- Define the default virtual host
- Note: XML Schema validation will not work with Xerces 2.2.
- -->
- <Host name="localhost" debug="0" appBase="webapps"
- unpackWARs="true" autoDeploy="true"
- xmlValidation="false" xmlNamespaceAware="false">
-
- <!-- Defines a cluster for this node,
- By defining this element, means that every manager will be changed.
- So when running a cluster, only make sure that you have webapps in there
- that need to be clustered and remove the other ones.
- A cluster has the following parameters:
-
- className = the fully qualified name of the cluster class
-
- name = a descriptive name for your cluster, can be anything
-
- debug = the debug level, higher means more output
-
- mcastAddr = the multicast address, has to be the same for all the nodes
-
- mcastPort = the multicast port, has to be the same for all the nodes
-
- mcastFrequency = the number of milliseconds in between sending a "I'm alive" heartbeat
-
- mcastDropTime = the number a milliseconds before a node is considered "dead" if no heartbeat is received
-
- tcpThreadCount = the number of threads to handle incoming replication requests, optimal would be the same amount of threads as nodes
-
- tcpListenAddress = the listen address (bind address) for TCP cluster request on this host,
- in case of multiple ethernet cards.
- auto means that address becomes
- InetAddress.getLocalHost().getHostAddress()
-
- tcpListenPort = the tcp listen port
-
- tcpSelectorTimeout = the timeout (ms) for the Selector.select() method in case the OS
- has a wakup bug in java.nio. Set to 0 for no timeout
-
- printToScreen = true means that managers will also print to std.out
-
- expireSessionsOnShutdown = true means that
-
- useDirtyFlag = true means that we only replicate a session after setAttribute,removeAttribute has been called.
- false means to replicate the session after each request.
- false means that replication would work for the following piece of code:
- <%
- HashMap map = (HashMap)session.getAttribute("map");
- map.put("key","value");
- %>
- replicationMode = can be either 'synchronous' or 'asynchronous'.
- * Synchronous means that the thread that executes the request, is also the
- thread the replicates the data to the other nodes, and will not return until all
- nodes have received the information.
- * Asynchronous means that there is a specific 'sender' thread for each cluster node,
- so the request thread will queue the replication request into a "smart" queue,
- and then return to the client.
- The "smart" queue is a queue where when a session is added to the queue, and the same session
- already exists in the queue from a previous request, that session will be replaced
- in the queue instead of replicating two requests. This almost never happens, unless there is a
- large network delay.
- -->
-
- <!-- When uncommenting the cluster, REMEMBER to uncomment the replication Valve below as well
-
-
- <Cluster className="org.apache.catalina.cluster.tcp.SimpleTcpCluster"
- name="FilipsCluster"
- debug="10"
- serviceclass="org.apache.catalina.cluster.mcast.McastService"
- mcastAddr="228.0.0.4"
- mcastPort="45565"
- mcastFrequency="500"
- mcastDropTime="3000"
- tcpThreadCount="2"
- tcpListenAddress="auto"
- tcpListenPort="4002"
- tcpSelectorTimeout="100"
- printToScreen="false"
- expireSessionsOnShutdown="false"
- useDirtyFlag="true"
- replicationMode="synchronous"
- />
- -->
- <!--
- When configuring for clustering, you also add in a valve to catch all the requests
- coming in, at the end of the request, the session may or may not be replicated.
- A session is replicated if and only if all the conditions are met:
- 1. useDirtyFlag is true or setAttribute or removeAttribute has been called AND
- 2. a session exists (has been created)
- 3. the request is not trapped by the "filter" attribute
-
- The filter attribute is to filter out requests that could not modify the session,
- hence we don't replicate the session after the end of this request.
- The filter is negative, ie, anything you put in the filter, you mean to filter out,
- ie, no replication will be done on requests that match one of the filters.
- The filter attribute is delimited by ;, so you can't escape out ; even if you wanted to.
-
- filter=".*\.gif;.*\.js;" means that we will not replicate the session after requests with the URI
- ending with .gif and .js are intercepted.
- -->
- <!--
- <Valve className="org.apache.catalina.cluster.tcp.ReplicationValve"
- filter=".*\.gif;.*\.js;.*\.jpg;.*\.htm;.*\.html;.*\.txt;"/>
-
- -->
- <!-- Normally, users must authenticate themselves to each web app
- individually. Uncomment the following entry if you would like
- a user to be authenticated the first time they encounter a
- resource protected by a security constraint, and then have that
- user identity maintained across *all* web applications contained
- in this virtual host. -->
- <!--
- <Valve className="org.apache.catalina.authenticator.SingleSignOn"
- debug="0"/>
- -->
-
- <!-- Access log processes all requests for this virtual host. By
- default, log files are created in the "logs" directory relative to
- $CATALINA_HOME. If you wish, you can specify a different
- directory with the "directory" attribute. Specify either a relative
- (to $CATALINA_HOME) or absolute path to the desired directory.
- -->
- <!--
- <Valve className="org.apache.catalina.valves.AccessLogValve"
- directory="logs" prefix="localhost_access_log." suffix=".txt"
- pattern="common" resolveHosts="false"/>
- -->
-
- <!-- Logger shared by all Contexts related to this virtual host. By
- default (when using FileLogger), log files are created in the "logs"
- directory relative to $CATALINA_HOME. If you wish, you can specify
- a different directory with the "directory" attribute. Specify either a
- relative (to $CATALINA_HOME) or absolute path to the desired
- directory.-->
- <Logger className="org.apache.catalina.logger.FileLogger"
- directory="logs" prefix="localhost_log." suffix=".txt"
- timestamp="true"/>
-
- <!-- Define properties for each web application. This is only needed
- if you want to set non-default properties, or have web application
- document roots in places other than the virtual host's appBase
- directory. -->
-
- <!-- Tomcat Root Context -->
- <!--
- <Context path="" docBase="ROOT" debug="0">
- -->
-
- </Host>
-
- </Engine>
-
- </Service>
-
-</Server>
Added: portal/branches/wci/web/eXoResources/src/main/webapp/META-INF/context.xml
===================================================================
--- portal/branches/wci/web/eXoResources/src/main/webapp/META-INF/context.xml (rev 0)
+++ portal/branches/wci/web/eXoResources/src/main/webapp/META-INF/context.xml 2010-11-29 15:32:23 UTC (rev 5354)
@@ -0,0 +1,22 @@
+<!--
+
+ Copyright (C) 2009 eXo Platform SAS.
+
+ This is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+
+-->
+
+<Context path="/eXoResources" docBase="eXoResources" debug="0" reloadable="true" crossContext="true"/>
\ No newline at end of file
Added: portal/branches/wci/web/portal/src/main/webapp/META-INF/context.xml
===================================================================
--- portal/branches/wci/web/portal/src/main/webapp/META-INF/context.xml (rev 0)
+++ portal/branches/wci/web/portal/src/main/webapp/META-INF/context.xml 2010-11-29 15:32:23 UTC (rev 5354)
@@ -0,0 +1,31 @@
+<!--
+
+ Copyright (C) 2009 eXo Platform SAS.
+
+ This is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+
+-->
+
+<Context path='/portal' docBase='portal' debug='0' reloadable='true' crossContext='true' privileged='true'>
+ <Realm className='org.apache.catalina.realm.JAASRealm'
+ appName='gatein-domain'
+ userClassNames='org.exoplatform.services.security.jaas.UserPrincipal'
+ roleClassNames='org.exoplatform.services.security.jaas.RolePrincipal'
+ debug='0' cache='false'/>
+ <Valve
+ className='org.apache.catalina.authenticator.FormAuthenticator'
+ characterEncoding='UTF-8'/>
+</Context>
\ No newline at end of file
Modified: portal/branches/wci/web/portal/src/main/webapp/groovy/portal/webui/UILoginForm.gtmpl
===================================================================
--- portal/branches/wci/web/portal/src/main/webapp/groovy/portal/webui/UILoginForm.gtmpl 2010-11-29 15:22:49 UTC (rev 5353)
+++ portal/branches/wci/web/portal/src/main/webapp/groovy/portal/webui/UILoginForm.gtmpl 2010-11-29 15:32:23 UTC (rev 5354)
@@ -7,7 +7,7 @@
jsmanager.addCustomizedOnLoadScript('document.getElementById("UIPortalComponentLogin").username.focus();');
HttpSession session = rcontext.getRequest().getSession();
String requestPath = rcontext.getRequestContextPath() + "/private/" + rcontext.getPortalOwner();
- session.setAttribute("initialURI", requestPath);
+ //session.setAttribute("initialURI", requestPath);
%>
<div class="UILoginForm">
<div class="LoginDecorator">
@@ -23,7 +23,7 @@
<div class="LoginDecoratorBackground">
<div class="LoginDetailBox">
<form class="UIForm" id="$uicomponent.id" name="loginForm" action="<%= rcontext.getRequestContextPath() + "/login"%>" method="post" style="margin: 0px;">
- <input type="hidden" name="initialURI" value="<%=session.getAttribute("initialURI"); %>"/>
+ <input type="hidden" name="initialURI" value="<%=requestPath %>"/>
<div class="VerticalLayout">
<table class="UIFormGrid">
<tr class="UserNameField">
Modified: portal/branches/wci/web/portal/src/main/webapp/login/jsp/login.jsp
===================================================================
--- portal/branches/wci/web/portal/src/main/webapp/login/jsp/login.jsp 2010-11-29 15:22:49 UTC (rev 5353)
+++ portal/branches/wci/web/portal/src/main/webapp/login/jsp/login.jsp 2010-11-29 15:32:23 UTC (rev 5354)
@@ -26,6 +26,7 @@
<%@ page import="java.util.ResourceBundle"%>
<%@ page import="org.exoplatform.web.login.InitiateLoginServlet"%>
<%@ page import="org.gatein.common.text.EntityEncoder"%>
+<%--<%@ page import="javax.servlet.http.HttpSession"%>--%>
<%@ page language="java" %>
<%
String contextPath = request.getContextPath() ;
@@ -44,6 +45,10 @@
cookie.setMaxAge(0);
response.addCookie(cookie);
+ //String uri = (String)request.getAttribute("org.gatein.portal.login.initial_uri");
+ /*HttpSession httpSession = request.getSession(true);
+ String uri = (String)httpSession.getAttribute("org.gatein.portal.login.initial_uri");
+ httpSession.removeAttribute("org.gatein.portal.login.initial_uri");*/
String uri = (String)request.getAttribute("org.gatein.portal.login.initial_uri");
response.setCharacterEncoding("UTF-8");
Added: portal/branches/wci/web/rest/src/main/webapp/META-INF/context.xml
===================================================================
--- portal/branches/wci/web/rest/src/main/webapp/META-INF/context.xml (rev 0)
+++ portal/branches/wci/web/rest/src/main/webapp/META-INF/context.xml 2010-11-29 15:32:23 UTC (rev 5354)
@@ -0,0 +1,29 @@
+<!--
+
+ Copyright (C) 2009 eXo Platform SAS.
+
+ This is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+
+-->
+
+<Context path="/rest" docBase="rest" reloadable="true" crossContext="false">
+
+ <Realm className='org.apache.catalina.realm.JAASRealm'
+ appName='gatein-domain'
+ userClassNames="org.exoplatform.services.security.jaas.UserPrincipal"
+ roleClassNames="org.exoplatform.services.security.jaas.RolePrincipal"
+ debug='0' cache='false'/>
+</Context>
\ No newline at end of file
14 years
gatein SVN: r5353 - in portal/branches/navcontroller/component/web/controller/src: test/java/org/exoplatform/web/controller/router and 1 other directory.
by do-not-reply@jboss.org
Author: julien_viet
Date: 2010-11-29 10:22:49 -0500 (Mon, 29 Nov 2010)
New Revision: 5353
Modified:
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/Route.java
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestBuildRoute.java
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestLegacyPortal.java
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPathParamEncoding.java
Log:
now use the correct form decoding in the router
Modified: portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/Route.java
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/Route.java 2010-11-29 14:52:18 UTC (rev 5352)
+++ portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/Route.java 2010-11-29 15:22:49 UTC (rev 5353)
@@ -24,6 +24,9 @@
import org.exoplatform.web.controller.metadata.RequestParamDescriptor;
import org.exoplatform.web.controller.metadata.RouteDescriptor;
import org.exoplatform.web.controller.metadata.RouteParamDescriptor;
+import org.exoplatform.web.controller.regexp.RENode;
+import org.exoplatform.web.controller.regexp.RegExpParser;
+import org.exoplatform.web.controller.regexp.SyntaxException;
import java.util.ArrayList;
import java.util.Collections;
@@ -640,25 +643,49 @@
//
if (regex == null)
{
- regex = "[^/]+";
+ if (encodingMode == EncodingMode.FORM)
+ {
+ regex = ".+";
+ }
+ else
+ {
+ regex = "[^/]+";
+ }
}
// Now analyse the regexp
- String regex2;
try
{
+ RegExpParser parser = new RegExpParser(regex);
+ RENode.Disjunction disjunction = parser.parseDisjunction();
+
+ // Process for form
+ if (encodingMode == EncodingMode.FORM)
+ {
+ RouteEscaper escaper = new RouteEscaper('/', '_');
+ escaper.visit(disjunction);
+ }
+
+ //
RegExpAnalyser analyser = new RegExpAnalyser();
- analyser.process(regex);
- regex2 = analyser.getPattern();
- System.out.println("" + regex + " -> " + regex2);
+ analyser.process(disjunction);
+
+ //
+ String tmp = analyser.getPattern();
+ System.out.println("" + regex + " -> " + tmp);
+ regex = tmp;
}
+ catch (SyntaxException e)
+ {
+ throw new RuntimeException(e);
+ }
catch (MalformedRegExpException e)
{
throw new RuntimeException(e);
}
//
- builder.expr("(").expr(regex2).expr(")");
+ builder.expr("(").expr(regex).expr(")");
//
parameterPatterns.add(new PathParam(
Modified: portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestBuildRoute.java
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestBuildRoute.java 2010-11-29 14:52:18 UTC (rev 5352)
+++ portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestBuildRoute.java 2010-11-29 15:22:49 UTC (rev 5353)
@@ -119,10 +119,10 @@
assertEquals(0, router.root.getSegmentNames().size());
assertEquals(1, router.root.getPatternSize());
PatternRoute patternRoute = router.root.getPattern(0);
- assertEquals("^/(.*)", patternRoute.pattern.toString());
+ assertEquals("^/([^/]*)", patternRoute.pattern.toString());
assertEquals(1, patternRoute.params.size());
assertEquals(QualifiedName.create("a"), patternRoute.params.get(0).name);
- assertEquals("^.*$", patternRoute.params.get(0).pattern.toString());
+ assertEquals("^[^/]*$", patternRoute.params.get(0).pattern.toString());
assertEquals(EncodingMode.FORM, patternRoute.params.get(0).encodingMode);
assertEquals(2, patternRoute.chunks.size());
assertEquals("", patternRoute.chunks.get(0));
Modified: portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestLegacyPortal.java
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestLegacyPortal.java 2010-11-29 14:52:18 UTC (rev 5352)
+++ portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestLegacyPortal.java 2010-11-29 15:22:49 UTC (rev 5353)
@@ -48,10 +48,14 @@
addRequestParam(QualifiedName.parse("gtn:componentid"), "portal:componentId", null, false).
addRequestParam(QualifiedName.parse("gtn:action"), "portal:action", null, false).
addRequestParam(QualifiedName.parse("gtn:objectid"), "portal:objectId", null, false).
- addRoute(new RouteDescriptor("/public/{gtn:sitename}{gtn:path}").
- addRouteParam(QualifiedName.parse("gtn:access"), "public")).addPathParam(QualifiedName.parse("gtn:path"), ".*", EncodingMode.PRESERVE_PATH).
- addRoute(new RouteDescriptor("/private/{gtn:sitename}{gtn:path}").addPathParam(QualifiedName.parse("gtn:path"), ".*", EncodingMode.PRESERVE_PATH).
- addRouteParam(QualifiedName.parse("gtn:access"), "private"));
+ addRoute(
+ new RouteDescriptor("/public/{gtn:sitename}{gtn:path}").
+ addRouteParam(QualifiedName.parse("gtn:access"), "public")).
+ addPathParam(QualifiedName.parse("gtn:path"), ".*", EncodingMode.PRESERVE_PATH).
+ addRoute(
+ new RouteDescriptor("/private/{gtn:sitename}{gtn:path}").
+ addPathParam(QualifiedName.parse("gtn:path"), ".*", EncodingMode.PRESERVE_PATH).
+ addRouteParam(QualifiedName.parse("gtn:access"), "private"));
//
routerMD.addRoute(portal);
Modified: portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPathParamEncoding.java
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPathParamEncoding.java 2010-11-29 14:52:18 UTC (rev 5352)
+++ portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPathParamEncoding.java 2010-11-29 15:22:49 UTC (rev 5353)
@@ -35,7 +35,7 @@
public void testDefaultForm() throws Exception
{
RouterDescriptor routerMD = new RouterDescriptor();
- routerMD.addRoute(new RouteDescriptor("/{p}").addPathParam(QualifiedName.parse("p"), "[^/]+", EncodingMode.FORM));
+ routerMD.addRoute(new RouteDescriptor("/{p}").addPathParam(QualifiedName.parse("p"), ".+", EncodingMode.FORM));
Router router = new Router(routerMD);
// Route
@@ -59,6 +59,22 @@
assertEquals(null, router.render(Collections.singletonMap(QualifiedName.create("p"), "/")));
}
+ public void testD() throws Exception
+ {
+ RouterDescriptor routerMD = new RouterDescriptor();
+ routerMD.addRoute(new RouteDescriptor("/{p}").
+ addPathParam(QualifiedName.parse("p"), "/[a-z]+/[a-z]+/?", EncodingMode.FORM));
+ Router router = new Router(routerMD);
+
+ // Route
+ assertEquals(Collections.singletonMap(QualifiedName.create("p"), "/platform/administrator"), router.route("/_platform_administrator"));
+ assertEquals(Collections.singletonMap(QualifiedName.create("p"), "/platform/administrator"), router.route("/_platform_administrator/"));
+ assertEquals(Collections.singletonMap(QualifiedName.create("p"), "/platform/administrator/"), router.route("/_platform_administrator_"));
+ assertEquals(Collections.singletonMap(QualifiedName.create("p"), "/platform/administrator/"), router.route("/_platform_administrator_/"));
+
+ // todo : render
+ }
+
public void testWildcardPathParamWithPreservePath() throws Exception
{
RouterDescriptor routerMD = new RouterDescriptor();
14 years
gatein SVN: r5352 - in portal/branches/navcontroller/component/web/controller/src: test/java/org/exoplatform/web/controller/router and 1 other directory.
by do-not-reply@jboss.org
Author: julien_viet
Date: 2010-11-29 09:52:18 -0500 (Mon, 29 Nov 2010)
New Revision: 5352
Modified:
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/RENode.java
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestRouteEscaper.java
Log:
add relevant unit test for route escape
Modified: portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/RENode.java
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/RENode.java 2010-11-29 13:30:56 UTC (rev 5351)
+++ portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/RENode.java 2010-11-29 14:52:18 UTC (rev 5352)
@@ -31,8 +31,12 @@
public abstract String toString();
- public final RENode replaceBy(RENode that)
+ public final RENode replaceBy(RENode that) throws IllegalStateException
{
+ if (owner == null)
+ {
+ throw new IllegalStateException("Not attached");
+ }
return owner.replace(that);
}
@@ -779,9 +783,16 @@
super(type);
//
- if (node != null && node.owner != null)
+ if (node != null)
{
- throw new IllegalArgumentException();
+ if (node.owner != null)
+ {
+ throw new IllegalArgumentException();
+ }
+ else
+ {
+ node.owner = this;
+ }
}
this.node = node;
}
Modified: portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestRouteEscaper.java
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestRouteEscaper.java 2010-11-29 13:30:56 UTC (rev 5351)
+++ portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestRouteEscaper.java 2010-11-29 14:52:18 UTC (rev 5352)
@@ -23,6 +23,9 @@
import org.exoplatform.web.controller.regexp.RENode;
import org.exoplatform.web.controller.regexp.RegExpParser;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
/**
* @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
* @version $Revision$
@@ -30,7 +33,7 @@
public class TestRouteEscaper extends BaseGateInTest
{
- private void assertFoo(String pattern) throws Exception
+ private void match(String pattern, String test, String expectedValue) throws Exception
{
RegExpParser parser = new RegExpParser(pattern);
RouteEscaper escaper = new RouteEscaper('/', '_');
@@ -39,13 +42,20 @@
RegExpAnalyser analyser = new RegExpAnalyser();
analyser.process(re);
System.out.println(pattern + " --> " + analyser.getPattern());
+ Pattern p = Pattern.compile(analyser.getPattern());
+ Matcher matcher = p.matcher(test);
+ assertTrue(matcher.find());
+ assertEquals(expectedValue, matcher.group());
}
- public void testFoo() throws Exception
+ public void testMatch() throws Exception
{
- assertFoo("/+");
- assertFoo(".*");
- assertFoo("[a/]");
- assertFoo("[,-1]");
+ match(".*", "_", "_");
+ match(".*", "_/", "_");
+ match(".*", "_/_", "_");
+ match("/", "_/", "_");
+ match("/*", "_/_", "_");
+ match("[/a]*", "_a_/_", "_a_");
+ match("[,-1&&[^/]]*", "_/_", "");
}
}
14 years
gatein SVN: r5351 - in portal/branches/navcontroller/component/web/controller/src: main/java/org/exoplatform/web/controller/router and 2 other directories.
by do-not-reply@jboss.org
Author: julien_viet
Date: 2010-11-29 08:30:56 -0500 (Mon, 29 Nov 2010)
New Revision: 5351
Added:
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/RouteEscaper.java
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestRouteEscaper.java
Modified:
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/RENode.java
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/RegExpParser.java
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/RegExpAnalyser.java
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/regexp/TestParser.java
Log:
start to properly escape / in route
Modified: portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/RENode.java
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/RENode.java 2010-11-29 11:40:57 UTC (rev 5350)
+++ portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/RENode.java 2010-11-29 13:30:56 UTC (rev 5351)
@@ -31,6 +31,11 @@
public abstract String toString();
+ public final RENode replaceBy(RENode that)
+ {
+ return owner.replace(that);
+ }
+
public static final class Disjunction extends RENode
{
@@ -47,8 +52,8 @@
public Disjunction(Alternative alternative, Disjunction next)
{
- this.alternative = new NonNullableRef<Alternative>(alternative);
- this.next = new NullableRef<Disjunction>(next);
+ this.alternative = new NonNullableRef<Alternative>(Alternative.class, alternative);
+ this.next = new NullableRef<Disjunction>(Disjunction.class, next);
}
public Alternative getAlternative()
@@ -101,8 +106,8 @@
public Alternative(Expr exp, Alternative next)
{
- this.exp = new NonNullableRef<Expr>(exp);
- this.next = new NullableRef<Alternative>(next);
+ this.exp = new NonNullableRef<Expr>(Expr.class, exp);
+ this.next = new NullableRef<Alternative>(Alternative.class, next);
}
public Expr getExp()
@@ -213,7 +218,7 @@
}
}
- public static final class Dot extends Atom
+ public static final class Any extends Atom
{
@Override
protected void writeTo(StringBuilder sb)
@@ -233,7 +238,7 @@
public Group(Disjunction disjunction, boolean capturing)
{
- this.disjunction = new NonNullableRef<Disjunction>(disjunction);
+ this.disjunction = new NonNullableRef<Disjunction>(Disjunction.class, disjunction);
this.capturing = capturing;
}
@@ -264,13 +269,13 @@
}
}
- public static final class Character extends Atom
+ public static final class Char extends Atom
{
/** . */
private char value;
- public Character(char value)
+ public Char(char value)
{
this.value = value;
}
@@ -298,9 +303,9 @@
/** . */
private final Ref<CharacterClassExpr> expr;
- protected CharacterClass(CharacterClassExpr expr)
+ public CharacterClass(CharacterClassExpr expr)
{
- this.expr = new NonNullableRef<CharacterClassExpr>(expr);
+ this.expr = new NonNullableRef<CharacterClassExpr>(CharacterClassExpr.class, expr);
}
public CharacterClassExpr getExpr()
@@ -327,6 +332,29 @@
{
}
+ /**
+ * Remove the specifed char from the expression.
+ *
+ * @param c the char to remove
+ * @return the replacement for this node
+ */
+ public CharacterClassExpr remove(char c)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Remove the specifed char from the expression.
+ *
+ * @param src the char is substituted
+ * @param dst the char that substitutes
+ * @return the replacement for this node
+ */
+ public CharacterClassExpr replace(char src, char dst)
+ {
+ throw new UnsupportedOperationException();
+ }
+
public static class Not extends CharacterClassExpr
{
@@ -335,7 +363,7 @@
public Not(CharacterClassExpr negated)
{
- this.negated = new NonNullableRef<CharacterClassExpr>(negated);
+ this.negated = new NullableRef<CharacterClassExpr>(CharacterClassExpr.class, negated);
}
public CharacterClassExpr getNegated()
@@ -349,6 +377,20 @@
}
@Override
+ public CharacterClassExpr remove(char c)
+ {
+ this.negated.get().remove(c);
+ return this;
+ }
+
+ @Override
+ public CharacterClassExpr replace(char src, char dst)
+ {
+ this.negated.get().replace(src, dst);
+ return this;
+ }
+
+ @Override
public String toString()
{
return "[^" + negated.get() + "]";
@@ -366,8 +408,8 @@
public Or(CharacterClassExpr left, CharacterClassExpr right)
{
- this.left = new NonNullableRef<CharacterClassExpr>(left);
- this.right = new NonNullableRef<CharacterClassExpr>(right);
+ this.left = new NullableRef<CharacterClassExpr>(CharacterClassExpr.class, left);
+ this.right = new NullableRef<CharacterClassExpr>(CharacterClassExpr.class, right);
}
public CharacterClassExpr getLeft()
@@ -391,9 +433,39 @@
}
@Override
+ public CharacterClassExpr remove(char c)
+ {
+ if (left.isNotNull())
+ {
+ left.get().remove(c);
+ }
+ if (right.isNotNull())
+ {
+ right.get().remove(c);
+ }
+ return this;
+ }
+
+ @Override
+ public CharacterClassExpr replace(char src, char dst)
+ {
+ if (left.isNotNull())
+ {
+ left.get().replace(src, dst);
+ }
+ if (right.isNotNull())
+ {
+ right.get().replace(src, dst);
+ }
+ return this;
+ }
+
+ @Override
public String toString()
{
- return "[" + left.get() + right.get() + "]";
+ String l = left.isNotNull() ? left.get().toString() : "";
+ String r = right.isNotNull() ? right.get().toString() : "";
+ return "[" + l + "||" + r + "]";
}
}
@@ -408,8 +480,8 @@
public And(CharacterClassExpr left, CharacterClassExpr right)
{
- this.left = new NonNullableRef<CharacterClassExpr>(left);
- this.right = new NonNullableRef<CharacterClassExpr>(right);
+ this.left = new NullableRef<CharacterClassExpr>(CharacterClassExpr.class, left);
+ this.right = new NullableRef<CharacterClassExpr>(CharacterClassExpr.class, right);
}
public CharacterClassExpr getLeft()
@@ -433,19 +505,49 @@
}
@Override
+ public CharacterClassExpr remove(char c)
+ {
+ if (left.isNotNull())
+ {
+ left.get().remove(c);
+ }
+ if (right.isNotNull())
+ {
+ right.get().remove(c);
+ }
+ return this;
+ }
+
+ @Override
+ public CharacterClassExpr replace(char src, char dst)
+ {
+ if (left.isNotNull())
+ {
+ left.get().replace(src, dst);
+ }
+ if (right.isNotNull())
+ {
+ right.get().replace(src, dst);
+ }
+ return this;
+ }
+
+ @Override
public String toString()
{
- return "[" + left.get() + "&&" + right.get() + "]";
+ String l = left.isNotNull() ? left.get().toString() : "";
+ String r = right.isNotNull() ? right.get().toString() : "";
+ return "[" + l + "&&" + r + "]";
}
}
- public static class Simple extends CharacterClassExpr
+ public static class Char extends CharacterClassExpr
{
/** . */
private char value;
- public Simple(char value)
+ public Char(char value)
{
this.value = value;
}
@@ -461,6 +563,30 @@
}
@Override
+ public CharacterClassExpr remove(char c)
+ {
+ if (c == value)
+ {
+ replaceBy(null);
+ return null;
+ }
+ else
+ {
+ return this;
+ }
+ }
+
+ @Override
+ public CharacterClassExpr replace(char src, char dst)
+ {
+ if (src == value)
+ {
+ value = dst;
+ }
+ return this;
+ }
+
+ @Override
public String toString()
{
return "[" + value + "]";
@@ -478,10 +604,92 @@
public Range(char from, char to)
{
+ if (from >= to)
+ {
+ throw new IllegalArgumentException("From cannot be greater or equals than to");
+ }
this.from = from;
this.to = to;
}
+ public CharacterClassExpr remove(char c) throws IllegalArgumentException
+ {
+ if (from == to)
+ {
+ if (from == c)
+ {
+ throw new UnsupportedOperationException();
+ }
+ }
+ else if (from +1 == to)
+ {
+ if (from == c)
+ {
+ Char repl = new Char(to);
+ replaceBy(repl);
+ return repl;
+ }
+ else
+ {
+ Char repl = new Char(from);
+ replaceBy(repl);
+ return repl;
+ }
+ }
+ else
+ {
+ if (from == c)
+ {
+ from++;
+ }
+ else if (to == c)
+ {
+ to--;
+ }
+ else if (from < c && c < to)
+ {
+ CharacterClassExpr left;
+ if (from + 1 == c)
+ {
+ left = new Char(from);
+ }
+ else
+ {
+ left = new Range(from, (char)(c - 1));
+ }
+ CharacterClassExpr right;
+ if (c == to - 1)
+ {
+ right = new Char(to);
+ }
+ else
+ {
+ right = new Range((char)(c + 1), to);
+ }
+ Or repl = new Or(left, right);
+ replaceBy(repl);
+ return repl;
+ }
+ }
+
+ // We keep the same node
+ return this;
+ }
+
+ @Override
+ public CharacterClassExpr replace(char src, char dst)
+ {
+ CharacterClassExpr repl = remove(src);
+ if (repl != this)
+ {
+ Or or = new Or(null, new Char(dst));
+ repl.replaceBy(or);
+ or.setLeft(repl);
+ repl = or;
+ }
+ return repl;
+ }
+
public char getFrom()
{
return from;
@@ -512,16 +720,47 @@
protected abstract class Ref<N extends RENode>
{
- protected abstract Ref<N> set(N node);
+
+ /** . */
+ private final Class<N> type;
+
+ protected Ref(Class<N> type)
+ {
+ this.type = type;
+ }
+
+ public final Class<N> getType()
+ {
+ return type;
+ }
+
+ protected abstract N set(N node);
+
protected abstract N get();
+
protected final boolean isNull()
{
return get() == null;
}
+
protected final boolean isNotNull()
{
return get() != null;
}
+
+ protected final N replace(RENode that)
+ {
+ if (that == null || type.isInstance(that))
+ {
+ return set(type.cast(that));
+ }
+ else
+ {
+ throw new ClassCastException("Cannot cast node with type " + that.getClass().getName() + " to type " +
+ type.getName());
+ }
+ }
+
}
protected class NullableRef<N extends RENode> extends Ref<N>
@@ -530,13 +769,16 @@
/** . */
private N node;
- public NullableRef()
+ public NullableRef(Class<N> type)
{
- this(null);
+ this(type, null);
}
- public NullableRef(N node)
+ public NullableRef(Class<N> type, N node)
{
+ super(type);
+
+ //
if (node != null && node.owner != null)
{
throw new IllegalArgumentException();
@@ -545,12 +787,13 @@
}
@Override
- protected Ref<N> set(N node)
+ protected N set(N node)
{
if (node != null && node.owner != null)
{
throw new IllegalArgumentException();
}
+ N previous = this.node;
if (this.node != null)
{
this.node.owner = null;
@@ -564,7 +807,7 @@
{
this.node = null;
}
- return this;
+ return previous;
}
@Override
@@ -580,8 +823,11 @@
/** . */
private N node;
- public NonNullableRef(N node)
+ public NonNullableRef(Class<N> type, N node)
{
+ super(type);
+
+ //
if (node == null)
{
throw new NullPointerException();
@@ -595,20 +841,21 @@
}
@Override
- protected Ref<N> set(N node)
+ protected N set(N node)
{
if (node == null)
{
- throw new NullPointerException();
+ throw new NullPointerException("No null node accepted");
}
if (node.owner != null)
{
throw new IllegalArgumentException();
}
+ N previous = this.node;
this.node.owner = null;
node.owner = this;
this.node = node;
- return this;
+ return previous;
}
@Override
Modified: portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/RegExpParser.java
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/RegExpParser.java 2010-11-29 11:40:57 UTC (rev 5350)
+++ portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/RegExpParser.java 2010-11-29 13:30:56 UTC (rev 5351)
@@ -214,7 +214,7 @@
{
throw new SyntaxException();
}
- exp = new RENode.Character(escaped);
+ exp = new RENode.Char(escaped);
index++;
break;
}
@@ -223,11 +223,11 @@
throw new SyntaxException();
}
case '.':
- exp = new RENode.Dot();
+ exp = new RENode.Any();
index++;
break;
default:
- exp = new RENode.Character(c);
+ exp = new RENode.Char(c);
index++;
break;
//
@@ -371,7 +371,7 @@
}
else
{
- next = new RENode.CharacterClassExpr.Simple(c);
+ next = new RENode.CharacterClassExpr.Char(c);
}
}
Modified: portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/RegExpAnalyser.java
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/RegExpAnalyser.java 2010-11-29 11:40:57 UTC (rev 5350)
+++ portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/RegExpAnalyser.java 2010-11-29 13:30:56 UTC (rev 5351)
@@ -105,7 +105,7 @@
private void visit(RENode.Expr expression) throws MalformedRegExpException
{
Quantifier quantifier = null;
- if (expression instanceof RENode.Dot)
+ if (expression instanceof RENode.Any)
{
pattern.append('.');
quantifier = expression.getQuantifier();
@@ -118,9 +118,9 @@
pattern.append(")");
quantifier = expression.getQuantifier();
}
- else if (expression instanceof RENode.Character)
+ else if (expression instanceof RENode.Char)
{
- RENode.Character character = (RENode.Character)expression;
+ RENode.Char character = (RENode.Char)expression;
pattern.append(character.getValue());
quantifier = expression.getQuantifier();
}
@@ -142,9 +142,9 @@
private void visit(RENode.CharacterClassExpr expr, boolean braced)
{
- if (expr instanceof RENode.CharacterClassExpr.Simple)
+ if (expr instanceof RENode.CharacterClassExpr.Char)
{
- RENode.CharacterClass.CharacterClassExpr.Simple simple = (RENode.CharacterClass.CharacterClassExpr.Simple)expr;
+ RENode.CharacterClassExpr.Char simple = (RENode.CharacterClassExpr.Char)expr;
pattern.append(simple.getValue());
}
else if (expr instanceof RENode.CharacterClass.CharacterClassExpr.Range)
Added: portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/RouteEscaper.java
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/RouteEscaper.java (rev 0)
+++ portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/RouteEscaper.java 2010-11-29 13:30:56 UTC (rev 5351)
@@ -0,0 +1,105 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller.router;
+
+import org.exoplatform.web.controller.regexp.RENode;
+
+/**
+ * The route escaper transformer a regular expression with the following rules:
+ * <ul>
+ * <li>substitute any char occurence of the source <i>s</i> by the destination <i>d</i></li>
+ * <li>replace the <i>any</i> by the negated destination character <i>[^]</i></li>
+ * <li>append <i>&&[^s]</i> to any top character class</li>
+ * </ul>
+ *
+ * A few examples with <i>/</i> replaced by <i>_</i>:
+ *
+ * <ul>
+ * <li><i>/</i> becomes <i>_</i></li>
+ * <li><i>.</i> becomes <i>[^/]</i></li>
+ * <li><i>[a/]</i> becomes <i>[a_&[^/]]</i></li>
+ * <li><i>[,-1]</i> becomes <i>[,-.0-1_&&[^/]]</i></li>
+ * </ul>
+ *
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class RouteEscaper
+{
+
+ /** . */
+ private final char src;
+
+ /** . */
+ private final char dst;
+
+ public RouteEscaper(char src, char dst)
+ {
+ this.src = src;
+ this.dst = dst;
+ }
+
+ public void visit(RENode.Disjunction disjunction) throws MalformedRegExpException
+ {
+ visit(disjunction.getAlternative());
+ RENode.Disjunction next = disjunction.getNext();
+ if (next != null)
+ {
+ visit(next);
+ }
+ }
+
+ public void visit(RENode.Alternative alternative) throws MalformedRegExpException
+ {
+ visit(alternative.getExp());
+ RENode.Alternative next = alternative.getNext();
+ if (next != null)
+ {
+ visit(next);
+ }
+ }
+
+ public void visit(RENode.Expr expr)
+ {
+ if (expr instanceof RENode.Char)
+ {
+ RENode.Char c = (RENode.Char)expr;
+ if (c.getValue() == src)
+ {
+ c.setValue(dst);
+ }
+ }
+ if (expr instanceof RENode.Any)
+ {
+ RENode.CharacterClass repl = new RENode.CharacterClass(new RENode.CharacterClassExpr.Not(new RENode.CharacterClassExpr.Char('/')));
+ repl.setQuantifier(expr.getQuantifier());
+ expr.replaceBy(repl);
+ }
+ else if (expr instanceof RENode.CharacterClass)
+ {
+ RENode.CharacterClass characterClass = (RENode.CharacterClass)expr;
+ RENode.CharacterClassExpr ccExpr = characterClass.getExpr();
+ ccExpr = ccExpr.replace(src, dst);
+ RENode.CharacterClassExpr.And ccRepl = new RENode.CharacterClassExpr.And(null, new RENode.CharacterClassExpr.Not(new RENode.CharacterClassExpr.Char('/')));
+ ccExpr.replaceBy(ccRepl);
+ ccRepl.setLeft(ccExpr);
+ }
+ }
+}
Modified: portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/regexp/TestParser.java
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/regexp/TestParser.java 2010-11-29 11:40:57 UTC (rev 5350)
+++ portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/regexp/TestParser.java 2010-11-29 13:30:56 UTC (rev 5351)
@@ -222,17 +222,17 @@
new ParserTester("[^a]").assertParseCharacterClass("[^[a]]");
new ParserTester("[^a-b]").assertParseCharacterClass("[^[a-b]]");
new ParserTester("[a-b]").assertParseCharacterClass("[a-b]");
- new ParserTester("[ab]").assertParseCharacterClass("[[a][b]]");
- new ParserTester("[a&]").assertParseCharacterClass("[[a][&]]");
+ new ParserTester("[ab]").assertParseCharacterClass("[[a]||[b]]");
+ new ParserTester("[a&]").assertParseCharacterClass("[[a]||[&]]");
new ParserTester("[a&&b]").assertParseCharacterClass("[[a]&&[b]]");
new ParserTester("[a&&[^b]]").assertParseCharacterClass("[[a]&&[^[b]]]");
- new ParserTester("[a[^b]]").assertParseCharacterClass("[[a][^[b]]]");
- new ParserTester("[a[b]]").assertParseCharacterClass("[[a][b]]");
- new ParserTester("[a[b]c]").assertParseCharacterClass("[[a][[b][c]]]");
- new ParserTester("[[a]bc]").assertParseCharacterClass("[[a][[b][c]]]");
+ new ParserTester("[a[^b]]").assertParseCharacterClass("[[a]||[^[b]]]");
+ new ParserTester("[a[b]]").assertParseCharacterClass("[[a]||[b]]");
+ new ParserTester("[a[b]c]").assertParseCharacterClass("[[a]||[[b]||[c]]]");
+ new ParserTester("[[a]bc]").assertParseCharacterClass("[[a]||[[b]||[c]]]");
new ParserTester("[-]").assertParseCharacterClass("[-]");
- new ParserTester("[a-]").assertParseCharacterClass("[[a][-]]");
- new ParserTester("[---]").assertParseCharacterClass("[---]");
+ new ParserTester("[a-]").assertParseCharacterClass("[[a]||[-]]");
+// new ParserTester("[---]").assertParseCharacterClass("[---]");
new ParserTester("[#--]").assertParseCharacterClass("[#--]");
}
Added: portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestRouteEscaper.java
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestRouteEscaper.java (rev 0)
+++ portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestRouteEscaper.java 2010-11-29 13:30:56 UTC (rev 5351)
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller.router;
+
+import org.exoplatform.component.test.BaseGateInTest;
+import org.exoplatform.web.controller.regexp.RENode;
+import org.exoplatform.web.controller.regexp.RegExpParser;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class TestRouteEscaper extends BaseGateInTest
+{
+
+ private void assertFoo(String pattern) throws Exception
+ {
+ RegExpParser parser = new RegExpParser(pattern);
+ RouteEscaper escaper = new RouteEscaper('/', '_');
+ RENode.Disjunction re = parser.parseDisjunction();
+ escaper.visit(re);
+ RegExpAnalyser analyser = new RegExpAnalyser();
+ analyser.process(re);
+ System.out.println(pattern + " --> " + analyser.getPattern());
+ }
+
+ public void testFoo() throws Exception
+ {
+ assertFoo("/+");
+ assertFoo(".*");
+ assertFoo("[a/]");
+ assertFoo("[,-1]");
+ }
+}
14 years