Author: chris.laprun(a)jboss.com
Date: 2011-08-09 14:48:56 -0400 (Tue, 09 Aug 2011)
New Revision: 7032
Added:
portal/trunk/component/api-impl/
portal/trunk/component/api-impl/pom.xml
portal/trunk/component/api-impl/src/
portal/trunk/component/api-impl/src/main/
portal/trunk/component/api-impl/src/main/java/
portal/trunk/component/api-impl/src/main/java/org/
portal/trunk/component/api-impl/src/main/java/org/gatein/
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/GateInImpl.java
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/IdentifiableImpl.java
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/LifecycleManager.java
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/AbstractPortlet.java
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/CategoryImpl.java
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ContentRegistryImpl.java
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/GadgetImpl.java
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ManagedContentImpl.java
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/PortletImpl.java
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/WSRPImpl.java
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/id/
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/id/ComplexApplicationContext.java
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/id/ComplexApplicationId.java
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/lifecycle/
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/lifecycle/NoOpLifecycleManager.java
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/lifecycle/RequestLifecycleManager.java
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/DashboardSiteImpl.java
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/GroupSiteImpl.java
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/NavigationImpl.java
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/PageImpl.java
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/PortalImpl.java
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/SiteImpl.java
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/util/
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/util/AdaptedIterableCollection.java
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/util/AdaptedIterableIdentifiableCollection.java
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/util/AdaptedIterator.java
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/util/Adaptor.java
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/util/AggregatedIterableIdentifiableCollection.java
portal/trunk/component/api-impl/src/test/
portal/trunk/component/api-impl/src/test/java/
portal/trunk/component/api-impl/src/test/java/org/
portal/trunk/component/api-impl/src/test/java/org/gatein/
portal/trunk/component/api-impl/src/test/java/org/gatein/portal/
portal/trunk/component/api-impl/src/test/java/org/gatein/portal/api/
portal/trunk/component/api-impl/src/test/java/org/gatein/portal/api/impl/
portal/trunk/component/api-impl/src/test/java/org/gatein/portal/api/impl/id/
portal/trunk/component/api-impl/src/test/java/org/gatein/portal/api/impl/id/ComplexApplicationContextTestCase.java
portal/trunk/component/api-impl/src/test/java/org/gatein/portal/api/impl/portal/
portal/trunk/component/api-impl/src/test/java/org/gatein/portal/api/impl/portal/SiteTestCase.java
portal/trunk/component/api-impl/src/test/java/org/gatein/portal/api/impl/util/
portal/trunk/component/api-impl/src/test/java/org/gatein/portal/api/impl/util/AggregatedIterableIdentifiableCollectionTestCase.java
portal/trunk/examples/portlets/api/src/main/java/org/gatein/portal/samples/api/ContentRegistryPortlet.java
portal/trunk/examples/portlets/api/src/main/java/org/gatein/portal/samples/api/NavigationPortlet.java
portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/api/
portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/api/api-configuration.xml
Removed:
portal/trunk/component/api-impl/pom.xml
portal/trunk/component/api-impl/src/
portal/trunk/component/api-impl/src/main/
portal/trunk/component/api-impl/src/main/java/
portal/trunk/component/api-impl/src/main/java/org/
portal/trunk/component/api-impl/src/main/java/org/gatein/
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/GateInImpl.java
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/IdentifiableImpl.java
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/LifecycleManager.java
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/AbstractPortlet.java
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/CategoryImpl.java
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ContentRegistryImpl.java
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/GadgetImpl.java
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ManagedContentImpl.java
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/PortletImpl.java
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/WSRPImpl.java
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/id/
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/id/ComplexApplicationContext.java
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/id/ComplexApplicationId.java
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/lifecycle/
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/lifecycle/NoOpLifecycleManager.java
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/lifecycle/RequestLifecycleManager.java
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/DashboardSiteImpl.java
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/GroupSiteImpl.java
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/NavigationImpl.java
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/PageImpl.java
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/PortalImpl.java
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/SiteImpl.java
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/util/
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/util/AdaptedIterableCollection.java
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/util/AdaptedIterableIdentifiableCollection.java
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/util/AdaptedIterator.java
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/util/Adaptor.java
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/util/AggregatedIterableIdentifiableCollection.java
portal/trunk/component/api-impl/src/test/
portal/trunk/component/api-impl/src/test/java/
portal/trunk/component/api-impl/src/test/java/org/
portal/trunk/component/api-impl/src/test/java/org/gatein/
portal/trunk/component/api-impl/src/test/java/org/gatein/portal/
portal/trunk/component/api-impl/src/test/java/org/gatein/portal/api/
portal/trunk/component/api-impl/src/test/java/org/gatein/portal/api/impl/
portal/trunk/component/api-impl/src/test/java/org/gatein/portal/api/impl/id/
portal/trunk/component/api-impl/src/test/java/org/gatein/portal/api/impl/id/ComplexApplicationContextTestCase.java
portal/trunk/component/api-impl/src/test/java/org/gatein/portal/api/impl/portal/
portal/trunk/component/api-impl/src/test/java/org/gatein/portal/api/impl/portal/SiteTestCase.java
portal/trunk/component/api-impl/src/test/java/org/gatein/portal/api/impl/util/
portal/trunk/component/api-impl/src/test/java/org/gatein/portal/api/impl/util/AggregatedIterableIdentifiableCollectionTestCase.java
portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/api/api-configuration.xml
Modified:
portal/trunk/
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/ApplicationRegistryService.java
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/impl/ApplicationRegistryServiceImpl.java
portal/trunk/component/pc/pom.xml
portal/trunk/component/pc/src/main/java/org/exoplatform/portal/pc/ExoKernelIntegration.java
portal/trunk/component/pc/src/main/java/org/exoplatform/portal/pc/ExoPortletApplicationDeployer.java
portal/trunk/component/pom.xml
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/UserACL.java
portal/trunk/examples/portlets/api/pom.xml
portal/trunk/examples/portlets/api/src/main/webapp/WEB-INF/portlet.xml
portal/trunk/packaging/jboss-as5/pkg/pom.xml
portal/trunk/packaging/jboss-as6/pkg/pom.xml
portal/trunk/packaging/jetty/pkg/pom.xml
portal/trunk/packaging/tomcat/pkg/pom.xml
portal/trunk/pom.xml
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIAddApplicationForm.java
portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/configuration.xml
Log:
- JBEPP-814: Initial API implementation. Merged code from API branch (-r6848:7030).
Property changes on: portal/trunk
___________________________________________________________________
Modified: svn:mergeinfo
- /epp/portal/branches/EPP_5_1_Branch:6841
/portal/branches/branch-GTNPORTAL-1790:5864-5919
/portal/branches/branch-GTNPORTAL-1822:5938-5991
/portal/branches/branch-GTNPORTAL-1832:5993-6105
/portal/branches/branch-GTNPORTAL-1872:6327-6594
/portal/branches/branch-GTNPORTAL-1921:6597-6803
/portal/branches/branch-GTNPORTAL-1963:6902-6986
/portal/branches/decoupled-webos:6214-6243
/portal/branches/gatein-management:6920-6958
/portal/branches/global-portlet-metadata:6298-6384
/portal/branches/site-describability:6171-6235
/portal/branches/wsrp-extraction:5828-6031
+ /epp/portal/branches/EPP_5_1_Branch:6841
/portal/branches/api:6849-7030
/portal/branches/branch-GTNPORTAL-1790:5864-5919
/portal/branches/branch-GTNPORTAL-1822:5938-5991
/portal/branches/branch-GTNPORTAL-1832:5993-6105
/portal/branches/branch-GTNPORTAL-1872:6327-6594
/portal/branches/branch-GTNPORTAL-1921:6597-6803
/portal/branches/branch-GTNPORTAL-1963:6902-6986
/portal/branches/decoupled-webos:6214-6243
/portal/branches/gatein-management:6920-6958
/portal/branches/global-portlet-metadata:6298-6384
/portal/branches/site-describability:6171-6235
/portal/branches/wsrp-extraction:5828-6031
Property changes on: portal/trunk/component/api-impl
___________________________________________________________________
Added: svn:ignore
+ target
*.iml
.idea
Deleted: portal/trunk/component/api-impl/pom.xml
===================================================================
--- portal/branches/api/component/api-impl/pom.xml 2011-08-09 13:52:09 UTC (rev 7030)
+++ portal/trunk/component/api-impl/pom.xml 2011-08-09 18:48:56 UTC (rev 7032)
@@ -1,54 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project
xmlns="http://maven.apache.org/POM/4.0.0"
-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <parent>
- <artifactId>exo.portal.component</artifactId>
- <groupId>org.exoplatform.portal</groupId>
- <version>3.2.0-M02-SNAPSHOT</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
-
- <groupId>org.gatein.api</groupId>
- <artifactId>java-api-impl</artifactId>
-
- <dependencies>
- <dependency>
- <groupId>org.gatein.api</groupId>
- <artifactId>gatein-java-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.gatein.api</groupId>
- <artifactId>generic-id-impl</artifactId>
- </dependency>
- <dependency>
- <groupId>org.exoplatform.kernel</groupId>
- <artifactId>exo.kernel.container</artifactId>
- </dependency>
- <dependency>
- <groupId>org.exoplatform.portal</groupId>
- <artifactId>exo.portal.component.portal</artifactId>
- </dependency>
- <dependency>
- <groupId>org.exoplatform.portal</groupId>
- <artifactId>exo.portal.component.application-registry</artifactId>
- </dependency>
- <dependency>
- <groupId>org.testng</groupId>
- <artifactId>testng</artifactId>
- <version>5.14.10</version>
- <scope>test</scope>
- </dependency>
-
- <!-- To be able to access Util to generate Navigation URI -->
- <dependency>
- <groupId>org.exoplatform.portal</groupId>
- <artifactId>exo.portal.webui.portal</artifactId>
- </dependency>
- </dependencies>
-
- <build>
- <finalName>gatein-java-api-impl-${project.version}</finalName>
- </build>
-
-</project>
\ No newline at end of file
Copied: portal/trunk/component/api-impl/pom.xml (from rev 7030,
portal/branches/api/component/api-impl/pom.xml)
===================================================================
--- portal/trunk/component/api-impl/pom.xml (rev 0)
+++ portal/trunk/component/api-impl/pom.xml 2011-08-09 18:48:56 UTC (rev 7032)
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project
xmlns="http://maven.apache.org/POM/4.0.0"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <artifactId>exo.portal.component</artifactId>
+ <groupId>org.exoplatform.portal</groupId>
+ <version>3.2.0-M02-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.gatein.api</groupId>
+ <artifactId>java-api-impl</artifactId>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.gatein.api</groupId>
+ <artifactId>gatein-java-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.gatein.api</groupId>
+ <artifactId>generic-id-impl</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.kernel</groupId>
+ <artifactId>exo.kernel.container</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.portal</groupId>
+ <artifactId>exo.portal.component.portal</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.portal</groupId>
+ <artifactId>exo.portal.component.application-registry</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <version>5.14.10</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- To be able to access Util to generate Navigation URI -->
+ <dependency>
+ <groupId>org.exoplatform.portal</groupId>
+ <artifactId>exo.portal.webui.portal</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <finalName>gatein-java-api-impl-${project.version}</finalName>
+ </build>
+
+</project>
\ No newline at end of file
Deleted:
portal/trunk/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
13:52:09 UTC (rev 7030)
+++
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/GateInImpl.java 2011-08-09
18:48:56 UTC (rev 7032)
@@ -1,752 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* 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.gatein.portal.api.impl;
-
-import org.exoplatform.application.gadget.GadgetRegistryService;
-import org.exoplatform.application.gadget.SourceStorage;
-import org.exoplatform.application.registry.Application;
-import org.exoplatform.application.registry.ApplicationRegistryService;
-import org.exoplatform.container.ExoContainer;
-import org.exoplatform.container.ExoContainerContext;
-import org.exoplatform.container.configuration.ConfigurationManager;
-import org.exoplatform.container.xml.InitParams;
-import org.exoplatform.portal.config.Query;
-import org.exoplatform.portal.config.UserACL;
-import org.exoplatform.portal.config.UserPortalConfigService;
-import org.exoplatform.portal.config.model.ApplicationType;
-import org.exoplatform.portal.config.model.PortalConfig;
-import org.exoplatform.portal.mop.SiteType;
-import org.exoplatform.portal.mop.description.DescriptionService;
-import org.exoplatform.portal.mop.navigation.NavigationService;
-import org.exoplatform.portal.pc.ExoKernelIntegration;
-import org.exoplatform.portal.pom.data.ModelDataStorage;
-import org.exoplatform.portal.pom.data.PageData;
-import org.exoplatform.portal.pom.data.PageKey;
-import org.exoplatform.portal.pom.data.PortalData;
-import org.exoplatform.portal.pom.data.PortalKey;
-import org.exoplatform.services.organization.Group;
-import org.exoplatform.services.organization.GroupHandler;
-import org.exoplatform.services.organization.Membership;
-import org.exoplatform.services.organization.OrganizationService;
-import org.exoplatform.services.organization.User;
-import org.exoplatform.services.organization.UserHandler;
-import org.exoplatform.services.security.Identity;
-import org.exoplatform.services.security.MembershipEntry;
-import org.gatein.api.GateIn;
-import org.gatein.api.content.Category;
-import org.gatein.api.content.Content;
-import org.gatein.api.content.Gadget;
-import org.gatein.api.content.ManagedContent;
-import org.gatein.api.content.Portlet;
-import org.gatein.api.content.WSRP;
-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;
-import org.gatein.api.portal.Page;
-import org.gatein.api.portal.Portal;
-import org.gatein.api.portal.Site;
-import org.gatein.api.util.Filter;
-import org.gatein.api.util.IterableIdentifiableCollection;
-import org.gatein.api.util.Type;
-import org.gatein.common.util.ParameterValidation;
-import org.gatein.pc.federation.FederatingPortletInvoker;
-import org.gatein.portal.api.impl.id.ComplexApplicationContext;
-import org.gatein.portal.api.impl.id.ComplexApplicationId;
-import org.gatein.portal.api.impl.portal.DashboardSiteImpl;
-import org.gatein.portal.api.impl.portal.GroupSiteImpl;
-import org.gatein.portal.api.impl.portal.PageImpl;
-import org.gatein.portal.api.impl.portal.PortalImpl;
-import org.gatein.portal.api.impl.util.AdaptedIterableIdentifiableCollection;
-import org.gatein.portal.api.impl.util.AggregatedIterableIdentifiableCollection;
-import org.picocontainer.Startable;
-
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.regex.Pattern;
-
-/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
-public class GateInImpl implements GateIn, Startable, LifecycleManager
-{
- private static final Query<PortalData> PORTALS = new
Query<PortalData>(SiteType.PORTAL.getName(), null, PortalData.class);
-
- private static final String GROUP_CHARS = "\\w|-|_";
-
- public static final String SITE_TYPE_COMPONENT = "type";
- public static final String SITE_NAME_COMPONENT = "name";
- public static final String APPLICATION_COMPONENT = "application";
- public static final String PORTLET_COMPONENT = "portlet";
- public static final String INVOKER_COMPONENT = "invoker";
- public static final String CATEGORY_COMPONENT = "category";
-
- public static final Pattern INVOKER_COMPONENT_PATTERN =
Pattern.compile("\\w+");
-
- public static final Context LOCAL_PORTLET_CONTEXT =
GenericContext.builder().named("Local Portlet")
- .requiredComponent(APPLICATION_COMPONENT, Identifiable.class,
Pattern.compile("(" + GROUP_CHARS + "|\\.)+"))
- .requiredComponent(PORTLET_COMPONENT, Portlet.class,
Pattern.compile("\\w+"))
- .withDefaultSeparator("/").build();
- private static final Context WSRP_PORTLET_CONTEXT =
GenericContext.builder().named("WSRP Portlet")
- .requiredComponent(INVOKER_COMPONENT, Identifiable.class,
INVOKER_COMPONENT_PATTERN)
- .requiredComponent("portletcontext", WSRP.class,
Pattern.compile("(" + GROUP_CHARS + ")+"))
- .withDefaultSeparator(".").build();
-
- public static final Context SITE_CONTEXT =
GenericContext.builder().named("Site")
- .requiredComponent(SITE_TYPE_COMPONENT, Identifiable.class,
Pattern.compile(Site.PORTAL_TYPE_NAME + "|" + Site.GROUP_TYPE_NAME +
"|" + Site.DASHBOARD_TYPE_NAME))
- .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 + ")+"))
- .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();
- 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;
- private ApplicationRegistryService registryService;
- private GadgetRegistryService gadgetService;
- private SourceStorage sourceStorage;
- private UserPortalConfigService configService;
- private Map<Type, Object> properties = new HashMap<Type, Object>(7);
- private LifecycleManager lcManager = GateIn.NO_OP_MANAGER;
- private FederatingPortletInvoker portletInvoker;
-
- public GateInImpl(ExoContainerContext context, InitParams params, ConfigurationManager
configurationManager, ExoKernelIntegration exoKernelIntegration)
- {
- container = context.getContainer();
- }
-
- public static Id<? extends Content> getContentIdFrom(Application application)
- {
- ApplicationType type = application.getType();
- Class<Content> contentClass = getContentClassFor(type);
- if (Gadget.class.isAssignableFrom(contentClass))
- {
- return staticGadgetId(application.getContentId());
- }
- else if (WSRP.class.isAssignableFrom(contentClass))
- {
- return parseWSRPPortletId(application.getContentId());
- }
- else if (Portlet.class.isAssignableFrom(contentClass))
- {
- return parsePortletId(application.getContentId());
- }
- else
- {
- throw new IllegalArgumentException("Unknown application type: " +
type);
- }
- }
-
- public static <T extends Content> Class<T>
getContentClassFor(ApplicationType type)
- {
- if (ApplicationType.GADGET.equals(type))
- {
- return (Class<T>)Gadget.class;
- }
- else if (ApplicationType.PORTLET.equals(type))
- {
- return (Class<T>)Portlet.class;
- }
- else if (ApplicationType.WSRP_PORTLET.equals(type))
- {
- return (Class<T>)WSRP.class;
- }
- else
- {
- throw new IllegalArgumentException("Unknown ApplicationType: " +
type);
- }
- }
-
- public <T> T getProperty(Type<T> property)
- {
- if (property == null)
- {
- return null;
- }
-
- Class<T> type = property.getValueType();
- Object o = properties.get(property);
- return type.cast(o);
- }
-
- public <T> void setProperty(Type<T> property, T value)
- {
- if (property != null)
- {
- if (GateIn.LIFECYCLE_MANAGER.equals(property))
- {
- lcManager = GateIn.LIFECYCLE_MANAGER.getValueType().cast(value);
- }
- properties.put(property, value);
- }
- }
-
- public IterableIdentifiableCollection<Portal> getPortals()
- {
- try
- {
- begin();
- final List<PortalData> portals = dataStorage.find(PORTALS).getAll();
-
- return new AdaptedIterableIdentifiableCollection<PortalData,
Portal>(portals.size(), portals.iterator())
- {
- public Portal adapt(PortalData old)
- {
- return new PortalImpl(old, GateInImpl.this);
- }
-
- public boolean contains(Id<Portal> id)
- {
- return getPortalDataFor(id) != null;
- }
- };
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- finally
- {
- end();
- }
- }
-
- public Portal getPortal(Id<Portal> portalId)
- {
- PortalData portalData = getPortalDataFor(portalId);
- return new PortalImpl(portalData, this);
- }
-
- public Portal getDefaultPortal()
- {
- return getPortal(siteId(Site.PORTAL, "classic")); // todo: check
- }
-
- public IterableIdentifiableCollection<? extends Site> getSites()
- {
- IterableIdentifiableCollection<Site> groupSites = getGroupSites();
- IterableIdentifiableCollection<Portal> portals = getPortals();
- IterableIdentifiableCollection<Site> dashboards = getDashboards();
-
- AggregatedIterableIdentifiableCollection collection = new
AggregatedIterableIdentifiableCollection();
- collection.addCollection(groupSites);
- collection.addCollection(portals);
- collection.addCollection(dashboards);
-
- return collection;
- }
-
- private IterableIdentifiableCollection<Site> getDashboards()
- {
- try
- {
- begin();
- final UserHandler userHandler = getOrganizationService().getUserHandler();
-
- // todo: optimize
- List<User> users = userHandler.getUserPageList(1000).getAll();
-
- // todo: check for correctness
- return new AdaptedIterableIdentifiableCollection<User, Site>(users.size(),
users.iterator())
- {
-
- public Site adapt(User old)
- {
- return getDashboard(userId(old.getUserName()));
- }
-
- public boolean contains(Id<Site> t)
- {
- try
- {
- return dataStorage.loadDashboard(t.toString()) != null;
- }
- catch (Exception e)
- {
- return false;
- }
- }
- };
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- finally
- {
- end();
- }
- }
-
- public IterableIdentifiableCollection<Site> getGroupSites()
- {
- try
- {
- begin();
-
- final GroupHandler groupHandler = getOrganizationService().getGroupHandler();
- Collection groups = groupHandler.getAllGroups();
-
- return new AdaptedIterableIdentifiableCollection<Object,
Site>(groups.size(), groups.iterator())
- {
- public boolean contains(Id<Site> siteId)
- {
- try
- {
- return groupHandler.findGroupById(siteId.toString()) != null;
- }
- catch (Exception e)
- {
- return false;
- }
- }
-
- public Site adapt(Object old)
- {
- Group group = (Group)old;
- return getGroupSite(GROUP_CONTEXT.parse(group.getId()));
- }
- };
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- finally
- {
- end();
- }
- }
-
- public Site getGroupSite(Id groupId)
- {
- String groupName = groupId.toString();
- Id<Site> siteId = siteId(Site.GROUP, groupName);
-
- return new GroupSiteImpl(siteId, groupName, this);
- }
-
- public IterableIdentifiableCollection<Site> getGroupSites(Id userId)
- {
- final GroupHandler groupHandler = getOrganizationService().getGroupHandler();
- try
- {
- begin();
- final String id = userId.toString();
- Collection groups = groupHandler.findGroupsOfUser(id);
-
- return new AdaptedIterableIdentifiableCollection<Object,
Site>(groups.size(), groups.iterator())
- {
- public boolean contains(Id<Site> siteId)
- {
- try
- {
- Group group = groupHandler.findGroupById(siteId.toString());
- return group != null && !groupHandler.findGroupByMembership(id,
null).isEmpty();
- }
- catch (Exception e)
- {
- return false;
- }
- }
-
- public Site adapt(Object old)
- {
- Group group = (Group)old;
- return getGroupSite(GROUP_CONTEXT.parse(group.getId()));
- }
- };
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- finally
- {
- end();
- }
- }
-
- public IterableIdentifiableCollection<Portal> getPortalSites(Id userId)
- {
- try
- {
- begin();
- final List<PortalData> portalDatas = dataStorage.find(PORTALS).getAll();
-
- // first build Identity based on user id so that we can check its permissions
using UserACL... ugh! :(
- final String user = userId.toString();
- final Collection membershipsByUser =
getOrganizationService().getMembershipHandler().findMembershipsByUser(user);
- Collection<MembershipEntry> membershipEntries = new
ArrayList<MembershipEntry>(membershipsByUser.size());
- for (Object o : membershipsByUser)
- {
- Membership membership = (Membership)o;
- membershipEntries.add(new MembershipEntry(membership.getGroupId(),
membership.getMembershipType()));
- }
- final Identity identity = new Identity(user, membershipEntries);
-
- final List<Portal> portals = new
ArrayList<Portal>(portalDatas.size());
- final Filter<PortalData> filter = new Filter<PortalData>()
- {
- @Override
- public boolean accept(PortalData item)
- {
- return getUserACL().hasPermission(identity, new PortalConfig(item));
- }
- };
-
- for (PortalData portalData : portalDatas)
- {
- if (filter.accept(portalData))
- {
- portals.add(new PortalImpl(portalData, this));
- }
- }
-
- return new AdaptedIterableIdentifiableCollection<Portal,
Portal>(portals.size(), portals.iterator())
- {
- public Portal adapt(Portal old)
- {
- return old;
- }
-
- public boolean contains(Id<Portal> id)
- {
- final PortalData portalData = getPortalDataFor(id);
- return portalData != null && filter.accept(portalData);
- }
- };
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- finally
- {
- end();
- }
- }
-
- public Site getDashboard(Id userId)
- {
- String user = userId.toString();
- Id<Site> siteId = siteId(Site.DASHBOARD, user);
-
- return new DashboardSiteImpl(siteId, user, this);
- }
-
- public <T extends Identifiable> T get(Id<T> id)
- {
- Class<T> type = id.getIdentifiableType();
-
- Object result = null;
-
- if (Portal.class.equals(type))
- {
- result = getPortal((Id<Portal>)id);
- }
- else if (Page.class.equals(type))
- {
- try
- {
- begin();
- PageData pageData = dataStorage.getPage(PageKey.create(id.toString()));
- result = new PageImpl(pageData, id.getParent(), this);
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- finally
- {
- end();
- }
- }
- else if (Site.class.equals(type))
- {
- Id<Site> siteId = (Id<Site>)id;
- result = getSite(siteId, null);
- }
- else if (Content.class.isAssignableFrom(type))
- {
- // todo: split by types and optimize by calling portlet invoker or gadget
registry directly
- final IterableIdentifiableCollection<Portal> portals = getPortals();
- for (Portal portal : portals)
- {
- result = portal.getContentRegistry().get((Id<? extends Content>)id);
- if (result != null)
- {
- break;
- }
- }
- }
- else if (Category.class.equals(type))
- {
- // todo: optimize by adding portal id to category id (so that appropriate
content registry can be retrieved) and calling application registry directly
- 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);
- //todo: need to get all the parents of a Navigation to be able to load it so we
would need to add the complete path to the Id to be able to resolve Navigations properly
- result = site.getNavigation().get(id.getComponent(NAVIGATION_COMPONENT));
-
- throw new UnsupportedOperationException("Id<" +
type.getSimpleName() + "> not yet supported");
- }
- else
- {
- throw new UnsupportedOperationException("Id<" +
type.getSimpleName() + "> not yet supported");
- }
-
- return type.cast(result);
- }
-
- public <T extends Site> T getSite(Id<T> siteId, Type<T> type)
- {
- final String siteType = siteId.getComponent(SITE_TYPE_COMPONENT);
- ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(siteType, "Site
type", "A valid Site Id");
-
- if (Site.PORTAL.equals(siteType))
- {
- return (T)getPortal((Id<Portal>)siteId);
- }
- else if (Site.GROUP_TYPE_NAME.equals(siteType))
- {
- return (T)getGroupSite(groupId(siteId.getComponent(SITE_NAME_COMPONENT)));
- }
- else if (Site.DASHBOARD_TYPE_NAME.equals(siteType))
- {
- return (T)getDashboard(userId(siteId.getComponent(SITE_NAME_COMPONENT)));
- }
- else
- {
- throw new IllegalArgumentException("Unknown Site type: " + siteType);
- }
- }
-
- public Id userId(String user)
- {
- return USER_CONTEXT.create(user);
- }
-
- public Id groupId(String root, String... children)
- {
- return GROUP_CONTEXT.create(root, children);
- }
-
- public Id<Portlet> portletId(String application, String portlet)
- {
- return LOCAL_PORTLET_CONTEXT.create(Portlet.class, application, portlet);
- }
-
- public static Id<Portlet> parsePortletId(String contentId)
- {
- if (contentId.contains(ComplexApplicationId.START))
- {
- return ComplexApplicationContext.INSTANCE.parse(contentId, Portlet.class);
- }
- else
- {
- return LOCAL_PORTLET_CONTEXT.parse(contentId, Portlet.class);
- }
- }
-
- public Id<WSRP> wsrpPortletId(String invoker, String portlet)
- {
- return staticWSRPPortletId(invoker, portlet);
- }
-
- private static Id<WSRP> staticWSRPPortletId(String invoker, String portlet)
- {
- return WSRP_PORTLET_CONTEXT.create(WSRP.class, invoker, portlet);
- }
-
- public static Id<WSRP> parseWSRPPortletId(String compositeId)
- {
- return WSRP_PORTLET_CONTEXT.parse(compositeId, WSRP.class);
- }
-
- public Id<Gadget> gadgetId(String gadgetName)
- {
- return staticGadgetId(gadgetName);
- }
-
- private static Id<Gadget> staticGadgetId(String gadgetName)
- {
- return GADGET_CONTEXT.create(Gadget.class, gadgetName);
- }
-
- public Id<Gadget> gadgetId(URI uri)
- {
- return GADGET_CONTEXT.create(Gadget.class, uri.toString());
- }
-
- public <T extends Content> Id<ManagedContent>
managedContentId(Id<Category> categoryId, String name, Id<T> contentId)
- {
- return MANAGED_CONTENT_CONTEXT.create(ManagedContent.class, categoryId.toString(),
name, contentId.toString());
- }
-
- public Id<Category> categoryId(String name)
- {
- return CATEGORY_CONTEXT.create(Category.class, name);
- }
-
- public <T extends Site> Id<T> siteId(Type<T> siteType, String
siteName)
- {
- return SITE_CONTEXT.create(siteType.getValueType(), siteType.getName(), siteName);
- }
-
- public <T extends Site> Id<Page> pageId(Id<T> ownerSite, String
pageName)
- {
- ParameterValidation.throwIllegalArgExceptionIfNull(ownerSite, "Owner Site
Id");
- return ownerSite.getIdForChild(pageName);
- }
-
- public void start()
- {
- dataStorage =
(ModelDataStorage)container.getComponentInstanceOfType(ModelDataStorage.class);
- registryService =
(ApplicationRegistryService)container.getComponentInstanceOfType(ApplicationRegistryService.class);
- gadgetService =
(GadgetRegistryService)container.getComponentInstanceOfType(GadgetRegistryService.class);
- sourceStorage =
(SourceStorage)container.getComponentInstanceOfType(SourceStorage.class);
- configService =
(UserPortalConfigService)container.getComponentInstanceOfType(UserPortalConfigService.class);
- portletInvoker =
(FederatingPortletInvoker)container.getComponentInstanceOfType(FederatingPortletInvoker.class);
- }
-
- public void stop()
- {
- // nothing to do
- }
-
- public ModelDataStorage getDataStorage()
- {
- return dataStorage;
- }
-
- public NavigationService getNavigationService()
- {
- return configService.getNavigationService();
- }
-
- public ApplicationRegistryService getRegistryService()
- {
- return registryService;
- }
-
- public SourceStorage getSourceStorage()
- {
- return sourceStorage;
- }
-
- public FederatingPortletInvoker getPortletInvoker()
- {
- return portletInvoker;
- }
-
- private PortalData getPortalDataFor(Id<Portal> portalId)
- {
- ParameterValidation.throwIllegalArgExceptionIfNull(portalId, "Portal
Id");
- try
- {
- begin();
-
- return dataStorage.getPortalConfig(PortalKey.create(portalId.toString()));
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- finally
- {
- end();
- }
- }
-
- public void begin()
- {
- lcManager.begin();
- }
-
- public void end()
- {
- lcManager.end();
- }
-
- public GadgetRegistryService getGadgetService()
- {
- return gadgetService;
- }
-
- public OrganizationService getOrganizationService()
- {
- return configService.getOrganizationService();
- }
-
- public UserACL getUserACL()
- {
- return configService.getUserACL();
- }
-
- public DescriptionService getDescriptionService()
- {
- return configService.getDescriptionService();
- }
-}
Copied:
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/GateInImpl.java
(from rev 7030,
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/GateInImpl.java)
===================================================================
---
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/GateInImpl.java
(rev 0)
+++
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/GateInImpl.java 2011-08-09
18:48:56 UTC (rev 7032)
@@ -0,0 +1,752 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* 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.gatein.portal.api.impl;
+
+import org.exoplatform.application.gadget.GadgetRegistryService;
+import org.exoplatform.application.gadget.SourceStorage;
+import org.exoplatform.application.registry.Application;
+import org.exoplatform.application.registry.ApplicationRegistryService;
+import org.exoplatform.container.ExoContainer;
+import org.exoplatform.container.ExoContainerContext;
+import org.exoplatform.container.configuration.ConfigurationManager;
+import org.exoplatform.container.xml.InitParams;
+import org.exoplatform.portal.config.Query;
+import org.exoplatform.portal.config.UserACL;
+import org.exoplatform.portal.config.UserPortalConfigService;
+import org.exoplatform.portal.config.model.ApplicationType;
+import org.exoplatform.portal.config.model.PortalConfig;
+import org.exoplatform.portal.mop.SiteType;
+import org.exoplatform.portal.mop.description.DescriptionService;
+import org.exoplatform.portal.mop.navigation.NavigationService;
+import org.exoplatform.portal.pc.ExoKernelIntegration;
+import org.exoplatform.portal.pom.data.ModelDataStorage;
+import org.exoplatform.portal.pom.data.PageData;
+import org.exoplatform.portal.pom.data.PageKey;
+import org.exoplatform.portal.pom.data.PortalData;
+import org.exoplatform.portal.pom.data.PortalKey;
+import org.exoplatform.services.organization.Group;
+import org.exoplatform.services.organization.GroupHandler;
+import org.exoplatform.services.organization.Membership;
+import org.exoplatform.services.organization.OrganizationService;
+import org.exoplatform.services.organization.User;
+import org.exoplatform.services.organization.UserHandler;
+import org.exoplatform.services.security.Identity;
+import org.exoplatform.services.security.MembershipEntry;
+import org.gatein.api.GateIn;
+import org.gatein.api.content.Category;
+import org.gatein.api.content.Content;
+import org.gatein.api.content.Gadget;
+import org.gatein.api.content.ManagedContent;
+import org.gatein.api.content.Portlet;
+import org.gatein.api.content.WSRP;
+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;
+import org.gatein.api.portal.Page;
+import org.gatein.api.portal.Portal;
+import org.gatein.api.portal.Site;
+import org.gatein.api.util.Filter;
+import org.gatein.api.util.IterableIdentifiableCollection;
+import org.gatein.api.util.Type;
+import org.gatein.common.util.ParameterValidation;
+import org.gatein.pc.federation.FederatingPortletInvoker;
+import org.gatein.portal.api.impl.id.ComplexApplicationContext;
+import org.gatein.portal.api.impl.id.ComplexApplicationId;
+import org.gatein.portal.api.impl.portal.DashboardSiteImpl;
+import org.gatein.portal.api.impl.portal.GroupSiteImpl;
+import org.gatein.portal.api.impl.portal.PageImpl;
+import org.gatein.portal.api.impl.portal.PortalImpl;
+import org.gatein.portal.api.impl.util.AdaptedIterableIdentifiableCollection;
+import org.gatein.portal.api.impl.util.AggregatedIterableIdentifiableCollection;
+import org.picocontainer.Startable;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Pattern;
+
+/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
+public class GateInImpl implements GateIn, Startable, LifecycleManager
+{
+ private static final Query<PortalData> PORTALS = new
Query<PortalData>(SiteType.PORTAL.getName(), null, PortalData.class);
+
+ private static final String GROUP_CHARS = "\\w|-|_";
+
+ public static final String SITE_TYPE_COMPONENT = "type";
+ public static final String SITE_NAME_COMPONENT = "name";
+ public static final String APPLICATION_COMPONENT = "application";
+ public static final String PORTLET_COMPONENT = "portlet";
+ public static final String INVOKER_COMPONENT = "invoker";
+ public static final String CATEGORY_COMPONENT = "category";
+
+ public static final Pattern INVOKER_COMPONENT_PATTERN =
Pattern.compile("\\w+");
+
+ public static final Context LOCAL_PORTLET_CONTEXT =
GenericContext.builder().named("Local Portlet")
+ .requiredComponent(APPLICATION_COMPONENT, Identifiable.class,
Pattern.compile("(" + GROUP_CHARS + "|\\.)+"))
+ .requiredComponent(PORTLET_COMPONENT, Portlet.class,
Pattern.compile("\\w+"))
+ .withDefaultSeparator("/").build();
+ private static final Context WSRP_PORTLET_CONTEXT =
GenericContext.builder().named("WSRP Portlet")
+ .requiredComponent(INVOKER_COMPONENT, Identifiable.class,
INVOKER_COMPONENT_PATTERN)
+ .requiredComponent("portletcontext", WSRP.class,
Pattern.compile("(" + GROUP_CHARS + ")+"))
+ .withDefaultSeparator(".").build();
+
+ public static final Context SITE_CONTEXT =
GenericContext.builder().named("Site")
+ .requiredComponent(SITE_TYPE_COMPONENT, Identifiable.class,
Pattern.compile(Site.PORTAL_TYPE_NAME + "|" + Site.GROUP_TYPE_NAME +
"|" + Site.DASHBOARD_TYPE_NAME))
+ .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 + ")+"))
+ .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();
+ 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;
+ private ApplicationRegistryService registryService;
+ private GadgetRegistryService gadgetService;
+ private SourceStorage sourceStorage;
+ private UserPortalConfigService configService;
+ private Map<Type, Object> properties = new HashMap<Type, Object>(7);
+ private LifecycleManager lcManager = GateIn.NO_OP_MANAGER;
+ private FederatingPortletInvoker portletInvoker;
+
+ public GateInImpl(ExoContainerContext context, InitParams params, ConfigurationManager
configurationManager, ExoKernelIntegration exoKernelIntegration)
+ {
+ container = context.getContainer();
+ }
+
+ public static Id<? extends Content> getContentIdFrom(Application application)
+ {
+ ApplicationType type = application.getType();
+ Class<Content> contentClass = getContentClassFor(type);
+ if (Gadget.class.isAssignableFrom(contentClass))
+ {
+ return staticGadgetId(application.getContentId());
+ }
+ else if (WSRP.class.isAssignableFrom(contentClass))
+ {
+ return parseWSRPPortletId(application.getContentId());
+ }
+ else if (Portlet.class.isAssignableFrom(contentClass))
+ {
+ return parsePortletId(application.getContentId());
+ }
+ else
+ {
+ throw new IllegalArgumentException("Unknown application type: " +
type);
+ }
+ }
+
+ public static <T extends Content> Class<T>
getContentClassFor(ApplicationType type)
+ {
+ if (ApplicationType.GADGET.equals(type))
+ {
+ return (Class<T>)Gadget.class;
+ }
+ else if (ApplicationType.PORTLET.equals(type))
+ {
+ return (Class<T>)Portlet.class;
+ }
+ else if (ApplicationType.WSRP_PORTLET.equals(type))
+ {
+ return (Class<T>)WSRP.class;
+ }
+ else
+ {
+ throw new IllegalArgumentException("Unknown ApplicationType: " +
type);
+ }
+ }
+
+ public <T> T getProperty(Type<T> property)
+ {
+ if (property == null)
+ {
+ return null;
+ }
+
+ Class<T> type = property.getValueType();
+ Object o = properties.get(property);
+ return type.cast(o);
+ }
+
+ public <T> void setProperty(Type<T> property, T value)
+ {
+ if (property != null)
+ {
+ if (GateIn.LIFECYCLE_MANAGER.equals(property))
+ {
+ lcManager = GateIn.LIFECYCLE_MANAGER.getValueType().cast(value);
+ }
+ properties.put(property, value);
+ }
+ }
+
+ public IterableIdentifiableCollection<Portal> getPortals()
+ {
+ try
+ {
+ begin();
+ final List<PortalData> portals = dataStorage.find(PORTALS).getAll();
+
+ return new AdaptedIterableIdentifiableCollection<PortalData,
Portal>(portals.size(), portals.iterator())
+ {
+ public Portal adapt(PortalData old)
+ {
+ return new PortalImpl(old, GateInImpl.this);
+ }
+
+ public boolean contains(Id<Portal> id)
+ {
+ return getPortalDataFor(id) != null;
+ }
+ };
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ finally
+ {
+ end();
+ }
+ }
+
+ public Portal getPortal(Id<Portal> portalId)
+ {
+ PortalData portalData = getPortalDataFor(portalId);
+ return new PortalImpl(portalData, this);
+ }
+
+ public Portal getDefaultPortal()
+ {
+ return getPortal(siteId(Site.PORTAL, "classic")); // todo: check
+ }
+
+ public IterableIdentifiableCollection<? extends Site> getSites()
+ {
+ IterableIdentifiableCollection<Site> groupSites = getGroupSites();
+ IterableIdentifiableCollection<Portal> portals = getPortals();
+ IterableIdentifiableCollection<Site> dashboards = getDashboards();
+
+ AggregatedIterableIdentifiableCollection collection = new
AggregatedIterableIdentifiableCollection();
+ collection.addCollection(groupSites);
+ collection.addCollection(portals);
+ collection.addCollection(dashboards);
+
+ return collection;
+ }
+
+ private IterableIdentifiableCollection<Site> getDashboards()
+ {
+ try
+ {
+ begin();
+ final UserHandler userHandler = getOrganizationService().getUserHandler();
+
+ // todo: optimize
+ List<User> users = userHandler.getUserPageList(1000).getAll();
+
+ // todo: check for correctness
+ return new AdaptedIterableIdentifiableCollection<User, Site>(users.size(),
users.iterator())
+ {
+
+ public Site adapt(User old)
+ {
+ return getDashboard(userId(old.getUserName()));
+ }
+
+ public boolean contains(Id<Site> t)
+ {
+ try
+ {
+ return dataStorage.loadDashboard(t.toString()) != null;
+ }
+ catch (Exception e)
+ {
+ return false;
+ }
+ }
+ };
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ finally
+ {
+ end();
+ }
+ }
+
+ public IterableIdentifiableCollection<Site> getGroupSites()
+ {
+ try
+ {
+ begin();
+
+ final GroupHandler groupHandler = getOrganizationService().getGroupHandler();
+ Collection groups = groupHandler.getAllGroups();
+
+ return new AdaptedIterableIdentifiableCollection<Object,
Site>(groups.size(), groups.iterator())
+ {
+ public boolean contains(Id<Site> siteId)
+ {
+ try
+ {
+ return groupHandler.findGroupById(siteId.toString()) != null;
+ }
+ catch (Exception e)
+ {
+ return false;
+ }
+ }
+
+ public Site adapt(Object old)
+ {
+ Group group = (Group)old;
+ return getGroupSite(GROUP_CONTEXT.parse(group.getId()));
+ }
+ };
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ finally
+ {
+ end();
+ }
+ }
+
+ public Site getGroupSite(Id groupId)
+ {
+ String groupName = groupId.toString();
+ Id<Site> siteId = siteId(Site.GROUP, groupName);
+
+ return new GroupSiteImpl(siteId, groupName, this);
+ }
+
+ public IterableIdentifiableCollection<Site> getGroupSites(Id userId)
+ {
+ final GroupHandler groupHandler = getOrganizationService().getGroupHandler();
+ try
+ {
+ begin();
+ final String id = userId.toString();
+ Collection groups = groupHandler.findGroupsOfUser(id);
+
+ return new AdaptedIterableIdentifiableCollection<Object,
Site>(groups.size(), groups.iterator())
+ {
+ public boolean contains(Id<Site> siteId)
+ {
+ try
+ {
+ Group group = groupHandler.findGroupById(siteId.toString());
+ return group != null && !groupHandler.findGroupByMembership(id,
null).isEmpty();
+ }
+ catch (Exception e)
+ {
+ return false;
+ }
+ }
+
+ public Site adapt(Object old)
+ {
+ Group group = (Group)old;
+ return getGroupSite(GROUP_CONTEXT.parse(group.getId()));
+ }
+ };
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ finally
+ {
+ end();
+ }
+ }
+
+ public IterableIdentifiableCollection<Portal> getPortalSites(Id userId)
+ {
+ try
+ {
+ begin();
+ final List<PortalData> portalDatas = dataStorage.find(PORTALS).getAll();
+
+ // first build Identity based on user id so that we can check its permissions
using UserACL... ugh! :(
+ final String user = userId.toString();
+ final Collection membershipsByUser =
getOrganizationService().getMembershipHandler().findMembershipsByUser(user);
+ Collection<MembershipEntry> membershipEntries = new
ArrayList<MembershipEntry>(membershipsByUser.size());
+ for (Object o : membershipsByUser)
+ {
+ Membership membership = (Membership)o;
+ membershipEntries.add(new MembershipEntry(membership.getGroupId(),
membership.getMembershipType()));
+ }
+ final Identity identity = new Identity(user, membershipEntries);
+
+ final List<Portal> portals = new
ArrayList<Portal>(portalDatas.size());
+ final Filter<PortalData> filter = new Filter<PortalData>()
+ {
+ @Override
+ public boolean accept(PortalData item)
+ {
+ return getUserACL().hasPermission(identity, new PortalConfig(item));
+ }
+ };
+
+ for (PortalData portalData : portalDatas)
+ {
+ if (filter.accept(portalData))
+ {
+ portals.add(new PortalImpl(portalData, this));
+ }
+ }
+
+ return new AdaptedIterableIdentifiableCollection<Portal,
Portal>(portals.size(), portals.iterator())
+ {
+ public Portal adapt(Portal old)
+ {
+ return old;
+ }
+
+ public boolean contains(Id<Portal> id)
+ {
+ final PortalData portalData = getPortalDataFor(id);
+ return portalData != null && filter.accept(portalData);
+ }
+ };
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ finally
+ {
+ end();
+ }
+ }
+
+ public Site getDashboard(Id userId)
+ {
+ String user = userId.toString();
+ Id<Site> siteId = siteId(Site.DASHBOARD, user);
+
+ return new DashboardSiteImpl(siteId, user, this);
+ }
+
+ public <T extends Identifiable> T get(Id<T> id)
+ {
+ Class<T> type = id.getIdentifiableType();
+
+ Object result = null;
+
+ if (Portal.class.equals(type))
+ {
+ result = getPortal((Id<Portal>)id);
+ }
+ else if (Page.class.equals(type))
+ {
+ try
+ {
+ begin();
+ PageData pageData = dataStorage.getPage(PageKey.create(id.toString()));
+ result = new PageImpl(pageData, id.getParent(), this);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ finally
+ {
+ end();
+ }
+ }
+ else if (Site.class.equals(type))
+ {
+ Id<Site> siteId = (Id<Site>)id;
+ result = getSite(siteId, null);
+ }
+ else if (Content.class.isAssignableFrom(type))
+ {
+ // todo: split by types and optimize by calling portlet invoker or gadget
registry directly
+ final IterableIdentifiableCollection<Portal> portals = getPortals();
+ for (Portal portal : portals)
+ {
+ result = portal.getContentRegistry().get((Id<? extends Content>)id);
+ if (result != null)
+ {
+ break;
+ }
+ }
+ }
+ else if (Category.class.equals(type))
+ {
+ // todo: optimize by adding portal id to category id (so that appropriate
content registry can be retrieved) and calling application registry directly
+ 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);
+ //todo: need to get all the parents of a Navigation to be able to load it so we
would need to add the complete path to the Id to be able to resolve Navigations properly
+ result = site.getNavigation().get(id.getComponent(NAVIGATION_COMPONENT));
+
+ throw new UnsupportedOperationException("Id<" +
type.getSimpleName() + "> not yet supported");
+ }
+ else
+ {
+ throw new UnsupportedOperationException("Id<" +
type.getSimpleName() + "> not yet supported");
+ }
+
+ return type.cast(result);
+ }
+
+ public <T extends Site> T getSite(Id<T> siteId, Type<T> type)
+ {
+ final String siteType = siteId.getComponent(SITE_TYPE_COMPONENT);
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(siteType, "Site
type", "A valid Site Id");
+
+ if (Site.PORTAL.equals(siteType))
+ {
+ return (T)getPortal((Id<Portal>)siteId);
+ }
+ else if (Site.GROUP_TYPE_NAME.equals(siteType))
+ {
+ return (T)getGroupSite(groupId(siteId.getComponent(SITE_NAME_COMPONENT)));
+ }
+ else if (Site.DASHBOARD_TYPE_NAME.equals(siteType))
+ {
+ return (T)getDashboard(userId(siteId.getComponent(SITE_NAME_COMPONENT)));
+ }
+ else
+ {
+ throw new IllegalArgumentException("Unknown Site type: " + siteType);
+ }
+ }
+
+ public Id userId(String user)
+ {
+ return USER_CONTEXT.create(user);
+ }
+
+ public Id groupId(String root, String... children)
+ {
+ return GROUP_CONTEXT.create(root, children);
+ }
+
+ public Id<Portlet> portletId(String application, String portlet)
+ {
+ return LOCAL_PORTLET_CONTEXT.create(Portlet.class, application, portlet);
+ }
+
+ public static Id<Portlet> parsePortletId(String contentId)
+ {
+ if (contentId.contains(ComplexApplicationId.START))
+ {
+ return ComplexApplicationContext.INSTANCE.parse(contentId, Portlet.class);
+ }
+ else
+ {
+ return LOCAL_PORTLET_CONTEXT.parse(contentId, Portlet.class);
+ }
+ }
+
+ public Id<WSRP> wsrpPortletId(String invoker, String portlet)
+ {
+ return staticWSRPPortletId(invoker, portlet);
+ }
+
+ private static Id<WSRP> staticWSRPPortletId(String invoker, String portlet)
+ {
+ return WSRP_PORTLET_CONTEXT.create(WSRP.class, invoker, portlet);
+ }
+
+ public static Id<WSRP> parseWSRPPortletId(String compositeId)
+ {
+ return WSRP_PORTLET_CONTEXT.parse(compositeId, WSRP.class);
+ }
+
+ public Id<Gadget> gadgetId(String gadgetName)
+ {
+ return staticGadgetId(gadgetName);
+ }
+
+ private static Id<Gadget> staticGadgetId(String gadgetName)
+ {
+ return GADGET_CONTEXT.create(Gadget.class, gadgetName);
+ }
+
+ public Id<Gadget> gadgetId(URI uri)
+ {
+ return GADGET_CONTEXT.create(Gadget.class, uri.toString());
+ }
+
+ public <T extends Content> Id<ManagedContent>
managedContentId(Id<Category> categoryId, String name, Id<T> contentId)
+ {
+ return MANAGED_CONTENT_CONTEXT.create(ManagedContent.class, categoryId.toString(),
name, contentId.toString());
+ }
+
+ public Id<Category> categoryId(String name)
+ {
+ return CATEGORY_CONTEXT.create(Category.class, name);
+ }
+
+ public <T extends Site> Id<T> siteId(Type<T> siteType, String
siteName)
+ {
+ return SITE_CONTEXT.create(siteType.getValueType(), siteType.getName(), siteName);
+ }
+
+ public <T extends Site> Id<Page> pageId(Id<T> ownerSite, String
pageName)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(ownerSite, "Owner Site
Id");
+ return ownerSite.getIdForChild(pageName);
+ }
+
+ public void start()
+ {
+ dataStorage =
(ModelDataStorage)container.getComponentInstanceOfType(ModelDataStorage.class);
+ registryService =
(ApplicationRegistryService)container.getComponentInstanceOfType(ApplicationRegistryService.class);
+ gadgetService =
(GadgetRegistryService)container.getComponentInstanceOfType(GadgetRegistryService.class);
+ sourceStorage =
(SourceStorage)container.getComponentInstanceOfType(SourceStorage.class);
+ configService =
(UserPortalConfigService)container.getComponentInstanceOfType(UserPortalConfigService.class);
+ portletInvoker =
(FederatingPortletInvoker)container.getComponentInstanceOfType(FederatingPortletInvoker.class);
+ }
+
+ public void stop()
+ {
+ // nothing to do
+ }
+
+ public ModelDataStorage getDataStorage()
+ {
+ return dataStorage;
+ }
+
+ public NavigationService getNavigationService()
+ {
+ return configService.getNavigationService();
+ }
+
+ public ApplicationRegistryService getRegistryService()
+ {
+ return registryService;
+ }
+
+ public SourceStorage getSourceStorage()
+ {
+ return sourceStorage;
+ }
+
+ public FederatingPortletInvoker getPortletInvoker()
+ {
+ return portletInvoker;
+ }
+
+ private PortalData getPortalDataFor(Id<Portal> portalId)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(portalId, "Portal
Id");
+ try
+ {
+ begin();
+
+ return dataStorage.getPortalConfig(PortalKey.create(portalId.toString()));
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ finally
+ {
+ end();
+ }
+ }
+
+ public void begin()
+ {
+ lcManager.begin();
+ }
+
+ public void end()
+ {
+ lcManager.end();
+ }
+
+ public GadgetRegistryService getGadgetService()
+ {
+ return gadgetService;
+ }
+
+ public OrganizationService getOrganizationService()
+ {
+ return configService.getOrganizationService();
+ }
+
+ public UserACL getUserACL()
+ {
+ return configService.getUserACL();
+ }
+
+ public DescriptionService getDescriptionService()
+ {
+ return configService.getDescriptionService();
+ }
+}
Deleted:
portal/trunk/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-09
13:52:09 UTC (rev 7030)
+++
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/IdentifiableImpl.java 2011-08-09
18:48:56 UTC (rev 7032)
@@ -1,69 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* 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.gatein.portal.api.impl;
-
-import org.gatein.api.GateIn;
-import org.gatein.api.id.Id;
-import org.gatein.api.id.Identifiable;
-
-/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
-public class IdentifiableImpl<T extends Identifiable<T>> implements
Identifiable<T>
-{
- private final Id<T> id;
- private final String name;
- private final String displayName;
- private final GateInImpl gateIn;
-
- public IdentifiableImpl(Id<T> id, String name, GateInImpl gateIn)
- {
- this.id = id;
- this.name = name;
- this.gateIn = gateIn;
- this.displayName = name; // todo: fix-me
- }
-
- public Id<T> getId()
- {
- return id;
- }
-
- public String getName()
- {
- return name;
- }
-
- public String getDisplayName()
- {
- return displayName;
- }
-
- public GateIn getGateIn()
- {
- return getGateInImpl();
- }
-
- protected GateInImpl getGateInImpl()
- {
- return gateIn;
- }
-}
Copied:
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/IdentifiableImpl.java
(from rev 7030,
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/IdentifiableImpl.java)
===================================================================
---
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/IdentifiableImpl.java
(rev 0)
+++
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/IdentifiableImpl.java 2011-08-09
18:48:56 UTC (rev 7032)
@@ -0,0 +1,69 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* 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.gatein.portal.api.impl;
+
+import org.gatein.api.GateIn;
+import org.gatein.api.id.Id;
+import org.gatein.api.id.Identifiable;
+
+/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
+public class IdentifiableImpl<T extends Identifiable<T>> implements
Identifiable<T>
+{
+ private final Id<T> id;
+ private final String name;
+ private final String displayName;
+ private final GateInImpl gateIn;
+
+ public IdentifiableImpl(Id<T> id, String name, GateInImpl gateIn)
+ {
+ this.id = id;
+ this.name = name;
+ this.gateIn = gateIn;
+ this.displayName = name; // todo: fix-me
+ }
+
+ public Id<T> getId()
+ {
+ return id;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public String getDisplayName()
+ {
+ return displayName;
+ }
+
+ public GateIn getGateIn()
+ {
+ return getGateInImpl();
+ }
+
+ protected GateInImpl getGateInImpl()
+ {
+ return gateIn;
+ }
+}
Deleted:
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/LifecycleManager.java
===================================================================
---
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/LifecycleManager.java 2011-08-09
13:52:09 UTC (rev 7030)
+++
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/LifecycleManager.java 2011-08-09
18:48:56 UTC (rev 7032)
@@ -1,31 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* 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.gatein.portal.api.impl;
-
-/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
-public interface LifecycleManager
-{
- void begin();
-
- void end();
-}
Copied:
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/LifecycleManager.java
(from rev 7030,
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/LifecycleManager.java)
===================================================================
---
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/LifecycleManager.java
(rev 0)
+++
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/LifecycleManager.java 2011-08-09
18:48:56 UTC (rev 7032)
@@ -0,0 +1,31 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* 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.gatein.portal.api.impl;
+
+/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
+public interface LifecycleManager
+{
+ void begin();
+
+ void end();
+}
Deleted:
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/AbstractPortlet.java
===================================================================
---
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/AbstractPortlet.java 2011-08-09
13:52:09 UTC (rev 7030)
+++
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/AbstractPortlet.java 2011-08-09
18:48:56 UTC (rev 7032)
@@ -1,47 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* 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.gatein.portal.api.impl.content;
-
-import org.gatein.api.content.Content;
-import org.gatein.api.id.Id;
-import org.gatein.portal.api.impl.GateInImpl;
-import org.gatein.portal.api.impl.IdentifiableImpl;
-
-/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
-public abstract class AbstractPortlet<T extends Content<T>> extends
IdentifiableImpl<T> implements Content<T>
-{
- private final org.gatein.pc.api.Portlet portlet;
-
- public AbstractPortlet(Id<T> id, org.gatein.pc.api.Portlet application,
GateInImpl gateIn)
- {
- super(id, application.getInfo().getName(), gateIn);
- this.portlet = application;
- }
-
- @Override
- public String toString()
- {
- return getType().getName() + " Portlet '" + getName() + "'
@" + getId();
- }
-
-}
Copied:
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/AbstractPortlet.java
(from rev 7030,
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/AbstractPortlet.java)
===================================================================
---
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/AbstractPortlet.java
(rev 0)
+++
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/AbstractPortlet.java 2011-08-09
18:48:56 UTC (rev 7032)
@@ -0,0 +1,47 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* 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.gatein.portal.api.impl.content;
+
+import org.gatein.api.content.Content;
+import org.gatein.api.id.Id;
+import org.gatein.portal.api.impl.GateInImpl;
+import org.gatein.portal.api.impl.IdentifiableImpl;
+
+/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
+public abstract class AbstractPortlet<T extends Content<T>> extends
IdentifiableImpl<T> implements Content<T>
+{
+ private final org.gatein.pc.api.Portlet portlet;
+
+ public AbstractPortlet(Id<T> id, org.gatein.pc.api.Portlet application,
GateInImpl gateIn)
+ {
+ super(id, application.getInfo().getName(), gateIn);
+ this.portlet = application;
+ }
+
+ @Override
+ public String toString()
+ {
+ return getType().getName() + " Portlet '" + getName() + "'
@" + getId();
+ }
+
+}
Deleted:
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/CategoryImpl.java
===================================================================
---
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/CategoryImpl.java 2011-08-09
13:52:09 UTC (rev 7030)
+++
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/CategoryImpl.java 2011-08-09
18:48:56 UTC (rev 7032)
@@ -1,290 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* 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.gatein.portal.api.impl.content;
-
-import org.exoplatform.application.registry.Application;
-import org.exoplatform.application.registry.ApplicationCategory;
-import org.exoplatform.application.registry.ApplicationRegistryService;
-import org.exoplatform.portal.config.UserACL;
-import org.exoplatform.portal.pom.spi.portlet.Portlet;
-import org.exoplatform.portal.pom.spi.wsrp.WSRP;
-import org.gatein.api.content.Category;
-import org.gatein.api.content.Content;
-import org.gatein.api.content.ContentRegistry;
-import org.gatein.api.content.Gadget;
-import org.gatein.api.content.ManagedContent;
-import org.gatein.api.id.Id;
-import org.gatein.api.util.IterableCollection;
-import org.gatein.api.util.Type;
-import org.gatein.common.util.ParameterValidation;
-import org.gatein.mop.api.content.ContentType;
-import org.gatein.portal.api.impl.GateInImpl;
-import org.gatein.portal.api.impl.util.AdaptedIterableCollection;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
-public class CategoryImpl implements Category
-{
- private final ApplicationCategory category;
- private final GateInImpl gateIn;
- private final ContentRegistry registry;
-
- public CategoryImpl(ApplicationCategory category, ContentRegistry registry, GateInImpl
gateIn)
- {
- this.category = category;
- this.registry = registry;
- this.gateIn = gateIn;
- }
-
- public IterableCollection<ManagedContent> getManagedContents()
- {
- List<Application> applications = category.getApplications();
- return new AdaptedIterableCollection<Application,
ManagedContent>(applications.size(), applications.iterator())
- {
- public ManagedContent adapt(Application old)
- {
- return new ManagedContentImpl(old.getApplicationName(),
GateInImpl.getContentIdFrom(old), old, CategoryImpl.this);
- }
-
- public boolean contains(ManagedContent managedContent)
- {
- return getApplication(managedContent.getName()) != null;
- }
- };
- }
-
- @Override
- public String toString()
- {
- StringBuilder sb = new StringBuilder("Category
'").append(getName()).append("':\n");
-
- for (ManagedContent content : getManagedContents())
- {
- sb.append('\t').append(content).append('\n');
- }
-
- return sb.toString();
- }
-
- ContentRegistry getRegistry()
- {
- return registry;
- }
-
- public boolean contains(String managedContentName)
- {
- return getApplication(managedContentName) != null;
- }
-
- private Application getApplication(String managedContentName)
- {
- try
- {
- gateIn.begin();
- return gateIn.getRegistryService().getApplication(category.getName(),
managedContentName);
- }
- catch (Exception e)
- {
- return null;
- }
- finally
- {
- gateIn.end();
- }
- }
-
- public <T extends Content> ManagedContent<T> addContent(Id<T>
contentId, String name)
- {
- ParameterValidation.throwIllegalArgExceptionIfNull(contentId, "Content
Id");
- GateInImpl.MANAGED_CONTENT_CONTEXT.validateValueFor("name", name);
-
- final ContentType<?> contentType = getContentTypeFor(contentId);
-
- // default permissions by default
- ArrayList<String> permissions = new ArrayList<String>();
- permissions.add(UserACL.EVERYONE);
-
- try
- {
- gateIn.begin();
-
- final ApplicationRegistryService registryService = gateIn.getRegistryService();
- final Application application =
registryService.createOrUpdateApplication(category.getName(), name, contentType,
contentId.toString(), name, null, permissions);
- return new ManagedContentImpl<T>(name, contentId, application, this);
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- finally
- {
- gateIn.end();
- }
- }
-
- private ContentType<?> getContentTypeFor(Type type)
- {
- if (Content.GADGET.equals(type))
- {
- return org.exoplatform.portal.pom.spi.gadget.Gadget.CONTENT_TYPE;
- }
- else if (Content.PORTLET.equals(type))
- {
- return Portlet.CONTENT_TYPE;
- }
- else if (Content.WSRP.equals(type))
- {
- return WSRP.CONTENT_TYPE;
- }
- else
- {
- throw new IllegalArgumentException("Unknown Content type: " + type);
- }
- }
-
- private ContentType<?> getContentTypeFor(Id id)
- {
- final Class type = id.getIdentifiableType();
- if (Gadget.class.equals(type))
- {
- return org.exoplatform.portal.pom.spi.gadget.Gadget.CONTENT_TYPE;
- }
- else if (org.gatein.api.content.Portlet.class.equals(type))
- {
- return Portlet.CONTENT_TYPE;
- }
- else if (org.gatein.api.content.WSRP.class.equals(type))
- {
- return WSRP.CONTENT_TYPE;
- }
- else
- {
- throw new IllegalArgumentException("Unknown Content type: " + type);
- }
- }
-
- public String getDescription()
- {
- return category.getDescription();
- }
-
- public void setDescription(String description)
- {
- category.setDescription(description);
- save();
- }
-
- private void save()
- {
- try
- {
- gateIn.begin();
- gateIn.getRegistryService().save(category);
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- finally
- {
- gateIn.end();
- }
- }
-
- public void setDisplayName(String displayName)
- {
- category.setDisplayName(displayName);
- save();
- }
-
- public void removeContent(String managedContentName)
- {
- Application application = getApplication(managedContentName);
-
- gateIn.begin();
- try
- {
- gateIn.getRegistryService().remove(application);
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- finally
- {
- gateIn.end();
- }
- }
-
- public ManagedContent getManagedContent(String name)
- {
- Application application = getApplication(name);
-
- if (application == null)
- {
- return null;
- }
-
- final Id<? extends Content> contentId =
GateInImpl.getContentIdFrom(application);
- return new ManagedContentImpl(name, contentId, application, this);
- }
-
- public IterableCollection<String> getKnownManagedContentNames()
- {
- IterableCollection<ManagedContent> managedContents = getManagedContents();
- return new AdaptedIterableCollection<ManagedContent,
String>(managedContents.size(), managedContents.iterator())
- {
- public boolean contains(String s)
- {
- return getApplication(s) != null;
- }
-
- public String adapt(ManagedContent old)
- {
- return old.getName();
- }
- };
- }
-
- public Id<Category> getId()
- {
- return gateIn.categoryId(getName());
- }
-
- public String getName()
- {
- return category.getName();
- }
-
- public String getDisplayName()
- {
- return category.getDisplayName();
- }
-
- public GateInImpl getGateIn()
- {
- return gateIn;
- }
-}
Copied:
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/CategoryImpl.java
(from rev 7030,
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/CategoryImpl.java)
===================================================================
---
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/CategoryImpl.java
(rev 0)
+++
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/CategoryImpl.java 2011-08-09
18:48:56 UTC (rev 7032)
@@ -0,0 +1,290 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* 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.gatein.portal.api.impl.content;
+
+import org.exoplatform.application.registry.Application;
+import org.exoplatform.application.registry.ApplicationCategory;
+import org.exoplatform.application.registry.ApplicationRegistryService;
+import org.exoplatform.portal.config.UserACL;
+import org.exoplatform.portal.pom.spi.portlet.Portlet;
+import org.exoplatform.portal.pom.spi.wsrp.WSRP;
+import org.gatein.api.content.Category;
+import org.gatein.api.content.Content;
+import org.gatein.api.content.ContentRegistry;
+import org.gatein.api.content.Gadget;
+import org.gatein.api.content.ManagedContent;
+import org.gatein.api.id.Id;
+import org.gatein.api.util.IterableCollection;
+import org.gatein.api.util.Type;
+import org.gatein.common.util.ParameterValidation;
+import org.gatein.mop.api.content.ContentType;
+import org.gatein.portal.api.impl.GateInImpl;
+import org.gatein.portal.api.impl.util.AdaptedIterableCollection;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
+public class CategoryImpl implements Category
+{
+ private final ApplicationCategory category;
+ private final GateInImpl gateIn;
+ private final ContentRegistry registry;
+
+ public CategoryImpl(ApplicationCategory category, ContentRegistry registry, GateInImpl
gateIn)
+ {
+ this.category = category;
+ this.registry = registry;
+ this.gateIn = gateIn;
+ }
+
+ public IterableCollection<ManagedContent> getManagedContents()
+ {
+ List<Application> applications = category.getApplications();
+ return new AdaptedIterableCollection<Application,
ManagedContent>(applications.size(), applications.iterator())
+ {
+ public ManagedContent adapt(Application old)
+ {
+ return new ManagedContentImpl(old.getApplicationName(),
GateInImpl.getContentIdFrom(old), old, CategoryImpl.this);
+ }
+
+ public boolean contains(ManagedContent managedContent)
+ {
+ return getApplication(managedContent.getName()) != null;
+ }
+ };
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder("Category
'").append(getName()).append("':\n");
+
+ for (ManagedContent content : getManagedContents())
+ {
+ sb.append('\t').append(content).append('\n');
+ }
+
+ return sb.toString();
+ }
+
+ ContentRegistry getRegistry()
+ {
+ return registry;
+ }
+
+ public boolean contains(String managedContentName)
+ {
+ return getApplication(managedContentName) != null;
+ }
+
+ private Application getApplication(String managedContentName)
+ {
+ try
+ {
+ gateIn.begin();
+ return gateIn.getRegistryService().getApplication(category.getName(),
managedContentName);
+ }
+ catch (Exception e)
+ {
+ return null;
+ }
+ finally
+ {
+ gateIn.end();
+ }
+ }
+
+ public <T extends Content> ManagedContent<T> addContent(Id<T>
contentId, String name)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(contentId, "Content
Id");
+ GateInImpl.MANAGED_CONTENT_CONTEXT.validateValueFor("name", name);
+
+ final ContentType<?> contentType = getContentTypeFor(contentId);
+
+ // default permissions by default
+ ArrayList<String> permissions = new ArrayList<String>();
+ permissions.add(UserACL.EVERYONE);
+
+ try
+ {
+ gateIn.begin();
+
+ final ApplicationRegistryService registryService = gateIn.getRegistryService();
+ final Application application =
registryService.createOrUpdateApplication(category.getName(), name, contentType,
contentId.toString(), name, null, permissions);
+ return new ManagedContentImpl<T>(name, contentId, application, this);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ finally
+ {
+ gateIn.end();
+ }
+ }
+
+ private ContentType<?> getContentTypeFor(Type type)
+ {
+ if (Content.GADGET.equals(type))
+ {
+ return org.exoplatform.portal.pom.spi.gadget.Gadget.CONTENT_TYPE;
+ }
+ else if (Content.PORTLET.equals(type))
+ {
+ return Portlet.CONTENT_TYPE;
+ }
+ else if (Content.WSRP.equals(type))
+ {
+ return WSRP.CONTENT_TYPE;
+ }
+ else
+ {
+ throw new IllegalArgumentException("Unknown Content type: " + type);
+ }
+ }
+
+ private ContentType<?> getContentTypeFor(Id id)
+ {
+ final Class type = id.getIdentifiableType();
+ if (Gadget.class.equals(type))
+ {
+ return org.exoplatform.portal.pom.spi.gadget.Gadget.CONTENT_TYPE;
+ }
+ else if (org.gatein.api.content.Portlet.class.equals(type))
+ {
+ return Portlet.CONTENT_TYPE;
+ }
+ else if (org.gatein.api.content.WSRP.class.equals(type))
+ {
+ return WSRP.CONTENT_TYPE;
+ }
+ else
+ {
+ throw new IllegalArgumentException("Unknown Content type: " + type);
+ }
+ }
+
+ public String getDescription()
+ {
+ return category.getDescription();
+ }
+
+ public void setDescription(String description)
+ {
+ category.setDescription(description);
+ save();
+ }
+
+ private void save()
+ {
+ try
+ {
+ gateIn.begin();
+ gateIn.getRegistryService().save(category);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ finally
+ {
+ gateIn.end();
+ }
+ }
+
+ public void setDisplayName(String displayName)
+ {
+ category.setDisplayName(displayName);
+ save();
+ }
+
+ public void removeContent(String managedContentName)
+ {
+ Application application = getApplication(managedContentName);
+
+ gateIn.begin();
+ try
+ {
+ gateIn.getRegistryService().remove(application);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ finally
+ {
+ gateIn.end();
+ }
+ }
+
+ public ManagedContent getManagedContent(String name)
+ {
+ Application application = getApplication(name);
+
+ if (application == null)
+ {
+ return null;
+ }
+
+ final Id<? extends Content> contentId =
GateInImpl.getContentIdFrom(application);
+ return new ManagedContentImpl(name, contentId, application, this);
+ }
+
+ public IterableCollection<String> getKnownManagedContentNames()
+ {
+ IterableCollection<ManagedContent> managedContents = getManagedContents();
+ return new AdaptedIterableCollection<ManagedContent,
String>(managedContents.size(), managedContents.iterator())
+ {
+ public boolean contains(String s)
+ {
+ return getApplication(s) != null;
+ }
+
+ public String adapt(ManagedContent old)
+ {
+ return old.getName();
+ }
+ };
+ }
+
+ public Id<Category> getId()
+ {
+ return gateIn.categoryId(getName());
+ }
+
+ public String getName()
+ {
+ return category.getName();
+ }
+
+ public String getDisplayName()
+ {
+ return category.getDisplayName();
+ }
+
+ public GateInImpl getGateIn()
+ {
+ return gateIn;
+ }
+}
Deleted:
portal/trunk/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-09
13:52:09 UTC (rev 7030)
+++
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ContentRegistryImpl.java 2011-08-09
18:48:56 UTC (rev 7032)
@@ -1,454 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* 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.gatein.portal.api.impl.content;
-
-import org.exoplatform.application.gadget.GadgetRegistryService;
-import org.exoplatform.application.gadget.Source;
-import org.exoplatform.application.gadget.SourceStorage;
-import org.exoplatform.application.registry.ApplicationCategory;
-import org.exoplatform.application.registry.ApplicationRegistryService;
-import org.gatein.api.content.Category;
-import org.gatein.api.content.Content;
-import org.gatein.api.content.ContentRegistry;
-import org.gatein.api.content.Gadget;
-import org.gatein.api.content.Portlet;
-import org.gatein.api.content.WSRP;
-import org.gatein.api.id.Id;
-import org.gatein.api.util.IterableCollection;
-import org.gatein.api.util.IterableIdentifiableCollection;
-import org.gatein.pc.api.PortletContext;
-import org.gatein.pc.api.PortletInvokerException;
-import org.gatein.pc.federation.FederatingPortletInvoker;
-import org.gatein.portal.api.impl.GateInImpl;
-import org.gatein.portal.api.impl.portal.PortalImpl;
-import org.gatein.portal.api.impl.util.AdaptedIterableCollection;
-import org.gatein.portal.api.impl.util.AdaptedIterableIdentifiableCollection;
-import org.gatein.portal.api.impl.util.AggregatedIterableIdentifiableCollection;
-
-import java.util.List;
-import java.util.Set;
-
-/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
-public class ContentRegistryImpl implements ContentRegistry
-{
- private final GateInImpl gateIn;
- private final PortalImpl portal;
-
- public ContentRegistryImpl(GateInImpl gateIn, PortalImpl portal)
- {
- this.gateIn = gateIn;
- this.portal = portal;
- }
-
- public Category getOrCreateCategory(String name)
- {
- return getOrCreateCategory(name, true);
- }
-
- public Category getCategory(String name)
- {
- return getOrCreateCategory(name, false);
- }
-
- public void deleteCategory(String name)
- {
- try
- {
- final ApplicationCategory category = new ApplicationCategory();
- category.setName(name);
- gateIn.begin();
- gateIn.getRegistryService().remove(category);
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- finally
- {
- gateIn.end();
- }
- }
-
- public IterableCollection<String> getCategoryNames()
- {
- try
- {
- gateIn.begin();
- final List<ApplicationCategory> categories =
gateIn.getRegistryService().getApplicationCategories();
- return new AdaptedIterableCollection<ApplicationCategory,
String>(categories.size(), categories.iterator())
- {
- public String adapt(ApplicationCategory old)
- {
- return old.getName();
- }
-
- public boolean contains(String s)
- {
- return doesCategoryExist(s);
- }
- };
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- finally
- {
- gateIn.end();
- }
- }
-
- public IterableIdentifiableCollection<Category> getAllCategories()
- {
- try
- {
- gateIn.begin();
- final List<ApplicationCategory> categories =
gateIn.getRegistryService().getApplicationCategories();
- return new AdaptedIterableIdentifiableCollection<ApplicationCategory,
Category>(categories.size(), categories.iterator())
- {
- public Category adapt(ApplicationCategory old)
- {
- return new CategoryImpl(old, ContentRegistryImpl.this, gateIn);
- }
-
- public boolean contains(Id<Category> t)
- {
- return doesCategoryExist(t.toString());
- }
- };
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- finally
- {
- gateIn.end();
- }
- }
-
- private Category getOrCreateCategory(String name, boolean forceCreate)
- {
- try
- {
- gateIn.begin();
- ApplicationRegistryService registryService = gateIn.getRegistryService();
- ApplicationCategory applicationCategory =
registryService.getApplicationCategory(name);
- if (applicationCategory == null)
- {
- if (forceCreate)
- {
- applicationCategory = new ApplicationCategory();
- applicationCategory.setName(name);
- applicationCategory.setDisplayName(name);
- applicationCategory.setDescription(name);
- registryService.save(applicationCategory);
- }
- else
- {
- return null;
- }
- }
-
- return new CategoryImpl(applicationCategory, this, gateIn);
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- finally
- {
- gateIn.end();
- }
- }
-
- private boolean doesCategoryExist(String name)
- {
- try
- {
- gateIn.begin();
- return gateIn.getRegistryService().getApplicationCategory(name) != null;
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- finally
- {
- gateIn.end();
- }
- }
-
- public <T extends Content> T get(Id<T> id)
- {
- Class<T> type = id.getIdentifiableType();
- Object result;
- Object regitryItem;
- try
- {
- gateIn.begin();
- if (Portlet.class.equals(type) || WSRP.class.equals(type))
- {
- regitryItem = getPortletFrom(id);
- }
- else if (Gadget.class.equals(type))
- {
- regitryItem = gateIn.getGadgetService().getGadget(id.toString());
- }
- else
- {
- throw new IllegalArgumentException("Unknown Content type: " +
type.getCanonicalName());
- }
-
- result = newContentFrom(id, regitryItem, type);
- return type.cast(result);
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- finally
- {
- gateIn.end();
- }
- }
-
- private <T extends Content> Object getPortletFrom(Id<T> id) throws
PortletInvokerException
- {
- PortletContext portletContext;
- Object regitryItem;
- if (!id.knowsComponent(GateInImpl.INVOKER_COMPONENT))
- {
- portletContext =
PortletContext.createPortletContext(id.getComponent(GateInImpl.APPLICATION_COMPONENT),
id.getComponent(GateInImpl.PORTLET_COMPONENT));
- regitryItem =
gateIn.getPortletInvoker().getFederatedInvoker("local").getPortletInvoker().getPortlet(portletContext);
- }
- else
- {
- portletContext = PortletContext.createPortletContext(id.toString());
- regitryItem = gateIn.getPortletInvoker().getPortlet(portletContext);
- }
- return regitryItem;
- }
-
- private <T extends Content> Content newContentFrom(Id id, Object registryItem,
Class<T> wanted)
- {
- Object result;
- if (Portlet.class.equals(wanted))
- {
- result = new PortletImpl((Id<Portlet>)id,
(org.gatein.pc.api.Portlet)registryItem, gateIn);
- }
- else if (Gadget.class.equals(wanted))
- {
- result = new GadgetImpl((Id<Gadget>)id,
(org.exoplatform.application.gadget.Gadget)registryItem, gateIn);
- }
- else if (WSRP.class.equals(wanted))
- {
- result = new WSRPImpl((Id<WSRP>)id,
(org.gatein.pc.api.Portlet)registryItem, gateIn);
- }
- else
- {
- throw new IllegalArgumentException("Unknown Content type: " +
wanted.getCanonicalName());
- }
-
- return wanted.cast(result);
- }
-
- public Gadget createGadget(String gadget, String source)
- {
- try
- {
- gateIn.begin();
- final GadgetRegistryService gadgetService = gateIn.getGadgetService();
- org.exoplatform.application.gadget.Gadget original =
gadgetService.getGadget(gadget);
- if (original == null)
- {
- original = new org.exoplatform.application.gadget.Gadget();
- original.setName(gadget);
- original.setUrl("http://www.gatein.org"); // todo: fix me
- gadgetService.saveGadget(original);
- }
-
- SourceStorage sourceStorage = gateIn.getSourceStorage();
- Source originalSource = sourceStorage.getSource(original);
- originalSource.setTextContent(source);
- sourceStorage.saveSource(original, originalSource);
-
- return (Gadget)newContentFrom(gateIn.gadgetId(gadget), original, Gadget.class);
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- finally
- {
- gateIn.end();
- }
- }
-
- public IterableIdentifiableCollection<Content> getAll()
- {
- try
- {
- gateIn.begin();
- IterableIdentifiableCollection<? extends Content> localPortlets =
getLocalPortlets();
- IterableIdentifiableCollection<? extends Content> gadgets = getGadgets();
- IterableIdentifiableCollection<? extends Content> remotePortlets =
getRemotePortlets();
-
- final AggregatedIterableIdentifiableCollection result = new
AggregatedIterableIdentifiableCollection();
- result.addCollection(localPortlets);
- result.addCollection(remotePortlets);
- result.addCollection(gadgets);
- return result;
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- finally
- {
- gateIn.end();
- }
- }
-
- public IterableIdentifiableCollection<Portlet> getLocalPortlets()
- {
- try
- {
- gateIn.begin();
- final FederatingPortletInvoker portletInvoker = gateIn.getPortletInvoker();
- final Set<org.gatein.pc.api.Portlet> initialLocalPortlets =
portletInvoker.getLocalPortlets();
- return new AdaptedIterableIdentifiableCollection<org.gatein.pc.api.Portlet,
Portlet>(initialLocalPortlets.size(), initialLocalPortlets.iterator())
- {
- public Portlet adapt(org.gatein.pc.api.Portlet old)
- {
- return
(Portlet)newContentFrom(GateInImpl.parsePortletId(old.getContext().getId()), old,
Portlet.class);
- }
-
- public boolean contains(Id<Portlet> t)
- {
- try
- {
- return getPortletFrom(t) != null;
- }
- catch (PortletInvokerException e)
- {
- return false;
- }
- }
- };
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- finally
- {
- gateIn.end();
- }
- }
-
- public IterableIdentifiableCollection<WSRP> getRemotePortlets()
- {
- try
- {
- gateIn.begin();
- final FederatingPortletInvoker portletInvoker = gateIn.getPortletInvoker();
- final Set<org.gatein.pc.api.Portlet> initialRemotePortlets =
portletInvoker.getRemotePortlets();
- return new AdaptedIterableIdentifiableCollection<org.gatein.pc.api.Portlet,
WSRP>(initialRemotePortlets.size(), initialRemotePortlets.iterator())
- {
- public WSRP adapt(org.gatein.pc.api.Portlet old)
- {
- return
(WSRP)newContentFrom(GateInImpl.parseWSRPPortletId(old.getContext().getId()), old,
WSRP.class);
- }
-
- public boolean contains(Id<WSRP> id)
- {
- try
- {
- return getPortletFrom(id) != null;
- }
- catch (PortletInvokerException e)
- {
- return false;
- }
- }
- };
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- finally
- {
- gateIn.end();
- }
- }
-
- public IterableIdentifiableCollection<Gadget> getGadgets()
- {
- try
- {
- gateIn.begin();
- final List<org.exoplatform.application.gadget.Gadget> initialGadgets =
gateIn.getGadgetService().getAllGadgets();
- return new
AdaptedIterableIdentifiableCollection<org.exoplatform.application.gadget.Gadget,
Gadget>(initialGadgets.size(), initialGadgets.iterator())
- {
- public Gadget adapt(org.exoplatform.application.gadget.Gadget old)
- {
- return (Gadget)newContentFrom(gateIn.gadgetId(old.getName()), old,
Gadget.class);
- }
-
- public boolean contains(Id<Gadget> id)
- {
- try
- {
- return gateIn.getGadgetService().getGadget(id.toString()) != null;
- }
- catch (Exception e)
- {
- return false;
- }
- }
- };
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- finally
- {
- gateIn.end();
- }
- }
-
- public int size()
- {
- // todo: optimize
- return getAll().size();
- }
-
- public <U extends Content> boolean contains(Id<U> id)
- {
- // todo: optimize
- return get(id) != null;
- }
-}
Copied:
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ContentRegistryImpl.java
(from rev 7030,
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ContentRegistryImpl.java)
===================================================================
---
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ContentRegistryImpl.java
(rev 0)
+++
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ContentRegistryImpl.java 2011-08-09
18:48:56 UTC (rev 7032)
@@ -0,0 +1,454 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* 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.gatein.portal.api.impl.content;
+
+import org.exoplatform.application.gadget.GadgetRegistryService;
+import org.exoplatform.application.gadget.Source;
+import org.exoplatform.application.gadget.SourceStorage;
+import org.exoplatform.application.registry.ApplicationCategory;
+import org.exoplatform.application.registry.ApplicationRegistryService;
+import org.gatein.api.content.Category;
+import org.gatein.api.content.Content;
+import org.gatein.api.content.ContentRegistry;
+import org.gatein.api.content.Gadget;
+import org.gatein.api.content.Portlet;
+import org.gatein.api.content.WSRP;
+import org.gatein.api.id.Id;
+import org.gatein.api.util.IterableCollection;
+import org.gatein.api.util.IterableIdentifiableCollection;
+import org.gatein.pc.api.PortletContext;
+import org.gatein.pc.api.PortletInvokerException;
+import org.gatein.pc.federation.FederatingPortletInvoker;
+import org.gatein.portal.api.impl.GateInImpl;
+import org.gatein.portal.api.impl.portal.PortalImpl;
+import org.gatein.portal.api.impl.util.AdaptedIterableCollection;
+import org.gatein.portal.api.impl.util.AdaptedIterableIdentifiableCollection;
+import org.gatein.portal.api.impl.util.AggregatedIterableIdentifiableCollection;
+
+import java.util.List;
+import java.util.Set;
+
+/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
+public class ContentRegistryImpl implements ContentRegistry
+{
+ private final GateInImpl gateIn;
+ private final PortalImpl portal;
+
+ public ContentRegistryImpl(GateInImpl gateIn, PortalImpl portal)
+ {
+ this.gateIn = gateIn;
+ this.portal = portal;
+ }
+
+ public Category getOrCreateCategory(String name)
+ {
+ return getOrCreateCategory(name, true);
+ }
+
+ public Category getCategory(String name)
+ {
+ return getOrCreateCategory(name, false);
+ }
+
+ public void deleteCategory(String name)
+ {
+ try
+ {
+ final ApplicationCategory category = new ApplicationCategory();
+ category.setName(name);
+ gateIn.begin();
+ gateIn.getRegistryService().remove(category);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ finally
+ {
+ gateIn.end();
+ }
+ }
+
+ public IterableCollection<String> getCategoryNames()
+ {
+ try
+ {
+ gateIn.begin();
+ final List<ApplicationCategory> categories =
gateIn.getRegistryService().getApplicationCategories();
+ return new AdaptedIterableCollection<ApplicationCategory,
String>(categories.size(), categories.iterator())
+ {
+ public String adapt(ApplicationCategory old)
+ {
+ return old.getName();
+ }
+
+ public boolean contains(String s)
+ {
+ return doesCategoryExist(s);
+ }
+ };
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ finally
+ {
+ gateIn.end();
+ }
+ }
+
+ public IterableIdentifiableCollection<Category> getAllCategories()
+ {
+ try
+ {
+ gateIn.begin();
+ final List<ApplicationCategory> categories =
gateIn.getRegistryService().getApplicationCategories();
+ return new AdaptedIterableIdentifiableCollection<ApplicationCategory,
Category>(categories.size(), categories.iterator())
+ {
+ public Category adapt(ApplicationCategory old)
+ {
+ return new CategoryImpl(old, ContentRegistryImpl.this, gateIn);
+ }
+
+ public boolean contains(Id<Category> t)
+ {
+ return doesCategoryExist(t.toString());
+ }
+ };
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ finally
+ {
+ gateIn.end();
+ }
+ }
+
+ private Category getOrCreateCategory(String name, boolean forceCreate)
+ {
+ try
+ {
+ gateIn.begin();
+ ApplicationRegistryService registryService = gateIn.getRegistryService();
+ ApplicationCategory applicationCategory =
registryService.getApplicationCategory(name);
+ if (applicationCategory == null)
+ {
+ if (forceCreate)
+ {
+ applicationCategory = new ApplicationCategory();
+ applicationCategory.setName(name);
+ applicationCategory.setDisplayName(name);
+ applicationCategory.setDescription(name);
+ registryService.save(applicationCategory);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ return new CategoryImpl(applicationCategory, this, gateIn);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ finally
+ {
+ gateIn.end();
+ }
+ }
+
+ private boolean doesCategoryExist(String name)
+ {
+ try
+ {
+ gateIn.begin();
+ return gateIn.getRegistryService().getApplicationCategory(name) != null;
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ finally
+ {
+ gateIn.end();
+ }
+ }
+
+ public <T extends Content> T get(Id<T> id)
+ {
+ Class<T> type = id.getIdentifiableType();
+ Object result;
+ Object regitryItem;
+ try
+ {
+ gateIn.begin();
+ if (Portlet.class.equals(type) || WSRP.class.equals(type))
+ {
+ regitryItem = getPortletFrom(id);
+ }
+ else if (Gadget.class.equals(type))
+ {
+ regitryItem = gateIn.getGadgetService().getGadget(id.toString());
+ }
+ else
+ {
+ throw new IllegalArgumentException("Unknown Content type: " +
type.getCanonicalName());
+ }
+
+ result = newContentFrom(id, regitryItem, type);
+ return type.cast(result);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ finally
+ {
+ gateIn.end();
+ }
+ }
+
+ private <T extends Content> Object getPortletFrom(Id<T> id) throws
PortletInvokerException
+ {
+ PortletContext portletContext;
+ Object regitryItem;
+ if (!id.knowsComponent(GateInImpl.INVOKER_COMPONENT))
+ {
+ portletContext =
PortletContext.createPortletContext(id.getComponent(GateInImpl.APPLICATION_COMPONENT),
id.getComponent(GateInImpl.PORTLET_COMPONENT));
+ regitryItem =
gateIn.getPortletInvoker().getFederatedInvoker("local").getPortletInvoker().getPortlet(portletContext);
+ }
+ else
+ {
+ portletContext = PortletContext.createPortletContext(id.toString());
+ regitryItem = gateIn.getPortletInvoker().getPortlet(portletContext);
+ }
+ return regitryItem;
+ }
+
+ private <T extends Content> Content newContentFrom(Id id, Object registryItem,
Class<T> wanted)
+ {
+ Object result;
+ if (Portlet.class.equals(wanted))
+ {
+ result = new PortletImpl((Id<Portlet>)id,
(org.gatein.pc.api.Portlet)registryItem, gateIn);
+ }
+ else if (Gadget.class.equals(wanted))
+ {
+ result = new GadgetImpl((Id<Gadget>)id,
(org.exoplatform.application.gadget.Gadget)registryItem, gateIn);
+ }
+ else if (WSRP.class.equals(wanted))
+ {
+ result = new WSRPImpl((Id<WSRP>)id,
(org.gatein.pc.api.Portlet)registryItem, gateIn);
+ }
+ else
+ {
+ throw new IllegalArgumentException("Unknown Content type: " +
wanted.getCanonicalName());
+ }
+
+ return wanted.cast(result);
+ }
+
+ public Gadget createGadget(String gadget, String source)
+ {
+ try
+ {
+ gateIn.begin();
+ final GadgetRegistryService gadgetService = gateIn.getGadgetService();
+ org.exoplatform.application.gadget.Gadget original =
gadgetService.getGadget(gadget);
+ if (original == null)
+ {
+ original = new org.exoplatform.application.gadget.Gadget();
+ original.setName(gadget);
+ original.setUrl("http://www.gatein.org"); // todo: fix me
+ gadgetService.saveGadget(original);
+ }
+
+ SourceStorage sourceStorage = gateIn.getSourceStorage();
+ Source originalSource = sourceStorage.getSource(original);
+ originalSource.setTextContent(source);
+ sourceStorage.saveSource(original, originalSource);
+
+ return (Gadget)newContentFrom(gateIn.gadgetId(gadget), original, Gadget.class);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ finally
+ {
+ gateIn.end();
+ }
+ }
+
+ public IterableIdentifiableCollection<Content> getAll()
+ {
+ try
+ {
+ gateIn.begin();
+ IterableIdentifiableCollection<? extends Content> localPortlets =
getLocalPortlets();
+ IterableIdentifiableCollection<? extends Content> gadgets = getGadgets();
+ IterableIdentifiableCollection<? extends Content> remotePortlets =
getRemotePortlets();
+
+ final AggregatedIterableIdentifiableCollection result = new
AggregatedIterableIdentifiableCollection();
+ result.addCollection(localPortlets);
+ result.addCollection(remotePortlets);
+ result.addCollection(gadgets);
+ return result;
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ finally
+ {
+ gateIn.end();
+ }
+ }
+
+ public IterableIdentifiableCollection<Portlet> getLocalPortlets()
+ {
+ try
+ {
+ gateIn.begin();
+ final FederatingPortletInvoker portletInvoker = gateIn.getPortletInvoker();
+ final Set<org.gatein.pc.api.Portlet> initialLocalPortlets =
portletInvoker.getLocalPortlets();
+ return new AdaptedIterableIdentifiableCollection<org.gatein.pc.api.Portlet,
Portlet>(initialLocalPortlets.size(), initialLocalPortlets.iterator())
+ {
+ public Portlet adapt(org.gatein.pc.api.Portlet old)
+ {
+ return
(Portlet)newContentFrom(GateInImpl.parsePortletId(old.getContext().getId()), old,
Portlet.class);
+ }
+
+ public boolean contains(Id<Portlet> t)
+ {
+ try
+ {
+ return getPortletFrom(t) != null;
+ }
+ catch (PortletInvokerException e)
+ {
+ return false;
+ }
+ }
+ };
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ finally
+ {
+ gateIn.end();
+ }
+ }
+
+ public IterableIdentifiableCollection<WSRP> getRemotePortlets()
+ {
+ try
+ {
+ gateIn.begin();
+ final FederatingPortletInvoker portletInvoker = gateIn.getPortletInvoker();
+ final Set<org.gatein.pc.api.Portlet> initialRemotePortlets =
portletInvoker.getRemotePortlets();
+ return new AdaptedIterableIdentifiableCollection<org.gatein.pc.api.Portlet,
WSRP>(initialRemotePortlets.size(), initialRemotePortlets.iterator())
+ {
+ public WSRP adapt(org.gatein.pc.api.Portlet old)
+ {
+ return
(WSRP)newContentFrom(GateInImpl.parseWSRPPortletId(old.getContext().getId()), old,
WSRP.class);
+ }
+
+ public boolean contains(Id<WSRP> id)
+ {
+ try
+ {
+ return getPortletFrom(id) != null;
+ }
+ catch (PortletInvokerException e)
+ {
+ return false;
+ }
+ }
+ };
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ finally
+ {
+ gateIn.end();
+ }
+ }
+
+ public IterableIdentifiableCollection<Gadget> getGadgets()
+ {
+ try
+ {
+ gateIn.begin();
+ final List<org.exoplatform.application.gadget.Gadget> initialGadgets =
gateIn.getGadgetService().getAllGadgets();
+ return new
AdaptedIterableIdentifiableCollection<org.exoplatform.application.gadget.Gadget,
Gadget>(initialGadgets.size(), initialGadgets.iterator())
+ {
+ public Gadget adapt(org.exoplatform.application.gadget.Gadget old)
+ {
+ return (Gadget)newContentFrom(gateIn.gadgetId(old.getName()), old,
Gadget.class);
+ }
+
+ public boolean contains(Id<Gadget> id)
+ {
+ try
+ {
+ return gateIn.getGadgetService().getGadget(id.toString()) != null;
+ }
+ catch (Exception e)
+ {
+ return false;
+ }
+ }
+ };
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ finally
+ {
+ gateIn.end();
+ }
+ }
+
+ public int size()
+ {
+ // todo: optimize
+ return getAll().size();
+ }
+
+ public <U extends Content> boolean contains(Id<U> id)
+ {
+ // todo: optimize
+ return get(id) != null;
+ }
+}
Deleted:
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/GadgetImpl.java
===================================================================
---
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/GadgetImpl.java 2011-08-09
13:52:09 UTC (rev 7030)
+++
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/GadgetImpl.java 2011-08-09
18:48:56 UTC (rev 7032)
@@ -1,134 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* 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.gatein.portal.api.impl.content;
-
-import org.exoplatform.application.gadget.Gadget;
-import org.exoplatform.application.gadget.Source;
-import org.gatein.api.content.Content;
-import org.gatein.api.id.Id;
-import org.gatein.api.util.Type;
-import org.gatein.portal.api.impl.GateInImpl;
-import org.gatein.portal.api.impl.IdentifiableImpl;
-
-import java.net.URI;
-
-/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
-public class GadgetImpl extends IdentifiableImpl<org.gatein.api.content.Gadget>
implements org.gatein.api.content.Gadget
-{
- private final Gadget gadget;
-
- public GadgetImpl(Id<org.gatein.api.content.Gadget> id, Gadget gadget,
GateInImpl gateIn)
- {
- super(id, gadget.getName(), gateIn);
- this.gadget = gadget;
- }
-
- @Override
- public String toString()
- {
- return (isLocal() ? "Local " : "") + "Gadget '" +
getName() + "' @" + getId() + " URI: " + getURI();
- }
-
- public URI getReferenceURI()
- {
- return URI.create(gadget.getReferenceUrl());
- }
-
- public URI getURI()
- {
- return URI.create(gadget.getUrl());
- }
-
- public Data getData()
- {
- if (isLocal())
- {
- return new LocalData()
- {
-
- public String getSource()
- {
- try
- {
- return GadgetImpl.this.getSource().getTextContent();
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- }
-
- public void setSource(String source)
- {
- Source initial = GadgetImpl.this.getSource();
- try
- {
- initial.setTextContent(source);
- getGateInImpl().getSourceStorage().saveSource(gadget, initial);
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- }
- };
- }
- else
- {
- return new RemoteData()
- {
- public URI getURI()
- {
- return GadgetImpl.this.getURI();
- }
-
- public void setURI(URI uri)
- {
- gadget.setUrl(uri.toString());
- }
- };
- }
- }
-
- private Source getSource()
- {
- try
- {
- return getGateInImpl().getSourceStorage().getSource(gadget);
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- }
-
- public boolean isLocal()
- {
- return gadget.isLocal();
- }
-
- public Type<org.gatein.api.content.Gadget> getType()
- {
- return Content.GADGET;
- }
-}
Copied:
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/GadgetImpl.java
(from rev 7030,
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/GadgetImpl.java)
===================================================================
---
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/GadgetImpl.java
(rev 0)
+++
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/GadgetImpl.java 2011-08-09
18:48:56 UTC (rev 7032)
@@ -0,0 +1,134 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* 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.gatein.portal.api.impl.content;
+
+import org.exoplatform.application.gadget.Gadget;
+import org.exoplatform.application.gadget.Source;
+import org.gatein.api.content.Content;
+import org.gatein.api.id.Id;
+import org.gatein.api.util.Type;
+import org.gatein.portal.api.impl.GateInImpl;
+import org.gatein.portal.api.impl.IdentifiableImpl;
+
+import java.net.URI;
+
+/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
+public class GadgetImpl extends IdentifiableImpl<org.gatein.api.content.Gadget>
implements org.gatein.api.content.Gadget
+{
+ private final Gadget gadget;
+
+ public GadgetImpl(Id<org.gatein.api.content.Gadget> id, Gadget gadget,
GateInImpl gateIn)
+ {
+ super(id, gadget.getName(), gateIn);
+ this.gadget = gadget;
+ }
+
+ @Override
+ public String toString()
+ {
+ return (isLocal() ? "Local " : "") + "Gadget '" +
getName() + "' @" + getId() + " URI: " + getURI();
+ }
+
+ public URI getReferenceURI()
+ {
+ return URI.create(gadget.getReferenceUrl());
+ }
+
+ public URI getURI()
+ {
+ return URI.create(gadget.getUrl());
+ }
+
+ public Data getData()
+ {
+ if (isLocal())
+ {
+ return new LocalData()
+ {
+
+ public String getSource()
+ {
+ try
+ {
+ return GadgetImpl.this.getSource().getTextContent();
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public void setSource(String source)
+ {
+ Source initial = GadgetImpl.this.getSource();
+ try
+ {
+ initial.setTextContent(source);
+ getGateInImpl().getSourceStorage().saveSource(gadget, initial);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+ };
+ }
+ else
+ {
+ return new RemoteData()
+ {
+ public URI getURI()
+ {
+ return GadgetImpl.this.getURI();
+ }
+
+ public void setURI(URI uri)
+ {
+ gadget.setUrl(uri.toString());
+ }
+ };
+ }
+ }
+
+ private Source getSource()
+ {
+ try
+ {
+ return getGateInImpl().getSourceStorage().getSource(gadget);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public boolean isLocal()
+ {
+ return gadget.isLocal();
+ }
+
+ public Type<org.gatein.api.content.Gadget> getType()
+ {
+ return Content.GADGET;
+ }
+}
Deleted:
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ManagedContentImpl.java
===================================================================
---
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ManagedContentImpl.java 2011-08-09
13:52:09 UTC (rev 7030)
+++
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ManagedContentImpl.java 2011-08-09
18:48:56 UTC (rev 7032)
@@ -1,121 +0,0 @@
-/*
- * JBoss, a division of Red Hat
- * Copyright 2011, Red Hat Middleware, LLC, and individual
- * contributors as indicated by the @authors tag. See the
- * copyright.txt in the distribution for a full listing of
- * individual contributors.
- *
- * 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.gatein.portal.api.impl.content;
-
-import org.exoplatform.application.registry.Application;
-import org.gatein.api.content.Content;
-import org.gatein.api.content.ManagedContent;
-import org.gatein.api.id.Id;
-import org.gatein.portal.api.impl.GateInImpl;
-
-/**
- * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
- * @version $Revision$
- */
-public class ManagedContentImpl<T extends Content> implements
ManagedContent<T>
-{
- private T content;
- private final Id<T> contentId;
- private final Id<ManagedContent<T>> id;
- private final CategoryImpl category;
- private final Application application;
-
- ManagedContentImpl(String name, Id contentId, Application application, CategoryImpl
category)
- {
- this.contentId = contentId;
- this.id = category.getGateIn().managedContentId(category.getId(), name,
contentId);
- this.category = category;
- this.application = application;
- }
-
- @Override
- public String toString()
- {
- return "ManagedContent '" + getName() + "' =>" +
getContent();
- }
-
- public Id<ManagedContent<T>> getId()
- {
- return id;
- }
-
- public String getName()
- {
- return application.getApplicationName();
- }
-
- public String getDisplayName()
- {
- return application.getDisplayName();
- }
-
- public void setDisplayName(String displayName)
- {
- application.setDisplayName(displayName);
- save();
- }
-
- public String getDescription()
- {
- return application.getDescription();
- }
-
- public void setDescription(String description)
- {
- application.setDescription(description);
- save();
- }
-
- public GateInImpl getGateIn()
- {
- return category.getGateIn();
- }
-
- public T getContent()
- {
- if (content == null)
- {
- content = category.getRegistry().get(contentId);
- }
-
- return content;
- }
-
- private void save()
- {
- try
- {
- getGateIn().begin();
- getGateIn().getRegistryService().update(application);
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- finally
- {
- getGateIn().end();
- }
- }
-}
Copied:
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ManagedContentImpl.java
(from rev 7030,
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ManagedContentImpl.java)
===================================================================
---
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ManagedContentImpl.java
(rev 0)
+++
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ManagedContentImpl.java 2011-08-09
18:48:56 UTC (rev 7032)
@@ -0,0 +1,121 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2011, Red Hat Middleware, LLC, and individual
+ * contributors as indicated by the @authors tag. See the
+ * copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * 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.gatein.portal.api.impl.content;
+
+import org.exoplatform.application.registry.Application;
+import org.gatein.api.content.Content;
+import org.gatein.api.content.ManagedContent;
+import org.gatein.api.id.Id;
+import org.gatein.portal.api.impl.GateInImpl;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ */
+public class ManagedContentImpl<T extends Content> implements
ManagedContent<T>
+{
+ private T content;
+ private final Id<T> contentId;
+ private final Id<ManagedContent<T>> id;
+ private final CategoryImpl category;
+ private final Application application;
+
+ ManagedContentImpl(String name, Id contentId, Application application, CategoryImpl
category)
+ {
+ this.contentId = contentId;
+ this.id = category.getGateIn().managedContentId(category.getId(), name,
contentId);
+ this.category = category;
+ this.application = application;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "ManagedContent '" + getName() + "' =>" +
getContent();
+ }
+
+ public Id<ManagedContent<T>> getId()
+ {
+ return id;
+ }
+
+ public String getName()
+ {
+ return application.getApplicationName();
+ }
+
+ public String getDisplayName()
+ {
+ return application.getDisplayName();
+ }
+
+ public void setDisplayName(String displayName)
+ {
+ application.setDisplayName(displayName);
+ save();
+ }
+
+ public String getDescription()
+ {
+ return application.getDescription();
+ }
+
+ public void setDescription(String description)
+ {
+ application.setDescription(description);
+ save();
+ }
+
+ public GateInImpl getGateIn()
+ {
+ return category.getGateIn();
+ }
+
+ public T getContent()
+ {
+ if (content == null)
+ {
+ content = category.getRegistry().get(contentId);
+ }
+
+ return content;
+ }
+
+ private void save()
+ {
+ try
+ {
+ getGateIn().begin();
+ getGateIn().getRegistryService().update(application);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ finally
+ {
+ getGateIn().end();
+ }
+ }
+}
Deleted:
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/PortletImpl.java
===================================================================
---
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/PortletImpl.java 2011-08-09
13:52:09 UTC (rev 7030)
+++
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/PortletImpl.java 2011-08-09
18:48:56 UTC (rev 7032)
@@ -1,43 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* 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.gatein.portal.api.impl.content;
-
-import org.gatein.api.content.Content;
-import org.gatein.api.content.Portlet;
-import org.gatein.api.id.Id;
-import org.gatein.api.util.Type;
-import org.gatein.portal.api.impl.GateInImpl;
-
-/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
-public class PortletImpl extends AbstractPortlet<Portlet> implements Portlet
-{
- public PortletImpl(Id<Portlet> id, org.gatein.pc.api.Portlet application,
GateInImpl gateIn)
- {
- super(id, application, gateIn);
- }
-
- public Type<Portlet> getType()
- {
- return Content.PORTLET;
- }
-}
Copied:
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/PortletImpl.java
(from rev 7030,
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/PortletImpl.java)
===================================================================
---
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/PortletImpl.java
(rev 0)
+++
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/PortletImpl.java 2011-08-09
18:48:56 UTC (rev 7032)
@@ -0,0 +1,43 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* 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.gatein.portal.api.impl.content;
+
+import org.gatein.api.content.Content;
+import org.gatein.api.content.Portlet;
+import org.gatein.api.id.Id;
+import org.gatein.api.util.Type;
+import org.gatein.portal.api.impl.GateInImpl;
+
+/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
+public class PortletImpl extends AbstractPortlet<Portlet> implements Portlet
+{
+ public PortletImpl(Id<Portlet> id, org.gatein.pc.api.Portlet application,
GateInImpl gateIn)
+ {
+ super(id, application, gateIn);
+ }
+
+ public Type<Portlet> getType()
+ {
+ return Content.PORTLET;
+ }
+}
Deleted:
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/WSRPImpl.java
===================================================================
---
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/WSRPImpl.java 2011-08-09
13:52:09 UTC (rev 7030)
+++
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/WSRPImpl.java 2011-08-09
18:48:56 UTC (rev 7032)
@@ -1,43 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* 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.gatein.portal.api.impl.content;
-
-import org.gatein.api.content.Content;
-import org.gatein.api.content.WSRP;
-import org.gatein.api.id.Id;
-import org.gatein.api.util.Type;
-import org.gatein.portal.api.impl.GateInImpl;
-
-/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
-public class WSRPImpl extends AbstractPortlet<WSRP> implements WSRP
-{
- public WSRPImpl(Id<WSRP> id, org.gatein.pc.api.Portlet application, GateInImpl
gateIn)
- {
- super(id, application, gateIn);
- }
-
- public Type<WSRP> getType()
- {
- return Content.WSRP;
- }
-}
Copied:
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/WSRPImpl.java
(from rev 7030,
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/WSRPImpl.java)
===================================================================
---
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/WSRPImpl.java
(rev 0)
+++
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/WSRPImpl.java 2011-08-09
18:48:56 UTC (rev 7032)
@@ -0,0 +1,43 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* 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.gatein.portal.api.impl.content;
+
+import org.gatein.api.content.Content;
+import org.gatein.api.content.WSRP;
+import org.gatein.api.id.Id;
+import org.gatein.api.util.Type;
+import org.gatein.portal.api.impl.GateInImpl;
+
+/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
+public class WSRPImpl extends AbstractPortlet<WSRP> implements WSRP
+{
+ public WSRPImpl(Id<WSRP> id, org.gatein.pc.api.Portlet application, GateInImpl
gateIn)
+ {
+ super(id, application, gateIn);
+ }
+
+ public Type<WSRP> getType()
+ {
+ return Content.WSRP;
+ }
+}
Deleted:
portal/trunk/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-09
13:52:09 UTC (rev 7030)
+++
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/id/ComplexApplicationContext.java 2011-08-09
18:48:56 UTC (rev 7032)
@@ -1,128 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* 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.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 static final Context INSTANCE = new ComplexApplicationContext();
-
- public String getName()
- {
- return "Application with prefixed invoker id";
- }
-
- public Id create(String rootComponent, String... additionalComponent)
- {
- return create(Identifiable.class, rootComponent, additionalComponent);
- }
-
- public <T extends Identifiable> Id<T> create(Class<T> type, String
rootComponent, String... additionalComponents)
- {
- if (!type.isAssignableFrom(Portlet.class))
- {
- throw new IllegalArgumentException("ComplexApplicationContext can only
create Id<Portlet>. Was asked to create Id<" + type.getSimpleName() +
">");
- }
-
- if (additionalComponents != null && additionalComponents.length == 3)
- {
- return (Id<T>)new ComplexApplicationId(rootComponent,
additionalComponents[0], additionalComponents[1], additionalComponents[2], this);
- }
- else
- {
- throw new IllegalArgumentException("ComplexApplicationContext can only
create Ids with 3 components: category name, application name and portlet name");
- }
- }
-
- public Id parse(String idAsString)
- {
- return parse(idAsString, Identifiable.class);
- }
-
- public <U extends Identifiable<U>> Id<U> parse(String idAsString,
Class<U> expectedType)
- {
- final int index = idAsString.indexOf(ComplexApplicationId.START);
- if (index < 0)
- {
- throw new IllegalArgumentException("'" + idAsString + "'
cannot be understood by ComplexApplicationContext. Understood format is
'{category/}local.(_|/)applicationName.portletName'");
- }
-
- String category;
- if (index == 0)
- {
- // we're in the regular portletcontext case:
local./applicationName.portletName
- category = null;
- }
- else
- {
- // we're in the application registry imported portlet:
category/local._applicationName.portletName
- category = idAsString.substring(0, idAsString.indexOf('/'));
- }
-
- final int length = ComplexApplicationId.START.length();
- final int sepIndex = idAsString.indexOf('.', index + length);
- String separator = idAsString.substring(index + length, index + length + 1);
- String app = idAsString.substring(index + length + 1, sepIndex);
- String portlet = idAsString.substring(sepIndex + 1);
-
- return create(expectedType, category, app, portlet, separator);
- }
-
- public String toString(Id id)
- {
- if (id instanceof ComplexApplicationId)
- {
- return id.toString();
- }
- else
- {
- throw new IllegalArgumentException("ComplexApplicationContext cannot handle
Ids that are not ComplexApplicationIds");
- }
- }
-
- public boolean isComponentRequired(String component)
- {
- return !GateInImpl.CATEGORY_COMPONENT.equals(component);
- }
-
- public boolean isComponentUnboundedHierarchical(String component)
- {
- return false; // no components are hierarchical
- }
-
- public boolean hasComponent(String component)
- {
- return GateInImpl.APPLICATION_COMPONENT.equals(component) ||
GateInImpl.PORTLET_COMPONENT.equals(component) ||
GateInImpl.CATEGORY_COMPONENT.equals(component) ||
GateInImpl.INVOKER_COMPONENT.equals(component);
- }
-
- public void validateValueFor(String component, String value) throws
IllegalArgumentException
- {
- // todo
- }
-}
Copied:
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/id/ComplexApplicationContext.java
(from rev 7030,
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/id/ComplexApplicationContext.java)
===================================================================
---
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/id/ComplexApplicationContext.java
(rev 0)
+++
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/id/ComplexApplicationContext.java 2011-08-09
18:48:56 UTC (rev 7032)
@@ -0,0 +1,128 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* 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.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 static final Context INSTANCE = new ComplexApplicationContext();
+
+ public String getName()
+ {
+ return "Application with prefixed invoker id";
+ }
+
+ public Id create(String rootComponent, String... additionalComponent)
+ {
+ return create(Identifiable.class, rootComponent, additionalComponent);
+ }
+
+ public <T extends Identifiable> Id<T> create(Class<T> type, String
rootComponent, String... additionalComponents)
+ {
+ if (!type.isAssignableFrom(Portlet.class))
+ {
+ throw new IllegalArgumentException("ComplexApplicationContext can only
create Id<Portlet>. Was asked to create Id<" + type.getSimpleName() +
">");
+ }
+
+ if (additionalComponents != null && additionalComponents.length == 3)
+ {
+ return (Id<T>)new ComplexApplicationId(rootComponent,
additionalComponents[0], additionalComponents[1], additionalComponents[2], this);
+ }
+ else
+ {
+ throw new IllegalArgumentException("ComplexApplicationContext can only
create Ids with 3 components: category name, application name and portlet name");
+ }
+ }
+
+ public Id parse(String idAsString)
+ {
+ return parse(idAsString, Identifiable.class);
+ }
+
+ public <U extends Identifiable<U>> Id<U> parse(String idAsString,
Class<U> expectedType)
+ {
+ final int index = idAsString.indexOf(ComplexApplicationId.START);
+ if (index < 0)
+ {
+ throw new IllegalArgumentException("'" + idAsString + "'
cannot be understood by ComplexApplicationContext. Understood format is
'{category/}local.(_|/)applicationName.portletName'");
+ }
+
+ String category;
+ if (index == 0)
+ {
+ // we're in the regular portletcontext case:
local./applicationName.portletName
+ category = null;
+ }
+ else
+ {
+ // we're in the application registry imported portlet:
category/local._applicationName.portletName
+ category = idAsString.substring(0, idAsString.indexOf('/'));
+ }
+
+ final int length = ComplexApplicationId.START.length();
+ final int sepIndex = idAsString.indexOf('.', index + length);
+ String separator = idAsString.substring(index + length, index + length + 1);
+ String app = idAsString.substring(index + length + 1, sepIndex);
+ String portlet = idAsString.substring(sepIndex + 1);
+
+ return create(expectedType, category, app, portlet, separator);
+ }
+
+ public String toString(Id id)
+ {
+ if (id instanceof ComplexApplicationId)
+ {
+ return id.toString();
+ }
+ else
+ {
+ throw new IllegalArgumentException("ComplexApplicationContext cannot handle
Ids that are not ComplexApplicationIds");
+ }
+ }
+
+ public boolean isComponentRequired(String component)
+ {
+ return !GateInImpl.CATEGORY_COMPONENT.equals(component);
+ }
+
+ public boolean isComponentUnboundedHierarchical(String component)
+ {
+ return false; // no components are hierarchical
+ }
+
+ public boolean hasComponent(String component)
+ {
+ return GateInImpl.APPLICATION_COMPONENT.equals(component) ||
GateInImpl.PORTLET_COMPONENT.equals(component) ||
GateInImpl.CATEGORY_COMPONENT.equals(component) ||
GateInImpl.INVOKER_COMPONENT.equals(component);
+ }
+
+ public void validateValueFor(String component, String value) throws
IllegalArgumentException
+ {
+ // todo
+ }
+}
Deleted:
portal/trunk/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-09
13:52:09 UTC (rev 7030)
+++
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/id/ComplexApplicationId.java 2011-08-09
18:48:56 UTC (rev 7032)
@@ -1,190 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* 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.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> */
-public class ComplexApplicationId implements Id<Portlet>
-{
- public static final String LOCAL = "local";
- public static final String START = LOCAL + ".";
- private final String category;
- private final String app;
- private final String portlet;
- private final Context context;
- private final String separator;
-
- public ComplexApplicationId(String category, String appName, String portletName,
String separator, ComplexApplicationContext context)
- {
- this.category = category;
- this.app = appName;
- this.portlet = portletName;
- this.context = context;
- this.separator = separator;
- }
-
- @Override
- public String toString()
- {
- return toString(context);
- }
-
- public String toString(RenderingContext context)
- {
- if (this.context.equals(context))
- {
- if ("/".equals(separator))
- {
- // we're in the regular portletcontext case:
local./applicationName.portletName
- return START + separator + app + '.' + portlet;
- }
- else
- {
- // we're in the application registry imported portlet:
category/local._applicationName.portletName
- return category + '/' + START + separator + app + '.' +
portlet;
- }
- }
- else
- {
- throw new IllegalArgumentException("ComplexApplicationIds can only be
rendered by ComplexApplicationContext at the moment.");
- }
- }
-
- @Override
- public boolean equals(Object o)
- {
- if (this == o)
- {
- return true;
- }
- if (o == null || getClass() != o.getClass())
- {
- return false;
- }
-
- ComplexApplicationId that = (ComplexApplicationId)o;
-
- if (!app.equals(that.app))
- {
- return false;
- }
- if (category != null ? !category.equals(that.category) : that.category != null)
- {
- return false;
- }
- if (!portlet.equals(that.portlet))
- {
- return false;
- }
-
- return true;
- }
-
- @Override
- public int hashCode()
- {
- int result = category != null ? category.hashCode() : 0;
- result = 31 * result + app.hashCode();
- result = 31 * result + portlet.hashCode();
- return result;
- }
-
- public Class<Portlet> getIdentifiableType()
- {
- return Portlet.class;
- }
-
- public Id getIdForChild(String childId)
- {
- throw new IllegalArgumentException("ComplexApplicationId doesn't currently
allow children Ids.");
- }
-
- public String getComponent(String component)
- {
- if (GateInImpl.APPLICATION_COMPONENT.equals(component))
- {
- return app;
- }
- else if (GateInImpl.PORTLET_COMPONENT.equals(component))
- {
- return portlet;
- }
- else if (GateInImpl.INVOKER_COMPONENT.equals(component))
- {
- return LOCAL;
- }
- else if (GateInImpl.CATEGORY_COMPONENT.equals(component))
- {
- return category;
- }
- else
- {
- throw new IllegalArgumentException("Unknown component '" +
component + "' for ComplexApplicationId");
- }
- }
-
- public Context getOriginalContext()
- {
- return context;
- }
-
- public int getComponentNumber()
- {
- return 4;
- }
-
- public String getRootComponent()
- {
- return LOCAL;
- }
-
- public Id getParent()
- {
- return null;
- }
-
- public String[] getComponents()
- {
- return new String[]{category, LOCAL, app, portlet};
- }
-
- public void associateComponentWith(int componentIndex, String name)
- {
- // do nothing as it shouldn't be called
- }
-
- public boolean knowsComponent(String name)
- {
- return context.hasComponent(name);
- }
-
- public int compareTo(Id o)
- {
- return toString().compareTo(o.toString());
- }
-}
Copied:
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/id/ComplexApplicationId.java
(from rev 7030,
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/id/ComplexApplicationId.java)
===================================================================
---
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/id/ComplexApplicationId.java
(rev 0)
+++
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/id/ComplexApplicationId.java 2011-08-09
18:48:56 UTC (rev 7032)
@@ -0,0 +1,190 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* 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.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> */
+public class ComplexApplicationId implements Id<Portlet>
+{
+ public static final String LOCAL = "local";
+ public static final String START = LOCAL + ".";
+ private final String category;
+ private final String app;
+ private final String portlet;
+ private final Context context;
+ private final String separator;
+
+ public ComplexApplicationId(String category, String appName, String portletName,
String separator, ComplexApplicationContext context)
+ {
+ this.category = category;
+ this.app = appName;
+ this.portlet = portletName;
+ this.context = context;
+ this.separator = separator;
+ }
+
+ @Override
+ public String toString()
+ {
+ return toString(context);
+ }
+
+ public String toString(RenderingContext context)
+ {
+ if (this.context.equals(context))
+ {
+ if ("/".equals(separator))
+ {
+ // we're in the regular portletcontext case:
local./applicationName.portletName
+ return START + separator + app + '.' + portlet;
+ }
+ else
+ {
+ // we're in the application registry imported portlet:
category/local._applicationName.portletName
+ return category + '/' + START + separator + app + '.' +
portlet;
+ }
+ }
+ else
+ {
+ throw new IllegalArgumentException("ComplexApplicationIds can only be
rendered by ComplexApplicationContext at the moment.");
+ }
+ }
+
+ @Override
+ public boolean equals(Object o)
+ {
+ if (this == o)
+ {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass())
+ {
+ return false;
+ }
+
+ ComplexApplicationId that = (ComplexApplicationId)o;
+
+ if (!app.equals(that.app))
+ {
+ return false;
+ }
+ if (category != null ? !category.equals(that.category) : that.category != null)
+ {
+ return false;
+ }
+ if (!portlet.equals(that.portlet))
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int result = category != null ? category.hashCode() : 0;
+ result = 31 * result + app.hashCode();
+ result = 31 * result + portlet.hashCode();
+ return result;
+ }
+
+ public Class<Portlet> getIdentifiableType()
+ {
+ return Portlet.class;
+ }
+
+ public Id getIdForChild(String childId)
+ {
+ throw new IllegalArgumentException("ComplexApplicationId doesn't currently
allow children Ids.");
+ }
+
+ public String getComponent(String component)
+ {
+ if (GateInImpl.APPLICATION_COMPONENT.equals(component))
+ {
+ return app;
+ }
+ else if (GateInImpl.PORTLET_COMPONENT.equals(component))
+ {
+ return portlet;
+ }
+ else if (GateInImpl.INVOKER_COMPONENT.equals(component))
+ {
+ return LOCAL;
+ }
+ else if (GateInImpl.CATEGORY_COMPONENT.equals(component))
+ {
+ return category;
+ }
+ else
+ {
+ throw new IllegalArgumentException("Unknown component '" +
component + "' for ComplexApplicationId");
+ }
+ }
+
+ public Context getOriginalContext()
+ {
+ return context;
+ }
+
+ public int getComponentNumber()
+ {
+ return 4;
+ }
+
+ public String getRootComponent()
+ {
+ return LOCAL;
+ }
+
+ public Id getParent()
+ {
+ return null;
+ }
+
+ public String[] getComponents()
+ {
+ return new String[]{category, LOCAL, app, portlet};
+ }
+
+ public void associateComponentWith(int componentIndex, String name)
+ {
+ // do nothing as it shouldn't be called
+ }
+
+ public boolean knowsComponent(String name)
+ {
+ return context.hasComponent(name);
+ }
+
+ public int compareTo(Id o)
+ {
+ return toString().compareTo(o.toString());
+ }
+}
Deleted:
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/lifecycle/NoOpLifecycleManager.java
===================================================================
---
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/lifecycle/NoOpLifecycleManager.java 2011-08-09
13:52:09 UTC (rev 7030)
+++
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/lifecycle/NoOpLifecycleManager.java 2011-08-09
18:48:56 UTC (rev 7032)
@@ -1,40 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* 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.gatein.portal.api.impl.lifecycle;
-
-import org.gatein.portal.api.impl.LifecycleManager;
-
-/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
-public class NoOpLifecycleManager implements LifecycleManager
-{
-
- public void begin()
- {
- // do nothing
- }
-
- public void end()
- {
- // do nothing
- }
-}
Copied:
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/lifecycle/NoOpLifecycleManager.java
(from rev 7030,
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/lifecycle/NoOpLifecycleManager.java)
===================================================================
---
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/lifecycle/NoOpLifecycleManager.java
(rev 0)
+++
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/lifecycle/NoOpLifecycleManager.java 2011-08-09
18:48:56 UTC (rev 7032)
@@ -0,0 +1,40 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* 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.gatein.portal.api.impl.lifecycle;
+
+import org.gatein.portal.api.impl.LifecycleManager;
+
+/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
+public class NoOpLifecycleManager implements LifecycleManager
+{
+
+ public void begin()
+ {
+ // do nothing
+ }
+
+ public void end()
+ {
+ // do nothing
+ }
+}
Deleted:
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/lifecycle/RequestLifecycleManager.java
===================================================================
---
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/lifecycle/RequestLifecycleManager.java 2011-08-09
13:52:09 UTC (rev 7030)
+++
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/lifecycle/RequestLifecycleManager.java 2011-08-09
18:48:56 UTC (rev 7032)
@@ -1,48 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* 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.gatein.portal.api.impl.lifecycle;
-
-import org.exoplatform.container.ExoContainer;
-import org.exoplatform.container.component.RequestLifeCycle;
-import org.gatein.portal.api.impl.LifecycleManager;
-
-/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
-public class RequestLifecycleManager implements LifecycleManager
-{
- private final ExoContainer container;
-
- public RequestLifecycleManager(ExoContainer container)
- {
- this.container = container;
- }
-
- public void begin()
- {
- RequestLifeCycle.begin(container);
- }
-
- public void end()
- {
- RequestLifeCycle.end();
- }
-}
Copied:
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/lifecycle/RequestLifecycleManager.java
(from rev 7030,
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/lifecycle/RequestLifecycleManager.java)
===================================================================
---
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/lifecycle/RequestLifecycleManager.java
(rev 0)
+++
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/lifecycle/RequestLifecycleManager.java 2011-08-09
18:48:56 UTC (rev 7032)
@@ -0,0 +1,48 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* 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.gatein.portal.api.impl.lifecycle;
+
+import org.exoplatform.container.ExoContainer;
+import org.exoplatform.container.component.RequestLifeCycle;
+import org.gatein.portal.api.impl.LifecycleManager;
+
+/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
+public class RequestLifecycleManager implements LifecycleManager
+{
+ private final ExoContainer container;
+
+ public RequestLifecycleManager(ExoContainer container)
+ {
+ this.container = container;
+ }
+
+ public void begin()
+ {
+ RequestLifeCycle.begin(container);
+ }
+
+ public void end()
+ {
+ RequestLifeCycle.end();
+ }
+}
Deleted:
portal/trunk/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-09
13:52:09 UTC (rev 7030)
+++
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/DashboardSiteImpl.java 2011-08-09
18:48:56 UTC (rev 7032)
@@ -1,49 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* 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.gatein.portal.api.impl.portal;
-
-import org.exoplatform.portal.mop.SiteKey;
-import org.gatein.api.id.Id;
-import org.gatein.api.portal.Site;
-import org.gatein.api.util.Type;
-import org.gatein.portal.api.impl.GateInImpl;
-
-/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
-public class DashboardSiteImpl extends SiteImpl
-{
- public DashboardSiteImpl(Id<? extends Site> siteId, String name, GateInImpl
gateIn)
- {
- super(siteId, name, gateIn);
- }
-
- @Override
- protected SiteKey getSiteKey()
- {
- return SiteKey.user(getName());
- }
-
- public Type getType()
- {
- return Site.DASHBOARD;
- }
-}
Copied:
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/DashboardSiteImpl.java
(from rev 7030,
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/DashboardSiteImpl.java)
===================================================================
---
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/DashboardSiteImpl.java
(rev 0)
+++
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/DashboardSiteImpl.java 2011-08-09
18:48:56 UTC (rev 7032)
@@ -0,0 +1,49 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* 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.gatein.portal.api.impl.portal;
+
+import org.exoplatform.portal.mop.SiteKey;
+import org.gatein.api.id.Id;
+import org.gatein.api.portal.Site;
+import org.gatein.api.util.Type;
+import org.gatein.portal.api.impl.GateInImpl;
+
+/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
+public class DashboardSiteImpl extends SiteImpl
+{
+ public DashboardSiteImpl(Id<? extends Site> siteId, String name, GateInImpl
gateIn)
+ {
+ super(siteId, name, gateIn);
+ }
+
+ @Override
+ protected SiteKey getSiteKey()
+ {
+ return SiteKey.user(getName());
+ }
+
+ public Type getType()
+ {
+ return Site.DASHBOARD;
+ }
+}
Deleted:
portal/trunk/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-09
13:52:09 UTC (rev 7030)
+++
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/GroupSiteImpl.java 2011-08-09
18:48:56 UTC (rev 7032)
@@ -1,49 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* 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.gatein.portal.api.impl.portal;
-
-import org.exoplatform.portal.mop.SiteKey;
-import org.gatein.api.id.Id;
-import org.gatein.api.portal.Site;
-import org.gatein.api.util.Type;
-import org.gatein.portal.api.impl.GateInImpl;
-
-/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
-public class GroupSiteImpl extends SiteImpl
-{
- public GroupSiteImpl(Id<? extends Site> siteId, String name, GateInImpl gateIn)
- {
- super(siteId, name, gateIn);
- }
-
- @Override
- protected SiteKey getSiteKey()
- {
- return SiteKey.group(getName());
- }
-
- public Type getType()
- {
- return Site.GROUP;
- }
-}
Copied:
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/GroupSiteImpl.java
(from rev 7030,
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/GroupSiteImpl.java)
===================================================================
---
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/GroupSiteImpl.java
(rev 0)
+++
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/GroupSiteImpl.java 2011-08-09
18:48:56 UTC (rev 7032)
@@ -0,0 +1,49 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* 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.gatein.portal.api.impl.portal;
+
+import org.exoplatform.portal.mop.SiteKey;
+import org.gatein.api.id.Id;
+import org.gatein.api.portal.Site;
+import org.gatein.api.util.Type;
+import org.gatein.portal.api.impl.GateInImpl;
+
+/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
+public class GroupSiteImpl extends SiteImpl
+{
+ public GroupSiteImpl(Id<? extends Site> siteId, String name, GateInImpl gateIn)
+ {
+ super(siteId, name, gateIn);
+ }
+
+ @Override
+ protected SiteKey getSiteKey()
+ {
+ return SiteKey.group(getName());
+ }
+
+ public Type getType()
+ {
+ return Site.GROUP;
+ }
+}
Deleted:
portal/trunk/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
13:52:09 UTC (rev 7030)
+++
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/NavigationImpl.java 2011-08-09
18:48:56 UTC (rev 7032)
@@ -1,374 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* 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.gatein.portal.api.impl.portal;
-
-import org.exoplatform.commons.utils.ExpressionUtil;
-import org.exoplatform.container.ExoContainer;
-import org.exoplatform.container.ExoContainerContext;
-import org.exoplatform.portal.application.PortalRequestContext;
-import org.exoplatform.portal.mop.Described;
-import org.exoplatform.portal.mop.description.DescriptionService;
-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.portal.webui.util.Util;
-import org.exoplatform.services.resources.ResourceBundleManager;
-import org.gatein.api.GateIn;
-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.Site;
-import org.gatein.api.util.IterableIdentifiableCollection;
-import org.gatein.common.NotYetImplemented;
-import org.gatein.common.net.URLTools;
-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.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>
-{
- private final NodeContext<NavigationImpl> context;
- private Id<? extends Site> site;
- private Id<Navigation> id;
- private final GateInImpl gateIn;
- private URI uri;
- private String displayName;
- private ResourceBundle bundle;
-
- public NavigationImpl(Id<Site> siteId, NodeContext<NavigationImpl>
context, GateInImpl gateIn)
- {
- this.context = context;
- this.site = siteId;
- this.gateIn = gateIn;
- }
-
- @Override
- public String toString()
- {
- String pageRef = context.getState().getPageRef();
- StringBuilder s = new
StringBuilder("Navigation(a)").append(getId()).append(" URI:
").append(getURI());
-
- if (pageRef != null)
- {
- s.append("-target->").append(pageRef);
- }
-
- if (size() != 0)
- {
- loadChildrenIfNeeded();
- s.append("\n|");
- Iterator<NavigationImpl> children = context.iterator();
- while (children.hasNext())
- {
- s.append("\n+--").append(children.next());
- }
- s.append("\n");
- }
-
- return s.toString();
- }
-
- public NodeContext<NavigationImpl> getContext()
- {
- return context;
- }
-
- public URI getURI()
- {
- if (uri != null)
- {
- return uri;
- }
- else
- {
- try
- {
- PortalRequestContext requestContext = Util.getPortalRequestContext();
- String host = URLTools.getServerAddressFrom(requestContext.getRequest());
- String portalURI = host + requestContext.getPortalURI();
- uri = new URI(portalURI + buildURI().toString());
- }
- catch (URISyntaxException e)
- {
- throw new RuntimeException(e);
- }
- return uri;
- }
- }
-
-
- private StringBuilder buildURI()
- {
- NavigationImpl parent = context.getParentNode();
- if (parent != null)
- {
- StringBuilder builder = parent.buildURI();
- if (builder.length() > 0)
- {
- builder.append('/');
- }
- return builder.append(context.getName());
- }
- else
- {
- return new StringBuilder();
- }
- }
-
-
- public Page getTargetPage()
- {
- String pageRef = context.getState().getPageRef();
- if (pageRef != null)
- {
- return gateIn.get(gateIn.pageId(site, pageRef));
- }
- else
- {
- return null;
- }
- }
-
- public void setTargetPage(Page target)
- {
- setTargetPage(target.getId());
- }
-
- public void setTargetPage(Id<Page> targetId)
- {
- context.setState(new
NodeState.Builder(context.getState()).pageRef(targetId.toString()).build());
- }
-
- public Site getSite()
- {
- return getGateIn().get(site);
- }
-
- public IterableIdentifiableCollection<Navigation> getAll()
- {
- loadChildrenIfNeeded();
-
- return new AdaptedIterableIdentifiableCollection<NavigationImpl,
Navigation>(size(), context.iterator())
- {
- public Navigation adapt(NavigationImpl old)
- {
- return old;
- }
-
- public boolean contains(Id<Navigation> id)
- {
- return NavigationImpl.this.contains(id);
- }
- };
- }
-
- private void loadChildrenIfNeeded()
- {
- if (!context.isExpanded())
- {
- NavigationService service = gateIn.getNavigationService();
- try
- {
- gateIn.begin();
- service.rebaseNode(context, Scope.CHILDREN, null);
- }
- finally
- {
- gateIn.end();
- }
- }
- }
-
- public int size()
- {
- return context.getNodeSize();
- }
-
- public boolean contains(String key)
- {
- return contains(getIdForChild(key));
- }
-
- public <U extends Navigation> boolean contains(Id<U> navigationId)
- {
- loadChildrenIfNeeded();
-
- return getChild(navigationId) != null;
- }
-
- private <U extends Navigation> NodeContext<NavigationImpl>
getChild(Id<U> navigationId)
- {
- return context.get(navigationId.getComponent(GateInImpl.NAVIGATION_COMPONENT));
- }
-
- public Navigation createAndAdd(String key)
- {
- return createAndAdd(getIdForChild(key));
- }
-
- public <U extends Navigation> U createAndAdd(Id<U> navigationId)
- {
- throw new NotYetImplemented(); // TODO
- }
-
- public Navigation get(String key)
- {
- return get(getIdForChild(key));
- }
-
- public <U extends Navigation> U get(Id<U> navigationId)
- {
- if (navigationId == null)
- {
- return null;
- }
- else
- {
- loadChildrenIfNeeded();
- final Class<U> type = navigationId.getIdentifiableType();
- final NodeContext<NavigationImpl> child = getChild(navigationId);
- return child != null ? type.cast(child.getNode()) : null;
- }
- }
-
- public Id<Navigation> getIdForChild(String key)
- {
- return site.getIdForChild(key);
- }
-
- public Id<Navigation> getId()
- {
- if (id == null)
- {
- id = GateInImpl.NAVIGATION_CONTEXT.create(Navigation.class, site.toString(),
context.getId());
- }
-
- return id;
- }
-
- public String getName()
- {
- return context.getName();
- }
-
- public String getDisplayName()
- {
- // basically duplicating code from UserNode and PortalRequestContext because we
can't use it as is
- if (displayName == null)
- {
- String resolvedLabel = null;
-
- String id = context.getId();
-
- if (context.getState().getLabel() != null)
- {
- resolvedLabel = ExpressionUtil.getExpressionValue(getBundle(),
context.getState().getLabel());
- }
- else if (id != null)
- {
- Locale userLocale = getUserLocale();
- DescriptionService descriptionService = gateIn.getDescriptionService();
- Described.State description = descriptionService.resolveDescription(id,
userLocale);
- if (description != null)
- {
- resolvedLabel = description.getName();
- }
- }
-
- //
- if (resolvedLabel == null)
- {
- resolvedLabel = getName();
- }
-
- //
- this.displayName = EntityEncoder.FULL.encode(resolvedLabel);
- }
- return displayName;
- }
-
- public Locale getUserLocale()
- {
- return Util.getPortalRequestContext().getLocale();
- }
-
-
- public ResourceBundle getBundle()
- {
- if (bundle == null)
- {
- ExoContainer container = ExoContainerContext.getCurrentContainer();
- ResourceBundleManager rbMgr =
(ResourceBundleManager)container.getComponentInstanceOfType(ResourceBundleManager.class);
- Locale locale = Util.getPortalRequestContext().getLocale();
- bundle = rbMgr.getNavigationResourceBundle(
- locale.getLanguage(),
- site.getComponent(GateInImpl.SITE_TYPE_COMPONENT),
- site.getComponent(GateInImpl.SITE_NAME_COMPONENT));
-
- if (bundle == null)
- {
- bundle = EmptyResourceBundle.INSTANCE;
- }
- }
- return bundle;
- }
-
-
- public GateIn getGateIn()
- {
- return gateIn;
- }
-
- static class NavigationNodeModel implements NodeModel<NavigationImpl>
- {
- private final Id<Site> siteId;
- private final GateInImpl gateIn;
-
- NavigationNodeModel(Id<Site> siteId, GateInImpl gateIn)
- {
- this.siteId = siteId;
- this.gateIn = gateIn;
- }
-
- public NodeContext<NavigationImpl> getContext(NavigationImpl node)
- {
- return node.context;
- }
-
- public NavigationImpl create(NodeContext<NavigationImpl> context)
- {
- return new NavigationImpl(siteId, context, gateIn);
- }
- }
-}
Copied:
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/NavigationImpl.java
(from rev 7030,
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/NavigationImpl.java)
===================================================================
---
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/NavigationImpl.java
(rev 0)
+++
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/NavigationImpl.java 2011-08-09
18:48:56 UTC (rev 7032)
@@ -0,0 +1,374 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* 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.gatein.portal.api.impl.portal;
+
+import org.exoplatform.commons.utils.ExpressionUtil;
+import org.exoplatform.container.ExoContainer;
+import org.exoplatform.container.ExoContainerContext;
+import org.exoplatform.portal.application.PortalRequestContext;
+import org.exoplatform.portal.mop.Described;
+import org.exoplatform.portal.mop.description.DescriptionService;
+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.portal.webui.util.Util;
+import org.exoplatform.services.resources.ResourceBundleManager;
+import org.gatein.api.GateIn;
+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.Site;
+import org.gatein.api.util.IterableIdentifiableCollection;
+import org.gatein.common.NotYetImplemented;
+import org.gatein.common.net.URLTools;
+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.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>
+{
+ private final NodeContext<NavigationImpl> context;
+ private Id<? extends Site> site;
+ private Id<Navigation> id;
+ private final GateInImpl gateIn;
+ private URI uri;
+ private String displayName;
+ private ResourceBundle bundle;
+
+ public NavigationImpl(Id<Site> siteId, NodeContext<NavigationImpl>
context, GateInImpl gateIn)
+ {
+ this.context = context;
+ this.site = siteId;
+ this.gateIn = gateIn;
+ }
+
+ @Override
+ public String toString()
+ {
+ String pageRef = context.getState().getPageRef();
+ StringBuilder s = new
StringBuilder("Navigation(a)").append(getId()).append(" URI:
").append(getURI());
+
+ if (pageRef != null)
+ {
+ s.append("-target->").append(pageRef);
+ }
+
+ if (size() != 0)
+ {
+ loadChildrenIfNeeded();
+ s.append("\n|");
+ Iterator<NavigationImpl> children = context.iterator();
+ while (children.hasNext())
+ {
+ s.append("\n+--").append(children.next());
+ }
+ s.append("\n");
+ }
+
+ return s.toString();
+ }
+
+ public NodeContext<NavigationImpl> getContext()
+ {
+ return context;
+ }
+
+ public URI getURI()
+ {
+ if (uri != null)
+ {
+ return uri;
+ }
+ else
+ {
+ try
+ {
+ PortalRequestContext requestContext = Util.getPortalRequestContext();
+ String host = URLTools.getServerAddressFrom(requestContext.getRequest());
+ String portalURI = host + requestContext.getPortalURI();
+ uri = new URI(portalURI + buildURI().toString());
+ }
+ catch (URISyntaxException e)
+ {
+ throw new RuntimeException(e);
+ }
+ return uri;
+ }
+ }
+
+
+ private StringBuilder buildURI()
+ {
+ NavigationImpl parent = context.getParentNode();
+ if (parent != null)
+ {
+ StringBuilder builder = parent.buildURI();
+ if (builder.length() > 0)
+ {
+ builder.append('/');
+ }
+ return builder.append(context.getName());
+ }
+ else
+ {
+ return new StringBuilder();
+ }
+ }
+
+
+ public Page getTargetPage()
+ {
+ String pageRef = context.getState().getPageRef();
+ if (pageRef != null)
+ {
+ return gateIn.get(gateIn.pageId(site, pageRef));
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public void setTargetPage(Page target)
+ {
+ setTargetPage(target.getId());
+ }
+
+ public void setTargetPage(Id<Page> targetId)
+ {
+ context.setState(new
NodeState.Builder(context.getState()).pageRef(targetId.toString()).build());
+ }
+
+ public Site getSite()
+ {
+ return getGateIn().get(site);
+ }
+
+ public IterableIdentifiableCollection<Navigation> getAll()
+ {
+ loadChildrenIfNeeded();
+
+ return new AdaptedIterableIdentifiableCollection<NavigationImpl,
Navigation>(size(), context.iterator())
+ {
+ public Navigation adapt(NavigationImpl old)
+ {
+ return old;
+ }
+
+ public boolean contains(Id<Navigation> id)
+ {
+ return NavigationImpl.this.contains(id);
+ }
+ };
+ }
+
+ private void loadChildrenIfNeeded()
+ {
+ if (!context.isExpanded())
+ {
+ NavigationService service = gateIn.getNavigationService();
+ try
+ {
+ gateIn.begin();
+ service.rebaseNode(context, Scope.CHILDREN, null);
+ }
+ finally
+ {
+ gateIn.end();
+ }
+ }
+ }
+
+ public int size()
+ {
+ return context.getNodeSize();
+ }
+
+ public boolean contains(String key)
+ {
+ return contains(getIdForChild(key));
+ }
+
+ public <U extends Navigation> boolean contains(Id<U> navigationId)
+ {
+ loadChildrenIfNeeded();
+
+ return getChild(navigationId) != null;
+ }
+
+ private <U extends Navigation> NodeContext<NavigationImpl>
getChild(Id<U> navigationId)
+ {
+ return context.get(navigationId.getComponent(GateInImpl.NAVIGATION_COMPONENT));
+ }
+
+ public Navigation createAndAdd(String key)
+ {
+ return createAndAdd(getIdForChild(key));
+ }
+
+ public <U extends Navigation> U createAndAdd(Id<U> navigationId)
+ {
+ throw new NotYetImplemented(); // TODO
+ }
+
+ public Navigation get(String key)
+ {
+ return get(getIdForChild(key));
+ }
+
+ public <U extends Navigation> U get(Id<U> navigationId)
+ {
+ if (navigationId == null)
+ {
+ return null;
+ }
+ else
+ {
+ loadChildrenIfNeeded();
+ final Class<U> type = navigationId.getIdentifiableType();
+ final NodeContext<NavigationImpl> child = getChild(navigationId);
+ return child != null ? type.cast(child.getNode()) : null;
+ }
+ }
+
+ public Id<Navigation> getIdForChild(String key)
+ {
+ return site.getIdForChild(key);
+ }
+
+ public Id<Navigation> getId()
+ {
+ if (id == null)
+ {
+ id = GateInImpl.NAVIGATION_CONTEXT.create(Navigation.class, site.toString(),
context.getId());
+ }
+
+ return id;
+ }
+
+ public String getName()
+ {
+ return context.getName();
+ }
+
+ public String getDisplayName()
+ {
+ // basically duplicating code from UserNode and PortalRequestContext because we
can't use it as is
+ if (displayName == null)
+ {
+ String resolvedLabel = null;
+
+ String id = context.getId();
+
+ if (context.getState().getLabel() != null)
+ {
+ resolvedLabel = ExpressionUtil.getExpressionValue(getBundle(),
context.getState().getLabel());
+ }
+ else if (id != null)
+ {
+ Locale userLocale = getUserLocale();
+ DescriptionService descriptionService = gateIn.getDescriptionService();
+ Described.State description = descriptionService.resolveDescription(id,
userLocale);
+ if (description != null)
+ {
+ resolvedLabel = description.getName();
+ }
+ }
+
+ //
+ if (resolvedLabel == null)
+ {
+ resolvedLabel = getName();
+ }
+
+ //
+ this.displayName = EntityEncoder.FULL.encode(resolvedLabel);
+ }
+ return displayName;
+ }
+
+ public Locale getUserLocale()
+ {
+ return Util.getPortalRequestContext().getLocale();
+ }
+
+
+ public ResourceBundle getBundle()
+ {
+ if (bundle == null)
+ {
+ ExoContainer container = ExoContainerContext.getCurrentContainer();
+ ResourceBundleManager rbMgr =
(ResourceBundleManager)container.getComponentInstanceOfType(ResourceBundleManager.class);
+ Locale locale = Util.getPortalRequestContext().getLocale();
+ bundle = rbMgr.getNavigationResourceBundle(
+ locale.getLanguage(),
+ site.getComponent(GateInImpl.SITE_TYPE_COMPONENT),
+ site.getComponent(GateInImpl.SITE_NAME_COMPONENT));
+
+ if (bundle == null)
+ {
+ bundle = EmptyResourceBundle.INSTANCE;
+ }
+ }
+ return bundle;
+ }
+
+
+ public GateIn getGateIn()
+ {
+ return gateIn;
+ }
+
+ static class NavigationNodeModel implements NodeModel<NavigationImpl>
+ {
+ private final Id<Site> siteId;
+ private final GateInImpl gateIn;
+
+ NavigationNodeModel(Id<Site> siteId, GateInImpl gateIn)
+ {
+ this.siteId = siteId;
+ this.gateIn = gateIn;
+ }
+
+ public NodeContext<NavigationImpl> getContext(NavigationImpl node)
+ {
+ return node.context;
+ }
+
+ public NavigationImpl create(NodeContext<NavigationImpl> context)
+ {
+ return new NavigationImpl(siteId, context, gateIn);
+ }
+ }
+}
Deleted:
portal/trunk/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-09
13:52:09 UTC (rev 7030)
+++
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/PageImpl.java 2011-08-09
18:48:56 UTC (rev 7032)
@@ -1,105 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* 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.gatein.portal.api.impl.portal;
-
-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;
-
-/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
-public class PageImpl extends IdentifiableImpl<Page> implements Page
-{
- private final Id<? extends Site> site;
- private PageData pageData;
-
- public PageImpl(PageData pageData, Id<? extends Site> parent, GateInImpl
gateIn)
- {
- super(gateIn.pageId(parent, pageData.getName()), pageData.getName(), gateIn);
- this.site = parent;
- this.pageData = pageData;
- }
-
- public Site getSite()
- {
- return getGateIn().get(site);
- }
-
- public String getTitle()
- {
- return pageData.getTitle();
- }
-
- @Override
- public String toString()
- {
- return "'" + getName() + "' Page titled '" +
getTitle() + "' id " + getId();
- }
-
- public void setTitle(String title)
- {
- try
- {
- getGateInImpl().begin();
- final ModelDataStorage dataStorage = getGateInImpl().getDataStorage();
-
- // recreate page with the new title
- final PageData newPageData = new PageData(pageData.getStorageId(),
pageData.getId(), pageData.getName(), pageData.getIcon(),
- pageData.getTemplate(), pageData.getFactoryId(), title,
pageData.getDescription(), pageData.getWidth(), pageData.getHeight(),
- pageData.getAccessPermissions(), pageData.getChildren(),
pageData.getOwnerType(), pageData.getOwnerId(),
- pageData.getEditPermission(), pageData.isShowMaxWindow());
-
- // save new page
- dataStorage.save(newPageData);
-
- // remove previous data
- dataStorage.remove(pageData);
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- finally
- {
- getGateInImpl().end();
- }
-
-
- }
-
- public IterableIdentifiableCollection<Navigation> getInboundNavigations()
- {
- throw new NotYetImplemented(); // todo
- }
-
- public Navigation createInboundNavigationIn(Site site, Navigation parent)
- {
- throw new NotYetImplemented(); // todo
- }
-}
Copied:
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/PageImpl.java
(from rev 7030,
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/PageImpl.java)
===================================================================
---
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/PageImpl.java
(rev 0)
+++
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/PageImpl.java 2011-08-09
18:48:56 UTC (rev 7032)
@@ -0,0 +1,105 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* 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.gatein.portal.api.impl.portal;
+
+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;
+
+/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
+public class PageImpl extends IdentifiableImpl<Page> implements Page
+{
+ private final Id<? extends Site> site;
+ private PageData pageData;
+
+ public PageImpl(PageData pageData, Id<? extends Site> parent, GateInImpl
gateIn)
+ {
+ super(gateIn.pageId(parent, pageData.getName()), pageData.getName(), gateIn);
+ this.site = parent;
+ this.pageData = pageData;
+ }
+
+ public Site getSite()
+ {
+ return getGateIn().get(site);
+ }
+
+ public String getTitle()
+ {
+ return pageData.getTitle();
+ }
+
+ @Override
+ public String toString()
+ {
+ return "'" + getName() + "' Page titled '" +
getTitle() + "' id " + getId();
+ }
+
+ public void setTitle(String title)
+ {
+ try
+ {
+ getGateInImpl().begin();
+ final ModelDataStorage dataStorage = getGateInImpl().getDataStorage();
+
+ // recreate page with the new title
+ final PageData newPageData = new PageData(pageData.getStorageId(),
pageData.getId(), pageData.getName(), pageData.getIcon(),
+ pageData.getTemplate(), pageData.getFactoryId(), title,
pageData.getDescription(), pageData.getWidth(), pageData.getHeight(),
+ pageData.getAccessPermissions(), pageData.getChildren(),
pageData.getOwnerType(), pageData.getOwnerId(),
+ pageData.getEditPermission(), pageData.isShowMaxWindow());
+
+ // save new page
+ dataStorage.save(newPageData);
+
+ // remove previous data
+ dataStorage.remove(pageData);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ finally
+ {
+ getGateInImpl().end();
+ }
+
+
+ }
+
+ public IterableIdentifiableCollection<Navigation> getInboundNavigations()
+ {
+ throw new NotYetImplemented(); // todo
+ }
+
+ public Navigation createInboundNavigationIn(Site site, Navigation parent)
+ {
+ throw new NotYetImplemented(); // todo
+ }
+}
Deleted:
portal/trunk/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-09
13:52:09 UTC (rev 7030)
+++
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/PortalImpl.java 2011-08-09
18:48:56 UTC (rev 7032)
@@ -1,57 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* 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.gatein.portal.api.impl.portal;
-
-import org.exoplatform.portal.mop.SiteKey;
-import org.exoplatform.portal.pom.data.PortalData;
-import org.gatein.api.content.ContentRegistry;
-import org.gatein.api.portal.Portal;
-import org.gatein.api.portal.Site;
-import org.gatein.api.util.Type;
-import org.gatein.portal.api.impl.GateInImpl;
-import org.gatein.portal.api.impl.content.ContentRegistryImpl;
-
-/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
-public class PortalImpl extends SiteImpl implements Portal
-{
-
- public PortalImpl(PortalData portal, GateInImpl gateIn)
- {
- super(gateIn.siteId(getAPITypeFrom(portal.getKey()), portal.getKey().getId()),
portal.getName(), gateIn);
- }
-
- public ContentRegistry getContentRegistry()
- {
- return new ContentRegistryImpl(getGateInImpl(), this);
- }
-
- public Type getType()
- {
- return Site.PORTAL;
- }
-
- protected SiteKey getSiteKey()
- {
- return SiteKey.portal(getName());
- }
-}
Copied:
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/PortalImpl.java
(from rev 7030,
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/PortalImpl.java)
===================================================================
---
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/PortalImpl.java
(rev 0)
+++
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/PortalImpl.java 2011-08-09
18:48:56 UTC (rev 7032)
@@ -0,0 +1,57 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* 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.gatein.portal.api.impl.portal;
+
+import org.exoplatform.portal.mop.SiteKey;
+import org.exoplatform.portal.pom.data.PortalData;
+import org.gatein.api.content.ContentRegistry;
+import org.gatein.api.portal.Portal;
+import org.gatein.api.portal.Site;
+import org.gatein.api.util.Type;
+import org.gatein.portal.api.impl.GateInImpl;
+import org.gatein.portal.api.impl.content.ContentRegistryImpl;
+
+/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
+public class PortalImpl extends SiteImpl implements Portal
+{
+
+ public PortalImpl(PortalData portal, GateInImpl gateIn)
+ {
+ super(gateIn.siteId(getAPITypeFrom(portal.getKey()), portal.getKey().getId()),
portal.getName(), gateIn);
+ }
+
+ public ContentRegistry getContentRegistry()
+ {
+ return new ContentRegistryImpl(getGateInImpl(), this);
+ }
+
+ public Type getType()
+ {
+ return Site.PORTAL;
+ }
+
+ protected SiteKey getSiteKey()
+ {
+ return SiteKey.portal(getName());
+ }
+}
Deleted:
portal/trunk/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-09
13:52:09 UTC (rev 7030)
+++
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/SiteImpl.java 2011-08-09
18:48:56 UTC (rev 7032)
@@ -1,237 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* 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.gatein.portal.api.impl.portal;
-
-import org.exoplatform.portal.config.Query;
-import org.exoplatform.portal.mop.SiteKey;
-import org.exoplatform.portal.mop.navigation.NavigationContext;
-import org.exoplatform.portal.mop.navigation.NavigationService;
-import org.exoplatform.portal.mop.navigation.NavigationState;
-import org.exoplatform.portal.mop.navigation.NodeModel;
-import org.exoplatform.portal.mop.navigation.Scope;
-import org.exoplatform.portal.pom.data.OwnerKey;
-import org.exoplatform.portal.pom.data.PageData;
-import org.exoplatform.portal.pom.data.PageKey;
-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.GateInTypesResolver;
-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 java.util.List;
-
-/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
-public abstract class SiteImpl extends IdentifiableImpl implements Site
-{
- private PageContainer pageRegistry;
-
- public SiteImpl(Id<? extends Site> siteId, String name, GateInImpl gateIn)
- {
- super(siteId, name, gateIn);
- pageRegistry = new PageContainer(gateIn, this);
- }
-
- @Override
- public String toString()
- {
- return getType().getName() + "\n" + getNavigation().toString();
- }
-
- static Type getAPITypeFrom(OwnerKey key)
- {
- return GateInTypesResolver.forName(key.getType(), Site.class);
- }
-
- public HierarchicalContainer<String, Page> getPageRegistry()
- {
- return pageRegistry;
- }
-
- public Navigation getNavigation()
- {
- GateInImpl gateIn = getGateInImpl();
- NavigationService service = gateIn.getNavigationService();
-
- try
- {
- gateIn.begin();
- NavigationContext navigation = service.loadNavigation(getSiteKey());
-
- if (navigation != null)
- {
- NodeModel<NavigationImpl> nodeModel = new
NavigationImpl.NavigationNodeModel(getId(), gateIn);
-
- return service.loadNode(nodeModel, navigation, Scope.CHILDREN,
null).getNode();
- }
- else
- {
- return null;
- }
- }
- finally
- {
- gateIn.end();
- }
- }
-
- public int getPriority()
- {
- GateInImpl gateIn = getGateInImpl();
- NavigationService service = gateIn.getNavigationService();
-
- try
- {
- gateIn.begin();
- NavigationContext navigation = service.loadNavigation(getSiteKey());
-
- NavigationState state = navigation.getState();
- return state != null ? state.getPriority() : 1;
- }
- finally
- {
- gateIn.end();
- }
- }
-
- public Navigation createNavigationTo(Page node, Navigation parent)
- {
- throw new NotYetImplemented(); // todo
- }
-
- protected abstract SiteKey getSiteKey();
-
- static class PageContainer implements HierarchicalContainer<String, Page>
- {
- private final GateInImpl gateIn;
- private final Site site;
- private final Query<PageData> pageDataQuery;
-
- PageContainer(GateInImpl gateIn, SiteImpl site)
- {
- this.gateIn = gateIn;
- this.site = site;
- pageDataQuery = new Query<PageData>(site.getType().getName(), null,
PageData.class);
- }
-
- public boolean contains(String key)
- {
- return getPageData(key) != null;
- }
-
- private PageData getPageData(String key)
- {
- try
- {
- gateIn.begin();
- return gateIn.getDataStorage().getPage(PageKey.create(key));
- }
- catch (Exception e)
- {
- return null;
- }
- finally
- {
- gateIn.end();
- }
- }
-
- public Page createAndAdd(String key)
- {
- throw new NotYetImplemented(); // todo
- }
-
- public Page get(String key)
- {
- final PageData pageData = getPageData(key);
- return pageData != null ? new PageImpl(pageData, site.getId(), gateIn) : null;
- }
-
- public Id<Page> getIdForChild(String key)
- {
- return site.getId().getIdForChild(key);
- }
-
- public <U extends Page> U createAndAdd(Id<U> id)
- {
- return (U)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(Id<Page> t)
- {
- return getPageData(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 <U extends Page> U get(Id<U> id)
- {
- return (U)get(id.toString());
- }
-
- public <U extends Page> boolean contains(Id<U> id)
- {
- return contains(id.toString());
- }
- }
-}
Copied:
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/SiteImpl.java
(from rev 7030,
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/SiteImpl.java)
===================================================================
---
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/SiteImpl.java
(rev 0)
+++
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/SiteImpl.java 2011-08-09
18:48:56 UTC (rev 7032)
@@ -0,0 +1,237 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* 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.gatein.portal.api.impl.portal;
+
+import org.exoplatform.portal.config.Query;
+import org.exoplatform.portal.mop.SiteKey;
+import org.exoplatform.portal.mop.navigation.NavigationContext;
+import org.exoplatform.portal.mop.navigation.NavigationService;
+import org.exoplatform.portal.mop.navigation.NavigationState;
+import org.exoplatform.portal.mop.navigation.NodeModel;
+import org.exoplatform.portal.mop.navigation.Scope;
+import org.exoplatform.portal.pom.data.OwnerKey;
+import org.exoplatform.portal.pom.data.PageData;
+import org.exoplatform.portal.pom.data.PageKey;
+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.GateInTypesResolver;
+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 java.util.List;
+
+/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
+public abstract class SiteImpl extends IdentifiableImpl implements Site
+{
+ private PageContainer pageRegistry;
+
+ public SiteImpl(Id<? extends Site> siteId, String name, GateInImpl gateIn)
+ {
+ super(siteId, name, gateIn);
+ pageRegistry = new PageContainer(gateIn, this);
+ }
+
+ @Override
+ public String toString()
+ {
+ return getType().getName() + "\n" + getNavigation().toString();
+ }
+
+ static Type getAPITypeFrom(OwnerKey key)
+ {
+ return GateInTypesResolver.forName(key.getType(), Site.class);
+ }
+
+ public HierarchicalContainer<String, Page> getPageRegistry()
+ {
+ return pageRegistry;
+ }
+
+ public Navigation getNavigation()
+ {
+ GateInImpl gateIn = getGateInImpl();
+ NavigationService service = gateIn.getNavigationService();
+
+ try
+ {
+ gateIn.begin();
+ NavigationContext navigation = service.loadNavigation(getSiteKey());
+
+ if (navigation != null)
+ {
+ NodeModel<NavigationImpl> nodeModel = new
NavigationImpl.NavigationNodeModel(getId(), gateIn);
+
+ return service.loadNode(nodeModel, navigation, Scope.CHILDREN,
null).getNode();
+ }
+ else
+ {
+ return null;
+ }
+ }
+ finally
+ {
+ gateIn.end();
+ }
+ }
+
+ public int getPriority()
+ {
+ GateInImpl gateIn = getGateInImpl();
+ NavigationService service = gateIn.getNavigationService();
+
+ try
+ {
+ gateIn.begin();
+ NavigationContext navigation = service.loadNavigation(getSiteKey());
+
+ NavigationState state = navigation.getState();
+ return state != null ? state.getPriority() : 1;
+ }
+ finally
+ {
+ gateIn.end();
+ }
+ }
+
+ public Navigation createNavigationTo(Page node, Navigation parent)
+ {
+ throw new NotYetImplemented(); // todo
+ }
+
+ protected abstract SiteKey getSiteKey();
+
+ static class PageContainer implements HierarchicalContainer<String, Page>
+ {
+ private final GateInImpl gateIn;
+ private final Site site;
+ private final Query<PageData> pageDataQuery;
+
+ PageContainer(GateInImpl gateIn, SiteImpl site)
+ {
+ this.gateIn = gateIn;
+ this.site = site;
+ pageDataQuery = new Query<PageData>(site.getType().getName(), null,
PageData.class);
+ }
+
+ public boolean contains(String key)
+ {
+ return getPageData(key) != null;
+ }
+
+ private PageData getPageData(String key)
+ {
+ try
+ {
+ gateIn.begin();
+ return gateIn.getDataStorage().getPage(PageKey.create(key));
+ }
+ catch (Exception e)
+ {
+ return null;
+ }
+ finally
+ {
+ gateIn.end();
+ }
+ }
+
+ public Page createAndAdd(String key)
+ {
+ throw new NotYetImplemented(); // todo
+ }
+
+ public Page get(String key)
+ {
+ final PageData pageData = getPageData(key);
+ return pageData != null ? new PageImpl(pageData, site.getId(), gateIn) : null;
+ }
+
+ public Id<Page> getIdForChild(String key)
+ {
+ return site.getId().getIdForChild(key);
+ }
+
+ public <U extends Page> U createAndAdd(Id<U> id)
+ {
+ return (U)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(Id<Page> t)
+ {
+ return getPageData(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 <U extends Page> U get(Id<U> id)
+ {
+ return (U)get(id.toString());
+ }
+
+ public <U extends Page> boolean contains(Id<U> id)
+ {
+ return contains(id.toString());
+ }
+ }
+}
Deleted:
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/util/AdaptedIterableCollection.java
===================================================================
---
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/util/AdaptedIterableCollection.java 2011-08-09
13:52:09 UTC (rev 7030)
+++
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/util/AdaptedIterableCollection.java 2011-08-09
18:48:56 UTC (rev 7032)
@@ -1,56 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* 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.gatein.portal.api.impl.util;
-
-import org.gatein.api.util.IterableCollection;
-
-import java.util.Iterator;
-
-/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
-public abstract class AdaptedIterableCollection<O, N> implements
IterableCollection<N>, Adaptor<O, N>
-{
- private final int size;
- private final Iterator<O> adaptee;
-
- public AdaptedIterableCollection(int size, Iterator<O> adaptee)
- {
- this.size = size;
- this.adaptee = adaptee;
- }
-
- public int size()
- {
- return size;
- }
-
- public Iterator<N> iterator()
- {
- return new AdaptedIterator<O, N>(adaptee)
- {
- public N adapt(O old)
- {
- return AdaptedIterableCollection.this.adapt(old);
- }
- };
- }
-}
Copied:
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/util/AdaptedIterableCollection.java
(from rev 7030,
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/util/AdaptedIterableCollection.java)
===================================================================
---
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/util/AdaptedIterableCollection.java
(rev 0)
+++
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/util/AdaptedIterableCollection.java 2011-08-09
18:48:56 UTC (rev 7032)
@@ -0,0 +1,56 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* 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.gatein.portal.api.impl.util;
+
+import org.gatein.api.util.IterableCollection;
+
+import java.util.Iterator;
+
+/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
+public abstract class AdaptedIterableCollection<O, N> implements
IterableCollection<N>, Adaptor<O, N>
+{
+ private final int size;
+ private final Iterator<O> adaptee;
+
+ public AdaptedIterableCollection(int size, Iterator<O> adaptee)
+ {
+ this.size = size;
+ this.adaptee = adaptee;
+ }
+
+ public int size()
+ {
+ return size;
+ }
+
+ public Iterator<N> iterator()
+ {
+ return new AdaptedIterator<O, N>(adaptee)
+ {
+ public N adapt(O old)
+ {
+ return AdaptedIterableCollection.this.adapt(old);
+ }
+ };
+ }
+}
Deleted:
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/util/AdaptedIterableIdentifiableCollection.java
===================================================================
---
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/util/AdaptedIterableIdentifiableCollection.java 2011-08-09
13:52:09 UTC (rev 7030)
+++
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/util/AdaptedIterableIdentifiableCollection.java 2011-08-09
18:48:56 UTC (rev 7032)
@@ -1,43 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* 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.gatein.portal.api.impl.util;
-
-
-import org.gatein.api.id.Identifiable;
-import org.gatein.api.util.IterableIdentifiableCollection;
-
-import java.util.Iterator;
-
-/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
-public abstract class AdaptedIterableIdentifiableCollection<O, N extends
Identifiable> extends AdaptedIterableCollection<O, N> implements
IterableIdentifiableCollection<N>
-{
- public AdaptedIterableIdentifiableCollection(int size, Iterator<O> adaptee)
- {
- super(size, adaptee);
- }
-
- public boolean contains(N n)
- {
- return this.contains(n.getId());
- }
-}
Copied:
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/util/AdaptedIterableIdentifiableCollection.java
(from rev 7030,
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/util/AdaptedIterableIdentifiableCollection.java)
===================================================================
---
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/util/AdaptedIterableIdentifiableCollection.java
(rev 0)
+++
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/util/AdaptedIterableIdentifiableCollection.java 2011-08-09
18:48:56 UTC (rev 7032)
@@ -0,0 +1,43 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* 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.gatein.portal.api.impl.util;
+
+
+import org.gatein.api.id.Identifiable;
+import org.gatein.api.util.IterableIdentifiableCollection;
+
+import java.util.Iterator;
+
+/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
+public abstract class AdaptedIterableIdentifiableCollection<O, N extends
Identifiable> extends AdaptedIterableCollection<O, N> implements
IterableIdentifiableCollection<N>
+{
+ public AdaptedIterableIdentifiableCollection(int size, Iterator<O> adaptee)
+ {
+ super(size, adaptee);
+ }
+
+ public boolean contains(N n)
+ {
+ return this.contains(n.getId());
+ }
+}
Deleted:
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/util/AdaptedIterator.java
===================================================================
---
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/util/AdaptedIterator.java 2011-08-09
13:52:09 UTC (rev 7030)
+++
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/util/AdaptedIterator.java 2011-08-09
18:48:56 UTC (rev 7032)
@@ -1,51 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* 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.gatein.portal.api.impl.util;
-
-import java.util.Iterator;
-
-/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
-public abstract class AdaptedIterator<O, N> implements Iterator<N>,
Adaptor<O, N>
-{
- private final Iterator<O> adaptee;
-
- public AdaptedIterator(Iterator<O> adaptee)
- {
- this.adaptee = adaptee;
- }
-
- public boolean hasNext()
- {
- return adaptee.hasNext();
- }
-
- public N next()
- {
- return adapt(adaptee.next());
- }
-
- public void remove()
- {
- adaptee.remove();
- }
-}
Copied:
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/util/AdaptedIterator.java
(from rev 7030,
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/util/AdaptedIterator.java)
===================================================================
---
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/util/AdaptedIterator.java
(rev 0)
+++
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/util/AdaptedIterator.java 2011-08-09
18:48:56 UTC (rev 7032)
@@ -0,0 +1,51 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* 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.gatein.portal.api.impl.util;
+
+import java.util.Iterator;
+
+/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
+public abstract class AdaptedIterator<O, N> implements Iterator<N>,
Adaptor<O, N>
+{
+ private final Iterator<O> adaptee;
+
+ public AdaptedIterator(Iterator<O> adaptee)
+ {
+ this.adaptee = adaptee;
+ }
+
+ public boolean hasNext()
+ {
+ return adaptee.hasNext();
+ }
+
+ public N next()
+ {
+ return adapt(adaptee.next());
+ }
+
+ public void remove()
+ {
+ adaptee.remove();
+ }
+}
Deleted:
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/util/Adaptor.java
===================================================================
---
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/util/Adaptor.java 2011-08-09
13:52:09 UTC (rev 7030)
+++
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/util/Adaptor.java 2011-08-09
18:48:56 UTC (rev 7032)
@@ -1,29 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* 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.gatein.portal.api.impl.util;
-
-/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
-public interface Adaptor<O, N>
-{
- N adapt(O old);
-}
Copied:
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/util/Adaptor.java
(from rev 7030,
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/util/Adaptor.java)
===================================================================
---
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/util/Adaptor.java
(rev 0)
+++
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/util/Adaptor.java 2011-08-09
18:48:56 UTC (rev 7032)
@@ -0,0 +1,29 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* 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.gatein.portal.api.impl.util;
+
+/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
+public interface Adaptor<O, N>
+{
+ N adapt(O old);
+}
Deleted:
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/util/AggregatedIterableIdentifiableCollection.java
===================================================================
---
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/util/AggregatedIterableIdentifiableCollection.java 2011-08-09
13:52:09 UTC (rev 7030)
+++
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/util/AggregatedIterableIdentifiableCollection.java 2011-08-09
18:48:56 UTC (rev 7032)
@@ -1,157 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* 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.gatein.portal.api.impl.util;
-
-import org.gatein.api.id.Id;
-import org.gatein.api.id.Identifiable;
-import org.gatein.api.util.IterableIdentifiableCollection;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.NoSuchElementException;
-
-/**
- * TODO: fix logic, adding empty collections shouldn't break the iteration process,
just move to the next collection
- *
- * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
- */
-public class AggregatedIterableIdentifiableCollection<T extends
Identifiable<T>> implements IterableIdentifiableCollection<T>
-{
- private List<IterableIdentifiableCollection> aggregated = new
ArrayList<IterableIdentifiableCollection>(7);
-
- public void addCollection(IterableIdentifiableCollection<? extends T>
collection)
- {
- if (collection.size() != 0)
- {
- aggregated.add(collection);
- }
- }
-
-
- public boolean contains(Id<T> t)
- {
- for (IterableIdentifiableCollection<T> collection : aggregated)
- {
- if (collection.contains(t))
- {
- return true;
- }
- }
-
- return false;
- }
-
- public int size()
- {
- int size = 0;
- for (IterableIdentifiableCollection<T> collection : aggregated)
- {
- size += collection.size();
- }
-
- return size;
- }
-
- public boolean contains(T t)
- {
- return contains(t.getId());
- }
-
- public Iterator<T> iterator()
- {
- final Iterator<IterableIdentifiableCollection> iterator =
aggregated.iterator();
-
- if (iterator.hasNext())
- {
- return new Iterator<T>()
- {
- private Iterator<T> current = iterator.next().iterator();
-
- public boolean hasNext()
- {
- Iterator<T> currentIterator = getCurrent();
- return currentIterator != null && currentIterator.hasNext();
- }
-
- public T next()
- {
- Iterator<T> currentIterator = getCurrent();
- if (currentIterator != null)
- {
- return currentIterator.next();
- }
- else
- {
- throw new NoSuchElementException();
- }
- }
-
- public void remove()
- {
- throw new UnsupportedOperationException();
- }
-
- private Iterator<T> getCurrent()
- {
- if (current.hasNext())
- {
- return current;
- }
- else
- {
- if (iterator.hasNext())
- {
- current = iterator.next().iterator();
- return current;
- }
- else
- {
- return null;
- }
- }
- }
- };
- }
- else
- {
- return new Iterator<T>()
- {
- public boolean hasNext()
- {
- return false;
- }
-
- public T next()
- {
- throw new NoSuchElementException();
- }
-
- public void remove()
- {
- throw new UnsupportedOperationException();
- }
- };
- }
- }
-}
Copied:
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/util/AggregatedIterableIdentifiableCollection.java
(from rev 7030,
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/util/AggregatedIterableIdentifiableCollection.java)
===================================================================
---
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/util/AggregatedIterableIdentifiableCollection.java
(rev 0)
+++
portal/trunk/component/api-impl/src/main/java/org/gatein/portal/api/impl/util/AggregatedIterableIdentifiableCollection.java 2011-08-09
18:48:56 UTC (rev 7032)
@@ -0,0 +1,157 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* 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.gatein.portal.api.impl.util;
+
+import org.gatein.api.id.Id;
+import org.gatein.api.id.Identifiable;
+import org.gatein.api.util.IterableIdentifiableCollection;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.NoSuchElementException;
+
+/**
+ * TODO: fix logic, adding empty collections shouldn't break the iteration process,
just move to the next collection
+ *
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ */
+public class AggregatedIterableIdentifiableCollection<T extends
Identifiable<T>> implements IterableIdentifiableCollection<T>
+{
+ private List<IterableIdentifiableCollection> aggregated = new
ArrayList<IterableIdentifiableCollection>(7);
+
+ public void addCollection(IterableIdentifiableCollection<? extends T>
collection)
+ {
+ if (collection.size() != 0)
+ {
+ aggregated.add(collection);
+ }
+ }
+
+
+ public boolean contains(Id<T> t)
+ {
+ for (IterableIdentifiableCollection<T> collection : aggregated)
+ {
+ if (collection.contains(t))
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ public int size()
+ {
+ int size = 0;
+ for (IterableIdentifiableCollection<T> collection : aggregated)
+ {
+ size += collection.size();
+ }
+
+ return size;
+ }
+
+ public boolean contains(T t)
+ {
+ return contains(t.getId());
+ }
+
+ public Iterator<T> iterator()
+ {
+ final Iterator<IterableIdentifiableCollection> iterator =
aggregated.iterator();
+
+ if (iterator.hasNext())
+ {
+ return new Iterator<T>()
+ {
+ private Iterator<T> current = iterator.next().iterator();
+
+ public boolean hasNext()
+ {
+ Iterator<T> currentIterator = getCurrent();
+ return currentIterator != null && currentIterator.hasNext();
+ }
+
+ public T next()
+ {
+ Iterator<T> currentIterator = getCurrent();
+ if (currentIterator != null)
+ {
+ return currentIterator.next();
+ }
+ else
+ {
+ throw new NoSuchElementException();
+ }
+ }
+
+ public void remove()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ private Iterator<T> getCurrent()
+ {
+ if (current.hasNext())
+ {
+ return current;
+ }
+ else
+ {
+ if (iterator.hasNext())
+ {
+ current = iterator.next().iterator();
+ return current;
+ }
+ else
+ {
+ return null;
+ }
+ }
+ }
+ };
+ }
+ else
+ {
+ return new Iterator<T>()
+ {
+ public boolean hasNext()
+ {
+ return false;
+ }
+
+ public T next()
+ {
+ throw new NoSuchElementException();
+ }
+
+ public void remove()
+ {
+ throw new UnsupportedOperationException();
+ }
+ };
+ }
+ }
+}
Deleted:
portal/trunk/component/api-impl/src/test/java/org/gatein/portal/api/impl/id/ComplexApplicationContextTestCase.java
===================================================================
---
portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/id/ComplexApplicationContextTestCase.java 2011-08-09
13:52:09 UTC (rev 7030)
+++
portal/trunk/component/api-impl/src/test/java/org/gatein/portal/api/impl/id/ComplexApplicationContextTestCase.java 2011-08-09
18:48:56 UTC (rev 7032)
@@ -1,51 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* 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.gatein.portal.api.impl.id;
-
-import org.gatein.api.content.Portlet;
-import org.gatein.api.id.Id;
-import org.gatein.portal.api.impl.GateInImpl;
-import org.testng.annotations.Test;
-
-/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
-public class ComplexApplicationContextTestCase
-{
- @Test
- public void checkParsing()
- {
- Id<Portlet> id =
ComplexApplicationContext.INSTANCE.parse("category/local._webapp.portlet",
Portlet.class);
- assert
"category".equals(id.getComponent(GateInImpl.CATEGORY_COMPONENT));
- assert
"webapp".equals(id.getComponent(GateInImpl.APPLICATION_COMPONENT));
- assert "portlet".equals(id.getComponent(GateInImpl.PORTLET_COMPONENT));
-
- assert id.equals(ComplexApplicationContext.INSTANCE.parse(id.toString()));
-
-
- id = ComplexApplicationContext.INSTANCE.parse("local./webapp.portlet",
Portlet.class);
- assert id.getComponent(GateInImpl.CATEGORY_COMPONENT) == null;
- assert
"webapp".equals(id.getComponent(GateInImpl.APPLICATION_COMPONENT));
- assert "portlet".equals(id.getComponent(GateInImpl.PORTLET_COMPONENT));
-
- assert id.equals(ComplexApplicationContext.INSTANCE.parse(id.toString()));
- }
-}
Copied:
portal/trunk/component/api-impl/src/test/java/org/gatein/portal/api/impl/id/ComplexApplicationContextTestCase.java
(from rev 7030,
portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/id/ComplexApplicationContextTestCase.java)
===================================================================
---
portal/trunk/component/api-impl/src/test/java/org/gatein/portal/api/impl/id/ComplexApplicationContextTestCase.java
(rev 0)
+++
portal/trunk/component/api-impl/src/test/java/org/gatein/portal/api/impl/id/ComplexApplicationContextTestCase.java 2011-08-09
18:48:56 UTC (rev 7032)
@@ -0,0 +1,51 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* 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.gatein.portal.api.impl.id;
+
+import org.gatein.api.content.Portlet;
+import org.gatein.api.id.Id;
+import org.gatein.portal.api.impl.GateInImpl;
+import org.testng.annotations.Test;
+
+/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
+public class ComplexApplicationContextTestCase
+{
+ @Test
+ public void checkParsing()
+ {
+ Id<Portlet> id =
ComplexApplicationContext.INSTANCE.parse("category/local._webapp.portlet",
Portlet.class);
+ assert
"category".equals(id.getComponent(GateInImpl.CATEGORY_COMPONENT));
+ assert
"webapp".equals(id.getComponent(GateInImpl.APPLICATION_COMPONENT));
+ assert "portlet".equals(id.getComponent(GateInImpl.PORTLET_COMPONENT));
+
+ assert id.equals(ComplexApplicationContext.INSTANCE.parse(id.toString()));
+
+
+ id = ComplexApplicationContext.INSTANCE.parse("local./webapp.portlet",
Portlet.class);
+ assert id.getComponent(GateInImpl.CATEGORY_COMPONENT) == null;
+ assert
"webapp".equals(id.getComponent(GateInImpl.APPLICATION_COMPONENT));
+ assert "portlet".equals(id.getComponent(GateInImpl.PORTLET_COMPONENT));
+
+ assert id.equals(ComplexApplicationContext.INSTANCE.parse(id.toString()));
+ }
+}
Deleted:
portal/trunk/component/api-impl/src/test/java/org/gatein/portal/api/impl/portal/SiteTestCase.java
===================================================================
---
portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/portal/SiteTestCase.java 2011-08-09
13:52:09 UTC (rev 7030)
+++
portal/trunk/component/api-impl/src/test/java/org/gatein/portal/api/impl/portal/SiteTestCase.java 2011-08-09
18:48:56 UTC (rev 7032)
@@ -1,51 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* 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.gatein.portal.api.impl.portal;
-
-import org.exoplatform.portal.mop.SiteType;
-import org.exoplatform.portal.pom.data.PageKey;
-import org.exoplatform.portal.pom.data.PortalKey;
-import org.gatein.api.portal.Site;
-import org.gatein.api.util.GateInTypesResolver;
-import org.gatein.api.util.Type;
-import org.testng.annotations.Test;
-
-/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
-public class SiteTestCase
-{
- @Test
- public void checkThatTypesAreProperlyResolvedEvenIfClassIsNotLoaded()
- {
- Type portal = GateInTypesResolver.forName("portal", Site.class);
- assert portal != null;
- }
-
- @Test
- public void getAPITypeShouldProperlyResolve()
- {
- assert Site.DASHBOARD.equals(SiteImpl.getAPITypeFrom(new
PageKey(SiteType.USER.getName(), "foo", "foo")));
- assert Site.GROUP.equals(SiteImpl.getAPITypeFrom(new
PageKey(SiteType.GROUP.getName(), "foo", "foo")));
- assert Site.PORTAL.equals(SiteImpl.getAPITypeFrom(new
PortalKey(SiteType.PORTAL.getName(), "foo")));
- assert Site.PORTAL.equals(SiteImpl.getAPITypeFrom(new PortalKey("portal",
"foo")));
- }
-}
Copied:
portal/trunk/component/api-impl/src/test/java/org/gatein/portal/api/impl/portal/SiteTestCase.java
(from rev 7030,
portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/portal/SiteTestCase.java)
===================================================================
---
portal/trunk/component/api-impl/src/test/java/org/gatein/portal/api/impl/portal/SiteTestCase.java
(rev 0)
+++
portal/trunk/component/api-impl/src/test/java/org/gatein/portal/api/impl/portal/SiteTestCase.java 2011-08-09
18:48:56 UTC (rev 7032)
@@ -0,0 +1,51 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* 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.gatein.portal.api.impl.portal;
+
+import org.exoplatform.portal.mop.SiteType;
+import org.exoplatform.portal.pom.data.PageKey;
+import org.exoplatform.portal.pom.data.PortalKey;
+import org.gatein.api.portal.Site;
+import org.gatein.api.util.GateInTypesResolver;
+import org.gatein.api.util.Type;
+import org.testng.annotations.Test;
+
+/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
+public class SiteTestCase
+{
+ @Test
+ public void checkThatTypesAreProperlyResolvedEvenIfClassIsNotLoaded()
+ {
+ Type portal = GateInTypesResolver.forName("portal", Site.class);
+ assert portal != null;
+ }
+
+ @Test
+ public void getAPITypeShouldProperlyResolve()
+ {
+ assert Site.DASHBOARD.equals(SiteImpl.getAPITypeFrom(new
PageKey(SiteType.USER.getName(), "foo", "foo")));
+ assert Site.GROUP.equals(SiteImpl.getAPITypeFrom(new
PageKey(SiteType.GROUP.getName(), "foo", "foo")));
+ assert Site.PORTAL.equals(SiteImpl.getAPITypeFrom(new
PortalKey(SiteType.PORTAL.getName(), "foo")));
+ assert Site.PORTAL.equals(SiteImpl.getAPITypeFrom(new PortalKey("portal",
"foo")));
+ }
+}
Deleted:
portal/trunk/component/api-impl/src/test/java/org/gatein/portal/api/impl/util/AggregatedIterableIdentifiableCollectionTestCase.java
===================================================================
---
portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/util/AggregatedIterableIdentifiableCollectionTestCase.java 2011-08-09
13:52:09 UTC (rev 7030)
+++
portal/trunk/component/api-impl/src/test/java/org/gatein/portal/api/impl/util/AggregatedIterableIdentifiableCollectionTestCase.java 2011-08-09
18:48:56 UTC (rev 7032)
@@ -1,172 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* 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.gatein.portal.api.impl.util;
-
-import org.gatein.api.id.Id;
-import org.gatein.api.id.Identifiable;
-import org.gatein.api.util.IterableIdentifiableCollection;
-import org.gatein.portal.api.impl.GateInImpl;
-import org.gatein.portal.api.impl.IdentifiableImpl;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.NoSuchElementException;
-
-/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
-public class AggregatedIterableIdentifiableCollectionTestCase
-{
- private AggregatedIterableIdentifiableCollection collection;
- private static final IterableIdentifiableCollection fixture3 = new
TestCollection("1", "2", "3");
- private static final IterableIdentifiableCollection fixture4 = new
TestCollection("a", "b", "c", "d");
- private static final IterableIdentifiableCollection fixture1 = new
TestCollection("0");
-
-
- @BeforeMethod
- public void setUp()
- {
- collection = new AggregatedIterableIdentifiableCollection();
- collection.addCollection(fixture3);
- collection.addCollection(fixture1);
- collection.addCollection(fixture4);
- }
-
- @Test
- public void emptyAggregatedShouldWorkAsExpected()
- {
- collection = new AggregatedIterableIdentifiableCollection();
- assert collection.size() == 0;
- IdentifiableImpl foo = createIdentifiable("foo");
- assert !collection.contains(foo);
- assert !collection.contains(foo.getId());
-
- Iterator iterator = collection.iterator();
- assert !iterator.hasNext();
- try
- {
- iterator.next();
- assert false;
- }
- catch (NoSuchElementException e)
- {
- // expected
- }
- }
-
- @Test
- public void testSize()
- {
- assert collection.size() == 8;
- }
-
- @Test
- public void testContains()
- {
- assert collection.contains(createIdentifiable("0"));
- assert collection.contains(createIdentifiable("2"));
- assert collection.contains(createIdentifiable("c"));
- }
-
- @Test
- public void testContainsId()
- {
- assert collection.contains(createIdentifiable("0").getId());
- assert collection.contains(createIdentifiable("1").getId());
- assert collection.contains(createIdentifiable("b").getId());
- }
-
- @Test
- public void iteratingShouldWork()
- {
- int i = 0;
- Iterator first = fixture3.iterator();
- int firstSize = fixture3.size();
- Iterator second = fixture1.iterator();
- int secondSize = fixture1.size();
- Iterator third = fixture4.iterator();
- int thirdSize = fixture4.size();
-
- for (Object identifiable : collection)
- {
- if (i < firstSize)
- {
- assert first.next().equals(identifiable);
- }
- else if (i < firstSize + secondSize)
- {
- assert second.next().equals(identifiable);
- }
- else if (i < firstSize + secondSize + thirdSize)
- {
- assert third.next().equals(identifiable);
- }
- else
- {
- assert false;
- }
-
- i++;
- }
- }
-
- private static IdentifiableImpl createIdentifiable(String name)
- {
- return new IdentifiableImpl(GateInImpl.GROUP_CONTEXT.create(name), name, null);
- }
-
- private static class TestCollection implements
IterableIdentifiableCollection<Identifiable>
- {
- private LinkedHashMap<Id<Identifiable>, Identifiable> elements;
-
- private TestCollection(String... names)
- {
- this.elements = new LinkedHashMap<Id<Identifiable>,
Identifiable>(names.length);
- for (String name : names)
- {
- IdentifiableImpl identifiable = createIdentifiable(name);
- elements.put(identifiable.getId(), identifiable);
- }
- }
-
- public boolean contains(Id<Identifiable> t)
- {
- return elements.containsKey(t);
- }
-
- public int size()
- {
- return elements.size();
- }
-
- public boolean contains(Identifiable identifiable)
- {
- return elements.containsKey(identifiable.getId());
- }
-
- public Iterator<Identifiable> iterator()
- {
- return elements.values().iterator();
- }
- }
-}
Copied:
portal/trunk/component/api-impl/src/test/java/org/gatein/portal/api/impl/util/AggregatedIterableIdentifiableCollectionTestCase.java
(from rev 7030,
portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/util/AggregatedIterableIdentifiableCollectionTestCase.java)
===================================================================
---
portal/trunk/component/api-impl/src/test/java/org/gatein/portal/api/impl/util/AggregatedIterableIdentifiableCollectionTestCase.java
(rev 0)
+++
portal/trunk/component/api-impl/src/test/java/org/gatein/portal/api/impl/util/AggregatedIterableIdentifiableCollectionTestCase.java 2011-08-09
18:48:56 UTC (rev 7032)
@@ -0,0 +1,172 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* 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.gatein.portal.api.impl.util;
+
+import org.gatein.api.id.Id;
+import org.gatein.api.id.Identifiable;
+import org.gatein.api.util.IterableIdentifiableCollection;
+import org.gatein.portal.api.impl.GateInImpl;
+import org.gatein.portal.api.impl.IdentifiableImpl;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.NoSuchElementException;
+
+/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
+public class AggregatedIterableIdentifiableCollectionTestCase
+{
+ private AggregatedIterableIdentifiableCollection collection;
+ private static final IterableIdentifiableCollection fixture3 = new
TestCollection("1", "2", "3");
+ private static final IterableIdentifiableCollection fixture4 = new
TestCollection("a", "b", "c", "d");
+ private static final IterableIdentifiableCollection fixture1 = new
TestCollection("0");
+
+
+ @BeforeMethod
+ public void setUp()
+ {
+ collection = new AggregatedIterableIdentifiableCollection();
+ collection.addCollection(fixture3);
+ collection.addCollection(fixture1);
+ collection.addCollection(fixture4);
+ }
+
+ @Test
+ public void emptyAggregatedShouldWorkAsExpected()
+ {
+ collection = new AggregatedIterableIdentifiableCollection();
+ assert collection.size() == 0;
+ IdentifiableImpl foo = createIdentifiable("foo");
+ assert !collection.contains(foo);
+ assert !collection.contains(foo.getId());
+
+ Iterator iterator = collection.iterator();
+ assert !iterator.hasNext();
+ try
+ {
+ iterator.next();
+ assert false;
+ }
+ catch (NoSuchElementException e)
+ {
+ // expected
+ }
+ }
+
+ @Test
+ public void testSize()
+ {
+ assert collection.size() == 8;
+ }
+
+ @Test
+ public void testContains()
+ {
+ assert collection.contains(createIdentifiable("0"));
+ assert collection.contains(createIdentifiable("2"));
+ assert collection.contains(createIdentifiable("c"));
+ }
+
+ @Test
+ public void testContainsId()
+ {
+ assert collection.contains(createIdentifiable("0").getId());
+ assert collection.contains(createIdentifiable("1").getId());
+ assert collection.contains(createIdentifiable("b").getId());
+ }
+
+ @Test
+ public void iteratingShouldWork()
+ {
+ int i = 0;
+ Iterator first = fixture3.iterator();
+ int firstSize = fixture3.size();
+ Iterator second = fixture1.iterator();
+ int secondSize = fixture1.size();
+ Iterator third = fixture4.iterator();
+ int thirdSize = fixture4.size();
+
+ for (Object identifiable : collection)
+ {
+ if (i < firstSize)
+ {
+ assert first.next().equals(identifiable);
+ }
+ else if (i < firstSize + secondSize)
+ {
+ assert second.next().equals(identifiable);
+ }
+ else if (i < firstSize + secondSize + thirdSize)
+ {
+ assert third.next().equals(identifiable);
+ }
+ else
+ {
+ assert false;
+ }
+
+ i++;
+ }
+ }
+
+ private static IdentifiableImpl createIdentifiable(String name)
+ {
+ return new IdentifiableImpl(GateInImpl.GROUP_CONTEXT.create(name), name, null);
+ }
+
+ private static class TestCollection implements
IterableIdentifiableCollection<Identifiable>
+ {
+ private LinkedHashMap<Id<Identifiable>, Identifiable> elements;
+
+ private TestCollection(String... names)
+ {
+ this.elements = new LinkedHashMap<Id<Identifiable>,
Identifiable>(names.length);
+ for (String name : names)
+ {
+ IdentifiableImpl identifiable = createIdentifiable(name);
+ elements.put(identifiable.getId(), identifiable);
+ }
+ }
+
+ public boolean contains(Id<Identifiable> t)
+ {
+ return elements.containsKey(t);
+ }
+
+ public int size()
+ {
+ return elements.size();
+ }
+
+ public boolean contains(Identifiable identifiable)
+ {
+ return elements.containsKey(identifiable.getId());
+ }
+
+ public Iterator<Identifiable> iterator()
+ {
+ return elements.values().iterator();
+ }
+ }
+}
Modified:
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/ApplicationRegistryService.java
===================================================================
---
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/ApplicationRegistryService.java 2011-08-09
14:55:41 UTC (rev 7031)
+++
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/ApplicationRegistryService.java 2011-08-09
18:48:56 UTC (rev 7032)
@@ -21,6 +21,7 @@
import org.exoplatform.container.component.ComponentPlugin;
import org.exoplatform.portal.config.model.ApplicationType;
+import org.gatein.mop.api.content.ContentType;
import java.util.Comparator;
import java.util.List;
@@ -31,21 +32,21 @@
String REMOTE_DISPLAY_NAME_SUFFIX = " (remote)";
/**
- * Return list of ApplicationCatgory (and applications in each category)
+ * Return list of ApplicationCatgory (and applications in each category)
+ *
* @param accessUser
- * @param appTypes - array of ApplicationType, used to filter applications in each
application category
- */
+ * @param appTypes - array of ApplicationType, used to filter applications in each
application category
+ */
public List<ApplicationCategory> getApplicationCategories(String accessUser,
ApplicationType<?>... appTypes) throws Exception;
public void initListener(ComponentPlugin com) throws Exception;
- /**
- * Return list of all current application categories (unsorted, all Application in all
ApplicationType)
- */
+ /** Return list of all current application categories (unsorted, all Application in
all ApplicationType) */
public List<ApplicationCategory> getApplicationCategories() throws Exception;
/**
* Return list of all current application categories (sorted, all applications in all
types)
+ *
* @param sortComparator - Comparator used to sort the returned list
*/
public List<ApplicationCategory>
getApplicationCategories(Comparator<ApplicationCategory> sortComparator)
@@ -54,6 +55,7 @@
/**
* Return ApplicationCategory with name provided <br/>
* if not found, return null
+ *
* @param name - ApplicationCategory's name
*/
public ApplicationCategory getApplicationCategory(String name) throws Exception;
@@ -61,6 +63,7 @@
/**
* Save an ApplicationCategory to database <br/>
* If it doesn't exist, a new one will be created, if not, it will be updated
+ *
* @param category - ApplicationCategory object that will be saved
*/
public void save(ApplicationCategory category) throws Exception;
@@ -68,12 +71,14 @@
/**
* Remove application category (and all application in it) from database <br/>
* If it doesn't exist, it will be ignored
+ *
* @param category - ApplicationCategory object that will be removed
*/
public void remove(ApplicationCategory category) throws Exception;
/**
* Return list of applications (unsorted) in specific category and have specific type
+ *
* @param category - ApplicationCategory that you want to list applications
* @param appTypes - array of application type
*/
@@ -81,12 +86,14 @@
/**
* Return list of applications (sorted) in specific category and have specific type
- * @param category - ApplicationCategory that you want to list applications
+ *
+ * @param category - ApplicationCategory that you want to list applications
* @param sortComparator - comparator used to sort application list
- * @param appTypes - array of application type
+ * @param appTypes - array of application type
*/
public List<Application> getApplications(ApplicationCategory category,
Comparator<Application> sortComparator,
ApplicationType<?>... appTypes) throws
Exception;
+
/**
* Return list of all Application in database (unsorted) <br/>
* If there are not any Application in database, return an empty list
@@ -95,6 +102,7 @@
/**
* Return Application with id provided
+ *
* @param id - must be valid applicationId (catgoryname/applicationName), if not, this
will throw exception
*/
public Application getApplication(String id) throws Exception;
@@ -102,8 +110,9 @@
/**
* Return Application in specific category and have name provided in param
<br/>
* If it can't be found, return null
+ *
* @param category - name of application category
- * @param name - name of application
+ * @param name - name of application
*/
public Application getApplication(String category, String name) throws Exception;
@@ -111,14 +120,16 @@
* Save Application in an ApplicationCategory <br/>
* If ApplicationCategory or Application don't exist, they'll be created
<br/>
* If Application has been already existed, it will be updated <br/>
- * @param category - ApplicationCategory that your application'll be saved to
- * @param application - Application that will be saved
+ *
+ * @param category - ApplicationCategory that your application'll be saved to
+ * @param application - Application that will be saved
*/
public void save(ApplicationCategory category, Application application) throws
Exception;
/**
* Update an Application <br/>
* It must be existed in database, if not, this will throw an IllegalStateException
+ *
* @param application - Application that you want to update
*/
public void update(Application application) throws Exception;
@@ -126,6 +137,7 @@
/**
* Remove an Application from database <br/>
* If it can't be found, it will be ignored (no exception)
+ *
* @param app - Application that you want to remove, must not be null
*/
public void remove(Application app) throws Exception;
@@ -133,16 +145,21 @@
/**
* Get all deployed portlet, add to portlet's ApplicationCategory <br/>
* If ApplicationCategory currently doesn't exist, it'll be created
<br/>
- * If Application've already existed, it'll be ignored
+ * If Application've already existed, it'll be ignored
*/
public void importAllPortlets() throws Exception;
//TODO: dang.tung
+
/**
* Get all Gadget, add to eXoGadgets application category <br/>
* When first added, it's access permission will be Everyone <br/>
* If ApplicationCategory currently doesn't exist, it'll be created
<br/>
- * Gadget that has been imported will be ignored
+ * Gadget that has been imported will be ignored
*/
public void importExoGadgets() throws Exception;
+
+ Application createOrUpdateApplication(String categoryName, String definitionName,
ContentType<?> contentType, String contentId, String displayName, String
description, List<String> permissions);
+
+ Application createApplicationFrom(org.gatein.pc.api.Portlet portlet);
}
\ No newline at end of file
Modified:
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/impl/ApplicationRegistryServiceImpl.java
===================================================================
---
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/impl/ApplicationRegistryServiceImpl.java 2011-08-09
14:55:41 UTC (rev 7031)
+++
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/impl/ApplicationRegistryServiceImpl.java 2011-08-09
18:48:56 UTC (rev 7032)
@@ -259,7 +259,7 @@
// If the application name contained a beginning slash (which can happen with
WSRP), we need to hack around the
// hardcoding of portlet id expectations >_<
- if(fragments.length == 3 && applicationName.length() == 0)
+ if (fragments.length == 3 && applicationName.length() == 0)
{
applicationName = "/" + fragments[2];
}
@@ -371,8 +371,6 @@
public void importExoGadgets() throws Exception
{
- ContentRegistry registry = getContentRegistry();
-
//
ExoContainer container = ExoContainerContext.getCurrentContainer();
GadgetRegistryService gadgetService =
(GadgetRegistryService)container.getComponentInstanceOfType(GadgetRegistryService.class);
@@ -386,22 +384,16 @@
String categoryName = "Gadgets";
//
- CategoryDefinition category = registry.getCategory(categoryName);
- if (category == null)
- {
- category = registry.createCategory(categoryName);
- category.setDisplayName(categoryName);
- category.setDescription(categoryName);
- category.setAccessPermissions(permissions);
- }
+ CategoryDefinition category = getOrCreateCategoryDefinition(categoryName,
permissions);
//
for (Gadget ele : eXoGadgets)
{
- ContentDefinition app = category.getContentMap().get(ele.getName());
+ String name = ele.getName();
+ ContentDefinition app = category.getContentMap().get(name);
if (app == null)
{
- app = category.createContent(ele.getName(),
org.exoplatform.portal.pom.spi.gadget.Gadget.CONTENT_TYPE, ele.getName());
+ app = category.createContent(name,
org.exoplatform.portal.pom.spi.gadget.Gadget.CONTENT_TYPE, name);
app.setDisplayName(ele.getTitle());
app.setDescription(ele.getDescription());
app.setAccessPermissions(permissions);
@@ -410,10 +402,53 @@
}
}
- public void importAllPortlets() throws Exception
+ public Application createOrUpdateApplication(String categoryName, String
definitionName, ContentType<?> contentType, String contentId, String displayName,
String description, List<String> permissions)
{
+ CategoryDefinition definition = getOrCreateCategoryDefinition(categoryName,
permissions);
+ ContentDefinition content = definition.getContentMap().get(definitionName);
+ if (content == null)
+ {
+ content = createContent(definitionName, contentType, contentId, displayName,
description, permissions, definition);
+ }
+ else
+ {
+ content.setAccessPermissions(permissions);
+ content.setDescription(description);
+ content.setDisplayName(displayName);
+ }
+ return load(content);
+ }
+
+ private ContentDefinition createContent(String definitionName, ContentType<?>
contentType, String contentId, String displayName, String description, List<String>
permissions, CategoryDefinition category)
+ {
+ ContentDefinition content = category.createContent(definitionName, contentType,
contentId);
+ content.setDisplayName(displayName);
+ content.setDescription(description);
+ content.setAccessPermissions(permissions);
+ return content;
+ }
+
+ private ContentDefinition createContentFrom(Application application,
CategoryDefinition category)
+ {
+ return createContent(application.getApplicationName(),
application.getType().getContentType(), application.getContentId(),
application.getDisplayName(), application.getDescription(),
application.getAccessPermissions(), category);
+ }
+
+ private CategoryDefinition getOrCreateCategoryDefinition(String categoryName,
List<String> permissions)
+ {
ContentRegistry registry = getContentRegistry();
+ CategoryDefinition category = registry.getCategory(categoryName);
+ if (category == null)
+ {
+ category = registry.createCategory(categoryName);
+ category.setDisplayName(categoryName);
+ category.setDescription(categoryName);
+ category.setAccessPermissions(permissions);
+ }
+ return category;
+ }
+ public void importAllPortlets() throws Exception
+ {
//
log.info("About to import portlets in application registry");
@@ -427,21 +462,17 @@
for (org.gatein.pc.api.Portlet portlet : portlets)
{
PortletInfo info = portlet.getInfo();
+
+ final Application application = createApplicationFrom(portlet);
+
String portletApplicationName = info.getApplicationName();
- String portletName = portlet.getContext().getId();
+ final String portletName = application.getApplicationName();
- // Need to sanitize portlet and application names in case they contain
characters that would
- // cause an improper Application name
- portletApplicationName = portletApplicationName.replace('/',
'_');
- portletName = portletName.replace('/', '_');
-
MetaInfo metaInfo = portlet.getInfo().getMeta();
LocalizedString keywordsLS = metaInfo.getMetaValue(MetaInfo.KEYWORDS);
- //
+ // Process keywords
Set<String> categoryNames = new HashSet<String>();
-
- // Process keywords
if (keywordsLS != null)
{
String keywords = keywordsLS.getDefaultString();
@@ -492,62 +523,89 @@
// Process category names
for (String categoryName : categoryNames)
{
- CategoryDefinition category = registry.getCategory(categoryName);
+ CategoryDefinition category = getOrCreateCategoryDefinition(categoryName,
permissions);
//
- if (category == null)
- {
- category = registry.createCategory(categoryName);
- category.setDisplayName(categoryName);
- category.setAccessPermissions(permissions);
- }
-
- //
ContentDefinition app = category.getContentMap().get(portletName);
if (app == null)
{
- LocalizedString descriptionLS =
metaInfo.getMetaValue(MetaInfo.DESCRIPTION);
- LocalizedString displayNameLS =
metaInfo.getMetaValue(MetaInfo.DISPLAY_NAME);
- String displayName = getLocalizedStringValue(displayNameLS, portletName);
-
- ContentType<?> contentType;
- String contentId;
- if (remote)
- {
- contentType = WSRP.CONTENT_TYPE;
- contentId = portlet.getContext().getId();
- displayName += REMOTE_DISPLAY_NAME_SUFFIX; // add remote to display
name to make it more obvious that the portlet is remote
- }
- else
- {
- contentType = Portlet.CONTENT_TYPE;
- contentId = info.getApplicationName() + "/" +
info.getName();
- }
-
// Check if the portlet has already existed in this category
List<Application> applications = load(category).getApplications();
boolean isExist = false;
- for (Application application : applications)
+ for (Application categoryApp : applications)
{
- if (application.getContentId().equals(contentId))
+ if (categoryApp.getContentId().equals(application.getContentId()))
{
isExist = true;
break;
}
}
-
+
if (!isExist)
{
- app = category.createContent(portletName, contentType, contentId);
- app.setDisplayName(displayName);
- app.setDescription(getLocalizedStringValue(descriptionLS,
portletName));
- app.setAccessPermissions(permissions);
+ app = createContentFrom(application, category);
}
}
}
}
}
+ public Application createApplicationFrom(org.gatein.pc.api.Portlet portlet)
+ {
+ PortletInfo info = portlet.getInfo();
+
+ String portletName = portlet.getContext().getId();
+
+ portletName = sanitize(portletName);
+
+ MetaInfo metaInfo = portlet.getInfo().getMeta();
+
+ ArrayList<String> permissions = new ArrayList<String>();
+ permissions.add(UserACL.EVERYONE);
+
+ // Additionally categorise the portlet as remote
+ boolean remote = portlet.isRemote();
+
+ LocalizedString descriptionLS = metaInfo.getMetaValue(MetaInfo.DESCRIPTION);
+ LocalizedString displayNameLS = metaInfo.getMetaValue(MetaInfo.DISPLAY_NAME);
+ String displayName = getLocalizedStringValue(displayNameLS, portletName);
+
+ ApplicationType appType;
+ String contentId;
+ if (remote)
+ {
+ appType = ApplicationType.WSRP_PORTLET;
+ contentId = portlet.getContext().getId();
+ displayName += REMOTE_DISPLAY_NAME_SUFFIX; // add remote to display name to
make it more obvious that the portlet is remote
+ }
+ else
+ {
+ appType = ApplicationType.PORTLET;
+ contentId = info.getApplicationName() + "/" + info.getName();
+ }
+
+ Application app = new Application();
+ app.setApplicationName(portletName);
+ app.setType(appType);
+ app.setDisplayName(displayName);
+ app.setDescription(getLocalizedStringValue(descriptionLS, portletName));
+ app.setAccessPermissions(permissions);
+ app.setContentId(contentId);
+
+ return app;
+ }
+
+ /**
+ * Sanitizes the specified name in case it contains characters that would cause
improper Application name.
+ *
+ * @param name
+ * @return
+ */
+ private String sanitize(String name)
+ {
+ return name.replace('/', '_');
+ }
+
private boolean isApplicationType(Application app, ApplicationType<?>...
appTypes)
{
if (appTypes == null || appTypes.length == 0)
Modified: portal/trunk/component/pc/pom.xml
===================================================================
--- portal/trunk/component/pc/pom.xml 2011-08-09 14:55:41 UTC (rev 7031)
+++ portal/trunk/component/pc/pom.xml 2011-08-09 18:48:56 UTC (rev 7032)
@@ -19,59 +19,66 @@
-->
-<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <groupId>org.exoplatform.portal</groupId>
- <artifactId>exo.portal.component</artifactId>
- <version>3.2.0-M02-SNAPSHOT</version>
- </parent>
+<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.exoplatform.portal</groupId>
+ <artifactId>exo.portal.component</artifactId>
+ <version>3.2.0-M02-SNAPSHOT</version>
+ </parent>
- <modelVersion>4.0.0</modelVersion>
- <artifactId>exo.portal.component.pc</artifactId>
- <packaging>jar</packaging>
- <name>GateIn Portal Component PC integration</name>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>exo.portal.component.pc</artifactId>
+ <packaging>jar</packaging>
+ <name>GateIn Portal Component PC integration</name>
- <dependencies>
+ <dependencies>
- <dependency>
- <groupId>org.exoplatform.portal</groupId>
- <artifactId>exo.portal.component.resources</artifactId>
- </dependency>
- <dependency>
- <groupId>org.gatein.common</groupId>
- <artifactId>common-common</artifactId>
- </dependency>
- <dependency>
- <groupId>org.gatein.pc</groupId>
- <artifactId>pc-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.gatein.pc</groupId>
- <artifactId>pc-portlet</artifactId>
- </dependency>
- <dependency>
- <groupId>org.gatein.pc</groupId>
- <artifactId>pc-mc</artifactId>
- </dependency>
- <dependency>
- <groupId>org.gatein.pc</groupId>
- <artifactId>pc-federation</artifactId>
- </dependency>
- <dependency>
- <groupId>org.gatein.pc</groupId>
- <artifactId>pc-bridge</artifactId>
- </dependency>
- <dependency>
- <groupId>org.gatein.wci</groupId>
- <artifactId>wci-wci</artifactId>
- </dependency>
- <dependency>
- <groupId>org.exoplatform.kernel</groupId>
- <artifactId>exo.kernel.container</artifactId>
- </dependency>
+ <dependency>
+ <groupId>org.exoplatform.portal</groupId>
+ <artifactId>exo.portal.component.resources</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.gatein.common</groupId>
+ <artifactId>common-common</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.gatein.pc</groupId>
+ <artifactId>pc-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.gatein.pc</groupId>
+ <artifactId>pc-portlet</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.gatein.pc</groupId>
+ <artifactId>pc-mc</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.gatein.pc</groupId>
+ <artifactId>pc-federation</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.gatein.pc</groupId>
+ <artifactId>pc-bridge</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.gatein.wci</groupId>
+ <artifactId>wci-wci</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.kernel</groupId>
+ <artifactId>exo.kernel.container</artifactId>
+ </dependency>
- </dependencies>
-
- <build>
- </build>
+ <!-- GateIn API support -->
+ <dependency>
+ <groupId>org.gatein.api</groupId>
+ <artifactId>gatein-java-api</artifactId>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ </build>
</project>
Modified:
portal/trunk/component/pc/src/main/java/org/exoplatform/portal/pc/ExoKernelIntegration.java
===================================================================
---
portal/trunk/component/pc/src/main/java/org/exoplatform/portal/pc/ExoKernelIntegration.java 2011-08-09
14:55:41 UTC (rev 7031)
+++
portal/trunk/component/pc/src/main/java/org/exoplatform/portal/pc/ExoKernelIntegration.java 2011-08-09
18:48:56 UTC (rev 7032)
@@ -22,6 +22,7 @@
import org.exoplatform.container.ExoContainer;
import org.exoplatform.container.ExoContainerContext;
import org.exoplatform.services.resources.ResourceBundleService;
+import org.gatein.api.GateIn;
import org.gatein.pc.api.PortletInvoker;
import org.gatein.pc.bridge.BridgeInterceptor;
import org.gatein.pc.federation.FederatingPortletInvoker;
@@ -66,7 +67,7 @@
* We enforce the dependency with the ResourceBundleService since it must be stared
before the
* <code>portletApplicationRegistry</code>
*
- * @param context the exo container context
+ * @param context the exo container context
* @param resourceBundleService the resource bundle service that is here for the sake
of creating a dependency
*/
public ExoKernelIntegration(ExoContainerContext context, ResourceBundleService
resourceBundleService)
@@ -83,13 +84,15 @@
// The portlet application deployer
portletApplicationRegistry = new ExoPortletApplicationDeployer();
portletApplicationRegistry.setContainerPortletInvoker(containerPortletInvoker);
+ GateIn gateIn = (GateIn)container.getComponentInstanceOfType(GateIn.class);
+
((ExoPortletApplicationDeployer)portletApplicationRegistry).setAPIInstance(gateIn);
//Container Stack
ContainerPortletDispatcher portletContainerDispatcher = new
ContainerPortletDispatcher();
-
+
// Federating portlet invoker
FederatingPortletInvoker federatingPortletInvoker = new
FederatingPortletInvokerService();
-
+
EventPayloadInterceptor eventPayloadInterceptor = new EventPayloadInterceptor();
eventPayloadInterceptor.setNext(portletContainerDispatcher);
RequestAttributeConversationInterceptor requestAttributeConversationInterceptor =
Modified:
portal/trunk/component/pc/src/main/java/org/exoplatform/portal/pc/ExoPortletApplicationDeployer.java
===================================================================
---
portal/trunk/component/pc/src/main/java/org/exoplatform/portal/pc/ExoPortletApplicationDeployer.java 2011-08-09
14:55:41 UTC (rev 7031)
+++
portal/trunk/component/pc/src/main/java/org/exoplatform/portal/pc/ExoPortletApplicationDeployer.java 2011-08-09
18:48:56 UTC (rev 7032)
@@ -1,16 +1,16 @@
/**
* Copyright (C) 2009 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
@@ -21,6 +21,7 @@
import org.exoplatform.commons.utils.PropertyManager;
import org.exoplatform.commons.utils.Safe;
+import org.gatein.api.GateIn;
import org.gatein.common.logging.Logger;
import org.gatein.common.logging.LoggerFactory;
import org.gatein.pc.mc.PortletApplicationDeployer;
@@ -44,6 +45,7 @@
public class ExoPortletApplicationDeployer extends PortletApplicationDeployer
{
private final Logger log =
LoggerFactory.getLogger(ExoPortletApplicationDeployer.class);
+ private GateIn gateIn;
@Override
protected PortletApplication10MetaData buildPortletApplicationMetaData(WebApp webApp)
@@ -80,6 +82,7 @@
log.warn("The global portlet metadata is not configured");
}
+ webApp.getServletContext().setAttribute(GateIn.GATEIN_API, gateIn);
}
return md;
}
@@ -89,8 +92,8 @@
* to ensure independence between portlet applications
*
* @return
- * @throws FileNotFoundException
- * @throws JBossXBException
+ * @throws FileNotFoundException
+ * @throws JBossXBException
*/
private GlobalPortletMetaData loadGlobalMetadata(String globalPortletLocation) throws
FileNotFoundException,
JBossXBException
@@ -106,4 +109,9 @@
Safe.close(in);
}
}
+
+ public void setAPIInstance(GateIn gateIn)
+ {
+ this.gateIn = gateIn;
+ }
}
Modified: portal/trunk/component/pom.xml
===================================================================
--- portal/trunk/component/pom.xml 2011-08-09 14:55:41 UTC (rev 7031)
+++ portal/trunk/component/pom.xml 2011-08-09 18:48:56 UTC (rev 7032)
@@ -45,6 +45,7 @@
<module>scripting</module>
<module>management</module>
<module>identity</module>
+ <module>api-impl</module>
</modules>
</project>
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/UserACL.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/UserACL.java 2011-08-09
14:55:41 UTC (rev 7031)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/UserACL.java 2011-08-09
18:48:56 UTC (rev 7032)
@@ -225,6 +225,11 @@
public boolean hasPermission(PortalConfig pconfig)
{
Identity identity = getIdentity();
+ return hasPermission(identity, pconfig);
+ }
+
+ public boolean hasPermission(Identity identity, PortalConfig pconfig)
+ {
if (hasPermission(identity, pconfig.getEditPermission()))
{
pconfig.setModifiable(true);
Modified: portal/trunk/examples/portlets/api/pom.xml
===================================================================
--- portal/trunk/examples/portlets/api/pom.xml 2011-08-09 14:55:41 UTC (rev 7031)
+++ portal/trunk/examples/portlets/api/pom.xml 2011-08-09 18:48:56 UTC (rev 7032)
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<!--
@@ -35,5 +36,10 @@
<artifactId>portlet-api</artifactId>
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>org.gatein.api</groupId>
+ <artifactId>gatein-java-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
Copied:
portal/trunk/examples/portlets/api/src/main/java/org/gatein/portal/samples/api/ContentRegistryPortlet.java
(from rev 7030,
portal/branches/api/examples/portlets/api/src/main/java/org/gatein/portal/samples/api/ContentRegistryPortlet.java)
===================================================================
---
portal/trunk/examples/portlets/api/src/main/java/org/gatein/portal/samples/api/ContentRegistryPortlet.java
(rev 0)
+++
portal/trunk/examples/portlets/api/src/main/java/org/gatein/portal/samples/api/ContentRegistryPortlet.java 2011-08-09
18:48:56 UTC (rev 7032)
@@ -0,0 +1,90 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* 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.gatein.portal.samples.api;
+
+import org.gatein.api.GateIn;
+import org.gatein.api.content.Category;
+import org.gatein.api.content.ManagedContent;
+import org.gatein.api.util.IterableCollection;
+import org.gatein.api.util.IterableIdentifiableCollection;
+
+import javax.portlet.GenericPortlet;
+import javax.portlet.PortletConfig;
+import javax.portlet.PortletException;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
+public class ContentRegistryPortlet extends GenericPortlet
+{
+ private GateIn gateIn;
+
+ @Override
+ public void init(PortletConfig config) throws PortletException
+ {
+ super.init(config);
+ gateIn = (GateIn)config.getPortletContext().getAttribute(GateIn.GATEIN_API);
+ }
+
+ @Override
+ protected void doView(RenderRequest request, RenderResponse response) throws
PortletException, IOException
+ {
+ PrintWriter writer = response.getWriter();
+
+ writer.println("<h1>Categories</h1>");
+
+ writer.println("<ul>");
+ IterableIdentifiableCollection<Category> categories =
gateIn.getDefaultPortal().getContentRegistry().getAllCategories();
+ for (Category category : categories)
+ {
+ writer.println("<li>");
+ outputCategory(category, writer);
+ writer.println("</li>");
+ }
+ writer.println("</ul>");
+ }
+
+ private void outputCategory(Category category, PrintWriter writer) throws IOException
+ {
+ writer.println("<h2>" + category.getDisplayName() +
"</h2>");
+ writer.println("<ul>");
+
+ final IterableCollection<ManagedContent> managedContents =
category.getManagedContents();
+ for (ManagedContent managedContent : managedContents)
+ {
+ outputManagedContent(managedContent, writer);
+ }
+
+ writer.println("</ul><br/>");
+ }
+
+ private void outputManagedContent(ManagedContent content, PrintWriter writer) throws
IOException
+ {
+ writer.println("<h3>" + content.getDisplayName() +
"</h3>");
+ writer.println("<h4>Name:" + content.getName() +
"</h4>");
+ writer.println("Content: " + content.getContent());
+ writer.println("<br/>");
+ }
+}
Copied:
portal/trunk/examples/portlets/api/src/main/java/org/gatein/portal/samples/api/NavigationPortlet.java
(from rev 7030,
portal/branches/api/examples/portlets/api/src/main/java/org/gatein/portal/samples/api/NavigationPortlet.java)
===================================================================
---
portal/trunk/examples/portlets/api/src/main/java/org/gatein/portal/samples/api/NavigationPortlet.java
(rev 0)
+++
portal/trunk/examples/portlets/api/src/main/java/org/gatein/portal/samples/api/NavigationPortlet.java 2011-08-09
18:48:56 UTC (rev 7032)
@@ -0,0 +1,113 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* 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.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;
+
+import javax.portlet.GenericPortlet;
+import javax.portlet.PortletConfig;
+import javax.portlet.PortletException;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
+public class NavigationPortlet extends GenericPortlet
+{
+ private GateIn gateIn;
+
+ @Override
+ public void init(PortletConfig config) throws PortletException
+ {
+ super.init(config);
+ gateIn = (GateIn)config.getPortletContext().getAttribute(GateIn.GATEIN_API);
+ }
+
+ @Override
+ protected void doView(RenderRequest request, RenderResponse response) throws
PortletException, IOException
+ {
+ Id userId = gateIn.userId("root");
+
+ PrintWriter writer = response.getWriter();
+
+ writer.println("<h1>Portal Sites</h1>");
+ IterableIdentifiableCollection<? extends Site> sites =
gateIn.getPortalSites(userId);
+ for (Site site : sites)
+ {
+ outputSite(site, writer);
+ }
+
+ writer.println("<h1>Group Sites</h1>");
+ sites = gateIn.getGroupSites(userId);
+ for (Site site : sites)
+ {
+ outputSite(site, writer);
+ }
+
+ writer.println("<h1>Dashboard</h1>");
+ outputSite(gateIn.getDashboard(userId), writer);
+ }
+
+ private void outputSite(Site site, PrintWriter writer) throws IOException
+ {
+ Navigation navigation = site.getNavigation();
+
+ IterableIdentifiableCollection<Navigation> adminNodes = navigation.getAll();
+
+ writer.println("<h2>" + site.getDisplayName() +
"</h2>");
+ writer.println("<ul>");
+
+ for (Navigation adminNode : adminNodes)
+ {
+ outputNode(adminNode, writer);
+ }
+
+ writer.println("</ul><br/>");
+ }
+
+ private void outputNode(Navigation node, PrintWriter writer)
+ {
+ IterableIdentifiableCollection<Navigation> children = node.getAll();
+ int size = children.size();
+ boolean isLeaf = size == 0;
+ writer.println("<li>"
+ + (isLeaf ? "<a style='font-weight: bold; text-decoration:
underline; color: #336666;' href='" + node.getURI() + "'>" :
"")
+ + node.getDisplayName()
+ + (isLeaf ? "</a>" : "")
+ + "</li>");
+ if (size != 0)
+ {
+ writer.println("<ul>");
+ for (Navigation child : children)
+ {
+ outputNode(child, writer);
+ }
+ writer.println("</ul>");
+ }
+ }
+}
Modified: portal/trunk/examples/portlets/api/src/main/webapp/WEB-INF/portlet.xml
===================================================================
--- portal/trunk/examples/portlets/api/src/main/webapp/WEB-INF/portlet.xml 2011-08-09
14:55:41 UTC (rev 7031)
+++ portal/trunk/examples/portlets/api/src/main/webapp/WEB-INF/portlet.xml 2011-08-09
18:48:56 UTC (rev 7032)
@@ -26,62 +26,98 @@
xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_1...
http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd">
-->
- <portlet-app
xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-
xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2...
http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd" version="1.0">
+<portlet-app
xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2...
http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
+ version="1.0">
<portlet>
- <description xml:lang="EN">Public Render Parameter API
Portlet</description>
- <portlet-name>PRPAPIPortlet</portlet-name>
- <display-name xml:lang="EN">Public Render Parameter API
Portlet</display-name>
- <portlet-class>org.gatein.portal.samples.api.PRPPortlet</portlet-class>
+ <description xml:lang="EN">Public Render Parameter API
Portlet</description>
+ <portlet-name>PRPAPIPortlet</portlet-name>
+ <display-name xml:lang="EN">Public Render Parameter API
Portlet</display-name>
+
<portlet-class>org.gatein.portal.samples.api.PRPPortlet</portlet-class>
- <supports>
- <mime-type>text/html</mime-type>
- </supports>
+ <supports>
+ <mime-type>text/html</mime-type>
+ </supports>
- <portlet-info>
- <title>PRP Portlet</title>
- <short-title>PRP Portlet</short-title>
- <keywords>Sample</keywords>
- </portlet-info>
+ <portlet-info>
+ <title>PRP Portlet</title>
+ <short-title>PRP Portlet</short-title>
+ <keywords>Sample</keywords>
+ </portlet-info>
-
<supported-public-render-parameter>navigation_uri</supported-public-render-parameter>
-
<supported-public-render-parameter>page_name</supported-public-render-parameter>
-
<supported-public-render-parameter>site_type</supported-public-render-parameter>
-
<supported-public-render-parameter>site_name</supported-public-render-parameter>
-
<supported-public-render-parameter>window_width</supported-public-render-parameter>
-
<supported-public-render-parameter>window_height</supported-public-render-parameter>
-
<supported-public-render-parameter>window_show_info_bar</supported-public-render-parameter>
+
<supported-public-render-parameter>navigation_uri</supported-public-render-parameter>
+
<supported-public-render-parameter>page_name</supported-public-render-parameter>
+
<supported-public-render-parameter>site_type</supported-public-render-parameter>
+
<supported-public-render-parameter>site_name</supported-public-render-parameter>
+
<supported-public-render-parameter>window_width</supported-public-render-parameter>
+
<supported-public-render-parameter>window_height</supported-public-render-parameter>
+
<supported-public-render-parameter>window_show_info_bar</supported-public-render-parameter>
- </portlet>
+ </portlet>
- <public-render-parameter>
- <identifier>navigation_uri</identifier>
- <qname
xmlns:prp='http://www.gatein.org/xml/ns/prp_1_0'>prp:navigatio...
- </public-render-parameter>
- <public-render-parameter>
- <identifier>page_name</identifier>
- <qname
xmlns:prp='http://www.gatein.org/xml/ns/prp_1_0'>prp:page_name...
- </public-render-parameter>
- <public-render-parameter>
- <identifier>site_type</identifier>
- <qname
xmlns:prp='http://www.gatein.org/xml/ns/prp_1_0'>prp:site_type...
- </public-render-parameter>
- <public-render-parameter>
- <identifier>site_name</identifier>
- <qname
xmlns:prp='http://www.gatein.org/xml/ns/prp_1_0'>prp:site_name...
- </public-render-parameter>
- <public-render-parameter>
- <identifier>window_width</identifier>
- <qname
xmlns:prp='http://www.gatein.org/xml/ns/prp_1_0'>prp:window_wi...
- </public-render-parameter>
- <public-render-parameter>
- <identifier>window_height</identifier>
- <qname
xmlns:prp='http://www.gatein.org/xml/ns/prp_1_0'>prp:window_he...
- </public-render-parameter>
- <public-render-parameter>
- <identifier>window_show_info_bar</identifier>
- <qname
xmlns:prp='http://www.gatein.org/xml/ns/prp_1_0'>prp:window_sh...
- </public-render-parameter>
+ <portlet>
+ <description xml:lang="EN">Navigation Portlet Example using
GateIn's public API</description>
+ <portlet-name>NavigationAPIPortlet</portlet-name>
+ <display-name xml:lang="EN">API Navigation
Portlet</display-name>
+
<portlet-class>org.gatein.portal.samples.api.NavigationPortlet</portlet-class>
+ <supports>
+ <mime-type>text/html</mime-type>
+ </supports>
+
+ <portlet-info>
+ <title>API Navigation Portlet</title>
+ <short-title>Navigation Portlet</short-title>
+ <keywords>Sample</keywords>
+ </portlet-info>
+ </portlet>
+
+ <portlet>
+ <description xml:lang="EN">Content Registry Portlet Example using
GateIn's public API</description>
+ <portlet-name>ContentRegistryAPIPortlet</portlet-name>
+ <display-name xml:lang="EN">API Content Registry
Portlet</display-name>
+
<portlet-class>org.gatein.portal.samples.api.ContentRegistryPortlet</portlet-class>
+
+ <supports>
+ <mime-type>text/html</mime-type>
+ </supports>
+
+ <portlet-info>
+ <title>API Content Registry Portlet</title>
+ <short-title>Content Registry Portlet</short-title>
+ <keywords>Sample</keywords>
+ </portlet-info>
+ </portlet>
+
+ <public-render-parameter>
+ <identifier>navigation_uri</identifier>
+ <qname
xmlns:prp='http://www.gatein.org/xml/ns/prp_1_0'>prp:navigatio...
+ </public-render-parameter>
+ <public-render-parameter>
+ <identifier>page_name</identifier>
+ <qname
xmlns:prp='http://www.gatein.org/xml/ns/prp_1_0'>prp:page_name...
+ </public-render-parameter>
+ <public-render-parameter>
+ <identifier>site_type</identifier>
+ <qname
xmlns:prp='http://www.gatein.org/xml/ns/prp_1_0'>prp:site_type...
+ </public-render-parameter>
+ <public-render-parameter>
+ <identifier>site_name</identifier>
+ <qname
xmlns:prp='http://www.gatein.org/xml/ns/prp_1_0'>prp:site_name...
+ </public-render-parameter>
+ <public-render-parameter>
+ <identifier>window_width</identifier>
+ <qname
xmlns:prp='http://www.gatein.org/xml/ns/prp_1_0'>prp:window_wi...
+ </public-render-parameter>
+ <public-render-parameter>
+ <identifier>window_height</identifier>
+ <qname
xmlns:prp='http://www.gatein.org/xml/ns/prp_1_0'>prp:window_he...
+ </public-render-parameter>
+ <public-render-parameter>
+ <identifier>window_show_info_bar</identifier>
+ <qname
xmlns:prp='http://www.gatein.org/xml/ns/prp_1_0'>prp:window_sh...
+ </public-render-parameter>
+
</portlet-app>
Modified: portal/trunk/packaging/jboss-as5/pkg/pom.xml
===================================================================
--- portal/trunk/packaging/jboss-as5/pkg/pom.xml 2011-08-09 14:55:41 UTC (rev 7031)
+++ portal/trunk/packaging/jboss-as5/pkg/pom.xml 2011-08-09 18:48:56 UTC (rev 7032)
@@ -1,5 +1,6 @@
<?xml version="1.0"?>
-<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
@@ -18,7 +19,7 @@
<!-- The following two properties should not be changed! -->
<jbossas.version>5.1.0.GA</jbossas.version>
<jbossas.dist.version>5.1.0.GA-jdk6</jbossas.dist.version>
-
+
<servers.dir>${project.basedir}/../../servers</servers.dir>
<jbossas.path>${servers.dir}</jbossas.path>
<jbossas.name>jboss-${jbossas.version}</jbossas.name>
@@ -294,6 +295,20 @@
<artifactId>picketlink-idm-ldap</artifactId>
</dependency>
+ <!-- GateIn API -->
+ <dependency>
+ <groupId>org.gatein.api</groupId>
+ <artifactId>java-api-impl</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.gatein.api</groupId>
+ <artifactId>gatein-java-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.gatein.api</groupId>
+ <artifactId>generic-id-impl</artifactId>
+ </dependency>
+
<!-- Gatein common -->
<dependency>
<groupId>org.gatein.common</groupId>
@@ -514,9 +529,9 @@
<!-- Provided -->
<dependency>
- <groupId>javax.inject</groupId>
- <artifactId>javax.inject</artifactId>
- <version>1</version>
+ <groupId>javax.inject</groupId>
+ <artifactId>javax.inject</artifactId>
+ <version>1</version>
</dependency>
<dependency>
<groupId>javax.activation</groupId>
@@ -644,8 +659,8 @@
<version>2.0.235</version>
</dependency>
<dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
@@ -812,19 +827,19 @@
<version>1.2.3</version>
</dependency>
<dependency>
- <groupId>org.apache.tika</groupId>
- <artifactId>tika-core</artifactId>
- <version>0.7</version>
+ <groupId>org.apache.tika</groupId>
+ <artifactId>tika-core</artifactId>
+ <version>0.7</version>
</dependency>
<dependency>
- <groupId>org.apache.tika</groupId>
- <artifactId>tika-parsers</artifactId>
- <version>0.7</version>
+ <groupId>org.apache.tika</groupId>
+ <artifactId>tika-parsers</artifactId>
+ <version>0.7</version>
</dependency>
<dependency>
- <groupId>com.google.javascript</groupId>
- <artifactId>closure-compiler</artifactId>
- <version>r706</version>
+ <groupId>com.google.javascript</groupId>
+ <artifactId>closure-compiler</artifactId>
+ <version>r706</version>
</dependency>
<dependency>
@@ -941,17 +956,17 @@
<requireProperty>
<property>jbossas.path</property>
<message>"
-You must define the property 'jbossas.path'
-to give the path to the directory where you store your applications servers.
-"
+ You must define the property 'jbossas.path'
+ to give the path to the directory where you store your
applications servers.
+ "
</message>
</requireProperty>
<requireProperty>
<property>jbossas.name</property>
<message>"
-You must define the property 'jbossas.name'
-to give the name of the directory where JBoss AS is stored.
-"
+ You must define the property 'jbossas.name'
+ to give the name of the directory where JBoss AS is
stored.
+ "
</message>
</requireProperty>
<requireFilesExist>
@@ -959,13 +974,14 @@
<file>${jbossas.path}/${jbossas.name}/</file>
</files>
<message>"
-The following JBoss AS directory doesn't exist :
+ The following JBoss AS directory doesn't exist :
${jbossas.path}/${jbossas.name}
-Make JBoss AS instance available at that location, or use -Dservers.dir=PATH to point to
the correct location of servers directory
-and/or -Djbossas.name=NAME to point to the correct directory under the servers
directory.
-You can also use -Pdownload to automatically provide JBoss AS instance.
-"
+ Make JBoss AS instance available at that location, or use
-Dservers.dir=PATH to point to
+ the correct location of servers directory
+ and/or -Djbossas.name=NAME to point to the correct
directory under the servers directory.
+ You can also use -Pdownload to automatically provide JBoss
AS instance.
+ "
</message>
</requireFilesExist>
</rules>
@@ -1001,9 +1017,9 @@
<configuration>
<target>
<ant antfile="${project.basedir}/package.xml"
inheritRefs="true">
- <target name="package" />
- <property name="maven.project.basedir"
value="${project.basedir}" />
- <property name="maven.project.build.directory"
value="${project.build.directory}" />
+ <target name="package"/>
+ <property name="maven.project.basedir"
value="${project.basedir}"/>
+ <property name="maven.project.build.directory"
value="${project.build.directory}"/>
</ant>
</target>
</configuration>
@@ -1012,8 +1028,8 @@
</plugin>
</plugins>
</build>
-
+
<profiles>
<profile>
<id>pkg-jbossas5</id>
@@ -1040,9 +1056,9 @@
<requireProperty>
<property>exo.projects.directory.dependencies</property>
<message>"
-You must define the property 'exo.projects.directory.dependencies'
-to specify the path to the directory where you store your application servers.
-"
+ You must define the property
'exo.projects.directory.dependencies'
+ to specify the path to the directory where you store
your application servers.
+ "
</message>
</requireProperty>
</rules>
@@ -1059,9 +1075,9 @@
<requireProperty>
<property>exo.projects.app.jboss5.version</property>
<message>"
-You must define the property 'exo.projects.app.jboss5.version'
-to specify the name of the directory where JBoss AS is stored.
-"
+ You must define the property
'exo.projects.app.jboss5.version'
+ to specify the name of the directory where JBoss AS
is stored.
+ "
</message>
</requireProperty>
</rules>
@@ -1082,13 +1098,15 @@
</file>
</files>
<message>"
-The following JBoss AS directory doesn't exist :
+ The following JBoss AS directory doesn't exist :
${exo.projects.directory.dependencies}/${exo.projects.app.jboss5.version}
-Make JBoss AS instance available at that location, or use
-Dexo.projects.directory.dependencies=PATH to point to the correct location
-of servers directory and/or -Dexo.projects.app.jboss5.version=NAME to point to the
correct directory under the servers directory.
-You can also use -Pdownload to automatically provide JBoss AS instance.
-"
+ Make JBoss AS instance available at that location, or
use
+ -Dexo.projects.directory.dependencies=PATH to point
to the correct location
+ of servers directory and/or
-Dexo.projects.app.jboss5.version=NAME to point to the
+ correct directory under the servers directory.
+ You can also use -Pdownload to automatically provide
JBoss AS instance.
+ "
</message>
</requireFilesExist>
</rules>
@@ -1098,10 +1116,10 @@
<execution>
<id>check-jboss-environment-ready</id>
<phase>none</phase>
- </execution>
+ </execution>
</executions>
</plugin>
-
+
</plugins>
</build>
</profile>
@@ -1141,35 +1159,36 @@
</goals>
<configuration>
<target>
- <available property="jbossas.dir.exists"
type="dir" file="${jbossas.dir}" />
+ <available property="jbossas.dir.exists"
type="dir" file="${jbossas.dir}"/>
<fail if="jbossas.dir.exists">"
-Destination JBossAS directory exists already:
+ Destination JBossAS directory exists already:
${jbossas.dir}
-Either rename it, delete it, or deactivate -Pdownload profile.
-"
+ Either rename it, delete it, or deactivate -Pdownload
profile.
+ "
</fail>
- <property name="jbossas.zip"
value="${jbossas.path}/jboss-${jbossas.dist.version}.zip" />
+ <property name="jbossas.zip"
value="${jbossas.path}/jboss-${jbossas.dist.version}.zip"/>
<!-- Autocreate servers.dir if necessary -->
- <mkdir dir="${jbossas.path}" />
+ <mkdir dir="${jbossas.path}"/>
<!-- Download JBossAS unless already downloaded -->
<ant
antfile="${project.basedir}/download-jboss.xml">
- <target name="download-jboss" />
- <property name="url"
value="http://sourceforge.net/projects/jboss/files/JBoss/JBoss-${jbo...
/>
- <property name="dest"
value="${jbossas.zip}" />
+ <target name="download-jboss"/>
+ <property name="url"
+
value="http://sourceforge.net/projects/jboss/files/JBoss/JBoss-${jbo...
+ <property name="dest"
value="${jbossas.zip}"/>
</ant>
<!-- Extract downloaded JBossAS to servers dir -->
- <unzip src="${jbossas.zip}"
dest="${jbossas.path}" overwrite="false" />
+ <unzip src="${jbossas.zip}"
dest="${jbossas.path}" overwrite="false"/>
<ant antfile="${project.basedir}/package.xml"
inheritRefs="true">
- <target name="package" />
- <property name="maven.project.basedir"
value="${project.basedir}" />
- <property
name="maven.project.build.directory"
value="${project.build.directory}" />
+ <target name="package"/>
+ <property name="maven.project.basedir"
value="${project.basedir}"/>
+ <property
name="maven.project.build.directory"
value="${project.build.directory}"/>
</ant>
</target>
</configuration>
@@ -1179,7 +1198,7 @@
</plugins>
</build>
</profile>
-
+
<profile>
<id>bundle</id>
<build>
@@ -1197,8 +1216,10 @@
</goals>
<configuration>
<target>
- <zip
destfile="${project.build.directory}/GateIn-${project.version}-jbossas.zip"
basedir="${jbossas.target.dir}" />
- <attachartifact
file="${project.build.directory}/GateIn-${project.version}-jbossas.zip"
classifier="bundle" type="zip" />
+ <zip
destfile="${project.build.directory}/GateIn-${project.version}-jbossas.zip"
+ basedir="${jbossas.target.dir}"/>
+ <attachartifact
file="${project.build.directory}/GateIn-${project.version}-jbossas.zip"
+ classifier="bundle"
type="zip"/>
</target>
</configuration>
</execution>
@@ -1207,5 +1228,5 @@
</plugins>
</build>
</profile>
- </profiles>
+ </profiles>
</project>
Modified: portal/trunk/packaging/jboss-as6/pkg/pom.xml
===================================================================
--- portal/trunk/packaging/jboss-as6/pkg/pom.xml 2011-08-09 14:55:41 UTC (rev 7031)
+++ portal/trunk/packaging/jboss-as6/pkg/pom.xml 2011-08-09 18:48:56 UTC (rev 7032)
@@ -1,5 +1,6 @@
<?xml version="1.0"?>
-<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
@@ -342,6 +343,20 @@
<artifactId>pc-bridge</artifactId>
</dependency>
+ <!-- GateIn API -->
+ <dependency>
+ <groupId>org.gatein.api</groupId>
+ <artifactId>java-api-impl</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.gatein.api</groupId>
+ <artifactId>gatein-java-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.gatein.api</groupId>
+ <artifactId>generic-id-impl</artifactId>
+ </dependency>
+
<!-- GateIn MOP -->
<dependency>
<groupId>org.gatein.mop</groupId>
@@ -512,9 +527,9 @@
<!-- Provided -->
<dependency>
- <groupId>javax.inject</groupId>
- <artifactId>javax.inject</artifactId>
- <version>1</version>
+ <groupId>javax.inject</groupId>
+ <artifactId>javax.inject</artifactId>
+ <version>1</version>
</dependency>
<dependency>
<groupId>javax.activation</groupId>
@@ -635,8 +650,8 @@
<version>2.0.235</version>
</dependency>
<dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
@@ -803,19 +818,19 @@
<version>1.2.3</version>
</dependency>
<dependency>
- <groupId>org.apache.tika</groupId>
- <artifactId>tika-core</artifactId>
- <version>0.7</version>
+ <groupId>org.apache.tika</groupId>
+ <artifactId>tika-core</artifactId>
+ <version>0.7</version>
</dependency>
<dependency>
- <groupId>org.apache.tika</groupId>
- <artifactId>tika-parsers</artifactId>
- <version>0.7</version>
+ <groupId>org.apache.tika</groupId>
+ <artifactId>tika-parsers</artifactId>
+ <version>0.7</version>
</dependency>
<dependency>
- <groupId>com.google.javascript</groupId>
- <artifactId>closure-compiler</artifactId>
- <version>r706</version>
+ <groupId>com.google.javascript</groupId>
+ <artifactId>closure-compiler</artifactId>
+ <version>r706</version>
</dependency>
<dependency>
@@ -932,17 +947,17 @@
<requireProperty>
<property>jbossas.path</property>
<message>"
-You must define the property 'jbossas.path'
-to give the path to the directory where you store your applications servers.
-"
+ You must define the property 'jbossas.path'
+ to give the path to the directory where you store your
applications servers.
+ "
</message>
</requireProperty>
<requireProperty>
<property>jbossas.name</property>
<message>"
-You must define the property 'jbossas.name'
-to give the name of the directory where JBoss AS is stored.
-"
+ You must define the property 'jbossas.name'
+ to give the name of the directory where JBoss AS is
stored.
+ "
</message>
</requireProperty>
<requireFilesExist>
@@ -950,13 +965,14 @@
<file>${jbossas.path}/${jbossas.name}/</file>
</files>
<message>"
-The following JBoss AS directory doesn't exist :
+ The following JBoss AS directory doesn't exist :
${jbossas.path}/${jbossas.name}
-Make JBoss AS instance available at that location, or use -Dservers.dir=PATH to point to
the correct location of servers directory
-and/or -Djbossas.name=NAME to point to the correct directory under the servers
directory.
-You can also use -Pdownload to automatically provide JBoss AS instance.
-"
+ Make JBoss AS instance available at that location, or use
-Dservers.dir=PATH to point to
+ the correct location of servers directory
+ and/or -Djbossas.name=NAME to point to the correct
directory under the servers directory.
+ You can also use -Pdownload to automatically provide JBoss
AS instance.
+ "
</message>
</requireFilesExist>
</rules>
@@ -992,9 +1008,9 @@
<configuration>
<target>
<ant antfile="${project.basedir}/package.xml"
inheritRefs="true">
- <target name="package" />
- <property name="maven.project.basedir"
value="${project.basedir}" />
- <property name="maven.project.build.directory"
value="${project.build.directory}" />
+ <target name="package"/>
+ <property name="maven.project.basedir"
value="${project.basedir}"/>
+ <property name="maven.project.build.directory"
value="${project.build.directory}"/>
</ant>
</target>
</configuration>
@@ -1031,9 +1047,9 @@
<requireProperty>
<property>exo.projects.directory.dependencies</property>
<message>"
-You must define the property 'exo.projects.directory.dependencies'
-to specify the path to the directory where you store your application servers.
-"
+ You must define the property
'exo.projects.directory.dependencies'
+ to specify the path to the directory where you store
your application servers.
+ "
</message>
</requireProperty>
</rules>
@@ -1050,9 +1066,9 @@
<requireProperty>
<property>exo.projects.app.jboss6.version</property>
<message>"
-You must define the property 'exo.projects.app.jboss6.version'
-to specify the name of the directory where JBoss AS is stored.
-"
+ You must define the property
'exo.projects.app.jboss6.version'
+ to specify the name of the directory where JBoss AS
is stored.
+ "
</message>
</requireProperty>
</rules>
@@ -1073,13 +1089,15 @@
</file>
</files>
<message>"
-The following JBoss AS directory doesn't exist :
+ The following JBoss AS directory doesn't exist :
${exo.projects.directory.dependencies}/${exo.projects.app.jboss6.version}
-Make JBoss AS instance available at that location, or use
-Dexo.projects.directory.dependencies=PATH to point to the correct location
-of servers directory and/or -Dexo.projects.app.jboss6.version=NAME to point to the
correct directory under the servers directory.
-You can also use -Pdownload to automatically provide JBoss AS instance.
-"
+ Make JBoss AS instance available at that location, or
use
+ -Dexo.projects.directory.dependencies=PATH to point
to the correct location
+ of servers directory and/or
-Dexo.projects.app.jboss6.version=NAME to point to the
+ correct directory under the servers directory.
+ You can also use -Pdownload to automatically provide
JBoss AS instance.
+ "
</message>
</requireFilesExist>
</rules>
@@ -1132,35 +1150,37 @@
</goals>
<configuration>
<target>
- <available property="jbossas.dir.exists"
type="dir" file="${jbossas.dir}" />
+ <available property="jbossas.dir.exists"
type="dir" file="${jbossas.dir}"/>
<fail if="jbossas.dir.exists">"
-Destination JBossAS directory exists already:
+ Destination JBossAS directory exists already:
${jbossas.dir}
-Either rename it, delete it, or deactivate -Pdownload profile.
-"
+ Either rename it, delete it, or deactivate -Pdownload
profile.
+ "
</fail>
- <property name="jbossas.zip"
value="${jbossas.path}/jboss-as-distribution-${jbossas.dist.version}.zip" />
+ <property name="jbossas.zip"
+
value="${jbossas.path}/jboss-as-distribution-${jbossas.dist.version}.zip"/>
<!-- Autocreate servers.dir if necessary -->
- <mkdir dir="${jbossas.path}" />
+ <mkdir dir="${jbossas.path}"/>
<!-- Download JBossAS unless already downloaded -->
<ant
antfile="${project.basedir}/download-jboss.xml">
- <target name="download-jboss" />
- <property name="url"
value="http://sourceforge.net/projects/jboss/files/JBoss/JBoss-${jbo...
/>
- <property name="dest"
value="${jbossas.zip}" />
+ <target name="download-jboss"/>
+ <property name="url"
+
value="http://sourceforge.net/projects/jboss/files/JBoss/JBoss-${jbo...
+ <property name="dest"
value="${jbossas.zip}"/>
</ant>
<!-- Extract downloaded JBossAS to servers dir -->
- <unzip src="${jbossas.zip}"
dest="${jbossas.path}" overwrite="false" />
+ <unzip src="${jbossas.zip}"
dest="${jbossas.path}" overwrite="false"/>
<ant antfile="${project.basedir}/package.xml"
inheritRefs="true">
- <target name="package" />
- <property name="maven.project.basedir"
value="${project.basedir}" />
- <property
name="maven.project.build.directory"
value="${project.build.directory}" />
+ <target name="package"/>
+ <property name="maven.project.basedir"
value="${project.basedir}"/>
+ <property
name="maven.project.build.directory"
value="${project.build.directory}"/>
</ant>
</target>
</configuration>
@@ -1188,8 +1208,10 @@
</goals>
<configuration>
<target>
- <zip
destfile="${project.build.directory}/GateIn-${project.version}-jbossas6.zip"
basedir="${jbossas.target.dir}" />
- <attachartifact
file="${project.build.directory}/GateIn-${project.version}-jbossas6.zip"
classifier="bundle" type="zip" />
+ <zip
destfile="${project.build.directory}/GateIn-${project.version}-jbossas6.zip"
+ basedir="${jbossas.target.dir}"/>
+ <attachartifact
file="${project.build.directory}/GateIn-${project.version}-jbossas6.zip"
+ classifier="bundle"
type="zip"/>
</target>
</configuration>
</execution>
@@ -1245,7 +1267,7 @@
<!-- Copy CDI specific configuration -->
<copy todir="${jbossas.target.dir}"
preservelastmodified="true" overwrite="true">
<fileset
dir="${project.basedir}/src/main/resources/cdi/jboss">
- <include name="**/*.xml" />
+ <include name="**/*.xml"/>
</fileset>
</copy>
</target>
Modified: portal/trunk/packaging/jetty/pkg/pom.xml
===================================================================
--- portal/trunk/packaging/jetty/pkg/pom.xml 2011-08-09 14:55:41 UTC (rev 7031)
+++ portal/trunk/packaging/jetty/pkg/pom.xml 2011-08-09 18:48:56 UTC (rev 7032)
@@ -342,6 +342,20 @@
<artifactId>pc-bridge</artifactId>
</dependency>
+ <!-- GateIn API -->
+ <dependency>
+ <groupId>org.gatein.api</groupId>
+ <artifactId>java-api-impl</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.gatein.api</groupId>
+ <artifactId>gatein-java-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.gatein.api</groupId>
+ <artifactId>generic-id-impl</artifactId>
+ </dependency>
+
<!-- GateIn MOP -->
<dependency>
<groupId>org.gatein.mop</groupId>
Modified: portal/trunk/packaging/tomcat/pkg/pom.xml
===================================================================
--- portal/trunk/packaging/tomcat/pkg/pom.xml 2011-08-09 14:55:41 UTC (rev 7031)
+++ portal/trunk/packaging/tomcat/pkg/pom.xml 2011-08-09 18:48:56 UTC (rev 7032)
@@ -334,6 +334,20 @@
<artifactId>pc-bridge</artifactId>
</dependency>
+ <!-- GateIn API -->
+ <dependency>
+ <groupId>org.gatein.api</groupId>
+ <artifactId>java-api-impl</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.gatein.api</groupId>
+ <artifactId>gatein-java-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.gatein.api</groupId>
+ <artifactId>generic-id-impl</artifactId>
+ </dependency>
+
<!-- GateIn MOP -->
<dependency>
<groupId>org.gatein.mop</groupId>
Modified: portal/trunk/pom.xml
===================================================================
--- portal/trunk/pom.xml 2011-08-09 14:55:41 UTC (rev 7031)
+++ portal/trunk/pom.xml 2011-08-09 18:48:56 UTC (rev 7032)
@@ -50,6 +50,7 @@
<org.gatein.wsrp.version>2.1.0-Beta04</org.gatein.wsrp.version>
<org.gatein.mop.version>1.1.0-Beta05</org.gatein.mop.version>
<org.gatein.mgmt.version>1.0.0-Beta01</org.gatein.mgmt.version>
+ <org.gatein.api.version>1.0.0-Beta01</org.gatein.api.version>
<org.slf4j.version>1.5.8</org.slf4j.version>
<commons-pool.version>1.5.5</commons-pool.version>
<rhino.version>1.6R5</rhino.version>
@@ -400,6 +401,23 @@
<version>${org.gatein.wsrp.version}</version>
</dependency>
+ <!-- API -->
+ <dependency>
+ <groupId>org.gatein.api</groupId>
+ <artifactId>gatein-java-api</artifactId>
+ <version>${org.gatein.api.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.gatein.api</groupId>
+ <artifactId>generic-id-impl</artifactId>
+ <version>${org.gatein.api.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.gatein.api</groupId>
+ <artifactId>java-api-impl</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
<!-- GateIn -->
<dependency>
<groupId>org.exoplatform.portal</groupId>
@@ -854,11 +872,11 @@
<maxmem>1024m</maxmem>
</configuration>
</plugin>
- <plugin>
- <groupId>org.jibx</groupId>
- <artifactId>maven-jibx-plugin</artifactId>
- <version>1.2.2</version>
- </plugin>
+ <plugin>
+ <groupId>org.jibx</groupId>
+ <artifactId>maven-jibx-plugin</artifactId>
+ <version>1.2.2</version>
+ </plugin>
</plugins>
</pluginManagement>
<plugins>
Modified:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIAddApplicationForm.java
===================================================================
---
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIAddApplicationForm.java 2011-08-09
14:55:41 UTC (rev 7031)
+++
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIAddApplicationForm.java 2011-08-09
18:48:56 UTC (rev 7032)
@@ -185,41 +185,17 @@
{
ExoContainer manager = ExoContainerContext.getCurrentContainer();
+ ApplicationRegistryService appRegistry =
+
(ApplicationRegistryService)manager.getComponentInstance(ApplicationRegistryService.class);
+
FederatingPortletInvoker portletInvoker =
(FederatingPortletInvoker)manager.getComponentInstance(FederatingPortletInvoker.class);
Set<Portlet> portlets = remote ? portletInvoker.getRemotePortlets() :
portletInvoker.getLocalPortlets();
+
List<Application> applications = new
ArrayList<Application>(portlets.size());
for (Portlet portlet : portlets)
{
- PortletInfo info = portlet.getInfo();
-
- LocalizedString descriptionLS =
info.getMeta().getMetaValue(MetaInfo.DESCRIPTION);
- LocalizedString displayNameLS =
info.getMeta().getMetaValue(MetaInfo.DISPLAY_NAME);
-
- String portletName = info.getName();
- Application app = new Application();
- app.setApplicationName(portletName);
- // app.setApplicationGroup(info.getApplicationName());
- ApplicationType appType;
- String contentId;
- String displayName = Util.getLocalizedStringValue(displayNameLS, portletName);
- if (remote)
- {
- appType = ApplicationType.WSRP_PORTLET;
- contentId = portlet.getContext().getId();
- displayName += ApplicationRegistryService.REMOTE_DISPLAY_NAME_SUFFIX; // add
remote to display name to make it more obvious that the portlet is remote
- }
- else
- {
- appType = ApplicationType.PORTLET;
- contentId = info.getApplicationName() + "/" + info.getName();
- }
- app.setType(appType);
- app.setDisplayName(displayName);
- app.setDescription(Util.getLocalizedStringValue(descriptionLS, portletName));
- app.setAccessPermissions(new ArrayList<String>());
- app.setContentId(contentId);
- applications.add(app);
+ applications.add(appRegistry.createApplicationFrom(portlet));
}
return applications;
Deleted: portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/api/api-configuration.xml
===================================================================
---
portal/branches/api/web/portal/src/main/webapp/WEB-INF/conf/api/api-configuration.xml 2011-08-09
13:52:09 UTC (rev 7030)
+++
portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/api/api-configuration.xml 2011-08-09
18:48:56 UTC (rev 7032)
@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
- ~ JBoss, a division of Red Hat
- ~ Copyright 2011, Red Hat Middleware, LLC, and individual
- ~ contributors as indicated by the @authors tag. See the
- ~ copyright.txt in the distribution for a full listing of
- ~ individual contributors.
- ~
- ~ 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.
- -->
-
-<configuration
-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-
xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_1.xsd
http://www.exoplaform.org/xml/ns/kernel_1_1.xsd"
-
xmlns="http://www.exoplaform.org/xml/ns/kernel_1_1.xsd">
-
- <component>
- <key>org.gatein.portal.api.GateIn</key>
- <type>org.gatein.portal.api.impl.GateInImpl</type>
- </component>
-
-</configuration>
Copied: portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/api/api-configuration.xml
(from rev 7030,
portal/branches/api/web/portal/src/main/webapp/WEB-INF/conf/api/api-configuration.xml)
===================================================================
--- portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/api/api-configuration.xml
(rev 0)
+++
portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/api/api-configuration.xml 2011-08-09
18:48:56 UTC (rev 7032)
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ ~ JBoss, a division of Red Hat
+ ~ Copyright 2011, Red Hat Middleware, LLC, and individual
+ ~ contributors as indicated by the @authors tag. See the
+ ~ copyright.txt in the distribution for a full listing of
+ ~ individual contributors.
+ ~
+ ~ 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.
+ -->
+
+<configuration
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_1.xsd
http://www.exoplaform.org/xml/ns/kernel_1_1.xsd"
+
xmlns="http://www.exoplaform.org/xml/ns/kernel_1_1.xsd">
+
+ <component>
+ <key>org.gatein.portal.api.GateIn</key>
+ <type>org.gatein.portal.api.impl.GateInImpl</type>
+ </component>
+
+</configuration>
Modified: portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/configuration.xml
===================================================================
--- portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/configuration.xml 2011-08-09
14:55:41 UTC (rev 7031)
+++ portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/configuration.xml 2011-08-09
18:48:56 UTC (rev 7032)
@@ -31,6 +31,7 @@
<import>war:/conf/common/autologin-configuration.xml</import>
<import>war:/conf/common/remindpwd-configuration.xml</import>
<import>war:/conf/jcr/jcr-configuration.xml</import>
+ <import>war:/conf/api/api-configuration.xml</import>