gatein SVN: r7148 - in portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl: content and 2 other directories.
by do-not-reply@jboss.org
Author: julien_viet
Date: 2011-08-16 05:51:44 -0400 (Tue, 16 Aug 2011)
New Revision: 7148
Modified:
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/GateInImpl.java
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ContentRegistryImpl.java
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/id/ComplexApplicationContext.java
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/id/ComplexApplicationId.java
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/NavigationImpl.java
Log:
more work
Modified: portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/GateInImpl.java
===================================================================
--- portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/GateInImpl.java 2011-08-16 09:13:51 UTC (rev 7147)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/GateInImpl.java 2011-08-16 09:51:44 UTC (rev 7148)
@@ -544,9 +544,10 @@
}
else if (ManagedContent.class.equals(type))
{
- final String categoryId = id.getComponent(CATEGORY_COMPONENT);
- final Category category = get(categoryId(categoryId));
- result = category.getManagedContent(id.getComponent("name"));
+// final String categoryId = id.getComponent(CATEGORY_COMPONENT);
+// final Category category = get(categoryId(categoryId));
+// result = category.getManagedContent(id.getComponent("name"));
+ throw new UnsupportedOperationException("disabled");
}
else if (Navigation.class.equals(type))
{
@@ -562,20 +563,18 @@
public Site getSite(Site.Id siteId)
{
- final String siteType = siteId.getComponent(SITE_TYPE_COMPONENT);
- ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(siteType, "Site type", "A valid Site Id");
-
- if (Site.PORTAL_TYPE_NAME.equals(siteType))
+ Type<Site> siteType = siteId.getType();
+ if (Site.PORTAL == siteType)
{
return getPortal(siteId);
}
- else if (Site.GROUP_TYPE_NAME.equals(siteType))
+ else if (Site.GROUP == siteType)
{
- return getGroupSite(siteId.getComponent(SITE_NAME_COMPONENT));
+ return getGroupSite(siteId.getName());
}
- else if (Site.DASHBOARD_TYPE_NAME.equals(siteType))
+ else if (Site.DASHBOARD == siteType)
{
- return getDashboard(siteId.getComponent(SITE_NAME_COMPONENT));
+ return getDashboard(siteId.getName());
}
else
{
Modified: portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ContentRegistryImpl.java
===================================================================
--- portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ContentRegistryImpl.java 2011-08-16 09:13:51 UTC (rev 7147)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ContentRegistryImpl.java 2011-08-16 09:51:44 UTC (rev 7148)
@@ -237,6 +237,7 @@
{
PortletContext portletContext;
Object regitryItem;
+/*
if (!id.knowsComponent(GateInImpl.INVOKER_COMPONENT))
{
portletContext = PortletContext.createPortletContext(id.getComponent(GateInImpl.APPLICATION_COMPONENT), id.getComponent(GateInImpl.PORTLET_COMPONENT));
@@ -248,6 +249,8 @@
regitryItem = gateIn.getPortletInvoker().getPortlet(portletContext);
}
return regitryItem;
+*/
+ throw new UnsupportedOperationException("disabled for now");
}
private <T extends Content> Content newContentFrom(Id id, Object registryItem, Class<T> wanted)
Modified: portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/id/ComplexApplicationContext.java
===================================================================
--- portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/id/ComplexApplicationContext.java 2011-08-16 09:13:51 UTC (rev 7147)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/id/ComplexApplicationContext.java 2011-08-16 09:51:44 UTC (rev 7148)
@@ -23,15 +23,13 @@
package org.gatein.portal.api.impl.id;
import org.gatein.api.content.Portlet;
-import org.gatein.api.id.Context;
import org.gatein.api.id.Id;
import org.gatein.api.id.Identifiable;
import org.gatein.portal.api.impl.GateInImpl;
/** @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a> */
-public class ComplexApplicationContext implements Context
+public class ComplexApplicationContext // implements Context
{
- public static final Context INSTANCE = new ComplexApplicationContext();
public String getName()
{
Modified: portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/id/ComplexApplicationId.java
===================================================================
--- portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/id/ComplexApplicationId.java 2011-08-16 09:13:51 UTC (rev 7147)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/id/ComplexApplicationId.java 2011-08-16 09:51:44 UTC (rev 7148)
@@ -23,9 +23,7 @@
package org.gatein.portal.api.impl.id;
import org.gatein.api.content.Portlet;
-import org.gatein.api.id.Context;
import org.gatein.api.id.Id;
-import org.gatein.api.id.RenderingContext;
import org.gatein.portal.api.impl.GateInImpl;
/** @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a> */
@@ -36,7 +34,7 @@
private final String category;
private final String app;
private final String portlet;
- private final Context context;
+// private final Context context;
private final String separator;
public ComplexApplicationId(String category, String appName, String portletName, String separator, ComplexApplicationContext context)
@@ -44,19 +42,19 @@
this.category = category;
this.app = appName;
this.portlet = portletName;
- this.context = context;
+// this.context = context;
this.separator = separator;
}
@Override
public String toString()
{
- return toString(context);
+ return toString(null);
}
- public String toString(RenderingContext context)
+ public String toString(Object context)
{
- if (this.context.equals(context))
+ if (false != true)
{
if ("/".equals(separator))
{
@@ -148,11 +146,6 @@
}
}
- public Context getOriginalContext()
- {
- return context;
- }
-
public int getComponentNumber()
{
return 4;
@@ -180,7 +173,7 @@
public boolean knowsComponent(String name)
{
- return context.hasComponent(name);
+ return false;
}
public int compareTo(Id o)
Modified: portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/NavigationImpl.java
===================================================================
--- portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/NavigationImpl.java 2011-08-16 09:13:51 UTC (rev 7147)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/NavigationImpl.java 2011-08-16 09:51:44 UTC (rev 7148)
@@ -284,8 +284,8 @@
Locale locale = getUserLocale();
bundle = rbMgr.getNavigationResourceBundle(
locale.getLanguage(),
- site.getId().getComponent(GateInImpl.SITE_TYPE_COMPONENT),
- site.getId().getComponent(GateInImpl.SITE_NAME_COMPONENT));
+ site.getId().getType().getName(),
+ site.getId().getName());
if (bundle == null)
{
13 years, 4 months
gatein SVN: r7147 - in portal/branches/api/component/api-impl/src: main/java/org/gatein/portal/api/impl/portal and 1 other directories.
by do-not-reply@jboss.org
Author: julien_viet
Date: 2011-08-16 05:13:51 -0400 (Tue, 16 Aug 2011)
New Revision: 7147
Modified:
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/GateInImpl.java
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/DashboardSiteImpl.java
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/GroupSiteImpl.java
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/PortalImpl.java
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/SiteImpl.java
portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/portal/NavigationTestCase.java
Log:
improve site id
Modified: portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/GateInImpl.java
===================================================================
--- portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/GateInImpl.java 2011-08-16 08:57:17 UTC (rev 7146)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/GateInImpl.java 2011-08-16 09:13:51 UTC (rev 7147)
@@ -264,7 +264,7 @@
public Portal getDefaultPortal()
{
- return getPortal(siteId(Site.PORTAL, "classic")); // todo: check
+ return getPortal(Site.Id.createPortal("classic")); // todo: check
}
public IterableIdentifiableCollection<Site> getSites()
@@ -372,9 +372,9 @@
sb.append("/").append(name);
}
String groupId = sb.toString();
- Site.Id siteId = siteId(Site.GROUP, groupId);
+ Site.Id siteId = Site.Id.createGroup(groupId);
- return new GroupSiteImpl(siteId, groupId, this);
+ return new GroupSiteImpl(siteId, this);
}
public IterableIdentifiableCollection<Site> getGroupSites(String userId)
@@ -479,9 +479,9 @@
public Site getDashboard(String userId)
{
- Site.Id siteId = siteId(Site.DASHBOARD, userId);
+ Site.Id siteId = Site.Id.createDashboard(userId);
- return new DashboardSiteImpl(siteId, userId, this);
+ return new DashboardSiteImpl(siteId, this);
}
public <T extends Identifiable<T>> T get(Id<T> id)
@@ -653,11 +653,6 @@
}
*/
- public Site.Id siteId(Type<Site> siteType, String portalName)
- {
- return new Site.Id(siteType, portalName);
- }
-
public Page.Id pageId(Site.Id ownerSite, String pageName)
{
ParameterValidation.throwIllegalArgExceptionIfNull(ownerSite, "Owner Site Id");
Modified: portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/DashboardSiteImpl.java
===================================================================
--- portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/DashboardSiteImpl.java 2011-08-16 08:57:17 UTC (rev 7146)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/DashboardSiteImpl.java 2011-08-16 09:13:51 UTC (rev 7147)
@@ -30,9 +30,9 @@
/** @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a> */
public class DashboardSiteImpl extends SiteImpl
{
- public DashboardSiteImpl(Site.Id siteId, String name, GateInImpl gateIn)
+ public DashboardSiteImpl(Site.Id siteId, GateInImpl gateIn)
{
- super(siteId, name, gateIn);
+ super(siteId, gateIn);
}
@Override
Modified: portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/GroupSiteImpl.java
===================================================================
--- portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/GroupSiteImpl.java 2011-08-16 08:57:17 UTC (rev 7146)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/GroupSiteImpl.java 2011-08-16 09:13:51 UTC (rev 7147)
@@ -31,9 +31,9 @@
/** @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a> */
public class GroupSiteImpl extends SiteImpl
{
- public GroupSiteImpl(Site.Id siteId, String name, GateInImpl gateIn)
+ public GroupSiteImpl(Site.Id siteId, GateInImpl gateIn)
{
- super(siteId, name, gateIn);
+ super(siteId, gateIn);
}
@Override
Modified: portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/PortalImpl.java
===================================================================
--- portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/PortalImpl.java 2011-08-16 08:57:17 UTC (rev 7146)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/PortalImpl.java 2011-08-16 09:13:51 UTC (rev 7147)
@@ -37,7 +37,7 @@
public PortalImpl(PortalData portal, GateInImpl gateIn)
{
- super(gateIn.siteId(getAPITypeFrom(portal.getKey()), portal.getKey().getId()), portal.getName(), gateIn);
+ super(Site.Id.create(getAPITypeFrom(portal.getKey()), portal.getKey().getId()), gateIn);
}
public ContentRegistry getContentRegistry()
Modified: portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/SiteImpl.java
===================================================================
--- portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/SiteImpl.java 2011-08-16 08:57:17 UTC (rev 7146)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/SiteImpl.java 2011-08-16 09:13:51 UTC (rev 7147)
@@ -61,9 +61,9 @@
/** . */
final PageContainer pages;
- public SiteImpl(Site.Id siteId, String name, GateInImpl gateIn)
+ public SiteImpl(Site.Id siteId, GateInImpl gateIn)
{
- super(siteId, name, gateIn);
+ super(siteId, siteId.getName(), gateIn);
//
this.pages = new PageContainer();
Modified: portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/portal/NavigationTestCase.java
===================================================================
--- portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/portal/NavigationTestCase.java 2011-08-16 08:57:17 UTC (rev 7146)
+++ portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/portal/NavigationTestCase.java 2011-08-16 09:13:51 UTC (rev 7147)
@@ -94,7 +94,7 @@
public void testEmptyNavigation()
{
- Site site = gatein.getPortal(new Site.Id(Site.PORTAL, "classic"));
+ Site site = gatein.getPortal(Site.Id.createPortal("classic"));
assertNotNull(site);
Site.Id id = site.getId();
assertEquals(Site.PORTAL, id.getType());
@@ -114,7 +114,7 @@
navService.saveNode(root, null);
//
- Site site = gatein.getPortal(new Site.Id(Site.PORTAL, "classic"));
+ Site site = gatein.getPortal(Site.Id.createPortal("classic"));
Navigation rootNav = site.getNavigation();
Iterator<? extends Navigation> i = rootNav.getChildren().iterator();
assertTrue(i.hasNext());
@@ -132,7 +132,7 @@
navService.saveNode(root, null);
//
- Site site = gatein.getPortal(new Site.Id(Site.PORTAL, "classic"));
+ Site site = gatein.getPortal(Site.Id.createPortal("classic"));
Page homePage = site.getPage("homepage");
assertNotNull(homePage);
13 years, 4 months
gatein SVN: r7146 - in portal/branches/api: component/api-impl/src/test/java/org/gatein/portal/api/impl and 5 other directories.
by do-not-reply@jboss.org
Author: julien_viet
Date: 2011-08-16 04:57:17 -0400 (Tue, 16 Aug 2011)
New Revision: 7146
Added:
portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/SimpleRequestContext.java
Modified:
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/NavigationImpl.java
portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/portal/NavigationTestCase.java
portal/branches/api/component/web/controller/src/main/java/org/exoplatform/web/url/ResourceType.java
portal/branches/api/component/web/controller/src/main/java/org/exoplatform/web/url/navigation/NodeURL.java
portal/branches/api/examples/portlets/api/src/main/java/org/gatein/portal/samples/api/NavigationPortlet.java
portal/branches/api/webui/framework/src/main/java/org/exoplatform/webui/url/ComponentURL.java
Log:
unit test for URI
Modified: portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/NavigationImpl.java
===================================================================
--- portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/NavigationImpl.java 2011-08-16 07:43:36 UTC (rev 7145)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/NavigationImpl.java 2011-08-16 08:57:17 UTC (rev 7146)
@@ -106,13 +106,11 @@
try
{
RequestContext requestContext = RequestContext.getCurrentInstance();
- SiteType siteType = SiteType.valueOf(site.getId().getComponents()[0].toUpperCase());
- String siteName = site.getId().getComponents()[1];
-
- NavigationResource navResource = new NavigationResource(siteType, siteName, buildURI().toString());
+ SiteType siteType = SiteType.valueOf(site.getId().getType().getName().toUpperCase());
+ String siteName = site.getId().getName();
+ NavigationResource navResource = new NavigationResource(siteType, siteName, buildURI().toString());
NodeURL nodeURL = requestContext.createURL(NodeURL.TYPE, navResource);
nodeURL.setSchemeUse(true);
-
uri = new URI(nodeURL.toString());
}
catch (URISyntaxException e)
Added: portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/SimpleRequestContext.java
===================================================================
--- portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/SimpleRequestContext.java (rev 0)
+++ portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/SimpleRequestContext.java 2011-08-16 08:57:17 UTC (rev 7146)
@@ -0,0 +1,99 @@
+package org.gatein.portal.api.impl;
+
+import org.exoplatform.services.resources.Orientation;
+import org.exoplatform.web.application.Application;
+import org.exoplatform.web.application.RequestContext;
+import org.exoplatform.web.application.URLBuilder;
+import org.exoplatform.web.url.PortalURL;
+import org.exoplatform.web.url.ResourceType;
+import org.exoplatform.web.url.URLContext;
+import org.exoplatform.web.url.URLFactory;
+import org.exoplatform.web.url.navigation.NavigationResource;
+import org.exoplatform.web.url.navigation.NodeURL;
+import org.gatein.common.NotYetImplemented;
+
+/** @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a> */
+public class SimpleRequestContext extends RequestContext
+{
+
+ /** . */
+ private static final URLContext ctx = new URLContext()
+ {
+ public <R, U extends PortalURL<R, U>> String render(U url)
+ {
+ PortalURL bu = url;
+ if (bu instanceof NodeURL)
+ {
+ NodeURL nodeURL = (NodeURL)bu;
+ NavigationResource res = nodeURL.getResource();
+ return "/" + res.getSiteType().getName() + "/" + res.getSiteName() + "/" + res.getNodeURI();
+ }
+ else
+ {
+ throw new UnsupportedOperationException();
+ }
+ }
+ };
+
+ public SimpleRequestContext(Application app)
+ {
+ super(app);
+ }
+
+ @Override
+ public URLFactory getURLFactory()
+ {
+ return new URLFactory()
+ {
+ @Override
+ public <R, U extends PortalURL<R, U>> U newURL(ResourceType<R, U> resourceType, URLContext context) throws NullPointerException
+ {
+ ResourceType rt = resourceType;
+ if (rt == NodeURL.TYPE)
+ {
+ return resourceType.getURLType().cast(new NodeURL(context));
+ }
+ else
+ {
+ return null;
+ }
+ }
+ };
+ }
+
+ @Override
+ public <R, U extends PortalURL<R, U>> U newURL(ResourceType<R, U> resourceType, URLFactory urlFactory)
+ {
+ return urlFactory.newURL(resourceType, ctx);
+ }
+
+ @Override
+ public Orientation getOrientation()
+ {
+ return Orientation.LT;
+ }
+
+ @Override
+ public String getRequestParameter(String name)
+ {
+ return null;
+ }
+
+ @Override
+ public String[] getRequestParameterValues(String name)
+ {
+ return null;
+ }
+
+ @Override
+ public URLBuilder<?> getURLBuilder()
+ {
+ throw new NotYetImplemented();
+ }
+
+ @Override
+ public boolean useAjax()
+ {
+ return false;
+ }
+}
Modified: portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/portal/NavigationTestCase.java
===================================================================
--- portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/portal/NavigationTestCase.java 2011-08-16 07:43:36 UTC (rev 7145)
+++ portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/portal/NavigationTestCase.java 2011-08-16 08:57:17 UTC (rev 7146)
@@ -15,12 +15,15 @@
import org.exoplatform.portal.mop.navigation.Scope;
import org.exoplatform.portal.pom.config.POMSessionManager;
import org.exoplatform.portal.pom.data.ModelDataStorage;
+import org.exoplatform.web.application.RequestContext;
import org.gatein.api.GateIn;
import org.gatein.api.portal.Navigation;
import org.gatein.api.portal.Page;
import org.gatein.api.portal.Site;
import org.gatein.portal.api.impl.GateInImpl;
+import org.gatein.portal.api.impl.SimpleRequestContext;
+import java.net.URI;
import java.util.Iterator;
/** @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a> */
@@ -78,6 +81,9 @@
//
storage.create(new org.exoplatform.portal.config.model.Page("portal", "classic", "homepage").build());
+
+ //
+ RequestContext.setCurrentInstance(new SimpleRequestContext(null));
}
@Override
@@ -116,6 +122,7 @@
assertSame(site, homeNav.getSite());
assertEquals("home", homeNav.getName());
assertSame(homeNav, rootNav.getChild("home"));
+ assertEquals(URI.create("/portal/classic/home"), homeNav.getURI());
assertFalse(i.hasNext());
}
Modified: portal/branches/api/component/web/controller/src/main/java/org/exoplatform/web/url/ResourceType.java
===================================================================
--- portal/branches/api/component/web/controller/src/main/java/org/exoplatform/web/url/ResourceType.java 2011-08-16 07:43:36 UTC (rev 7145)
+++ portal/branches/api/component/web/controller/src/main/java/org/exoplatform/web/url/ResourceType.java 2011-08-16 08:57:17 UTC (rev 7146)
@@ -29,4 +29,7 @@
*/
public abstract class ResourceType<R, U extends PortalURL<R, U>>
{
+
+ public abstract Class<U> getURLType();
+
}
Modified: portal/branches/api/component/web/controller/src/main/java/org/exoplatform/web/url/navigation/NodeURL.java
===================================================================
--- portal/branches/api/component/web/controller/src/main/java/org/exoplatform/web/url/navigation/NodeURL.java 2011-08-16 07:43:36 UTC (rev 7145)
+++ portal/branches/api/component/web/controller/src/main/java/org/exoplatform/web/url/navigation/NodeURL.java 2011-08-16 08:57:17 UTC (rev 7146)
@@ -47,7 +47,14 @@
public static final QualifiedName REQUEST_SITE_NAME = QualifiedName.create("gtn", "sitename");
/** . */
- public static final ResourceType<NavigationResource, NodeURL> TYPE = new ResourceType<NavigationResource, NodeURL>(){};
+ public static final ResourceType<NavigationResource, NodeURL> TYPE = new ResourceType<NavigationResource, NodeURL>()
+ {
+ @Override
+ public Class<NodeURL> getURLType()
+ {
+ return NodeURL.class;
+ }
+ };
/** . */
private static final Set<QualifiedName> PARAMETER_NAMES = new HashSet<QualifiedName>();
Modified: portal/branches/api/examples/portlets/api/src/main/java/org/gatein/portal/samples/api/NavigationPortlet.java
===================================================================
--- portal/branches/api/examples/portlets/api/src/main/java/org/gatein/portal/samples/api/NavigationPortlet.java 2011-08-16 07:43:36 UTC (rev 7145)
+++ portal/branches/api/examples/portlets/api/src/main/java/org/gatein/portal/samples/api/NavigationPortlet.java 2011-08-16 08:57:17 UTC (rev 7146)
@@ -23,7 +23,6 @@
package org.gatein.portal.samples.api;
import org.gatein.api.GateIn;
-import org.gatein.api.id.Id;
import org.gatein.api.portal.Navigation;
import org.gatein.api.portal.Site;
import org.gatein.api.util.IterableIdentifiableCollection;
@@ -35,6 +34,7 @@
import javax.portlet.RenderResponse;
import java.io.IOException;
import java.io.PrintWriter;
+import java.util.Collection;
/** @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a> */
public class NavigationPortlet extends GenericPortlet
@@ -75,7 +75,7 @@
{
Navigation navigation = site.getNavigation();
- IterableIdentifiableCollection<Navigation> adminNodes = navigation.getAll();
+ Collection<? extends Navigation> adminNodes = navigation.getChildren();
writer.println("<h2>" + site.getDisplayName() + "</h2>");
writer.println("<ul>");
@@ -90,7 +90,7 @@
private void outputNode(Navigation node, PrintWriter writer)
{
- IterableIdentifiableCollection<Navigation> children = node.getAll();
+ Collection<? extends Navigation> children = node.getChildren();
int size = children.size();
boolean isLeaf = size == 0;
writer.println("<li>"
Modified: portal/branches/api/webui/framework/src/main/java/org/exoplatform/webui/url/ComponentURL.java
===================================================================
--- portal/branches/api/webui/framework/src/main/java/org/exoplatform/webui/url/ComponentURL.java 2011-08-16 07:43:36 UTC (rev 7145)
+++ portal/branches/api/webui/framework/src/main/java/org/exoplatform/webui/url/ComponentURL.java 2011-08-16 08:57:17 UTC (rev 7146)
@@ -37,7 +37,14 @@
{
/** . */
- public static final ResourceType<UIComponent, ComponentURL> TYPE = new ResourceType<UIComponent, ComponentURL>() {};
+ public static final ResourceType<UIComponent, ComponentURL> TYPE = new ResourceType<UIComponent, ComponentURL>()
+ {
+ @Override
+ public Class<ComponentURL> getURLType()
+ {
+ return ComponentURL.class;
+ }
+ };
/** . */
public static final QualifiedName COMPONENT = QualifiedName.create("gtn", "componentid");
13 years, 4 months
gatein SVN: r7145 - in portal/branches/api/component/api-impl/src: test/java/org/gatein/portal/api/impl/portal and 1 other directory.
by do-not-reply@jboss.org
Author: julien_viet
Date: 2011-08-16 03:43:36 -0400 (Tue, 16 Aug 2011)
New Revision: 7145
Modified:
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/NavigationImpl.java
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/PageImpl.java
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/SiteImpl.java
portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/portal/NavigationTestCase.java
Log:
more work
Modified: portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/NavigationImpl.java
===================================================================
--- portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/NavigationImpl.java 2011-08-16 07:29:10 UTC (rev 7144)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/NavigationImpl.java 2011-08-16 07:43:36 UTC (rev 7145)
@@ -146,7 +146,7 @@
String pageRef = context.getState().getPageRef();
if (pageRef != null)
{
- return site.pageRegistry.getPageByRef(pageRef);
+ return site.pages.getPageByRef(pageRef);
}
else
{
Modified: portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/PageImpl.java
===================================================================
--- portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/PageImpl.java 2011-08-16 07:29:10 UTC (rev 7144)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/PageImpl.java 2011-08-16 07:43:36 UTC (rev 7145)
@@ -29,8 +29,6 @@
import org.gatein.portal.api.impl.GateInImpl;
import org.gatein.portal.api.impl.IdentifiableImpl;
-import java.util.Collection;
-
/** @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a> */
public class PageImpl extends IdentifiableImpl<Page, Page.Id> implements Page
{
Modified: portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/SiteImpl.java
===================================================================
--- portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/SiteImpl.java 2011-08-16 07:29:10 UTC (rev 7144)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/SiteImpl.java 2011-08-16 07:43:36 UTC (rev 7145)
@@ -35,19 +35,15 @@
import org.gatein.api.portal.Navigation;
import org.gatein.api.portal.Page;
import org.gatein.api.portal.Site;
-import org.gatein.api.util.HierarchicalContainer;
-import org.gatein.api.util.IterableIdentifiableCollection;
import org.gatein.api.util.Type;
import org.gatein.common.NotYetImplemented;
import org.gatein.portal.api.impl.GateInImpl;
import org.gatein.portal.api.impl.IdentifiableImpl;
-import org.gatein.portal.api.impl.util.AdaptedIterableIdentifiableCollection;
import org.gatein.portal.api.impl.util.GateInTypesResolver;
import java.lang.reflect.UndeclaredThrowableException;
import java.util.Collections;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -57,12 +53,20 @@
{
/** . */
- final PageContainer pageRegistry;
+ private static final Map<PageKey, PageImpl> EMPTY_CACHE = Collections.emptyMap();
+ /** . */
+ private static final Pattern PAGE_REF_PATTERN = Pattern.compile("^([^:]+)::([^:]+)::([^:]+)$");
+
+ /** . */
+ final PageContainer pages;
+
public SiteImpl(Site.Id siteId, String name, GateInImpl gateIn)
{
super(siteId, name, gateIn);
- pageRegistry = new PageContainer(gateIn, this);
+
+ //
+ this.pages = new PageContainer();
}
@Override
@@ -76,11 +80,6 @@
return GateInTypesResolver.forName(key.getType(), Site.class);
}
- public HierarchicalContainer<String, Page> getPageRegistry()
- {
- return pageRegistry;
- }
-
public Navigation getNavigation()
{
GateInImpl gateIn = getGateInImpl();
@@ -134,35 +133,26 @@
protected abstract SiteKey getSiteKey();
- static class PageContainer implements HierarchicalContainer<String, Page>
+ public Page getPage(String pageName)
{
+ return pages.getPageByName(pageName);
+ }
- /** . */
- private static final Map<PageKey, PageImpl> EMPTY_CACHE = Collections.emptyMap();
+ class PageContainer
+ {
- private final GateInImpl gateIn;
- private final SiteImpl site;
+ /** . */
private final Query<PageData> pageDataQuery;
/** A local cache so we return the same pages. */
private Map<PageKey, PageImpl> cache;
- PageContainer(GateInImpl gateIn, SiteImpl site)
+ private PageContainer()
{
- this.gateIn = gateIn;
- this.site = site;
- this.pageDataQuery = new Query<PageData>(site.getType().getName(), null, PageData.class);
+ this.pageDataQuery = new Query<PageData>(getType().getName(), null, PageData.class);
this.cache = EMPTY_CACHE;
}
- public boolean contains(String key)
- {
- return getPageByName(key) != null;
- }
-
- /** . */
- private static final Pattern PAGE_REF_PATTERN = Pattern.compile("^([^:]+)::([^:]+)::([^:]+)$");
-
PageImpl getPageByRef(String pageRef)
{
Matcher m = PAGE_REF_PATTERN.matcher(pageRef);
@@ -173,7 +163,7 @@
PageImpl getPageByName(String name)
{
- SiteKey siteKey = site.getSiteKey();
+ SiteKey siteKey = getSiteKey();
PageKey key = new PageKey(siteKey.getTypeName(), siteKey.getName(), name);
return getPageData(key);
}
@@ -189,7 +179,7 @@
PageData data = gateIn.getDataStorage().getPage(key);
if (data != null)
{
- page = new PageImpl(data, site.getId(), gateIn);
+ page = new PageImpl(data, getId(), gateIn);
if (cache == EMPTY_CACHE)
{
cache = new HashMap<PageKey, PageImpl>();
@@ -208,76 +198,5 @@
}
return page;
}
-
- public Page createAndAdd(String key)
- {
- throw new NotYetImplemented(); // todo
- }
-
- public Page get(String key)
- {
- return getPageByName(key);
- }
-
- public org.gatein.api.id.Id<Page> getIdForChild(String key)
- {
- return site.getId().getIdForChild(key);
- }
-
- public Page createAndAdd(org.gatein.api.id.Id<Page> id)
- {
- return createAndAdd(id.toString());
- }
-
- public IterableIdentifiableCollection<Page> getAll()
- {
- final List<PageData> pageList = getAllPageData();
- return new AdaptedIterableIdentifiableCollection<PageData, Page>(pageList.size(), pageList.iterator())
- {
- public Page adapt(PageData old)
- {
- return new PageImpl(old, site.getId(), gateIn);
- }
-
- public boolean contains(org.gatein.api.id.Id<Page> t)
- {
- return getPageByName(t.toString()) != null;
- }
- };
- }
-
- private List<PageData> getAllPageData()
- {
- try
- {
- gateIn.begin();
-
- return gateIn.getDataStorage().find(pageDataQuery).getAll();
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- finally
- {
- gateIn.end();
- }
- }
-
- public int size()
- {
- // todo: optimize
- return getAllPageData().size();
- }
-
- public Page get(org.gatein.api.id.Id<Page> id)
- {
- return get(id.toString());
- }
-
- public boolean contains(org.gatein.api.id.Id<Page> id)
- {
- return contains(id.toString());
- }
}
}
Modified: portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/portal/NavigationTestCase.java
===================================================================
--- portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/portal/NavigationTestCase.java 2011-08-16 07:29:10 UTC (rev 7144)
+++ portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/portal/NavigationTestCase.java 2011-08-16 07:43:36 UTC (rev 7145)
@@ -19,7 +19,6 @@
import org.gatein.api.portal.Navigation;
import org.gatein.api.portal.Page;
import org.gatein.api.portal.Site;
-import org.gatein.api.util.HierarchicalContainer;
import org.gatein.portal.api.impl.GateInImpl;
import java.util.Iterator;
@@ -127,8 +126,7 @@
//
Site site = gatein.getPortal(new Site.Id(Site.PORTAL, "classic"));
- HierarchicalContainer<String,Page> pages = site.getPageRegistry();
- Page homePage = pages.get("homepage");
+ Page homePage = site.getPage("homepage");
assertNotNull(homePage);
//
13 years, 4 months
gatein SVN: r7144 - portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal.
by do-not-reply@jboss.org
Author: julien_viet
Date: 2011-08-16 03:29:10 -0400 (Tue, 16 Aug 2011)
New Revision: 7144
Modified:
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/PageImpl.java
Log:
more work
Modified: portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/PageImpl.java
===================================================================
--- portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/PageImpl.java 2011-08-16 07:08:43 UTC (rev 7143)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/PageImpl.java 2011-08-16 07:29:10 UTC (rev 7144)
@@ -24,15 +24,13 @@
import org.exoplatform.portal.pom.data.ModelDataStorage;
import org.exoplatform.portal.pom.data.PageData;
-import org.gatein.api.id.Id;
-import org.gatein.api.portal.Navigation;
import org.gatein.api.portal.Page;
import org.gatein.api.portal.Site;
-import org.gatein.api.util.IterableIdentifiableCollection;
-import org.gatein.common.NotYetImplemented;
import org.gatein.portal.api.impl.GateInImpl;
import org.gatein.portal.api.impl.IdentifiableImpl;
+import java.util.Collection;
+
/** @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a> */
public class PageImpl extends IdentifiableImpl<Page, Page.Id> implements Page
{
@@ -92,14 +90,4 @@
}
-
- public IterableIdentifiableCollection<Navigation> getInboundNavigations()
- {
- throw new NotYetImplemented(); // todo
- }
-
- public Navigation createInboundNavigationIn(Site site, Navigation parent)
- {
- throw new NotYetImplemented(); // todo
- }
}
13 years, 4 months
gatein SVN: r7143 - in portal/branches/api/component/api-impl/src: test/java/org/gatein/portal/api/impl/portal and 1 other directory.
by do-not-reply@jboss.org
Author: julien_viet
Date: 2011-08-16 03:08:43 -0400 (Tue, 16 Aug 2011)
New Revision: 7143
Modified:
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/NavigationImpl.java
portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/portal/NavigationTestCase.java
Log:
more work about API
Modified: portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/NavigationImpl.java
===================================================================
--- portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/NavigationImpl.java 2011-08-16 06:45:32 UTC (rev 7142)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/NavigationImpl.java 2011-08-16 07:08:43 UTC (rev 7143)
@@ -37,25 +37,22 @@
import org.exoplatform.web.url.navigation.NavigationResource;
import org.exoplatform.web.url.navigation.NodeURL;
import org.gatein.api.GateIn;
-import org.gatein.api.id.Identifiable;
import org.gatein.api.portal.Navigation;
import org.gatein.api.portal.Page;
import org.gatein.api.portal.Site;
-import org.gatein.api.util.IterableIdentifiableCollection;
-import org.gatein.common.NotYetImplemented;
import org.gatein.common.text.EntityEncoder;
import org.gatein.common.util.EmptyResourceBundle;
import org.gatein.portal.api.impl.GateInImpl;
-import org.gatein.portal.api.impl.util.AdaptedIterableIdentifiableCollection;
import java.net.URI;
import java.net.URISyntaxException;
+import java.util.Collection;
import java.util.Iterator;
import java.util.Locale;
import java.util.ResourceBundle;
/** @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a> */
-public class NavigationImpl implements Navigation, Identifiable<Navigation>
+public class NavigationImpl implements Navigation
{
private final NodeContext<NavigationImpl> context;
private SiteImpl site;
@@ -83,7 +80,7 @@
s.append("-target->").append(pageRef);
}
- if (size() != 0)
+ if (context.getNodeCount() != 0)
{
loadChildrenIfNeeded();
s.append("\n|");
@@ -98,11 +95,6 @@
return s.toString();
}
- public NodeContext<NavigationImpl> getContext()
- {
- return context;
- }
-
public URI getURI()
{
if (uri != null)
@@ -131,7 +123,6 @@
}
}
-
private StringBuilder buildURI()
{
NavigationImpl parent = context.getParentNode();
@@ -150,7 +141,6 @@
}
}
-
public Page getTargetPage()
{
String pageRef = context.getState().getPageRef();
@@ -195,22 +185,10 @@
return site;
}
- public IterableIdentifiableCollection<Navigation> getAll()
+ public Collection<? extends Navigation> getChildren()
{
loadChildrenIfNeeded();
-
- return new AdaptedIterableIdentifiableCollection<NavigationImpl, Navigation>(size(), context.iterator())
- {
- public Navigation adapt(NavigationImpl old)
- {
- return old;
- }
-
- public boolean contains(org.gatein.api.id.Id<Navigation> id)
- {
- return NavigationImpl.this.contains(id);
- }
- };
+ return context.getNodes();
}
private void loadChildrenIfNeeded()
@@ -230,64 +208,19 @@
}
}
- public int size()
+ public Navigation getChild(String name)
{
- return context.getNodeSize();
- }
-
- public boolean contains(String key)
- {
- return contains(getIdForChild(key));
- }
-
- public boolean contains(org.gatein.api.id.Id<Navigation> navigationId)
- {
- loadChildrenIfNeeded();
-
- return getChild(navigationId) != null;
- }
-
- private NodeContext<NavigationImpl> getChild(org.gatein.api.id.Id<Navigation> navigationId)
- {
-// return context.get(navigationId.getComponent(GateInImpl.NAVIGATION_COMPONENT));
- throw new UnsupportedOperationException();
- }
-
- public Navigation createAndAdd(String key)
- {
- return createAndAdd(getIdForChild(key));
- }
-
- public Navigation createAndAdd(org.gatein.api.id.Id<Navigation> navigationId)
- {
- throw new NotYetImplemented(); // TODO
- }
-
- public Navigation get(String key)
- {
- return context.getNode(key);
- }
-
- public Navigation get(org.gatein.api.id.Id<Navigation> navigationId)
- {
- if (navigationId == null)
+ if (name == null)
{
return null;
}
else
{
loadChildrenIfNeeded();
- final NodeContext<NavigationImpl> child = getChild(navigationId);
- return child != null ? child.getNode() : null;
+ return context.getNode(name);
}
}
- public Navigation.Id getIdForChild(String key)
- {
-// return site.getIdForChild(key);
- throw new UnsupportedOperationException();
- }
-
public Navigation.Id getId()
{
if (id == null)
@@ -344,7 +277,6 @@
return RequestContext.getCurrentInstance().getLocale();
}
-
public ResourceBundle getBundle()
{
if (bundle == null)
Modified: portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/portal/NavigationTestCase.java
===================================================================
--- portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/portal/NavigationTestCase.java 2011-08-16 06:45:32 UTC (rev 7142)
+++ portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/portal/NavigationTestCase.java 2011-08-16 07:08:43 UTC (rev 7143)
@@ -99,7 +99,7 @@
Navigation rootNav = site.getNavigation();
assertSame(site, rootNav.getSite());
assertNotNull(rootNav);
- Iterator<Navigation> i = rootNav.getAll().iterator();
+ Iterator<? extends Navigation> i = rootNav.getChildren().iterator();
assertFalse(i.hasNext());
}
@@ -111,18 +111,18 @@
//
Site site = gatein.getPortal(new Site.Id(Site.PORTAL, "classic"));
Navigation rootNav = site.getNavigation();
- Iterator<Navigation> i = rootNav.getAll().iterator();
+ Iterator<? extends Navigation> i = rootNav.getChildren().iterator();
assertTrue(i.hasNext());
Navigation homeNav = i.next();
assertSame(site, homeNav.getSite());
assertEquals("home", homeNav.getName());
- assertSame(homeNav, rootNav.get("home"));
+ assertSame(homeNav, rootNav.getChild("home"));
assertFalse(i.hasNext());
}
public void testPage()
{
- NodeContext home = root.add(null, "home");
+ root.add(null, "home");
navService.saveNode(root, null);
//
@@ -133,13 +133,13 @@
//
Navigation rootNav = site.getNavigation();
- Navigation homeNav = rootNav.get("home");
+ Navigation homeNav = rootNav.getChild("home");
assertNull(homeNav.getTargetPage());
homeNav.setTargetPage(homePage);
assertSame(homePage, homeNav.getTargetPage());
//
- homeNav.setTargetPage((Page)null);
+ homeNav.setTargetPage(null);
assertNull(null, homeNav.getTargetPage());
}
}
13 years, 4 months
gatein SVN: r7142 - in portal/branches/api/component/api-impl/src: test/java/org/gatein/portal/api/impl/portal and 1 other directory.
by do-not-reply@jboss.org
Author: julien_viet
Date: 2011-08-16 02:45:32 -0400 (Tue, 16 Aug 2011)
New Revision: 7142
Modified:
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/NavigationImpl.java
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/PageImpl.java
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/SiteImpl.java
portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/portal/NavigationTestCase.java
Log:
some more work on API
Modified: portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/NavigationImpl.java
===================================================================
--- portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/NavigationImpl.java 2011-08-16 03:03:02 UTC (rev 7141)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/NavigationImpl.java 2011-08-16 06:45:32 UTC (rev 7142)
@@ -31,7 +31,6 @@
import org.exoplatform.portal.mop.navigation.NavigationService;
import org.exoplatform.portal.mop.navigation.NodeContext;
import org.exoplatform.portal.mop.navigation.NodeModel;
-import org.exoplatform.portal.mop.navigation.NodeState;
import org.exoplatform.portal.mop.navigation.Scope;
import org.exoplatform.services.resources.ResourceBundleManager;
import org.exoplatform.web.application.RequestContext;
@@ -59,14 +58,14 @@
public class NavigationImpl implements Navigation, Identifiable<Navigation>
{
private final NodeContext<NavigationImpl> context;
- private Site site;
+ private SiteImpl site;
private Navigation.Id id;
private final GateInImpl gateIn;
private URI uri;
private String displayName;
private ResourceBundle bundle;
- public NavigationImpl(Site site, NodeContext<NavigationImpl> context, GateInImpl gateIn)
+ public NavigationImpl(SiteImpl site, NodeContext<NavigationImpl> context, GateInImpl gateIn)
{
this.context = context;
this.site = site;
@@ -157,8 +156,7 @@
String pageRef = context.getState().getPageRef();
if (pageRef != null)
{
- // return gateIn.get(gateIn.pageId(site.getId(), pageRef));
- throw new UnsupportedOperationException();
+ return site.pageRegistry.getPageByRef(pageRef);
}
else
{
@@ -168,10 +166,17 @@
public void setTargetPage(Page target)
{
- setTargetPage(target.getId());
+ if (target != null)
+ {
+ setTargetPageRef(target.getId());
+ }
+ else
+ {
+ setTargetPageRef(null);
+ }
}
- public void setTargetPage(Page.Id targetId)
+ public void setTargetPageRef(Page.Id targetId)
{
if (targetId != null)
{
@@ -368,12 +373,12 @@
static class NavigationNodeModel implements NodeModel<NavigationImpl>
{
- private final Site site;
+ private final SiteImpl site;
private final GateInImpl gateIn;
- NavigationNodeModel(Site siteId, GateInImpl gateIn)
+ NavigationNodeModel(SiteImpl site, GateInImpl gateIn)
{
- this.site = siteId;
+ this.site = site;
this.gateIn = gateIn;
}
Modified: portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/PageImpl.java
===================================================================
--- portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/PageImpl.java 2011-08-16 03:03:02 UTC (rev 7141)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/PageImpl.java 2011-08-16 06:45:32 UTC (rev 7142)
@@ -39,10 +39,10 @@
private final Site.Id site;
private PageData pageData;
- public PageImpl(PageData pageData, Site.Id parent, GateInImpl gateIn)
+ public PageImpl(PageData pageData, Site.Id site, GateInImpl gateIn)
{
- super(gateIn.pageId(parent, pageData.getName()), pageData.getName(), gateIn);
- this.site = parent;
+ super(gateIn.pageId(site, pageData.getName()), pageData.getName(), gateIn);
+ this.site = site;
this.pageData = pageData;
}
Modified: portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/SiteImpl.java
===================================================================
--- portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/SiteImpl.java 2011-08-16 03:03:02 UTC (rev 7141)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/SiteImpl.java 2011-08-16 06:45:32 UTC (rev 7142)
@@ -45,13 +45,20 @@
import org.gatein.portal.api.impl.util.GateInTypesResolver;
import java.lang.reflect.UndeclaredThrowableException;
+import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
/** @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a> */
public abstract class SiteImpl extends IdentifiableImpl<Site, Site.Id> implements Site
{
- private PageContainer pageRegistry;
+ /** . */
+ final PageContainer pageRegistry;
+
public SiteImpl(Site.Id siteId, String name, GateInImpl gateIn)
{
super(siteId, name, gateIn);
@@ -129,39 +136,77 @@
static class PageContainer implements HierarchicalContainer<String, Page>
{
+
+ /** . */
+ private static final Map<PageKey, PageImpl> EMPTY_CACHE = Collections.emptyMap();
+
private final GateInImpl gateIn;
private final SiteImpl site;
private final Query<PageData> pageDataQuery;
+ /** A local cache so we return the same pages. */
+ private Map<PageKey, PageImpl> cache;
+
PageContainer(GateInImpl gateIn, SiteImpl site)
{
this.gateIn = gateIn;
this.site = site;
- pageDataQuery = new Query<PageData>(site.getType().getName(), null, PageData.class);
+ this.pageDataQuery = new Query<PageData>(site.getType().getName(), null, PageData.class);
+ this.cache = EMPTY_CACHE;
}
public boolean contains(String key)
{
- return getPageData(key) != null;
+ return getPageByName(key) != null;
}
- private PageData getPageData(String key)
+ /** . */
+ private static final Pattern PAGE_REF_PATTERN = Pattern.compile("^([^:]+)::([^:]+)::([^:]+)$");
+
+ PageImpl getPageByRef(String pageRef)
{
- try
+ Matcher m = PAGE_REF_PATTERN.matcher(pageRef);
+ m.matches();
+ PageKey key = new PageKey(m.group(1), m.group(2), m.group(3));
+ return getPageData(key);
+ }
+
+ PageImpl getPageByName(String name)
+ {
+ SiteKey siteKey = site.getSiteKey();
+ PageKey key = new PageKey(siteKey.getTypeName(), siteKey.getName(), name);
+ return getPageData(key);
+ }
+
+ private PageImpl getPageData(PageKey key)
+ {
+ PageImpl page = cache.get(key);
+ if (page == null)
{
- gateIn.begin();
- SiteKey sk = site.getSiteKey();
- PageKey pk = new PageKey(sk.getTypeName(), sk.getName(), key);
- return gateIn.getDataStorage().getPage(pk);
+ try
+ {
+ gateIn.begin();
+ PageData data = gateIn.getDataStorage().getPage(key);
+ if (data != null)
+ {
+ page = new PageImpl(data, site.getId(), gateIn);
+ if (cache == EMPTY_CACHE)
+ {
+ cache = new HashMap<PageKey, PageImpl>();
+ }
+ cache.put(key, page);
+ }
+ }
+ catch (Exception e)
+ {
+ throw new UndeclaredThrowableException(e);
+ }
+ finally
+ {
+ gateIn.end();
+ }
}
- catch (Exception e)
- {
- throw new UndeclaredThrowableException(e);
- }
- finally
- {
- gateIn.end();
- }
+ return page;
}
public Page createAndAdd(String key)
@@ -171,8 +216,7 @@
public Page get(String key)
{
- final PageData pageData = getPageData(key);
- return pageData != null ? new PageImpl(pageData, site.getId(), gateIn) : null;
+ return getPageByName(key);
}
public org.gatein.api.id.Id<Page> getIdForChild(String key)
@@ -197,7 +241,7 @@
public boolean contains(org.gatein.api.id.Id<Page> t)
{
- return getPageData(t.toString()) != null;
+ return getPageByName(t.toString()) != null;
}
};
}
Modified: portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/portal/NavigationTestCase.java
===================================================================
--- portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/portal/NavigationTestCase.java 2011-08-16 03:03:02 UTC (rev 7141)
+++ portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/portal/NavigationTestCase.java 2011-08-16 06:45:32 UTC (rev 7142)
@@ -96,10 +96,10 @@
assertEquals("classic", id.getName());
//
- Navigation navigation = site.getNavigation();
- assertSame(site, navigation.getSite());
- assertNotNull(navigation);
- Iterator<Navigation> i = navigation.getAll().iterator();
+ Navigation rootNav = site.getNavigation();
+ assertSame(site, rootNav.getSite());
+ assertNotNull(rootNav);
+ Iterator<Navigation> i = rootNav.getAll().iterator();
assertFalse(i.hasNext());
}
@@ -110,19 +110,19 @@
//
Site site = gatein.getPortal(new Site.Id(Site.PORTAL, "classic"));
- Navigation navigation = site.getNavigation();
- Iterator<Navigation> i = navigation.getAll().iterator();
+ Navigation rootNav = site.getNavigation();
+ Iterator<Navigation> i = rootNav.getAll().iterator();
assertTrue(i.hasNext());
- Navigation home = i.next();
- assertSame(site, home.getSite());
- assertEquals("home", home.getName());
- assertSame(home, navigation.get("home"));
+ Navigation homeNav = i.next();
+ assertSame(site, homeNav.getSite());
+ assertEquals("home", homeNav.getName());
+ assertSame(homeNav, rootNav.get("home"));
assertFalse(i.hasNext());
}
public void testPage()
{
- root.add(null, "home");
+ NodeContext home = root.add(null, "home");
navService.saveNode(root, null);
//
@@ -132,9 +132,14 @@
assertNotNull(homePage);
//
- Navigation navigation = site.getNavigation();
- Navigation home = navigation.get("home");
- assertNull(home.getTargetPage());
- home.setTargetPage(homePage);
+ Navigation rootNav = site.getNavigation();
+ Navigation homeNav = rootNav.get("home");
+ assertNull(homeNav.getTargetPage());
+ homeNav.setTargetPage(homePage);
+ assertSame(homePage, homeNav.getTargetPage());
+
+ //
+ homeNav.setTargetPage((Page)null);
+ assertNull(null, homeNav.getTargetPage());
}
}
13 years, 4 months
gatein SVN: r7141 - portal/trunk/webui/core/src/main/java/org/exoplatform/webui/form.
by do-not-reply@jboss.org
Author: kien_nguyen
Date: 2011-08-15 23:03:02 -0400 (Mon, 15 Aug 2011)
New Revision: 7141
Modified:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/form/UIFormTextAreaInput.java
Log:
GTNPORTAL-1967 Gadget source is escaped in editor (related to groovy templates)
Modified: portal/trunk/webui/core/src/main/java/org/exoplatform/webui/form/UIFormTextAreaInput.java
===================================================================
--- portal/trunk/webui/core/src/main/java/org/exoplatform/webui/form/UIFormTextAreaInput.java 2011-08-15 22:06:37 UTC (rev 7140)
+++ portal/trunk/webui/core/src/main/java/org/exoplatform/webui/form/UIFormTextAreaInput.java 2011-08-16 03:03:02 UTC (rev 7141)
@@ -21,7 +21,6 @@
import org.exoplatform.webui.application.WebuiRequestContext;
import org.exoplatform.commons.serialization.api.annotations.Serialized;
-import org.gatein.common.text.EntityEncoder;
import java.io.Writer;
@@ -42,11 +41,6 @@
*/
private int columns = 30;
- /**
- * HTML Entity Encoder
- */
- private EntityEncoder entityEncoder = EntityEncoder.FULL;
-
public UIFormTextAreaInput()
{
}
@@ -78,7 +72,9 @@
w.append(" cols=\"").append(String.valueOf(columns)).append("\"");
w.write(">");
if (value != null)
- w.write(entityEncoder.encode(value));
+ //TODO: remove from other components and than encode here
+ //w.write(org.gatein.common.text.EntityEncoder.FULL.encode(value));
+ w.write(value);
w.write("</textarea>");
if (this.isMandatory())
w.write(" *");
13 years, 4 months
gatein SVN: r7140 - in portal/branches/api/component/api-impl/src: test/java/org/gatein/portal/api/impl/portal and 1 other directory.
by do-not-reply@jboss.org
Author: julien_viet
Date: 2011-08-15 18:06:37 -0400 (Mon, 15 Aug 2011)
New Revision: 7140
Modified:
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/NavigationImpl.java
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/SiteImpl.java
portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/portal/NavigationTestCase.java
Log:
more work on API
Modified: portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/NavigationImpl.java
===================================================================
--- portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/NavigationImpl.java 2011-08-15 21:29:37 UTC (rev 7139)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/NavigationImpl.java 2011-08-15 22:06:37 UTC (rev 7140)
@@ -157,7 +157,8 @@
String pageRef = context.getState().getPageRef();
if (pageRef != null)
{
- return gateIn.get(gateIn.pageId(site.getId(), pageRef));
+ // return gateIn.get(gateIn.pageId(site.getId(), pageRef));
+ throw new UnsupportedOperationException();
}
else
{
@@ -172,7 +173,16 @@
public void setTargetPage(Page.Id targetId)
{
- context.setState(new NodeState.Builder(context.getState()).pageRef(targetId.toString()).build());
+ if (targetId != null)
+ {
+ String ref = targetId.getSite().getType().getName() + "::" + targetId.getSite().getName() + "::" + targetId.getName();
+ context.setState(context.getState().builder().pageRef(ref).build());
+ }
+ else
+ {
+
+ context.setState(context.getState().builder().pageRef(null).build());
+ }
}
public Site getSite()
@@ -250,7 +260,7 @@
public Navigation get(String key)
{
- return get(getIdForChild(key));
+ return context.getNode(key);
}
public Navigation get(org.gatein.api.id.Id<Navigation> navigationId)
Modified: portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/SiteImpl.java
===================================================================
--- portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/SiteImpl.java 2011-08-15 21:29:37 UTC (rev 7139)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/SiteImpl.java 2011-08-15 22:06:37 UTC (rev 7140)
@@ -44,6 +44,7 @@
import org.gatein.portal.api.impl.util.AdaptedIterableIdentifiableCollection;
import org.gatein.portal.api.impl.util.GateInTypesResolver;
+import java.lang.reflect.UndeclaredThrowableException;
import java.util.List;
/** @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a> */
@@ -129,7 +130,7 @@
static class PageContainer implements HierarchicalContainer<String, Page>
{
private final GateInImpl gateIn;
- private final Site site;
+ private final SiteImpl site;
private final Query<PageData> pageDataQuery;
PageContainer(GateInImpl gateIn, SiteImpl site)
@@ -149,11 +150,13 @@
try
{
gateIn.begin();
- return gateIn.getDataStorage().getPage(PageKey.create(key));
+ SiteKey sk = site.getSiteKey();
+ PageKey pk = new PageKey(sk.getTypeName(), sk.getName(), key);
+ return gateIn.getDataStorage().getPage(pk);
}
catch (Exception e)
{
- return null;
+ throw new UndeclaredThrowableException(e);
}
finally
{
Modified: portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/portal/NavigationTestCase.java
===================================================================
--- portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/portal/NavigationTestCase.java 2011-08-15 21:29:37 UTC (rev 7139)
+++ portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/portal/NavigationTestCase.java 2011-08-15 22:06:37 UTC (rev 7140)
@@ -17,7 +17,9 @@
import org.exoplatform.portal.pom.data.ModelDataStorage;
import org.gatein.api.GateIn;
import org.gatein.api.portal.Navigation;
+import org.gatein.api.portal.Page;
import org.gatein.api.portal.Site;
+import org.gatein.api.util.HierarchicalContainer;
import org.gatein.portal.api.impl.GateInImpl;
import java.util.Iterator;
@@ -74,6 +76,9 @@
NavigationContext nav = new NavigationContext(SiteKey.portal("classic"), new NavigationState(0));
navService.saveNavigation(nav);
root = navService.loadNode(NodeModel.SELF_MODEL, nav, Scope.ALL, null);
+
+ //
+ storage.create(new org.exoplatform.portal.config.model.Page("portal", "classic", "homepage").build());
}
@Override
@@ -111,6 +116,25 @@
Navigation home = i.next();
assertSame(site, home.getSite());
assertEquals("home", home.getName());
+ assertSame(home, navigation.get("home"));
assertFalse(i.hasNext());
}
+
+ public void testPage()
+ {
+ root.add(null, "home");
+ navService.saveNode(root, null);
+
+ //
+ Site site = gatein.getPortal(new Site.Id(Site.PORTAL, "classic"));
+ HierarchicalContainer<String,Page> pages = site.getPageRegistry();
+ Page homePage = pages.get("homepage");
+ assertNotNull(homePage);
+
+ //
+ Navigation navigation = site.getNavigation();
+ Navigation home = navigation.get("home");
+ assertNull(home.getTargetPage());
+ home.setTargetPage(homePage);
+ }
}
13 years, 4 months
gatein SVN: r7139 - in portal/branches/api/component/api-impl/src: main/java/org/gatein/portal/api/impl/portal and 1 other directories.
by do-not-reply@jboss.org
Author: julien_viet
Date: 2011-08-15 17:29:37 -0400 (Mon, 15 Aug 2011)
New Revision: 7139
Modified:
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/IdentifiableImpl.java
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/NavigationImpl.java
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/SiteImpl.java
portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/portal/NavigationTestCase.java
Log:
some work on API
Modified: portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/IdentifiableImpl.java
===================================================================
--- portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/IdentifiableImpl.java 2011-08-15 20:55:43 UTC (rev 7138)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/IdentifiableImpl.java 2011-08-15 21:29:37 UTC (rev 7139)
@@ -29,10 +29,10 @@
/** @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a> */
public class IdentifiableImpl<T extends Identifiable<T>, I extends Id<T>> implements Identifiable<T>
{
- private final I id;
- private final String name;
- private final String displayName;
- private final GateInImpl gateIn;
+ protected final I id;
+ protected final String name;
+ protected final String displayName;
+ protected final GateInImpl gateIn;
public IdentifiableImpl(I id, String name, GateInImpl gateIn)
{
Modified: portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/NavigationImpl.java
===================================================================
--- portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/NavigationImpl.java 2011-08-15 20:55:43 UTC (rev 7138)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/NavigationImpl.java 2011-08-15 21:29:37 UTC (rev 7139)
@@ -59,17 +59,17 @@
public class NavigationImpl implements Navigation, Identifiable<Navigation>
{
private final NodeContext<NavigationImpl> context;
- private Site.Id site;
+ private Site site;
private Navigation.Id id;
private final GateInImpl gateIn;
private URI uri;
private String displayName;
private ResourceBundle bundle;
- public NavigationImpl(Site.Id siteId, NodeContext<NavigationImpl> context, GateInImpl gateIn)
+ public NavigationImpl(Site site, NodeContext<NavigationImpl> context, GateInImpl gateIn)
{
this.context = context;
- this.site = siteId;
+ this.site = site;
this.gateIn = gateIn;
}
@@ -115,8 +115,8 @@
try
{
RequestContext requestContext = RequestContext.getCurrentInstance();
- SiteType siteType = SiteType.valueOf(site.getComponents()[0].toUpperCase());
- String siteName = site.getComponents()[1];
+ SiteType siteType = SiteType.valueOf(site.getId().getComponents()[0].toUpperCase());
+ String siteName = site.getId().getComponents()[1];
NavigationResource navResource = new NavigationResource(siteType, siteName, buildURI().toString());
NodeURL nodeURL = requestContext.createURL(NodeURL.TYPE, navResource);
@@ -157,7 +157,7 @@
String pageRef = context.getState().getPageRef();
if (pageRef != null)
{
- return gateIn.get(gateIn.pageId(site, pageRef));
+ return gateIn.get(gateIn.pageId(site.getId(), pageRef));
}
else
{
@@ -177,7 +177,7 @@
public Site getSite()
{
- return getGateIn().get(site);
+ return site;
}
public IterableIdentifiableCollection<Navigation> getAll()
@@ -339,8 +339,8 @@
Locale locale = getUserLocale();
bundle = rbMgr.getNavigationResourceBundle(
locale.getLanguage(),
- site.getComponent(GateInImpl.SITE_TYPE_COMPONENT),
- site.getComponent(GateInImpl.SITE_NAME_COMPONENT));
+ site.getId().getComponent(GateInImpl.SITE_TYPE_COMPONENT),
+ site.getId().getComponent(GateInImpl.SITE_NAME_COMPONENT));
if (bundle == null)
{
@@ -358,12 +358,12 @@
static class NavigationNodeModel implements NodeModel<NavigationImpl>
{
- private final Site.Id siteId;
+ private final Site site;
private final GateInImpl gateIn;
- NavigationNodeModel(Site.Id siteId, GateInImpl gateIn)
+ NavigationNodeModel(Site siteId, GateInImpl gateIn)
{
- this.siteId = siteId;
+ this.site = siteId;
this.gateIn = gateIn;
}
@@ -374,7 +374,7 @@
public NavigationImpl create(NodeContext<NavigationImpl> context)
{
- return new NavigationImpl(siteId, context, gateIn);
+ return new NavigationImpl(site, context, gateIn);
}
}
}
Modified: portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/SiteImpl.java
===================================================================
--- portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/SiteImpl.java 2011-08-15 20:55:43 UTC (rev 7138)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/SiteImpl.java 2011-08-15 21:29:37 UTC (rev 7139)
@@ -85,7 +85,7 @@
if (navigation != null)
{
- NodeModel<NavigationImpl> nodeModel = new NavigationImpl.NavigationNodeModel(getId(), gateIn);
+ NodeModel<NavigationImpl> nodeModel = new NavigationImpl.NavigationNodeModel(this, gateIn);
return service.loadNode(nodeModel, navigation, Scope.CHILDREN, null).getNode();
}
Modified: portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/portal/NavigationTestCase.java
===================================================================
--- portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/portal/NavigationTestCase.java 2011-08-15 20:55:43 UTC (rev 7138)
+++ portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/portal/NavigationTestCase.java 2011-08-15 21:29:37 UTC (rev 7139)
@@ -92,6 +92,7 @@
//
Navigation navigation = site.getNavigation();
+ assertSame(site, navigation.getSite());
assertNotNull(navigation);
Iterator<Navigation> i = navigation.getAll().iterator();
assertFalse(i.hasNext());
@@ -104,17 +105,11 @@
//
Site site = gatein.getPortal(new Site.Id(Site.PORTAL, "classic"));
- assertNotNull(site);
- Site.Id id = site.getId();
- assertEquals(Site.PORTAL, id.getType());
- assertEquals("classic", id.getName());
-
- //
Navigation navigation = site.getNavigation();
- assertNotNull(navigation);
Iterator<Navigation> i = navigation.getAll().iterator();
assertTrue(i.hasNext());
Navigation home = i.next();
+ assertSame(site, home.getSite());
assertEquals("home", home.getName());
assertFalse(i.hasNext());
}
13 years, 4 months