Author: chris.laprun(a)jboss.com
Date: 2011-08-09 04:10:17 -0400 (Tue, 09 Aug 2011)
New Revision: 7018
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/NavigationImpl.java
Log:
- Added originating site component to Navigation ids to make it easier to resolve, though
it's still not enough at the moment.
- Added Category, ManagedContent and Navigation to GateIn.get(Id). Resolving Navigation
doesn't work at the moment.
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-09
08:05:23 UTC (rev 7017)
+++
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/GateInImpl.java 2011-08-09
08:10:17 UTC (rev 7018)
@@ -63,6 +63,7 @@
import org.gatein.api.id.GenericContext;
import org.gatein.api.id.Id;
import org.gatein.api.id.Identifiable;
+import org.gatein.api.portal.Navigation;
import org.gatein.api.portal.Page;
import org.gatein.api.portal.Portal;
import org.gatein.api.portal.Site;
@@ -119,17 +120,28 @@
.requiredComponent(SITE_NAME_COMPONENT, Site.class, Pattern.compile("(" +
GROUP_CHARS + "|\\/)+"))
.optionalComponent("page", Page.class,
Pattern.compile("\\w+"))
.withDefaultSeparator("::").build();
- public static final Context GROUP_CONTEXT =
GenericContext.builder().named("Group").requiredUnboundedHierarchicalComponent("group",
Identifiable.class, Pattern.compile("(" + GROUP_CHARS + ")+"))
+ public static final Context GROUP_CONTEXT =
GenericContext.builder().named("Group")
+ .requiredUnboundedHierarchicalComponent("group", Identifiable.class,
Pattern.compile("(" + GROUP_CHARS + ")+"))
.withDefaultSeparator("/").requireSeparatorInFirstPosition().build();
- private static final Context GADGET_CONTEXT =
GenericContext.builder().named("Gadget").requiredComponent("name",
Gadget.class, Pattern.compile("\\w+")).build();
- private static final Context USER_CONTEXT =
GenericContext.builder().named("User").requiredComponent("name",
Identifiable.class, Pattern.compile("[a-zA-Z0-9]+")).build();
- private static final Context CATEGORY_CONTEXT =
GenericContext.builder().named("Category").requiredComponent("name",
Category.class, Pattern.compile("\\w+")).build();
+ private static final Context GADGET_CONTEXT =
GenericContext.builder().named("Gadget")
+ .requiredComponent("name", Gadget.class,
Pattern.compile("\\w+")).build();
+ private static final Context USER_CONTEXT =
GenericContext.builder().named("User")
+ .requiredComponent("name", Identifiable.class,
Pattern.compile("[a-zA-Z0-9]+")).build();
+ private static final Context CATEGORY_CONTEXT =
GenericContext.builder().named("Category")
+ .requiredComponent("name", Category.class,
Pattern.compile("\\w+")).build();
public static final Context MANAGED_CONTENT_CONTEXT =
GenericContext.builder().named("ManagedContent")
.requiredComponent(CATEGORY_COMPONENT, Category.class,
Pattern.compile("\\w+"))
.requiredComponent("name", ManagedContent.class,
Pattern.compile("(" + GROUP_CHARS + "|\\.)+"))
.requiredComponent("content", Content.class,
Pattern.compile(".+"))
.withDefaultSeparator(":")
.build();
+ public static final String NAVIGATION_COMPONENT = "navigation";
+ public static final String NAVIGATION_SITE_COMPONENT = "site id";
+ public final static Context NAVIGATION_CONTEXT =
GenericContext.builder().named("Navigation")
+ .requiredComponent(NAVIGATION_SITE_COMPONENT, Site.class,
Pattern.compile("(" + GROUP_CHARS + "|::|\\/)+"))
+ .requiredComponent(NAVIGATION_COMPONENT, Navigation.class,
Pattern.compile("[a-z0-9]+"))
+ .withDefaultSeparator("@")
+ .build();
private ExoContainer container;
private ModelDataStorage dataStorage;
@@ -510,6 +522,31 @@
}
}
}
+ else if (Category.class.equals(type))
+ {
+ final IterableIdentifiableCollection<Portal> portals = getPortals();
+ for (Portal portal : portals)
+ {
+ result = portal.getContentRegistry().getCategory(id.toString());
+ if (result != null)
+ {
+ break;
+ }
+ }
+ }
+ 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"));
+ }
+ else if (Navigation.class.equals(type))
+ {
+ final String siteStringId = id.getComponent(NAVIGATION_SITE_COMPONENT);
+ final Id<Site> siteId = SITE_CONTEXT.parse(siteStringId, Site.class);
+ final Site site = getSite(siteId, null);
+ result = site.getNavigation().get(id.toString()); //todo: this probably
doesn't work correctly
+ }
else
{
// todo: finish support of other types
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-09
08:05:23 UTC (rev 7017)
+++
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/NavigationImpl.java 2011-08-09
08:10:17 UTC (rev 7018)
@@ -36,8 +36,6 @@
import org.exoplatform.portal.webui.util.Util;
import org.exoplatform.services.resources.ResourceBundleManager;
import org.gatein.api.GateIn;
-import org.gatein.api.id.Context;
-import org.gatein.api.id.GenericContext;
import org.gatein.api.id.Id;
import org.gatein.api.id.Identifiable;
import org.gatein.api.portal.Navigation;
@@ -56,7 +54,6 @@
import java.util.Iterator;
import java.util.Locale;
import java.util.ResourceBundle;
-import java.util.regex.Pattern;
/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
public class NavigationImpl implements Navigation, Identifiable<Navigation>
@@ -69,8 +66,6 @@
private String displayName;
private ResourceBundle bundle;
- private final static Context NAVIGATION_CONTEXT =
GenericContext.builder().named("Navigation").requiredComponent("navigation",
Navigation.class, Pattern.compile("[a-z0-9]+")).build();
-
public NavigationImpl(Id<Site> siteId, NodeContext<NavigationImpl>
context, GateInImpl gateIn)
{
this.context = context;
@@ -266,7 +261,7 @@
{
if (id == null)
{
- id = NAVIGATION_CONTEXT.create(Navigation.class, context.getId());
+ id = GateInImpl.NAVIGATION_CONTEXT.create(Navigation.class, site.toString(),
context.getId());
}
return id;