Author: julien_viet
Date: 2010-09-05 05:31:13 -0400 (Sun, 05 Sep 2010)
New Revision: 4044
Added:
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/url/LocatorFactory.java
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/url/ResourceLocator.java
Removed:
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/component/web/controller/src/main/java/org/exoplatform/web/url/ResourceType.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:
improve a bit
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-04
07:27:43 UTC (rev 4043)
+++
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/application/RequestContext.java 2010-09-05
09:31:13 UTC (rev 4044)
@@ -20,7 +20,7 @@
package org.exoplatform.web.application;
import org.exoplatform.services.resources.Orientation;
-import org.exoplatform.web.url.URLFactory;
+import org.exoplatform.web.url.LocatorFactory;
import java.io.Writer;
import java.util.HashMap;
@@ -70,11 +70,11 @@
}
/**
- * Returns the URL factory associated with this context.
+ * Returns the locator factory associated with this context.
*
- * @return the URL factory
+ * @return the locator factory
*/
- public abstract URLFactory getURLFactory();
+ public abstract LocatorFactory getLocatorFactory();
/**
* Returns the orientation for the current request.
Copied:
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/url/LocatorFactory.java
(from rev 4043,
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/LocatorFactory.java
(rev 0)
+++
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/url/LocatorFactory.java 2010-09-05
09:31:13 UTC (rev 4044)
@@ -0,0 +1,53 @@
+/*
+ * 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 LocatorFactory
+{
+
+ /**
+ * Returns a resource context for a resource type or null if none can be found.
+ *
+ * @param resourceType the resource type
+ * @param <R> the resource parameter type
+ * @param <C> the resource context parameter type
+ * @param <L> the resource locator parameter type
+ * @return the context
+ * @throws NullPointerException if the resource type is null
+ */
+ protected abstract <R, C, L extends ResourceLocator<R>> C
getContext(ResourceType<R, C, L> resourceType) throws NullPointerException;
+
+ public <R, C, U extends ResourceLocator<R>> U
newLocator(ResourceType<R, C, U> resourceType)
+ {
+ C context = getContext(resourceType);
+ return resourceType.newLocator(context);
+ }
+
+ public <R, C, L extends ResourceLocator<R>> L
newLocator(ResourceType<R, C, L> resourceType, R resource)
+ {
+ L locator = newLocator(resourceType);
+ locator.setResource(resource);
+ return locator;
+ }
+}
Copied:
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/url/ResourceLocator.java
(from rev 4043,
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/ResourceLocator.java
(rev 0)
+++
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/url/ResourceLocator.java 2010-09-05
09:31:13 UTC (rev 4044)
@@ -0,0 +1,56 @@
+/*
+ * 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;
+
+import java.io.IOException;
+
+/**
+ * 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 ResourceLocator<R>
+{
+
+ /**
+ * Returns the current resource actually set.
+ *
+ * @return the resource
+ */
+ public abstract R getResource();
+
+ /**
+ * Set the resource on this locator.
+ *
+ * @param resource the resource to set
+ */
+ public abstract void setResource(R resource);
+
+ /**
+ * Append the resource locator path.
+ *
+ * @param appendable the appendable
+ * @throws IOException any IOException thrown by the appendable
+ */
+ public abstract void append(Appendable appendable) throws IOException;
+
+}
Modified:
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 2010-09-04
07:27:43 UTC (rev 4043)
+++
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/url/ResourceType.java 2010-09-05
09:31:13 UTC (rev 4044)
@@ -26,17 +26,19 @@
* @version $Revision$
* @param <R> the resource parameter type
* @param <C> the resource context parameter type
- * @param <U> the resource URL parameter type
+ * @param <L> the resource locator parameter type
*/
-public abstract class ResourceType<R, C, U extends ResourceURL<R>>
+public abstract class ResourceType<R, C, L extends ResourceLocator<R>>
{
+ public abstract Class<C> getContextType();
+
/**
- * Creates a new URL instance with the specified context.
+ * Creates a new locator instance with the specified context.
*
* @param context the context
- * @return a new URL instance
+ * @return a new locator instance
*/
- protected abstract U newURL(C context);
+ protected abstract L newLocator(C context);
}
Deleted:
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-04
07:27:43 UTC (rev 4043)
+++
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/url/ResourceURL.java 2010-09-05
09:31:13 UTC (rev 4044)
@@ -1,47 +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.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);
-
-
-}
Deleted:
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 2010-09-04
07:27:43 UTC (rev 4043)
+++
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/url/URLFactory.java 2010-09-05
09:31:13 UTC (rev 4044)
@@ -1,43 +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.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-04
07:27:43 UTC (rev 4043)
+++
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestContext.java 2010-09-05
09:31:13 UTC (rev 4044)
@@ -26,6 +26,7 @@
import org.exoplatform.portal.config.model.Page;
import org.exoplatform.portal.config.model.PageNavigation;
import org.exoplatform.portal.config.model.PageNode;
+import org.exoplatform.portal.url.PortalLocatorFactory;
import org.exoplatform.portal.webui.portal.PageNodeEvent;
import org.exoplatform.portal.webui.portal.UIPortal;
import org.exoplatform.portal.webui.util.Util;
@@ -35,7 +36,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.web.url.LocatorFactory;
import org.exoplatform.webui.application.WebuiApplication;
import org.exoplatform.webui.application.WebuiRequestContext;
import org.exoplatform.webui.core.UIComponent;
@@ -123,6 +124,9 @@
private PageNode targetNode_;
+ /** . */
+ private final PortalLocatorFactory locatorFactory;
+
public JavascriptManager getJavascriptManager()
{
return jsmanager_;
@@ -144,6 +148,11 @@
public PortalRequestContext(WebuiApplication app, HttpServletRequest req,
HttpServletResponse res) throws Exception
{
super(app);
+
+ //
+ locatorFactory = new PortalLocatorFactory();
+
+ //
request_ = req;
response_ = res;
response_.setBufferSize(1024 * 100);
@@ -255,9 +264,9 @@
}
@Override
- public URLFactory getURLFactory()
+ public LocatorFactory getLocatorFactory()
{
- throw new UnsupportedOperationException();
+ return locatorFactory;
}
/**
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-04
07:27:43 UTC (rev 4043)
+++
portal/branches/navcontroller/webui/portlet/src/main/java/org/exoplatform/webui/application/portlet/PortletRequestContext.java 2010-09-05
09:31:13 UTC (rev 4044)
@@ -22,7 +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.web.url.LocatorFactory;
import org.exoplatform.webui.application.WebuiApplication;
import org.exoplatform.webui.application.WebuiRequestContext;
import org.exoplatform.webui.core.UIApplication;
@@ -134,9 +134,9 @@
}
@Override
- public URLFactory getURLFactory()
+ public LocatorFactory getLocatorFactory()
{
- return parentAppRequestContext_.getURLFactory();
+ return parentAppRequestContext_.getLocatorFactory();
}
public String getRemoteUser()