Author: julien_viet
Date: 2010-09-14 10:01:03 -0400 (Tue, 14 Sep 2010)
New Revision: 4189
Added:
portal/branches/navcontroller/webui/framework/src/main/java/org/exoplatform/webui/application/UIComponentURLBuilder.java
portal/branches/navcontroller/webui/framework/src/main/java/org/exoplatform/webui/url/
portal/branches/navcontroller/webui/framework/src/main/java/org/exoplatform/webui/url/ComponentLocator.java
portal/branches/navcontroller/webui/portlet/src/main/java/org/exoplatform/portal/
portal/branches/navcontroller/webui/portlet/src/main/java/org/exoplatform/portal/url/
portal/branches/navcontroller/webui/portlet/src/main/java/org/exoplatform/portal/url/PortletResourceURL.java
Removed:
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/url/component/ComponentLocator.java
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/QualifiedName.java
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/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/router/RequestParamDef.java
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/url/ResourceURL.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/TestMatch.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/TestRequestParam.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/router.xml
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestContext.java
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestHandler.java
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/url/PortalURL.java
Log:
- allow request param to be optional
- use access type in route parameter
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-09-14
13:24:11 UTC (rev 4188)
+++
portal/branches/navcontroller/component/web/controller/src/main/java/gatein_router_1_0.xsd 2010-09-14
14:01:03 UTC (rev 4189)
@@ -38,15 +38,23 @@
<xs:complexType name="routeType">
<xs:sequence>
- <xs:element name="parameter" type="parameterType"
minOccurs="0" maxOccurs="unbounded"/>
+ <xs:element name="param" type="paramType"
minOccurs="0" maxOccurs="unbounded"/>
+ <xs:element name="request-param" type="requestParamType"
minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="route" type="routeType"
minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="path" type="xs:string"
use="required"/>
</xs:complexType>
- <xs:complexType name="parameterType">
+ <xs:complexType name="paramType">
<xs:attribute name="name" type="xs:string"
use="required"/>
<xs:attribute name="value" type="xs:string"
use="required"/>
</xs:complexType>
+ <xs:complexType name="requestParamType">
+ <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="required" type="xs:boolean"
use="optional"/>
+ </xs:complexType>
+
</xs:schema>
\ No newline at end of file
Modified:
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/QualifiedName.java
===================================================================
---
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/QualifiedName.java 2010-09-14
13:24:11 UTC (rev 4188)
+++
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/QualifiedName.java 2010-09-14
14:01:03 UTC (rev 4189)
@@ -92,6 +92,18 @@
return name;
}
+ public String getValue()
+ {
+ if (qualifier.isEmpty())
+ {
+ return name;
+ }
+ else
+ {
+ return "{" + qualifier + "}" + name;
+ }
+ }
+
@Override
public int hashCode()
{
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-09-14
13:24:11 UTC (rev 4188)
+++
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/DescriptorBuilder.java 2010-09-14
14:01:03 UTC (rev 4189)
@@ -40,8 +40,11 @@
private static final QName routeQN = new
QName("http://www.gatein.org/xml/ns/gatein_router_1_0", "route");
/** . */
- private static final QName parameterQN = new
QName("http://www.gatein.org/xml/ns/gatein_router_1_0", "parameter");
+ private static final QName paramQN = new
QName("http://www.gatein.org/xml/ns/gatein_router_1_0", "param");
+ /** . */
+ private static final QName requestParamQN = new
QName("http://www.gatein.org/xml/ns/gatein_router_1_0",
"request-param");
+
public RouterDescriptor build(XMLStreamReader reader) throws Exception
{
RouterDescriptor routerDesc = new RouterDescriptor();
@@ -68,12 +71,20 @@
SMInputCursor childC = routeC.childElementCursor();
while (childC.getNext() != null)
{
- if (childC.getQName().equals(parameterQN))
+ if (childC.getQName().equals(paramQN))
{
String name = childC.getAttrValue("name");
String value = childC.getAttrValue("value");
- routeDesc.addParameter(QualifiedName.parse(name), value);
+ routeDesc.addParam(QualifiedName.parse(name), value);
}
+ else if (childC.getQName().equals(requestParamQN))
+ {
+ String name = childC.getAttrValue("name");
+ String matchName = childC.getAttrValue("matchName");
+ String matchValue = childC.getAttrValue("matchValue");
+ String optional = childC.getAttrValue("required");
+ routeDesc.addRequestParam(QualifiedName.parse(name), matchName, matchValue,
"true".equals(optional));
+ }
else if (childC.getQName().equals(routeQN))
{
build(childC, routeDesc.getChildren());
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-09-14
13:24:11 UTC (rev 4188)
+++
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RequestParamDescriptor.java 2010-09-14
14:01:03 UTC (rev 4189)
@@ -29,15 +29,18 @@
{
/** . */
- private QualifiedName name;
+ private final QualifiedName name;
/** . */
- private String matchName;
+ private final String matchName;
/** . */
- private String matchValue;
+ private final String matchValue;
- public RequestParamDescriptor(QualifiedName name, String matchName, String
matchValue)
+ /** . */
+ private final boolean required;
+
+ public RequestParamDescriptor(QualifiedName name, String matchName, String matchValue,
boolean required)
{
if (name == null)
{
@@ -47,15 +50,12 @@
{
throw new NullPointerException("No null match name accepted");
}
- if (matchValue == null)
- {
- throw new NullPointerException("No null match value accepted");
- }
//
this.name = name;
this.matchName = matchName;
this.matchValue = matchValue;
+ this.required = required;
}
public QualifiedName getName()
@@ -72,4 +72,9 @@
{
return matchValue;
}
+
+ public boolean isRequired()
+ {
+ return required;
+ }
}
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-09-14
13:24:11 UTC (rev 4188)
+++
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RouteDescriptor.java 2010-09-14
14:01:03 UTC (rev 4189)
@@ -37,7 +37,7 @@
private final String path;
/** . */
- private final Map<QualifiedName, String> parameters;
+ private final Map<QualifiedName, String> params;
/** . */
private final Map<String, RequestParamDescriptor> requestParams;
@@ -48,7 +48,7 @@
public RouteDescriptor(String path)
{
this.path = path;
- this.parameters = new HashMap<QualifiedName, String>();
+ this.params = new HashMap<QualifiedName, String>();
this.requestParams = new HashMap<String, RequestParamDescriptor>();
this.children = new ArrayList<RouteDescriptor>();
}
@@ -58,32 +58,27 @@
return path;
}
- public RouteDescriptor addParameter(QualifiedName name, String value)
+ public RouteDescriptor addParam(QualifiedName name, String value)
{
- parameters.put(name, value);
+ params.put(name, value);
return this;
}
- public RouteDescriptor addParameter(String name, String value)
+ public RouteDescriptor addParam(String name, String value)
{
- return addParameter(QualifiedName.parse(name), value);
+ return addParam(QualifiedName.parse(name), value);
}
- public Map<QualifiedName, String> getParameters()
+ public Map<QualifiedName, String> getParams()
{
- return parameters;
+ return params;
}
- public RouteDescriptor addRequestParam(QualifiedName name, String matchName, String
matchValue)
+ public RouteDescriptor addRequestParam(QualifiedName name, String matchName, String
matchValue, boolean required)
{
- return addRequestParam(new RequestParamDescriptor(name, matchName, matchValue));
+ return addRequestParam(new RequestParamDescriptor(name, matchName, matchValue,
required));
}
- public RouteDescriptor addRequestParam(String name, String matchName, String
matchValue)
- {
- return addRequestParam(QualifiedName.parse(name), matchName, matchValue);
- }
-
public RouteDescriptor addRequestParam(RequestParamDescriptor requestParam)
{
requestParams.put(requestParam.getMatchName(), requestParam);
Modified:
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/RequestParamDef.java
===================================================================
---
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/RequestParamDef.java 2010-09-14
13:24:11 UTC (rev 4188)
+++
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/RequestParamDef.java 2010-09-14
14:01:03 UTC (rev 4189)
@@ -40,6 +40,9 @@
/** . */
final Pattern matchValue;
+ /** . */
+ final boolean required;
+
RequestParamDef(RequestParamDescriptor descriptor)
{
if (descriptor == null)
@@ -48,47 +51,53 @@
}
//
- PatternBuilder matchValue = new PatternBuilder();
- matchValue.expr("^");
- int level = 0;
- for (char c : descriptor.getMatchValue().toCharArray())
+ Pattern matchValue = null;
+ if (descriptor.getMatchValue() != null)
{
- switch (c)
+ PatternBuilder matchValueBuilder = new PatternBuilder();
+ matchValueBuilder.expr("^");
+ int level = 0;
+ for (char c : descriptor.getMatchValue().toCharArray())
{
- case '{':
+ switch (c)
+ {
+ case '{':
- if (level++ > 0)
- {
- matchValue.expr('{');
- }
- break;
- case '}':
- if (--level > 0)
- {
- matchValue.expr('}');
- }
- break;
- default:
- if (level == 0)
- {
- matchValue.litteral(c);
- }
- else
- {
- matchValue.expr(c);
- }
- break;
+ if (level++ > 0)
+ {
+ matchValueBuilder.expr('{');
+ }
+ break;
+ case '}':
+ if (--level > 0)
+ {
+ matchValueBuilder.expr('}');
+ }
+ break;
+ default:
+ if (level == 0)
+ {
+ matchValueBuilder.litteral(c);
+ }
+ else
+ {
+ matchValueBuilder.expr(c);
+ }
+ break;
+ }
}
+ matchValueBuilder.expr("$");
+ matchValue = matchValueBuilder.build();
}
- matchValue.expr("$");
//
this.name = descriptor.getName();
this.matchName = descriptor.getMatchName();
- this.matchValue = matchValue.build();
+ this.matchValue = matchValue;
+ this.required = descriptor.isRequired();
}
- RequestParamDef(QualifiedName name, String matchName, Pattern matchValue)
+ RequestParamDef(QualifiedName name, String matchName, Pattern matchValue, boolean
required)
{
if (name == null)
{
@@ -107,6 +116,7 @@
this.name = name;
this.matchName = matchName;
this.matchValue = matchValue;
+ this.required = required;
}
public QualifiedName getName()
@@ -123,4 +133,14 @@
{
return matchValue;
}
+
+ public boolean matchValue(String value)
+ {
+ return matchValue == null || matchValue.matcher(value).matches();
+ }
+
+ public boolean isRequired()
+ {
+ return required;
+ }
}
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-09-14
13:24:11 UTC (rev 4188)
+++
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/Route.java 2010-09-14
14:01:03 UTC (rev 4189)
@@ -155,7 +155,7 @@
String a = blah.get(requestParamDef.name);
if (a != null)
{
- if (requestParamDef.matchValue.matcher(a).matches())
+ if (requestParamDef.matchValue(a))
{
//
abc.remove(requestParamDef.name);
@@ -231,25 +231,24 @@
{
for (RequestParamDef requestParamDef : requestParamDefs.values())
{
+ String value = null;
String[] values = requestParams.get(requestParamDef.getMatchName());
- if (values != null && values.length > 0)
+ if (values != null && values.length > 0 && values[0] !=
null)
{
- String value = values[0];
- if (value != null)
+ value = values[0];
+ }
+ if (value != null && requestParamDef.matchValue(value))
+ {
+ if (routeRequestParams.isEmpty())
{
- Matcher matcher = requestParamDef.matchValue.matcher(value);
- if (matcher.matches())
- {
- if (routeRequestParams.isEmpty())
- {
- routeRequestParams = new HashMap<QualifiedName, String>();
- }
- routeRequestParams.put(requestParamDef.getName(), value);
- continue;
- }
+ routeRequestParams = new HashMap<QualifiedName, String>();
}
+ routeRequestParams.put(requestParamDef.getName(), value);
}
- return null;
+ else if (requestParamDef.isRequired())
+ {
+ return null;
+ }
}
}
@@ -450,7 +449,7 @@
//
route.terminal = true;
- route.routeParameters.putAll(descriptor.getParameters());
+ route.routeParameters.putAll(descriptor.getParams());
for (RequestParamDescriptor requestParamDescriptor :
descriptor.getRequestParams().values())
{
RequestParamDef requestParamDef = new RequestParamDef(requestParamDescriptor);
Modified:
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/url/ResourceURL.java
===================================================================
---
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/url/ResourceURL.java 2010-09-14
13:24:11 UTC (rev 4188)
+++
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/url/ResourceURL.java 2010-09-14
14:01:03 UTC (rev 4189)
@@ -34,6 +34,9 @@
/** . */
protected Boolean ajax;
+ /** . */
+ protected String confirm;
+
/**
* Create a resource URL instance.
*
@@ -51,6 +54,7 @@
//
this.locator = locator;
this.ajax = ajax;
+ this.confirm = null;
}
/**
@@ -86,6 +90,26 @@
}
/**
+ * Returns the confirm message.
+ *
+ * @return the confirm message
+ */
+ public String getConfirm()
+ {
+ return confirm;
+ }
+
+ /**
+ * Updates the confirm message.
+ *
+ * @param confirm the new confirm message
+ */
+ public void setConfirm(String confirm)
+ {
+ this.confirm = confirm;
+ }
+
+ /**
* Returns the current resource associated with this URL.
*
* @return the resource
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-09-14
13:24:11 UTC (rev 4188)
+++
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestDescriptorBuilder.java 2010-09-14
14:01:03 UTC (rev 4189)
@@ -29,7 +29,9 @@
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamReader;
import java.net.URL;
+import java.util.Arrays;
import java.util.Collections;
+import java.util.HashSet;
import java.util.Iterator;
/**
@@ -52,34 +54,52 @@
assertTrue(i.hasNext());
RouteDescriptor route1 = i.next();
assertEquals("/public/{{gtn}sitename}{{gtn}path:.*}", route1.getPath());
- assertEquals(Collections.singletonMap(WebAppController.HANDLER_PARAM,
"portal"), route1.getParameters());
+ assertEquals(Collections.singletonMap(WebAppController.HANDLER_PARAM,
"portal"), route1.getParams());
//
assertTrue(i.hasNext());
RouteDescriptor route2 = i.next();
assertEquals("/private/{{gtn}sitename}{{gtn}path:.*}",
route2.getPath());
- assertEquals(Collections.singletonMap(WebAppController.HANDLER_PARAM,
"portal"), route2.getParameters());
+ assertEquals(Collections.singletonMap(WebAppController.HANDLER_PARAM,
"portal"), route2.getParams());
//
assertTrue(i.hasNext());
RouteDescriptor route3 = i.next();
assertEquals("/upload", route3.getPath());
- assertEquals(Collections.singletonMap(WebAppController.HANDLER_PARAM,
"upload"), route3.getParameters());
+ assertEquals(Collections.singletonMap(WebAppController.HANDLER_PARAM,
"upload"), route3.getParams());
//
assertTrue(i.hasNext());
RouteDescriptor route4 = i.next();
assertEquals("/download", route4.getPath());
- assertEquals(Collections.singletonMap(WebAppController.HANDLER_PARAM,
"download"), route4.getParameters());
+ assertEquals(Collections.singletonMap(WebAppController.HANDLER_PARAM,
"download"), route4.getParams());
//
assertTrue(i.hasNext());
RouteDescriptor route5 = i.next();
assertEquals("/a", route5.getPath());
- assertEquals(Collections.singletonMap(new QualifiedName("a"),
"a_value"), route5.getParameters());
+ assertEquals(Collections.singletonMap(new QualifiedName("a"),
"a_value"), route5.getParams());
assertEquals(1, route5.getChildren().size());
RouteDescriptor route5_1 = route5.getChildren().get(0);
assertEquals("/b", route5_1.getPath());
- assertEquals(Collections.singletonMap(new QualifiedName("b"),
"b_value"), route5_1.getParameters());
+ assertEquals(Collections.singletonMap(new QualifiedName("b"),
"b_value"), route5_1.getParams());
+
+ //
+ assertTrue(i.hasNext());
+ RouteDescriptor route6 = i.next();
+ assertEquals("/b", route6.getPath());
+ assertEquals(new HashSet<String>(Arrays.asList("foo",
"bar", "juu")), route6.getRequestParams().keySet());
+ assertEquals(QualifiedName.parse("foo"),
route6.getRequestParams().get("foo").getName());
+ assertEquals("foo",
route6.getRequestParams().get("foo").getMatchName());
+ assertEquals(null,
route6.getRequestParams().get("foo").getMatchValue());
+ assertEquals(false, route6.getRequestParams().get("foo").isRequired());
+ assertEquals(QualifiedName.parse("bar"),
route6.getRequestParams().get("bar").getName());
+ assertEquals("bar",
route6.getRequestParams().get("bar").getMatchName());
+ assertEquals("bar",
route6.getRequestParams().get("bar").getMatchValue());
+ assertEquals(false, route6.getRequestParams().get("bar").isRequired());
+ assertEquals(QualifiedName.parse("juu"),
route6.getRequestParams().get("juu").getName());
+ assertEquals("juu",
route6.getRequestParams().get("juu").getMatchName());
+ assertEquals("juu",
route6.getRequestParams().get("juu").getMatchValue());
+ assertEquals(true, route6.getRequestParams().get("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-09-14
13:24:11 UTC (rev 4188)
+++
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestHierarchy.java 2010-09-14
14:01:03 UTC (rev 4189)
@@ -38,8 +38,8 @@
{
RouteDescriptor descriptor = new RouteDescriptor("/a").
- addParameter("foo", "bar").
- addChild(new RouteDescriptor("/b").addParameter("juu",
"daa"));
+ addParam("foo", "bar").
+ addChild(new RouteDescriptor("/b").addParam("juu",
"daa"));
//
Router router = new Router(new RouterDescriptor().addRoute(descriptor));
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-09-14
13:24:11 UTC (rev 4188)
+++
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestMatch.java 2010-09-14
14:01:03 UTC (rev 4189)
@@ -132,7 +132,7 @@
public void testParameterPropagationToDescendants() throws Exception
{
RouterDescriptor routerMD = new RouterDescriptor();
- routerMD.addRoute(new RouteDescriptor("/").addParameter("p",
"a"));
+ routerMD.addRoute(new RouteDescriptor("/").addParam("p",
"a"));
routerMD.addRoute(new RouteDescriptor("/a"));
Router router = new Router(routerMD);
assertEquals(Collections.singletonMap(new QualifiedName("p"),
"a"), router.route(("/a")));
@@ -199,7 +199,7 @@
public void testTwoRules1() throws Exception
{
RouterDescriptor routerMD = new RouterDescriptor();
- routerMD.addRoute(new RouteDescriptor("/a").addParameter("b",
"b"));
+ routerMD.addRoute(new RouteDescriptor("/a").addParam("b",
"b"));
routerMD.addRoute(new RouteDescriptor("/a/b"));
Router router = new Router(routerMD);
@@ -211,7 +211,7 @@
public void testTwoRules2() throws Exception
{
RouterDescriptor routerMD = new RouterDescriptor();
- routerMD.addRoute(new RouteDescriptor("/{a}").addParameter("b",
"b"));
+ routerMD.addRoute(new RouteDescriptor("/{a}").addParam("b",
"b"));
routerMD.addRoute(new RouteDescriptor("/{a}/b"));
Router router = new Router(routerMD);
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-09-14
13:24:11 UTC (rev 4188)
+++
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPortalConfiguration.java 2010-09-14
14:01:03 UTC (rev 4189)
@@ -23,6 +23,7 @@
import org.exoplatform.web.controller.metadata.RouteDescriptor;
import org.exoplatform.web.controller.metadata.RouterDescriptor;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
@@ -43,26 +44,47 @@
//
RouteDescriptor portalRouteMD = new
RouteDescriptor("/private/{{gtn}sitename}{{gtn}path:.*}");
- portalRouteMD.addParameter(new QualifiedName("gtn",
"controller"), "site");
- portalRouteMD.addParameter(new QualifiedName("gtn",
"sitetype"), "portal");
+ portalRouteMD.addParam(new QualifiedName("gtn", "controller"),
"site");
+ portalRouteMD.addParam(new QualifiedName("gtn", "sitetype"),
"portal");
+ portalRouteMD.addRequestParam(new QualifiedName("gtn",
"componentid"), "portal:componentId", null, false);
routerMD.addRoute(portalRouteMD);
//
+ RouteDescriptor portalRouteMD2 = new
RouteDescriptor("/private/{{gtn}sitename}{{gtn}path:.*}");
+ portalRouteMD2.addParam(new QualifiedName("gtn", "controller"),
"site");
+ portalRouteMD2.addParam(new QualifiedName("gtn", "sitetype"),
"portal");
+ routerMD.addRoute(portalRouteMD2);
+
+ //
RouteDescriptor groupRouteMD = new
RouteDescriptor("/groups/{{gtn}sitename}{{gtn}path:.*}");
- portalRouteMD.addParameter(new QualifiedName("gtn",
"controller"), "site");
- groupRouteMD.addParameter(new QualifiedName("gtn", "sitetype"),
"group");
+ portalRouteMD.addParam(new QualifiedName("gtn", "controller"),
"site");
+ groupRouteMD.addParam(new QualifiedName("gtn", "sitetype"),
"group");
routerMD.addRoute(groupRouteMD);
//
RouteDescriptor userRouteMD = new
RouteDescriptor("/users/{{gtn}sitename}{{gtn}path:.*}");
- portalRouteMD.addParameter(new QualifiedName("gtn",
"controller"), "site");
- userRouteMD.addParameter(new QualifiedName("gtn", "sitetype"),
"user");
+ portalRouteMD.addParam(new QualifiedName("gtn", "controller"),
"site");
+ userRouteMD.addParam(new QualifiedName("gtn", "sitetype"),
"user");
routerMD.addRoute(userRouteMD);
//
this.router = new Router(routerMD);
}
+ public void testComponent() throws Exception
+ {
+ Map<QualifiedName, String> expectedParameters = new HashMap<QualifiedName,
String>();
+ expectedParameters.put(new QualifiedName("gtn", "controller"),
"site");
+ expectedParameters.put(new QualifiedName("gtn", "sitename"),
"classic");
+ expectedParameters.put(new QualifiedName("gtn", "sitetype"),
"portal");
+ expectedParameters.put(new QualifiedName("gtn", "path"),
"");
+ expectedParameters.put(new QualifiedName("gtn", "componentid"),
"foo");
+
+ //
+ assertEquals(expectedParameters, router.route("/private/classic",
Collections.singletonMap("portal:componentId", new
String[]{"foo"})));
+ assertEquals("/private/classic", router.render(expectedParameters));
+ }
+
public void testPrivateClassic() throws Exception
{
Map<QualifiedName, String> expectedParameters = new HashMap<QualifiedName,
String>();
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-09-14
13:24:11 UTC (rev 4188)
+++
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestRequestParam.java 2010-09-14
14:01:03 UTC (rev 4189)
@@ -37,7 +37,7 @@
public void testRoot() throws Exception
{
RouterDescriptor descriptor = new RouterDescriptor();
- descriptor.addRoute(new
RouteDescriptor("/").addRequestParam("foo", "a",
"a"));
+ descriptor.addRoute(new
RouteDescriptor("/").addRequestParam(QualifiedName.parse("foo"),
"a", "a", true));
Router router = new Router(descriptor);
//
@@ -55,7 +55,7 @@
public void testSegment() throws Exception
{
RouterDescriptor descriptor = new RouterDescriptor();
- descriptor.addRoute(new
RouteDescriptor("/a").addRequestParam("foo", "a",
"a"));
+ descriptor.addRoute(new
RouteDescriptor("/a").addRequestParam(QualifiedName.parse("foo"),
"a", "a", true));
Router router = new Router(descriptor);
//
@@ -73,7 +73,7 @@
public void testValuePattern() throws Exception
{
RouterDescriptor descriptor = new RouterDescriptor();
- descriptor.addRoute(new
RouteDescriptor("/a").addRequestParam("foo", "a",
"{[0-9]+}"));
+ descriptor.addRoute(new
RouteDescriptor("/a").addRequestParam(QualifiedName.parse("foo"),
"a", "{[0-9]+}", true));
Router router = new Router(descriptor);
//
@@ -93,8 +93,8 @@
public void testPrecedence() throws Exception
{
RouterDescriptor descriptor = new RouterDescriptor();
- descriptor.addRoute(new
RouteDescriptor("/a").addRequestParam("foo", "a",
"a"));
- descriptor.addRoute(new
RouteDescriptor("/a").addRequestParam("bar", "b",
"b"));
+ 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);
//
@@ -117,7 +117,7 @@
public void testInheritance() throws Exception
{
RouterDescriptor descriptor = new RouterDescriptor();
- descriptor.addRoute(new
RouteDescriptor("/a").addRequestParam("foo", "a",
"a").addChild(new
RouteDescriptor("/b").addRequestParam("bar", "b",
"b")));
+ descriptor.addRoute(new
RouteDescriptor("/a").addRequestParam(QualifiedName.parse("foo"),
"a", "a", true).addChild(new
RouteDescriptor("/b").addRequestParam(QualifiedName.parse("bar"),
"b", "b", true)));
Router router = new Router(descriptor);
//
@@ -148,4 +148,15 @@
assertEquals(expectedRequestParameters, renderContext2.getQueryParams());
}
+ 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);
+
+ //
+ assertEquals(Collections.<QualifiedName, String>emptyMap(),
router.route("/", Collections.<String, String[]>emptyMap()));
+ assertEquals(Collections.singletonMap(QualifiedName.parse("foo"),
"a"), router.route("/", Collections.singletonMap("a", new
String[]{"a"})));
+ }
+
}
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-09-14
13:24:11 UTC (rev 4188)
+++
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/router.xml 2010-09-14
14:01:03 UTC (rev 4189)
@@ -4,26 +4,32 @@
xmlns="http://www.gatein.org/xml/ns/gatein_router_1_0">
<route path="/public/{{gtn}sitename}{{gtn}path:.*}">
- <parameter name="{gtn}handler" value="portal"/>
+ <param name="{gtn}handler" value="portal"/>
</route>
<route path="/private/{{gtn}sitename}{{gtn}path:.*}">
- <parameter name="{gtn}handler" value="portal"/>
+ <param name="{gtn}handler" value="portal"/>
</route>
<route path="/upload">
- <parameter name="{gtn}handler" value="upload"/>
+ <param name="{gtn}handler" value="upload"/>
</route>
<route path="/download">
- <parameter name="{gtn}handler" value="download"/>
+ <param name="{gtn}handler" value="download"/>
</route>
<route path="/a">
- <parameter name="a" value="a_value"/>
+ <param name="a" value="a_value"/>
<route path="/b">
- <parameter name="b" value="b_value"/>
+ <param name="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"/>
+ </route>
+
</router>
\ No newline at end of file
Modified:
portal/branches/navcontroller/web/portal/src/main/webapp/WEB-INF/conf/router.xml
===================================================================
---
portal/branches/navcontroller/web/portal/src/main/webapp/WEB-INF/conf/router.xml 2010-09-14
13:24:11 UTC (rev 4188)
+++
portal/branches/navcontroller/web/portal/src/main/webapp/WEB-INF/conf/router.xml 2010-09-14
14:01:03 UTC (rev 4189)
@@ -4,26 +4,38 @@
xmlns="http://www.gatein.org/xml/ns/gatein_router_1_0">
<route path="/public/{{gtn}sitename}{{gtn}path:.*}">
- <parameter name="{gtn}handler" value="portal"/>
+ <param name="{gtn}handler" value="portal"/>
+ <param name="{gtn}access" value="public"/>
+<!--
+ <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"/>
+-->
</route>
<route path="/private/{{gtn}sitename}{{gtn}path:.*}">
- <parameter name="{gtn}handler" value="portal"/>
+ <param name="{gtn}handler" value="portal"/>
+ <param name="{gtn}access" value="private"/>
+<!--
+ <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"/>
+-->
</route>
<route path="/upload">
- <parameter name="{gtn}handler" value="upload"/>
+ <param name="{gtn}handler" value="upload"/>
</route>
<route path="/download">
- <parameter name="{gtn}handler" value="download"/>
+ <param name="{gtn}handler" value="download"/>
</route>
<!-- Map the sitemap navigation on the /foo path -->
<route path="/foo">
- <parameter name="{gtn}sitename" value="classic"/>
- <parameter name="{gtn}path" value="/sitemap"/>
- <parameter name="{gtn}handler" value="portal"/>
+ <param name="{gtn}sitename" value="classic"/>
+ <param name="{gtn}path" value="/sitemap"/>
+ <param name="{gtn}handler" value="portal"/>
</route>
</router>
\ No newline at end of file
Added:
portal/branches/navcontroller/webui/framework/src/main/java/org/exoplatform/webui/application/UIComponentURLBuilder.java
===================================================================
---
portal/branches/navcontroller/webui/framework/src/main/java/org/exoplatform/webui/application/UIComponentURLBuilder.java
(rev 0)
+++
portal/branches/navcontroller/webui/framework/src/main/java/org/exoplatform/webui/application/UIComponentURLBuilder.java 2010-09-14
14:01:03 UTC (rev 4189)
@@ -0,0 +1,85 @@
+/*
+ * 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.webui.application;
+
+import org.exoplatform.web.application.Parameter;
+import org.exoplatform.web.application.URLBuilder;
+import org.exoplatform.web.url.ResourceURL;
+import org.exoplatform.webui.core.UIComponent;
+import org.exoplatform.webui.url.ComponentLocator;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
+ * @version $Revision$
+ */
+public abstract class UIComponentURLBuilder extends URLBuilder<UIComponent>
+{
+
+ /** . */
+ private final ResourceURL<UIComponent, ComponentLocator> url;
+
+/*
+ public UIComponentURLBuilder(ResourceURL<UIComponent, ComponentLocator> url)
+ {
+ this.url = url;
+ }
+*/
+
+ public UIComponentURLBuilder(String baseURL)
+ {
+ super(baseURL);
+
+ //
+ url = null;
+ }
+
+ @Override
+ public String createAjaxURL(UIComponent targetComponent, String action, String
confirm, String targetBeanId, Parameter[] params)
+ {
+ return createURL(true, targetComponent, action, confirm, targetBeanId, params);
+ }
+
+ @Override
+ public String createURL(UIComponent targetComponent, String action, String confirm,
String targetBeanId, Parameter[] params)
+ {
+ return createURL(false, targetComponent, action, confirm, targetBeanId, params);
+ }
+
+ private String createURL(boolean ajax, UIComponent targetComponent, String action,
String confirm, String targetBeanId, Parameter[] params)
+ {
+ url.setAjax(ajax);
+ url.setConfirm(confirm);
+ url.setResource(targetComponent);
+
+ //
+ ComponentLocator locator = url.getResourceLocator();
+
+ //
+ locator.setAction(action);
+ locator.setTargetBeanId(targetBeanId);
+ for (Parameter param : params)
+ {
+ locator.addParameter(param);
+ }
+
+ //
+ return url.toString();
+ }
+}
Copied:
portal/branches/navcontroller/webui/framework/src/main/java/org/exoplatform/webui/url/ComponentLocator.java
(from rev 4173,
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/url/component/ComponentLocator.java)
===================================================================
---
portal/branches/navcontroller/webui/framework/src/main/java/org/exoplatform/webui/url/ComponentLocator.java
(rev 0)
+++
portal/branches/navcontroller/webui/framework/src/main/java/org/exoplatform/webui/url/ComponentLocator.java 2010-09-14
14:01:03 UTC (rev 4189)
@@ -0,0 +1,121 @@
+/*
+ * 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.webui.url;
+
+import org.exoplatform.web.application.Parameter;
+import org.exoplatform.web.controller.QualifiedName;
+import org.exoplatform.web.url.ResourceLocator;
+import org.exoplatform.web.url.ResourceType;
+import org.exoplatform.webui.core.UIComponent;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
+ * @version $Revision$
+ */
+public class ComponentLocator implements ResourceLocator<UIComponent>
+{
+
+ /** . */
+ public static final ResourceType<UIComponent, ComponentLocator> TYPE = new
ResourceType<UIComponent, ComponentLocator>() {};
+
+ /** . */
+ public static final QualifiedName COMPONENT = new QualifiedName("gtn",
"componentid");
+
+ /** . */
+ public static final QualifiedName ACTION = new QualifiedName("gtn",
"action");
+
+ /** . */
+ public static final QualifiedName TARGET = new QualifiedName("gtn",
"objectid");
+
+ /** . */
+ private UIComponent resource;
+
+ /** . */
+ private Map<QualifiedName, String> parameters;
+
+ public ComponentLocator()
+ {
+ this.parameters = new HashMap<QualifiedName, String>();
+ }
+
+ private void setParameter(QualifiedName parameterName, String parameterValue)
+ {
+ if (parameterValue == null)
+ {
+ parameters.remove(parameterName);
+ }
+ else
+ {
+ parameters.put(parameterName, parameterValue);
+ }
+ }
+
+ public UIComponent getResource()
+ {
+ return resource;
+ }
+
+ public void setResource(UIComponent resource)
+ {
+ setParameter(COMPONENT, resource != null ? resource.getId() : null);
+
+ //
+ this.resource = resource;
+ }
+
+ public String getAction()
+ {
+ return parameters.get(ACTION);
+ }
+
+ public void setAction(String action)
+ {
+ setParameter(ACTION, action);
+ }
+
+ public String getTargetBeanId()
+ {
+ return parameters.get(TARGET);
+ }
+
+ public void setTargetBeanId(String targetBeanId)
+ {
+ setParameter(TARGET, targetBeanId);
+ }
+
+ public void addParameter(Parameter param)
+ {
+ throw new UnsupportedOperationException("is it really used?");
+ }
+
+ public Set<QualifiedName> getParameterNames()
+ {
+ return parameters.keySet();
+ }
+
+ public String getParameterValue(QualifiedName parameterName)
+ {
+ return parameters.get(parameterName);
+ }
+}
Modified:
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestContext.java
===================================================================
---
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestContext.java 2010-09-14
13:24:11 UTC (rev 4188)
+++
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestContext.java 2010-09-14
14:01:03 UTC (rev 4189)
@@ -102,16 +102,24 @@
/** The path decoded from the request. */
private final String nodePath_;
- private String requestURI_;
+ /** . */
+ private final String access;
- private String portalURI;
+ /** . */
+ private final String requestURI_;
- private int accessPath = -1;
+ /** . */
+ private final String portalURI;
- private HttpServletRequest request_;
+ /** . */
+ private final int accessPath;
- private HttpServletResponse response_;
+ /** . */
+ private final HttpServletRequest request_;
+ /** . */
+ private final HttpServletResponse response_;
+
private String cacheLevel_ = "cacheLevelPortlet";
private boolean ajaxRequest_ = true;
@@ -157,7 +165,8 @@
WebuiApplication app,
ControllerContext controllerContext,
String requestSiteName,
- String requestPath) throws Exception
+ String requestPath,
+ String access) throws Exception
{
super(app);
@@ -224,33 +233,41 @@
nodePath_ = pathInfo.substring(colonIndex, pathInfo.length());
*/
//
- portalOwner_ = requestSiteName;
- nodePath_ = requestPath;
+ this.portalOwner_ = requestSiteName;
+ this.nodePath_ = requestPath;
+ this.access = access;
// portalURI = requestURI_.substring(0, requestURI_.lastIndexOf(nodePath_)) +
"/";
Map<QualifiedName, String> tmp = new HashMap<QualifiedName, String>();
tmp.put(WebAppController.HANDLER_PARAM, "portal");
+ tmp.put(PortalRequestHandler.ACCESS, access);
tmp.put(PortalRequestHandler.REQUEST_SITE_NAME, requestSiteName);
tmp.put(PortalRequestHandler.REQUEST_PATH, "/");
portalURI = controllerContext.renderURL(tmp);
//
- if (requestURI_.indexOf("/public/") >= 0)
+ if (access.endsWith("public"))
{
accessPath = PUBLIC_ACCESS;
}
- else if (requestURI_.indexOf("/private/") >= 0)
+ else if (access.equals("private"))
{
accessPath = PRIVATE_ACCESS;
}
+ else
+ {
+ accessPath = -1;
+ }
+ //
urlBuilder = new PortalURLBuilder(requestURI_);
+// urlBuilder = new PortalURLBuilder(createURL(ComponentLocator.TYPE));
}
@Override
public <R, L extends ResourceLocator<R>> ResourceURL<R, L>
newURL(ResourceType<R, L> resourceType, L locator)
{
- return new PortalURL<R, L>(this, locator, false);
+ return new PortalURL<R, L>(this, locator, false, portalOwner_, access);
}
public ControllerContext getControllerContext()
Modified:
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestHandler.java
===================================================================
---
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestHandler.java 2010-09-14
13:24:11 UTC (rev 4188)
+++
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestHandler.java 2010-09-14
14:01:03 UTC (rev 4189)
@@ -57,6 +57,9 @@
/** . */
public static final QualifiedName REQUEST_SITE_NAME = new
QualifiedName("gtn", "sitename");
+ /** . */
+ public static final QualifiedName ACCESS = new QualifiedName("gtn",
"access");
+
public String getHandlerName()
{
return "portal";
@@ -99,10 +102,11 @@
//
String requestPath = controllerContext.getParameter(REQUEST_PATH);
String requestSiteName = controllerContext.getParameter(REQUEST_SITE_NAME);
+ String access = controllerContext.getParameter(ACCESS);
//
PortalApplication app =
controllerContext.getController().getApplication(PortalApplication.PORTAL_APPLICATION_ID);
- PortalRequestContext context = new PortalRequestContext(app, controllerContext,
requestSiteName, requestPath);
+ PortalRequestContext context = new PortalRequestContext(app, controllerContext,
requestSiteName, requestPath, access);
if (context.getPortalOwner().length() == 0) {
res.sendRedirect(req.getContextPath());
return;
Modified:
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/url/PortalURL.java
===================================================================
---
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/url/PortalURL.java 2010-09-14
13:24:11 UTC (rev 4188)
+++
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/url/PortalURL.java 2010-09-14
14:01:03 UTC (rev 4189)
@@ -44,12 +44,18 @@
private final PortalRequestContext requestContext;
/** . */
+ private final String access;
+
+ /** . */
+ private final String siteName;
+
+ /** . */
private StringBuilder buffer;
/** . */
private SimpleRenderContext renderContext;
- public PortalURL(PortalRequestContext requestContext, L locator, Boolean ajax)
+ public PortalURL(PortalRequestContext requestContext, L locator, Boolean ajax, String
siteName, String access)
{
super(locator, ajax);
@@ -60,7 +66,9 @@
}
//
+ this.siteName = siteName;
this.requestContext = requestContext;
+ this.access = access;
}
public String toString()
@@ -90,8 +98,9 @@
// julien : find out how to change the hardcoded "classic"
Map<QualifiedName, String> parameters = new HashMap<QualifiedName,
String>();
- parameters.put(PortalRequestHandler.REQUEST_SITE_NAME, "classic");
parameters.put(WebAppController.HANDLER_PARAM, "portal");
+ parameters.put(PortalRequestHandler.ACCESS, access);
+ parameters.put(PortalRequestHandler.REQUEST_SITE_NAME, siteName);
//
for (QualifiedName parameterName : locator.getParameterNames())
Deleted:
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/url/component/ComponentLocator.java
===================================================================
---
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/url/component/ComponentLocator.java 2010-09-14
13:24:11 UTC (rev 4188)
+++
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/url/component/ComponentLocator.java 2010-09-14
14:01:03 UTC (rev 4189)
@@ -1,58 +0,0 @@
-/*
- * 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.url.component;
-
-import org.exoplatform.web.controller.QualifiedName;
-import org.exoplatform.web.url.ResourceLocator;
-import org.exoplatform.webui.core.UIComponent;
-
-import java.util.Collections;
-import java.util.Set;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
- * @version $Revision$
- */
-public class ComponentLocator implements ResourceLocator<UIComponent>
-{
-
- /** . */
- private UIComponent resource;
-
- public UIComponent getResource()
- {
- return resource;
- }
-
- public void setResource(UIComponent resource)
- {
- this.resource = resource;
- }
-
- public Set<QualifiedName> getParameterNames()
- {
- return Collections.emptySet();
- }
-
- public String getParameterValue(QualifiedName parameterName)
- {
- return null;
- }
-}
Added:
portal/branches/navcontroller/webui/portlet/src/main/java/org/exoplatform/portal/url/PortletResourceURL.java
===================================================================
---
portal/branches/navcontroller/webui/portlet/src/main/java/org/exoplatform/portal/url/PortletResourceURL.java
(rev 0)
+++
portal/branches/navcontroller/webui/portlet/src/main/java/org/exoplatform/portal/url/PortletResourceURL.java 2010-09-14
14:01:03 UTC (rev 4189)
@@ -0,0 +1,71 @@
+/*
+ * 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.url;
+
+import org.exoplatform.web.controller.QualifiedName;
+import org.exoplatform.web.url.ResourceLocator;
+import org.exoplatform.web.url.ResourceURL;
+
+import javax.portlet.MimeResponse;
+import javax.portlet.PortletURL;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
+ * @version $Revision$
+ */
+public class PortletResourceURL<R, L extends ResourceLocator<R>> extends
ResourceURL<R, L>
+{
+
+ /** . */
+ public static final QualifiedName CONFIRM = new QualifiedName("gtn",
"confirm");
+
+ /** . */
+ private PortletURL url;
+
+ private final MimeResponse response;
+
+
+ public PortletResourceURL(MimeResponse response, L locator, Boolean ajax) throws
NullPointerException
+ {
+ super(locator, ajax);
+
+ //
+ this.response = response;
+ }
+
+ @Override
+ public String toString()
+ {
+ if (url == null)
+ {
+ url = response.createActionURL();
+ }
+
+ //
+ for (QualifiedName parameterName : locator.getParameterNames())
+ {
+ String parameterValue = locator.getParameterValue(parameterName);
+ url.setParameter(parameterName.getValue(), parameterValue);
+ }
+
+ //
+ return url.toString();
+ }
+}