Author: julien_viet
Date: 2010-09-05 07:49:55 -0400 (Sun, 05 Sep 2010)
New Revision: 4045
Added:
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/url/LocatorProvider.java
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/url/ResourceURL.java
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/url/
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/url/LocatorProviderService.java
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/ResourceLocatorPlugin.java
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/url/navigation/
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/url/navigation/NavigationLocator.java
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/url/navigation/NavigationLocatorPlugin.java
Removed:
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/url/LocatorFactory.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/ResourceLocator.java
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/url/ResourceType.java
portal/branches/navcontroller/webui/portal/src/main/java/conf/portal/configuration.xml
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:
attempt to plugin the resource url in the request context pipeline
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-05
09:31:13 UTC (rev 4044)
+++
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/application/RequestContext.java 2010-09-05
11:49:55 UTC (rev 4045)
@@ -20,7 +20,10 @@
package org.exoplatform.web.application;
import org.exoplatform.services.resources.Orientation;
-import org.exoplatform.web.url.LocatorFactory;
+import org.exoplatform.web.url.LocatorProvider;
+import org.exoplatform.web.url.ResourceLocator;
+import org.exoplatform.web.url.ResourceType;
+import org.exoplatform.web.url.ResourceURL;
import java.io.Writer;
import java.util.HashMap;
@@ -74,8 +77,34 @@
*
* @return the locator factory
*/
- public abstract LocatorFactory getLocatorFactory();
+ public abstract LocatorProvider getLocatorProvider();
+ public abstract <R, L extends ResourceLocator<R>> ResourceURL<R, L>
newURL(ResourceType<R, L> resourceType, L locator);
+
+ public final <R, L extends ResourceLocator<R>> ResourceURL<R, L>
createURL(ResourceType<R, L> resourceType, R resource)
+ {
+ // Get the provider
+ LocatorProvider provider = getLocatorProvider();
+
+ // Obtain a locator for the resource type
+ L locator = provider.newLocator(resourceType);
+
+ //
+ if (locator == null)
+ {
+ throw new IllegalArgumentException("No resource locator found for the
resource type " + resourceType);
+ }
+
+ // Create an URL from the locator
+ ResourceURL<R, L> url = newURL(resourceType, locator);
+
+ // Set the resource on the URL
+ url.setResource(resource);
+
+ // Returns the URL object
+ return url;
+ }
+
/**
* Returns the orientation for the current request.
*
Deleted:
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/LocatorFactory.java 2010-09-05
09:31:13 UTC (rev 4044)
+++
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/url/LocatorFactory.java 2010-09-05
11:49:55 UTC (rev 4045)
@@ -1,53 +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 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/LocatorProvider.java
(from rev 4044,
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/LocatorProvider.java
(rev 0)
+++
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/url/LocatorProvider.java 2010-09-05
11:49:55 UTC (rev 4045)
@@ -0,0 +1,40 @@
+/*
+ * 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 LocatorProvider
+{
+
+ /**
+ * Creates a new locator.
+ *
+ * @param resourceType the resource type
+ * @param <R> the resource parameter type
+ * @param <L> the resource locator parameter type
+ * @return the context
+ * @throws NullPointerException if the resource type is null
+ */
+ public abstract <R, L extends ResourceLocator<R>> L
newLocator(ResourceType<R, L> resourceType) throws NullPointerException;
+
+}
Modified:
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/url/ResourceLocator.java
===================================================================
---
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/url/ResourceLocator.java 2010-09-05
09:31:13 UTC (rev 4044)
+++
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/url/ResourceLocator.java 2010-09-05
11:49:55 UTC (rev 4045)
@@ -22,28 +22,30 @@
import java.io.IOException;
/**
- * Abstracts the URL of a resource.
+ * <p>A locator for a resource.</p>
*
+ * <p>This class is abstract to allow locator subclass to add specific
parameters.</p>
+ *
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
* @param <R> the resource parameter type
*/
-public abstract class ResourceLocator<R>
+public interface ResourceLocator<R>
{
/**
- * Returns the current resource actually set.
+ * Returns the current resource actually set on this locator.
*
* @return the resource
*/
- public abstract R getResource();
+ R getResource();
/**
* Set the resource on this locator.
*
* @param resource the resource to set
*/
- public abstract void setResource(R resource);
+ void setResource(R resource);
/**
* Append the resource locator path.
@@ -51,6 +53,6 @@
* @param appendable the appendable
* @throws IOException any IOException thrown by the appendable
*/
- public abstract void append(Appendable appendable) throws IOException;
+ 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-05
09:31:13 UTC (rev 4044)
+++
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/url/ResourceType.java 2010-09-05
11:49:55 UTC (rev 4045)
@@ -25,20 +25,8 @@
* @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 <L> the resource locator parameter type
*/
-public abstract class ResourceType<R, C, L extends ResourceLocator<R>>
+public abstract class ResourceType<R, L extends ResourceLocator<R>>
{
-
- public abstract Class<C> getContextType();
-
- /**
- * Creates a new locator instance with the specified context.
- *
- * @param context the context
- * @return a new locator instance
- */
- protected abstract L newLocator(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-05
11:49:55 UTC (rev 4045)
@@ -0,0 +1,87 @@
+/*
+ * 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;
+
+/**
+ * An URL for a resource.
+ *
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
+ * @version $Revision$
+ */
+public abstract class ResourceURL<R, L extends ResourceLocator<R>>
+{
+
+ /** . */
+ protected final L locator;
+
+ /**
+ * Create a new instance.
+ *
+ * @param locator the resource locator that can't be null
+ * @throws NullPointerException if the resource locator is null
+ */
+ public ResourceURL(L locator) throws NullPointerException
+ {
+ if (locator == null)
+ {
+ throw new NullPointerException("No null locator");
+ }
+
+ //
+ this.locator = locator;
+ }
+
+ /**
+ * Returns the resource locator of this URL.
+ *
+ * @return the resource locator
+ */
+ public final L getResourceLocator()
+ {
+ return locator;
+ }
+
+ /**
+ * Returns the current resource associated with this URL.
+ *
+ * @return the resource
+ */
+ public final R getResource()
+ {
+ return locator.getResource();
+ }
+
+ /**
+ * Set a new resource on this URL.
+ *
+ * @param resource the new resource
+ */
+ public final void setResource(R resource)
+ {
+ locator.setResource(resource);
+ }
+
+ /**
+ * Generates the URL value.
+ *
+ * @return the URL value
+ */
+ public abstract String toString();
+}
Modified:
portal/branches/navcontroller/webui/portal/src/main/java/conf/portal/configuration.xml
===================================================================
---
portal/branches/navcontroller/webui/portal/src/main/java/conf/portal/configuration.xml 2010-09-05
09:31:13 UTC (rev 4044)
+++
portal/branches/navcontroller/webui/portal/src/main/java/conf/portal/configuration.xml 2010-09-05
11:49:55 UTC (rev 4045)
@@ -37,4 +37,15 @@
<!--type>org.exoplatform.portal.application.NoBrowserLocalePolicyService</type-->
<type>org.exoplatform.portal.application.localization.DefaultLocalePolicyService</type>
</component>
+
+ <component>
+ <type>org.exoplatform.portal.url.LocatorProviderService</type>
+ <component-plugins>
+ <component-plugin>
+ <name>navigation.locator.plugin</name>
+ <set-method>addPlugin</set-method>
+
<type>org.exoplatform.portal.url.navigation.NavigationLocatorPlugin</type>
+ </component-plugin>
+ </component-plugins>
+ </component>
</configuration>
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-05
09:31:13 UTC (rev 4044)
+++
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestContext.java 2010-09-05
11:49:55 UTC (rev 4045)
@@ -22,11 +22,13 @@
import org.exoplatform.Constants;
import org.exoplatform.commons.utils.PortalPrinter;
import org.exoplatform.container.ExoContainer;
+import org.exoplatform.container.PortalContainer;
import org.exoplatform.portal.config.UserPortalConfigService;
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.url.LocatorProviderService;
+import org.exoplatform.portal.url.PortalURL;
import org.exoplatform.portal.webui.portal.PageNodeEvent;
import org.exoplatform.portal.webui.portal.UIPortal;
import org.exoplatform.portal.webui.util.Util;
@@ -36,7 +38,10 @@
import org.exoplatform.services.resources.Orientation;
import org.exoplatform.web.application.JavascriptManager;
import org.exoplatform.web.application.URLBuilder;
-import org.exoplatform.web.url.LocatorFactory;
+import org.exoplatform.web.url.LocatorProvider;
+import org.exoplatform.web.url.ResourceLocator;
+import org.exoplatform.web.url.ResourceType;
+import org.exoplatform.web.url.ResourceURL;
import org.exoplatform.webui.application.WebuiApplication;
import org.exoplatform.webui.application.WebuiRequestContext;
import org.exoplatform.webui.core.UIComponent;
@@ -125,7 +130,7 @@
private PageNode targetNode_;
/** . */
- private final PortalLocatorFactory locatorFactory;
+ private final LocatorProviderService locatorFactory;
public JavascriptManager getJavascriptManager()
{
@@ -150,7 +155,7 @@
super(app);
//
- locatorFactory = new PortalLocatorFactory();
+ locatorFactory =
(LocatorProviderService)PortalContainer.getComponent(LocatorProviderService.class);
//
request_ = req;
@@ -223,6 +228,12 @@
urlBuilder = new PortalURLBuilder(requestURI_);
}
+ @Override
+ public <R, L extends ResourceLocator<R>> ResourceURL<R, L>
newURL(ResourceType<R, L> resourceType, L locator)
+ {
+ return new PortalURL<R,L>(this, locator);
+ }
+
public void refreshResourceBundle() throws Exception
{
appRes_ = getApplication().getResourceBundle(getLocale());
@@ -264,7 +275,7 @@
}
@Override
- public LocatorFactory getLocatorFactory()
+ public LocatorProvider getLocatorProvider()
{
return locatorFactory;
}
Added:
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/url/LocatorProviderService.java
===================================================================
---
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/url/LocatorProviderService.java
(rev 0)
+++
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/url/LocatorProviderService.java 2010-09-05
11:49:55 UTC (rev 4045)
@@ -0,0 +1,62 @@
+/*
+ * 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.url.*;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
+ * @version $Revision$
+ */
+public class LocatorProviderService extends LocatorProvider
+{
+
+ /** . */
+ private final Map<ResourceType<?,?>, ResourceLocatorPlugin> plugins;
+
+ public LocatorProviderService()
+ {
+ this.plugins = new HashMap<ResourceType<?,?>,
ResourceLocatorPlugin>();
+ }
+
+ @Override
+ public <R, L extends ResourceLocator<R>> L newLocator(ResourceType<R,
L> resourceType) throws NullPointerException
+ {
+ if (resourceType == null)
+ {
+ throw new NullPointerException("No null resource type accepted");
+ }
+
+ // Can't really make that checked
+ @SuppressWarnings("unchecked")
+ ResourceLocatorPlugin<R, L> plugin =
(ResourceLocatorPlugin<R,L>)plugins.get(resourceType);
+
+ //
+ return plugin != null ? plugin.newLocator() : null;
+ }
+
+ public void addPlugin(ResourceLocatorPlugin plugin)
+ {
+ plugins.put(plugin.getResourceType(), plugin);
+ }
+}
Added:
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
(rev 0)
+++
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/url/PortalURL.java 2010-09-05
11:49:55 UTC (rev 4045)
@@ -0,0 +1,66 @@
+/*
+ * 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.portal.application.PortalRequestContext;
+import org.exoplatform.web.url.ResourceLocator;
+import org.exoplatform.web.url.ResourceURL;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
+ * @version $Revision$
+ */
+public class PortalURL<R, L extends ResourceLocator<R>> extends
ResourceURL<R, L>
+{
+
+ /** . */
+ private final PortalRequestContext requestContext;
+
+ public PortalURL(PortalRequestContext requestContext, L locator)
+ {
+ super(locator);
+
+ //
+ if (requestContext == null)
+ {
+ throw new NullPointerException("No null request context");
+ }
+
+ //
+ this.requestContext = requestContext;
+ }
+
+ public String toString()
+ {
+ if (locator.getResource() == null)
+ {
+ throw new IllegalStateException("No resource set of the portal URL");
+ }
+
+ //
+ StringBuilder sb = new StringBuilder();
+
+ //
+ sb.append(requestContext.getPortalURI());
+
+ //
+ return sb.toString();
+ }
+}
Added:
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/url/ResourceLocatorPlugin.java
===================================================================
---
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/url/ResourceLocatorPlugin.java
(rev 0)
+++
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/url/ResourceLocatorPlugin.java 2010-09-05
11:49:55 UTC (rev 4045)
@@ -0,0 +1,49 @@
+/*
+ * 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.container.component.BaseComponentPlugin;
+import org.exoplatform.web.url.ResourceLocator;
+import org.exoplatform.web.url.ResourceType;
+
+/**
+ * A plugin for adding resource locator to the {@link LocatorProviderService}.
+ *
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
+ * @version $Revision$
+ */
+public abstract class ResourceLocatorPlugin<R, L extends ResourceLocator<R>>
extends BaseComponentPlugin
+{
+
+ /**
+ * Returns the resource type.
+ *
+ * @return the resource type
+ */
+ protected abstract ResourceType<R, L> getResourceType();
+
+ /**
+ * Returns a new locator instance.
+ *
+ * @return a new locator instance
+ */
+ protected abstract L newLocator();
+
+}
Added:
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/url/navigation/NavigationLocator.java
===================================================================
---
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/url/navigation/NavigationLocator.java
(rev 0)
+++
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/url/navigation/NavigationLocator.java 2010-09-05
11:49:55 UTC (rev 4045)
@@ -0,0 +1,57 @@
+/*
+ * 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.navigation;
+
+import org.exoplatform.portal.config.model.PageNode;
+import org.exoplatform.web.url.ResourceLocator;
+import org.exoplatform.web.url.ResourceType;
+
+import java.io.IOException;
+
+/**
+ * A resource locator for navigation nodes.
+ *
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
+ * @version $Revision$
+ */
+public class NavigationLocator implements ResourceLocator<PageNode>
+{
+
+ /** . */
+ public static final ResourceType<PageNode, NavigationLocator> TYPE = new
ResourceType<PageNode, NavigationLocator>(){};
+
+ /** . */
+ private PageNode resource;
+
+ public PageNode getResource()
+ {
+ return resource;
+ }
+
+ public void setResource(PageNode resource)
+ {
+ this.resource = resource;
+ }
+
+ public void append(Appendable appendable) throws IOException
+ {
+ appendable.append(resource.getUri());
+ }
+}
Added:
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/url/navigation/NavigationLocatorPlugin.java
===================================================================
---
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/url/navigation/NavigationLocatorPlugin.java
(rev 0)
+++
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/url/navigation/NavigationLocatorPlugin.java 2010-09-05
11:49:55 UTC (rev 4045)
@@ -0,0 +1,44 @@
+/*
+ * 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.navigation;
+
+import org.exoplatform.portal.config.model.PageNode;
+import org.exoplatform.portal.url.ResourceLocatorPlugin;
+import org.exoplatform.web.url.ResourceType;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
+ * @version $Revision$
+ */
+public class NavigationLocatorPlugin extends ResourceLocatorPlugin<PageNode,
NavigationLocator>
+{
+
+ @Override
+ protected ResourceType<PageNode, NavigationLocator> getResourceType()
+ {
+ return NavigationLocator.TYPE;
+ }
+
+ @Override
+ protected NavigationLocator newLocator()
+ {
+ return new NavigationLocator();
+ }
+}
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-05
09:31:13 UTC (rev 4044)
+++
portal/branches/navcontroller/webui/portlet/src/main/java/org/exoplatform/webui/application/portlet/PortletRequestContext.java 2010-09-05
11:49:55 UTC (rev 4045)
@@ -22,7 +22,10 @@
import org.exoplatform.commons.utils.WriterPrinter;
import org.exoplatform.services.resources.Orientation;
import org.exoplatform.web.application.URLBuilder;
-import org.exoplatform.web.url.LocatorFactory;
+import org.exoplatform.web.url.LocatorProvider;
+import org.exoplatform.web.url.ResourceLocator;
+import org.exoplatform.web.url.ResourceType;
+import org.exoplatform.web.url.ResourceURL;
import org.exoplatform.webui.application.WebuiApplication;
import org.exoplatform.webui.application.WebuiRequestContext;
import org.exoplatform.webui.core.UIApplication;
@@ -74,6 +77,12 @@
urlBuilder = new PortletURLBuilder();
}
+ @Override
+ public <R, L extends ResourceLocator<R>> ResourceURL<R, L>
newURL(ResourceType<R, L> resourceType, L locator)
+ {
+ return parentAppRequestContext_.newURL(resourceType, locator);
+ }
+
public void init(Writer writer, PortletRequest req, PortletResponse res)
{
request_ = req;
@@ -134,9 +143,9 @@
}
@Override
- public LocatorFactory getLocatorFactory()
+ public LocatorProvider getLocatorProvider()
{
- return parentAppRequestContext_.getLocatorFactory();
+ return parentAppRequestContext_.getLocatorProvider();
}
public String getRemoteUser()