gatein SVN: r6941 - in portal/branches/api: component/api-impl and 3 other directories.
by do-not-reply@jboss.org
Author: chris.laprun(a)jboss.com
Date: 2011-07-28 11:27:35 -0400 (Thu, 28 Jul 2011)
New Revision: 6941
Modified:
portal/branches/api/component/api-impl/pom.xml
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/GateInImpl.java
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/NavigationImpl.java
portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/util/AggregatedIterableIdentifiableCollectionTestCase.java
portal/branches/api/pom.xml
Log:
- Adapted for changes in Id design.
Modified: portal/branches/api/component/api-impl/pom.xml
===================================================================
--- portal/branches/api/component/api-impl/pom.xml 2011-07-28 12:18:49 UTC (rev 6940)
+++ portal/branches/api/component/api-impl/pom.xml 2011-07-28 15:27:35 UTC (rev 6941)
@@ -18,6 +18,10 @@
<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>
Modified: portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/GateInImpl.java
===================================================================
--- portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/GateInImpl.java 2011-07-28 12:18:49 UTC (rev 6940)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/GateInImpl.java 2011-07-28 15:27:35 UTC (rev 6941)
@@ -52,6 +52,7 @@
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.Page;
@@ -83,21 +84,21 @@
private static final Query<PageData> GROUPS = new Query<PageData>(SiteType.GROUP.getName(), null, PageData.class);
private static final String GROUP_CHARS = "\\w|-|_";
- public static final Context CONTEXT = Context.builder()
+ public static final Context CONTEXT = GenericContext.builder()
.requiredComponent("owner", Site.class, Pattern.compile(Site.PORTAL_NAME + "|" + Site.GROUP_NAME + "|" + Site.DASHBOARD_NAME))
.requiredComponent("portal", Portal.class, Pattern.compile("(" + GROUP_CHARS + "|\\/)+"))
.optionalComponent("page", Page.class, Pattern.compile("\\w+"))
.withDefaultSeparator("::").build();
- public static final Context GROUP_CONTEXT = Context.builder().requiredUnboundedHierarchicalComponent("group", Identifiable.class, Pattern.compile("(" + GROUP_CHARS + ")+"))
+ public static final Context GROUP_CONTEXT = GenericContext.builder().requiredUnboundedHierarchicalComponent("group", Identifiable.class, Pattern.compile("(" + GROUP_CHARS + ")+"))
.withDefaultSeparator("/").requireSeparatorInFirstPosition().build();
- public static final Context APPLICATION_CONTEXT = Context.builder().requiredComponent("application", Identifiable.class, Pattern.compile("\\w+"))
+ public static final Context APPLICATION_CONTEXT = GenericContext.builder().requiredComponent("application", Identifiable.class, Pattern.compile("\\w+"))
.requiredComponent("portlet", Portlet.class, Pattern.compile("\\w+")).withDefaultSeparator("/").build();
- private static final Context GADGET_CONTEXT = Context.builder().requiredComponent("name", Gadget.class, Pattern.compile("\\w+")).build();
- private static final Context CATEGORY_CONTEXT = Context.builder().requiredComponent("name", Category.class, Pattern.compile("\\w+")).build();
- private static final Context WSRP_CONTEXT = Context.builder().requiredComponent("invoker", Identifiable.class, Pattern.compile("\\w+"))
+ private static final Context GADGET_CONTEXT = GenericContext.builder().requiredComponent("name", Gadget.class, Pattern.compile("\\w+")).build();
+ private static final Context CATEGORY_CONTEXT = GenericContext.builder().requiredComponent("name", Category.class, Pattern.compile("\\w+")).build();
+ private static final Context WSRP_CONTEXT = GenericContext.builder().requiredComponent("invoker", Identifiable.class, Pattern.compile("\\w+"))
.requiredComponent("portletcontext", WSRP.class, Pattern.compile(GROUP_CHARS + "+")).build();
private static final String MANAGED = "managed";
- private static final Context MANAGED_CONTENT_CONTEXT = Context.builder()
+ private static final Context MANAGED_CONTENT_CONTEXT = GenericContext.builder()
.requiredComponent(MANAGED, ManagedContent.class, Pattern.compile(MANAGED))
.requiredComponent("content", Content.class, Pattern.compile(".+"))
.build();
@@ -239,7 +240,7 @@
public Site adapt(Object old)
{
Group group = (Group)old;
- return getGroupSite(Id.parse(GROUP_CONTEXT, group.getId()));
+ return getGroupSite(GROUP_CONTEXT.parse(group.getId()));
}
};
}
@@ -324,32 +325,32 @@
public Id groupId(String root, String... children)
{
- return Id.create(GROUP_CONTEXT, root, children);
+ return GROUP_CONTEXT.create(root, children);
}
public Id<Portlet> portletId(String application, String portlet)
{
- return Id.create(APPLICATION_CONTEXT, Portlet.class, application, portlet);
+ return APPLICATION_CONTEXT.create(Portlet.class, application, portlet);
}
public Id<Portlet> parsePortletId(String contentId)
{
- return Id.parse(GateInImpl.APPLICATION_CONTEXT, contentId, Portlet.class);
+ return APPLICATION_CONTEXT.parse(contentId, Portlet.class);
}
public Id<WSRP> wsrpPortletId(String invoker, String portlet)
{
- return Id.create(WSRP_CONTEXT, WSRP.class, invoker, portlet);
+ return WSRP_CONTEXT.create(WSRP.class, invoker, portlet);
}
public Id<WSRP> parseWSRPPortletId(String compositeId)
{
- return Id.parse(WSRP_CONTEXT, compositeId, WSRP.class);
+ return WSRP_CONTEXT.parse(compositeId, WSRP.class);
}
public Id<Gadget> gadgetId(String gadgetName)
{
- return Id.create(GADGET_CONTEXT, Gadget.class, gadgetName);
+ return GADGET_CONTEXT.create(Gadget.class, gadgetName);
}
public Id<Gadget> gadgetId(URI uri)
@@ -359,17 +360,17 @@
public <T extends Content> Id<ManagedContent> managedContentId(Id<T> contentId)
{
- return Id.create(MANAGED_CONTENT_CONTEXT, ManagedContent.class, MANAGED, contentId.toString());
+ return MANAGED_CONTENT_CONTEXT.create(ManagedContent.class, MANAGED, contentId.toString());
}
public Id<Category> categoryId(String name)
{
- return Id.create(CATEGORY_CONTEXT, Category.class, name);
+ return CATEGORY_CONTEXT.create(Category.class, name);
}
public <T extends Site> Id<T> siteId(Type<T, Site> siteType, String siteName)
{
- return Id.create(CONTEXT, siteType.getValueType(), siteType.getName(), siteName);
+ return CONTEXT.create(siteType.getValueType(), siteType.getName(), siteName);
}
public <T extends Site> Id<Page> pageId(Id<T> ownerSite, String pageName)
Modified: portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/NavigationImpl.java
===================================================================
--- portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/NavigationImpl.java 2011-07-28 12:18:49 UTC (rev 6940)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/NavigationImpl.java 2011-07-28 15:27:35 UTC (rev 6941)
@@ -29,6 +29,7 @@
import org.exoplatform.portal.mop.navigation.Scope;
import org.gatein.api.GateIn;
import org.gatein.api.id.Context;
+import org.gatein.api.id.GenericContext;
import org.gatein.api.id.Id;
import org.gatein.api.id.Identifiable;
import org.gatein.api.portal.Navigation;
@@ -51,7 +52,7 @@
private Id<Navigation> id;
private final GateInImpl gateIn;
- private final static Context CONTEXT = Context.builder().requiredComponent("navigation", Navigation.class, Pattern.compile("[a-z0-9]+")).build();
+ private final static Context CONTEXT = GenericContext.builder().requiredComponent("navigation", Navigation.class, Pattern.compile("[a-z0-9]+")).build();
public NavigationImpl(Id<Site> siteId, NodeContext<NavigationImpl> context, GateInImpl gateIn)
{
@@ -210,7 +211,7 @@
{
if (id == null)
{
- id = Id.create(CONTEXT, Navigation.class, context.getId());
+ id = CONTEXT.create(Navigation.class, context.getId());
}
return id;
Modified: portal/branches/api/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-07-28 12:18:49 UTC (rev 6940)
+++ portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/util/AggregatedIterableIdentifiableCollectionTestCase.java 2011-07-28 15:27:35 UTC (rev 6941)
@@ -132,7 +132,7 @@
private static IdentifiableImpl createIdentifiable(String name)
{
- return new IdentifiableImpl(Id.create(GateInImpl.GROUP_CONTEXT, name), name, null);
+ return new IdentifiableImpl(GateInImpl.GROUP_CONTEXT.create(name), name, null);
}
private static class TestCollection implements IterableIdentifiableCollection<Identifiable>
Modified: portal/branches/api/pom.xml
===================================================================
--- portal/branches/api/pom.xml 2011-07-28 12:18:49 UTC (rev 6940)
+++ portal/branches/api/pom.xml 2011-07-28 15:27:35 UTC (rev 6941)
@@ -387,6 +387,11 @@
</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>
13 years, 5 months
gatein SVN: r6940 - epp/portal/branches/EPP_5_2_Branch/component/web/security/src/main/java/org/exoplatform/web.
by do-not-reply@jboss.org
Author: hfnukal
Date: 2011-07-28 08:18:49 -0400 (Thu, 28 Jul 2011)
New Revision: 6940
Modified:
epp/portal/branches/EPP_5_2_Branch/component/web/security/src/main/java/org/exoplatform/web/CacheUserProfileFilter.java
Log:
JBEPP-1005 OrganizationService lifecycle (and Hibernate transaction) always started in CacheUserProfileFilter during HTTP request of anonymous user
Modified: epp/portal/branches/EPP_5_2_Branch/component/web/security/src/main/java/org/exoplatform/web/CacheUserProfileFilter.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/security/src/main/java/org/exoplatform/web/CacheUserProfileFilter.java 2011-07-28 10:59:21 UTC (rev 6939)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/security/src/main/java/org/exoplatform/web/CacheUserProfileFilter.java 2011-07-28 12:18:49 UTC (rev 6940)
@@ -27,6 +27,8 @@
import org.exoplatform.services.organization.OrganizationService;
import org.exoplatform.services.organization.User;
import org.exoplatform.services.security.ConversationState;
+import org.exoplatform.services.security.IdentityConstants;
+import org.exoplatform.services.security.web.SetCurrentIdentityFilter;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
@@ -44,14 +46,14 @@
/**
* Logger.
*/
- private static Log log = ExoLogger.getLogger("core.security.SetCurrentIdentityFilter");
+ private static Log log = ExoLogger.getLogger(SetCurrentIdentityFilter.class);
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws ServletException
{
ConversationState state = ConversationState.getCurrent();
try
{
- if (state != null)
+ if (state != null && !state.getIdentity().getUserId().equals(IdentityConstants.ANONIM))
{
if (log.isDebugEnabled())
log.debug("Conversation State found, save user profile to Conversation State.");
@@ -65,7 +67,6 @@
User user = orgService.getUserHandler().findUserByName(state.getIdentity().getUserId());
end(orgService);
state.setAttribute(USER_PROFILE, user);
-
}
}
13 years, 5 months
gatein SVN: r6939 - in portal/branches/api: component/api-impl/src/main/java/org/gatein/portal/api/impl and 1 other directories.
by do-not-reply@jboss.org
Author: chris.laprun(a)jboss.com
Date: 2011-07-28 06:59:21 -0400 (Thu, 28 Jul 2011)
New Revision: 6939
Modified:
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/GateInImpl.java
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/util/AggregatedIterableIdentifiableCollection.java
portal/branches/api/pom.xml
Log:
- Updated to API Alpha02-SNAPSHOT.
- Improved AggregatedIterableIdentifiableCollection so that it can be used in getSites but still not very satisfying (i.e. no real type safety) :(
Modified: portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/GateInImpl.java
===================================================================
--- portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/GateInImpl.java 2011-07-28 00:02:21 UTC (rev 6938)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/GateInImpl.java 2011-07-28 10:59:21 UTC (rev 6939)
@@ -25,6 +25,7 @@
import org.exoplatform.application.gadget.GadgetRegistryService;
import org.exoplatform.application.gadget.SourceStorage;
import org.exoplatform.application.registry.ApplicationRegistryService;
+import org.exoplatform.commons.utils.ListAccess;
import org.exoplatform.container.ExoContainer;
import org.exoplatform.container.ExoContainerContext;
import org.exoplatform.container.configuration.ConfigurationManager;
@@ -41,6 +42,8 @@
import org.exoplatform.services.organization.Group;
import org.exoplatform.services.organization.GroupHandler;
import org.exoplatform.services.organization.OrganizationService;
+import org.exoplatform.services.organization.User;
+import org.exoplatform.services.organization.UserHandler;
import org.gatein.api.GateIn;
import org.gatein.api.content.Category;
import org.gatein.api.content.Content;
@@ -58,13 +61,16 @@
import org.gatein.api.util.Type;
import org.gatein.common.util.ParameterValidation;
import org.gatein.portal.api.impl.lifecycle.NoOpLifecycleManager;
+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.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.regex.Pattern;
@@ -156,11 +162,59 @@
return getPortal(siteId(Site.PORTAL, "classic")); // todo: check
}
- public IterableIdentifiableCollection<Site> getSites()
+ public IterableIdentifiableCollection<? extends Site> getSites()
{
- return null; //To change body of implemented methods use File | Settings | File Templates.
+ 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
+ {
+ final UserHandler userHandler = organizationService.getUserHandler();
+
+ // todo: optimize
+ ListAccess<User> usersAccess = userHandler.findAllUsers();
+ List<User> users = Arrays.asList(usersAccess.load(0, usersAccess.getSize()));
+
+
+ // 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);
+ }
+ }
+
public IterableIdentifiableCollection<Site> getGroupSites()
{
try
@@ -215,7 +269,10 @@
public Site getDashboard(Id userId)
{
- return null; //To change body of implemented methods use File | Settings | File Templates.
+ 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)
Modified: portal/branches/api/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-07-28 00:02:21 UTC (rev 6938)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/util/AggregatedIterableIdentifiableCollection.java 2011-07-28 10:59:21 UTC (rev 6939)
@@ -34,9 +34,9 @@
/** @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a> */
public class AggregatedIterableIdentifiableCollection<T extends Identifiable<T>> implements IterableIdentifiableCollection<T>
{
- private List<IterableIdentifiableCollection<T>> aggregated = new ArrayList<IterableIdentifiableCollection<T>>(7);
+ private List<IterableIdentifiableCollection> aggregated = new ArrayList<IterableIdentifiableCollection>(7);
- public void addCollection(IterableIdentifiableCollection<T> collection)
+ public void addCollection(IterableIdentifiableCollection<? extends T> collection)
{
aggregated.add(collection);
}
@@ -73,7 +73,7 @@
public Iterator<T> iterator()
{
- final Iterator<IterableIdentifiableCollection<T>> iterator = aggregated.iterator();
+ final Iterator<IterableIdentifiableCollection> iterator = aggregated.iterator();
if (iterator.hasNext())
{
Modified: portal/branches/api/pom.xml
===================================================================
--- portal/branches/api/pom.xml 2011-07-28 00:02:21 UTC (rev 6938)
+++ portal/branches/api/pom.xml 2011-07-28 10:59:21 UTC (rev 6939)
@@ -50,7 +50,7 @@
<org.picketlink.idm>1.3.0.Alpha03</org.picketlink.idm>
<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.api.version>1.0.0-Alpha01</org.gatein.api.version>
+ <org.gatein.api.version>1.0.0-Alpha02-SNAPSHOT</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>
13 years, 5 months
gatein SVN: r6938 - in portal/branches/gatein-management: component/portal/src/main/java/org/exoplatform/portal/mop/management and 4 other directories.
by do-not-reply@jboss.org
Author: nscavell
Date: 2011-07-27 20:02:21 -0400 (Wed, 27 Jul 2011)
New Revision: 6938
Added:
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationReadConfigAsXml.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationReadResource.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationUtils.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageReadConfigAsXml.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageReadResource.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageUtils.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteLayoutReadConfigAsXml.java
Removed:
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationReadResource.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/PageNavigationUtils.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/PathScope.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/AbstractPageQueryOperation.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageReadResource.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageUpdateResource.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PagesReadResource.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PagesUpdateResource.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteLayoutReadResource.java
Modified:
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/MopManagementExtension.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/NavigationExportTask.java
portal/branches/gatein-management/pom.xml
Log:
Clarify difference between reading resources and reading configuration.
Modified: portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/MopManagementExtension.java
===================================================================
--- portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/MopManagementExtension.java 2011-07-27 14:07:50 UTC (rev 6937)
+++ portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/MopManagementExtension.java 2011-07-28 00:02:21 UTC (rev 6938)
@@ -26,12 +26,13 @@
import org.exoplatform.portal.mop.management.operations.MopImportResource;
import org.exoplatform.portal.mop.management.operations.MopReadResource;
import org.exoplatform.portal.mop.management.operations.navigation.NavigationExportResource;
+import org.exoplatform.portal.mop.management.operations.navigation.NavigationReadConfigAsXml;
import org.exoplatform.portal.mop.management.operations.navigation.NavigationReadResource;
import org.exoplatform.portal.mop.management.operations.page.PageExportResource;
+import org.exoplatform.portal.mop.management.operations.page.PageReadConfigAsXml;
import org.exoplatform.portal.mop.management.operations.page.PageReadResource;
-import org.exoplatform.portal.mop.management.operations.page.PagesReadResource;
import org.exoplatform.portal.mop.management.operations.site.SiteLayoutExportResource;
-import org.exoplatform.portal.mop.management.operations.site.SiteLayoutReadResource;
+import org.exoplatform.portal.mop.management.operations.site.SiteLayoutReadConfigAsXml;
import org.exoplatform.portal.mop.management.operations.site.SiteReadResource;
import org.exoplatform.portal.mop.management.operations.site.SiteTypeReadResource;
import org.gatein.management.api.ComponentRegistration;
@@ -54,43 +55,59 @@
registration.registerBindingProvider(MopBindingProvider.INSTANCE);
ManagedResource.Registration mop = registration.registerManagedResource(description("MOP (Model Object for Portal) Managed Resource"));
- mop.registerOperationHandler("import-resource", new MopImportResource(), description("Imports mop data from an exported zip file."), true);
+ mop.registerOperationHandler(OperationNames.IMPORT_RESOURCE, new MopImportResource(), description("Imports mop data from an exported zip file."));
- mop.registerOperationHandler(OperationNames.READ_RESOURCE, new MopReadResource(), description("Lists the available site types for a portal."));
+ mop.registerOperationHandler(OperationNames.READ_RESOURCE, new MopReadResource(), description("Available site types for a portal"));
ManagedResource.Registration sitetypes = mop.registerSubResource("{site-type}sites", description("Management resource responsible for handling management operations on a specific site type for a portal."));
- sitetypes.registerOperationHandler(OperationNames.READ_RESOURCE, new SiteTypeReadResource(), description("Lists the available sites for a site type."));
+ sitetypes.registerOperationHandler(OperationNames.READ_RESOURCE, new SiteTypeReadResource(), description("Available sites for a given site type."));
- //TODO: Would be nice to find acceptable regex for site name, nav uri, page name
ManagedResource.Registration sites = sitetypes.registerSubResource("{site-name: .*}", description("Management resource responsible for handling management operations on a specific site."));
- sites.registerOperationHandler(OperationNames.READ_RESOURCE, new SiteReadResource(), description("Lists all available artifacts for a given site (ie pages, navigation, site layout)"));
+ sites.registerOperationHandler(OperationNames.READ_RESOURCE, new SiteReadResource(), description("Available artifacts for a given site (ie pages, navigation, site layout)"));
- // Site layout management and operation registration
+ // Site Layout management
+ siteLayoutManagementRegistration(sites);
+
+ // Page management
+ pageManagementRegistration(sites);
+
+ // Navigation management
+ navigationManagementRegistration(sites);
+ }
+
+ private void siteLayoutManagementRegistration(ManagedResource.Registration sites)
+ {
ManagedResource.Registration siteLayout = sites.registerSubResource("portal", description("Management resource responsible for handling management operations for a site layout."));
- siteLayout.registerOperationHandler(OperationNames.READ_RESOURCE, new SiteLayoutReadResource(), description("Retrieves site layout data for a specific site."));
- siteLayout.registerOperationHandler(OperationNames.EXPORT_RESOURCE, new SiteLayoutExportResource(), description("Exports a site layout as a zip file."));
+ siteLayout.registerOperationHandler(OperationNames.READ_CONFIG_AS_XML, new SiteLayoutReadConfigAsXml(), description("Reads site layout data for a specific site as configuration xml."));
+ siteLayout.registerOperationHandler(OperationNames.EXPORT_RESOURCE, new SiteLayoutExportResource(), description("Exports site layout configuration xml as a zip file."));
+ }
- // Page management and operation registration
- PageExportResource pageExport = new PageExportResource();
- PageReadResource pageReadResource = new PageReadResource();
+ private void pageManagementRegistration(ManagedResource.Registration sites)
+ {
+ // Pages management resource registration
ManagedResource.Registration pages = sites.registerSubResource("pages", description("Management resource responsible for handling management operations on all pages of a site."));
- pages.registerOperationHandler(OperationNames.READ_RESOURCE, new PagesReadResource(), description("Lists all available pages available for a site."));
- pages.registerOperationHandler(OperationNames.EXPORT_RESOURCE, pageExport, description("Exports all pages for a site as a zip file."));
- ManagedResource.Registration page = pages.registerSubResource("{page-name}", description("Page management resource representing an individual page."));
- page.registerOperationHandler(OperationNames.READ_RESOURCE, new PageReadResource(), description("Retrieves page data for a specific site."));
- page.registerOperationHandler(OperationNames.EXPORT_RESOURCE, pageExport, description("Exports a page as a zip file."));
+ // Pages management operations
+ pages.registerOperationHandler(OperationNames.READ_RESOURCE, new PageReadResource(), description("Available pages at the specified address."), true);
+ pages.registerOperationHandler(OperationNames.READ_CONFIG_AS_XML, new PageReadConfigAsXml(), description("Reads pages as configuration xml at the specified address."), true);
+ pages.registerOperationHandler(OperationNames.EXPORT_RESOURCE, new PageExportResource(), description("Exports pages configuration xml as a zip file."), true);
- // Navigation management and operation registration
- NavigationReadResource navReadResource = new NavigationReadResource();
- NavigationExportResource navExport = new NavigationExportResource();
- ManagedResource.Registration navigation = sites.registerSubResource("navigation", description("Navigation management resource representing a sites navigation."));
- navigation.registerOperationHandler(OperationNames.READ_RESOURCE, navReadResource, description("Retrieves navigation for a specific site."));
- navigation.registerOperationHandler(OperationNames.EXPORT_RESOURCE, navExport, description("Exports navigation as a zip file."));
+ // Page name management resource registration
+ pages.registerSubResource("{page-name}", description("Page management resource representing an individual page."));
+ }
- ManagedResource.Registration navigationNode = navigation.registerSubResource("{nav-uri: .*}", description("Navigation node management resource representing a sites navigation."));
- navigationNode.registerOperationHandler(OperationNames.READ_RESOURCE, navReadResource, description("Retrieves navigation node for a specific site."));
- navigationNode.registerOperationHandler(OperationNames.EXPORT_RESOURCE, navExport, description("Exports navigation as a zip file."));
+ private void navigationManagementRegistration(ManagedResource.Registration sites)
+ {
+ // Navigation management resource registration
+ ManagedResource.Registration navigation = sites.registerSubResource("navigation", description("Management resource responsible for handling management operations on a sites navigation."));
+
+ // Navigation management operations
+ navigation.registerOperationHandler(OperationNames.READ_RESOURCE, new NavigationReadResource(), description("Available navigation nodes at the specified address."), true);
+ navigation.registerOperationHandler(OperationNames.READ_CONFIG_AS_XML, new NavigationReadConfigAsXml(), description("Reads navigation as configuration xml at the specified address."), true);
+ navigation.registerOperationHandler(OperationNames.EXPORT_RESOURCE, new NavigationExportResource(), description("Exports navigation configuration xml as a zip file."), true);
+
+ // Navigation node management resource registration
+ navigation.registerSubResource("{nav-uri: .*}", description("Management resource responsible for handling management operations on specific navigation nodes."));
}
@Override
Modified: portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/NavigationExportTask.java
===================================================================
--- portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/NavigationExportTask.java 2011-07-27 14:07:50 UTC (rev 6937)
+++ portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/NavigationExportTask.java 2011-07-28 00:02:21 UTC (rev 6938)
@@ -25,7 +25,7 @@
import org.exoplatform.portal.config.model.PageNavigation;
import org.exoplatform.portal.mop.description.DescriptionService;
import org.exoplatform.portal.mop.management.operations.navigation.NavigationKey;
-import org.exoplatform.portal.mop.management.operations.navigation.PageNavigationUtils;
+import org.exoplatform.portal.mop.management.operations.navigation.NavigationUtils;
import org.exoplatform.portal.mop.navigation.NavigationService;
import org.gatein.management.api.binding.Marshaller;
@@ -64,7 +64,7 @@
@Override
public void export(OutputStream outputStream) throws IOException
{
- PageNavigation navigation = PageNavigationUtils.loadPageNavigation(navigationKey, navigationService, descriptionService);
+ PageNavigation navigation = NavigationUtils.loadPageNavigation(navigationKey, navigationService, descriptionService);
marshaller.marshal(navigation, outputStream);
}
}
Copied: portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationReadConfigAsXml.java (from rev 6934, portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationReadResource.java)
===================================================================
--- portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationReadConfigAsXml.java (rev 0)
+++ portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationReadConfigAsXml.java 2011-07-28 00:02:21 UTC (rev 6938)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.exoplatform.portal.mop.management.operations.navigation;
+
+import org.exoplatform.portal.config.model.PageNavigation;
+import org.exoplatform.portal.mop.SiteKey;
+import org.exoplatform.portal.mop.description.DescriptionService;
+import org.exoplatform.portal.mop.navigation.NavigationService;
+import org.gatein.management.api.exceptions.ResourceNotFoundException;
+import org.gatein.management.api.operation.OperationContext;
+import org.gatein.management.api.operation.ResultHandler;
+import org.gatein.mop.api.workspace.Navigation;
+import org.gatein.mop.api.workspace.Site;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class NavigationReadConfigAsXml extends AbstractNavigationOperationHandler
+{
+ @Override
+ protected void execute(OperationContext operationContext, ResultHandler resultHandler, Navigation defaultNavigation)
+ {
+ String navUri = operationContext.getAddress().resolvePathTemplate("nav-uri");
+
+ Site site = defaultNavigation.getSite();
+ SiteKey siteKey = getSiteKey(site);
+
+ //TODO: If there's any benefit in creating our own node model to use with navigation service, lets do it
+
+ DescriptionService descriptionService = operationContext.getRuntimeContext().getRuntimeComponent(DescriptionService.class);
+ NavigationService navigationService = operationContext.getRuntimeContext().getRuntimeComponent(NavigationService.class);
+
+ PageNavigation pageNavigation = NavigationUtils.loadPageNavigation(new NavigationKey(siteKey, navUri), navigationService, descriptionService);
+ if (pageNavigation == null) throw new ResourceNotFoundException("Navigation node not found for navigation uri '" + navUri +"'");
+
+ resultHandler.completed(pageNavigation);
+ }
+}
Deleted: portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationReadResource.java
===================================================================
--- portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationReadResource.java 2011-07-27 14:07:50 UTC (rev 6937)
+++ portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationReadResource.java 2011-07-28 00:02:21 UTC (rev 6938)
@@ -1,59 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.exoplatform.portal.mop.management.operations.navigation;
-
-import org.exoplatform.portal.config.model.PageNavigation;
-import org.exoplatform.portal.mop.SiteKey;
-import org.exoplatform.portal.mop.description.DescriptionService;
-import org.exoplatform.portal.mop.navigation.NavigationService;
-import org.gatein.management.api.exceptions.ResourceNotFoundException;
-import org.gatein.management.api.operation.OperationContext;
-import org.gatein.management.api.operation.ResultHandler;
-import org.gatein.mop.api.workspace.Navigation;
-import org.gatein.mop.api.workspace.Site;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public class NavigationReadResource extends AbstractNavigationOperationHandler
-{
- @Override
- protected void execute(OperationContext operationContext, ResultHandler resultHandler, Navigation navigation)
- {
- String navUri = operationContext.getAddress().resolvePathTemplate("nav-uri");
-
- Site site = navigation.getSite();
- SiteKey siteKey = getSiteKey(site);
-
- //TODO: If there's any benefit in creating our own node model to use with navigation service, lets do it
-
- DescriptionService descriptionService = operationContext.getRuntimeContext().getRuntimeComponent(DescriptionService.class);
- NavigationService navigationService = operationContext.getRuntimeContext().getRuntimeComponent(NavigationService.class);
-
- PageNavigation pageNavigation = PageNavigationUtils.loadPageNavigation(new NavigationKey(siteKey, navUri), navigationService, descriptionService);
- if (pageNavigation == null) throw new ResourceNotFoundException("Navigation node " + navUri + " not found.");
-
- resultHandler.completed(pageNavigation);
- }
-}
Added: portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationReadResource.java
===================================================================
--- portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationReadResource.java (rev 0)
+++ portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationReadResource.java 2011-07-28 00:02:21 UTC (rev 6938)
@@ -0,0 +1,47 @@
+package org.exoplatform.portal.mop.management.operations.navigation;
+
+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.NodeContext;
+import org.gatein.management.api.exceptions.ResourceNotFoundException;
+import org.gatein.management.api.operation.OperationContext;
+import org.gatein.management.api.operation.ResultHandler;
+import org.gatein.management.api.operation.model.ReadResourceModel;
+import org.gatein.mop.api.workspace.Navigation;
+
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class NavigationReadResource extends AbstractNavigationOperationHandler
+{
+ @Override
+ protected void execute(OperationContext operationContext, ResultHandler resultHandler, Navigation defaultNavigation)
+ {
+ SiteKey siteKey = getSiteKey(defaultNavigation.getSite());
+ String navUri = operationContext.getAddress().resolvePathTemplate("nav-uri");
+
+ NavigationService navigationService = operationContext.getRuntimeContext().getRuntimeComponent(NavigationService.class);
+ NavigationContext navigation = navigationService.loadNavigation(siteKey);
+
+ Set<String> children = new LinkedHashSet<String>();
+
+ NodeContext<NodeContext<?>> node = NavigationUtils.loadNode(navigationService, navigation, navUri);
+ if (node == null)
+ {
+ throw new ResourceNotFoundException("Navigation node not found for navigation uri '" + navUri +"'");
+ }
+
+ for (NodeContext child : node.getNodes())
+ {
+ children.add(child.getName());
+ }
+
+ ReadResourceModel model = new ReadResourceModel("Navigation nodes available at this resource.", children);
+ resultHandler.completed(model);
+ }
+}
Copied: portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationUtils.java (from rev 6934, portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/PageNavigationUtils.java)
===================================================================
--- portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationUtils.java (rev 0)
+++ portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationUtils.java 2011-07-28 00:02:21 UTC (rev 6938)
@@ -0,0 +1,220 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.exoplatform.portal.mop.management.operations.navigation;
+
+import org.exoplatform.portal.config.model.I18NString;
+import org.exoplatform.portal.config.model.LocalizedString;
+import org.exoplatform.portal.config.model.NavigationFragment;
+import org.exoplatform.portal.config.model.PageNavigation;
+import org.exoplatform.portal.config.model.PageNode;
+import org.exoplatform.portal.mop.Described;
+import org.exoplatform.portal.mop.SiteKey;
+import org.exoplatform.portal.mop.description.DescriptionService;
+import org.exoplatform.portal.mop.navigation.GenericScope;
+import org.exoplatform.portal.mop.navigation.NavigationContext;
+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.Scope;
+import org.gatein.mop.api.workspace.Navigation;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class NavigationUtils
+{
+ private NavigationUtils(){}
+
+ public static PageNavigation loadPageNavigation(NavigationKey key, NavigationService navigationService, DescriptionService descriptionService)
+ {
+ NavigationContext navigation = navigationService.loadNavigation(key.getSiteKey());
+ if (navigation == null) return null;
+
+ NodeContext<NodeContext<?>> node = loadNode(navigationService, navigation, key.getNavUri());
+ if (node == null) return null;
+
+ if (key.getNavUri() != null)
+ {
+ return createFragmentedPageNavigation(descriptionService, navigation, node);
+ }
+ else
+ {
+ return createPageNavigation(descriptionService, navigation, node);
+ }
+ }
+
+ public static NodeContext<NodeContext<?>> loadNode(NavigationService navigationService, NavigationContext navigation, String navUri)
+ {
+ if (navigation == null) return null;
+
+ if (navUri != null)
+ {
+ String[] path = trim(navUri.split("/"));
+ NodeContext<NodeContext<?>> node = navigationService.loadNode(NodeModel.SELF_MODEL, navigation, GenericScope.branchShape(path), null);
+ for (String name : path)
+ {
+ node = node.get(name);
+ if (node == null) break;
+ }
+
+ return node;
+ }
+ else
+ {
+ return navigationService.loadNode(NodeModel.SELF_MODEL, navigation, Scope.ALL, null);
+ }
+ }
+
+ public static PageNavigation createPageNavigation(DescriptionService service, NavigationContext navigation, NodeContext<NodeContext<?>> node)
+ {
+ PageNavigation pageNavigation = new PageNavigation();
+ pageNavigation.setPriority(navigation.getState().getPriority());
+ pageNavigation.setOwnerType(navigation.getKey().getTypeName());
+ pageNavigation.setOwnerId(navigation.getKey().getName());
+
+ ArrayList<PageNode> children = new ArrayList<PageNode>(node.getNodeCount());
+ for (NodeContext<?> child : node.getNodes())
+ {
+ @SuppressWarnings("unchecked")
+ NodeContext<NodeContext<?>> childNode = (NodeContext<NodeContext<?>>) child;
+ children.add(createPageNode(service, childNode));
+ }
+
+ NavigationFragment fragment = new NavigationFragment();
+ fragment.setNodes(children);
+ pageNavigation.addFragment(fragment);
+
+ return pageNavigation;
+ }
+
+ private static PageNavigation createFragmentedPageNavigation(DescriptionService service, NavigationContext navigation, NodeContext<NodeContext<?>> node)
+ {
+ PageNavigation pageNavigation = new PageNavigation();
+ pageNavigation.setPriority(navigation.getState().getPriority());
+ pageNavigation.setOwnerType(navigation.getKey().getTypeName());
+ pageNavigation.setOwnerId(navigation.getKey().getName());
+
+ ArrayList<PageNode> children = new ArrayList<PageNode>(1);
+ children.add(createPageNode(service, node));
+
+ NavigationFragment fragment = new NavigationFragment();
+ StringBuilder parentUri = new StringBuilder("/");
+ getPath(node.getParent(), parentUri);
+ fragment.setParentURI(parentUri.toString());
+ fragment.setNodes(children);
+
+ pageNavigation.addFragment(fragment);
+
+ return pageNavigation;
+ }
+
+ private static void getPath(NodeContext<NodeContext<?>> node, StringBuilder parentUri)
+ {
+ if (node == null) return;
+ if (node.getParent() == null) return; // since "default" is the root node, we ignore it
+
+ parentUri.insert(0, node.getName()).append("/");
+ getPath(node.getParent(), parentUri);
+ }
+
+ private static PageNode createPageNode(DescriptionService service, NodeContext<NodeContext<?>> node)
+ {
+ PageNode pageNode = new PageNode();
+ pageNode.setName(node.getName());
+
+ if (node.getState().getLabel() == null)
+ {
+ Map<Locale, Described.State> descriptions = service.getDescriptions(node.getId());
+ if (descriptions != null && !descriptions.isEmpty())
+ {
+ I18NString labels = new I18NString();
+ for (Map.Entry<Locale, Described.State> entry : descriptions.entrySet())
+ {
+ labels.add(new LocalizedString(entry.getValue().getName(), entry.getKey()));
+ }
+
+ pageNode.setLabels(labels);
+ }
+ }
+ else
+ {
+ pageNode.setLabel(node.getState().getLabel());
+ }
+
+ pageNode.setIcon(node.getState().getIcon());
+ long startPublicationTime = node.getState().getStartPublicationTime();
+ if (startPublicationTime != -1)
+ {
+ pageNode.setStartPublicationDate(new Date(startPublicationTime));
+ }
+
+ long endPublicationTime = node.getState().getEndPublicationTime();
+ if (endPublicationTime != -1)
+ {
+ pageNode.setEndPublicationDate(new Date(endPublicationTime));
+ }
+
+ pageNode.setVisibility(node.getState().getVisibility());
+ pageNode.setPageReference(node.getState().getPageRef());
+
+ if (node.getNodes() != null)
+ {
+ ArrayList<PageNode> children = new ArrayList<PageNode>(node.getNodeCount());
+ for (NodeContext<?> child : node.getNodes())
+ {
+ @SuppressWarnings("unchecked")
+ NodeContext<NodeContext<?>> childNode = (NodeContext<NodeContext<?>>) child;
+ children.add(createPageNode(service, childNode));
+ }
+
+ pageNode.setChildren(children);
+ }
+ else
+ {
+ pageNode.setChildren(new ArrayList<PageNode>(0));
+ }
+
+ return pageNode;
+ }
+
+ private static String[] trim(String[] array)
+ {
+ List<String> trimmed = new ArrayList<String>(array.length);
+ for (String s : array)
+ {
+ if (s != null && !"".equals(s))
+ {
+ trimmed.add(s);
+ }
+ }
+
+ return trimmed.toArray(new String[trimmed.size()]);
+ }
+}
Deleted: portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/PageNavigationUtils.java
===================================================================
--- portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/PageNavigationUtils.java 2011-07-27 14:07:50 UTC (rev 6937)
+++ portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/PageNavigationUtils.java 2011-07-28 00:02:21 UTC (rev 6938)
@@ -1,186 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.exoplatform.portal.mop.management.operations.navigation;
-
-import org.exoplatform.portal.config.model.I18NString;
-import org.exoplatform.portal.config.model.LocalizedString;
-import org.exoplatform.portal.config.model.NavigationFragment;
-import org.exoplatform.portal.config.model.PageNavigation;
-import org.exoplatform.portal.config.model.PageNode;
-import org.exoplatform.portal.mop.Described;
-import org.exoplatform.portal.mop.description.DescriptionService;
-import org.exoplatform.portal.mop.navigation.NavigationContext;
-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.Scope;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.Locale;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public class PageNavigationUtils
-{
- private PageNavigationUtils(){}
-
- public static PageNavigation loadPageNavigation(NavigationKey key, NavigationService navigationService, DescriptionService descriptionService)
- {
- NodeContext<NodeContext<?>> node;
- NavigationContext navigation = navigationService.loadNavigation(key.getSiteKey());
- if (navigation == null) return null;
-
- if (key.getNavUri() != null)
- {
- PathScope scope = new PathScope(key.getNavUri());
- node = navigationService.loadNode(NodeModel.SELF_MODEL, navigation, scope, null);
- if (scope.getFoundId() == null) return null;
-
- node = node.getDescendant(scope.getFoundId());
- return createFragmentedPageNavigation(descriptionService, navigation, node);
- }
- else
- {
- node = navigationService.loadNode(NodeModel.SELF_MODEL, navigation, Scope.ALL, null);
- if (node == null) return null;
-
- return createPageNavigation(descriptionService, navigation, node);
- }
- }
-
- public static PageNavigation createPageNavigation(DescriptionService service, NavigationContext navigation, NodeContext<NodeContext<?>> node)
- {
- PageNavigation pageNavigation = new PageNavigation();
- pageNavigation.setPriority(navigation.getState().getPriority());
- pageNavigation.setOwnerType(navigation.getKey().getTypeName());
- pageNavigation.setOwnerId(navigation.getKey().getName());
-
- ArrayList<PageNode> children = new ArrayList<PageNode>(node.getNodeCount());
- for (NodeContext<?> child : node.getNodes())
- {
- @SuppressWarnings("unchecked")
- NodeContext<NodeContext<?>> childNode = (NodeContext<NodeContext<?>>) child;
- children.add(createPageNode(service, childNode));
- }
-
- NavigationFragment fragment = new NavigationFragment();
- fragment.setNodes(children);
- pageNavigation.addFragment(fragment);
-
- return pageNavigation;
- }
-
- private static PageNavigation createFragmentedPageNavigation(DescriptionService service, NavigationContext navigation, NodeContext<NodeContext<?>> node)
- {
- PageNavigation pageNavigation = new PageNavigation();
- pageNavigation.setPriority(navigation.getState().getPriority());
- pageNavigation.setOwnerType(navigation.getKey().getTypeName());
- pageNavigation.setOwnerId(navigation.getKey().getName());
-
- ArrayList<PageNode> children = new ArrayList<PageNode>(1);
- children.add(createPageNode(service, node));
-
- NavigationFragment fragment = new NavigationFragment();
- StringBuilder parentUri = new StringBuilder("/");
- getPath(node.getParent(), parentUri);
- fragment.setParentURI(parentUri.toString());
- fragment.setNodes(children);
-
- pageNavigation.addFragment(fragment);
-
- return pageNavigation;
- }
-
- private static void getPath(NodeContext<NodeContext<?>> node, StringBuilder parentUri)
- {
- if (node == null) return;
- if (node.getParent() == null) return; // since "default" is the root node, we ignore it
-
- parentUri.insert(0, node.getName()).append("/");
- getPath(node.getParent(), parentUri);
- }
-
- private static PageNode createPageNode(DescriptionService service, NodeContext<NodeContext<?>> node)
- {
- PageNode pageNode = new PageNode();
- pageNode.setName(node.getName());
-
- if (node.getState().getLabel() == null)
- {
- Map<Locale, Described.State> descriptions = service.getDescriptions(node.getId());
- if (descriptions != null && !descriptions.isEmpty())
- {
- I18NString labels = new I18NString();
- for (Map.Entry<Locale, Described.State> entry : descriptions.entrySet())
- {
- labels.add(new LocalizedString(entry.getValue().getName(), entry.getKey()));
- }
-
- pageNode.setLabels(labels);
- }
- }
- else
- {
- pageNode.setLabel(node.getState().getLabel());
- }
-
- pageNode.setIcon(node.getState().getIcon());
- long startPublicationTime = node.getState().getStartPublicationTime();
- if (startPublicationTime != -1)
- {
- pageNode.setStartPublicationDate(new Date(startPublicationTime));
- }
-
- long endPublicationTime = node.getState().getEndPublicationTime();
- if (endPublicationTime != -1)
- {
- pageNode.setEndPublicationDate(new Date(endPublicationTime));
- }
-
- pageNode.setVisibility(node.getState().getVisibility());
- pageNode.setPageReference(node.getState().getPageRef());
-
- if (node.getNodes() != null)
- {
- ArrayList<PageNode> children = new ArrayList<PageNode>(node.getNodeCount());
- for (NodeContext<?> child : node.getNodes())
- {
- @SuppressWarnings("unchecked")
- NodeContext<NodeContext<?>> childNode = (NodeContext<NodeContext<?>>) child;
- children.add(createPageNode(service, childNode));
- }
-
- pageNode.setChildren(children);
- }
- else
- {
- pageNode.setChildren(new ArrayList<PageNode>(0));
- }
-
- return pageNode;
- }
-}
Deleted: portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/PathScope.java
===================================================================
--- portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/PathScope.java 2011-07-27 14:07:50 UTC (rev 6937)
+++ portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/PathScope.java 2011-07-28 00:02:21 UTC (rev 6938)
@@ -1,127 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.exoplatform.portal.mop.management.operations.navigation;
-
-import org.exoplatform.portal.mop.navigation.NodeState;
-import org.exoplatform.portal.mop.navigation.Scope;
-import org.exoplatform.portal.mop.navigation.VisitMode;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public class PathScope implements Scope
-{
- private String path;
- private String foundId;
-
- public PathScope(String path)
- {
- if (path == null) throw new IllegalArgumentException("path is null.");
- this.path = path;
- }
-
- @Override
- public Visitor get()
- {
- final String[] segments = trim(path.split("/"));
- return new Visitor()
- {
- @Override
- public VisitMode enter(int depth, String id, String name, NodeState state)
- {
- if (depth == 0)
- {
- return VisitMode.ALL_CHILDREN;
- }
- assert depth > 0;
-
- if (depth < segments.length)
- {
- if (name.equals(segments[depth-1]))
- {
- return VisitMode.ALL_CHILDREN;
- }
- else
- {
- return VisitMode.NO_CHILDREN;
- }
- }
- else if (depth == segments.length)
- {
- if (name.equals(segments[depth-1]))
- {
- foundId = id;
- return VisitMode.ALL_CHILDREN;
- }
- else
- {
- return VisitMode.NO_CHILDREN;
- }
- }
- else if (depth > segments.length)
- {
- if (foundId != null)
- {
- return VisitMode.ALL_CHILDREN;
- }
- else
- {
- return VisitMode.NO_CHILDREN;
- }
- }
- else
- {
- return VisitMode.NO_CHILDREN;
- }
- }
-
- @Override
- public void leave(int depth, String id, String name, NodeState state)
- {
- }
- };
- }
-
- String getFoundId()
- {
- return foundId;
- }
-
- private String[] trim(String[] array)
- {
- List<String> trimmed = new ArrayList<String>(array.length);
- for (String s : array)
- {
- if (s != null && !"".equals(s))
- {
- trimmed.add(s);
- }
- }
-
- return trimmed.toArray(new String[trimmed.size()]);
- }
-}
Deleted: portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/AbstractPageQueryOperation.java
===================================================================
--- portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/AbstractPageQueryOperation.java 2011-07-27 14:07:50 UTC (rev 6937)
+++ portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/AbstractPageQueryOperation.java 2011-07-28 00:02:21 UTC (rev 6938)
@@ -1,34 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.exoplatform.portal.mop.management.operations.page;
-
-import org.exoplatform.portal.pom.data.PageData;
-import org.gatein.management.api.operation.QueryOperationHandler;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public abstract class AbstractPageQueryOperation extends QueryOperationHandler<PageData>
-{
-}
Copied: portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageReadConfigAsXml.java (from rev 6934, portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageReadResource.java)
===================================================================
--- portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageReadConfigAsXml.java (rev 0)
+++ portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageReadConfigAsXml.java 2011-07-28 00:02:21 UTC (rev 6938)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.exoplatform.portal.mop.management.operations.page;
+
+import org.exoplatform.portal.config.DataStorage;
+import org.exoplatform.portal.config.Query;
+import org.exoplatform.portal.config.model.Page;
+import org.exoplatform.portal.mop.SiteKey;
+import org.gatein.management.api.exceptions.OperationException;
+import org.gatein.management.api.exceptions.ResourceNotFoundException;
+import org.gatein.management.api.operation.OperationContext;
+import org.gatein.management.api.operation.ResultHandler;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class PageReadConfigAsXml extends AbstractPageOperationHandler
+{
+ @Override
+ protected void execute(OperationContext operationContext, ResultHandler resultHandler, org.gatein.mop.api.workspace.Page rootPage) throws ResourceNotFoundException, OperationException
+ {
+ SiteKey siteKey = getSiteKey(rootPage.getSite());
+ DataStorage dataStorage = operationContext.getRuntimeContext().getRuntimeComponent(DataStorage.class);
+
+ String pageName = operationContext.getAddress().resolvePathTemplate("page-name");
+ if (pageName == null)
+ {
+ resultHandler.completed(PageUtils.getAllPages(dataStorage, siteKey, operationContext.getOperationName()));
+ }
+ else
+ {
+ PageKey key = new PageKey(siteKey, pageName);
+ Page page = PageUtils.getPage(dataStorage, key, operationContext.getOperationName());
+ if (page == null)
+ {
+ throw new ResourceNotFoundException("No page found for " + key);
+ }
+ else
+ {
+ resultHandler.completed(page);
+ }
+ }
+ }
+}
Deleted: portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageReadResource.java
===================================================================
--- portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageReadResource.java 2011-07-27 14:07:50 UTC (rev 6937)
+++ portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageReadResource.java 2011-07-28 00:02:21 UTC (rev 6938)
@@ -1,72 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.exoplatform.portal.mop.management.operations.page;
-
-import org.exoplatform.portal.config.DataStorage;
-import org.gatein.management.api.exceptions.OperationException;
-import org.gatein.management.api.exceptions.ResourceNotFoundException;
-import org.gatein.management.api.operation.OperationContext;
-import org.gatein.management.api.operation.ResultHandler;
-import org.gatein.mop.api.workspace.Page;
-
-import java.util.ArrayList;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public class PageReadResource extends AbstractPageOperationHandler
-{
- @Override
- protected void execute(OperationContext operationContext, ResultHandler resultHandler, Page pages) throws ResourceNotFoundException, OperationException
- {
- String pageName = operationContext.getAddress().resolvePathTemplate("page-name");
-
- if (pageName == null)
- throw new OperationException(operationContext.getOperationName(), "No page name specified.");
-
- DataStorage dataStorage = operationContext.getRuntimeContext().getRuntimeComponent(DataStorage.class);
-
- PageKey key = new PageKey(getSiteKey(pages.getSite()), pageName);
- try
- {
- org.exoplatform.portal.config.model.Page page = dataStorage.getPage(key.getPageId());
- if (page == null)
- {
- throw new ResourceNotFoundException("No page found for " + key);
- }
- else
- {
- resultHandler.completed(page);
- }
- }
- catch (ResourceNotFoundException nfe)
- {
- throw nfe;
- }
- catch (Exception e)
- {
- throw new OperationException(operationContext.getOperationName(), "Operation failed getting page for " + key, e);
- }
- }
-}
Added: portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageReadResource.java
===================================================================
--- portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageReadResource.java (rev 0)
+++ portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageReadResource.java 2011-07-28 00:02:21 UTC (rev 6938)
@@ -0,0 +1,50 @@
+package org.exoplatform.portal.mop.management.operations.page;
+
+import org.exoplatform.portal.config.DataStorage;
+import org.gatein.management.api.exceptions.OperationException;
+import org.gatein.management.api.exceptions.ResourceNotFoundException;
+import org.gatein.management.api.operation.OperationContext;
+import org.gatein.management.api.operation.ResultHandler;
+import org.gatein.management.api.operation.model.ReadResourceModel;
+import org.gatein.mop.api.workspace.Page;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class PageReadResource extends AbstractPageOperationHandler
+{
+ @Override
+ protected void execute(OperationContext operationContext, ResultHandler resultHandler, Page rootPage) throws ResourceNotFoundException, OperationException
+ {
+ String pageName = operationContext.getAddress().resolvePathTemplate("page-name");
+ if (pageName == null)
+ {
+ Collection<Page> pageList = rootPage.getChildren();
+ Set<String> children = new LinkedHashSet<String>(pageList.size());
+ for (Page page : pageList)
+ {
+ children.add(page.getName());
+ }
+
+ resultHandler.completed(new ReadResourceModel("List of all available pages for site '" + rootPage.getSite().getName() +"'", children));
+ }
+ else
+ {
+ DataStorage dataStorage = operationContext.getRuntimeContext().getRuntimeComponent(DataStorage.class);
+ PageKey pageKey = new PageKey(getSiteKey(rootPage.getSite()), pageName);
+
+ if (PageUtils.getPage(dataStorage, pageKey, operationContext.getOperationName()) == null)
+ {
+ throw new ResourceNotFoundException("No page found for " + pageKey);
+ }
+
+ resultHandler.completed(new ReadResourceModel("List of child pages for page '" + pageName +"'", Collections.<String>emptySet()));
+ }
+ }
+}
Deleted: portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageUpdateResource.java
===================================================================
--- portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageUpdateResource.java 2011-07-27 14:07:50 UTC (rev 6937)
+++ portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageUpdateResource.java 2011-07-28 00:02:21 UTC (rev 6938)
@@ -1,47 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.exoplatform.portal.mop.management.operations.page;
-
-import org.exoplatform.portal.mop.management.model.PageDataContainer;
-import org.exoplatform.portal.pom.data.PageData;
-import org.gatein.management.api.exceptions.ResourceNotFoundException;
-import org.gatein.management.api.exceptions.OperationException;
-import org.gatein.management.api.operation.OperationContext;
-import org.gatein.management.api.operation.UpdateOperationHandler;
-
-import java.util.Collections;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public class PageUpdateResource extends UpdateOperationHandler<PageData>
-{
- private static final PagesUpdateResource delegate = new PagesUpdateResource();
-
- @Override
- protected void execute(OperationContext operationContext, PageData page) throws ResourceNotFoundException, OperationException
- {
- delegate.execute(operationContext, new PageDataContainer(Collections.singletonList(page)));
- }
-}
Added: portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageUtils.java
===================================================================
--- portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageUtils.java (rev 0)
+++ portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageUtils.java 2011-07-28 00:02:21 UTC (rev 6938)
@@ -0,0 +1,48 @@
+package org.exoplatform.portal.mop.management.operations.page;
+
+import org.exoplatform.portal.config.DataStorage;
+import org.exoplatform.portal.config.Query;
+import org.exoplatform.portal.config.model.Page;
+import org.exoplatform.portal.mop.SiteKey;
+import org.gatein.management.api.exceptions.OperationException;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class PageUtils
+{
+ private PageUtils(){}
+
+ public static Page getPage(DataStorage dataStorage, PageKey pageKey, String operationName)
+ {
+ try
+ {
+ return dataStorage.getPage(pageKey.getPageId());
+ }
+ catch (Exception e)
+ {
+ throw new OperationException(operationName, "Operation failed getting page for " + pageKey, e);
+ }
+ }
+
+ public static Page.PageSet getAllPages(DataStorage dataStorage, SiteKey siteKey, String operationName)
+ {
+ Query<Page> query = new Query<Page>(siteKey.getTypeName(), siteKey.getName(), Page.class);
+ try
+ {
+ List<Page> pageList = dataStorage.find(query).getAll();
+ Page.PageSet pages = new Page.PageSet();
+ pages.setPages(new ArrayList<Page>(pageList));
+
+ return pages;
+ }
+ catch (Exception e)
+ {
+ throw new OperationException(operationName, "Could not retrieve pages for site " + siteKey);
+ }
+ }
+}
Deleted: portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PagesReadResource.java
===================================================================
--- portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PagesReadResource.java 2011-07-27 14:07:50 UTC (rev 6937)
+++ portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PagesReadResource.java 2011-07-28 00:02:21 UTC (rev 6938)
@@ -1,54 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.exoplatform.portal.mop.management.operations.page;
-
-import org.gatein.management.api.exceptions.OperationException;
-import org.gatein.management.api.exceptions.ResourceNotFoundException;
-import org.gatein.management.api.operation.OperationContext;
-import org.gatein.management.api.operation.ResultHandler;
-import org.gatein.management.api.operation.model.ReadResourceModel;
-import org.gatein.mop.api.workspace.Page;
-
-import java.util.Collection;
-import java.util.LinkedHashSet;
-import java.util.Set;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public class PagesReadResource extends AbstractPageOperationHandler
-{
- @Override
- protected void execute(OperationContext operationContext, ResultHandler resultHandler, Page pages) throws ResourceNotFoundException, OperationException
- {
- Collection<Page> pageList = pages.getChildren();
- Set<String> children = new LinkedHashSet<String>(pageList.size());
- for (Page page : pageList)
- {
- children.add(page.getName());
- }
-
- resultHandler.completed(new ReadResourceModel("List of pages available for given site.", children));
- }
-}
Deleted: portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PagesUpdateResource.java
===================================================================
--- portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PagesUpdateResource.java 2011-07-27 14:07:50 UTC (rev 6937)
+++ portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PagesUpdateResource.java 2011-07-28 00:02:21 UTC (rev 6938)
@@ -1,58 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.exoplatform.portal.mop.management.operations.page;
-
-import org.exoplatform.portal.mop.management.model.PageDataContainer;
-import org.exoplatform.portal.pom.data.ModelDataStorage;
-import org.exoplatform.portal.pom.data.PageData;
-import org.gatein.management.api.exceptions.ResourceNotFoundException;
-import org.gatein.management.api.exceptions.OperationException;
-import org.gatein.management.api.operation.OperationContext;
-import org.gatein.management.api.operation.UpdateOperationHandler;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public class PagesUpdateResource extends UpdateOperationHandler<PageDataContainer>
-{
- //TODO: Rollback ?
- //TODO: Maybe use an import api and execute on input stream. See if we can use only mop api's.
-
- @Override
- protected void execute(OperationContext operationContext, PageDataContainer pages) throws ResourceNotFoundException, OperationException
- {
- ModelDataStorage dataStorage = operationContext.getRuntimeContext().getRuntimeComponent(ModelDataStorage.class);
- for (PageData page : pages.getPages())
- {
- try
- {
- //dataStorage.save(page);
- }
- catch (Exception e)
- {
- throw new OperationException(operationContext.getOperationName(), "Could not update page for address " + operationContext.getAddress(), e);
- }
- }
- }
-}
Copied: portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteLayoutReadConfigAsXml.java (from rev 6934, portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteLayoutReadResource.java)
===================================================================
--- portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteLayoutReadConfigAsXml.java (rev 0)
+++ portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteLayoutReadConfigAsXml.java 2011-07-28 00:02:21 UTC (rev 6938)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.exoplatform.portal.mop.management.operations.site;
+
+import org.exoplatform.portal.config.DataStorage;
+import org.exoplatform.portal.config.model.PortalConfig;
+import org.exoplatform.portal.mop.SiteKey;
+import org.exoplatform.portal.pom.config.POMSessionManager;
+import org.exoplatform.portal.pom.config.tasks.PortalConfigTask;
+import org.exoplatform.portal.pom.data.PortalData;
+import org.exoplatform.portal.pom.data.PortalKey;
+import org.gatein.management.api.exceptions.OperationException;
+import org.gatein.management.api.exceptions.ResourceNotFoundException;
+import org.gatein.management.api.operation.OperationContext;
+import org.gatein.management.api.operation.ResultHandler;
+import org.gatein.mop.api.workspace.Site;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class SiteLayoutReadConfigAsXml extends AbstractSiteOperationHandler
+{
+ @Override
+ protected void execute(OperationContext operationContext, ResultHandler resultHandler, Site site) throws ResourceNotFoundException, OperationException
+ {
+ DataStorage dataStorage = operationContext.getRuntimeContext().getRuntimeComponent(DataStorage.class);
+ SiteKey siteKey = getSiteKey(site);
+
+ try
+ {
+ PortalConfig portalConfig = dataStorage.getPortalConfig(siteKey.getTypeName(), siteKey.getName());
+ resultHandler.completed(portalConfig);
+ }
+ catch (Exception e)
+ {
+ throw new OperationException(operationContext.getOperationName(), "Could not retrieve site layout for site " + site, e);
+ }
+ }
+}
Deleted: portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteLayoutReadResource.java
===================================================================
--- portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteLayoutReadResource.java 2011-07-27 14:07:50 UTC (rev 6937)
+++ portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteLayoutReadResource.java 2011-07-28 00:02:21 UTC (rev 6938)
@@ -1,60 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.exoplatform.portal.mop.management.operations.site;
-
-import org.exoplatform.portal.config.DataStorage;
-import org.exoplatform.portal.config.model.PortalConfig;
-import org.exoplatform.portal.mop.SiteKey;
-import org.exoplatform.portal.pom.config.POMSessionManager;
-import org.exoplatform.portal.pom.config.tasks.PortalConfigTask;
-import org.exoplatform.portal.pom.data.PortalData;
-import org.exoplatform.portal.pom.data.PortalKey;
-import org.gatein.management.api.exceptions.OperationException;
-import org.gatein.management.api.exceptions.ResourceNotFoundException;
-import org.gatein.management.api.operation.OperationContext;
-import org.gatein.management.api.operation.ResultHandler;
-import org.gatein.mop.api.workspace.Site;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public class SiteLayoutReadResource extends AbstractSiteOperationHandler
-{
- @Override
- protected void execute(OperationContext operationContext, ResultHandler resultHandler, Site site) throws ResourceNotFoundException, OperationException
- {
- DataStorage dataStorage = operationContext.getRuntimeContext().getRuntimeComponent(DataStorage.class);
- SiteKey siteKey = getSiteKey(site);
-
- try
- {
- PortalConfig portalConfig = dataStorage.getPortalConfig(siteKey.getTypeName(), siteKey.getName());
- resultHandler.completed(portalConfig);
- }
- catch (Exception e)
- {
- throw new OperationException(operationContext.getOperationName(), "Could not retrieve site layout for site " + site, e);
- }
- }
-}
Modified: portal/branches/gatein-management/pom.xml
===================================================================
--- portal/branches/gatein-management/pom.xml 2011-07-27 14:07:50 UTC (rev 6937)
+++ portal/branches/gatein-management/pom.xml 2011-07-28 00:02:21 UTC (rev 6938)
@@ -49,7 +49,7 @@
<org.picketlink.idm>1.3.0.Alpha03</org.picketlink.idm>
<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-Alpha02-SNAPSHOT</org.gatein.mgmt.version>
+ <org.gatein.mgmt.version>1.0.0-Alpha03-SNAPSHOT</org.gatein.mgmt.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>
13 years, 5 months
gatein SVN: r6937 - in epp/portal/branches/EPP_5_2_Branch: component and 1 other directories.
by do-not-reply@jboss.org
Author: hfnukal
Date: 2011-07-27 10:07:50 -0400 (Wed, 27 Jul 2011)
New Revision: 6937
Modified:
epp/portal/branches/EPP_5_2_Branch/
epp/portal/branches/EPP_5_2_Branch/component/
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIApplicationList.java
Log:
JBEPP-1008 missing caching of categories in ApplicationRegistryService
Property changes on: epp/portal/branches/EPP_5_2_Branch
___________________________________________________________________
Modified: svn:mergeinfo
- /epp/portal/branches/EPP_5_1_0_GA_JBEPP-795:5868
/portal/branches/branch-GTNPORTAL-1592:4894
/portal/branches/branch-GTNPORTAL-1643:5002,5063,5167
/portal/branches/branch-GTNPORTAL-1700:5348,5363,5402,5445
/portal/branches/branch-GTNPORTAL-1731:5622,5668
/portal/branches/branch-GTNPORTAL-1745:5765
/portal/branches/branch-GTNPORTAL-1822:5943,5952
/portal/branches/branch-GTNPORTAL-1832:6030,6063
/portal/branches/branch-GTNPORTAL-1872:6400
/portal/branches/decoupled-webos:6214-6243
/portal/branches/global-portlet-metadata:6298-6384
/portal/branches/site-describability:6171-6235
/portal/trunk:4891,5744,5822,5943,6168,6196,6201-6203,6205-6206,6437,6440,6449,6452,6573,6783-6784
+ /epp/portal/branches/EPP_5_1_0_GA_JBEPP-795:5868
/portal/branches/branch-GTNPORTAL-1592:4894
/portal/branches/branch-GTNPORTAL-1643:5002,5063,5167
/portal/branches/branch-GTNPORTAL-1700:5348,5363,5402,5445
/portal/branches/branch-GTNPORTAL-1731:5622,5668
/portal/branches/branch-GTNPORTAL-1745:5765
/portal/branches/branch-GTNPORTAL-1822:5943,5952
/portal/branches/branch-GTNPORTAL-1832:6030,6063
/portal/branches/branch-GTNPORTAL-1872:6400,6551
/portal/branches/branch-GTNPORTAL-1921:6603
/portal/branches/branch-GTNPORTAL-1963:6904,6915-6916
/portal/branches/decoupled-webos:6214-6243
/portal/branches/global-portlet-metadata:6298-6384
/portal/branches/site-describability:6171-6235
/portal/trunk:4891,5744,5822,5943,6168,6196,6201-6203,6205-6206,6437,6440,6449,6452,6573,6783-6784
Property changes on: epp/portal/branches/EPP_5_2_Branch/component
___________________________________________________________________
Modified: svn:mergeinfo
- /epp/portal/branches/EPP_5_1_0_GA_JBEPP-795/component:5868
/portal/branches/branch-GTNPORTAL-1592/component:4894
/portal/branches/branch-GTNPORTAL-1643/component:5002,5063,5167
/portal/branches/branch-GTNPORTAL-1700/component:5348,5363,5402,5445
/portal/branches/branch-GTNPORTAL-1731/component:5622,5668
/portal/branches/branch-GTNPORTAL-1745/component:5765
/portal/branches/branch-GTNPORTAL-1822/component:5943,5952
/portal/branches/branch-GTNPORTAL-1832/component:6030,6063
/portal/branches/branch-GTNPORTAL-1872/component:6400
/portal/trunk/component:4891,5744,5822,5943,6031,6033,6168,6196,6201-6203,6205-6206,6437,6440,6449,6452,6573,6783-6784
+ /epp/portal/branches/EPP_5_1_0_GA_JBEPP-795/component:5868
/portal/branches/branch-GTNPORTAL-1592/component:4894
/portal/branches/branch-GTNPORTAL-1643/component:5002,5063,5167
/portal/branches/branch-GTNPORTAL-1700/component:5348,5363,5402,5445
/portal/branches/branch-GTNPORTAL-1731/component:5622,5668
/portal/branches/branch-GTNPORTAL-1745/component:5765
/portal/branches/branch-GTNPORTAL-1822/component:5943,5952
/portal/branches/branch-GTNPORTAL-1832/component:6030,6063
/portal/branches/branch-GTNPORTAL-1872/component:6400,6551
/portal/branches/branch-GTNPORTAL-1921/component:6603
/portal/branches/branch-GTNPORTAL-1963/component:6904,6915-6916
/portal/trunk/component:4891,5744,5822,5943,6031,6033,6168,6196,6201-6203,6205-6206,6437,6440,6449,6452,6573,6783-6784
Modified: epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIApplicationList.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIApplicationList.java 2011-07-27 13:42:48 UTC (rev 6936)
+++ epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIApplicationList.java 2011-07-27 14:07:50 UTC (rev 6937)
@@ -54,51 +54,11 @@
public UIApplicationList() throws Exception
{
- ApplicationRegistryService service = getApplicationComponent(ApplicationRegistryService.class);
- String remoteUser = Util.getPortalRequestContext().getRemoteUser();
- if (remoteUser == null || remoteUser.equals(""))
- return;
- UserACL userACL = Util.getUIPortalApplication().getApplicationComponent(UserACL.class);
-
- PortletComparator portletComparator = new PortletComparator();
- categories = service.getApplicationCategories(remoteUser);
-
- Iterator<ApplicationCategory> cateItr = categories.iterator();
- while (cateItr.hasNext())
- {
- ApplicationCategory cate = cateItr.next();
- List<Application> applications = cate.getApplications();
- boolean hasPermission = false;
- List<String> accessPermission = cate.getAccessPermissions();
- if (accessPermission == null)
- {
- accessPermission = new ArrayList<String>();
- }
- if (accessPermission.size() == 0)
- {
- accessPermission.add(null);
- }
- for (String permssion : accessPermission)
- {
- hasPermission = userACL.hasPermission(permssion);
- if (hasPermission)
- break;
- }
-
- if (!hasPermission || applications.size() < 1)
- cateItr.remove();
- else
- Collections.sort(applications, portletComparator);
- }
- if (categories.size() > 0)
- setSelectedCategory(categories.get(0).getName());
-
- Collections.sort(categories, new PortletCategoryComparator());
}
public Application getApplication(String id) throws Exception
{
- for (ApplicationCategory category : categories)
+ for (ApplicationCategory category : getCategories())
{
List<Application> items = category.getApplications();
for (Application item : items)
@@ -117,7 +77,7 @@
public void setSelectedCategory(String categoryName)
{
- for (ApplicationCategory category : categories)
+ for (ApplicationCategory category : getCategories())
{
if (category.getName().equals(categoryName))
{
@@ -155,22 +115,76 @@
public List<ApplicationCategory> getCategories()
{
- return categories;
+ try
+ {
+ //TODO: Handle concurrent requests associated with current session
+ if (categories == null)
+ {
+ initAllCategories();
+ }
+ return categories;
+ }
+ catch (Exception ex)
+ {
+ return null;
+ }
}
- static class PortletCategoryComparator implements Comparator<ApplicationCategory>
+ private void initAllCategories() throws Exception
{
- public int compare(ApplicationCategory cat1, ApplicationCategory cat2)
+ String remoteUser = Util.getPortalRequestContext().getRemoteUser();
+ if (remoteUser == null || remoteUser.equals(""))
+ { return; }
+
+ ApplicationRegistryService service = getApplicationComponent(ApplicationRegistryService.class);
+ UserACL userACL = Util.getUIPortalApplication().getApplicationComponent(UserACL.class);
+
+ final Comparator<Application> appComparator = new Comparator<Application>()
{
- return cat1.getDisplayName().compareToIgnoreCase(cat2.getDisplayName());
+ public int compare(Application p_1, Application p_2)
+ {
+ return p_1.getDisplayName().compareToIgnoreCase(p_2.getDisplayName());
+ }
+ };
+ final Comparator<ApplicationCategory> cateComparator = new Comparator<ApplicationCategory>()
+ {
+ public int compare(ApplicationCategory p_1, ApplicationCategory p_2)
+ {
+ return p_1.getDisplayName().compareToIgnoreCase(p_2.getDisplayName());
+ }
+ };
+
+ List<ApplicationCategory> allCategories = service.getApplicationCategories(remoteUser);
+ categories = new ArrayList<ApplicationCategory>();
+
+ for (ApplicationCategory category : allCategories)
+ {
+ List<Application> apps = category.getApplications();
+ List<String> accessPermission = category.getAccessPermissions();
+ if(accessPermission == null)
+ {
+ continue;
+ }
+
+ accessCheck:
+ for (String p : accessPermission)
+ {
+ if (userACL.hasPermission(p))
+ {
+ if (apps.size() > 0)
+ {
+ Collections.sort(apps, appComparator);
+ }
+ categories.add(category);
+ }
+ break accessCheck;
+ }
}
- }
- static class PortletComparator implements Comparator<Application>
- {
- public int compare(Application p1, Application p2)
+ if (categories.size() > 0)
{
- return p1.getDisplayName().compareToIgnoreCase(p2.getDisplayName());
+ Collections.sort(categories, cateComparator);
+ selectedCategory = categories.get(0);
}
}
13 years, 5 months
gatein SVN: r6936 - in portal/branches/api/component/api-impl: src/main/java/org/gatein/portal/api/impl/util and 7 other directories.
by do-not-reply@jboss.org
Author: chris.laprun(a)jboss.com
Date: 2011-07-27 09:42:48 -0400 (Wed, 27 Jul 2011)
New Revision: 6936
Added:
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/util/AggregatedIterableIdentifiableCollection.java
portal/branches/api/component/api-impl/src/test/java/org/
portal/branches/api/component/api-impl/src/test/java/org/gatein/
portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/
portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/
portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/
portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/util/
portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/util/AggregatedIterableIdentifiableCollectionTestCase.java
Modified:
portal/branches/api/component/api-impl/pom.xml
Log:
- Added AggregatedIterableIdentifiableCollection and related test case.
Modified: portal/branches/api/component/api-impl/pom.xml
===================================================================
--- portal/branches/api/component/api-impl/pom.xml 2011-07-27 11:04:44 UTC (rev 6935)
+++ portal/branches/api/component/api-impl/pom.xml 2011-07-27 13:42:48 UTC (rev 6936)
@@ -34,6 +34,12 @@
<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>
</dependencies>
<build>
Added: portal/branches/api/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 (rev 0)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/util/AggregatedIterableIdentifiableCollection.java 2011-07-27 13:42:48 UTC (rev 6936)
@@ -0,0 +1,150 @@
+/*
+* 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;
+
+/** @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a> */
+public class AggregatedIterableIdentifiableCollection<T extends Identifiable<T>> implements IterableIdentifiableCollection<T>
+{
+ private List<IterableIdentifiableCollection<T>> aggregated = new ArrayList<IterableIdentifiableCollection<T>>(7);
+
+ public void addCollection(IterableIdentifiableCollection<T> collection)
+ {
+ 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<T>> 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();
+ }
+ };
+ }
+ }
+}
Added: portal/branches/api/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 (rev 0)
+++ portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/util/AggregatedIterableIdentifiableCollectionTestCase.java 2011-07-27 13:42:48 UTC (rev 6936)
@@ -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(Id.create(GateInImpl.GROUP_CONTEXT, 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();
+ }
+ }
+}
13 years, 5 months
gatein SVN: r6935 - portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium.
by do-not-reply@jboss.org
Author: hanh.ly
Date: 2011-07-27 07:04:44 -0400 (Wed, 27 Jul 2011)
New Revision: 6935
Modified:
portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_SNF_PRL_25_ChangeContainerInPortal.html
portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_SNF_PRL_35_ChangeApplicationWhenEditPropertiesOfNodeInPortalNavigation.html
portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_SNF_PRL_36_AddApplicationIntoContainerWhenEditPagePropertiesOfNode.html
portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_SNF_PRL_37_ManageNavigationOfGroup.html
portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_SNF_PRL_38_EditPropertiesForGroup.html
portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_SNF_PRL_40_EditPageForGroup.html
portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_SNF_PRL_41_ChangeSiteConfigWhenEditlayOutForGroupPage.html
portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_SNF_PRL_42_ChangeContainerWhenEditLayoutForGroupPage.html
portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_SNF_PRL_43_ChangeApplicationWhenEditLayoutForGroupPage.html
portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_SNF_PRL_44_AddApplicationIntoCategoryWhenEditLayoutForGroupPage.html
portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_SNF_PRL_45_ManageNodeGroup.html.html
portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_SNF_PRL_46_MoreActionOnNodeInEditNavigationOfGroup.html
portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_SNF_PRL_51_ManageGadget.html
portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_SNF_PRL_52_ManageTab.html
portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_SNF_PRL_53_DragAndDropGadget.html
portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_SNF_PRL_63_ManagePageOfUser.html
portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_SNF_PRL_67_ChangePassword.html
Log:
TESTVN-3935
Modified: portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_SNF_PRL_25_ChangeContainerInPortal.html
===================================================================
--- portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_SNF_PRL_25_ChangeContainerInPortal.html 2011-07-26 21:14:24 UTC (rev 6934)
+++ portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_SNF_PRL_25_ChangeContainerInPortal.html 2011-07-27 11:04:44 UTC (rev 6935)
@@ -407,8 +407,13 @@
<td></td>
</tr>
<tr>
+ <td>waitForElementPresent</td>
+ <td>//div[@title="Hold this area to drag this container"]</td>
+ <td></td>
+</tr>
+<tr>
<td>mouseOver</td>
- <td>//div/div/div[2]/div/div[2]/div/div</td>
+ <td>//div[@title="Hold this area to drag this container"]</td>
<td></td>
</tr>
<tr>
Modified: portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_SNF_PRL_35_ChangeApplicationWhenEditPropertiesOfNodeInPortalNavigation.html
===================================================================
--- portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_SNF_PRL_35_ChangeApplicationWhenEditPropertiesOfNodeInPortalNavigation.html 2011-07-26 21:14:24 UTC (rev 6934)
+++ portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_SNF_PRL_35_ChangeApplicationWhenEditPropertiesOfNodeInPortalNavigation.html 2011-07-27 11:04:44 UTC (rev 6935)
@@ -192,16 +192,6 @@
<td></td>
</tr>
<tr>
- <td>waitForElementPresent</td>
- <td>//div[@id='PortalNavigationTopContainer']/div[3]/div/div/div/div/div/div/a</td>
- <td></td>
-</tr>
-<tr>
- <td>clickAndWait</td>
- <td>//div[@id='PortalNavigationTopContainer']/div[3]/div/div/div/div/div/div/a</td>
- <td></td>
-</tr>
-<tr>
<td>waitForTextPresent</td>
<td>Test_SNF_PRL_35</td>
<td></td>
@@ -402,8 +392,13 @@
<td>Calculator</td>
</tr>
<tr>
+ <td>waitForElementPresent</td>
+ <td>//div[2]/div/div[2]/div/a</td>
+ <td></td>
+</tr>
+<tr>
<td>click</td>
- <td>//div[2]/div/div[2]/div/div/div[2]/div//a[1]</td>
+ <td>//div[2]/div/div[2]/div/a</td>
<td></td>
</tr>
<tr>
Modified: portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_SNF_PRL_36_AddApplicationIntoContainerWhenEditPagePropertiesOfNode.html
===================================================================
--- portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_SNF_PRL_36_AddApplicationIntoContainerWhenEditPagePropertiesOfNode.html 2011-07-26 21:14:24 UTC (rev 6934)
+++ portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_SNF_PRL_36_AddApplicationIntoContainerWhenEditPagePropertiesOfNode.html 2011-07-27 11:04:44 UTC (rev 6935)
@@ -123,12 +123,12 @@
</tr>
<tr>
<td>waitForElementPresent</td>
- <td>searchTerm</td>
+ <td>//form[@id='UIPageSearchForm']/div[2]/input</td>
<td></td>
</tr>
<tr>
<td>type</td>
- <td>searchTerm</td>
+ <td>//form[@id='UIPageSearchForm']/div[2]/input</td>
<td>Community Management</td>
</tr>
<tr>
@@ -139,16 +139,16 @@
<tr>
<td>select</td>
<td>searchOption</td>
- <td>label=Title</td>
+ <td>label=group</td>
</tr>
<tr>
<td>waitForElementPresent</td>
- <td>//form[@id='UIPageSearch']//a[@title="Quick Search"]</td>
+ <td>//form[@id='UIPageSearchForm']/div[2]/a</td>
<td></td>
</tr>
<tr>
<td>click</td>
- <td>//form[@id='UIPageSearch']//a[@title="Quick Search"]</td>
+ <td>//form[@id='UIPageSearchForm']/div[2]/a</td>
<td></td>
</tr>
<tr>
@@ -193,12 +193,12 @@
</tr>
<tr>
<td>waitForElementPresent</td>
- <td>//div[@id='PortalNavigationTopContainer']/div[3]/div/div/div/div/div/div/a</td>
+ <td>//a[contains(text(),'Home')]</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
- <td>//div[@id='PortalNavigationTopContainer']/div[3]/div/div/div/div/div/div/a</td>
+ <td>//a[contains(text(),'Home')]</td>
<td></td>
</tr>
<tr>
@@ -508,21 +508,6 @@
</tr>
<tr>
<td>echo</td>
- <td>-- View node after change application --</td>
- <td></td>
-</tr>
-<tr>
- <td>waitForElementPresent</td>
- <td>//div[@id='PortalNavigationTopContainer']/div[3]/div/div/div/div/div/div/a</td>
- <td></td>
-</tr>
-<tr>
- <td>clickAndWait</td>
- <td>//div[@id='PortalNavigationTopContainer']/div[3]/div/div/div/div/div/div/a</td>
- <td></td>
-</tr>
-<tr>
- <td>echo</td>
<td>-- Delete this node--</td>
<td></td>
</tr>
Modified: portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_SNF_PRL_37_ManageNavigationOfGroup.html
===================================================================
--- portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_SNF_PRL_37_ManageNavigationOfGroup.html 2011-07-26 21:14:24 UTC (rev 6934)
+++ portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_SNF_PRL_37_ManageNavigationOfGroup.html 2011-07-27 11:04:44 UTC (rev 6935)
@@ -83,16 +83,6 @@
</tr>
<tr>
<td>waitForTextPresent</td>
- <td>Guests</td>
- <td></td>
-</tr>
-<tr>
- <td>verifyTextPresent</td>
- <td>Guests</td>
- <td></td>
-</tr>
-<tr>
- <td>waitForTextPresent</td>
<td>Users</td>
<td></td>
</tr>
Modified: portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_SNF_PRL_38_EditPropertiesForGroup.html
===================================================================
--- portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_SNF_PRL_38_EditPropertiesForGroup.html 2011-07-26 21:14:24 UTC (rev 6934)
+++ portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_SNF_PRL_38_EditPropertiesForGroup.html 2011-07-27 11:04:44 UTC (rev 6935)
@@ -73,12 +73,12 @@
</tr>
<tr>
<td>waitForElementPresent</td>
- <td>//div[4]/div/div[1]/a[text()='Organization']</td>
+ <td>//a[contains(text(),'Organization')]</td>
<td></td>
</tr>
<tr>
<td>verifyElementPresent</td>
- <td>//div[4]/div/div[1]/a[text()='Organization']</td>
+ <td>//a[contains(text(),'Organization')]</td>
<td></td>
</tr>
<tr>
@@ -88,7 +88,7 @@
</tr>
<tr>
<td>mouseOver</td>
- <td>link=Users and groups management</td>
+ <td>link=Users and Groups Manager</td>
<td></td>
</tr>
<tr>
@@ -114,16 +114,16 @@
<tr>
<td>select</td>
<td>priority</td>
- <td>label=1</td>
+ <td>label=6</td>
</tr>
<tr>
<td>waitForElementPresent</td>
- <td>//form[@id='UIPageNavigationForm']/div[2]/div/div/table/tbody/tr/td/div[1]/div/div/div</td>
+ <td>//form[@id='UIPageNavigationForm']/div[2]/div/div/a</td>
<td></td>
</tr>
<tr>
<td>click</td>
- <td>//form[@id='UIPageNavigationForm']/div[2]/div/div/table/tbody/tr/td/div[1]/div/div/div</td>
+ <td>//form[@id='UIPageNavigationForm']/div[2]/div/div/a</td>
<td></td>
</tr>
<tr>
@@ -137,13 +137,13 @@
<td></td>
</tr>
<tr>
- <td>verifyElementNotPresent</td>
- <td>//div[4]/div/div[1]/a[text()='Organization']</td>
+ <td>verifyElementPresent</td>
+ <td>//li[2]/ul/li/a</td>
<td></td>
</tr>
<tr>
<td>verifyElementPresent</td>
- <td>//div[2]/div/div[1]/a[text()='Organization']</td>
+ <td>//li[2]/ul/li[2]/a</td>
<td></td>
</tr>
<tr>
@@ -158,27 +158,27 @@
</tr>
<tr>
<td>waitForElementPresent</td>
- <td>link=Edit Properties</td>
+ <td>//table[2]/tbody/tr/td[3]/a[2]</td>
<td></td>
</tr>
<tr>
<td>click</td>
- <td>link=Edit Properties</td>
+ <td>//table[2]/tbody/tr/td[3]/a[2]</td>
<td></td>
</tr>
<tr>
<td>select</td>
<td>priority</td>
- <td>label=5</td>
+ <td>label=2</td>
</tr>
<tr>
<td>waitForElementPresent</td>
- <td>//form[@id='UIPageNavigationForm']/div[2]/div/div/table/tbody/tr/td/div[1]/div/div/div</td>
+ <td>//form[@id='UIPageNavigationForm']/div[2]/div/div/a</td>
<td></td>
</tr>
<tr>
<td>click</td>
- <td>//form[@id='UIPageNavigationForm']/div[2]/div/div/table/tbody/tr/td/div[1]/div/div/div</td>
+ <td>//form[@id='UIPageNavigationForm']/div[2]/div/div/a</td>
<td></td>
</tr>
<tr>
@@ -187,21 +187,16 @@
<td></td>
</tr>
<tr>
- <td>waitForElementPresent</td>
- <td>//div[4]/div/div[1]/a[text()='Organization']</td>
+ <td>verifyElementPresent</td>
+ <td>//li[4]/ul/li/a</td>
<td></td>
</tr>
<tr>
<td>verifyElementPresent</td>
- <td>//div[4]/div/div[1]/a[text()='Organization']</td>
+ <td>//li[4]/ul/li[2]/a</td>
<td></td>
</tr>
<tr>
- <td>verifyElementNotPresent</td>
- <td>//div[2]/div/div[1]/a[text()='Organization']</td>
- <td></td>
-</tr>
-<tr>
<td>waitForElementPresent</td>
<td>link=Sign out</td>
<td></td>
Modified: portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_SNF_PRL_40_EditPageForGroup.html
===================================================================
--- portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_SNF_PRL_40_EditPageForGroup.html 2011-07-26 21:14:24 UTC (rev 6934)
+++ portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_SNF_PRL_40_EditPageForGroup.html 2011-07-27 11:04:44 UTC (rev 6935)
@@ -598,7 +598,7 @@
</tr>
<tr>
<td>clickAndWait</td>
- <td>link=Page Management</td>
+ <td>link=Pages Manager</td>
<td></td>
</tr>
<tr>
Modified: portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_SNF_PRL_41_ChangeSiteConfigWhenEditlayOutForGroupPage.html
===================================================================
--- portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_SNF_PRL_41_ChangeSiteConfigWhenEditlayOutForGroupPage.html 2011-07-26 21:14:24 UTC (rev 6934)
+++ portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_SNF_PRL_41_ChangeSiteConfigWhenEditlayOutForGroupPage.html 2011-07-27 11:04:44 UTC (rev 6935)
@@ -53,7 +53,7 @@
</tr>
<tr>
<td>clickAndWait</td>
- <td>link=Application Registry</td>
+ <td>link=Applications Manager</td>
<td></td>
</tr>
<tr>
@@ -103,12 +103,12 @@
</tr>
<tr>
<td>waitForElementPresent</td>
- <td>//div[@id='UIPageCreationWizard']/div/div[3]/div/div/div/div[2]/div/table/tbody/tr/td/div[2]/div/div/div</td>
+ <td>//div[@id='UIPageCreationWizard']/div/div[3]/div/div/div/div[2]/div/a[2]</td>
<td></td>
</tr>
<tr>
<td>click</td>
- <td>//div[@id='UIPageCreationWizard']/div/div[3]/div/div/div/div[2]/div/table/tbody/tr/td/div[2]/div/div/div</td>
+ <td>//div[@id='UIPageCreationWizard']/div/div[3]/div/div/div/div[2]/div/a[2]</td>
<td></td>
</tr>
<tr>
@@ -118,12 +118,12 @@
</tr>
<tr>
<td>waitForElementPresent</td>
- <td>//div[@id='UIPageCreationWizard']/div/div[3]/div/div/div/div[2]/div/table/tbody/tr/td/div[2]/div/div/div</td>
+ <td>//div[@id='UIPageCreationWizard']/div/div[3]/div/div/div/div[2]/div/a[2]</td>
<td></td>
</tr>
<tr>
<td>click</td>
- <td>//div[@id='UIPageCreationWizard']/div/div[3]/div/div/div/div[2]/div/table/tbody/tr/td/div[2]/div/div/div</td>
+ <td>//div[@id='UIPageCreationWizard']/div/div[3]/div/div/div/div[2]/div/a[2]</td>
<td></td>
</tr>
<tr>
@@ -142,7 +142,7 @@
<td></td>
</tr>
<tr>
- <td>assertLocation</td>
+ <td>open</td>
<td>http://localhost:8080/portal/private/classic/administration/Test_SNF_PRL_41</td>
<td></td>
</tr>
@@ -338,12 +338,12 @@
</tr>
<tr>
<td>waitForElementPresent</td>
- <td>//div[@id='UIGroupNavigationGrid']/table[2]/tbody/tr/td[3]/a[1]</td>
+ <td>//div[@id='UIGroupNavigationGrid']/table/tbody/tr/td[3]/a</td>
<td>Edit Navigation</td>
</tr>
<tr>
<td>click</td>
- <td>//div[@id='UIGroupNavigationGrid']/table[2]/tbody/tr/td[3]/a[1]</td>
+ <td>//div[@id='UIGroupNavigationGrid']/table/tbody/tr/td[3]/a</td>
<td>Edit Navigation</td>
</tr>
<tr>
@@ -398,37 +398,27 @@
</tr>
<tr>
<td>clickAndWait</td>
- <td>link=Page Management</td>
+ <td>link=Pages Manager</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
- <td>searchTerm</td>
+ <td>pageTitle</td>
<td>Test_SNF_PRL_41</td>
</tr>
<tr>
<td>type</td>
- <td>searchTerm</td>
+ <td>pageTitle</td>
<td>Test_SNF_PRL_41</td>
</tr>
<tr>
<td>waitForElementPresent</td>
- <td>searchOption</td>
+ <td>//form[@id='UIPageSearchForm']/div[2]/a</td>
<td></td>
</tr>
<tr>
- <td>select</td>
- <td>searchOption</td>
- <td>label=Title</td>
-</tr>
-<tr>
- <td>waitForElementPresent</td>
- <td>//form[@id='UIPageSearch']/div[2]/a</td>
- <td></td>
-</tr>
-<tr>
<td>click</td>
- <td>//form[@id='UIPageSearch']/div[2]/a</td>
+ <td>//form[@id='UIPageSearchForm']/div[2]/a</td>
<td></td>
</tr>
<tr>
@@ -468,12 +458,12 @@
</tr>
<tr>
<td>waitForElementPresent</td>
- <td>//div[5]/div/div[2]/div/div/div/div/div/div[3]/div/table/tbody/tr/td/div/div/div/div/a</td>
+ <td>//div[5]/div/div[2]/div/div/div/div/div/div[3]/div/a</td>
<td></td>
</tr>
<tr>
<td>click</td>
- <td>//div[5]/div/div[2]/div/div/div/div/div/div[3]/div/table/tbody/tr/td/div/div/div/div/a</td>
+ <td>//div[5]/div/div[2]/div/div/div/div/div/div[3]/div/a</td>
<td></td>
</tr>
<tr>
Modified: portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_SNF_PRL_42_ChangeContainerWhenEditLayoutForGroupPage.html
===================================================================
--- portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_SNF_PRL_42_ChangeContainerWhenEditLayoutForGroupPage.html 2011-07-26 21:14:24 UTC (rev 6934)
+++ portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_SNF_PRL_42_ChangeContainerWhenEditLayoutForGroupPage.html 2011-07-27 11:04:44 UTC (rev 6935)
@@ -103,12 +103,12 @@
</tr>
<tr>
<td>waitForElementPresent</td>
- <td>//div[@id='UIPageCreationWizard']/div/div[3]/div/div/div/div[2]/div/table/tbody/tr/td/div[2]/div/div/div</td>
+ <td>//div[@id='UIPageCreationWizard']/div/div[3]/div/div/div/div[2]/div/a[2]</td>
<td></td>
</tr>
<tr>
<td>click</td>
- <td>//div[@id='UIPageCreationWizard']/div/div[3]/div/div/div/div[2]/div/table/tbody/tr/td/div[2]/div/div/div</td>
+ <td>//div[@id='UIPageCreationWizard']/div/div[3]/div/div/div/div[2]/div/a[2]</td>
<td></td>
</tr>
<tr>
@@ -118,12 +118,12 @@
</tr>
<tr>
<td>waitForElementPresent</td>
- <td>//div[@id='UIPageCreationWizard']/div/div[3]/div/div/div/div[2]/div/table/tbody/tr/td/div[2]/div/div/div</td>
+ <td>//div[@id='UIPageCreationWizard']/div/div[3]/div/div/div/div[2]/div/a[2]</td>
<td></td>
</tr>
<tr>
<td>click</td>
- <td>//div[@id='UIPageCreationWizard']/div/div[3]/div/div/div/div[2]/div/table/tbody/tr/td/div[2]/div/div/div</td>
+ <td>//div[@id='UIPageCreationWizard']/div/div[3]/div/div/div/div[2]/div/a[2]</td>
<td></td>
</tr>
<tr>
Modified: portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_SNF_PRL_43_ChangeApplicationWhenEditLayoutForGroupPage.html
===================================================================
--- portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_SNF_PRL_43_ChangeApplicationWhenEditLayoutForGroupPage.html 2011-07-26 21:14:24 UTC (rev 6934)
+++ portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_SNF_PRL_43_ChangeApplicationWhenEditLayoutForGroupPage.html 2011-07-27 11:04:44 UTC (rev 6935)
@@ -53,7 +53,7 @@
</tr>
<tr>
<td>clickAndWait</td>
- <td>link=Application Registry</td>
+ <td>link=Applications Manager</td>
<td></td>
</tr>
<tr>
@@ -103,12 +103,12 @@
</tr>
<tr>
<td>waitForElementPresent</td>
- <td>//div[@id='UIPageCreationWizard']/div/div[3]/div/div/div/div[2]/div/table/tbody/tr/td/div[2]/div/div/div</td>
+ <td>//div[@id='UIPageCreationWizard']/div/div[3]/div/div/div/div[2]/div/a[2]</td>
<td></td>
</tr>
<tr>
<td>click</td>
- <td>//div[@id='UIPageCreationWizard']/div/div[3]/div/div/div/div[2]/div/table/tbody/tr/td/div[2]/div/div/div</td>
+ <td>//div[@id='UIPageCreationWizard']/div/div[3]/div/div/div/div[2]/div/a[2]</td>
<td></td>
</tr>
<tr>
@@ -118,12 +118,12 @@
</tr>
<tr>
<td>waitForElementPresent</td>
- <td>//div[@id='UIPageCreationWizard']/div/div[3]/div/div/div/div[2]/div/table/tbody/tr/td/div[2]/div/div/div</td>
+ <td>//div[@id='UIPageCreationWizard']/div/div[3]/div/div/div/div[2]/div/a[2]</td>
<td></td>
</tr>
<tr>
<td>click</td>
- <td>//div[@id='UIPageCreationWizard']/div/div[3]/div/div/div/div[2]/div/table/tbody/tr/td/div[2]/div/div/div</td>
+ <td>//div[@id='UIPageCreationWizard']/div/div[3]/div/div/div/div[2]/div/a[2]</td>
<td></td>
</tr>
<tr>
Modified: portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_SNF_PRL_44_AddApplicationIntoCategoryWhenEditLayoutForGroupPage.html
===================================================================
--- portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_SNF_PRL_44_AddApplicationIntoCategoryWhenEditLayoutForGroupPage.html 2011-07-26 21:14:24 UTC (rev 6934)
+++ portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_SNF_PRL_44_AddApplicationIntoCategoryWhenEditLayoutForGroupPage.html 2011-07-27 11:04:44 UTC (rev 6935)
@@ -53,7 +53,7 @@
</tr>
<tr>
<td>clickAndWait</td>
- <td>link=Application Registry</td>
+ <td>link=Applications Manager</td>
<td></td>
</tr>
<tr>
@@ -103,12 +103,12 @@
</tr>
<tr>
<td>waitForElementPresent</td>
- <td>//div[@id='UIPageCreationWizard']/div/div[3]/div/div/div/div[2]/div/table/tbody/tr/td/div[2]/div/div/div</td>
+ <td>//div[@id='UIPageCreationWizard']/div/div[3]/div/div/div/div[2]/div/a[2]</td>
<td></td>
</tr>
<tr>
<td>click</td>
- <td>//div[@id='UIPageCreationWizard']/div/div[3]/div/div/div/div[2]/div/table/tbody/tr/td/div[2]/div/div/div</td>
+ <td>//div[@id='UIPageCreationWizard']/div/div[3]/div/div/div/div[2]/div/a[2]</td>
<td></td>
</tr>
<tr>
@@ -118,12 +118,12 @@
</tr>
<tr>
<td>waitForElementPresent</td>
- <td>//div[@id='UIPageCreationWizard']/div/div[3]/div/div/div/div[2]/div/table/tbody/tr/td/div[2]/div/div/div</td>
+ <td>//div[@id='UIPageCreationWizard']/div/div[3]/div/div/div/div[2]/div/a[2]</td>
<td></td>
</tr>
<tr>
<td>click</td>
- <td>//div[@id='UIPageCreationWizard']/div/div[3]/div/div/div/div[2]/div/table/tbody/tr/td/div[2]/div/div/div</td>
+ <td>//div[@id='UIPageCreationWizard']/div/div[3]/div/div/div/div[2]/div/a[2]</td>
<td></td>
</tr>
<tr>
@@ -293,17 +293,22 @@
</tr>
<tr>
<td>mouseOver</td>
- <td>//div/div/div[2]/div/div/div/div/div/div/div[2]</td>
+ <td>//div[2]/div/div[2]/div/div[2]</td>
<td>Calculator</td>
</tr>
<tr>
<td>waitForElementPresent</td>
- <td>//div/div/div[2]/div/div/div/div/div/div/a[2]</td>
+ <td>//div[2]/div/a[2]</td>
<td></td>
</tr>
<tr>
+ <td>waitForElementPresent</td>
+ <td>//div[2]/div/a[2]</td>
+ <td></td>
+</tr>
+<tr>
<td>click</td>
- <td>//div/div/div[2]/div/div/div/div/div/div/a[2]</td>
+ <td>//div[2]/div/a[2]</td>
<td></td>
</tr>
<tr>
@@ -338,12 +343,12 @@
</tr>
<tr>
<td>waitForElementPresent</td>
- <td>//div/div/div[2]/div/div/div/div/div/div/a[2]</td>
+ <td>//div[2]/div/a[2]</td>
<td></td>
</tr>
<tr>
<td>click</td>
- <td>//div/div/div[2]/div/div/div/div/div/div/a[2]</td>
+ <td>//div[2]/div/a[2]</td>
<td></td>
</tr>
<tr>
@@ -388,12 +393,12 @@
</tr>
<tr>
<td>waitForElementPresent</td>
- <td>//div[@id='UIGroupNavigationGrid']/table[2]/tbody/tr/td[3]/a[1]</td>
+ <td>//div[@id='UIGroupNavigationGrid']/table/tbody/tr/td[3]/a</td>
<td>Edit Navigation</td>
</tr>
<tr>
<td>click</td>
- <td>//div[@id='UIGroupNavigationGrid']/table[2]/tbody/tr/td[3]/a[1]</td>
+ <td>//div[@id='UIGroupNavigationGrid']/table/tbody/tr/td[3]/a</td>
<td>Edit Navigation</td>
</tr>
<tr>
@@ -443,42 +448,42 @@
</tr>
<tr>
<td>echo</td>
- <td>-- Go to Page Management --</td>
+ <td>-- Go to Pages Manager --</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
- <td>link=Page Management</td>
+ <td>link=Pages Manager</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
- <td>searchTerm</td>
+ <td>pageTitle</td>
<td></td>
</tr>
<tr>
<td>type</td>
- <td>searchTerm</td>
+ <td>pageTitle</td>
<td>Test_SNF_PRL_44</td>
</tr>
<tr>
<td>waitForElementPresent</td>
- <td>searchOption</td>
+ <td>name=searchOption</td>
<td></td>
</tr>
<tr>
<td>select</td>
- <td>searchOption</td>
- <td>label=Title</td>
+ <td>name=searchOption</td>
+ <td>label=group</td>
</tr>
<tr>
<td>waitForElementPresent</td>
- <td>//form[@id='UIPageSearch']/div[2]/a</td>
+ <td>//form[@id='UIPageSearchForm']/div[2]/a</td>
<td></td>
</tr>
<tr>
<td>click</td>
- <td>//form[@id='UIPageSearch']/div[2]/a</td>
+ <td>//form[@id='UIPageSearchForm']/div[2]/a</td>
<td></td>
</tr>
<tr>
@@ -513,12 +518,12 @@
</tr>
<tr>
<td>waitForElementPresent</td>
- <td>//div[5]/div/div[2]/div/div/div/div/div/div[3]/div/table/tbody/tr/td/div/div/div/div/a</td>
+ <td>//div[5]/div/div[2]/div/div/div/div/div/div[3]/div/a</td>
<td></td>
</tr>
<tr>
<td>click</td>
- <td>//div[5]/div/div[2]/div/div/div/div/div/div[3]/div/table/tbody/tr/td/div/div/div/div/a</td>
+ <td>//div[5]/div/div[2]/div/div/div/div/div/div[3]/div/a</td>
<td></td>
</tr>
<tr>
Modified: portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_SNF_PRL_45_ManageNodeGroup.html.html
===================================================================
--- portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_SNF_PRL_45_ManageNodeGroup.html.html 2011-07-26 21:14:24 UTC (rev 6934)
+++ portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_SNF_PRL_45_ManageNodeGroup.html.html 2011-07-27 11:04:44 UTC (rev 6935)
@@ -248,12 +248,12 @@
</tr>
<tr>
<td>waitForElementPresent</td>
- <td>//a[contains(@onmousedown,'Test_SNF_PRL_45')]</td>
+ <td>//div[@id='UINavigationNodeSelector']/div/div/div/div[2]/div/div/div[3]/div//a[@title='Test_SNF_PRL_45']</td>
<td></td>
</tr>
<tr>
<td>mouseDownRight</td>
- <td>//a[contains(@onmousedown,'Test_SNF_PRL_45')]</td>
+ <td>//div[@id='UINavigationNodeSelector']/div/div/div/div[2]/div/div/div[3]/div//a[@title='Test_SNF_PRL_45']</td>
<td></td>
</tr>
<tr>
Modified: portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_SNF_PRL_46_MoreActionOnNodeInEditNavigationOfGroup.html
===================================================================
--- portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_SNF_PRL_46_MoreActionOnNodeInEditNavigationOfGroup.html 2011-07-26 21:14:24 UTC (rev 6934)
+++ portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_SNF_PRL_46_MoreActionOnNodeInEditNavigationOfGroup.html 2011-07-27 11:04:44 UTC (rev 6935)
@@ -133,32 +133,32 @@
</tr>
<tr>
<td>waitForElementPresent</td>
- <td>searchTerm</td>
+ <td>//form[@id='UIPageSearchForm']/div[2]/input</td>
<td></td>
</tr>
<tr>
<td>type</td>
- <td>searchTerm</td>
+ <td>//form[@id='UIPageSearchForm']/div[2]/input</td>
<td>Community Management</td>
</tr>
<tr>
<td>waitForElementPresent</td>
- <td>searchOption</td>
+ <td>name=searchOption</td>
<td></td>
</tr>
<tr>
<td>select</td>
- <td>searchOption</td>
- <td>label=Title</td>
+ <td>name=searchOption</td>
+ <td>label=group</td>
</tr>
<tr>
<td>waitForElementPresent</td>
- <td>//form[@id='UIPageSearch']/div[2]/a</td>
+ <td>//form[@id='UIPageSearchForm']/div[2]/a</td>
<td></td>
</tr>
<tr>
<td>click</td>
- <td>//form[@id='UIPageSearch']/div[2]/a</td>
+ <td>//form[@id='UIPageSearchForm']/div[2]/a</td>
<td></td>
</tr>
<tr>
Modified: portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_SNF_PRL_51_ManageGadget.html
===================================================================
--- portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_SNF_PRL_51_ManageGadget.html 2011-07-26 21:14:24 UTC (rev 6934)
+++ portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_SNF_PRL_51_ManageGadget.html 2011-07-27 11:04:44 UTC (rev 6935)
@@ -158,17 +158,17 @@
</tr>
<tr>
<td>clickAndWait</td>
- <td>link=Application Registry</td>
+ <td>link=Applications Manager</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
- <td>link=Gadget</td>
+ <td>link=Gadgets</td>
<td></td>
</tr>
<tr>
<td>click</td>
- <td>link=Gadget</td>
+ <td>link=Gadgets</td>
<td></td>
</tr>
<tr>
@@ -183,7 +183,7 @@
</tr>
<tr>
<td>assertConfirmation</td>
- <td>Are you sure to delete this gadget?</td>
+ <td>Are you sure you want to delete this gadget?</td>
<td></td>
</tr>
<tr>
Modified: portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_SNF_PRL_52_ManageTab.html
===================================================================
--- portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_SNF_PRL_52_ManageTab.html 2011-07-26 21:14:24 UTC (rev 6934)
+++ portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_SNF_PRL_52_ManageTab.html 2011-07-27 11:04:44 UTC (rev 6935)
@@ -68,37 +68,27 @@
</tr>
<tr>
<td>waitForElementPresent</td>
- <td>//div[@id='UITabPaneDashboard']/div/div/div/div/div/div[2]</td>
+ <td>//div[@id='UITabPaneDashboard']/a</td>
<td></td>
</tr>
<tr>
<td>click</td>
- <td>//div[@id='UITabPaneDashboard']/div/div/div/div/div/div[2]</td>
+ <td>//div[@id='UITabPaneDashboard']/a</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
- <td>//div[@id='UITabPaneDashboard']/div/div/div/div/div/div[2]/div/div/div/div/input</td>
+ <td>//div[@id='UITabPaneDashboard']/div[2]/input</td>
<td></td>
</tr>
<tr>
<td>type</td>
- <td>//div[@id='UITabPaneDashboard']/div/div/div/div/div/div[2]/div/div/div/div/input</td>
+ <td>//div[@id='UITabPaneDashboard']/div[2]/input</td>
<td>Test_SNF_PRL_52</td>
</tr>
<tr>
- <td>waitForElementPresent</td>
- <td>//div[@id='UITabPaneDashboard']/div/div/div/div/div/div[2]/div/div/div/div/a/img</td>
- <td></td>
-</tr>
-<tr>
- <td>click</td>
- <td>//div[@id='UITabPaneDashboard']/div/div/div/div/div/div[2]/div/div/div/div/a/img</td>
- <td></td>
-</tr>
-<tr>
<td>keyPress</td>
- <td>//div[@id='UITabPaneDashboard']/div/div/div/div/div/div[2]/div/div/div/div/input</td>
+ <td>//div[@id='UITabPaneDashboard']/div[2]/input</td>
<td>\13</td>
</tr>
<tr>
@@ -118,27 +108,27 @@
</tr>
<tr>
<td>waitForElementPresent</td>
- <td>//div[@id='UITabPaneDashboard']/div/div/div/div/div/div[2]/div/div/div/div/span</td>
+ <td>//div[@id='UITabPaneDashboard']/div[2]/span</td>
<td></td>
</tr>
<tr>
<td>doubleClick</td>
- <td>//div[@id='UITabPaneDashboard']/div/div/div/div/div/div[2]/div/div/div/div/span</td>
+ <td>//div[@id='UITabPaneDashboard']/div[2]/span</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
- <td>//div[@id='UITabPaneDashboard']/div/div/div/div/div/div[2]/div/div/div/div/input</td>
+ <td>//div[@id='UITabPaneDashboard']/div[2]/input</td>
<td></td>
</tr>
<tr>
<td>type</td>
- <td>//div[@id='UITabPaneDashboard']/div/div/div/div/div/div[2]/div/div/div/div/input</td>
+ <td>//div[@id='UITabPaneDashboard']/div[2]/input</td>
<td>Test_SNF_PRL_52_edit</td>
</tr>
<tr>
<td>keyPress</td>
- <td>//div[@id='UITabPaneDashboard']/div/div/div/div/div/div[2]/div/div/div/div/input</td>
+ <td>//div[@id='UITabPaneDashboard']/div[2]/input</td>
<td>\13</td>
</tr>
<tr>
@@ -152,18 +142,23 @@
<td></td>
</tr>
<tr>
+ <td>waitForElementPresent</td>
+ <td>//div[@id='UITabPaneDashboard']/div[2]/a</td>
+ <td></td>
+</tr>
+<tr>
<td>echo</td>
<td>-- Delete tab--</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
- <td>//div[@id='UITabPaneDashboard']/div/div/div/div/div/div[2]/div/div/div/div/a/img</td>
+ <td>//div[@id='UITabPaneDashboard']/div[2]/a</td>
<td></td>
</tr>
<tr>
<td>click</td>
- <td>//div[@id='UITabPaneDashboard']/div/div/div/div/div/div[2]/div/div/div/div/a/img</td>
+ <td>//div[@id='UITabPaneDashboard']/div[2]/a</td>
<td></td>
</tr>
<tr>
@@ -173,7 +168,7 @@
</tr>
<tr>
<td>assertConfirmation</td>
- <td>Really want to remove this dashboard?</td>
+ <td>Are you sure you want to remove this dashboard?</td>
<td></td>
</tr>
<tr>
Modified: portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_SNF_PRL_53_DragAndDropGadget.html
===================================================================
--- portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_SNF_PRL_53_DragAndDropGadget.html 2011-07-26 21:14:24 UTC (rev 6934)
+++ portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_SNF_PRL_53_DragAndDropGadget.html 2011-07-27 11:04:44 UTC (rev 6935)
@@ -48,7 +48,7 @@
</tr>
<tr>
<td>clickAndWait</td>
- <td>xpath=//div[@id='UIPortalLoginFormAction']/div/div/div/a</td>
+ <td>//a[@id='UIPortalLoginFormAction']</td>
<td></td>
</tr>
<tr>
Modified: portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_SNF_PRL_63_ManagePageOfUser.html
===================================================================
--- portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_SNF_PRL_63_ManagePageOfUser.html 2011-07-26 21:14:24 UTC (rev 6934)
+++ portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_SNF_PRL_63_ManagePageOfUser.html 2011-07-27 11:04:44 UTC (rev 6935)
@@ -58,7 +58,7 @@
</tr>
<tr>
<td>clickAndWait</td>
- <td>link=Page Management</td>
+ <td>link=Pages Manager</td>
<td></td>
</tr>
<tr>
Modified: portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_SNF_PRL_67_ChangePassword.html
===================================================================
--- portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_SNF_PRL_67_ChangePassword.html 2011-07-26 21:14:24 UTC (rev 6934)
+++ portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_SNF_PRL_67_ChangePassword.html 2011-07-27 11:04:44 UTC (rev 6935)
@@ -373,7 +373,7 @@
</tr>
<tr>
<td>clickAndWait</td>
- <td>link=Users and groups management</td>
+ <td>link=Users and Groups Manager</td>
<td></td>
</tr>
<tr>
13 years, 5 months
gatein SVN: r6934 - in portal/branches/gatein-management: component/management and 31 other directories.
by do-not-reply@jboss.org
Author: nscavell
Date: 2011-07-26 17:14:24 -0400 (Tue, 26 Jul 2011)
New Revision: 6934
Added:
portal/branches/gatein-management/component/management/src/main/java/org/gatein/
portal/branches/gatein-management/component/management/src/main/java/org/gatein/management/
portal/branches/gatein-management/component/management/src/main/java/org/gatein/management/runtime/
portal/branches/gatein-management/component/management/src/main/java/org/gatein/management/runtime/ManagementBootstrap.java
portal/branches/gatein-management/component/management/src/main/java/org/gatein/management/runtime/RuntimeContextImpl.java
portal/branches/gatein-management/component/management/src/main/resources/conf/
portal/branches/gatein-management/component/management/src/main/resources/conf/portal/
portal/branches/gatein-management/component/management/src/main/resources/conf/portal/configuration.xml
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/MopManagementExtension.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/MopBindingProvider.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/AbstractMarshaller.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/DelimitedValueType.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/Element.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/Namespace.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/NavigationMarshaller.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/PageMarshaller.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/SiteLayoutMarshaller.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/Utils.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/AbstractExportTask.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/AbstractImportTask.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/ImportStrategy.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/ImportTask.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/NavigationExportTask.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/NavigationImportTask.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/POMSessionExportTask.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/PageExportTask.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/PageImportTask.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/SiteLayoutExportTask.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/SiteLayoutImportTask.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/model/
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/model/PageDataContainer.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/AbstractMopOperationHandler.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/MopImportResource.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/MopReadResource.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/Utils.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/AbstractNavigationOperationHandler.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationExportResource.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationKey.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationReadResource.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/PageNavigationUtils.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/PathScope.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/AbstractPageOperationHandler.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/AbstractPageQueryOperation.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageExportResource.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageKey.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageReadResource.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageUpdateResource.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PagesReadResource.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PagesUpdateResource.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/AbstractSiteOperationHandler.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteLayoutExportResource.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteLayoutReadResource.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteReadResource.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteTypeReadResource.java
portal/branches/gatein-management/component/portal/src/main/resources/META-INF/services/org.gatein.management.spi.ManagementExtension
portal/branches/gatein-management/component/portal/src/test/java/org/exoplatform/portal/mop/management/
portal/branches/gatein-management/component/portal/src/test/java/org/exoplatform/portal/mop/management/binding/
portal/branches/gatein-management/component/portal/src/test/java/org/exoplatform/portal/mop/management/binding/xml/
portal/branches/gatein-management/component/portal/src/test/java/org/exoplatform/portal/mop/management/binding/xml/AbstractMarshallerTest.java
portal/branches/gatein-management/component/portal/src/test/java/org/exoplatform/portal/mop/management/binding/xml/NavigationMarshallerTest.java
portal/branches/gatein-management/component/portal/src/test/java/org/exoplatform/portal/mop/management/binding/xml/PageMarshallerTest.java
portal/branches/gatein-management/component/portal/src/test/java/org/exoplatform/portal/mop/management/binding/xml/SiteLayoutMarshallerTest.java
portal/branches/gatein-management/component/portal/src/test/java/org/exoplatform/portal/mop/management/exportimport/
portal/branches/gatein-management/component/portal/src/test/java/org/exoplatform/portal/mop/management/exportimport/PageImportTaskTest.java
portal/branches/gatein-management/component/portal/src/test/resources/org/exoplatform/portal/mop/management/
portal/branches/gatein-management/component/portal/src/test/resources/org/exoplatform/portal/mop/management/navigation-empty.xml
portal/branches/gatein-management/component/portal/src/test/resources/org/exoplatform/portal/mop/management/navigation-extended.xml
portal/branches/gatein-management/component/portal/src/test/resources/org/exoplatform/portal/mop/management/navigation-fragment.xml
portal/branches/gatein-management/component/portal/src/test/resources/org/exoplatform/portal/mop/management/navigation.xml
portal/branches/gatein-management/component/portal/src/test/resources/org/exoplatform/portal/mop/management/pages-empty.xml
portal/branches/gatein-management/component/portal/src/test/resources/org/exoplatform/portal/mop/management/pages-homepage.xml
portal/branches/gatein-management/component/portal/src/test/resources/org/exoplatform/portal/mop/management/pages-loaded.xml
portal/branches/gatein-management/component/portal/src/test/resources/org/exoplatform/portal/mop/management/portal.xml
Modified:
portal/branches/gatein-management/component/management/pom.xml
portal/branches/gatein-management/component/portal/pom.xml
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/config/DataStorage.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/config/DataStorageImpl.java
portal/branches/gatein-management/packaging/jboss-as5/pkg/pom.xml
portal/branches/gatein-management/packaging/jboss-as6/pkg/pom.xml
portal/branches/gatein-management/packaging/jetty/pkg/pom.xml
portal/branches/gatein-management/packaging/tomcat/pkg/pom.xml
portal/branches/gatein-management/pom.xml
Log:
Initial support for mop management extension.
Modified: portal/branches/gatein-management/component/management/pom.xml
===================================================================
--- portal/branches/gatein-management/component/management/pom.xml 2011-07-26 17:06:24 UTC (rev 6933)
+++ portal/branches/gatein-management/component/management/pom.xml 2011-07-26 21:14:24 UTC (rev 6934)
@@ -43,6 +43,13 @@
<groupId>org.exoplatform.ws</groupId>
<artifactId>exo.ws.rest.core</artifactId>
</dependency>
-
+ <dependency>
+ <groupId>org.gatein.management</groupId>
+ <artifactId>gatein-management-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.gatein.management</groupId>
+ <artifactId>gatein-management-rest</artifactId>
+ </dependency>
</dependencies>
</project>
Added: portal/branches/gatein-management/component/management/src/main/java/org/gatein/management/runtime/ManagementBootstrap.java
===================================================================
--- portal/branches/gatein-management/component/management/src/main/java/org/gatein/management/runtime/ManagementBootstrap.java (rev 0)
+++ portal/branches/gatein-management/component/management/src/main/java/org/gatein/management/runtime/ManagementBootstrap.java 2011-07-26 21:14:24 UTC (rev 6934)
@@ -0,0 +1,30 @@
+package org.gatein.management.runtime;
+
+import org.gatein.management.api.ManagementService;
+import org.picocontainer.Startable;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class ManagementBootstrap implements Startable
+{
+ private ManagementService service;
+
+ public ManagementBootstrap(ManagementService service)
+ {
+ this.service = service;
+ }
+
+ @Override
+ public void start()
+ {
+ service.load();
+ }
+
+ @Override
+ public void stop()
+ {
+ service.unload();
+ }
+}
Added: portal/branches/gatein-management/component/management/src/main/java/org/gatein/management/runtime/RuntimeContextImpl.java
===================================================================
--- portal/branches/gatein-management/component/management/src/main/java/org/gatein/management/runtime/RuntimeContextImpl.java (rev 0)
+++ portal/branches/gatein-management/component/management/src/main/java/org/gatein/management/runtime/RuntimeContextImpl.java 2011-07-26 21:14:24 UTC (rev 6934)
@@ -0,0 +1,17 @@
+package org.gatein.management.runtime;
+
+import org.exoplatform.container.PortalContainer;
+import org.gatein.management.api.RuntimeContext;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class RuntimeContextImpl implements RuntimeContext
+{
+ @Override
+ public <T> T getRuntimeComponent(Class<T> componentClass)
+ {
+ return componentClass.cast(PortalContainer.getInstance().getComponentInstanceOfType(componentClass));
+ }
+}
Added: portal/branches/gatein-management/component/management/src/main/resources/conf/portal/configuration.xml
===================================================================
--- portal/branches/gatein-management/component/management/src/main/resources/conf/portal/configuration.xml (rev 0)
+++ portal/branches/gatein-management/component/management/src/main/resources/conf/portal/configuration.xml 2011-07-26 21:14:24 UTC (rev 6934)
@@ -0,0 +1,50 @@
+<!--
+ ~ JBoss, Home of Professional Open Source.
+ ~ Copyright 2011, Red Hat, Inc., and individual contributors
+ ~ as indicated by the @author tags. See the copyright.txt file 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_0.xsd http://www.exoplaform.org/xml/ns/kernel_1_0.xsd"
+ xmlns="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd">
+
+ <component>
+ <key>org.gatein.management.api.ManagementService</key>
+ <type>org.gatein.management.core.api.ManagementServiceImpl</type>
+ </component>
+
+ <component>
+ <key>org.gatein.management.api.controller.ManagementController</key>
+ <type>org.gatein.management.core.api.controller.SimpleManagementController</type>
+ </component>
+
+ <component>
+ <type>org.gatein.management.rest.RestApplication</type>
+ </component>
+
+ <component>
+ <type>org.gatein.management.runtime.RuntimeContextImpl</type>
+ </component>
+
+ <component>
+ <type>org.gatein.management.runtime.ManagementBootstrap</type>
+ </component>
+
+</configuration>
\ No newline at end of file
Modified: portal/branches/gatein-management/component/portal/pom.xml
===================================================================
--- portal/branches/gatein-management/component/portal/pom.xml 2011-07-26 17:06:24 UTC (rev 6933)
+++ portal/branches/gatein-management/component/portal/pom.xml 2011-07-26 21:14:24 UTC (rev 6934)
@@ -74,6 +74,16 @@
</dependency>
<dependency>
+ <groupId>org.gatein.management</groupId>
+ <artifactId>gatein-management-spi</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.gatein.management</groupId>
+ <artifactId>gatein-management-common</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>org.picketlink.idm</groupId>
<artifactId>picketlink-idm-core</artifactId>
</dependency>
@@ -114,6 +124,13 @@
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <version>1.8.5</version>
+ <scope>test</scope>
+ </dependency>
+
</dependencies>
<build>
Modified: portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/config/DataStorage.java
===================================================================
--- portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/config/DataStorage.java 2011-07-26 17:06:24 UTC (rev 6933)
+++ portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/config/DataStorage.java 2011-07-26 21:14:24 UTC (rev 6934)
@@ -217,6 +217,8 @@
*/
public void saveDashboard(Dashboard dashboard) throws Exception;
+ public void save() throws Exception;
+
/**
* Returns the list of all portal names.
*
Modified: portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/config/DataStorageImpl.java
===================================================================
--- portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/config/DataStorageImpl.java 2011-07-26 17:06:24 UTC (rev 6933)
+++ portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/config/DataStorageImpl.java 2011-07-26 21:14:24 UTC (rev 6934)
@@ -285,6 +285,11 @@
delegate.save(portletPreferences);
}
+ public void save() throws Exception
+ {
+ delegate.save();
+ }
+
public PortalConfig getPortalConfig(String ownerType, String portalName) throws Exception
{
PortalKey key = new PortalKey(ownerType, portalName);
Added: portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/MopManagementExtension.java
===================================================================
--- portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/MopManagementExtension.java (rev 0)
+++ portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/MopManagementExtension.java 2011-07-26 21:14:24 UTC (rev 6934)
@@ -0,0 +1,112 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.exoplatform.portal.mop.management;
+
+import org.exoplatform.portal.mop.management.binding.MopBindingProvider;
+import org.exoplatform.portal.mop.management.operations.MopImportResource;
+import org.exoplatform.portal.mop.management.operations.MopReadResource;
+import org.exoplatform.portal.mop.management.operations.navigation.NavigationExportResource;
+import org.exoplatform.portal.mop.management.operations.navigation.NavigationReadResource;
+import org.exoplatform.portal.mop.management.operations.page.PageExportResource;
+import org.exoplatform.portal.mop.management.operations.page.PageReadResource;
+import org.exoplatform.portal.mop.management.operations.page.PagesReadResource;
+import org.exoplatform.portal.mop.management.operations.site.SiteLayoutExportResource;
+import org.exoplatform.portal.mop.management.operations.site.SiteLayoutReadResource;
+import org.exoplatform.portal.mop.management.operations.site.SiteReadResource;
+import org.exoplatform.portal.mop.management.operations.site.SiteTypeReadResource;
+import org.gatein.management.api.ComponentRegistration;
+import org.gatein.management.api.ManagedDescription;
+import org.gatein.management.api.ManagedResource;
+import org.gatein.management.api.operation.OperationNames;
+import org.gatein.management.spi.ExtensionContext;
+import org.gatein.management.spi.ManagementExtension;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class MopManagementExtension implements ManagementExtension
+{
+ @Override
+ public void initialize(ExtensionContext context)
+ {
+ ComponentRegistration registration = context.registerManagedComponent("mop");
+ registration.registerBindingProvider(MopBindingProvider.INSTANCE);
+
+ ManagedResource.Registration mop = registration.registerManagedResource(description("MOP (Model Object for Portal) Managed Resource"));
+ mop.registerOperationHandler("import-resource", new MopImportResource(), description("Imports mop data from an exported zip file."), true);
+
+ mop.registerOperationHandler(OperationNames.READ_RESOURCE, new MopReadResource(), description("Lists the available site types for a portal."));
+
+ ManagedResource.Registration sitetypes = mop.registerSubResource("{site-type}sites", description("Management resource responsible for handling management operations on a specific site type for a portal."));
+ sitetypes.registerOperationHandler(OperationNames.READ_RESOURCE, new SiteTypeReadResource(), description("Lists the available sites for a site type."));
+
+ //TODO: Would be nice to find acceptable regex for site name, nav uri, page name
+ ManagedResource.Registration sites = sitetypes.registerSubResource("{site-name: .*}", description("Management resource responsible for handling management operations on a specific site."));
+ sites.registerOperationHandler(OperationNames.READ_RESOURCE, new SiteReadResource(), description("Lists all available artifacts for a given site (ie pages, navigation, site layout)"));
+
+ // Site layout management and operation registration
+ ManagedResource.Registration siteLayout = sites.registerSubResource("portal", description("Management resource responsible for handling management operations for a site layout."));
+ siteLayout.registerOperationHandler(OperationNames.READ_RESOURCE, new SiteLayoutReadResource(), description("Retrieves site layout data for a specific site."));
+ siteLayout.registerOperationHandler(OperationNames.EXPORT_RESOURCE, new SiteLayoutExportResource(), description("Exports a site layout as a zip file."));
+
+ // Page management and operation registration
+ PageExportResource pageExport = new PageExportResource();
+ PageReadResource pageReadResource = new PageReadResource();
+ ManagedResource.Registration pages = sites.registerSubResource("pages", description("Management resource responsible for handling management operations on all pages of a site."));
+ pages.registerOperationHandler(OperationNames.READ_RESOURCE, new PagesReadResource(), description("Lists all available pages available for a site."));
+ pages.registerOperationHandler(OperationNames.EXPORT_RESOURCE, pageExport, description("Exports all pages for a site as a zip file."));
+
+ ManagedResource.Registration page = pages.registerSubResource("{page-name}", description("Page management resource representing an individual page."));
+ page.registerOperationHandler(OperationNames.READ_RESOURCE, new PageReadResource(), description("Retrieves page data for a specific site."));
+ page.registerOperationHandler(OperationNames.EXPORT_RESOURCE, pageExport, description("Exports a page as a zip file."));
+
+ // Navigation management and operation registration
+ NavigationReadResource navReadResource = new NavigationReadResource();
+ NavigationExportResource navExport = new NavigationExportResource();
+ ManagedResource.Registration navigation = sites.registerSubResource("navigation", description("Navigation management resource representing a sites navigation."));
+ navigation.registerOperationHandler(OperationNames.READ_RESOURCE, navReadResource, description("Retrieves navigation for a specific site."));
+ navigation.registerOperationHandler(OperationNames.EXPORT_RESOURCE, navExport, description("Exports navigation as a zip file."));
+
+ ManagedResource.Registration navigationNode = navigation.registerSubResource("{nav-uri: .*}", description("Navigation node management resource representing a sites navigation."));
+ navigationNode.registerOperationHandler(OperationNames.READ_RESOURCE, navReadResource, description("Retrieves navigation node for a specific site."));
+ navigationNode.registerOperationHandler(OperationNames.EXPORT_RESOURCE, navExport, description("Exports navigation as a zip file."));
+ }
+
+ @Override
+ public void destroy()
+ {
+ }
+
+ private static ManagedDescription description(final String description)
+ {
+ return new ManagedDescription()
+ {
+ @Override
+ public String getDescription()
+ {
+ return description;
+ }
+ };
+ }
+}
Added: portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/MopBindingProvider.java
===================================================================
--- portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/MopBindingProvider.java (rev 0)
+++ portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/MopBindingProvider.java 2011-07-26 21:14:24 UTC (rev 6934)
@@ -0,0 +1,123 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.exoplatform.portal.mop.management.binding;
+
+import org.exoplatform.portal.config.model.Page;
+import org.exoplatform.portal.config.model.PageNavigation;
+import org.exoplatform.portal.config.model.PortalConfig;
+import org.exoplatform.portal.mop.management.binding.xml.NavigationMarshaller;
+import org.exoplatform.portal.mop.management.binding.xml.PageMarshaller;
+import org.exoplatform.portal.mop.management.binding.xml.SiteLayoutMarshaller;
+import org.exoplatform.portal.pom.data.PortalData;
+import org.gatein.management.api.ContentType;
+import org.gatein.management.api.binding.BindingException;
+import org.gatein.management.api.binding.BindingProvider;
+import org.gatein.management.api.binding.Marshaller;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class MopBindingProvider implements BindingProvider
+{
+ public static final MopBindingProvider INSTANCE = new MopBindingProvider();
+
+ private MopBindingProvider(){}
+
+ @Override
+ public <T> Marshaller<T> getMarshaller(Class<T> type, ContentType contentType) throws BindingException
+ {
+ switch (contentType)
+ {
+ case XML:
+ return getXmlMarshaller(type);
+ case JSON:
+ case ZIP:
+ default:
+ return null;
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private <T> Marshaller<T> getXmlMarshaller(Class<T> type)
+ {
+ if (Page.class.isAssignableFrom(type))
+ {
+ return (Marshaller<T>) XmlMarshallers.page_marshaller;
+ }
+ else if (Page.PageSet.class.isAssignableFrom(type))
+ {
+ return (Marshaller<T>) XmlMarshallers.pages_marshaller;
+ }
+ else if (PageNavigation.class.isAssignableFrom(type))
+ {
+ return (Marshaller<T>) XmlMarshallers.navigation_marshaller;
+ }
+ else if (PortalConfig.class.isAssignableFrom(type))
+ {
+ return (Marshaller<T>) XmlMarshallers.site_marshaller;
+ }
+
+ return null;
+ }
+
+ private static class XmlMarshallers
+ {
+
+ //------------------------------------ Page Marshallers ------------------------------------//
+ private static Marshaller<Page.PageSet> pages_marshaller = new PageMarshaller();
+
+ private static Marshaller<Page> page_marshaller = new Marshaller<Page>()
+ {
+ @Override
+ public void marshal(Page page, OutputStream outputStream) throws BindingException
+ {
+ Page.PageSet pages = new Page.PageSet();
+ pages.setPages(new ArrayList<Page>(1));
+ pages.getPages().add(page);
+
+ XmlMarshallers.pages_marshaller.marshal(pages, outputStream);
+ }
+
+ @Override
+ public Page unmarshal(InputStream inputStream) throws BindingException
+ {
+ Page.PageSet pages = pages_marshaller.unmarshal(inputStream);
+
+ if (pages.getPages().isEmpty()) throw new BindingException("No page was unmarshalled.");
+
+ if (pages.getPages().size() != 1) throw new BindingException("Multiple pages found.");
+
+ return pages.getPages().get(0);
+ }
+ };
+
+ private static Marshaller<PageNavigation> navigation_marshaller = new NavigationMarshaller();
+
+ private static Marshaller<PortalConfig> site_marshaller = new SiteLayoutMarshaller();
+ }
+}
Added: portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/AbstractMarshaller.java
===================================================================
--- portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/AbstractMarshaller.java (rev 0)
+++ portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/AbstractMarshaller.java 2011-07-26 21:14:24 UTC (rev 6934)
@@ -0,0 +1,668 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.exoplatform.portal.mop.management.binding.xml;
+
+import org.exoplatform.container.ExoContainer;
+import org.exoplatform.container.ExoContainerContext;
+import org.exoplatform.container.PortalContainer;
+import org.exoplatform.portal.config.DataStorage;
+import org.exoplatform.portal.config.model.Application;
+import org.exoplatform.portal.config.model.ApplicationState;
+import org.exoplatform.portal.config.model.ApplicationType;
+import org.exoplatform.portal.config.model.Container;
+import org.exoplatform.portal.config.model.ModelObject;
+import org.exoplatform.portal.config.model.Page;
+import org.exoplatform.portal.config.model.PageBody;
+import org.exoplatform.portal.config.model.TransientApplicationState;
+import org.exoplatform.portal.pom.data.ComponentData;
+import org.exoplatform.portal.pom.data.ContainerData;
+import org.exoplatform.portal.pom.data.ModelDataStorage;
+import org.exoplatform.portal.pom.spi.gadget.Gadget;
+import org.exoplatform.portal.pom.spi.portlet.Portlet;
+import org.exoplatform.portal.pom.spi.portlet.PortletBuilder;
+import org.exoplatform.portal.pom.spi.portlet.Preference;
+import org.gatein.common.xml.stax.writer.StaxWriter;
+import org.gatein.common.xml.stax.writer.WritableValueTypes;
+import org.gatein.management.api.binding.Marshaller;
+import org.staxnav.StaxNavigator;
+import org.staxnav.ValueType;
+
+import javax.xml.stream.XMLStreamException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import static org.gatein.common.xml.stax.navigator.Exceptions.*;
+import static org.gatein.common.xml.stax.navigator.StaxNavUtils.*;
+import static org.gatein.common.xml.stax.writer.StaxWriterUtils.*;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public abstract class AbstractMarshaller<T> implements Marshaller<T>
+{
+ protected void marshalModelObject(StaxWriter<Element> writer, ModelObject modelObject) throws XMLStreamException
+ {
+ if (modelObject instanceof Application)
+ {
+ Application application = (Application) modelObject;
+ ApplicationType type = application.getType();
+ if (ApplicationType.PORTLET == type)
+ {
+ marshalPortletApplication(writer, safeCast(application, Portlet.class));
+ }
+ else if (ApplicationType.GADGET == type)
+ {
+ marshalGadgetApplication(writer, safeCast(application, Gadget.class));
+ }
+ else if (ApplicationType.WSRP_PORTLET == type)
+ {
+ throw new XMLStreamException("WSRP portlet marshalling not supported.");
+ }
+ }
+ else if (modelObject instanceof Page)
+ {
+ //marshalPageData(writer, (PageData) componentData);
+ throw new XMLStreamException("Unexpected PageData object. Storage id: " + modelObject.getStorageId());
+ }
+ else if (modelObject instanceof Container)
+ {
+ marshalContainer(writer, (Container) modelObject);
+ }
+ else if (modelObject instanceof PageBody)
+ {
+ writer.writeStartElement(Element.PAGE_BODY).writeEndElement();
+ }
+ else
+ {
+ throw new XMLStreamException("Unknown ComponentData type " + modelObject);
+ }
+ }
+
+ protected void marshalContainer(StaxWriter<Element> writer, Container container) throws XMLStreamException
+ {
+ writer.writeStartElement(Element.CONTAINER);
+
+ writeOptionalAttribute(writer, Attribute.ID, container.getId());
+ writeOptionalAttribute(writer, Attribute.TEMPLATE, container.getTemplate());
+ writeOptionalAttribute(writer, Attribute.WIDTH, container.getWidth());
+ writeOptionalAttribute(writer, Attribute.HEIGHT, container.getHeight());
+
+ writeOptionalElement(writer, Element.NAME, container.getName());
+ writeOptionalElement(writer, Element.TITLE, container.getTitle());
+ writeOptionalElement(writer, Element.ICON, container.getIcon());
+ writeOptionalElement(writer, Element.DESCRIPTION, container.getDescription());
+
+ marshalAccessPermissions(writer, container.getAccessPermissions());
+
+ writeOptionalElement(writer, Element.FACTORY_ID, container.getFactoryId());
+
+ List<ModelObject> children = container.getChildren();
+ for (ModelObject child : children)
+ {
+ marshalModelObject(writer, child);
+ }
+
+ writer.writeEndElement(); // End of container element
+ }
+
+ protected Container unmarshalContainer(StaxNavigator<Element> navigator) throws XMLStreamException
+ {
+ Container container = new Container();
+ container.setId(navigator.getAttribute(Attribute.ID.getLocalName()));
+ container.setTemplate(navigator.getAttribute(Attribute.TEMPLATE.getLocalName()));
+ container.setWidth(navigator.getAttribute(Attribute.WIDTH.getLocalName()));
+ container.setHeight(navigator.getAttribute(Attribute.HEIGHT.getLocalName()));
+
+ Element current = navigator.child();
+ while (current != null)
+ {
+ switch (current)
+ {
+ case NAME:
+ container.setName(navigator.getContent());
+ current = navigator.sibling();
+ break;
+ case TITLE:
+ container.setTitle(navigator.getContent());
+ current = navigator.sibling();
+ break;
+ case ICON:
+ container.setIcon(navigator.getContent());
+ current = navigator.sibling();
+ break;
+ case DESCRIPTION:
+ container.setDescription(navigator.getContent());
+ current = navigator.sibling();
+ break;
+ case ACCESS_PERMISSIONS:
+ container.setAccessPermissions(unmarshalAccessPermissions(navigator, false));
+ current = navigator.sibling();
+ break;
+ case FACTORY_ID:
+ container.setFactoryId(navigator.getContent());
+ current = navigator.sibling();
+ break;
+ case CONTAINER:
+ if (container.getChildren() == null)
+ {
+ container.setChildren(new ArrayList<ModelObject>());
+ }
+ container.getChildren().add(unmarshalContainer(navigator.fork()));
+ current = navigator.getName();
+ break;
+ case PORTLET_APPLICATION:
+ if (container.getChildren() == null)
+ {
+ container.setChildren(new ArrayList<ModelObject>());
+ }
+ container.getChildren().add(unmarshalPortletApplication(navigator.fork()));
+ current = navigator.getName();
+ break;
+ case GADGET_APPLICATION:
+ if (container.getChildren() == null)
+ {
+ container.setChildren(new ArrayList<ModelObject>());
+ }
+ container.getChildren().add(unmarshalGadgetApplication(navigator.fork()));
+ current = navigator.getName();
+ break;
+ case UNKNOWN:
+ throw unknownElement(navigator);
+ default:
+ throw unexpectedElement(navigator);
+ }
+ }
+
+ return container;
+ }
+
+ protected void marshalPortletApplication(StaxWriter<Element> writer, Application<Portlet> portletApplication) throws XMLStreamException
+ {
+ writer.writeStartElement(Element.PORTLET_APPLICATION).writeStartElement(Element.PORTLET);
+
+ // Marshal ApplicationState
+ ApplicationState<Portlet> state = portletApplication.getState();
+
+ // Marshal application state
+ String contentId;
+ Portlet portlet;
+ // If transient we have all the information we need
+ if (state instanceof TransientApplicationState)
+ {
+ TransientApplicationState<Portlet> transientApplicationState = (TransientApplicationState<Portlet>) state;
+ contentId = transientApplicationState.getContentId();
+ portlet = transientApplicationState.getContentState();
+ }
+ else
+ {
+ // The only way to retrieve the information if the state is not transient is if we're within the portal context
+ ExoContainer container = ExoContainerContext.getCurrentContainer();
+ if (container instanceof PortalContainer)
+ {
+ DataStorage dataStorage = (DataStorage) container.getComponentInstanceOfType(DataStorage.class);
+ try
+ {
+ portlet = dataStorage.load(state, ApplicationType.PORTLET);
+ }
+ catch (Exception e)
+ {
+ throw new XMLStreamException("Could not obtain portlet state.");
+ }
+
+ try
+ {
+ contentId = dataStorage.getId(state);
+ }
+ catch (Exception e)
+ {
+ throw new XMLStreamException("Could not obtain contentId.", e);
+ }
+ }
+ else
+ {
+ throw new XMLStreamException("Cannot marshal application state " + state + " outside the context of the portal.");
+ }
+ }
+
+ // Marshal portlet application id
+ if (contentId == null) throw new XMLStreamException("Portlet application ID was null.");
+ writer.writeElement(Element.APPLICATION_REF, contentId.substring(0, contentId.indexOf("/")));
+ writer.writeElement(Element.PORTLET_REF, contentId.substring(contentId.indexOf("/") + 1, contentId.length()));
+
+ // Marshal preferences
+ if (portlet != null)
+ {
+ boolean prefsWritten = false;
+ for (Preference preference : portlet)
+ {
+ if (!prefsWritten)
+ {
+ writer.writeStartElement(Element.PREFERENCES);
+ prefsWritten = true;
+ }
+
+ writer.writeStartElement(Element.PREFERENCE);
+ writer.writeElement(Element.NAME, preference.getName());
+ for (String value : preference.getValues())
+ {
+ writeOptionalContent(writer, Element.PREFERENCE_VALUE, value);
+ }
+ writer.writeElement(Element.PREFERENCE_READONLY, WritableValueTypes.BOOLEAN, preference.isReadOnly());
+ writer.writeEndElement(); // End of preference
+ }
+ if (prefsWritten)
+ {
+ writer.writeEndElement(); // End of preferences
+ }
+ }
+ writer.writeEndElement(); // End of portlet
+
+ marshalApplication(writer, portletApplication);
+
+ writer.writeEndElement(); // End of portlet-application
+ }
+
+ protected Application<Portlet> unmarshalPortletApplication(StaxNavigator<Element> navigator) throws XMLStreamException
+ {
+ requiresChild(navigator, Element.PORTLET);
+ ApplicationState<Portlet> state = unmarshalPortletApplicationState(navigator.fork());
+
+ Application<Portlet> portlet = new Application<Portlet>(ApplicationType.PORTLET);
+ portlet.setState(state);
+
+ boolean showInfoBarParsed = false;
+
+ Element current = navigator.getName();
+ while (current != null)
+ {
+ switch (current)
+ {
+ case THEME:
+ portlet.setTheme(navigator.getContent());
+ current = navigator.sibling();
+ break;
+ case TITLE:
+ portlet.setTitle(navigator.getContent());
+ current = navigator.sibling();
+ break;
+ case ACCESS_PERMISSIONS:
+ portlet.setAccessPermissions(unmarshalAccessPermissions(navigator, true));
+ current = navigator.sibling();
+ break;
+ case SHOW_INFO_BAR:
+ portlet.setShowInfoBar(parseRequiredContent(navigator, ValueType.BOOLEAN));
+ showInfoBarParsed = true;
+ current = navigator.sibling();
+ break;
+ case SHOW_APPLICATION_STATE:
+ portlet.setShowApplicationState(navigator.parseContent(ValueType.BOOLEAN));
+ current = navigator.sibling();
+ break;
+ case SHOW_APPLICATION_MODE:
+ portlet.setShowApplicationMode(navigator.parseContent(ValueType.BOOLEAN));
+ current = navigator.sibling();
+ break;
+ case DESCRIPTION:
+ portlet.setDescription(navigator.getContent());
+ current = navigator.sibling();
+ break;
+ case ICON:
+ portlet.setIcon(navigator.getContent());
+ current = navigator.sibling();
+ break;
+ case WIDTH:
+ portlet.setWidth(navigator.getContent());
+ current = navigator.sibling();
+ break;
+ case HEIGHT:
+ portlet.setHeight(navigator.getContent());
+ current = navigator.sibling();
+ break;
+ case UNKNOWN:
+ throw unknownElement(navigator);
+ default:
+ throw unexpectedElement(navigator);
+ }
+ }
+
+ //TODO: We should raise this exception as soon as we know so location is accurate
+ if (portlet.getAccessPermissions() == null) throw expectedElement(navigator, Element.ACCESS_PERMISSIONS);
+ if (!showInfoBarParsed) throw expectedElement(navigator, Element.SHOW_INFO_BAR);
+
+ return portlet;
+ }
+
+ private ApplicationState<Portlet> unmarshalPortletApplicationState(StaxNavigator<Element> navigator) throws XMLStreamException
+ {
+ // Application name
+ requiresChild(navigator, Element.APPLICATION_REF);
+ String applicationRef = getRequiredContent(navigator, true);
+
+ // Portlet name
+ requiresSibling(navigator, Element.PORTLET_REF);
+ String portletRef = getRequiredContent(navigator, true);
+
+ // Preferences
+ PortletBuilder portletBuilder = null;
+ if (navigator.sibling() == Element.PREFERENCES)
+ {
+ requiresChild(navigator, Element.PREFERENCE);
+ portletBuilder = new PortletBuilder();
+ for (StaxNavigator<Element> fork : navigator.fork(Element.PREFERENCE))
+ {
+ // Preference name
+ requiresChild(fork, Element.NAME);
+ String prefName = getRequiredContent(fork, false);
+
+ // Preference values
+ List<String> values = null;
+ while (fork.sibling() == Element.PREFERENCE_VALUE)
+ {
+ if (values == null) values = new ArrayList<String>();
+ values.add(getContent(fork, false));
+ }
+ if (values == null)
+ {
+ values = Collections.singletonList(null);
+ }
+
+ // Preference readonly
+ Boolean readOnly = null;
+ if (fork.getName() == Element.PREFERENCE_READONLY)
+ {
+ readOnly = parseRequiredContent(fork, ValueType.BOOLEAN);
+ }
+
+ // Ensure nothing is left.
+ if (fork.next() != null)
+ {
+ throw unexpectedElement(fork);
+ }
+
+ if (readOnly == null)
+ {
+ portletBuilder.add(prefName, values);
+ }
+ else
+ {
+ portletBuilder.add(prefName, values, readOnly);
+ }
+ }
+ }
+
+ TransientApplicationState<Portlet> state = new TransientApplicationState<Portlet>(applicationRef + "/" + portletRef);
+ if (portletBuilder != null)
+ {
+ state.setContentState(portletBuilder.build());
+ }
+
+ return state;
+ }
+
+ protected void marshalGadgetApplication(StaxWriter<Element> writer, Application<Gadget> gadgetApplication) throws XMLStreamException
+ {
+ writer.writeStartElement(Element.GADGET_APPLICATION).writeStartElement(Element.GADGET);
+
+ // Marshal ApplicationState
+ ApplicationState<Gadget> state = gadgetApplication.getState();
+
+ // Marshal application state
+ String contentId;
+ Gadget gadget;
+ // If transient we have all the information we need
+ if (state instanceof TransientApplicationState)
+ {
+ TransientApplicationState<Gadget> transientApplicationState = (TransientApplicationState<Gadget>) state;
+ contentId = transientApplicationState.getContentId();
+ gadget = transientApplicationState.getContentState();
+ }
+ else
+ {
+ // The only way to retrieve the information if the state is not transient is if we're within a portal context
+ ExoContainer container = ExoContainerContext.getCurrentContainer();
+ if (container instanceof PortalContainer)
+ {
+ ModelDataStorage dataStorage = (ModelDataStorage) container.getComponentInstanceOfType(ModelDataStorage.class);
+ try
+ {
+ gadget = dataStorage.load(state, ApplicationType.GADGET);
+ }
+ catch (Exception e)
+ {
+ throw new XMLStreamException("Could not obtain gadget state from custom context.");
+ }
+
+ try
+ {
+ contentId = dataStorage.getId(state);
+ }
+ catch (Exception e)
+ {
+ throw new XMLStreamException("Could not obtain contentId from custom context.", e);
+ }
+ }
+ else
+ {
+ throw new XMLStreamException("Cannot marshal application state " + state + " outside the context of the portal.");
+ }
+ }
+
+ // Marshal portlet application id
+ if (contentId == null) throw new XMLStreamException("Gadget content ID was null.");
+ writer.writeElement(Element.GADGET_REF, contentId);
+
+ // Marshal preferences
+ if (gadget != null)
+ {
+ //TODO: When user-prefs are supported, uncomment
+ //writer.writeOptionalElement(Element.PREFERENCES, gadget.getUserPref());
+ }
+ writer.writeEndElement(); // End of portlet
+
+ marshalApplication(writer, gadgetApplication);
+
+
+ writer.writeEndElement(); // End of gadget-application
+ }
+
+ protected Application<Gadget> unmarshalGadgetApplication(StaxNavigator<Element> navigator) throws XMLStreamException
+ {
+ requiresChild(navigator, Element.GADGET);
+ ApplicationState<Gadget> state = unmarshalGadgetApplicationState(navigator.fork());
+
+ Application<Gadget> gadget = new Application<Gadget>(ApplicationType.GADGET);
+ gadget.setState(state);
+
+ boolean showInfoBarParsed = false;
+
+ Element current = navigator.getName();
+ while (current != null)
+ {
+ switch (current)
+ {
+ case THEME:
+ gadget.setTheme(navigator.getContent());
+ current = navigator.sibling();
+ break;
+ case TITLE:
+ gadget.setTitle(navigator.getContent());
+ current = navigator.sibling();
+ break;
+ case ACCESS_PERMISSIONS:
+ gadget.setAccessPermissions(unmarshalAccessPermissions(navigator, true));
+ current = navigator.sibling();
+ break;
+ case SHOW_INFO_BAR:
+ gadget.setShowInfoBar(parseRequiredContent(navigator, ValueType.BOOLEAN));
+ showInfoBarParsed = true;
+ current = navigator.sibling();
+ break;
+ case SHOW_APPLICATION_STATE:
+ gadget.setShowApplicationState(navigator.parseContent(ValueType.BOOLEAN));
+ current = navigator.sibling();
+ break;
+ case SHOW_APPLICATION_MODE:
+ gadget.setShowApplicationMode(navigator.parseContent(ValueType.BOOLEAN));
+ current = navigator.sibling();
+ break;
+ case DESCRIPTION:
+ gadget.setDescription(navigator.getContent());
+ current = navigator.sibling();
+ break;
+ case ICON:
+ gadget.setIcon(navigator.getContent());
+ current = navigator.sibling();
+ break;
+ case WIDTH:
+ gadget.setWidth(navigator.getContent());
+ current = navigator.sibling();
+ break;
+ case HEIGHT:
+ gadget.setHeight(navigator.getContent());
+ current = navigator.sibling();
+ break;
+ case UNKNOWN:
+ throw unknownElement(navigator);
+ default:
+ throw unexpectedElement(navigator);
+ }
+ }
+
+ //TODO: We should raise this exception as soon as we know so location is accurate
+ if (gadget.getAccessPermissions() == null) throw expectedElement(navigator, Element.ACCESS_PERMISSIONS);
+ if (!showInfoBarParsed) throw expectedElement(navigator, Element.SHOW_INFO_BAR);
+
+ return gadget;
+ }
+
+ private ApplicationState<Gadget> unmarshalGadgetApplicationState(StaxNavigator<Element> navigator) throws XMLStreamException
+ {
+ requiresChild(navigator, Element.GADGET_REF);
+ String gadgetRef = getRequiredContent(navigator, true);
+
+ //TODO: Implement userPref unmarshalling when gatein_objects support it
+ Gadget gadget = null;
+
+ if (navigator.next() != null)
+ {
+ throw unexpectedElement(navigator);
+ }
+
+ return new TransientApplicationState<Gadget>(gadgetRef, gadget);
+ }
+
+ protected void marshalApplication(StaxWriter<Element> writer, Application<?> application) throws XMLStreamException
+ {
+ // Theme, Title
+ writeOptionalElement(writer, Element.THEME, application.getTheme());
+ writeOptionalElement(writer, Element.TITLE, application.getTitle());
+
+ // Access Permissions
+ marshalAccessPermissions(writer, application.getAccessPermissions());
+
+ // common application elements
+ writeOptionalElement(writer, Element.SHOW_INFO_BAR, String.valueOf(application.getShowInfoBar()));
+ writeOptionalElement(writer, Element.SHOW_APPLICATION_STATE, String.valueOf(application.getShowApplicationState()));
+ writeOptionalElement(writer, Element.SHOW_APPLICATION_MODE, String.valueOf(application.getShowApplicationMode()));
+
+ // Description, Icon
+ writeOptionalElement(writer, Element.DESCRIPTION, application.getDescription());
+ writeOptionalElement(writer, Element.ICON, application.getIcon());
+
+ // Width & Height
+ writeOptionalElement(writer, Element.WIDTH, application.getWidth());
+ writeOptionalElement(writer, Element.HEIGHT, application.getHeight());
+ }
+
+ protected void marshalAccessPermissions(StaxWriter<Element> writer, String[] accessPermissions) throws XMLStreamException
+ {
+ writeOptionalElement(writer, Element.ACCESS_PERMISSIONS, DelimitedValueType.SEMI_COLON, accessPermissions);
+ }
+
+ protected String[] unmarshalAccessPermissions(StaxNavigator<Element> navigator, boolean required) throws XMLStreamException
+ {
+ if (required)
+ {
+ return parseRequiredContent(navigator, DelimitedValueType.SEMI_COLON);
+ }
+ else
+ {
+ return parseContent(navigator, DelimitedValueType.SEMI_COLON, null);
+ }
+ }
+
+ protected void marshalEditPermission(StaxWriter<Element> writer, String editPermission) throws XMLStreamException
+ {
+ writeOptionalElement(writer, Element.EDIT_PERMISSION, editPermission);
+ }
+
+ protected String unmarshalEditPermission(StaxNavigator<Element> navigator) throws XMLStreamException
+ {
+ return getContent(navigator, true);
+ }
+
+ protected void writeGateinObjectsNamespace(StaxWriter<Element> writer) throws XMLStreamException
+ {
+ Utils.writeGateinObjectsNamespace(writer);
+ }
+
+ @SuppressWarnings("unchecked")
+ private <S> Application<S> safeCast(Application application, Class<S> stateClass)
+ {
+ return (Application<S>) application;
+ }
+
+ private static void writeOptionalAttribute(StaxWriter writer, Attribute attribute, String value) throws XMLStreamException
+ {
+ if (value == null) return;
+
+ writer.writeAttribute(attribute.getLocalName(), value);
+ }
+
+ private static enum Attribute
+ {
+ ID("id"),
+ TEMPLATE("template"),
+ WIDTH("width"),
+ HEIGHT("height");
+
+ private final String name;
+
+ Attribute(final String name)
+ {
+ this.name = name;
+ }
+
+ /**
+ * Get the local name of this element.
+ *
+ * @return the local name
+ */
+ public String getLocalName()
+ {
+ return name;
+ }
+ }
+}
Added: portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/DelimitedValueType.java
===================================================================
--- portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/DelimitedValueType.java (rev 0)
+++ portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/DelimitedValueType.java 2011-07-26 21:14:24 UTC (rev 6934)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.exoplatform.portal.mop.management.binding.xml;
+
+import org.exoplatform.portal.pom.config.Utils;
+import org.gatein.common.xml.stax.writer.WritableValueType;
+import org.staxnav.StaxNavException;
+import org.staxnav.ValueType;
+
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class DelimitedValueType extends ValueType<String[]> implements WritableValueType<String[]>
+{
+ public static DelimitedValueType SEMI_COLON = new DelimitedValueType(";");
+
+ private final String delimiter;
+
+ public DelimitedValueType(String delimiter)
+ {
+ this.delimiter = delimiter;
+ }
+
+ @Override
+ protected String[] parse(String s) throws Exception
+ {
+ return Utils.split(delimiter, s);
+ }
+
+ @Override
+ public String format(String[] value) throws StaxNavException
+ {
+ String s = Utils.join(delimiter, value);
+
+ if (s != null && s.trim().length() == 0)
+ {
+ return null;
+ }
+ else
+ {
+ return s;
+ }
+ }
+}
Added: portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/Element.java
===================================================================
--- portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/Element.java (rev 0)
+++ portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/Element.java 2011-07-26 21:14:24 UTC (rev 6934)
@@ -0,0 +1,104 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.exoplatform.portal.mop.management.binding.xml;
+
+
+import org.staxnav.EnumElement;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public enum Element implements EnumElement<Element>
+{
+ // Navigation Elements
+ UNKNOWN(null),
+ NODE_NAVIGATION("node-navigation"),
+ PRIORITY("priority"),
+ PAGE_NODES("page-nodes"),
+ NODE("node"),
+ @Deprecated
+ URI("uri"),
+ PARENT_URI("parent-uri"),
+ LABEL("label"),
+ START_PUBLICATION_DATE("start-publication-date"),
+ END_PUBLICATION_DATE("end-publication-date"),
+ VISIBILITY("visibility"),
+ PAGE_REFERENCE("page-reference"),
+
+ // Page elements
+ PAGE_SET("page-set"),
+ PAGE("page"),
+ NAME("name"),
+ SHOW_MAX_WINDOW("show-max-window"),
+
+ // Portal config elements
+ PORTAL_CONFIG("portal-config"),
+ PORTAL_NAME("portal-name"),
+ LOCALE("locale"),
+ SKIN("skin"),
+ PROPERTIES("properties"),
+ PROPERTIES_ENTRY("entry"),
+ PORTAL_LAYOUT("portal-layout"),
+
+ // Common elements
+ TITLE("title"),
+ DESCRIPTION("description"),
+ FACTORY_ID("factory-id"),
+ ACCESS_PERMISSIONS("access-permissions"),
+ EDIT_PERMISSION("edit-permission"),
+ PORTLET_APPLICATION("portlet-application"),
+ GADGET_APPLICATION("gadget-application"),
+ CONTAINER("container"),
+ PAGE_BODY("page-body"),
+ APPLICATION_REF("application-ref"),
+ PORTLET_REF("portlet-ref"),
+ PORTLET("portlet"),
+ GADGET_REF("gadget-ref"),
+ GADGET("gadget"),
+ THEME("theme"),
+ SHOW_INFO_BAR("show-info-bar"),
+ SHOW_APPLICATION_STATE("show-application-state"),
+ SHOW_APPLICATION_MODE("show-application-mode"),
+ ICON("icon"),
+ WIDTH("width"),
+ HEIGHT("height"),
+ PREFERENCES("preferences"),
+ PREFERENCE("preference"),
+ PREFERENCE_VALUE("value"),
+ PREFERENCE_READONLY("read-only")
+ ;
+
+ private final String name;
+
+ Element(String name)
+ {
+ this.name = name;
+ }
+
+ @Override
+ public String getLocalName()
+ {
+ return name;
+ }
+}
Added: portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/Namespace.java
===================================================================
--- portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/Namespace.java (rev 0)
+++ portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/Namespace.java 2011-07-26 21:14:24 UTC (rev 6934)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.exoplatform.portal.mop.management.binding.xml;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public enum Namespace
+{
+ GATEIN_OBJECTS_1_1("http://www.gatein.org/xml/ns/gatein_objects_1_1"),
+ GATEIN_OBJECTS_1_2("http://www.gatein.org/xml/ns/gatein_objects_1_2");
+
+ /**
+ * The current namespace version.
+ */
+ public static final Namespace CURRENT = GATEIN_OBJECTS_1_2;
+
+ private final String name;
+
+ Namespace(final String name)
+ {
+ this.name = name;
+ }
+
+ /**
+ * Get the URI of this namespace.
+ *
+ * @return the URI
+ */
+ public String getUri()
+ {
+ return name;
+ }
+}
Added: portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/NavigationMarshaller.java
===================================================================
--- portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/NavigationMarshaller.java (rev 0)
+++ portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/NavigationMarshaller.java 2011-07-26 21:14:24 UTC (rev 6934)
@@ -0,0 +1,295 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.exoplatform.portal.mop.management.binding.xml;
+
+import org.exoplatform.portal.config.model.I18NString;
+import org.exoplatform.portal.config.model.LocalizedString;
+import org.exoplatform.portal.config.model.NavigationFragment;
+import org.exoplatform.portal.config.model.PageNavigation;
+import org.exoplatform.portal.config.model.PageNode;
+import org.exoplatform.portal.mop.Visibility;
+import org.gatein.common.xml.stax.writer.StaxWriter;
+import org.gatein.common.xml.stax.writer.WritableValueTypes;
+import org.gatein.management.api.binding.BindingException;
+import org.gatein.management.api.binding.Marshaller;
+import org.staxnav.StaxNavException;
+import org.staxnav.StaxNavigator;
+import org.staxnav.ValueType;
+
+import javax.xml.XMLConstants;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import static org.gatein.common.xml.stax.navigator.Exceptions.*;
+import static org.gatein.common.xml.stax.navigator.StaxNavUtils.*;
+import static org.gatein.common.xml.stax.writer.StaxWriterUtils.*;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class NavigationMarshaller implements Marshaller<PageNavigation>
+{
+
+ @Override
+ public void marshal(PageNavigation navigation, OutputStream outputStream) throws BindingException
+ {
+ try
+ {
+ StaxWriter<Element> writer = createWriter(Element.class, outputStream);
+ marshalNavigation(writer, navigation);
+ }
+ catch (StaxNavException e)
+ {
+ throw new BindingException(e);
+ }
+ catch (XMLStreamException e)
+ {
+ throw new BindingException(e);
+ }
+ }
+
+ @Override
+ public PageNavigation unmarshal(InputStream is) throws BindingException
+ {
+ try
+ {
+ StaxNavigator<Element> navigator = createNavigator(Element.class, Element.UNKNOWN, is);
+ return unmarshalNavigation(navigator);
+ }
+ catch (StaxNavException e)
+ {
+ throw new BindingException(e);
+ }
+ }
+
+ private void marshalNavigation(StaxWriter<Element> writer, PageNavigation navigation) throws XMLStreamException
+ {
+ writer.writeStartElement(Element.NODE_NAVIGATION);
+
+ // Write gatein_objects xml namespace
+ Utils.writeGateinObjectsNamespace(writer);
+
+ // Priority
+ writer.writeElement(Element.PRIORITY, WritableValueTypes.INTEGER, navigation.getPriority());
+
+ // Page nodes
+ writer.writeStartElement(Element.PAGE_NODES);
+ ArrayList<NavigationFragment> fragments = navigation.getFragments();
+ for (NavigationFragment fragment : fragments)
+ {
+ if (fragment.getParentURI() != null)
+ {
+ String parentUri = fragment.getParentURI().trim();
+ if (parentUri.length() > 0)
+ {
+ writer.writeElement(Element.PARENT_URI, parentUri);
+ }
+ }
+
+ Collection<PageNode> nodes = fragment.getNodes();
+ if (nodes != null && !nodes.isEmpty())
+ {
+ for (PageNode node : nodes)
+ {
+ marshallNode(writer, node);
+ }
+ }
+ }
+
+ writer.writeEndElement().writeEndElement(); // End page-nodes and node-navigation
+ }
+
+ public void marshallNode(StaxWriter<Element> writer, PageNode node) throws XMLStreamException
+ {
+ writer.writeStartElement(Element.NODE);
+ writer.writeElement(Element.NAME, node.getName());
+
+ if (node.getLabels() != null)
+ {
+ for (LocalizedString label : node.getLabels())
+ {
+ writer.writeStartElement(Element.LABEL);
+ if (label.getLang() != null)
+ {
+ String localeString = label.getLang().getLanguage();
+ if (localeString == null)
+ {
+ throw new XMLStreamException("Language was null for locale " + label.getLang());
+ }
+ String country = label.getLang().getCountry();
+ if (country != null && country.length() > 0)
+ {
+ localeString += "-" + country.toLowerCase();
+ }
+
+ writer.writeAttribute(new QName(XMLConstants.XML_NS_URI, "lang", XMLConstants.XML_NS_PREFIX), localeString);
+ }
+ writer.writeContent(label.getValue()).writeEndElement();
+ }
+ }
+
+ writeOptionalElement(writer, Element.ICON, node.getIcon());
+
+ writeOptionalElement(writer, Element.START_PUBLICATION_DATE, WritableValueTypes.DATE_TIME, node.getStartPublicationDate());
+ writeOptionalElement(writer, Element.END_PUBLICATION_DATE, WritableValueTypes.DATE_TIME, node.getEndPublicationDate());
+
+ String visibility = (node.getVisibility() == null) ? null : node.getVisibility().name();
+ writeOptionalElement(writer, Element.VISIBILITY, visibility);
+ writeOptionalElement(writer, Element.PAGE_REFERENCE, node.getPageReference());
+
+ // Marshall children
+ List<PageNode> children = node.getNodes();
+ if (children != null && !children.isEmpty())
+ {
+ for (PageNode child : children)
+ {
+ marshallNode(writer, child);
+ }
+ }
+
+ writer.writeEndElement(); // End of node
+ }
+
+ private PageNavigation unmarshalNavigation(StaxNavigator<Element> navigator) throws StaxNavException
+ {
+ PageNavigation navigation = new PageNavigation();
+
+ if (navigator.getName() == Element.NODE_NAVIGATION)
+ {
+ Element next = navigator.child();
+ if (next != Element.PRIORITY)
+ {
+ throw expectedElement(navigator, Element.PRIORITY);
+ }
+ Integer priority = parseRequiredContent(navigator, ValueType.INTEGER);
+ navigation.setPriority(priority);
+
+ next = navigator.sibling();
+ if (next == Element.PAGE_NODES)
+ {
+ for (StaxNavigator<Element> fork: navigator.fork(Element.PAGE_NODES))
+ {
+ NavigationFragment fragment = new NavigationFragment();
+ navigation.addFragment(fragment);
+
+ next = fork.child();
+ if (next == Element.PARENT_URI)
+ {
+ fragment.setParentURI(fork.getContent());
+ next = fork.sibling();
+ }
+
+ if (next == Element.NODE)
+ {
+ ArrayList<PageNode> nodes = new ArrayList<PageNode>();
+ for (StaxNavigator<Element> nodeFork : fork.fork(Element.NODE))
+ {
+ nodes.add(unmarshalNode(nodeFork));
+ }
+ fragment.setNodes(nodes);
+ }
+ else if (next != null)
+ {
+ throw unknownElement(fork);
+ }
+ }
+ }
+ else if (next != null)
+ {
+ throw expectedElement(navigator, Element.PAGE_NODES);
+ }
+
+ return navigation;
+ }
+ else
+ {
+ throw unknownElement(navigator);
+ }
+ }
+
+ private PageNode unmarshalNode(StaxNavigator<Element> navigator) throws StaxNavException
+ {
+ PageNode node = new PageNode();
+ I18NString labels = new I18NString();
+ ArrayList<PageNode> children = new ArrayList<PageNode>();
+
+ Element current = navigator.child();
+ while (current != null)
+ {
+ switch (navigator.getName())
+ {
+ case URI: // For backwards compatibility
+ current = navigator.sibling();
+ break;
+ case NAME:
+ node.setName(navigator.getContent());
+ current = navigator.sibling();
+ break;
+ case LABEL:
+ labels.add(Utils.parseLocalizedString(navigator));
+ current = navigator.sibling();
+ break;
+ case ICON:
+ node.setIcon(navigator.getContent());
+ current = navigator.sibling();
+ break;
+ case START_PUBLICATION_DATE:
+ node.setStartPublicationDate(navigator.parseContent(ValueType.DATE_TIME));
+ current = navigator.sibling();
+ break;
+ case END_PUBLICATION_DATE:
+ node.setEndPublicationDate(navigator.parseContent(ValueType.DATE_TIME));
+ current = navigator.sibling();
+ break;
+ case VISIBILITY:
+ node.setVisibility(navigator.parseContent(ValueType.get(Visibility.class)));
+ current = navigator.sibling();
+ break;
+ case PAGE_REFERENCE:
+ node.setPageReference(navigator.getContent());
+ current = navigator.sibling();
+ break;
+ case NODE:
+ PageNode child = unmarshalNode(navigator.fork());
+ children.add(child);
+ current = navigator.getName();
+ break;
+ case UNKNOWN:
+ throw unknownElement(navigator);
+ default:
+ throw unexpectedElement(navigator);
+ }
+ }
+
+ node.setLabels(labels);
+ node.setChildren(children);
+
+ return node;
+ }
+}
Added: portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/PageMarshaller.java
===================================================================
--- portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/PageMarshaller.java (rev 0)
+++ portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/PageMarshaller.java 2011-07-26 21:14:24 UTC (rev 6934)
@@ -0,0 +1,220 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.exoplatform.portal.mop.management.binding.xml;
+
+import org.exoplatform.portal.config.model.ModelObject;
+import org.exoplatform.portal.config.model.Page;
+import org.gatein.common.xml.stax.writer.StaxWriter;
+import org.gatein.common.xml.stax.writer.WritableValueTypes;
+import org.gatein.management.api.binding.BindingException;
+import org.staxnav.StaxNavException;
+import org.staxnav.StaxNavigator;
+import org.staxnav.ValueType;
+
+import javax.xml.stream.XMLStreamException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.gatein.common.xml.stax.navigator.Exceptions.*;
+import static org.gatein.common.xml.stax.navigator.StaxNavUtils.*;
+import static org.gatein.common.xml.stax.writer.StaxWriterUtils.*;
+
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class PageMarshaller extends AbstractMarshaller<Page.PageSet>
+{
+ @Override
+ public void marshal(Page.PageSet pageSet, OutputStream outputStream) throws BindingException
+ {
+ try
+ {
+ StaxWriter<Element> writer = createWriter(Element.class, outputStream);
+
+ writer.writeStartElement(Element.PAGE_SET);
+ writeGateinObjectsNamespace(writer);
+
+ // Marshal pages
+ for (Page page : pageSet.getPages())
+ {
+ marshalPage(writer, page);
+ }
+
+ writer.finish();
+ }
+ catch (StaxNavException e)
+ {
+ throw new BindingException(e);
+ }
+ catch (XMLStreamException e)
+ {
+ throw new BindingException(e);
+ }
+ }
+
+ @Override
+ public Page.PageSet unmarshal(InputStream inputStream) throws BindingException
+ {
+ try
+ {
+ StaxNavigator<Element> navigator = createNavigator(Element.class, Element.UNKNOWN, inputStream);
+ if (navigator.getName() == Element.PAGE_SET)
+ {
+ ArrayList<Page> pages = new ArrayList<Page>();
+ Element next = navigator.child();
+ if (next == Element.PAGE)
+ {
+ for (StaxNavigator<Element> fork : navigator.fork(Element.PAGE))
+ {
+ pages.add(unmarshalPage(fork));
+ }
+ }
+ else if (next != null)
+ {
+ throw unexpectedElement(navigator);
+ }
+
+ //Seems like next should be null here...
+ if (navigator.sibling() != null)
+ {
+ throw unexpectedElement(navigator);
+ }
+
+ Page.PageSet pageSet = new Page.PageSet();
+ pageSet.setPages(pages);
+
+ return pageSet;
+ }
+ else
+ {
+ throw unknownElement(navigator);
+ }
+ }
+ catch (StaxNavException e)
+ {
+ throw new BindingException(e);
+ }
+ catch (XMLStreamException e)
+ {
+ throw new BindingException(e);
+ }
+ }
+
+ private void marshalPage(StaxWriter<Element> writer, Page page) throws XMLStreamException
+ {
+ writer.writeStartElement(Element.PAGE);
+
+ // name, title description
+ writer.writeElement(Element.NAME, page.getName());
+ writeOptionalElement(writer, Element.TITLE, page.getTitle());
+ writeOptionalElement(writer, Element.DESCRIPTION, page.getDescription());
+
+ // Access/Edit permissions
+ marshalAccessPermissions(writer, page.getAccessPermissions());
+ marshalEditPermission(writer, page.getEditPermission());
+
+ writeOptionalElement(writer, Element.SHOW_MAX_WINDOW, WritableValueTypes.BOOLEAN, page.isShowMaxWindow());
+
+ List<ModelObject> children = page.getChildren();
+ for (ModelObject child : children)
+ {
+ marshalModelObject(writer, child);
+ }
+
+ writer.writeEndElement(); // End of page element
+ }
+
+ private Page unmarshalPage(StaxNavigator<Element> navigator) throws XMLStreamException
+ {
+ requiresChild(navigator, Element.NAME);
+ String name = getRequiredContent(navigator, true);
+
+ Page page = new Page();
+ page.setName(name);
+
+ //TODO: Need valid way to ensure a sequence of xml elements, with a mix of required and optional elements.
+ Element current = navigator.sibling();
+ while (current != null)
+ {
+ switch (current)
+ {
+ case TITLE:
+ page.setTitle(getContent(navigator, false));
+ current = navigator.sibling();
+ break;
+ case DESCRIPTION:
+ page.setDescription(getContent(navigator, false));
+ current = navigator.sibling();
+ break;
+ case ACCESS_PERMISSIONS:
+ page.setAccessPermissions(unmarshalAccessPermissions(navigator, true));
+ current = navigator.sibling();
+ break;
+ case EDIT_PERMISSION:
+ page.setEditPermission(unmarshalEditPermission(navigator));
+ current = navigator.sibling();
+ break;
+ case SHOW_MAX_WINDOW:
+ page.setShowMaxWindow(parseRequiredContent(navigator, ValueType.BOOLEAN));
+ current = navigator.sibling();
+ break;
+ case CONTAINER:
+ if (page.getChildren() == null)
+ {
+ page.setChildren(new ArrayList<ModelObject>());
+ }
+ page.getChildren().add(unmarshalContainer(navigator.fork()));
+ current = navigator.getName();
+ break;
+ case PORTLET_APPLICATION:
+ if (page.getChildren() == null)
+ {
+ page.setChildren(new ArrayList<ModelObject>());
+ }
+ page.getChildren().add(unmarshalPortletApplication(navigator.fork()));
+ current = navigator.getName();
+ break;
+ case GADGET_APPLICATION:
+ if (page.getChildren() == null)
+ {
+ page.setChildren(new ArrayList<ModelObject>());
+ }
+ page.getChildren().add(unmarshalGadgetApplication(navigator.fork()));
+ current = navigator.getName();
+ break;
+ case UNKNOWN:
+ throw unknownElement(navigator);
+ default:
+ throw unexpectedElement(navigator);
+ }
+ }
+ //TODO: We should raise this exception as soon as we know so location is accurate
+ if (page.getAccessPermissions() == null) throw expectedElement(navigator, Element.ACCESS_PERMISSIONS);
+
+ return page;
+ }
+}
Added: portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/SiteLayoutMarshaller.java
===================================================================
--- portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/SiteLayoutMarshaller.java (rev 0)
+++ portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/SiteLayoutMarshaller.java 2011-07-26 21:14:24 UTC (rev 6934)
@@ -0,0 +1,292 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.exoplatform.portal.mop.management.binding.xml;
+
+import org.exoplatform.portal.config.model.Container;
+import org.exoplatform.portal.config.model.ModelObject;
+import org.exoplatform.portal.config.model.PageBody;
+import org.exoplatform.portal.config.model.PortalConfig;
+import org.exoplatform.portal.config.model.Properties;
+import org.gatein.common.xml.stax.navigator.StaxNavUtils;
+import org.gatein.common.xml.stax.writer.StaxWriter;
+import org.gatein.management.api.binding.BindingException;
+import org.staxnav.Axis;
+import org.staxnav.StaxNavException;
+import org.staxnav.StaxNavigator;
+
+import javax.xml.stream.XMLStreamException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.List;
+import java.util.Map;
+
+import static org.gatein.common.xml.stax.navigator.Exceptions.*;
+import static org.gatein.common.xml.stax.navigator.StaxNavUtils.*;
+import static org.gatein.common.xml.stax.writer.StaxWriterUtils.*;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class SiteLayoutMarshaller extends AbstractMarshaller<PortalConfig>
+{
+ @Override
+ public void marshal(PortalConfig object, OutputStream outputStream) throws BindingException
+ {
+ try
+ {
+ StaxWriter<Element> writer = createWriter(Element.class, outputStream);
+
+ // root element
+ writer.writeStartElement(Element.PORTAL_CONFIG);
+ writeGateinObjectsNamespace(writer);
+
+ marshalPortalConfig(writer, object);
+
+ writer.finish();
+ }
+ catch (StaxNavException e)
+ {
+ throw new BindingException(e);
+ }
+ catch (XMLStreamException e)
+ {
+ throw new BindingException(e);
+ }
+ }
+
+ @Override
+ public PortalConfig unmarshal(InputStream is) throws BindingException
+ {
+ try
+ {
+ StaxNavigator<Element> navigator = StaxNavUtils.createNavigator(Element.class, Element.UNKNOWN, is);
+
+ if (navigator.getName() == Element.PORTAL_CONFIG)
+ {
+ return unmarshalPortalConfig(navigator);
+ }
+ else
+ {
+ throw unknownElement(navigator);
+ }
+ }
+ catch (StaxNavException e)
+ {
+ throw new BindingException(e);
+ }
+ catch (XMLStreamException e)
+ {
+ throw new BindingException(e);
+ }
+ }
+
+ private void marshalPortalConfig(StaxWriter<Element> writer, PortalConfig portalConfig) throws XMLStreamException
+ {
+ writer.writeElement(Element.PORTAL_NAME, portalConfig.getName());
+ writeOptionalElement(writer, Element.LABEL, portalConfig.getLabel());
+ writeOptionalElement(writer, Element.DESCRIPTION, portalConfig.getDescription());
+ writeOptionalElement(writer, Element.LOCALE, portalConfig.getLocale());
+
+ // Access permissions
+ marshalAccessPermissions(writer, portalConfig.getAccessPermissions());
+
+ // Edit permission
+ marshalEditPermission(writer, portalConfig.getEditPermission());
+
+ writeOptionalElement(writer, Element.SKIN, portalConfig.getSkin());
+
+ boolean propertiesWritten = false;
+ Map<String, String> properties = portalConfig.getProperties();
+ if (properties != null)
+ {
+ for (String key : properties.keySet())
+ {
+ if (!propertiesWritten)
+ {
+ writer.writeStartElement(Element.PROPERTIES);
+ propertiesWritten = true;
+ }
+ String value = properties.get(key);
+ if (value != null)
+ {
+ writer.writeStartElement(Element.PROPERTIES_ENTRY);
+ writer.writeAttribute(Attribute.PROPERTIES_KEY.getLocalName(), key);
+ writer.writeContent(value).writeEndElement();
+ }
+ }
+ if (propertiesWritten)
+ {
+ writer.writeEndElement();
+ }
+ }
+
+ Container container = portalConfig.getPortalLayout();
+ if (container != null)
+ {
+ writer.writeStartElement(Element.PORTAL_LAYOUT);
+ List<ModelObject> children = container.getChildren();
+ if (children != null && !children.isEmpty())
+ {
+ for (ModelObject child : children)
+ {
+ marshalModelObject(writer, child);
+ }
+ }
+ writer.writeEndElement();
+ }
+ }
+
+ private PortalConfig unmarshalPortalConfig(StaxNavigator<Element> navigator) throws XMLStreamException
+ {
+ PortalConfig portalConfig = new PortalConfig();
+
+ Container portalLayout = null;
+ Element current = navigator.child();
+ while (current != null)
+ {
+ switch (current)
+ {
+ case PORTAL_NAME:
+ portalConfig.setName(navigator.getContent());
+ current = navigator.sibling();
+ break;
+ case LOCALE:
+ portalConfig.setLocale(navigator.getContent());
+ current = navigator.sibling();
+ break;
+ case LABEL:
+ portalConfig.setLabel(navigator.getContent());
+ current = navigator.sibling();
+ break;
+ case DESCRIPTION:
+ portalConfig.setDescription(navigator.getContent());
+ current = navigator.sibling();
+ break;
+ case SKIN:
+ portalConfig.setSkin(navigator.getContent());
+ current = navigator.sibling();
+ break;
+ case PROPERTIES:
+ Properties properties = new Properties();
+ if (navigator.navigate(Axis.CHILD, Element.PROPERTIES_ENTRY))
+ {
+ for (StaxNavigator<Element> fork : navigator.fork(Element.PROPERTIES_ENTRY))
+ {
+ String key = getRequiredAttribute(fork, Attribute.PROPERTIES_KEY.getLocalName());
+ String value = getRequiredContent(fork, false);
+ properties.put(key, value);
+ }
+ }
+ else
+ {
+ throw expectedElement(navigator, Element.PROPERTIES_ENTRY);
+ }
+ portalConfig.setProperties(properties);
+ current = navigator.next();
+ break;
+ case ACCESS_PERMISSIONS:
+ portalConfig.setAccessPermissions(unmarshalAccessPermissions(navigator, false));
+ current = navigator.sibling();
+ break;
+ case EDIT_PERMISSION:
+ portalConfig.setEditPermission(unmarshalEditPermission(navigator));
+ current = navigator.sibling();
+ break;
+ case PORTAL_LAYOUT:
+ portalLayout = new Container();
+ current = navigator.child();
+ break;
+ case PAGE_BODY:
+ if (portalLayout == null)
+ {
+ throw expectedElement(navigator, Element.PORTAL_LAYOUT);
+ }
+ portalLayout.getChildren().add(new PageBody());
+ current = navigator.sibling();
+ break;
+ case PORTLET_APPLICATION:
+ if (portalLayout == null)
+ {
+ throw expectedElement(navigator, Element.PORTAL_LAYOUT);
+ }
+ portalLayout.getChildren().add(unmarshalPortletApplication(navigator.fork()));
+ current = navigator.getName();
+ break;
+ case GADGET_APPLICATION:
+ if (portalLayout == null)
+ {
+ throw expectedElement(navigator, Element.PORTAL_LAYOUT);
+ }
+ portalLayout.getChildren().add(unmarshalGadgetApplication(navigator.fork()));
+ current = navigator.getName();
+ break;
+ case CONTAINER:
+ if (portalLayout == null)
+ {
+ throw expectedElement(navigator, Element.PORTAL_LAYOUT);
+ }
+ portalLayout.getChildren().add(unmarshalContainer(navigator.fork()));
+ current = navigator.getName();
+ break;
+ case UNKNOWN:
+ throw unknownElement(navigator);
+ default:
+ throw unexpectedElement(navigator);
+ }
+ }
+
+ //TODO: We should raise this exception as soon as we know so location is accurate
+ if (portalConfig.getAccessPermissions() == null) throw expectedElement(navigator, Element.ACCESS_PERMISSIONS);
+ if (portalLayout == null)
+ {
+ portalLayout = PortalConfig.DEFAULT_LAYOUT;
+ }
+
+ portalConfig.setPortalLayout(portalLayout);
+
+ return portalConfig;
+ }
+
+ private static enum Attribute
+ {
+ PROPERTIES_KEY("key");
+
+ private final String name;
+
+ Attribute(final String name)
+ {
+ this.name = name;
+ }
+
+ /**
+ * Get the local name of this element.
+ *
+ * @return the local name
+ */
+ public String getLocalName()
+ {
+ return name;
+ }
+ }
+}
Added: portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/Utils.java
===================================================================
--- portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/Utils.java (rev 0)
+++ portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/Utils.java 2011-07-26 21:14:24 UTC (rev 6934)
@@ -0,0 +1,91 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.exoplatform.portal.mop.management.binding.xml;
+
+import org.exoplatform.portal.config.model.LocalizedString;
+import org.gatein.common.xml.stax.navigator.StaxNavUtils;
+import org.gatein.common.xml.stax.writer.StaxWriter;
+import org.staxnav.StaxNavException;
+import org.staxnav.StaxNavigator;
+
+import javax.xml.XMLConstants;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import java.util.Locale;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+class Utils
+{
+ private static final Pattern XMLLANG_PATTERN = Pattern.compile("^([a-zA-Z]{2})(?:-([a-zA-Z]{2}))?$");
+
+ public static <N> void writeGateinObjectsNamespace(StaxWriter<N> writer) throws XMLStreamException
+ {
+ String gatein_object_ns = Namespace.CURRENT.getUri();
+ String location = new StringBuilder().append(gatein_object_ns).append(" ").append(gatein_object_ns).toString();
+
+ writer.writeDefaultNamespace(gatein_object_ns);
+ writer.writeNamespace("xsi", XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI);
+ writer.writeAttribute(new QName(XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI, "schemaLocation"), location);
+ }
+
+ public static <N> LocalizedString parseLocalizedString(StaxNavigator<N> navigator) throws StaxNavException
+ {
+ String attribute = navigator.getAttribute(new QName(XMLConstants.XML_NS_URI, "lang", XMLConstants.XML_NS_PREFIX));
+ if (attribute == null)
+ {
+ attribute = navigator.getAttribute("lang");
+ }
+
+ Locale lang = null;
+ if (attribute != null)
+ {
+ Matcher matcher = XMLLANG_PATTERN.matcher(attribute);
+ if (matcher.matches())
+ {
+ String langISO = matcher.group(1);
+ String countryISO = matcher.group(2);
+ if (countryISO == null)
+ {
+ lang = new Locale(langISO.toLowerCase());
+ }
+ else
+ {
+ lang = new Locale(langISO.toLowerCase(), countryISO.toLowerCase());
+ }
+ }
+ else
+ {
+ throw new StaxNavException(navigator.getLocation(), "The attribute xml:lang='" + attribute + "' does not represent a valid language pattern (ie: en, en-us).");
+ }
+ }
+
+ String value = StaxNavUtils.getRequiredContent(navigator, false);
+
+ return new LocalizedString(value, lang);
+ }
+}
Added: portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/AbstractExportTask.java
===================================================================
--- portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/AbstractExportTask.java (rev 0)
+++ portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/AbstractExportTask.java 2011-07-26 21:14:24 UTC (rev 6934)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.exoplatform.portal.mop.management.exportimport;
+
+import org.exoplatform.portal.mop.SiteKey;
+import org.gatein.management.api.operation.model.ExportTask;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public abstract class AbstractExportTask implements ExportTask
+{
+ protected SiteKey siteKey;
+
+ protected AbstractExportTask(SiteKey siteKey)
+ {
+ this.siteKey = siteKey;
+ }
+
+ @Override
+ public String getEntry()
+ {
+ String siteType = siteKey.getTypeName();
+
+ String siteName = siteKey.getName();
+ if (siteName.charAt(0) == '/') siteName = siteName.substring(1, siteName.length());
+
+ return new StringBuilder().
+ append(siteType).append("/").append(siteName).append("/").append(getXmlFileName()).toString();
+ }
+
+ protected abstract String getXmlFileName();
+}
Added: portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/AbstractImportTask.java
===================================================================
--- portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/AbstractImportTask.java (rev 0)
+++ portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/AbstractImportTask.java 2011-07-26 21:14:24 UTC (rev 6934)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.exoplatform.portal.mop.management.exportimport;
+
+import org.exoplatform.portal.mop.SiteKey;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public abstract class AbstractImportTask<T> extends ImportTask<T>
+{
+ protected final SiteKey siteKey;
+
+ public AbstractImportTask(T data, SiteKey siteKey)
+ {
+ super(data);
+ this.siteKey = siteKey;
+ }
+
+ public SiteKey getSiteKey()
+ {
+ return siteKey;
+ }
+}
Added: portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/ImportStrategy.java
===================================================================
--- portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/ImportStrategy.java (rev 0)
+++ portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/ImportStrategy.java 2011-07-26 21:14:24 UTC (rev 6934)
@@ -0,0 +1,78 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.exoplatform.portal.mop.management.exportimport;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public enum ImportStrategy
+{
+ /**
+ * Import when data does not exist. Otherwise do nothing.
+ */
+ CONSERVE("conserve"),
+
+ /**
+ * Import when data does not exist. Otherwise perform a merge
+ */
+ MERGE("merge"),
+
+ /**
+ * Delete existing data, import new data.
+ */
+ OVERWRITE("overwrite");
+
+ private String name;
+
+ ImportStrategy(String name)
+ {
+ this.name = name;
+ }
+
+ private static final Map<String, ImportStrategy> MAP;
+
+ static
+ {
+ Map<String, ImportStrategy> tmp = new HashMap<String, ImportStrategy>(3);
+ for (ImportStrategy strategy : ImportStrategy.values())
+ {
+ tmp.put(strategy.name, strategy);
+ }
+
+ MAP = tmp;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public static ImportStrategy forName(String name)
+ {
+ return MAP.get(name);
+ }
+}
Added: portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/ImportTask.java
===================================================================
--- portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/ImportTask.java (rev 0)
+++ portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/ImportTask.java 2011-07-26 21:14:24 UTC (rev 6934)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.exoplatform.portal.mop.management.exportimport;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public abstract class ImportTask<T>
+{
+ protected final T data;
+ protected ImportTask(T data)
+ {
+ this.data = data;
+ }
+
+ public abstract void importData(ImportStrategy importStrategy) throws Exception;
+
+ public abstract void rollback() throws Exception;
+}
Added: portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/NavigationExportTask.java
===================================================================
--- portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/NavigationExportTask.java (rev 0)
+++ portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/NavigationExportTask.java 2011-07-26 21:14:24 UTC (rev 6934)
@@ -0,0 +1,70 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.exoplatform.portal.mop.management.exportimport;
+
+import org.exoplatform.portal.config.model.PageNavigation;
+import org.exoplatform.portal.mop.description.DescriptionService;
+import org.exoplatform.portal.mop.management.operations.navigation.NavigationKey;
+import org.exoplatform.portal.mop.management.operations.navigation.PageNavigationUtils;
+import org.exoplatform.portal.mop.navigation.NavigationService;
+import org.gatein.management.api.binding.Marshaller;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class NavigationExportTask extends AbstractExportTask
+{
+ public static final String FILE = "navigation.xml";
+
+ private NavigationKey navigationKey;
+ private Marshaller<PageNavigation> marshaller;
+ private NavigationService navigationService;
+ private DescriptionService descriptionService;
+
+ public NavigationExportTask(NavigationKey navigationKey, NavigationService navigationService,
+ DescriptionService descriptionService, Marshaller<PageNavigation> marshaller)
+ {
+ super(navigationKey.getSiteKey());
+ this.navigationKey = navigationKey;
+ this.navigationService = navigationService;
+ this.descriptionService = descriptionService;
+ this.marshaller = marshaller;
+ }
+
+ @Override
+ protected String getXmlFileName()
+ {
+ return FILE;
+ }
+
+ @Override
+ public void export(OutputStream outputStream) throws IOException
+ {
+ PageNavigation navigation = PageNavigationUtils.loadPageNavigation(navigationKey, navigationService, descriptionService);
+ marshaller.marshal(navigation, outputStream);
+ }
+}
Added: portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/NavigationImportTask.java
===================================================================
--- portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/NavigationImportTask.java (rev 0)
+++ portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/NavigationImportTask.java 2011-07-26 21:14:24 UTC (rev 6934)
@@ -0,0 +1,130 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.exoplatform.portal.mop.management.exportimport;
+
+import org.exoplatform.portal.config.DataStorage;
+import org.exoplatform.portal.config.model.PageNavigation;
+import org.exoplatform.portal.config.model.PortalConfig;
+import org.exoplatform.portal.mop.SiteKey;
+import org.exoplatform.portal.mop.description.DescriptionService;
+import org.exoplatform.portal.mop.importer.ImportMode;
+import org.exoplatform.portal.mop.importer.NavigationImporter;
+import org.exoplatform.portal.mop.navigation.NavigationContext;
+import org.exoplatform.portal.mop.navigation.NavigationService;
+import org.exoplatform.portal.pom.data.ModelDataStorage;
+import org.exoplatform.portal.pom.data.PortalData;
+import org.exoplatform.portal.pom.data.PortalKey;
+import org.gatein.common.logging.Logger;
+import org.gatein.common.logging.LoggerFactory;
+
+import java.util.Locale;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class NavigationImportTask extends AbstractImportTask<PageNavigation>
+{
+ private static final Logger log = LoggerFactory.getLogger(NavigationImportTask.class);
+
+ private NavigationService navigationService;
+ private DescriptionService descriptionService;
+ private DataStorage dataStorage;
+ private RollbackTask rollbackTask;
+
+ public NavigationImportTask(PageNavigation data, SiteKey siteKey,
+ NavigationService navigationService, DescriptionService descriptionService, DataStorage dataStorage)
+ {
+ super(data, siteKey);
+ this.navigationService = navigationService;
+ this.descriptionService = descriptionService;
+ this.dataStorage = dataStorage;
+ }
+
+ @Override
+ public void importData(ImportStrategy importStrategy) throws Exception
+ {
+ ImportMode mode;
+ switch (importStrategy)
+ {
+ case CONSERVE:
+ mode = ImportMode.INSERT;
+ break;
+ case MERGE:
+ mode = ImportMode.MERGE;
+ break;
+ case OVERWRITE:
+ mode = ImportMode.OVERWRITE;
+ break;
+ default:
+ throw new Exception("Could not map import strategy " + importStrategy.getName() + " to import mode.");
+ }
+
+ PortalConfig portalConfig = dataStorage.getPortalConfig(siteKey.getTypeName(), siteKey.getName());
+ if (portalConfig == null) throw new Exception("Cannot import navigation because site does not exist for " + siteKey);
+
+ Locale locale = (portalConfig.getLocale() == null) ? Locale.ENGLISH : new Locale(portalConfig.getLocale());
+
+ final NavigationContext navContext = navigationService.loadNavigation(siteKey);
+ if (navContext == null)
+ {
+ rollbackTask = new RollbackTask()
+ {
+ @Override
+ public void rollback() throws Exception
+ {
+ navigationService.destroyNavigation(navContext);
+ }
+ };
+ }
+ else
+ {
+ //TODO: Rollback updates.
+ rollbackTask = new RollbackTask()
+ {
+ @Override
+ public void rollback() throws Exception
+ {
+ log.warn("Rollback for existing navigation not supported at the moment.");
+ }
+ };
+ }
+
+ NavigationImporter importer = new NavigationImporter(locale, mode, data, navigationService, descriptionService);
+ importer.perform();
+ }
+
+ @Override
+ public void rollback() throws Exception
+ {
+ if (rollbackTask != null)
+ {
+ rollbackTask.rollback();
+ }
+ }
+
+ private static interface RollbackTask
+ {
+ void rollback() throws Exception;
+ }
+}
Added: portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/POMSessionExportTask.java
===================================================================
--- portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/POMSessionExportTask.java (rev 0)
+++ portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/POMSessionExportTask.java 2011-07-26 21:14:24 UTC (rev 6934)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.exoplatform.portal.mop.management.exportimport;
+
+import org.exoplatform.portal.mop.SiteKey;
+import org.exoplatform.portal.pom.config.POMSession;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public abstract class POMSessionExportTask extends AbstractExportTask
+{
+ protected POMSession session;
+
+ public POMSessionExportTask(SiteKey siteKey, POMSession session)
+ {
+ super(siteKey);
+ this.session = session;
+ }
+}
Added: portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/PageExportTask.java
===================================================================
--- portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/PageExportTask.java (rev 0)
+++ portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/PageExportTask.java 2011-07-26 21:14:24 UTC (rev 6934)
@@ -0,0 +1,95 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.exoplatform.portal.mop.management.exportimport;
+
+import org.exoplatform.portal.config.DataStorage;
+import org.exoplatform.portal.config.model.Page;
+import org.exoplatform.portal.mop.SiteKey;
+import org.exoplatform.portal.pom.config.POMSession;
+import org.exoplatform.portal.pom.config.Utils;
+import org.gatein.management.api.binding.Marshaller;
+import org.gatein.management.api.operation.model.ExportTask;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class PageExportTask extends AbstractExportTask implements ExportTask
+{
+ public static final String FILE = "pages.xml";
+
+ private final DataStorage dataStorage;
+ private final Marshaller<Page.PageSet> marshaller;
+ private final List<String> pageNames;
+
+ public PageExportTask(SiteKey siteKey, DataStorage dataStorage, Marshaller<Page.PageSet> marshaller)
+ {
+ super(siteKey);
+ this.dataStorage = dataStorage;
+ this.marshaller = marshaller;
+ pageNames = new ArrayList<String>();
+ }
+
+ @Override
+ public void export(OutputStream outputStream) throws IOException
+ {
+ Page.PageSet pages = new Page.PageSet();
+ pages.setPages(new ArrayList<Page>(pageNames.size()));
+ for (String pageName : pageNames)
+ {
+ try
+ {
+ Page page = dataStorage.getPage(Utils.join("::", siteKey.getTypeName(), siteKey.getName(), pageName));
+ pages.getPages().add(page);
+ }
+ catch (Exception e)
+ {
+ throw new IOException("Could not retrieve page name " + pageName + " for site " + siteKey, e);
+ }
+ }
+
+ marshaller.marshal(pages, outputStream);
+ }
+
+ @Override
+ protected String getXmlFileName()
+ {
+ return FILE;
+ }
+
+ public void addPageName(String pageName)
+ {
+ pageNames.add(pageName);
+ }
+
+ public List<String> getPageNames()
+ {
+ return Collections.unmodifiableList(pageNames);
+ }
+}
Added: portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/PageImportTask.java
===================================================================
--- portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/PageImportTask.java (rev 0)
+++ portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/PageImportTask.java 2011-07-26 21:14:24 UTC (rev 6934)
@@ -0,0 +1,203 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.exoplatform.portal.mop.management.exportimport;
+
+import org.exoplatform.commons.utils.LazyPageList;
+import org.exoplatform.portal.config.DataStorage;
+import org.exoplatform.portal.config.Query;
+import org.exoplatform.portal.config.model.Page;
+import org.exoplatform.portal.mop.SiteKey;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class PageImportTask extends AbstractImportTask<Page.PageSet>
+{
+ private final DataStorage dataStorage;
+ private Page.PageSet rollbackSaves;
+ private Page.PageSet rollbackDeletes;
+
+ public PageImportTask(Page.PageSet data, SiteKey siteKey, DataStorage dataStorage)
+ {
+ super(data, siteKey);
+ this.dataStorage = dataStorage;
+ }
+
+ @Override
+ public void importData(ImportStrategy strategy) throws Exception
+ {
+ if (data == null || data.getPages() == null || data.getPages().isEmpty()) return;
+
+ Query<Page> query = new Query<Page>(siteKey.getTypeName(), siteKey.getName(), Page.class);
+ LazyPageList<Page> list = dataStorage.find(query);
+ int size = list.getAvailable();
+
+ Page.PageSet dst = null;
+ switch (strategy)
+ {
+ case CONSERVE:
+ if (size == 0)
+ {
+ dst = data; // No pages exist yet.
+ rollbackDeletes = data;
+ }
+ else
+ {
+ dst = new Page.PageSet();
+ dst.setPages(new ArrayList<Page>());
+ List<Page> existingPages = list.getAll();
+ rollbackDeletes = new Page.PageSet();
+ rollbackDeletes.setPages(new ArrayList<Page>());
+ for (Page src : data.getPages())
+ {
+ Page found = findPage(existingPages, src);
+ if (found == null)
+ {
+ dst.getPages().add(src);
+ rollbackDeletes.getPages().add(src);
+ }
+ }
+ }
+ break;
+ case MERGE:
+ if (size == 0) // No pages exist yet.
+ {
+ dst = data;
+ rollbackDeletes = data;
+ }
+ else
+ {
+ dst = new Page.PageSet();
+ dst.setPages(new ArrayList<Page>(data.getPages().size()));
+ List<Page> existingPages = list.getAll();
+ rollbackSaves = new Page.PageSet();
+ rollbackSaves.setPages(new ArrayList<Page>(size));
+ rollbackDeletes = new Page.PageSet();
+ rollbackDeletes.setPages(new ArrayList<Page>());
+ for (Page src : data.getPages())
+ {
+ dst.getPages().add(src);
+
+ Page found = findPage(existingPages, src);
+ if (found == null)
+ {
+ rollbackDeletes.getPages().add(src);
+ }
+ else
+ {
+ rollbackSaves.getPages().add(found);
+ }
+ }
+ }
+ break;
+ case OVERWRITE:
+ if (size == 0)
+ {
+ dst = data;
+ rollbackDeletes = data;
+ }
+ else
+ {
+ List<Page> existingPages = list.getAll();
+ rollbackSaves = new Page.PageSet();
+ rollbackSaves.setPages(new ArrayList<Page>(size));
+ rollbackDeletes = new Page.PageSet();
+ rollbackDeletes.setPages(new ArrayList<Page>());
+ for (Page page : existingPages)
+ {
+ dataStorage.remove(page);
+ dataStorage.save();
+ rollbackSaves.getPages().add(page);
+ }
+ for (Page src : data.getPages())
+ {
+ Page found = findPage(rollbackSaves.getPages(), src);
+ if (found == null)
+ {
+ rollbackDeletes.getPages().add(src);
+ }
+ }
+
+ dst = data;
+ }
+ break;
+ }
+
+ if (dst != null)
+ {
+ for (Page page : dst.getPages())
+ {
+ dataStorage.save(page);
+ dataStorage.save();
+ }
+ }
+ }
+
+ @Override
+ public void rollback() throws Exception
+ {
+ if (rollbackDeletes != null && !rollbackDeletes.getPages().isEmpty())
+ {
+ for (Page page : rollbackDeletes.getPages())
+ {
+ dataStorage.remove(page);
+ dataStorage.save();
+ }
+ }
+ if (rollbackSaves != null && !rollbackSaves.getPages().isEmpty())
+ {
+ for (Page page : rollbackSaves.getPages())
+ {
+ dataStorage.save(page);
+ dataStorage.save();
+ }
+ }
+ }
+
+ Page.PageSet getRollbackSaves()
+ {
+ return rollbackSaves;
+ }
+
+ Page.PageSet getRollbackDeletes()
+ {
+ return rollbackDeletes;
+ }
+
+ private Page findPage(List<Page> pages, Page src)
+ {
+ Page found = null;
+ for (Page page : pages)
+ {
+ if (src.getName().equals(page.getName()))
+ {
+ found = page;
+ }
+ }
+ return found;
+ }
+}
Added: portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/SiteLayoutExportTask.java
===================================================================
--- portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/SiteLayoutExportTask.java (rev 0)
+++ portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/SiteLayoutExportTask.java 2011-07-26 21:14:24 UTC (rev 6934)
@@ -0,0 +1,77 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.exoplatform.portal.mop.management.exportimport;
+
+import org.exoplatform.portal.config.DataStorage;
+import org.exoplatform.portal.config.model.PortalConfig;
+import org.exoplatform.portal.mop.SiteKey;
+import org.exoplatform.portal.pom.config.POMSession;
+import org.exoplatform.portal.pom.config.tasks.PortalConfigTask;
+import org.exoplatform.portal.pom.data.PortalData;
+import org.exoplatform.portal.pom.data.PortalKey;
+import org.gatein.management.api.binding.Marshaller;
+import org.gatein.management.api.operation.model.ExportTask;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class SiteLayoutExportTask extends AbstractExportTask implements ExportTask
+{
+ public static final String FILE = "portal.xml";
+
+ private final DataStorage dataStorage;
+ private final Marshaller<PortalConfig> marshaller;
+
+ public SiteLayoutExportTask(SiteKey siteKey, DataStorage dataStorage, Marshaller<PortalConfig> marshaller)
+ {
+ super(siteKey);
+ this.dataStorage = dataStorage;
+ this.marshaller = marshaller;
+ }
+
+ @Override
+ protected String getXmlFileName()
+ {
+ return FILE;
+ }
+
+ @Override
+ public void export(OutputStream outputStream) throws IOException
+ {
+ PortalConfig portalConfig;
+ try
+ {
+ portalConfig = dataStorage.getPortalConfig(siteKey.getTypeName(), siteKey.getName());
+ }
+ catch (Exception e)
+ {
+ throw new IOException("Could not retrieve site " + siteKey, e);
+ }
+
+ marshaller.marshal(portalConfig, outputStream);
+ }
+}
Added: portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/SiteLayoutImportTask.java
===================================================================
--- portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/SiteLayoutImportTask.java (rev 0)
+++ portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/SiteLayoutImportTask.java 2011-07-26 21:14:24 UTC (rev 6934)
@@ -0,0 +1,106 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.exoplatform.portal.mop.management.exportimport;
+
+import org.exoplatform.portal.config.DataStorage;
+import org.exoplatform.portal.config.model.PortalConfig;
+import org.exoplatform.portal.mop.SiteKey;
+import org.exoplatform.portal.pom.data.ModelDataStorage;
+import org.exoplatform.portal.pom.data.PortalData;
+import org.exoplatform.portal.pom.data.PortalKey;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class SiteLayoutImportTask extends AbstractImportTask<PortalConfig>
+{
+ private final DataStorage dataStorage;
+ private PortalConfig rollbackDelete;
+ private PortalConfig rollbackSave;
+
+ public SiteLayoutImportTask(PortalConfig data, SiteKey siteKey, DataStorage dataStorage)
+ {
+ super(data, siteKey);
+ this.dataStorage = dataStorage;
+ }
+
+ @Override
+ public void importData(ImportStrategy importStrategy) throws Exception
+ {
+ PortalConfig dst = dataStorage.getPortalConfig(siteKey.getTypeName(), siteKey.getName());
+
+ switch (importStrategy)
+ {
+ // Really doesn't make sense to "merge" site layout data. Really two modes, conserve (keep) and overwrite.
+ case CONSERVE:
+ if (dst == null)
+ {
+ dst = data;
+ rollbackDelete = data;
+ }
+ else
+ {
+ dst = null;
+ }
+ break;
+ case MERGE:
+ case OVERWRITE:
+ if (dst == null)
+ {
+ rollbackDelete = data;
+ }
+ else
+ {
+ rollbackSave = dst;
+ }
+ dst = data;
+ break;
+ }
+
+ if (dst != null)
+ {
+ if (rollbackDelete == null)
+ {
+ dataStorage.save(dst);
+ }
+ else
+ {
+ dataStorage.create(dst);
+ }
+ }
+ }
+
+ @Override
+ public void rollback() throws Exception
+ {
+ if (rollbackDelete != null)
+ {
+ dataStorage.remove(rollbackDelete);
+ }
+ else if (rollbackSave != null)
+ {
+ dataStorage.save(rollbackSave);
+ }
+ }
+}
Added: portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/model/PageDataContainer.java
===================================================================
--- portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/model/PageDataContainer.java (rev 0)
+++ portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/model/PageDataContainer.java 2011-07-26 21:14:24 UTC (rev 6934)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.exoplatform.portal.mop.management.model;
+
+import org.exoplatform.portal.pom.data.PageData;
+
+import java.util.List;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class PageDataContainer
+{
+ private List<PageData> pages;
+
+ public PageDataContainer(List<PageData> pages)
+ {
+ this.pages = pages;
+ }
+
+ public List<PageData> getPages()
+ {
+ return pages;
+ }
+}
Added: portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/AbstractMopOperationHandler.java
===================================================================
--- portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/AbstractMopOperationHandler.java (rev 0)
+++ portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/AbstractMopOperationHandler.java 2011-07-26 21:14:24 UTC (rev 6934)
@@ -0,0 +1,88 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.exoplatform.portal.mop.management.operations;
+
+import org.exoplatform.portal.mop.SiteKey;
+import org.exoplatform.portal.mop.SiteType;
+import org.exoplatform.portal.pom.config.POMSession;
+import org.exoplatform.portal.pom.config.POMSessionManager;
+import org.gatein.management.api.PathAddress;
+import org.gatein.management.api.exceptions.OperationException;
+import org.gatein.management.api.exceptions.ResourceNotFoundException;
+import org.gatein.management.api.operation.OperationContext;
+import org.gatein.management.api.operation.OperationHandler;
+import org.gatein.management.api.operation.ResultHandler;
+import org.gatein.mop.api.workspace.ObjectType;
+import org.gatein.mop.api.workspace.Site;
+import org.gatein.mop.api.workspace.Workspace;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public abstract class AbstractMopOperationHandler implements OperationHandler
+{
+ @Override
+ public final void execute(OperationContext operationContext, ResultHandler resultHandler) throws ResourceNotFoundException, OperationException
+ {
+ String operationName = operationContext.getOperationName();
+ PathAddress address = operationContext.getAddress();
+
+ String siteType = address.resolvePathTemplate("site-type");
+ if (siteType == null) throw new OperationException(operationName, "Site type was not specified.");
+
+ ObjectType<Site> objectType = Utils.getObjectType(Utils.getSiteType(siteType));
+ if (objectType == null)
+ {
+ throw new ResourceNotFoundException("No site type found for " + siteType);
+ }
+
+ POMSessionManager mgr = operationContext.getRuntimeContext().getRuntimeComponent(POMSessionManager.class);
+ POMSession session = mgr.getSession();
+ if (session == null) throw new OperationException(operationName, "MOP session was null");
+
+ Workspace workspace = session.getWorkspace();
+ if (workspace == null) throw new OperationException(operationName, "MOP workspace was null");
+
+ execute(operationContext, resultHandler, workspace, objectType);
+ }
+
+ protected abstract void execute(OperationContext operationContext, ResultHandler resultHandler,
+ Workspace workspace, ObjectType<Site> siteType) throws ResourceNotFoundException, OperationException;
+
+
+ protected SiteType getSiteType(ObjectType<? extends Site> objectType)
+ {
+ return Utils.getSiteType(objectType);
+ }
+
+ protected SiteKey getSiteKey(ObjectType<? extends Site> objectType, String name)
+ {
+ return Utils.siteKey(Utils.getSiteType(objectType), name);
+ }
+
+ protected SiteKey getSiteKey(Site site)
+ {
+ return getSiteKey(site.getObjectType(), site.getName());
+ }
+}
Added: portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/MopImportResource.java
===================================================================
--- portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/MopImportResource.java (rev 0)
+++ portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/MopImportResource.java 2011-07-26 21:14:24 UTC (rev 6934)
@@ -0,0 +1,343 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.exoplatform.portal.mop.management.operations;
+
+import org.exoplatform.portal.config.DataStorage;
+import org.exoplatform.portal.config.model.Page;
+import org.exoplatform.portal.config.model.PageNavigation;
+import org.exoplatform.portal.config.model.PortalConfig;
+import org.exoplatform.portal.mop.SiteKey;
+import org.exoplatform.portal.mop.description.DescriptionService;
+import org.exoplatform.portal.mop.management.exportimport.ImportStrategy;
+import org.exoplatform.portal.mop.management.exportimport.NavigationExportTask;
+import org.exoplatform.portal.mop.management.exportimport.NavigationImportTask;
+import org.exoplatform.portal.mop.management.exportimport.PageExportTask;
+import org.exoplatform.portal.mop.management.exportimport.PageImportTask;
+import org.exoplatform.portal.mop.management.exportimport.SiteLayoutExportTask;
+import org.exoplatform.portal.mop.management.exportimport.SiteLayoutImportTask;
+import org.exoplatform.portal.mop.navigation.NavigationService;
+import org.exoplatform.portal.pom.config.POMSession;
+import org.exoplatform.portal.pom.config.POMSessionManager;
+import org.gatein.common.logging.Logger;
+import org.gatein.common.logging.LoggerFactory;
+import org.gatein.management.api.ContentType;
+import org.gatein.management.api.binding.Marshaller;
+import org.gatein.management.api.exceptions.OperationException;
+import org.gatein.management.api.exceptions.ResourceNotFoundException;
+import org.gatein.management.api.operation.OperationAttachment;
+import org.gatein.management.api.operation.OperationContext;
+import org.gatein.management.api.operation.OperationHandler;
+import org.gatein.management.api.operation.ResultHandler;
+import org.gatein.management.api.operation.model.NoResultModel;
+import org.gatein.mop.api.workspace.Workspace;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class MopImportResource implements OperationHandler
+{
+ private static final Logger log = LoggerFactory.getLogger(MopImportResource.class);
+
+ //TODO: Would like to see the step operations be handled by mgmt core.
+
+ //TODO: Clean this up when we have time
+ @Override
+ public void execute(final OperationContext operationContext, ResultHandler resultHandler) throws ResourceNotFoundException, OperationException
+ {
+ final String operationName = operationContext.getOperationName();
+
+ OperationAttachment attachment = operationContext.getAttachment(true);
+ if (attachment == null) throw new OperationException(operationContext.getOperationName(), "No attachment available for MOP import.");
+
+ InputStream inputStream = attachment.getStream();
+ if (inputStream == null) throw new OperationException(operationContext.getOperationName(), "No data stream available for import.");
+
+ POMSessionManager mgr = operationContext.getRuntimeContext().getRuntimeComponent(POMSessionManager.class);
+ POMSession session = mgr.getSession();
+ if (session == null) throw new OperationException(operationName, "MOP session was null");
+
+ Workspace workspace = session.getWorkspace();
+ if (workspace == null) throw new OperationException(operationName, "MOP workspace was null");
+
+ DataStorage dataStorage = operationContext.getRuntimeContext().getRuntimeComponent(DataStorage.class);
+ if (dataStorage == null) throw new OperationException(operationName, "DataStorage was null");
+
+ NavigationService navigationService = operationContext.getRuntimeContext().getRuntimeComponent(NavigationService.class);
+ if (navigationService == null) throw new OperationException(operationName, "Navigation service was null");
+
+ DescriptionService descriptionService = operationContext.getRuntimeContext().getRuntimeComponent(DescriptionService.class);
+ if (descriptionService == null) throw new OperationException(operationName, "Description service was null");
+
+ String strategyAttribute = operationContext.getAttributes().getValue("import-strategy");
+ ImportStrategy strategy = ImportStrategy.MERGE;
+ if (strategyAttribute != null)
+ {
+ strategy = ImportStrategy.forName(strategyAttribute);
+ if (strategy == null) throw new OperationException(operationName, "Unknown import strategy " + strategyAttribute);
+ }
+
+ Map<SiteKey, MopImport> importMap = new HashMap<SiteKey, MopImport>();
+ final NonCloseableZipInputStream zis = new NonCloseableZipInputStream(inputStream);
+ ZipEntry entry;
+ try
+ {
+ log.info("Preparing data for import.");
+ while ( (entry = zis.getNextEntry()) != null)
+ {
+ // Skip directories
+ if (entry.isDirectory()) continue;
+
+ // Parse zip entry
+ String[] parts = parseEntry(entry);
+ SiteKey siteKey = Utils.siteKey(parts[0], parts[1]);
+ String file = parts[2];
+
+ MopImport mopImport = importMap.get(siteKey);
+ if (mopImport == null)
+ {
+ mopImport = new MopImport();
+ importMap.put(siteKey, mopImport);
+ }
+
+ if (file.equals(SiteLayoutExportTask.FILE))
+ {
+ // Unmarshal site layout data
+ Marshaller<PortalConfig> marshaller = operationContext.getBindingProvider().getMarshaller(PortalConfig.class, ContentType.XML);
+ PortalConfig portalConfig = marshaller.unmarshal(zis);
+ portalConfig.setType(siteKey.getTypeName());
+ if (!portalConfig.getName().equals(siteKey.getName()))
+ {
+ throw new OperationException(operationName, "Name of site does not match that of the zip entry site name.");
+ }
+
+ // Add import task to run later
+ mopImport.siteTask = new SiteLayoutImportTask(portalConfig, siteKey, dataStorage);
+ }
+ else if (file.equals(PageExportTask.FILE))
+ {
+ // Unmarshal page data
+ Marshaller<Page.PageSet> marshaller = operationContext.getBindingProvider().getMarshaller(Page.PageSet.class, ContentType.XML);
+ Page.PageSet pages = marshaller.unmarshal(zis);
+ for (Page page : pages.getPages())
+ {
+ page.setOwnerType(siteKey.getTypeName());
+ page.setOwnerId(siteKey.getName());
+ }
+
+ // Add import task to run later.
+ mopImport.pageTask = new PageImportTask(pages, siteKey, dataStorage);
+ }
+ else if (file.equals(NavigationExportTask.FILE))
+ {
+ // Unmarshal navigation data
+ Marshaller<PageNavigation> marshaller = operationContext.getBindingProvider().getMarshaller(PageNavigation.class, ContentType.XML);
+ PageNavigation navigation = marshaller.unmarshal(zis);
+ navigation.setOwnerType(siteKey.getTypeName());
+ navigation.setOwnerId(siteKey.getName());
+
+ // Add import task to run later
+ mopImport.navigationTask = new NavigationImportTask(navigation, siteKey, navigationService, descriptionService, dataStorage);
+ }
+ }
+
+ resultHandler.completed(NoResultModel.INSTANCE);
+ }
+ catch (Throwable t)
+ {
+ throw new OperationException(operationContext.getOperationName(), "Exception reading data for import.", t);
+ }
+ finally
+ {
+ try
+ {
+ zis.reallyClose();
+ }
+ catch (IOException e)
+ {
+ log.warn("Exception closing underlying data stream from import.");
+ }
+ }
+
+ // Perform import
+ Map<SiteKey, MopImport> completedImportMap = new HashMap<SiteKey, MopImport>();
+ try
+ {
+ log.info("Performing import using strategy '" + strategy.getName() + "'");
+ for (Map.Entry<SiteKey, MopImport> mopImportEntry : importMap.entrySet())
+ {
+ SiteKey siteKey = mopImportEntry.getKey();
+ MopImport mopImport = mopImportEntry.getValue();
+ MopImport completed = new MopImport();
+
+ if (completedImportMap.containsKey(siteKey))
+ {
+ throw new IllegalStateException("Multiple site imports for same operation.");
+ }
+ completedImportMap.put(siteKey, completed);
+
+ log.debug("Importing data for site " + siteKey);
+
+ // Site layout import
+ if (mopImport.siteTask != null)
+ {
+ log.debug("Importing site layout data.");
+ mopImport.siteTask.importData(strategy);
+ completed.siteTask = mopImport.siteTask;
+ }
+
+ // Page import
+ if (mopImport.pageTask != null)
+ {
+ log.debug("Importing page data.");
+ mopImport.pageTask.importData(strategy);
+ completed.pageTask = mopImport.pageTask;
+ }
+
+ // Navigation import
+ if (mopImport.navigationTask != null)
+ {
+ log.debug("Importing navigation data.");
+ mopImport.navigationTask.importData(strategy);
+ completed.navigationTask = mopImport.navigationTask;
+ }
+ }
+ log.info("Import successful !");
+ }
+ catch (Throwable t)
+ {
+ boolean rollbackSuccess = true;
+ log.error("Exception importing data.", t);
+ log.info("Attempting to rollback data modified by import.");
+ for (Map.Entry<SiteKey, MopImport> mopImportEntry : completedImportMap.entrySet())
+ {
+ SiteKey siteKey = mopImportEntry.getKey();
+ MopImport mopImport = mopImportEntry.getValue();
+
+ log.debug("Rolling back imported data for site " + siteKey);
+ if (mopImport.navigationTask != null)
+ {
+ log.debug("Rolling back navigation modified during import...");
+ try
+ {
+ mopImport.navigationTask.rollback();
+ }
+ catch (Throwable t1) // Continue rolling back even though there are exceptions.
+ {
+ rollbackSuccess = false;
+ log.error("Error rolling back navigation data for site " + siteKey, t1);
+ }
+ }
+ if (mopImport.pageTask != null)
+ {
+ log.debug("Rolling back pages modified during import...");
+ try
+ {
+ mopImport.pageTask.rollback();
+ }
+ catch (Throwable t1) // Continue rolling back even though there are exceptions.
+ {
+ rollbackSuccess = false;
+ log.error("Error rolling back page data for site " + siteKey, t1);
+ }
+ }
+ if (mopImport.siteTask != null)
+ {
+ log.debug("Rolling back site layout modified during import...");
+ try
+ {
+ mopImport.siteTask.rollback();
+ }
+ catch (Throwable t1) // Continue rolling back even though there are exceptions.
+ {
+ rollbackSuccess = false;
+ log.error("Error rolling back site layout for site " + siteKey, t1);
+ }
+ }
+ }
+
+ String message = (rollbackSuccess) ?
+ "Error during import. Tasks successfully rolled back. Portal should be back to consistent state." :
+ "Error during import. Errors in rollback as well. Portal may be in an inconsistent state.";
+
+ throw new OperationException(operationName, message, t);
+ }
+ finally
+ {
+ importMap.clear();
+ completedImportMap.clear();
+ }
+ }
+
+ private static String[] parseEntry(ZipEntry entry) throws IOException
+ {
+ String name = entry.getName();
+ if (name.endsWith(SiteLayoutExportTask.FILE) || name.endsWith(PageExportTask.FILE) || name.endsWith(NavigationExportTask.FILE))
+ {
+ String[] parts = new String[3];
+ parts[0] = name.substring(0, name.indexOf("/"));
+ parts[1] = name.substring(parts[0].length() + 1, name.lastIndexOf("/"));
+ parts[2] = name.substring(name.lastIndexOf("/") + 1);
+ return parts;
+ }
+ else
+ {
+ throw new IOException("Unknown entry " + name + " in zip file.");
+ }
+ }
+
+ // Bug in SUN's JDK XMLStreamReader implementation closes the underlying stream when
+ // it finishes reading an XML document. This is no good when we are using a ZipInputStream.
+ // See http://bugs.sun.com/view_bug.do?bug_id=6539065 for more information.
+ private static class NonCloseableZipInputStream extends ZipInputStream
+ {
+ private NonCloseableZipInputStream(InputStream inputStream)
+ {
+ super(inputStream);
+ }
+
+ @Override
+ public void close() throws IOException
+ {
+ }
+
+ private void reallyClose() throws IOException
+ {
+ super.close();
+ }
+ }
+
+ private static class MopImport
+ {
+ private SiteLayoutImportTask siteTask;
+ private PageImportTask pageTask;
+ private NavigationImportTask navigationTask;
+ }
+}
Added: portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/MopReadResource.java
===================================================================
--- portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/MopReadResource.java (rev 0)
+++ portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/MopReadResource.java 2011-07-26 21:14:24 UTC (rev 6934)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.exoplatform.portal.mop.management.operations;
+
+import org.gatein.management.api.exceptions.OperationException;
+import org.gatein.management.api.operation.model.ReadResourceModel;
+import org.gatein.management.api.operation.OperationContext;
+import org.gatein.management.api.operation.OperationHandler;
+import org.gatein.management.api.operation.ResultHandler;
+
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class MopReadResource implements OperationHandler
+{
+ @Override
+ public void execute(OperationContext operationContext, ResultHandler resultHandler) throws OperationException
+ {
+ Set<String> children = new LinkedHashSet<String>(3);
+ children.add("portalsites");
+ children.add("groupsites");
+ children.add("usersites");
+
+ resultHandler.completed(new ReadResourceModel("Available site types.", children));
+ }
+}
Added: portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/Utils.java
===================================================================
--- portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/Utils.java (rev 0)
+++ portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/Utils.java 2011-07-26 21:14:24 UTC (rev 6934)
@@ -0,0 +1,111 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.exoplatform.portal.mop.management.operations;
+
+import org.exoplatform.portal.mop.SiteKey;
+import org.exoplatform.portal.mop.SiteType;
+import org.gatein.mop.api.workspace.ObjectType;
+import org.gatein.mop.api.workspace.Site;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class Utils
+{
+
+ private Utils()
+ {
+ }
+
+ public static ObjectType<Site> getObjectType(SiteType siteType)
+ {
+ switch (siteType)
+ {
+ case PORTAL:
+ return ObjectType.PORTAL_SITE;
+ case GROUP:
+ return ObjectType.GROUP_SITE;
+ case USER:
+ return ObjectType.USER_SITE;
+ default:
+ return null;
+ }
+ }
+
+ public static SiteType getSiteType(ObjectType<? extends Site> objectType)
+ {
+ if (ObjectType.PORTAL_SITE == objectType)
+ {
+ return SiteType.PORTAL;
+ }
+ else if (ObjectType.GROUP_SITE == objectType)
+ {
+ return SiteType.GROUP;
+ }
+ else if (ObjectType.USER_SITE == objectType)
+ {
+ return SiteType.USER;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public static SiteType getSiteType(String siteType)
+ {
+ if (siteType == null) return null;
+
+ return SiteType.valueOf(siteType.toUpperCase());
+ }
+
+
+ public static SiteKey siteKey(String siteType, String siteName)
+ {
+ SiteType st = getSiteType(siteType);
+ return siteKey(st, siteName);
+ }
+
+ public static SiteKey siteKey(SiteType siteType, String siteName)
+ {
+ switch (siteType)
+ {
+ case PORTAL:
+ return SiteKey.portal(siteName);
+ case GROUP:
+ if (siteName.charAt(0) != '/') siteName = "/" + siteName;
+ return SiteKey.group(siteName);
+ case USER:
+ return SiteKey.user(siteName);
+ default:
+ return null;
+
+ }
+ }
+
+ public static SiteKey siteKey(Site site)
+ {
+ return siteKey(getSiteType(site.getObjectType()), site.getName());
+ }
+}
Added: portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/AbstractNavigationOperationHandler.java
===================================================================
--- portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/AbstractNavigationOperationHandler.java (rev 0)
+++ portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/AbstractNavigationOperationHandler.java 2011-07-26 21:14:24 UTC (rev 6934)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.exoplatform.portal.mop.management.operations.navigation;
+
+import org.exoplatform.portal.mop.management.operations.site.AbstractSiteOperationHandler;
+import org.gatein.management.api.exceptions.OperationException;
+import org.gatein.management.api.exceptions.ResourceNotFoundException;
+import org.gatein.management.api.operation.OperationContext;
+import org.gatein.management.api.operation.ResultHandler;
+import org.gatein.mop.api.workspace.Navigation;
+import org.gatein.mop.api.workspace.Site;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public abstract class AbstractNavigationOperationHandler extends AbstractSiteOperationHandler
+{
+ @Override
+ protected void execute(OperationContext operationContext, ResultHandler resultHandler, Site site) throws ResourceNotFoundException, OperationException
+ {
+ Navigation navigation = site.getRootNavigation().getChild("default");
+ if (navigation == null) throw new ResourceNotFoundException("Navigation does not exist for site " + getSiteKey(site));
+
+ execute(operationContext, resultHandler, navigation);
+ }
+
+ protected abstract void execute(OperationContext operationContext, ResultHandler resultHandler, Navigation defaultNavigation);
+}
Added: portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationExportResource.java
===================================================================
--- portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationExportResource.java (rev 0)
+++ portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationExportResource.java 2011-07-26 21:14:24 UTC (rev 6934)
@@ -0,0 +1,63 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.exoplatform.portal.mop.management.operations.navigation;
+
+import org.exoplatform.portal.config.model.PageNavigation;
+import org.exoplatform.portal.mop.SiteKey;
+import org.exoplatform.portal.mop.description.DescriptionService;
+import org.exoplatform.portal.mop.management.exportimport.NavigationExportTask;
+import org.exoplatform.portal.mop.navigation.NavigationService;
+import org.gatein.management.api.ContentType;
+import org.gatein.management.api.binding.BindingProvider;
+import org.gatein.management.api.binding.Marshaller;
+import org.gatein.management.api.exceptions.OperationException;
+import org.gatein.management.api.exceptions.ResourceNotFoundException;
+import org.gatein.management.api.operation.OperationContext;
+import org.gatein.management.api.operation.ResultHandler;
+import org.gatein.management.api.operation.model.ExportResourceModel;
+import org.gatein.mop.api.workspace.Navigation;
+import org.gatein.mop.api.workspace.Site;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class NavigationExportResource extends AbstractNavigationOperationHandler
+{
+ @Override
+ protected void execute(OperationContext operationContext, ResultHandler resultHandler, Navigation navigation) throws ResourceNotFoundException, OperationException
+ {
+ Site site = navigation.getSite();
+ String navUri = operationContext.getAddress().resolvePathTemplate("nav-uri");
+ SiteKey siteKey = getSiteKey(site);
+
+ DescriptionService descriptionService = operationContext.getRuntimeContext().getRuntimeComponent(DescriptionService.class);
+ NavigationService navigationService = operationContext.getRuntimeContext().getRuntimeComponent(NavigationService.class);
+ BindingProvider bindingProvider = operationContext.getBindingProvider();
+ Marshaller<PageNavigation> marshaller = bindingProvider.getMarshaller(PageNavigation.class, ContentType.XML);
+
+ NavigationExportTask exportTask = new NavigationExportTask(new NavigationKey(siteKey, navUri), navigationService, descriptionService, marshaller);
+
+ resultHandler.completed(new ExportResourceModel(exportTask));
+ }
+}
Added: portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationKey.java
===================================================================
--- portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationKey.java (rev 0)
+++ portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationKey.java 2011-07-26 21:14:24 UTC (rev 6934)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.exoplatform.portal.mop.management.operations.navigation;
+
+import org.exoplatform.portal.mop.SiteKey;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class NavigationKey
+{
+ private SiteKey siteKey;
+ private String navUri;
+
+ public NavigationKey(SiteKey siteKey)
+ {
+ this.siteKey = siteKey;
+ }
+
+ public NavigationKey(SiteKey siteKey, String navUri)
+ {
+ this.siteKey = siteKey;
+ this.navUri = navUri;
+ }
+
+ public SiteKey getSiteKey()
+ {
+ return siteKey;
+ }
+
+ public String getNavUri()
+ {
+ return navUri;
+ }
+}
Added: portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationReadResource.java
===================================================================
--- portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationReadResource.java (rev 0)
+++ portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationReadResource.java 2011-07-26 21:14:24 UTC (rev 6934)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.exoplatform.portal.mop.management.operations.navigation;
+
+import org.exoplatform.portal.config.model.PageNavigation;
+import org.exoplatform.portal.mop.SiteKey;
+import org.exoplatform.portal.mop.description.DescriptionService;
+import org.exoplatform.portal.mop.navigation.NavigationService;
+import org.gatein.management.api.exceptions.ResourceNotFoundException;
+import org.gatein.management.api.operation.OperationContext;
+import org.gatein.management.api.operation.ResultHandler;
+import org.gatein.mop.api.workspace.Navigation;
+import org.gatein.mop.api.workspace.Site;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class NavigationReadResource extends AbstractNavigationOperationHandler
+{
+ @Override
+ protected void execute(OperationContext operationContext, ResultHandler resultHandler, Navigation navigation)
+ {
+ String navUri = operationContext.getAddress().resolvePathTemplate("nav-uri");
+
+ Site site = navigation.getSite();
+ SiteKey siteKey = getSiteKey(site);
+
+ //TODO: If there's any benefit in creating our own node model to use with navigation service, lets do it
+
+ DescriptionService descriptionService = operationContext.getRuntimeContext().getRuntimeComponent(DescriptionService.class);
+ NavigationService navigationService = operationContext.getRuntimeContext().getRuntimeComponent(NavigationService.class);
+
+ PageNavigation pageNavigation = PageNavigationUtils.loadPageNavigation(new NavigationKey(siteKey, navUri), navigationService, descriptionService);
+ if (pageNavigation == null) throw new ResourceNotFoundException("Navigation node " + navUri + " not found.");
+
+ resultHandler.completed(pageNavigation);
+ }
+}
Added: portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/PageNavigationUtils.java
===================================================================
--- portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/PageNavigationUtils.java (rev 0)
+++ portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/PageNavigationUtils.java 2011-07-26 21:14:24 UTC (rev 6934)
@@ -0,0 +1,186 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.exoplatform.portal.mop.management.operations.navigation;
+
+import org.exoplatform.portal.config.model.I18NString;
+import org.exoplatform.portal.config.model.LocalizedString;
+import org.exoplatform.portal.config.model.NavigationFragment;
+import org.exoplatform.portal.config.model.PageNavigation;
+import org.exoplatform.portal.config.model.PageNode;
+import org.exoplatform.portal.mop.Described;
+import org.exoplatform.portal.mop.description.DescriptionService;
+import org.exoplatform.portal.mop.navigation.NavigationContext;
+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.Scope;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Locale;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class PageNavigationUtils
+{
+ private PageNavigationUtils(){}
+
+ public static PageNavigation loadPageNavigation(NavigationKey key, NavigationService navigationService, DescriptionService descriptionService)
+ {
+ NodeContext<NodeContext<?>> node;
+ NavigationContext navigation = navigationService.loadNavigation(key.getSiteKey());
+ if (navigation == null) return null;
+
+ if (key.getNavUri() != null)
+ {
+ PathScope scope = new PathScope(key.getNavUri());
+ node = navigationService.loadNode(NodeModel.SELF_MODEL, navigation, scope, null);
+ if (scope.getFoundId() == null) return null;
+
+ node = node.getDescendant(scope.getFoundId());
+ return createFragmentedPageNavigation(descriptionService, navigation, node);
+ }
+ else
+ {
+ node = navigationService.loadNode(NodeModel.SELF_MODEL, navigation, Scope.ALL, null);
+ if (node == null) return null;
+
+ return createPageNavigation(descriptionService, navigation, node);
+ }
+ }
+
+ public static PageNavigation createPageNavigation(DescriptionService service, NavigationContext navigation, NodeContext<NodeContext<?>> node)
+ {
+ PageNavigation pageNavigation = new PageNavigation();
+ pageNavigation.setPriority(navigation.getState().getPriority());
+ pageNavigation.setOwnerType(navigation.getKey().getTypeName());
+ pageNavigation.setOwnerId(navigation.getKey().getName());
+
+ ArrayList<PageNode> children = new ArrayList<PageNode>(node.getNodeCount());
+ for (NodeContext<?> child : node.getNodes())
+ {
+ @SuppressWarnings("unchecked")
+ NodeContext<NodeContext<?>> childNode = (NodeContext<NodeContext<?>>) child;
+ children.add(createPageNode(service, childNode));
+ }
+
+ NavigationFragment fragment = new NavigationFragment();
+ fragment.setNodes(children);
+ pageNavigation.addFragment(fragment);
+
+ return pageNavigation;
+ }
+
+ private static PageNavigation createFragmentedPageNavigation(DescriptionService service, NavigationContext navigation, NodeContext<NodeContext<?>> node)
+ {
+ PageNavigation pageNavigation = new PageNavigation();
+ pageNavigation.setPriority(navigation.getState().getPriority());
+ pageNavigation.setOwnerType(navigation.getKey().getTypeName());
+ pageNavigation.setOwnerId(navigation.getKey().getName());
+
+ ArrayList<PageNode> children = new ArrayList<PageNode>(1);
+ children.add(createPageNode(service, node));
+
+ NavigationFragment fragment = new NavigationFragment();
+ StringBuilder parentUri = new StringBuilder("/");
+ getPath(node.getParent(), parentUri);
+ fragment.setParentURI(parentUri.toString());
+ fragment.setNodes(children);
+
+ pageNavigation.addFragment(fragment);
+
+ return pageNavigation;
+ }
+
+ private static void getPath(NodeContext<NodeContext<?>> node, StringBuilder parentUri)
+ {
+ if (node == null) return;
+ if (node.getParent() == null) return; // since "default" is the root node, we ignore it
+
+ parentUri.insert(0, node.getName()).append("/");
+ getPath(node.getParent(), parentUri);
+ }
+
+ private static PageNode createPageNode(DescriptionService service, NodeContext<NodeContext<?>> node)
+ {
+ PageNode pageNode = new PageNode();
+ pageNode.setName(node.getName());
+
+ if (node.getState().getLabel() == null)
+ {
+ Map<Locale, Described.State> descriptions = service.getDescriptions(node.getId());
+ if (descriptions != null && !descriptions.isEmpty())
+ {
+ I18NString labels = new I18NString();
+ for (Map.Entry<Locale, Described.State> entry : descriptions.entrySet())
+ {
+ labels.add(new LocalizedString(entry.getValue().getName(), entry.getKey()));
+ }
+
+ pageNode.setLabels(labels);
+ }
+ }
+ else
+ {
+ pageNode.setLabel(node.getState().getLabel());
+ }
+
+ pageNode.setIcon(node.getState().getIcon());
+ long startPublicationTime = node.getState().getStartPublicationTime();
+ if (startPublicationTime != -1)
+ {
+ pageNode.setStartPublicationDate(new Date(startPublicationTime));
+ }
+
+ long endPublicationTime = node.getState().getEndPublicationTime();
+ if (endPublicationTime != -1)
+ {
+ pageNode.setEndPublicationDate(new Date(endPublicationTime));
+ }
+
+ pageNode.setVisibility(node.getState().getVisibility());
+ pageNode.setPageReference(node.getState().getPageRef());
+
+ if (node.getNodes() != null)
+ {
+ ArrayList<PageNode> children = new ArrayList<PageNode>(node.getNodeCount());
+ for (NodeContext<?> child : node.getNodes())
+ {
+ @SuppressWarnings("unchecked")
+ NodeContext<NodeContext<?>> childNode = (NodeContext<NodeContext<?>>) child;
+ children.add(createPageNode(service, childNode));
+ }
+
+ pageNode.setChildren(children);
+ }
+ else
+ {
+ pageNode.setChildren(new ArrayList<PageNode>(0));
+ }
+
+ return pageNode;
+ }
+}
Added: portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/PathScope.java
===================================================================
--- portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/PathScope.java (rev 0)
+++ portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/PathScope.java 2011-07-26 21:14:24 UTC (rev 6934)
@@ -0,0 +1,127 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.exoplatform.portal.mop.management.operations.navigation;
+
+import org.exoplatform.portal.mop.navigation.NodeState;
+import org.exoplatform.portal.mop.navigation.Scope;
+import org.exoplatform.portal.mop.navigation.VisitMode;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class PathScope implements Scope
+{
+ private String path;
+ private String foundId;
+
+ public PathScope(String path)
+ {
+ if (path == null) throw new IllegalArgumentException("path is null.");
+ this.path = path;
+ }
+
+ @Override
+ public Visitor get()
+ {
+ final String[] segments = trim(path.split("/"));
+ return new Visitor()
+ {
+ @Override
+ public VisitMode enter(int depth, String id, String name, NodeState state)
+ {
+ if (depth == 0)
+ {
+ return VisitMode.ALL_CHILDREN;
+ }
+ assert depth > 0;
+
+ if (depth < segments.length)
+ {
+ if (name.equals(segments[depth-1]))
+ {
+ return VisitMode.ALL_CHILDREN;
+ }
+ else
+ {
+ return VisitMode.NO_CHILDREN;
+ }
+ }
+ else if (depth == segments.length)
+ {
+ if (name.equals(segments[depth-1]))
+ {
+ foundId = id;
+ return VisitMode.ALL_CHILDREN;
+ }
+ else
+ {
+ return VisitMode.NO_CHILDREN;
+ }
+ }
+ else if (depth > segments.length)
+ {
+ if (foundId != null)
+ {
+ return VisitMode.ALL_CHILDREN;
+ }
+ else
+ {
+ return VisitMode.NO_CHILDREN;
+ }
+ }
+ else
+ {
+ return VisitMode.NO_CHILDREN;
+ }
+ }
+
+ @Override
+ public void leave(int depth, String id, String name, NodeState state)
+ {
+ }
+ };
+ }
+
+ String getFoundId()
+ {
+ return foundId;
+ }
+
+ private String[] trim(String[] array)
+ {
+ List<String> trimmed = new ArrayList<String>(array.length);
+ for (String s : array)
+ {
+ if (s != null && !"".equals(s))
+ {
+ trimmed.add(s);
+ }
+ }
+
+ return trimmed.toArray(new String[trimmed.size()]);
+ }
+}
Added: portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/AbstractPageOperationHandler.java
===================================================================
--- portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/AbstractPageOperationHandler.java (rev 0)
+++ portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/AbstractPageOperationHandler.java 2011-07-26 21:14:24 UTC (rev 6934)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.exoplatform.portal.mop.management.operations.page;
+
+import org.exoplatform.portal.mop.management.operations.site.AbstractSiteOperationHandler;
+import org.gatein.management.api.exceptions.OperationException;
+import org.gatein.management.api.exceptions.ResourceNotFoundException;
+import org.gatein.management.api.operation.OperationContext;
+import org.gatein.management.api.operation.ResultHandler;
+import org.gatein.mop.api.workspace.Page;
+import org.gatein.mop.api.workspace.Site;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public abstract class AbstractPageOperationHandler extends AbstractSiteOperationHandler
+{
+ @Override
+ protected void execute(OperationContext operationContext, ResultHandler resultHandler, Site site) throws ResourceNotFoundException, OperationException
+ {
+ Page pages = site.getRootPage().getChild("pages");
+ if (pages == null || pages.getChildren().isEmpty()) throw new ResourceNotFoundException("No pages found for site " + getSiteKey(site));
+
+ execute(operationContext, resultHandler, pages);
+ }
+
+ protected abstract void execute(OperationContext operationContext, ResultHandler resultHandler, Page page) throws ResourceNotFoundException, OperationException;
+}
Added: portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/AbstractPageQueryOperation.java
===================================================================
--- portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/AbstractPageQueryOperation.java (rev 0)
+++ portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/AbstractPageQueryOperation.java 2011-07-26 21:14:24 UTC (rev 6934)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.exoplatform.portal.mop.management.operations.page;
+
+import org.exoplatform.portal.pom.data.PageData;
+import org.gatein.management.api.operation.QueryOperationHandler;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public abstract class AbstractPageQueryOperation extends QueryOperationHandler<PageData>
+{
+}
Added: portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageExportResource.java
===================================================================
--- portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageExportResource.java (rev 0)
+++ portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageExportResource.java 2011-07-26 21:14:24 UTC (rev 6934)
@@ -0,0 +1,84 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.exoplatform.portal.mop.management.operations.page;
+
+import org.exoplatform.portal.config.DataStorage;
+import org.exoplatform.portal.mop.SiteKey;
+import org.exoplatform.portal.mop.management.exportimport.PageExportTask;
+import org.gatein.management.api.ContentType;
+import org.gatein.management.api.binding.BindingProvider;
+import org.gatein.management.api.exceptions.OperationException;
+import org.gatein.management.api.exceptions.ResourceNotFoundException;
+import org.gatein.management.api.operation.OperationContext;
+import org.gatein.management.api.operation.ResultHandler;
+import org.gatein.management.api.operation.model.ExportResourceModel;
+import org.gatein.management.api.operation.model.ExportTask;
+import org.gatein.mop.api.workspace.Page;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class PageExportResource extends AbstractPageOperationHandler
+{
+ @Override
+ protected void execute(OperationContext operationContext, ResultHandler resultHandler, Page pages) throws ResourceNotFoundException, OperationException
+ {
+ SiteKey siteKey = getSiteKey(pages.getSite());
+
+ DataStorage dataStorage = operationContext.getRuntimeContext().getRuntimeComponent(DataStorage.class);
+ BindingProvider bindingProvider = operationContext.getBindingProvider();
+
+ Collection<Page> pagesList = pages.getChildren();
+ List<ExportTask> tasks = new ArrayList<ExportTask>(pagesList.size());
+ PageExportTask pageExportTask =
+ new PageExportTask(siteKey, dataStorage, bindingProvider.getMarshaller(
+ org.exoplatform.portal.config.model.Page.PageSet.class, ContentType.XML));
+
+ String pageName = operationContext.getAddress().resolvePathTemplate("page-name");
+ for (Page page : pagesList)
+ {
+ if (pageName == null)
+ {
+ pageExportTask.addPageName(page.getName());
+ }
+ else if (pageName.equals(page.getName()))
+ {
+ pageExportTask.addPageName(page.getName());
+ }
+ }
+
+ if (pageExportTask.getPageNames().isEmpty() && pageName != null)
+ {
+ throw new ResourceNotFoundException("No page found for " + new PageKey(siteKey, pageName));
+ }
+
+ tasks.add(pageExportTask);
+
+ resultHandler.completed(new ExportResourceModel(tasks));
+ }
+}
Added: portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageKey.java
===================================================================
--- portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageKey.java (rev 0)
+++ portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageKey.java 2011-07-26 21:14:24 UTC (rev 6934)
@@ -0,0 +1,43 @@
+package org.exoplatform.portal.mop.management.operations.page;
+
+import org.exoplatform.portal.mop.SiteKey;
+import org.exoplatform.portal.pom.config.Utils;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class PageKey
+{
+ private final SiteKey siteKey;
+ private final String pageName;
+ private final String pageId;
+
+ public PageKey(SiteKey siteKey, String pageName)
+ {
+ this.siteKey = siteKey;
+ this.pageName = pageName;
+ this.pageId = Utils.join("::", siteKey.getTypeName(), siteKey.getName(), pageName);
+ }
+
+ public SiteKey getSiteKey()
+ {
+ return siteKey;
+ }
+
+ public String getPageName()
+ {
+ return pageName;
+ }
+
+ public String getPageId()
+ {
+ return pageId;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "PageKey{siteKey=" + siteKey + ", pageName='" + pageName + "'}";
+ }
+}
Added: portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageReadResource.java
===================================================================
--- portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageReadResource.java (rev 0)
+++ portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageReadResource.java 2011-07-26 21:14:24 UTC (rev 6934)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.exoplatform.portal.mop.management.operations.page;
+
+import org.exoplatform.portal.config.DataStorage;
+import org.gatein.management.api.exceptions.OperationException;
+import org.gatein.management.api.exceptions.ResourceNotFoundException;
+import org.gatein.management.api.operation.OperationContext;
+import org.gatein.management.api.operation.ResultHandler;
+import org.gatein.mop.api.workspace.Page;
+
+import java.util.ArrayList;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class PageReadResource extends AbstractPageOperationHandler
+{
+ @Override
+ protected void execute(OperationContext operationContext, ResultHandler resultHandler, Page pages) throws ResourceNotFoundException, OperationException
+ {
+ String pageName = operationContext.getAddress().resolvePathTemplate("page-name");
+
+ if (pageName == null)
+ throw new OperationException(operationContext.getOperationName(), "No page name specified.");
+
+ DataStorage dataStorage = operationContext.getRuntimeContext().getRuntimeComponent(DataStorage.class);
+
+ PageKey key = new PageKey(getSiteKey(pages.getSite()), pageName);
+ try
+ {
+ org.exoplatform.portal.config.model.Page page = dataStorage.getPage(key.getPageId());
+ if (page == null)
+ {
+ throw new ResourceNotFoundException("No page found for " + key);
+ }
+ else
+ {
+ resultHandler.completed(page);
+ }
+ }
+ catch (ResourceNotFoundException nfe)
+ {
+ throw nfe;
+ }
+ catch (Exception e)
+ {
+ throw new OperationException(operationContext.getOperationName(), "Operation failed getting page for " + key, e);
+ }
+ }
+}
Added: portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageUpdateResource.java
===================================================================
--- portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageUpdateResource.java (rev 0)
+++ portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageUpdateResource.java 2011-07-26 21:14:24 UTC (rev 6934)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.exoplatform.portal.mop.management.operations.page;
+
+import org.exoplatform.portal.mop.management.model.PageDataContainer;
+import org.exoplatform.portal.pom.data.PageData;
+import org.gatein.management.api.exceptions.ResourceNotFoundException;
+import org.gatein.management.api.exceptions.OperationException;
+import org.gatein.management.api.operation.OperationContext;
+import org.gatein.management.api.operation.UpdateOperationHandler;
+
+import java.util.Collections;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class PageUpdateResource extends UpdateOperationHandler<PageData>
+{
+ private static final PagesUpdateResource delegate = new PagesUpdateResource();
+
+ @Override
+ protected void execute(OperationContext operationContext, PageData page) throws ResourceNotFoundException, OperationException
+ {
+ delegate.execute(operationContext, new PageDataContainer(Collections.singletonList(page)));
+ }
+}
Added: portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PagesReadResource.java
===================================================================
--- portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PagesReadResource.java (rev 0)
+++ portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PagesReadResource.java 2011-07-26 21:14:24 UTC (rev 6934)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.exoplatform.portal.mop.management.operations.page;
+
+import org.gatein.management.api.exceptions.OperationException;
+import org.gatein.management.api.exceptions.ResourceNotFoundException;
+import org.gatein.management.api.operation.OperationContext;
+import org.gatein.management.api.operation.ResultHandler;
+import org.gatein.management.api.operation.model.ReadResourceModel;
+import org.gatein.mop.api.workspace.Page;
+
+import java.util.Collection;
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class PagesReadResource extends AbstractPageOperationHandler
+{
+ @Override
+ protected void execute(OperationContext operationContext, ResultHandler resultHandler, Page pages) throws ResourceNotFoundException, OperationException
+ {
+ Collection<Page> pageList = pages.getChildren();
+ Set<String> children = new LinkedHashSet<String>(pageList.size());
+ for (Page page : pageList)
+ {
+ children.add(page.getName());
+ }
+
+ resultHandler.completed(new ReadResourceModel("List of pages available for given site.", children));
+ }
+}
Added: portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PagesUpdateResource.java
===================================================================
--- portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PagesUpdateResource.java (rev 0)
+++ portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PagesUpdateResource.java 2011-07-26 21:14:24 UTC (rev 6934)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.exoplatform.portal.mop.management.operations.page;
+
+import org.exoplatform.portal.mop.management.model.PageDataContainer;
+import org.exoplatform.portal.pom.data.ModelDataStorage;
+import org.exoplatform.portal.pom.data.PageData;
+import org.gatein.management.api.exceptions.ResourceNotFoundException;
+import org.gatein.management.api.exceptions.OperationException;
+import org.gatein.management.api.operation.OperationContext;
+import org.gatein.management.api.operation.UpdateOperationHandler;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class PagesUpdateResource extends UpdateOperationHandler<PageDataContainer>
+{
+ //TODO: Rollback ?
+ //TODO: Maybe use an import api and execute on input stream. See if we can use only mop api's.
+
+ @Override
+ protected void execute(OperationContext operationContext, PageDataContainer pages) throws ResourceNotFoundException, OperationException
+ {
+ ModelDataStorage dataStorage = operationContext.getRuntimeContext().getRuntimeComponent(ModelDataStorage.class);
+ for (PageData page : pages.getPages())
+ {
+ try
+ {
+ //dataStorage.save(page);
+ }
+ catch (Exception e)
+ {
+ throw new OperationException(operationContext.getOperationName(), "Could not update page for address " + operationContext.getAddress(), e);
+ }
+ }
+ }
+}
Added: portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/AbstractSiteOperationHandler.java
===================================================================
--- portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/AbstractSiteOperationHandler.java (rev 0)
+++ portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/AbstractSiteOperationHandler.java 2011-07-26 21:14:24 UTC (rev 6934)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.exoplatform.portal.mop.management.operations.site;
+
+import org.exoplatform.portal.mop.SiteKey;
+import org.exoplatform.portal.mop.management.operations.AbstractMopOperationHandler;
+import org.gatein.management.api.PathAddress;
+import org.gatein.management.api.exceptions.OperationException;
+import org.gatein.management.api.exceptions.ResourceNotFoundException;
+import org.gatein.management.api.operation.OperationContext;
+import org.gatein.management.api.operation.ResultHandler;
+import org.gatein.mop.api.workspace.ObjectType;
+import org.gatein.mop.api.workspace.Site;
+import org.gatein.mop.api.workspace.Workspace;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public abstract class AbstractSiteOperationHandler extends AbstractMopOperationHandler
+{
+ @Override
+ protected final void execute(OperationContext operationContext, ResultHandler resultHandler, Workspace workspace, ObjectType<Site> siteType) throws ResourceNotFoundException, OperationException
+ {
+ String operationName = operationContext.getOperationName();
+ PathAddress address = operationContext.getAddress();
+
+ String siteName = address.resolvePathTemplate("site-name");
+ if (siteName == null) throw new OperationException(operationName, "No site name specified.");
+
+ SiteKey siteKey = getSiteKey(siteType, siteName);
+
+ Site site = workspace.getSite(siteType, siteKey.getName());
+ if (site == null) throw new ResourceNotFoundException("No site found for site " + siteKey);
+
+ execute(operationContext, resultHandler, site);
+ }
+
+ protected abstract void execute(OperationContext operationContext, ResultHandler resultHandler, Site site) throws ResourceNotFoundException, OperationException;
+}
Added: portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteLayoutExportResource.java
===================================================================
--- portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteLayoutExportResource.java (rev 0)
+++ portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteLayoutExportResource.java 2011-07-26 21:14:24 UTC (rev 6934)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.exoplatform.portal.mop.management.operations.site;
+
+import org.exoplatform.portal.config.DataStorage;
+import org.exoplatform.portal.config.model.PortalConfig;
+import org.exoplatform.portal.mop.SiteKey;
+import org.exoplatform.portal.mop.management.exportimport.SiteLayoutExportTask;
+import org.exoplatform.portal.pom.config.POMSession;
+import org.exoplatform.portal.pom.config.POMSessionManager;
+import org.exoplatform.portal.pom.data.PortalData;
+import org.gatein.management.api.ContentType;
+import org.gatein.management.api.binding.BindingProvider;
+import org.gatein.management.api.exceptions.OperationException;
+import org.gatein.management.api.exceptions.ResourceNotFoundException;
+import org.gatein.management.api.operation.OperationContext;
+import org.gatein.management.api.operation.ResultHandler;
+import org.gatein.management.api.operation.model.ExportResourceModel;
+import org.gatein.mop.api.workspace.Site;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class SiteLayoutExportResource extends AbstractSiteOperationHandler
+{
+ @Override
+ protected void execute(OperationContext operationContext, ResultHandler resultHandler, Site site) throws ResourceNotFoundException, OperationException
+ {
+ BindingProvider bindingProvider = operationContext.getBindingProvider();
+ DataStorage dataStorage = operationContext.getRuntimeContext().getRuntimeComponent(DataStorage.class);
+
+ SiteKey siteKey = getSiteKey(site);
+
+ resultHandler.completed(new ExportResourceModel(new SiteLayoutExportTask(siteKey, dataStorage, bindingProvider.getMarshaller(PortalConfig.class, ContentType.XML))));
+ }
+}
Added: portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteLayoutReadResource.java
===================================================================
--- portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteLayoutReadResource.java (rev 0)
+++ portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteLayoutReadResource.java 2011-07-26 21:14:24 UTC (rev 6934)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.exoplatform.portal.mop.management.operations.site;
+
+import org.exoplatform.portal.config.DataStorage;
+import org.exoplatform.portal.config.model.PortalConfig;
+import org.exoplatform.portal.mop.SiteKey;
+import org.exoplatform.portal.pom.config.POMSessionManager;
+import org.exoplatform.portal.pom.config.tasks.PortalConfigTask;
+import org.exoplatform.portal.pom.data.PortalData;
+import org.exoplatform.portal.pom.data.PortalKey;
+import org.gatein.management.api.exceptions.OperationException;
+import org.gatein.management.api.exceptions.ResourceNotFoundException;
+import org.gatein.management.api.operation.OperationContext;
+import org.gatein.management.api.operation.ResultHandler;
+import org.gatein.mop.api.workspace.Site;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class SiteLayoutReadResource extends AbstractSiteOperationHandler
+{
+ @Override
+ protected void execute(OperationContext operationContext, ResultHandler resultHandler, Site site) throws ResourceNotFoundException, OperationException
+ {
+ DataStorage dataStorage = operationContext.getRuntimeContext().getRuntimeComponent(DataStorage.class);
+ SiteKey siteKey = getSiteKey(site);
+
+ try
+ {
+ PortalConfig portalConfig = dataStorage.getPortalConfig(siteKey.getTypeName(), siteKey.getName());
+ resultHandler.completed(portalConfig);
+ }
+ catch (Exception e)
+ {
+ throw new OperationException(operationContext.getOperationName(), "Could not retrieve site layout for site " + site, e);
+ }
+ }
+}
Added: portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteReadResource.java
===================================================================
--- portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteReadResource.java (rev 0)
+++ portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteReadResource.java 2011-07-26 21:14:24 UTC (rev 6934)
@@ -0,0 +1,70 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.exoplatform.portal.mop.management.operations.site;
+
+import org.gatein.management.api.exceptions.OperationException;
+import org.gatein.management.api.exceptions.ResourceNotFoundException;
+import org.gatein.management.api.operation.OperationContext;
+import org.gatein.management.api.operation.ResultHandler;
+import org.gatein.management.api.operation.model.ReadResourceModel;
+import org.gatein.mop.api.workspace.Navigation;
+import org.gatein.mop.api.workspace.Page;
+import org.gatein.mop.api.workspace.Site;
+
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class SiteReadResource extends AbstractSiteOperationHandler
+{
+ @Override
+ protected void execute(OperationContext operationContext, ResultHandler resultHandler, Site site) throws ResourceNotFoundException, OperationException
+ {
+ boolean pageOrNav = false;
+ Set<String> children = new LinkedHashSet<String>(3);
+
+ Page pages = site.getRootPage().getChild("pages");
+ if (pages != null && !pages.getChildren().isEmpty())
+ {
+ children.add("pages");
+ pageOrNav = true;
+ }
+
+ Navigation defaultNav = site.getRootNavigation().getChild("default");
+ if (defaultNav != null && !defaultNav.getChildren().isEmpty())
+ {
+ children.add("navigation");
+ pageOrNav = true;
+ }
+
+ if (pageOrNav)
+ {
+ children.add("portal");
+ }
+
+ resultHandler.completed(new ReadResourceModel("Available artifacts for site " + getSiteKey(site), children));
+ }
+}
Added: portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteTypeReadResource.java
===================================================================
--- portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteTypeReadResource.java (rev 0)
+++ portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteTypeReadResource.java 2011-07-26 21:14:24 UTC (rev 6934)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.exoplatform.portal.mop.management.operations.site;
+
+import org.exoplatform.portal.mop.management.operations.AbstractMopOperationHandler;
+import org.gatein.management.api.exceptions.OperationException;
+import org.gatein.management.api.exceptions.ResourceNotFoundException;
+import org.gatein.management.api.operation.OperationContext;
+import org.gatein.management.api.operation.ResultHandler;
+import org.gatein.management.api.operation.model.ReadResourceModel;
+import org.gatein.mop.api.workspace.ObjectType;
+import org.gatein.mop.api.workspace.Site;
+import org.gatein.mop.api.workspace.Workspace;
+
+import java.util.Collection;
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class SiteTypeReadResource extends AbstractMopOperationHandler
+{
+ @Override
+ protected void execute(OperationContext operationContext, ResultHandler resultHandler, Workspace workspace, ObjectType<Site> siteType) throws ResourceNotFoundException, OperationException
+ {
+ Collection<Site> sites = workspace.getSites(siteType);
+ Set<String> children = new LinkedHashSet<String>(sites.size());
+ for (Site site : sites)
+ {
+ children.add(site.getName());
+ }
+ resultHandler.completed(new ReadResourceModel("Available sites for site type '" + getSiteType(siteType).getName() + "'", children));
+ }
+}
Added: portal/branches/gatein-management/component/portal/src/main/resources/META-INF/services/org.gatein.management.spi.ManagementExtension
===================================================================
--- portal/branches/gatein-management/component/portal/src/main/resources/META-INF/services/org.gatein.management.spi.ManagementExtension (rev 0)
+++ portal/branches/gatein-management/component/portal/src/main/resources/META-INF/services/org.gatein.management.spi.ManagementExtension 2011-07-26 21:14:24 UTC (rev 6934)
@@ -0,0 +1 @@
+org.exoplatform.portal.mop.management.MopManagementExtension
\ No newline at end of file
Added: portal/branches/gatein-management/component/portal/src/test/java/org/exoplatform/portal/mop/management/binding/xml/AbstractMarshallerTest.java
===================================================================
--- portal/branches/gatein-management/component/portal/src/test/java/org/exoplatform/portal/mop/management/binding/xml/AbstractMarshallerTest.java (rev 0)
+++ portal/branches/gatein-management/component/portal/src/test/java/org/exoplatform/portal/mop/management/binding/xml/AbstractMarshallerTest.java 2011-07-26 21:14:24 UTC (rev 6934)
@@ -0,0 +1,169 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.exoplatform.portal.mop.management.binding.xml;
+
+import junit.framework.TestCase;
+import org.exoplatform.portal.config.model.Application;
+import org.exoplatform.portal.config.model.ApplicationState;
+import org.exoplatform.portal.config.model.Container;
+import org.exoplatform.portal.config.model.ModelObject;
+import org.exoplatform.portal.config.model.PageBody;
+import org.exoplatform.portal.config.model.TransientApplicationState;
+import org.exoplatform.portal.pom.data.ApplicationData;
+import org.exoplatform.portal.pom.data.ContainerData;
+import org.exoplatform.portal.pom.spi.gadget.Gadget;
+import org.exoplatform.portal.pom.spi.portlet.Portlet;
+import org.exoplatform.portal.pom.spi.portlet.Preference;
+
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public abstract class AbstractMarshallerTest extends TestCase
+{
+ protected void compareComponents(List<ModelObject> expectedComponents, List<ModelObject> actualComponents)
+ {
+ assertEquals(expectedComponents.size(), actualComponents.size());
+ for (int i=0; i<expectedComponents.size(); i++)
+ {
+ ModelObject expected = expectedComponents.get(i);
+ ModelObject actual = actualComponents.get(i);
+ assertEquals(expected.getClass(), actual.getClass());
+
+ if (expected instanceof Application)
+ {
+ compareApplication((Application) expected, (Application) actual);
+ }
+ else if (expected instanceof PageBody)
+ {
+ assertTrue(actual instanceof PageBody);
+ }
+ else if (expected instanceof Container)
+ {
+ compareContainer((Container) expected, (Container) actual);
+ }
+ }
+ }
+
+ protected void compareContainer(Container expected, Container actual)
+ {
+ assertNull(actual.getStorageId());
+ assertNull(actual.getStorageName());
+ assertEquals(expected.getId(), actual.getId());
+ assertEquals(expected.getName(), actual.getName());
+ assertEquals(expected.getIcon(), actual.getIcon());
+ assertEquals(expected.getTemplate(), actual.getTemplate());
+ assertEquals(expected.getFactoryId(), actual.getFactoryId());
+ assertEquals(expected.getTitle(), actual.getTitle());
+ assertEquals(expected.getDescription(), actual.getDescription());
+ assertEquals(expected.getWidth(), actual.getWidth());
+ assertEquals(expected.getHeight(), actual.getHeight());
+ assertEquals(Arrays.asList(expected.getAccessPermissions()), Arrays.asList(actual.getAccessPermissions()));
+
+ compareComponents(expected.getChildren(), actual.getChildren());
+ }
+
+ protected void compareApplication(Application expected, Application actual)
+ {
+ assertNull(actual.getStorageId());
+ assertNull(actual.getStorageName());
+ assertEquals(expected.getType(), actual.getType());
+ if (expected.getState() == null)
+ {
+ assertNull(actual.getState());
+ }
+ else
+ {
+ assertNotNull(actual.getState());
+ compareApplicationState(expected.getState(), actual.getState());
+ }
+
+ assertNull(actual.getStorageId());
+ assertNull(actual.getStorageName());
+ assertNull(actual.getId());
+ assertEquals(expected.getTitle(), actual.getTitle());
+ assertEquals(expected.getIcon(), actual.getIcon());
+ assertEquals(expected.getDescription(), actual.getDescription());
+ assertEquals(expected.getShowInfoBar(), actual.getShowInfoBar());
+ assertEquals(expected.getShowApplicationState(), actual.getShowApplicationState());
+ assertEquals(expected.getShowApplicationMode(), actual.getShowApplicationMode());
+ assertEquals(expected.getTheme(), actual.getTheme());
+ assertEquals(expected.getWidth(), actual.getWidth());
+ assertEquals(expected.getHeight(), actual.getHeight());
+ assertEquals(expected.getProperties(), actual.getProperties());
+ assertEquals(Arrays.asList(expected.getAccessPermissions()), Arrays.asList(actual.getAccessPermissions()));
+ }
+
+ protected void compareApplicationState(ApplicationState expected, ApplicationState actual)
+ {
+ assertEquals(expected.getClass(), actual.getClass());
+ if (expected instanceof TransientApplicationState)
+ {
+ TransientApplicationState expectedTas = (TransientApplicationState) expected;
+ TransientApplicationState actualTas = (TransientApplicationState) actual;
+ assertEquals(expectedTas.getContentId(), actualTas.getContentId());
+ assertNull(actualTas.getOwnerType());
+ assertNull(actualTas.getOwnerId());
+ assertNull(actualTas.getUniqueId());
+ if (expectedTas.getContentState() == null)
+ {
+ assertNull(actualTas.getContentState());
+ }
+ else
+ {
+ assertEquals(expectedTas.getContentState().getClass(), actualTas.getContentState().getClass());
+ if (expectedTas.getContentState() instanceof Portlet)
+ {
+ comparePortlet((Portlet) expectedTas.getContentState(), (Portlet) actualTas.getContentState());
+ }
+ else if (expectedTas.getContentState() instanceof Gadget)
+ {
+ compareGadget((Gadget) expectedTas.getContentState(), (Gadget) actualTas.getContentState());
+ }
+ }
+ }
+ }
+
+ protected void comparePortlet(Portlet expected, Portlet actual)
+ {
+ for (Preference expectedPref : expected)
+ {
+ Preference actualPref = actual.getPreference(expectedPref.getName());
+ assertNotNull(actualPref);
+ assertEquals(expectedPref.getName(), actualPref.getName());
+ assertEquals(expectedPref.getValues(), actualPref.getValues());
+ assertEquals(expectedPref.isReadOnly(), actualPref.isReadOnly());
+ }
+ }
+
+ private void compareGadget(Gadget expected, Gadget actual)
+ {
+ assertNotNull(expected);
+ assertNotNull(actual);
+ // When gadget user prefs are supported in gatein_objects, uncomment.
+ //assertEquals(expected.getUserPref(), actual.getUserPref());
+ }
+}
Added: portal/branches/gatein-management/component/portal/src/test/java/org/exoplatform/portal/mop/management/binding/xml/NavigationMarshallerTest.java
===================================================================
--- portal/branches/gatein-management/component/portal/src/test/java/org/exoplatform/portal/mop/management/binding/xml/NavigationMarshallerTest.java (rev 0)
+++ portal/branches/gatein-management/component/portal/src/test/java/org/exoplatform/portal/mop/management/binding/xml/NavigationMarshallerTest.java 2011-07-26 21:14:24 UTC (rev 6934)
@@ -0,0 +1,323 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.exoplatform.portal.mop.management.binding.xml;
+
+import junit.framework.TestCase;
+import org.exoplatform.portal.config.model.I18NString;
+import org.exoplatform.portal.config.model.LocalizedString;
+import org.exoplatform.portal.config.model.NavigationFragment;
+import org.exoplatform.portal.config.model.PageNavigation;
+import org.exoplatform.portal.config.model.PageNode;
+import org.exoplatform.portal.mop.Visibility;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collections;
+import java.util.Date;
+import java.util.Locale;
+import java.util.TimeZone;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class NavigationMarshallerTest extends TestCase
+{
+ public void testNavigationUnmarshalling()
+ {
+ NavigationMarshaller marshaller = new NavigationMarshaller();
+ PageNavigation data = marshaller.unmarshal(getClass().getResourceAsStream("/org/exoplatform/portal/mop/management/navigation.xml"));
+ assertNotNull(data);
+ assertEquals(111, data.getPriority());
+ assertNotNull(data.getFragment());
+ assertEquals(7, data.getFragment().getNodes().size());
+ PageNode node = data.getFragment().getNodes().get(0);
+ verifyNode(node, "home", "#{portal.classic.home}", "home", Visibility.DISPLAYED, "portal::classic::homepage", null, null, null, 1);
+ node = node.getNodes().get(0);
+ Date start = createDate(2011, 1, 10, 12, 13, 55);
+ Date end = createDate(2011, 1, 17, 17, 14, 0);
+ verifyNode(node, "home-1", "Home 1", "home/home-1", Visibility.TEMPORAL, null, start, end, "StarAward", 1);
+ node = node.getNodes().get(0);
+ verifyNode(node, "empty", "Empty", "home/home-1/empty", Visibility.HIDDEN, "portal::classic::empty-page", null, null, null, 0);
+
+ node = data.getFragment().getNodes().get(5);
+ verifyNode(node, "notfound", "NotFound", "notfound", Visibility.SYSTEM, null, null, null, null, 0);
+
+ node = data.getFragment().getNodes().get(6);
+ verifyNode(node, "n0", "n0", "n0", Visibility.DISPLAYED, "portal::classic::n0", null, null, null, 1);
+ node = node.getNodes().get(0);
+ verifyNode(node, "n0", "n0", "n0/n0", Visibility.DISPLAYED, "portal::classic::n0_n0", null, null, null, 10);
+ for (int i=0; i<10; i++)
+ {
+ String name = "n" + i;
+ String uri = "n0/n0/n" + i;
+ String pageref = uri.replace("/", "_");
+
+ PageNode child = node.getNodes().get(i);
+ verifyNode(child, name, name, uri, Visibility.DISPLAYED, "portal::classic::" + pageref, null, null, null, 0);
+ }
+ }
+
+ public void testEmptyNavigationUnmarshalling()
+ {
+ NavigationMarshaller marshaller = new NavigationMarshaller();
+ PageNavigation data = marshaller.unmarshal(getClass().getResourceAsStream("/org/exoplatform/portal/mop/management/navigation-empty.xml"));
+ assertNotNull(data);
+ assertEquals(3, data.getPriority());
+ assertNotNull(data.getFragment().getNodes());
+ assertTrue(data.getFragment().getNodes().isEmpty());
+ }
+
+ public void testFragmentedNavigationUnmarshalling()
+ {
+ NavigationMarshaller marshaller = new NavigationMarshaller();
+ PageNavigation data = marshaller.unmarshal(getClass().getResourceAsStream("/org/exoplatform/portal/mop/management/navigation-fragment.xml"));
+ assertNotNull(data);
+ assertNotNull(data.getFragments());
+ assertEquals(2, data.getFragments().size());
+
+ NavigationFragment fragment = data.getFragments().get(0);
+ assertNotNull(fragment);
+ assertEquals("home", fragment.getParentURI());
+ assertNotNull(fragment.getNodes());
+ assertEquals(1, fragment.getNodes().size());
+ PageNode node = fragment.getNode("home-1");
+ assertNotNull(node);
+ assertNotNull(node.getNodes());
+ assertEquals(2, node.getNodes().size());
+ assertNotNull(node.getNode("home-1-1"));
+ assertNotNull(node.getNode("home-1-2"));
+
+ fragment = data.getFragments().get(1);
+ assertNotNull(fragment);
+ assertEquals("foo-bar", fragment.getParentURI());
+ assertNotNull(fragment.getNodes());
+ assertEquals(2, fragment.getNodes().size());
+ assertNotNull(fragment.getNode("foo"));
+ assertNotNull(fragment.getNode("bar"));
+ }
+
+ public void testLocaleNavigationUnmarshalling()
+ {
+ NavigationMarshaller marshaller = new NavigationMarshaller();
+ PageNavigation data = marshaller.unmarshal(getClass().getResourceAsStream("/org/exoplatform/portal/mop/management/navigation-extended.xml"));
+ assertNotNull(data);
+ assertNotNull(data.getFragment().getNodes());
+
+ PageNode node = data.getFragment().getNode("hello-node");
+ assertNotNull(node);
+ assertNotNull(node.getLabels());
+ assertEquals(8, node.getLabels().size());
+
+ Locale locale = Locale.getDefault();
+
+ String cn = "Dobrý den";
+ String fr = "Bonjour";
+ String en = "Hello";
+ String es = "Hola";
+ String ja = "こんにちは";
+ String it = "Ciào";
+ String zh = "你好";
+ String zh_tw = "Li-ho";
+
+ assertEquals(cn, node.getLabels().getExtended(locale).get(new Locale("cn")));
+ assertEquals(fr, node.getLabels().getExtended(locale).get(new Locale("fr")));
+ assertEquals(en, node.getLabels().getExtended(locale).get(new Locale("en")));
+ assertEquals(es, node.getLabels().getExtended(locale).get(new Locale("es")));
+ assertEquals(ja, node.getLabels().getExtended(locale).get(new Locale("ja")));
+ assertEquals(it, node.getLabels().getExtended(locale).get(new Locale("it")));
+ assertEquals(zh, node.getLabels().getExtended(locale).get(new Locale("zh")));
+ assertEquals(zh_tw, node.getLabels().getExtended(locale).get(Locale.TAIWAN));
+
+ node = data.getFragment().getNode("hello-node2");
+ assertNotNull(node);
+ assertNotNull(node.getLabels());
+ assertEquals(8, node.getLabels().size());
+
+ assertEquals(cn, node.getLabels().getExtended(locale).get(new Locale("cn")));
+ assertEquals(fr, node.getLabels().getExtended(locale).get(new Locale("fr")));
+ assertEquals(en, node.getLabels().getExtended(locale).get(new Locale("en")));
+ assertEquals(es, node.getLabels().getExtended(locale).get(new Locale("es")));
+ assertEquals(ja, node.getLabels().getExtended(locale).get(new Locale("ja")));
+ assertEquals(it, node.getLabels().getExtended(locale).get(new Locale("it")));
+ assertEquals(zh, node.getLabels().getExtended(locale).get(new Locale("zh")));
+ assertEquals(zh_tw, node.getLabels().getExtended(locale).get(Locale.TAIWAN));
+ }
+
+ public void testNavigationMarshalling()
+ {
+ Calendar startCal = Calendar.getInstance();
+ startCal.set(Calendar.MILLISECOND, 0);
+ Date start = startCal.getTime();
+ Calendar endCal = Calendar.getInstance();
+ endCal.set(Calendar.MILLISECOND, 0);
+ Date end = endCal.getTime();
+
+ PageNode expectedChild1 = newPageNode("node-1", "Icon-1", "Node 1",
+ null, null, Visibility.DISPLAYED, null, new ArrayList<PageNode>());
+
+ I18NString labels = new I18NString(
+ new LocalizedString("Node 2", Locale.ENGLISH),
+ new LocalizedString("Node 2", Locale.FRENCH),
+ new LocalizedString("Node 2", Locale.TAIWAN));
+
+ PageNode expectedChild2 = newPageNode("node-2", "Icon-2", labels,
+ createDate(2011, 7, 22, 10, 10, 10), createDate(2011, 7, 30, 12, 0, 0), Visibility.SYSTEM, "some:page:ref", new ArrayList<PageNode>());
+
+ ArrayList<PageNode> children = new ArrayList<PageNode>(2);
+ children.add(expectedChild1);
+ children.add(expectedChild2);
+
+ PageNode expectedNode = newPageNode("node", "Icon", "Node", start, end, Visibility.HIDDEN, "page-ref", children);
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ NavigationMarshaller marshaller = new NavigationMarshaller();
+ PageNavigation expected = newPageNavigation("", "", 123, new ArrayList<PageNode>(Collections.singletonList(expectedNode)));
+ marshaller.marshal(expected, baos);
+
+ PageNavigation actual = marshaller.unmarshal(new ByteArrayInputStream(baos.toByteArray()));
+
+ assertNotNull(actual);
+ assertNull(actual.getOwnerType());
+ assertNull(actual.getOwnerId());
+ assertEquals(expected.getPriority(), actual.getPriority());
+ assertNotNull(expected.getFragment().getNodes());
+ assertEquals(expected.getFragment().getNodes().size(), actual.getFragment().getNodes().size());
+
+ PageNode actualNode = actual.getFragment().getNodes().get(0);
+ compareNode(expectedNode, actualNode);
+
+ assertNotNull(actualNode.getNodes());
+ assertEquals(expectedNode.getNodes().size(), actualNode.getNodes().size());
+ compareNode(expectedChild1, actualNode.getNodes().get(0));
+ compareNode(expectedChild2, actualNode.getNodes().get(1));
+ }
+
+ private PageNavigation newPageNavigation(String ownerType, String ownerId, int priority, ArrayList<PageNode> children)
+ {
+ PageNavigation pageNavigation = new PageNavigation();
+ pageNavigation.setOwnerType(ownerType);
+ pageNavigation.setOwnerId(ownerId);
+ pageNavigation.setPriority(priority);
+ NavigationFragment fragment = new NavigationFragment();
+ fragment.setNodes(children);
+ pageNavigation.addFragment(fragment);
+
+ return pageNavigation;
+ }
+
+ private void verifyNode(PageNode node, String name, String label, String uri, Visibility visibility,
+ String pageRef, Date start, Date end, String icon, int children)
+ {
+ assertNotNull(node);
+ assertEquals(name, node.getName());
+ assertEquals(label, node.getLabel());
+ assertEquals(visibility, node.getVisibility());
+ assertEquals(pageRef, node.getPageReference());
+ assertEquals(start, node.getStartPublicationDate());
+ assertEquals(end, node.getEndPublicationDate());
+ assertEquals(icon, node.getIcon());
+ assertNotNull(node.getNodes());
+ assertEquals(children, node.getNodes().size());
+ }
+
+ private void compareNode(PageNode expected, PageNode actual)
+ {
+ if (expected.getLabel() != null)
+ {
+ assertEquals(expected.getLabel(), actual.getLabel());
+ }
+ else if (expected.getLabels() != null)
+ {
+ assertNotNull(actual.getLabels());
+ assertEquals(actual.getLabels().size(), expected.getLabels().size());
+
+ for (int i=0; i<actual.getLabels().size(); i++)
+ {
+ LocalizedString actualLocalizedString = expected.getLabels().get(i);
+ LocalizedString expectedLocalizedString = expected.getLabels().get(i);
+ assertEquals(actualLocalizedString.getValue(), expectedLocalizedString.getValue());
+ assertEquals(actualLocalizedString.getLang(), expectedLocalizedString.getLang());
+ }
+ }
+ else
+ {
+ assertNull(actual.getLabel());
+ assertNull(actual.getLabels());
+ }
+
+ assertEquals(expected.getIcon(), actual.getIcon());
+ assertEquals(expected.getName(), actual.getName());
+ assertEquals(expected.getStartPublicationDate(), actual.getStartPublicationDate());
+ assertEquals(expected.getEndPublicationDate(), actual.getEndPublicationDate());
+ assertEquals(expected.getVisibility(), actual.getVisibility());
+ assertEquals(expected.getPageReference(), actual.getPageReference());
+ assertEquals(expected.getNodes().size(), actual.getNodes().size());
+ }
+
+ private Date createDate(int year, int month, int day, int hour, int minute, int seconds)
+ {
+ Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("US/Eastern"));
+ cal.set(Calendar.YEAR, year);
+ cal.set(Calendar.MONTH, month-1);
+ cal.set(Calendar.DAY_OF_MONTH, day);
+ cal.set(Calendar.HOUR_OF_DAY, hour);
+ cal.set(Calendar.MINUTE, minute);
+ cal.set(Calendar.SECOND, seconds);
+ cal.set(Calendar.MILLISECOND, 0);
+
+ return cal.getTime();
+ }
+
+ private PageNode newPageNode(String name, String icon, String label, Date start, Date end, Visibility visibility, String pageref, ArrayList<PageNode> pageNodes)
+ {
+ PageNode pageNode = new PageNode();
+ pageNode.setName(name);
+ pageNode.setIcon(icon);
+ pageNode.setLabel(label);
+ pageNode.setStartPublicationDate(start);
+ pageNode.setEndPublicationDate(end);
+ pageNode.setVisibility(visibility);
+ pageNode.setPageReference(pageref);
+ pageNode.setChildren(pageNodes);
+
+ return pageNode;
+ }
+
+ private PageNode newPageNode(String name, String icon, I18NString labels, Date start, Date end, Visibility visibility, String pageref, ArrayList<PageNode> pageNodes)
+ {
+ PageNode pageNode = new PageNode();
+ pageNode.setName(name);
+ pageNode.setIcon(icon);
+ pageNode.setLabels(labels);
+ pageNode.setStartPublicationDate(start);
+ pageNode.setEndPublicationDate(end);
+ pageNode.setVisibility(visibility);
+ pageNode.setPageReference(pageref);
+ pageNode.setChildren(pageNodes);
+
+ return pageNode;
+ }
+}
Added: portal/branches/gatein-management/component/portal/src/test/java/org/exoplatform/portal/mop/management/binding/xml/PageMarshallerTest.java
===================================================================
--- portal/branches/gatein-management/component/portal/src/test/java/org/exoplatform/portal/mop/management/binding/xml/PageMarshallerTest.java (rev 0)
+++ portal/branches/gatein-management/component/portal/src/test/java/org/exoplatform/portal/mop/management/binding/xml/PageMarshallerTest.java 2011-07-26 21:14:24 UTC (rev 6934)
@@ -0,0 +1,441 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.exoplatform.portal.mop.management.binding.xml;
+
+import org.exoplatform.portal.config.model.Application;
+import org.exoplatform.portal.config.model.ApplicationState;
+import org.exoplatform.portal.config.model.ApplicationType;
+import org.exoplatform.portal.config.model.Container;
+import org.exoplatform.portal.config.model.ModelObject;
+import org.exoplatform.portal.config.model.Page;
+import org.exoplatform.portal.config.model.TransientApplicationState;
+import org.exoplatform.portal.pom.config.Utils;
+import org.exoplatform.portal.pom.data.ApplicationData;
+import org.exoplatform.portal.pom.data.ComponentData;
+import org.exoplatform.portal.pom.data.ContainerData;
+import org.exoplatform.portal.pom.data.PageData;
+import org.exoplatform.portal.pom.spi.gadget.Gadget;
+import org.exoplatform.portal.pom.spi.portlet.Portlet;
+import org.exoplatform.portal.pom.spi.portlet.Preference;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class PageMarshallerTest extends AbstractMarshallerTest
+{
+ public void testHomePageUnMarshalling()
+ {
+ PageMarshaller marshaller = new PageMarshaller();
+ Page.PageSet pages = marshaller.unmarshal(getClass().getResourceAsStream("/org/exoplatform/portal/mop/management/pages-homepage.xml"));
+ assertNotNull(pages);
+ assertNotNull(pages.getPages());
+ assertEquals(1, pages.getPages().size());
+ Page page = pages.getPages().get(0);
+
+ assertEquals("homepage", page.getName());
+ assertEquals("Home Page", page.getTitle());
+ assertEquals("Everyone", Utils.join(";", page.getAccessPermissions()));
+ assertEquals("*:/platform/administrators", page.getEditPermission());
+ assertNotNull(page.getChildren());
+ assertEquals(1, page.getChildren().size());
+ ModelObject child = page.getChildren().get(0);
+ assertTrue(child instanceof Application);
+ @SuppressWarnings("unchecked")
+ Application<Portlet> application = (Application<Portlet>) child;
+ assertTrue(application.getType() == ApplicationType.PORTLET);
+ ApplicationState<Portlet> state = application.getState();
+ assertNotNull(state);
+ assertTrue(state instanceof TransientApplicationState);
+ TransientApplicationState<Portlet> tas = (TransientApplicationState<Portlet>) state;
+ assertEquals("web/HomePagePortlet", tas.getContentId());
+ Portlet portlet = tas.getContentState();
+ int count = 0;
+ for (Preference pref : portlet)
+ {
+ count++;
+ }
+ assertEquals(1, count);
+ Preference pref = portlet.getPreference("template");
+ assertNotNull(pref);
+ assertEquals("template", pref.getName());
+ assertEquals("system:/templates/groovy/webui/component/UIHomePagePortlet.gtmpl", pref.getValue());
+ assertFalse(pref.isReadOnly());
+
+ assertNull(application.getTheme());
+ assertEquals("Home Page portlet", application.getTitle());
+ assertEquals("Everyone", Utils.join(";", application.getAccessPermissions()));
+ assertFalse(application.getShowInfoBar());
+ assertFalse(application.getShowApplicationState());
+ assertFalse(application.getShowApplicationMode());
+ assertNull(application.getDescription());
+ assertNull(application.getIcon());
+ assertNull(application.getWidth());
+ assertNull(application.getHeight());
+ }
+
+ public void testLoadedPageUnmarshalling()
+ {
+ PageMarshaller marshaller = new PageMarshaller();
+ Page.PageSet pages = marshaller.unmarshal(getClass().getResourceAsStream("/org/exoplatform/portal/mop/management/pages-loaded.xml"));
+ assertNotNull(pages);
+ assertNotNull(pages.getPages());
+ assertEquals(1, pages.getPages().size());
+ Page page = pages.getPages().get(0);
+
+ // Verify page properties
+ assertEquals("loaded-page", page.getName());
+ assertEquals("Loaded Page", page.getTitle());
+ assertEquals("manager:/platform/administrators;manager:/platform/users", Utils.join(";", page.getAccessPermissions()));
+ assertEquals("*:/platform/administrators", page.getEditPermission());
+
+ // Verify page children
+ assertNotNull(page.getChildren());
+ assertEquals(1, page.getChildren().size());
+ ModelObject child = page.getChildren().get(0);
+ assertTrue(child instanceof Container);
+
+ // Verify root container
+ Container rootContainer = (Container) child;
+ assertEquals("rootContainer", rootContainer.getId());
+ assertEquals("system:/groovy/portal/webui/container/UIContainer.gtmpl", rootContainer.getTemplate());
+ assertEquals("Everyone", Utils.join(";", rootContainer.getAccessPermissions()));
+
+ // Verify root container children
+ List<ModelObject> rootChildren = rootContainer.getChildren();
+ assertNotNull(rootChildren);
+ assertEquals(3, rootChildren.size());
+
+ // Verify container 1
+ ModelObject c1 = rootChildren.get(0);
+ assertNotNull(c1);
+ assertTrue(c1 instanceof ModelObject);
+ Container container1 = (Container) c1;
+ assertEquals("c1", container1.getId());
+ assertEquals("system:/groovy/portal/webui/container/UIContainer.gtmpl", container1.getTemplate());
+ assertEquals("*:/platform/users", Utils.join(";", container1.getAccessPermissions()));
+ {
+ // Verify homepage application
+ assertNotNull(container1.getChildren());
+ assertEquals(1, container1.getChildren().size());
+ ModelObject homeComponent = container1.getChildren().get(0);
+ assertTrue(homeComponent instanceof Application);
+ @SuppressWarnings("unchecked")
+ Application<Portlet> application = (Application<Portlet>) homeComponent;
+ assertTrue(application.getType() == ApplicationType.PORTLET);
+ ApplicationState<Portlet> state = application.getState();
+ assertNotNull(state);
+ assertTrue(state instanceof TransientApplicationState);
+ TransientApplicationState<Portlet> tas = (TransientApplicationState<Portlet>) state;
+ assertEquals("web/HomePagePortlet", tas.getContentId());
+ Portlet portlet = tas.getContentState();
+ int count = 0;
+ for (Preference pref : portlet)
+ {
+ count++;
+ }
+ assertEquals(3, count);
+ Preference pref = portlet.getPreference("template");
+ assertNotNull(pref);
+ assertEquals("template", pref.getName());
+ assertEquals("system:/templates/groovy/webui/component/UIHomePagePortlet.gtmpl", pref.getValue());
+ assertTrue(pref.isReadOnly());
+
+ pref = portlet.getPreference("empty-preference-value");
+ assertNotNull(pref);
+ assertEquals("empty-preference-value", pref.getName());
+ assertNull(pref.getValue());
+ assertFalse(pref.isReadOnly());
+
+ pref = portlet.getPreference("no-preference-value");
+ assertNotNull(pref);
+ assertEquals("no-preference-value", pref.getName());
+ assertNull(pref.getValue());
+ assertFalse(pref.isReadOnly());
+
+ assertEquals("Mac:MacTheme::Default:DefaultTheme::Vista:VistaTheme", application.getTheme());
+ assertEquals("Home Page portlet", application.getTitle());
+ assertEquals("Everyone", Utils.join(";", application.getAccessPermissions()));
+ assertTrue(application.getShowInfoBar());
+ assertTrue(application.getShowApplicationState());
+ assertTrue(application.getShowApplicationMode());
+ assertNull(application.getDescription());
+ assertNull(application.getIcon());
+ assertNull(application.getWidth());
+ assertNull(application.getHeight());
+ }
+
+ // Verify container 2
+ ModelObject c2 = rootChildren.get(1);
+ assertNotNull(c2);
+ assertTrue(c2 instanceof Container);
+ Container container2 = (Container) c2;
+ assertEquals("c2", container2.getId());
+ assertEquals("system:/groovy/portal/webui/container/UITableColumnContainer.gtmpl", container2.getTemplate());
+ assertEquals("*:/platform/guests", Utils.join(";", container2.getAccessPermissions()));
+ assertEquals("TableColumnContainer", container2.getFactoryId());
+ assertNotNull(container2.getChildren());
+ assertEquals(2, container2.getChildren().size());
+
+ {
+ // Verify column 1 of container 2
+ ModelObject appregComp = container2.getChildren().get(0);
+ assertTrue(appregComp instanceof Container);
+ Container appregContainer = (Container) appregComp;
+ assertEquals("c2-1", appregContainer.getId());
+ assertEquals("system:/groovy/portal/webui/container/UIContainer.gtmpl", appregContainer.getTemplate());
+ assertEquals("300px", appregContainer.getWidth());
+ assertEquals("400px", appregContainer.getHeight());
+ assertEquals("Everyone", Utils.join(";", appregContainer.getAccessPermissions()));
+ {
+ // Verify app registry application
+ assertNotNull(appregContainer.getChildren());
+ assertEquals(1, appregContainer.getChildren().size());
+ ModelObject appregComponent = appregContainer.getChildren().get(0);
+ assertTrue(appregComponent instanceof Application);
+ @SuppressWarnings("unchecked")
+ Application<Portlet> application = (Application<Portlet>) appregComponent;
+ assertTrue(application.getType() == ApplicationType.PORTLET);
+ ApplicationState<Portlet> state = application.getState();
+ assertNotNull(state);
+ assertTrue(state instanceof TransientApplicationState);
+ TransientApplicationState<Portlet> tas = (TransientApplicationState<Portlet>) state;
+ assertEquals("exoadmin/ApplicationRegistryPortlet", tas.getContentId());
+ assertNull(tas.getContentState());
+
+ assertEquals("Default:DefaultTheme::Mac:MacTheme::Vista:VistaTheme", application.getTheme());
+ assertEquals("Application Registry", application.getTitle());
+ assertEquals("*:/platform/administrators;*:/organization/management/executive-board", Utils.join(";", application.getAccessPermissions()));
+ assertFalse(application.getShowInfoBar());
+ assertTrue(application.getShowApplicationState());
+ assertFalse(application.getShowApplicationMode());
+ assertEquals("Application Registry", application.getDescription());
+ assertEquals("PortletIcon", application.getIcon());
+ assertEquals("250px", application.getWidth());
+ assertEquals("350px", application.getHeight());
+ }
+
+ // Verify column 2 of container 2
+ ModelObject orgComp = container2.getChildren().get(1);
+ assertTrue(orgComp instanceof Container);
+ Container orgContainer = (Container) orgComp;
+ assertEquals("c2-2", orgContainer.getId());
+ assertEquals("system:/groovy/portal/webui/container/UIContainer.gtmpl", orgContainer.getTemplate());
+ assertEquals("200px", orgContainer.getWidth());
+ assertEquals("300px", orgContainer.getHeight());
+ assertEquals("/platform/users", Utils.join(";", orgContainer.getAccessPermissions()));
+ {
+ // Verify calendar gadget application
+ assertNotNull(orgContainer.getChildren());
+ assertEquals(1, orgContainer.getChildren().size());
+ ModelObject gadgetComponent = orgContainer.getChildren().get(0);
+ assertTrue(gadgetComponent instanceof Application);
+ @SuppressWarnings("unchecked")
+ Application<Gadget> application = (Application<Gadget>) gadgetComponent;
+ assertTrue(application.getType() == ApplicationType.GADGET);
+ ApplicationState<Gadget> state = application.getState();
+ assertNotNull(state);
+ assertTrue(state instanceof TransientApplicationState);
+ TransientApplicationState<Gadget> tas = (TransientApplicationState<Gadget>) state;
+ assertEquals("Calendar", tas.getContentId());
+ assertNull(tas.getContentState());
+
+ assertEquals("Vista:VistaTheme::Mac:MacTheme::Default:DefaultTheme", application.getTheme());
+ assertEquals("Calendar Title", application.getTitle());
+ assertEquals("*:/platform/administrators;*:/organization/management/executive-board", Utils.join(";", application.getAccessPermissions()));
+ assertTrue(application.getShowInfoBar());
+ assertFalse(application.getShowApplicationState());
+ assertFalse(application.getShowApplicationMode());
+ assertEquals("Calendar Description", application.getDescription());
+ assertEquals("StarAwardIcon", application.getIcon());
+ assertEquals("100px", application.getWidth());
+ assertEquals("200px", application.getHeight());
+ }
+ }
+
+ // Verify container 3
+ ModelObject c3 = rootChildren.get(2);
+ assertNotNull(c3);
+ assertTrue(c3 instanceof Container);
+ Container container3 = (Container) c3;
+ assertEquals("c3", container3.getId());
+ assertEquals("system:/groovy/portal/webui/container/UIContainer.gtmpl", container3.getTemplate());
+ assertEquals(container3.getTemplate(), "system:/groovy/portal/webui/container/UIContainer.gtmpl");
+ assertEquals("Everyone", Utils.join(";", container3.getAccessPermissions()));
+ assertNull(container3.getFactoryId());
+ {
+ // Verify site map application
+ assertNotNull(container3.getChildren());
+ assertEquals(1, container3.getChildren().size());
+ ModelObject sitemapcomponent = container3.getChildren().get(0);
+ assertTrue(sitemapcomponent instanceof Application);
+ @SuppressWarnings("unchecked")
+ Application<Portlet> application = (Application<Portlet>) sitemapcomponent;
+ assertTrue(application.getType() == ApplicationType.PORTLET);
+ ApplicationState<Portlet> state = application.getState();
+ assertNotNull(state);
+ assertTrue(state instanceof TransientApplicationState);
+ TransientApplicationState<Portlet> tas = (TransientApplicationState<Portlet>) state;
+ assertEquals("web/SiteMapPortlet", tas.getContentId());
+ assertNull(tas.getContentState());
+
+ assertEquals("Default:DefaultTheme::Vista:VistaTheme::Mac:MacTheme", application.getTheme());
+ assertEquals("SiteMap", application.getTitle());
+ assertEquals("*:/platform/users", Utils.join(";", application.getAccessPermissions()));
+ assertTrue(application.getShowInfoBar());
+ assertTrue(application.getShowApplicationState());
+ assertFalse(application.getShowApplicationMode());
+ assertEquals("SiteMap", application.getDescription());
+ assertNull(application.getIcon());
+ assertNull(application.getWidth());
+ assertNull(application.getHeight());
+ }
+ }
+
+ public void testEmptyPageUnmarshalling()
+ {
+ PageMarshaller marshaller = new PageMarshaller();
+ Page.PageSet pages = marshaller.unmarshal(getClass().getResourceAsStream("/org/exoplatform/portal/mop/management/pages-empty.xml"));
+ assertNotNull(pages);
+ assertNotNull(pages.getPages());
+ assertEquals(1, pages.getPages().size());
+ Page page = pages.getPages().get(0);
+ assertNotNull(page);
+ assertEquals("empty-page", page.getName());
+ assertEquals("Empty", page.getTitle());
+ assertNotNull(page.getChildren());
+ assertTrue(page.getChildren().isEmpty());
+ }
+
+ public void testPageMarshalling()
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+ Portlet portlet = new Portlet();
+ portlet.putPreference(new Preference("pref-1", "value-1", true));
+ portlet.putPreference(new Preference("pref-2", "value-2", false));
+ portlet.putPreference(new Preference("multi-value-pref", Arrays.asList("one", "two", "three"), false));
+ portlet.putPreference(new Preference("empty-value-pref", (String) null, true));
+
+ ApplicationState<Portlet> state = new TransientApplicationState<Portlet>("app-ref/portlet-ref", portlet);
+ ApplicationData<Portlet> applicationData = new ApplicationData<Portlet>(null, null,
+ ApplicationType.PORTLET, state, null, "app-title", "app-icon", "app-description", false, true, false,
+ "app-theme", "app-wdith", "app-height", new HashMap<String,String>(),
+ Collections.singletonList("app-edit-permissions"));
+
+ ContainerData containerData = new ContainerData(null, "cd-id", "cd-name", "cd-icon", "cd-template", "cd-factoryId", "cd-title", "cd-description", "cd-width", "cd-height", Collections.singletonList("cd-access-permissions"), Collections.singletonList((ComponentData) applicationData));
+ List<ComponentData> children = Collections.singletonList((ComponentData) containerData);
+
+ PageData expectedData = new PageData(null, null, "page-name", null, null, null, "Page Title", null, null, null,
+ Collections.singletonList("access-permissions"), children, "", "", "edit-permission", true);
+
+ Page expected = new Page(expectedData);
+
+ Page.PageSet expectedPages = new Page.PageSet();
+ expectedPages.setPages(new ArrayList<Page>(1));
+ expectedPages.getPages().add(expected);
+
+ PageMarshaller marshaller = new PageMarshaller();
+ marshaller.marshal(expectedPages, baos);
+
+ //System.out.println(baos.toString());
+
+ Page.PageSet actualPages = marshaller.unmarshal(new ByteArrayInputStream(baos.toByteArray()));
+
+ assertNotNull(actualPages);
+ assertNotNull(actualPages.getPages());
+ assertEquals(1, actualPages.getPages().size());
+
+ comparePages(expected, actualPages.getPages().get(0));
+ }
+
+ public void testPageMarshallingWithGadget()
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+ Gadget gadget = null;
+ //TODO: Uncomment when gadget user-prefs are supported in gatein_objects
+ //Gadget gadget = new Gadget();
+ //gadget.setUserPref("user-pref");
+
+ ApplicationState<Gadget> state = new TransientApplicationState<Gadget>("gadget-ref", gadget);
+ ApplicationData<Gadget> applicationData = new ApplicationData<Gadget>(null, null,
+ ApplicationType.GADGET, state, null, "app-title", "app-icon", "app-description", false, true, false,
+ "app-theme", "app-wdith", "app-height", new HashMap<String,String>(),
+ Collections.singletonList("app-edit-permissions"));
+
+ List<ComponentData> children = Collections.singletonList((ComponentData) applicationData);
+ PageData expectedData = new PageData(null, null, "page-name", null, null, null, "Page Title", null, null, null,
+ Collections.singletonList("access-permissions"), children, "", "", "edit-permission", true);
+
+ Page expected = new Page(expectedData);
+
+ Page.PageSet expectedPages = new Page.PageSet();
+ expectedPages.setPages(new ArrayList<Page>(1));
+ expectedPages.getPages().add(expected);
+
+ PageMarshaller marshaller = new PageMarshaller();
+ marshaller.marshal(expectedPages, baos);
+
+ //System.out.println(baos.toString());
+
+ Page.PageSet actualPages = marshaller.unmarshal(new ByteArrayInputStream(baos.toByteArray()));
+
+ assertNotNull(actualPages);
+ assertNotNull(actualPages.getPages());
+ assertEquals(1, actualPages.getPages().size());
+
+ comparePages(expected, actualPages.getPages().get(0));
+ }
+
+ private void comparePages(Page expected, Page actual)
+ {
+ assertNull(actual.getStorageId());
+ assertNull(actual.getStorageName());
+ assertNull(actual.getId());
+ assertNull(actual.getOwnerType());
+ assertNull(actual.getOwnerId());
+ assertEquals(expected.getName(), actual.getName());
+ assertNull(actual.getIcon());
+ assertNull(actual.getTemplate());
+ assertNull(actual.getFactoryId());
+ assertEquals(expected.getTitle(), actual.getTitle());
+ assertNull(actual.getDescription());
+ assertNull(actual.getWidth());
+ assertNull(actual.getHeight());
+ assertEquals(Arrays.asList(expected.getAccessPermissions()), Arrays.asList(actual.getAccessPermissions()));
+
+ compareComponents(expected.getChildren(), actual.getChildren());
+
+ assertEquals(expected.getEditPermission(), actual.getEditPermission());
+ assertEquals(expected.isShowMaxWindow(), actual.isShowMaxWindow());
+ }
+}
Added: portal/branches/gatein-management/component/portal/src/test/java/org/exoplatform/portal/mop/management/binding/xml/SiteLayoutMarshallerTest.java
===================================================================
--- portal/branches/gatein-management/component/portal/src/test/java/org/exoplatform/portal/mop/management/binding/xml/SiteLayoutMarshallerTest.java (rev 0)
+++ portal/branches/gatein-management/component/portal/src/test/java/org/exoplatform/portal/mop/management/binding/xml/SiteLayoutMarshallerTest.java 2011-07-26 21:14:24 UTC (rev 6934)
@@ -0,0 +1,225 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.exoplatform.portal.mop.management.binding.xml;
+
+import org.exoplatform.portal.config.model.Application;
+import org.exoplatform.portal.config.model.ApplicationState;
+import org.exoplatform.portal.config.model.ApplicationType;
+import org.exoplatform.portal.config.model.Container;
+import org.exoplatform.portal.config.model.ModelObject;
+import org.exoplatform.portal.config.model.PageBody;
+import org.exoplatform.portal.config.model.PortalConfig;
+import org.exoplatform.portal.config.model.TransientApplicationState;
+import org.exoplatform.portal.pom.config.Utils;
+import org.exoplatform.portal.pom.data.ApplicationData;
+import org.exoplatform.portal.pom.data.BodyData;
+import org.exoplatform.portal.pom.data.BodyType;
+import org.exoplatform.portal.pom.data.ComponentData;
+import org.exoplatform.portal.pom.data.ContainerData;
+import org.exoplatform.portal.pom.data.PortalData;
+import org.exoplatform.portal.pom.spi.portlet.Portlet;
+import org.exoplatform.portal.pom.spi.portlet.Preference;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static junit.framework.Assert.*;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class SiteLayoutMarshallerTest extends AbstractMarshallerTest
+{
+ public void testPortalDataUnmarshalling()
+ {
+ SiteLayoutMarshaller marshaller = new SiteLayoutMarshaller();
+ PortalConfig data = marshaller.unmarshal(getClass().getResourceAsStream("/org/exoplatform/portal/mop/management/portal.xml"));
+ assertNotNull(data);
+ assertEquals("classic", data.getName());
+ assertEquals("site-label", data.getLabel());
+ assertEquals("site-description", data.getDescription());
+ assertEquals("en", data.getLocale());
+ assertEquals("Everyone", Utils.join(";", data.getAccessPermissions()));
+ assertEquals("*:/platform/administrators", data.getEditPermission());
+ assertNotNull(data.getProperties());
+ assertEquals(1, data.getProperties().size());
+ assertTrue(data.getProperties().containsKey("sessionAlive"));
+ assertEquals("onDemand", data.getProperties().get("sessionAlive"));
+
+ // Verify portal layout container only has children
+ assertNotNull(data.getPortalLayout());
+ Container layout = data.getPortalLayout();
+ assertNull(layout.getStorageId());
+ assertNull(layout.getId());
+ assertNull(layout.getName());
+ assertNull(layout.getIcon());
+ assertNull(layout.getTemplate());
+ assertNull(layout.getFactoryId());
+ assertNull(layout.getTitle());
+ assertNull(layout.getDescription());
+ assertNull(layout.getWidth());
+ assertNull(layout.getHeight());
+ assertNull(layout.getAccessPermissions());
+ List<ModelObject> children = data.getPortalLayout().getChildren();
+ assertEquals(5, children.size());
+ int bodyCount = 0;
+ for (ModelObject component : children)
+ {
+ if (component instanceof Application)
+ {
+ }
+ else if (component instanceof PageBody)
+ {
+ bodyCount++;
+ }
+ else
+ {
+ fail("Only application data and one body data should be created for a portal layout.");
+ }
+ }
+ assertEquals(1, bodyCount);
+
+ // Verify banner portlet app
+ {
+ @SuppressWarnings("unchecked")
+ Application<Portlet> application = (Application<Portlet>) children.get(0);
+ assertTrue(application.getType() == ApplicationType.PORTLET);
+ ApplicationState<Portlet> state = application.getState();
+ assertNotNull(state);
+ assertTrue(state instanceof TransientApplicationState);
+ TransientApplicationState<Portlet> tas = (TransientApplicationState<Portlet>) state;
+ assertEquals("web/BannerPortlet", tas.getContentId());
+ Portlet portlet = tas.getContentState();
+ int count = 0;
+ for (Preference pref : portlet)
+ {
+ count++;
+ }
+ assertEquals(1, count);
+ Preference pref = portlet.getPreference("template");
+ assertNotNull(pref);
+ assertEquals("template", pref.getName());
+ assertEquals("par:/groovy/groovy/webui/component/UIBannerPortlet.gtmpl", pref.getValue());
+ assertFalse(pref.isReadOnly());
+
+ assertEquals("Default:DefaultTheme::Mac:MacTheme::Vista:VistaTheme", application.getTheme());
+ assertEquals("Banner", application.getTitle());
+ assertEquals("*:/platform/administrators;*:/organization/management/executive-board", Utils.join(";", application.getAccessPermissions()));
+ assertFalse(application.getShowInfoBar());
+ assertTrue(application.getShowApplicationState());
+ assertFalse(application.getShowApplicationMode());
+ assertEquals("Banner Portlet", application.getDescription());
+ assertEquals("PortletIcon", application.getIcon());
+ assertEquals("250px", application.getWidth());
+ assertEquals("350px", application.getHeight());
+ }
+
+ // Verify navigation portlet app
+ {
+ @SuppressWarnings("unchecked")
+ Application<Portlet> application = (Application<Portlet>) children.get(1);
+ assertTrue(application.getType() == ApplicationType.PORTLET);
+ ApplicationState<Portlet> state = application.getState();
+ assertNotNull(state);
+ assertTrue(state instanceof TransientApplicationState);
+ TransientApplicationState<Portlet> tas = (TransientApplicationState<Portlet>) state;
+ assertEquals("web/NavigationPortlet", tas.getContentId());
+ assertNull(tas.getContentState());
+
+ assertNull(application.getTheme());
+ assertNull(application.getTitle());
+ assertEquals("Everyone", Utils.join(";", application.getAccessPermissions()));
+ assertFalse(application.getShowInfoBar());
+ assertTrue(application.getShowApplicationState());
+ assertTrue(application.getShowApplicationMode());
+ assertNull(application.getDescription());
+ assertNull(application.getIcon());
+ assertNull(application.getWidth());
+ assertNull(application.getHeight());
+ }
+ }
+
+ public void testPortalDataMarshalling()
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+ Portlet portlet = new Portlet();
+ portlet.putPreference(new Preference("pref-1", "value-1", true));
+ portlet.putPreference(new Preference("pref-2", "value-2", false));
+ portlet.putPreference(new Preference("multi-value-pref", Arrays.asList("one", "two", "three"), false));
+ portlet.putPreference(new Preference("no-value-pref", (String) null, true));
+
+ ApplicationState<Portlet> state = new TransientApplicationState<Portlet>("app-ref/portlet-ref", portlet);
+ ApplicationData<Portlet> application = new ApplicationData<Portlet>(null, null,
+ ApplicationType.PORTLET, state, null, "app-title", "app-icon", "app-description", false, true, false,
+ "app-theme", "app-wdith", "app-height", new HashMap<String,String>(),
+ Collections.singletonList("app-edit-permissions"));
+
+ List<ComponentData> children = new ArrayList<ComponentData>();
+ children.add(application);
+ children.add(new BodyData(null, BodyType.PAGE));
+
+ ContainerData layout = new ContainerData(null, null, "container-name", "container-icon", "container-template",
+ "factoryId", "title", "description", "width", "height", Collections.singletonList("blah"), children);
+
+ Map<String,String> properties = new HashMap<String,String>();
+ properties.put("key1", "value1");
+ properties.put("key2", "value2");
+
+ PortalData expectedData = new PortalData(null, "name", "type", "locale", "label", "description",
+ Collections.singletonList("access-permissions"), "edit-permissions", properties, "skin", layout);
+
+ PortalConfig expected = new PortalConfig(expectedData);
+
+ SiteLayoutMarshaller marshaller = new SiteLayoutMarshaller();
+ marshaller.marshal(expected, baos);
+
+// System.out.println(baos.toString());
+
+ PortalConfig actual = marshaller.unmarshal(new ByteArrayInputStream(baos.toByteArray()));
+ assertNotNull(actual);
+ assertNull(actual.getStorageId());
+ assertNull(actual.getStorageName());
+ assertEquals("name", actual.getName());
+ assertEquals("label", actual.getLabel());
+ assertEquals("description", actual.getDescription());
+ assertEquals("portal", actual.getType());
+ assertEquals("locale", actual.getLocale());
+ assertEquals("access-permissions", Utils.join(";", actual.getAccessPermissions()));
+ assertEquals("edit-permissions", actual.getEditPermission());
+ assertEquals(properties, actual.getProperties());
+ assertEquals("skin", actual.getSkin());
+ assertNotNull(actual.getPortalLayout());
+ assertNotNull(actual.getPortalLayout().getChildren());
+ assertEquals(2, actual.getPortalLayout().getChildren().size());
+
+ compareComponents(expected.getPortalLayout().getChildren(), actual.getPortalLayout().getChildren());
+ }
+}
Added: portal/branches/gatein-management/component/portal/src/test/java/org/exoplatform/portal/mop/management/exportimport/PageImportTaskTest.java
===================================================================
--- portal/branches/gatein-management/component/portal/src/test/java/org/exoplatform/portal/mop/management/exportimport/PageImportTaskTest.java (rev 0)
+++ portal/branches/gatein-management/component/portal/src/test/java/org/exoplatform/portal/mop/management/exportimport/PageImportTaskTest.java 2011-07-26 21:14:24 UTC (rev 6934)
@@ -0,0 +1,492 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.exoplatform.portal.mop.management.exportimport;
+
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+import org.exoplatform.commons.utils.LazyPageList;
+import org.exoplatform.portal.config.DataStorage;
+import org.exoplatform.portal.config.Query;
+import org.exoplatform.portal.config.model.Page;
+import org.exoplatform.portal.mop.SiteKey;
+import org.exoplatform.portal.pom.data.ComponentData;
+import org.exoplatform.portal.pom.data.PageData;
+import org.mockito.ArgumentMatcher;
+import org.mockito.Matchers;
+
+import java.util.ArrayList;
+import java.util.Collections;
+
+import static org.mockito.Mockito.*;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class PageImportTaskTest extends TestCase
+{
+ private DataStorage dataStorage;
+ private LazyPageList<Page> list;
+ private SiteKey siteKey = new SiteKey("user", "foo");
+
+ @Override
+ @SuppressWarnings("unchecked")
+ protected void setUp() throws Exception
+ {
+ dataStorage = mock(DataStorage.class);
+ list = mock(LazyPageList.class);
+ }
+
+ public void testConserve_NoPages() throws Exception
+ {
+ Page.PageSet importing = new Builder().addPage("page1").addPage("page2").addPage("page3").build();
+ PageImportTask task = new PageImportTask(importing, siteKey, dataStorage);
+
+ when(dataStorage.find(Matchers.<Query<Page>>any())).thenReturn(list);
+ when(list.getAvailable()).thenReturn(0); // no pages exist
+
+ task.importData(ImportStrategy.CONSERVE);
+
+ verify(dataStorage).find(query("user", "foo"));
+ verify(list).getAvailable();
+ verify(list, never()).getAll();
+
+ for (Page page : importing.getPages())
+ {
+ verify(dataStorage).save(page);
+ }
+ verify(dataStorage, times(3)).save();
+
+ verifyNoMoreInteractions(dataStorage, list);
+
+ Assert.assertNotNull(task.getRollbackDeletes());
+ Assert.assertEquals(importing, task.getRollbackDeletes());
+ Assert.assertNull(task.getRollbackSaves());
+ }
+
+ public void testConserve_SamePages() throws Exception
+ {
+ Page.PageSet importing = new Builder().addPage("page1").addPage("page2").addPage("page3").build();
+ Page.PageSet existing = new Builder().addPage("page1").addPage("page2").addPage("page3").build();
+ PageImportTask task = new PageImportTask(importing, siteKey, dataStorage);
+
+ when(dataStorage.find(Matchers.<Query<Page>>any())).thenReturn(list);
+ when(list.getAvailable()).thenReturn(3);
+ when(list.getAll()).thenReturn(existing.getPages());
+
+ task.importData(ImportStrategy.CONSERVE);
+
+ verify(dataStorage).find(query("user", "foo"));
+ verify(list).getAvailable();
+ verify(list).getAll();
+
+ verifyNoMoreInteractions(dataStorage, list);
+
+ assertNullOrEmpty(task.getRollbackDeletes());
+ assertNullOrEmpty(task.getRollbackSaves());
+ }
+
+ public void testConserve_NewPages() throws Exception
+ {
+ Page.PageSet importing = new Builder().addPage("page1").addPage("page2").addPage("page3").build();
+ Page.PageSet existing = new Builder().addPage("foo").addPage("bar").addPage("baz").build();
+ PageImportTask task = new PageImportTask(importing, siteKey, dataStorage);
+
+ when(dataStorage.find(Matchers.<Query<Page>>any())).thenReturn(list);
+ when(list.getAvailable()).thenReturn(3);
+ when(list.getAll()).thenReturn(existing.getPages());
+
+ task.importData(ImportStrategy.CONSERVE);
+
+ verify(dataStorage).find(query("user", "foo"));
+ verify(list).getAvailable();
+ verify(list).getAll();
+
+ for (Page page : importing.getPages())
+ {
+ verify(dataStorage).save(page);
+ }
+ verify(dataStorage, times(3)).save();
+
+ verifyNoMoreInteractions(dataStorage, list);
+
+ Assert.assertNotNull(task.getRollbackDeletes());
+ Assert.assertEquals(importing.getPages(), task.getRollbackDeletes().getPages());
+ Assert.assertNull(task.getRollbackSaves());
+ }
+
+ public void testConserve_NewAndSamePages() throws Exception
+ {
+ Page.PageSet importing = new Builder().addPage("page1").addPage("page2").addPage("page3").addPage("page4").build();
+ Page.PageSet existing = new Builder().addPage("page2").addPage("bar").addPage("page3").build();
+ PageImportTask task = new PageImportTask(importing, siteKey, dataStorage);
+
+ when(dataStorage.find(Matchers.<Query<Page>>any())).thenReturn(list);
+ when(list.getAvailable()).thenReturn(3);
+ when(list.getAll()).thenReturn(existing.getPages());
+
+ task.importData(ImportStrategy.CONSERVE);
+
+ verify(dataStorage).find(query("user", "foo"));
+ verify(list).getAvailable();
+ verify(list).getAll();
+
+ verify(dataStorage).save(importing.getPages().get(0));
+ verify(dataStorage).save(importing.getPages().get(3));
+
+ verify(dataStorage, times(2)).save();
+
+ verifyNoMoreInteractions(dataStorage, list);
+
+ Assert.assertNotNull(task.getRollbackDeletes());
+ Assert.assertEquals(2, task.getRollbackDeletes().getPages().size());
+ Assert.assertEquals(importing.getPages().get(0), task.getRollbackDeletes().getPages().get(0));
+ Assert.assertEquals(importing.getPages().get(3), task.getRollbackDeletes().getPages().get(1));
+ Assert.assertNull(task.getRollbackSaves());
+ }
+
+ public void testMerge_NoPages() throws Exception
+ {
+ Page.PageSet importing = new Builder().addPage("page1").addPage("page2").addPage("page3").build();
+ PageImportTask task = new PageImportTask(importing, siteKey, dataStorage);
+
+ when(dataStorage.find(Matchers.<Query<Page>>any())).thenReturn(list);
+ when(list.getAvailable()).thenReturn(0); // no pages exist
+
+ task.importData(ImportStrategy.MERGE);
+
+ verify(dataStorage).find(query("user", "foo"));
+ verify(list).getAvailable();
+ verify(list, never()).getAll();
+
+ for (Page page : importing.getPages())
+ {
+ verify(dataStorage).save(page);
+ }
+ verify(dataStorage, times(3)).save();
+
+ verifyNoMoreInteractions(dataStorage, list);
+
+ Assert.assertNotNull(task.getRollbackDeletes());
+ Assert.assertEquals(importing, task.getRollbackDeletes());
+ Assert.assertNull(task.getRollbackSaves());
+ }
+
+ public void testMerge_SamePages() throws Exception
+ {
+ Page.PageSet importing = new Builder().addPage("page1").addPage("page2").addPage("page3").build();
+ Page.PageSet existing = new Builder().addPage("page1").addPage("page2").addPage("page3").build();
+ PageImportTask task = new PageImportTask(importing, siteKey, dataStorage);
+
+ when(dataStorage.find(Matchers.<Query<Page>>any())).thenReturn(list);
+ when(list.getAvailable()).thenReturn(3);
+ when(list.getAll()).thenReturn(existing.getPages());
+
+ task.importData(ImportStrategy.MERGE);
+
+ verify(dataStorage).find(query("user", "foo"));
+ verify(list).getAvailable();
+ verify(list).getAll();
+
+ for (Page page : importing.getPages())
+ {
+ verify(dataStorage).save(page);
+ }
+ verify(dataStorage, times(3)).save();
+
+ verifyNoMoreInteractions(dataStorage, list);
+
+ assertNullOrEmpty(task.getRollbackDeletes());
+ Assert.assertNotNull(task.getRollbackSaves());
+ Assert.assertEquals(3, task.getRollbackSaves().getPages().size());
+ Assert.assertEquals(existing.getPages(), task.getRollbackSaves().getPages());
+ }
+
+ public void testMerge_NewPages() throws Exception
+ {
+ Page.PageSet importing = new Builder().addPage("page1").addPage("page2").addPage("page3").build();
+ Page.PageSet existing = new Builder().addPage("foo").addPage("bar").addPage("baz").build();
+ PageImportTask task = new PageImportTask(importing, siteKey, dataStorage);
+
+ when(dataStorage.find(Matchers.<Query<Page>>any())).thenReturn(list);
+ when(list.getAvailable()).thenReturn(3);
+ when(list.getAll()).thenReturn(existing.getPages());
+
+ task.importData(ImportStrategy.MERGE);
+
+ verify(dataStorage).find(query("user", "foo"));
+ verify(list).getAvailable();
+ verify(list).getAll();
+
+ for (Page page : importing.getPages())
+ {
+ verify(dataStorage).save(page);
+ }
+ verify(dataStorage, times(3)).save();
+
+ verifyNoMoreInteractions(dataStorage, list);
+
+ Assert.assertNotNull(task.getRollbackDeletes());
+ Assert.assertEquals(importing.getPages(), task.getRollbackDeletes().getPages());
+ assertNullOrEmpty(task.getRollbackSaves());
+ }
+
+ public void testMerge_NewAndSamePages() throws Exception
+ {
+ Page.PageSet importing = new Builder().addPage("page1").addPage("page2").addPage("page3").addPage("page4").build();
+ Page.PageSet existing = new Builder().addPage("page2").addPage("bar").addPage("page3").build();
+ PageImportTask task = new PageImportTask(importing, siteKey, dataStorage);
+
+ when(dataStorage.find(Matchers.<Query<Page>>any())).thenReturn(list);
+ when(list.getAvailable()).thenReturn(3);
+ when(list.getAll()).thenReturn(existing.getPages());
+
+ task.importData(ImportStrategy.MERGE);
+
+ verify(dataStorage).find(query("user", "foo"));
+ verify(list).getAvailable();
+ verify(list).getAll();
+
+ for (Page page : importing.getPages())
+ {
+ verify(dataStorage).save(page);
+ }
+ verify(dataStorage, times(4)).save();
+
+ verifyNoMoreInteractions(dataStorage, list);
+
+ Assert.assertNotNull(task.getRollbackDeletes());
+ Assert.assertEquals(2, task.getRollbackDeletes().getPages().size());
+ Assert.assertEquals(importing.getPages().get(0), task.getRollbackDeletes().getPages().get(0));
+ Assert.assertEquals(importing.getPages().get(3), task.getRollbackDeletes().getPages().get(1));
+
+ Assert.assertNotNull(task.getRollbackSaves());
+ Assert.assertEquals(2, task.getRollbackSaves().getPages().size());
+ Assert.assertEquals(existing.getPages().get(0), task.getRollbackSaves().getPages().get(0));
+ Assert.assertEquals(existing.getPages().get(2), task.getRollbackSaves().getPages().get(1));
+ }
+
+ public void testOverwrite_NoPages() throws Exception
+ {
+ Page.PageSet importing = new Builder().addPage("page1").addPage("page2").addPage("page3").build();
+ PageImportTask task = new PageImportTask(importing, siteKey, dataStorage);
+
+ when(dataStorage.find(Matchers.<Query<Page>>any())).thenReturn(list);
+ when(list.getAvailable()).thenReturn(0); // no pages exist
+
+ task.importData(ImportStrategy.OVERWRITE);
+
+ verify(dataStorage).find(query("user", "foo"));
+ verify(list).getAvailable();
+ verify(list, never()).getAll();
+
+ for (Page page : importing.getPages())
+ {
+ verify(dataStorage).save(page);
+ }
+ verify(dataStorage, times(3)).save();
+
+ verifyNoMoreInteractions(dataStorage, list);
+
+ Assert.assertNotNull(task.getRollbackDeletes());
+ Assert.assertEquals(importing, task.getRollbackDeletes());
+ Assert.assertNull(task.getRollbackSaves());
+ }
+
+ public void testOverwrite_SamePages() throws Exception
+ {
+ Page.PageSet importing = new Builder().addPage("page1").addPage("page2").addPage("page3").build();
+ Page.PageSet existing = new Builder().addPage("page1").addPage("page2").addPage("page3").build();
+ PageImportTask task = new PageImportTask(importing, siteKey, dataStorage);
+
+ when(dataStorage.find(Matchers.<Query<Page>>any())).thenReturn(list);
+ when(list.getAvailable()).thenReturn(3);
+ when(list.getAll()).thenReturn(existing.getPages());
+
+ task.importData(ImportStrategy.OVERWRITE);
+
+ verify(dataStorage).find(query("user", "foo"));
+ verify(list).getAvailable();
+ verify(list).getAll();
+
+ int saveCount = importing.getPages().size() + existing.getPages().size();
+ for (Page page : existing.getPages())
+ {
+ verify(dataStorage).remove(page);
+ }
+
+ for (Page page : importing.getPages())
+ {
+ verify(dataStorage).save(page);
+ }
+ verify(dataStorage, times(saveCount)).save();
+
+ verifyNoMoreInteractions(dataStorage, list);
+
+ assertNullOrEmpty(task.getRollbackDeletes());
+ Assert.assertNotNull(task.getRollbackSaves());
+ Assert.assertEquals(3, task.getRollbackSaves().getPages().size());
+ Assert.assertEquals(existing.getPages(), task.getRollbackSaves().getPages());
+ }
+
+ public void testOverwrite_NewPages() throws Exception
+ {
+ Page.PageSet importing = new Builder().addPage("page1").addPage("page2").addPage("page3").build();
+ Page.PageSet existing = new Builder().addPage("foo").addPage("bar").addPage("baz").build();
+ PageImportTask task = new PageImportTask(importing, siteKey, dataStorage);
+
+ when(dataStorage.find(Matchers.<Query<Page>>any())).thenReturn(list);
+ when(list.getAvailable()).thenReturn(3);
+ when(list.getAll()).thenReturn(existing.getPages());
+
+ task.importData(ImportStrategy.OVERWRITE);
+
+ verify(dataStorage).find(query("user", "foo"));
+ verify(list).getAvailable();
+ verify(list).getAll();
+
+ int saveCount = importing.getPages().size() + existing.getPages().size();
+ for (Page page : existing.getPages())
+ {
+ verify(dataStorage).remove(page);
+ }
+
+ for (Page page : importing.getPages())
+ {
+ verify(dataStorage).save(page);
+ }
+ verify(dataStorage, times(saveCount)).save();
+
+ verifyNoMoreInteractions(dataStorage, list);
+
+ Assert.assertNotNull(task.getRollbackDeletes());
+ Assert.assertEquals(importing.getPages(), task.getRollbackDeletes().getPages());
+
+ Assert.assertNotNull(task.getRollbackSaves());
+ Assert.assertEquals(existing.getPages(), task.getRollbackSaves().getPages());
+ }
+
+ public void testOverwrite_NewAndSamePages() throws Exception
+ {
+ Page.PageSet importing = new Builder().addPage("page1").addPage("page2").addPage("page3").addPage("page4").build();
+ Page.PageSet existing = new Builder().addPage("page2").addPage("bar").addPage("page3").build();
+ PageImportTask task = new PageImportTask(importing, siteKey, dataStorage);
+
+ when(dataStorage.find(Matchers.<Query<Page>>any())).thenReturn(list);
+ when(list.getAvailable()).thenReturn(3);
+ when(list.getAll()).thenReturn(existing.getPages());
+
+ task.importData(ImportStrategy.OVERWRITE);
+
+ verify(dataStorage).find(query("user", "foo"));
+ verify(list).getAvailable();
+ verify(list).getAll();
+
+ int saveCount = importing.getPages().size() + existing.getPages().size();
+ for (Page page : existing.getPages())
+ {
+ verify(dataStorage).remove(page);
+ }
+
+ for (Page page : importing.getPages())
+ {
+ verify(dataStorage).save(page);
+ }
+ verify(dataStorage, times(saveCount)).save();
+
+ verifyNoMoreInteractions(dataStorage, list);
+
+ Assert.assertNotNull(task.getRollbackDeletes());
+ Assert.assertEquals(2, task.getRollbackDeletes().getPages().size());
+ Assert.assertEquals(importing.getPages().get(0), task.getRollbackDeletes().getPages().get(0));
+ Assert.assertEquals(importing.getPages().get(3), task.getRollbackDeletes().getPages().get(1));
+
+ Assert.assertNotNull(task.getRollbackSaves());
+ Assert.assertEquals(existing.getPages(), task.getRollbackSaves().getPages());
+ }
+
+ private void assertNullOrEmpty(Page.PageSet pages)
+ {
+ if (pages != null)
+ {
+ Assert.assertTrue(pages.getPages().isEmpty());
+ }
+ }
+
+ private Query<Page> query(String ownerType, String ownerId)
+ {
+ return argThat(new QueryMatcher(new Query<Page>(ownerType, ownerId, Page.class)));
+ }
+
+ private class QueryMatcher extends ArgumentMatcher<Query<Page>>
+ {
+ private Query<Page> query;
+
+ public QueryMatcher(Query<Page> query)
+ {
+ this.query = query;
+ }
+
+ @Override
+ public boolean matches(Object o)
+ {
+ if (query == o) return true;
+ if (!(o instanceof Query)) return false;
+
+ Query that = (Query) o;
+
+ if (!query.getClassType().equals(that.getClassType())) return false;
+ if (!query.getOwnerType().equals(that.getOwnerType())) return false;
+ if (!query.getOwnerId().equals(that.getOwnerId())) return false;
+
+ if (query.getName() != null ? !query.getName().equals(that.getName()) : that.getName() != null) return false;
+ if (query.getTitle() != null ? !query.getTitle().equals(that.getTitle()) : that.getTitle() != null) return false;
+
+ return true;
+ }
+ }
+
+ private static class Builder
+ {
+ private Page.PageSet pages;
+ public Builder()
+ {
+ pages = new Page.PageSet();
+ pages.setPages(new ArrayList<Page>());
+ }
+
+ public Builder addPage(String name)
+ {
+ PageData page= new PageData(null, "", name, null, null, null, null, null, null, null, Collections.<String>emptyList(), Collections.<ComponentData>emptyList(), "", "", null, false);
+ pages.getPages().add(new Page(page));
+
+ return this;
+ }
+
+ public Page.PageSet build()
+ {
+ return pages;
+ }
+ }
+}
Added: portal/branches/gatein-management/component/portal/src/test/resources/org/exoplatform/portal/mop/management/navigation-empty.xml
===================================================================
--- portal/branches/gatein-management/component/portal/src/test/resources/org/exoplatform/portal/mop/management/navigation-empty.xml (rev 0)
+++ portal/branches/gatein-management/component/portal/src/test/resources/org/exoplatform/portal/mop/management/navigation-empty.xml 2011-07-26 21:14:24 UTC (rev 6934)
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ ~ JBoss, Home of Professional Open Source.
+ ~ Copyright 2011, Red Hat, Inc., and individual contributors
+ ~ as indicated by the @author tags. See the copyright.txt file 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.
+ -->
+
+<node-navigation xmlns="http://www.gatein.org/xml/ns/gatein_objects_1_2"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.gatein.org/xml/ns/gatein_objects_1_2 http://www.gatein.org/xml/ns/gatein_objects_1_2">
+ <priority>3</priority>
+ <page-nodes/>
+</node-navigation>
Added: portal/branches/gatein-management/component/portal/src/test/resources/org/exoplatform/portal/mop/management/navigation-extended.xml
===================================================================
--- portal/branches/gatein-management/component/portal/src/test/resources/org/exoplatform/portal/mop/management/navigation-extended.xml (rev 0)
+++ portal/branches/gatein-management/component/portal/src/test/resources/org/exoplatform/portal/mop/management/navigation-extended.xml 2011-07-26 21:14:24 UTC (rev 6934)
@@ -0,0 +1,53 @@
+<?xml version='1.0' encoding='UTF-8'?>
+
+<!--
+ ~ JBoss, Home of Professional Open Source.
+ ~ Copyright 2011, Red Hat, Inc., and individual contributors
+ ~ as indicated by the @author tags. See the copyright.txt file 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.
+ -->
+
+<node-navigation xmlns="http://www.gatein.org/xml/ns/gatein_objects_1_2"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.gatein.org/xml/ns/gatein_objects_1_2 http://www.gatein.org/xml/ns/gatein_objects_1_2">
+ <priority>1</priority>
+ <page-nodes>
+ <node>
+ <name>hello-node</name>
+ <label lang="cn">Dobrý den</label>
+ <label lang="fr">Bonjour</label>
+ <label lang="en">Hello</label>
+ <label lang="es">Hola</label>
+ <label lang="ja">こんにちは</label>
+ <label lang="it">Ciào</label>
+ <label lang="zh">你好</label>
+ <label lang="zh-TW">Li-ho</label>
+ </node>
+ <node>
+ <name>hello-node2</name>
+ <label xml:lang="cn">Dobrý den</label>
+ <label xml:lang="fr">Bonjour</label>
+ <label xml:lang="en">Hello</label>
+ <label xml:lang="es">Hola</label>
+ <label xml:lang="ja">こんにちは</label>
+ <label xml:lang="it">Ciào</label>
+ <label xml:lang="zh">你好</label>
+ <label lang="zh-tw">Li-ho</label>
+ </node>
+ </page-nodes>
+</node-navigation>
Added: portal/branches/gatein-management/component/portal/src/test/resources/org/exoplatform/portal/mop/management/navigation-fragment.xml
===================================================================
--- portal/branches/gatein-management/component/portal/src/test/resources/org/exoplatform/portal/mop/management/navigation-fragment.xml (rev 0)
+++ portal/branches/gatein-management/component/portal/src/test/resources/org/exoplatform/portal/mop/management/navigation-fragment.xml 2011-07-26 21:14:24 UTC (rev 6934)
@@ -0,0 +1,53 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!--
+ ~ JBoss, Home of Professional Open Source.
+ ~ Copyright 2011, Red Hat, Inc., and individual contributors
+ ~ as indicated by the @author tags. See the copyright.txt file 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.
+ -->
+<node-navigation xmlns="http://www.gatein.org/xml/ns/gatein_objects_1_2"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.gatein.org/xml/ns/gatein_objects_1_2 http://www.gatein.org/xml/ns/gatein_objects_1_2">
+ <priority>1</priority>
+ <page-nodes>
+ <parent-uri>home</parent-uri>
+ <node>
+ <name>home-1</name>
+ <label>Home 1</label>
+ <node>
+ <name>home-1-1</name>
+ <label>Home 1-1</label>
+ </node>
+ <node>
+ <name>home-1-2</name>
+ <label>Home 1-1</label>
+ </node>
+ </node>
+ </page-nodes>
+ <page-nodes>
+ <parent-uri>foo-bar</parent-uri>
+ <node>
+ <name>foo</name>
+ <label>Foo</label>
+ </node>
+ <node>
+ <name>bar</name>
+ <label>Bar</label>
+ </node>
+ </page-nodes>
+</node-navigation>
Added: portal/branches/gatein-management/component/portal/src/test/resources/org/exoplatform/portal/mop/management/navigation.xml
===================================================================
--- portal/branches/gatein-management/component/portal/src/test/resources/org/exoplatform/portal/mop/management/navigation.xml (rev 0)
+++ portal/branches/gatein-management/component/portal/src/test/resources/org/exoplatform/portal/mop/management/navigation.xml 2011-07-26 21:14:24 UTC (rev 6934)
@@ -0,0 +1,172 @@
+<?xml version='1.0' encoding='UTF-8'?>
+
+<!--
+ ~ JBoss, Home of Professional Open Source.
+ ~ Copyright 2011, Red Hat, Inc., and individual contributors
+ ~ as indicated by the @author tags. See the copyright.txt file 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.
+ -->
+
+<node-navigation xmlns="http://www.gatein.org/xml/ns/gatein_objects_1_2"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.gatein.org/xml/ns/gatein_objects_1_2 http://www.gatein.org/xml/ns/gatein_objects_1_2">
+ <priority>111</priority>
+ <page-nodes>
+ <node>
+ <uri>home</uri>
+ <name>home</name>
+ <label>#{portal.classic.home}</label>
+ <visibility>DISPLAYED</visibility>
+ <page-reference>portal::classic::homepage</page-reference>
+ <node>
+ <uri>home/home-1</uri>
+ <name>home-1</name>
+ <label>Home 1</label>
+ <icon>StarAward</icon>
+ <start-publication-date>2011-01-10T12:13:55-05:00</start-publication-date>
+ <end-publication-date>2011-01-17T17:14:00-05:00</end-publication-date>
+ <visibility>TEMPORAL</visibility>
+ <node>
+ <uri>home/home-1/empty</uri>
+ <name>empty</name>
+ <label>Empty</label>
+ <visibility>HIDDEN</visibility>
+ <page-reference>portal::classic::empty-page</page-reference>
+ </node>
+ </node>
+ </node>
+ <node>
+ <uri>sitemap</uri>
+ <name>sitemap</name>
+ <label>#{portal.classic.sitemap}</label>
+ <visibility>DISPLAYED</visibility>
+ <page-reference>portal::classic::sitemap</page-reference>
+ </node>
+ <node>
+ <uri>groupnavigation</uri>
+ <name>groupnavigation</name>
+ <label>#{portal.classic.groupnavigation}</label>
+ <visibility>DISPLAYED</visibility>
+ <page-reference>portal::classic::groupnavigation</page-reference>
+ </node>
+ <node>
+ <uri>portalnavigation</uri>
+ <name>portalnavigation</name>
+ <label>#{portal.classic.portalnavigation}</label>
+ <visibility>SYSTEM</visibility>
+ <page-reference>portal::classic::portalnavigation</page-reference>
+ </node>
+ <node>
+ <uri>register</uri>
+ <name>register</name>
+ <label>#{portal.classic.register}</label>
+ <visibility>SYSTEM</visibility>
+ <page-reference>portal::classic::register</page-reference>
+ </node>
+ <node>
+ <uri>notfound</uri>
+ <name>notfound</name>
+ <label>NotFound</label>
+ <visibility>SYSTEM</visibility>
+ </node>
+ <node>
+ <uri>n0</uri>
+ <name>n0</name>
+ <label>n0</label>
+ <visibility>DISPLAYED</visibility>
+ <page-reference>portal::classic::n0</page-reference>
+ <node>
+ <uri>n0/n0</uri>
+ <name>n0</name>
+ <label>n0</label>
+ <visibility>DISPLAYED</visibility>
+ <page-reference>portal::classic::n0_n0</page-reference>
+ <node>
+ <uri>n0/n0/n0</uri>
+ <name>n0</name>
+ <label>n0</label>
+ <visibility>DISPLAYED</visibility>
+ <page-reference>portal::classic::n0_n0_n0</page-reference>
+ </node>
+ <node>
+ <uri>n0/n0/n1</uri>
+ <name>n1</name>
+ <label>n1</label>
+ <visibility>DISPLAYED</visibility>
+ <page-reference>portal::classic::n0_n0_n1</page-reference>
+ </node>
+ <node>
+ <uri>n0/n0/n2</uri>
+ <name>n2</name>
+ <label>n2</label>
+ <visibility>DISPLAYED</visibility>
+ <page-reference>portal::classic::n0_n0_n2</page-reference>
+ </node>
+ <node>
+ <uri>n0/n0/n3</uri>
+ <name>n3</name>
+ <label>n3</label>
+ <visibility>DISPLAYED</visibility>
+ <page-reference>portal::classic::n0_n0_n3</page-reference>
+ </node>
+ <node>
+ <uri>n0/n0/n4</uri>
+ <name>n4</name>
+ <label>n4</label>
+ <visibility>DISPLAYED</visibility>
+ <page-reference>portal::classic::n0_n0_n4</page-reference>
+ </node>
+ <node>
+ <uri>n0/n0/n5</uri>
+ <name>n5</name>
+ <label>n5</label>
+ <visibility>DISPLAYED</visibility>
+ <page-reference>portal::classic::n0_n0_n5</page-reference>
+ </node>
+ <node>
+ <uri>n0/n0/n6</uri>
+ <name>n6</name>
+ <label>n6</label>
+ <visibility>DISPLAYED</visibility>
+ <page-reference>portal::classic::n0_n0_n6</page-reference>
+ </node>
+ <node>
+ <uri>n0/n0/n7</uri>
+ <name>n7</name>
+ <label>n7</label>
+ <visibility>DISPLAYED</visibility>
+ <page-reference>portal::classic::n0_n0_n7</page-reference>
+ </node>
+ <node>
+ <uri>n0/n0/n8</uri>
+ <name>n8</name>
+ <label>n8</label>
+ <visibility>DISPLAYED</visibility>
+ <page-reference>portal::classic::n0_n0_n8</page-reference>
+ </node>
+ <node>
+ <uri>n0/n0/n9</uri>
+ <name>n9</name>
+ <label>n9</label>
+ <visibility>DISPLAYED</visibility>
+ <page-reference>portal::classic::n0_n0_n9</page-reference>
+ </node>
+ </node>
+ </node>
+ </page-nodes>
+</node-navigation>
Added: portal/branches/gatein-management/component/portal/src/test/resources/org/exoplatform/portal/mop/management/pages-empty.xml
===================================================================
--- portal/branches/gatein-management/component/portal/src/test/resources/org/exoplatform/portal/mop/management/pages-empty.xml (rev 0)
+++ portal/branches/gatein-management/component/portal/src/test/resources/org/exoplatform/portal/mop/management/pages-empty.xml 2011-07-26 21:14:24 UTC (rev 6934)
@@ -0,0 +1,35 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!--
+ ~ JBoss, Home of Professional Open Source.
+ ~ Copyright 2011, Red Hat, Inc., and individual contributors
+ ~ as indicated by the @author tags. See the copyright.txt file 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.
+ -->
+
+<page-set xmlns="http://www.gatein.org/xml/ns/gatein_objects_1_2"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.gatein.org/xml/ns/gatein_objects_1_2 http://www.gatein.org/xml/ns/gatein_objects_1_2">
+ <page>
+ <name>empty-page</name>
+ <title>Empty</title>
+ <access-permissions>Everyone</access-permissions>
+ <edit-permission>*:/platform/administrators</edit-permission>
+ <show-max-window>false</show-max-window>
+ </page>
+
+</page-set>
\ No newline at end of file
Added: portal/branches/gatein-management/component/portal/src/test/resources/org/exoplatform/portal/mop/management/pages-homepage.xml
===================================================================
--- portal/branches/gatein-management/component/portal/src/test/resources/org/exoplatform/portal/mop/management/pages-homepage.xml (rev 0)
+++ portal/branches/gatein-management/component/portal/src/test/resources/org/exoplatform/portal/mop/management/pages-homepage.xml 2011-07-26 21:14:24 UTC (rev 6934)
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ JBoss, Home of Professional Open Source.
+ ~ Copyright 2011, Red Hat, Inc., and individual contributors
+ ~ as indicated by the @author tags. See the copyright.txt file 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.
+ -->
+
+<page-set xmlns="http://www.gatein.org/xml/ns/gatein_objects_1_2"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.gatein.org/xml/ns/gatein_objects_1_2 http://www.gatein.org/xml/ns/gatein_objects_1_2">
+
+ <page>
+ <name>homepage</name>
+ <title>Home Page</title>
+ <access-permissions>Everyone</access-permissions>
+ <edit-permission>*:/platform/administrators</edit-permission>
+ <portlet-application>
+ <portlet>
+ <application-ref>web</application-ref>
+ <portlet-ref>HomePagePortlet</portlet-ref>
+ <preferences>
+ <preference>
+ <name>template</name>
+ <value>system:/templates/groovy/webui/component/UIHomePagePortlet.gtmpl</value>
+ <read-only>false</read-only>
+ </preference>
+ </preferences>
+ </portlet>
+ <title>Home Page portlet</title>
+ <access-permissions>Everyone</access-permissions>
+ <show-info-bar>false</show-info-bar>
+ <show-application-state>false</show-application-state>
+ <show-application-mode>false</show-application-mode>
+ </portlet-application>
+ </page>
+
+</page-set>
Added: portal/branches/gatein-management/component/portal/src/test/resources/org/exoplatform/portal/mop/management/pages-loaded.xml
===================================================================
--- portal/branches/gatein-management/component/portal/src/test/resources/org/exoplatform/portal/mop/management/pages-loaded.xml (rev 0)
+++ portal/branches/gatein-management/component/portal/src/test/resources/org/exoplatform/portal/mop/management/pages-loaded.xml 2011-07-26 21:14:24 UTC (rev 6934)
@@ -0,0 +1,123 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!--
+ ~ JBoss, Home of Professional Open Source.
+ ~ Copyright 2011, Red Hat, Inc., and individual contributors
+ ~ as indicated by the @author tags. See the copyright.txt file 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.
+ -->
+
+<page-set xmlns="http://www.gatein.org/xml/ns/gatein_objects_1_2"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.gatein.org/xml/ns/gatein_objects_1_2 http://www.gatein.org/xml/ns/gatein_objects_1_2">
+ <page>
+ <name>loaded-page</name>
+ <title>Loaded Page</title>
+ <access-permissions>manager:/platform/administrators;manager:/platform/users</access-permissions>
+ <edit-permission>*:/platform/administrators</edit-permission>
+ <show-max-window>false</show-max-window>
+ <container id="rootContainer" template="system:/groovy/portal/webui/container/UIContainer.gtmpl">
+ <access-permissions>Everyone</access-permissions>
+ <container id="c1" template="system:/groovy/portal/webui/container/UIContainer.gtmpl">
+ <access-permissions>*:/platform/users</access-permissions>
+ <portlet-application>
+ <portlet>
+ <application-ref>web</application-ref>
+ <portlet-ref>HomePagePortlet</portlet-ref>
+ <preferences>
+ <preference>
+ <name>template</name>
+ <value>system:/templates/groovy/webui/component/UIHomePagePortlet.gtmpl</value>
+ <read-only>true</read-only>
+ </preference>
+ <preference>
+ <name>empty-preference-value</name>
+ <value></value>
+ </preference>
+ <preference>
+ <name>no-preference-value</name>
+ </preference>
+ </preferences>
+ </portlet>
+ <theme>Mac:MacTheme::Default:DefaultTheme::Vista:VistaTheme</theme>
+ <title>Home Page portlet</title>
+ <access-permissions>Everyone</access-permissions>
+ <show-info-bar>true</show-info-bar>
+ <show-application-state>true</show-application-state>
+ <show-application-mode>true</show-application-mode>
+ </portlet-application>
+ </container>
+ <container id="c2" template="system:/groovy/portal/webui/container/UITableColumnContainer.gtmpl">
+ <access-permissions>*:/platform/guests</access-permissions>
+ <factory-id>TableColumnContainer</factory-id>
+ <container id="c2-1" template="system:/groovy/portal/webui/container/UIContainer.gtmpl" width="300px" height="400px">
+ <access-permissions>Everyone</access-permissions>
+ <portlet-application>
+ <portlet>
+ <application-ref>exoadmin</application-ref>
+ <portlet-ref>ApplicationRegistryPortlet</portlet-ref>
+ </portlet>
+ <theme>Default:DefaultTheme::Mac:MacTheme::Vista:VistaTheme</theme>
+ <title>Application Registry</title>
+ <access-permissions>*:/platform/administrators;*:/organization/management/executive-board</access-permissions>
+ <show-info-bar>false</show-info-bar>
+ <show-application-state>true</show-application-state>
+ <show-application-mode>false</show-application-mode>
+ <description>Application Registry</description>
+ <icon>PortletIcon</icon>
+ <width>250px</width>
+ <height>350px</height>
+ </portlet-application>
+ </container>
+ <container id="c2-2" template="system:/groovy/portal/webui/container/UIContainer.gtmpl" width="200px" height="300px">
+ <access-permissions>/platform/users</access-permissions>
+ <gadget-application>
+ <gadget>
+ <gadget-ref>Calendar</gadget-ref>
+ </gadget>
+ <theme>Vista:VistaTheme::Mac:MacTheme::Default:DefaultTheme</theme>
+ <title>Calendar Title</title>
+ <access-permissions>*:/platform/administrators;*:/organization/management/executive-board</access-permissions>
+ <show-info-bar>true</show-info-bar>
+ <show-application-state>false</show-application-state>
+ <show-application-mode>false</show-application-mode>
+ <description>Calendar Description</description>
+ <icon>StarAwardIcon</icon>
+ <width>100px</width>
+ <height>200px</height>
+ </gadget-application>
+ </container>
+ </container>
+ <container id="c3" template="system:/groovy/portal/webui/container/UIContainer.gtmpl">
+ <access-permissions>Everyone</access-permissions>
+ <portlet-application>
+ <portlet>
+ <application-ref>web</application-ref>
+ <portlet-ref>SiteMapPortlet</portlet-ref>
+ </portlet>
+ <theme>Default:DefaultTheme::Vista:VistaTheme::Mac:MacTheme</theme>
+ <title>SiteMap</title>
+ <access-permissions>*:/platform/users</access-permissions>
+ <show-info-bar>true</show-info-bar>
+ <show-application-state>true</show-application-state>
+ <show-application-mode>false</show-application-mode>
+ <description>SiteMap</description>
+ </portlet-application>
+ </container>
+ </container>
+ </page>
+</page-set>
\ No newline at end of file
Added: portal/branches/gatein-management/component/portal/src/test/resources/org/exoplatform/portal/mop/management/portal.xml
===================================================================
--- portal/branches/gatein-management/component/portal/src/test/resources/org/exoplatform/portal/mop/management/portal.xml (rev 0)
+++ portal/branches/gatein-management/component/portal/src/test/resources/org/exoplatform/portal/mop/management/portal.xml 2011-07-26 21:14:24 UTC (rev 6934)
@@ -0,0 +1,100 @@
+<?xml version='1.0' encoding='UTF-8'?>
+
+<!--
+ ~ JBoss, Home of Professional Open Source.
+ ~ Copyright 2011, Red Hat, Inc., and individual contributors
+ ~ as indicated by the @author tags. See the copyright.txt file 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.
+ -->
+
+<portal-config xmlns="http://www.gatein.org/xml/ns/gatein_objects_1_2"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.gatein.org/xml/ns/gatein_objects_1_2 http://www.gatein.org/xml/ns/gatein_objects_1_2">
+ <portal-name>classic</portal-name>
+ <label>site-label</label>
+ <description>site-description</description>
+ <locale>en</locale>
+ <access-permissions>Everyone</access-permissions>
+ <edit-permission>*:/platform/administrators</edit-permission>
+ <properties>
+ <entry key="sessionAlive">onDemand</entry>
+ </properties>
+ <portal-layout>
+ <portlet-application>
+ <portlet>
+ <application-ref>web</application-ref>
+ <portlet-ref>BannerPortlet</portlet-ref>
+ <preferences>
+ <preference>
+ <name>template</name>
+ <value>par:/groovy/groovy/webui/component/UIBannerPortlet.gtmpl</value>
+ <read-only>false</read-only>
+ </preference>
+ </preferences>
+ </portlet>
+ <theme>Default:DefaultTheme::Mac:MacTheme::Vista:VistaTheme</theme>
+ <title>Banner</title>
+ <access-permissions>*:/platform/administrators;*:/organization/management/executive-board</access-permissions>
+ <show-info-bar>false</show-info-bar>
+ <show-application-state>true</show-application-state>
+ <show-application-mode>false</show-application-mode>
+ <description>Banner Portlet</description>
+ <icon>PortletIcon</icon>
+ <width>250px</width>
+ <height>350px</height>
+ </portlet-application>
+ <portlet-application>
+ <portlet>
+ <application-ref>web</application-ref>
+ <portlet-ref>NavigationPortlet</portlet-ref>
+ </portlet>
+ <access-permissions>Everyone</access-permissions>
+ <show-info-bar>false</show-info-bar>
+ <show-application-state>true</show-application-state>
+ <show-application-mode>true</show-application-mode>
+ </portlet-application>
+ <portlet-application>
+ <portlet>
+ <application-ref>web</application-ref>
+ <portlet-ref>BreadcumbsPortlet</portlet-ref>
+ </portlet>
+ <access-permissions>Everyone</access-permissions>
+ <show-info-bar>false</show-info-bar>
+ <show-application-state>true</show-application-state>
+ <show-application-mode>true</show-application-mode>
+ </portlet-application>
+ <page-body/>
+ <portlet-application>
+ <portlet>
+ <application-ref>web</application-ref>
+ <portlet-ref>FooterPortlet</portlet-ref>
+ <preferences>
+ <preference>
+ <name>template</name>
+ <value>par:/groovy/groovy/webui/component/UIFooterPortlet.gtmpl</value>
+ <read-only>false</read-only>
+ </preference>
+ </preferences>
+ </portlet>
+ <access-permissions>Everyone</access-permissions>
+ <show-info-bar>false</show-info-bar>
+ <show-application-state>true</show-application-state>
+ <show-application-mode>true</show-application-mode>
+ </portlet-application>
+ </portal-layout>
+</portal-config>
\ No newline at end of file
Modified: portal/branches/gatein-management/packaging/jboss-as5/pkg/pom.xml
===================================================================
--- portal/branches/gatein-management/packaging/jboss-as5/pkg/pom.xml 2011-07-26 17:06:24 UTC (rev 6933)
+++ portal/branches/gatein-management/packaging/jboss-as5/pkg/pom.xml 2011-07-26 21:14:24 UTC (rev 6934)
@@ -358,6 +358,34 @@
<artifactId>mop-spi</artifactId>
</dependency>
+ <!-- GateIn Management -->
+ <dependency>
+ <groupId>org.gatein.management</groupId>
+ <artifactId>gatein-management-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.gatein.management</groupId>
+ <artifactId>gatein-management-spi</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.gatein.management</groupId>
+ <artifactId>gatein-management-common</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.gatein.management</groupId>
+ <artifactId>gatein-management-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.gatein.management</groupId>
+ <artifactId>gatein-management-rest</artifactId>
+ </dependency>
+
+ <!-- Staxnav -->
+ <dependency>
+ <groupId>org.staxnav</groupId>
+ <artifactId>staxnav.core</artifactId>
+ </dependency>
+
<!-- GateIn Captcha -->
<dependency>
<groupId>org.gatein.captcha</groupId>
Modified: portal/branches/gatein-management/packaging/jboss-as6/pkg/pom.xml
===================================================================
--- portal/branches/gatein-management/packaging/jboss-as6/pkg/pom.xml 2011-07-26 17:06:24 UTC (rev 6933)
+++ portal/branches/gatein-management/packaging/jboss-as6/pkg/pom.xml 2011-07-26 21:14:24 UTC (rev 6934)
@@ -356,6 +356,34 @@
<artifactId>mop-spi</artifactId>
</dependency>
+ <!-- GateIn Management -->
+ <dependency>
+ <groupId>org.gatein.management</groupId>
+ <artifactId>gatein-management-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.gatein.management</groupId>
+ <artifactId>gatein-management-spi</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.gatein.management</groupId>
+ <artifactId>gatein-management-common</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.gatein.management</groupId>
+ <artifactId>gatein-management-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.gatein.management</groupId>
+ <artifactId>gatein-management-rest</artifactId>
+ </dependency>
+
+ <!-- Staxnav -->
+ <dependency>
+ <groupId>org.staxnav</groupId>
+ <artifactId>staxnav.core</artifactId>
+ </dependency>
+
<!-- GateIn Captcha -->
<dependency>
<groupId>org.gatein.captcha</groupId>
Modified: portal/branches/gatein-management/packaging/jetty/pkg/pom.xml
===================================================================
--- portal/branches/gatein-management/packaging/jetty/pkg/pom.xml 2011-07-26 17:06:24 UTC (rev 6933)
+++ portal/branches/gatein-management/packaging/jetty/pkg/pom.xml 2011-07-26 21:14:24 UTC (rev 6934)
@@ -356,6 +356,34 @@
<artifactId>mop-spi</artifactId>
</dependency>
+ <!-- GateIn Management -->
+ <dependency>
+ <groupId>org.gatein.management</groupId>
+ <artifactId>gatein-management-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.gatein.management</groupId>
+ <artifactId>gatein-management-spi</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.gatein.management</groupId>
+ <artifactId>gatein-management-common</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.gatein.management</groupId>
+ <artifactId>gatein-management-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.gatein.management</groupId>
+ <artifactId>gatein-management-rest</artifactId>
+ </dependency>
+
+ <!-- Staxnav -->
+ <dependency>
+ <groupId>org.staxnav</groupId>
+ <artifactId>staxnav.core</artifactId>
+ </dependency>
+
<!-- GateIn Captcha -->
<dependency>
<groupId>org.gatein.captcha</groupId>
Modified: portal/branches/gatein-management/packaging/tomcat/pkg/pom.xml
===================================================================
--- portal/branches/gatein-management/packaging/tomcat/pkg/pom.xml 2011-07-26 17:06:24 UTC (rev 6933)
+++ portal/branches/gatein-management/packaging/tomcat/pkg/pom.xml 2011-07-26 21:14:24 UTC (rev 6934)
@@ -348,6 +348,34 @@
<artifactId>mop-spi</artifactId>
</dependency>
+ <!-- GateIn Management -->
+ <dependency>
+ <groupId>org.gatein.management</groupId>
+ <artifactId>gatein-management-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.gatein.management</groupId>
+ <artifactId>gatein-management-spi</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.gatein.management</groupId>
+ <artifactId>gatein-management-common</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.gatein.management</groupId>
+ <artifactId>gatein-management-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.gatein.management</groupId>
+ <artifactId>gatein-management-rest</artifactId>
+ </dependency>
+
+ <!-- Staxnav -->
+ <dependency>
+ <groupId>org.staxnav</groupId>
+ <artifactId>staxnav.core</artifactId>
+ </dependency>
+
<!-- GateIn Captcha -->
<dependency>
<groupId>org.gatein.captcha</groupId>
Modified: portal/branches/gatein-management/pom.xml
===================================================================
--- portal/branches/gatein-management/pom.xml 2011-07-26 17:06:24 UTC (rev 6933)
+++ portal/branches/gatein-management/pom.xml 2011-07-26 21:14:24 UTC (rev 6934)
@@ -49,6 +49,7 @@
<org.picketlink.idm>1.3.0.Alpha03</org.picketlink.idm>
<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-Alpha02-SNAPSHOT</org.gatein.mgmt.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>
@@ -56,6 +57,7 @@
<javax.servlet.version>2.5</javax.servlet.version>
<version.chromattic>1.1.0-beta6</version.chromattic>
<version.reflext>1.1.0-beta12</version.reflext>
+ <org.staxnav.version>0.9.3</org.staxnav.version>
<jcip.version>1.0</jcip.version>
<!-- ************** -->
@@ -321,6 +323,32 @@
<artifactId>mop-core</artifactId>
<version>${org.gatein.mop.version}</version>
</dependency>
+ <!-- Gatein Mgmt -->
+ <dependency>
+ <groupId>org.gatein.management</groupId>
+ <artifactId>gatein-management-api</artifactId>
+ <version>${org.gatein.mgmt.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.gatein.management</groupId>
+ <artifactId>gatein-management-spi</artifactId>
+ <version>${org.gatein.mgmt.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.gatein.management</groupId>
+ <artifactId>gatein-management-common</artifactId>
+ <version>${org.gatein.mgmt.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.gatein.management</groupId>
+ <artifactId>gatein-management-core</artifactId>
+ <version>${org.gatein.mgmt.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.gatein.management</groupId>
+ <artifactId>gatein-management-rest</artifactId>
+ <version>${org.gatein.mgmt.version}</version>
+ </dependency>
<!-- WSRP -->
<dependency>
<groupId>org.gatein.wsrp</groupId>
@@ -637,6 +665,13 @@
<version>${version.chromattic}</version>
</dependency>
+ <!-- Staxnav -->
+ <dependency>
+ <groupId>org.staxnav</groupId>
+ <artifactId>staxnav.core</artifactId>
+ <version>${org.staxnav.version}</version>
+ </dependency>
+
<!-- Picketlink -->
<dependency>
<groupId>org.picketlink.idm</groupId>
13 years, 5 months
gatein SVN: r6933 - sandbox/as7_support/trunk.
by do-not-reply@jboss.org
Author: mstruk
Date: 2011-07-26 13:06:24 -0400 (Tue, 26 Jul 2011)
New Revision: 6933
Modified:
sandbox/as7_support/trunk/README.txt
Log:
Updated build instructions to include JBoss Portlet Bridge example
Modified: sandbox/as7_support/trunk/README.txt
===================================================================
--- sandbox/as7_support/trunk/README.txt 2011-07-26 16:38:31 UTC (rev 6932)
+++ sandbox/as7_support/trunk/README.txt 2011-07-26 17:06:24 UTC (rev 6933)
@@ -2,9 +2,19 @@
To deploy SimplePortal to JBoss AS7 follow these steps:
+Checkout JBoss Portlet Bridge sources (we package SimplePortal with JBossPortletBridge (JPB) example that's not available in maven repository).
-Check out the sources. To checkout as7_support trunk use:
+svn co svn co http://anonsvn.jboss.org/repos/portletbridge/tags/3.0.0.Beta1 jboss-portletbridge-3.0.0.Beta1
+cd jboss-portletbridge-3.0.0.Beta1
+Build JBP:
+
+mvn install -DskipTests
+cd ..
+
+
+Checkout as7_support trunk:
+
svn co http://anonsvn.jboss.org/repos/gatein/sandbox/as7_support/trunk as7_support
cd as7_support
13 years, 5 months