Author: julien_viet
Date: 2010-09-04 03:27:43 -0400 (Sat, 04 Sep 2010)
New Revision: 4043
Added:
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/url/
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/url/ResourceType.java
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/URLFactory.java
Modified:
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/application/RequestContext.java
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestContext.java
portal/branches/navcontroller/webui/portlet/src/main/java/org/exoplatform/webui/application/portlet/PortletRequestContext.java
Log:
start to scratch the internal API for dealing with URL generation properly
Modified:
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/application/RequestContext.java
===================================================================
---
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/application/RequestContext.java 2010-09-03
21:19:40 UTC (rev 4042)
+++
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/application/RequestContext.java 2010-09-04
07:27:43 UTC (rev 4043)
@@ -20,6 +20,7 @@
package org.exoplatform.web.application;
import org.exoplatform.services.resources.Orientation;
+import org.exoplatform.web.url.URLFactory;
import java.io.Writer;
import java.util.HashMap;
@@ -69,6 +70,13 @@
}
/**
+ * Returns the URL factory associated with this context.
+ *
+ * @return the URL factory
+ */
+ public abstract URLFactory getURLFactory();
+
+ /**
* Returns the orientation for the current request.
*
* @return the orientation
Added:
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/url/ResourceType.java
===================================================================
---
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/url/ResourceType.java
(rev 0)
+++
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/url/ResourceType.java 2010-09-04
07:27:43 UTC (rev 4043)
@@ -0,0 +1,42 @@
+/*
+ * 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.url;
+
+/**
+ * The type of a resource.
+ *
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
+ * @version $Revision$
+ * @param <R> the resource parameter type
+ * @param <C> the resource context parameter type
+ * @param <U> the resource URL parameter type
+ */
+public abstract class ResourceType<R, C, U extends ResourceURL<R>>
+{
+
+ /**
+ * Creates a new URL instance with the specified context.
+ *
+ * @param context the context
+ * @return a new URL instance
+ */
+ protected abstract U newURL(C context);
+
+}
Added:
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
(rev 0)
+++
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/url/ResourceURL.java 2010-09-04
07:27:43 UTC (rev 4043)
@@ -0,0 +1,47 @@
+/*
+ * 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.url;
+
+/**
+ * Abstracts the URL of a resource.
+ *
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
+ * @version $Revision$
+ * @param <R> the resource parameter type
+ */
+public abstract class ResourceURL<R>
+{
+
+ /**
+ * Returns the current resource actually set.
+ *
+ * @return the resource
+ */
+ public abstract R getResource();
+
+ /**
+ * Set the resource on this URL.
+ *
+ * @param resource the resource to set
+ */
+ public abstract void setResource(R resource);
+
+
+}
Added:
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/url/URLFactory.java
===================================================================
---
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/url/URLFactory.java
(rev 0)
+++
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/url/URLFactory.java 2010-09-04
07:27:43 UTC (rev 4043)
@@ -0,0 +1,43 @@
+/*
+ * 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.url;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
+ * @version $Revision$
+ */
+public abstract class URLFactory
+{
+
+ protected abstract <R, C, U extends ResourceURL<R>> C
getContext(ResourceType<R, C, U> resourceType);
+
+ public <R, C, U extends ResourceURL<R>> U newURL(ResourceType<R, C,
U> resourceType)
+ {
+ C context = getContext(resourceType);
+ return resourceType.newURL(context);
+ }
+
+ public <R, C, U extends ResourceURL<R>> U newURL(ResourceType<R, C,
U> resourceType, R resource)
+ {
+ U url = newURL(resourceType);
+ url.setResource(resource);
+ return url;
+ }
+}
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-03
21:19:40 UTC (rev 4042)
+++
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestContext.java 2010-09-04
07:27:43 UTC (rev 4043)
@@ -35,6 +35,7 @@
import org.exoplatform.services.resources.Orientation;
import org.exoplatform.web.application.JavascriptManager;
import org.exoplatform.web.application.URLBuilder;
+import org.exoplatform.web.url.URLFactory;
import org.exoplatform.webui.application.WebuiApplication;
import org.exoplatform.webui.application.WebuiRequestContext;
import org.exoplatform.webui.core.UIComponent;
@@ -253,6 +254,12 @@
return title;
}
+ @Override
+ public URLFactory getURLFactory()
+ {
+ throw new UnsupportedOperationException();
+ }
+
/**
* Process current Portal Request URI. if current require uri is not equal to last one
then
* an event of type UIPortalApplication.CHANGE_NODE will be retuned, otherwise it
returns <code>null</code>
Modified:
portal/branches/navcontroller/webui/portlet/src/main/java/org/exoplatform/webui/application/portlet/PortletRequestContext.java
===================================================================
---
portal/branches/navcontroller/webui/portlet/src/main/java/org/exoplatform/webui/application/portlet/PortletRequestContext.java 2010-09-03
21:19:40 UTC (rev 4042)
+++
portal/branches/navcontroller/webui/portlet/src/main/java/org/exoplatform/webui/application/portlet/PortletRequestContext.java 2010-09-04
07:27:43 UTC (rev 4043)
@@ -22,6 +22,7 @@
import org.exoplatform.commons.utils.WriterPrinter;
import org.exoplatform.services.resources.Orientation;
import org.exoplatform.web.application.URLBuilder;
+import org.exoplatform.web.url.URLFactory;
import org.exoplatform.webui.application.WebuiApplication;
import org.exoplatform.webui.application.WebuiRequestContext;
import org.exoplatform.webui.core.UIApplication;
@@ -132,6 +133,12 @@
return response_;
}
+ @Override
+ public URLFactory getURLFactory()
+ {
+ return parentAppRequestContext_.getURLFactory();
+ }
+
public String getRemoteUser()
{
return parentAppRequestContext_.getRemoteUser();