[gatein-commits] gatein SVN: r5046 - in epp/portal/branches/EPP_5_1_Branch: component/wsrp and 17 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Thu Nov 11 13:25:36 EST 2010
Author: thomas.heute at jboss.com
Date: 2010-11-11 13:25:34 -0500 (Thu, 11 Nov 2010)
New Revision: 5046
Added:
epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/structure/
epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/structure/MOPConsumerStructureProvider.java
epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/structure/MOPPortalStructureAccess.java
epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/structure/PortalStructureAccess.java
epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/test/java/org/gatein/portal/wsrp/structure/
epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/test/java/org/gatein/portal/wsrp/structure/MOPConsumerStructureProviderTestCase.java
epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/conf/wsrp/portal/
epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/conf/wsrp/portal/group/
epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/conf/wsrp/portal/group/platform/
epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/conf/wsrp/portal/group/platform/administrators/
epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/conf/wsrp/portal/group/platform/administrators/navigation.xml
epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/conf/wsrp/portal/group/platform/administrators/pages.xml
Removed:
epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/MOPConsumerStructureProvider.java
epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/structure/MOPConsumerStructureProvider.java
epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/structure/MOPPortalStructureAccess.java
epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/structure/PortalStructureAccess.java
epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/test/java/org/gatein/portal/wsrp/structure/MOPConsumerStructureProviderTestCase.java
epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/conf/wsrp/portal/group/
epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/conf/wsrp/portal/group/platform/
epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/conf/wsrp/portal/group/platform/administrators/
epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/conf/wsrp/portal/group/platform/administrators/navigation.xml
epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/conf/wsrp/portal/group/platform/administrators/pages.xml
Modified:
epp/portal/branches/EPP_5_1_Branch/.classpath
epp/portal/branches/EPP_5_1_Branch/component/wsrp/pom.xml
epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/WSRPServiceIntegration.java
epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/JCRPersister.java
epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/JCRConsumerRegistry.java
epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/migration/JCRMigrationService.java
epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/producer/configuration/JCRProducerConfigurationService.java
epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/producer/registrations/JCRRegistrationPersistenceManager.java
epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/producer/state/JCRPortletStatePersistenceManager.java
epp/portal/branches/EPP_5_1_Branch/pom.xml
epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/conf/wsrp/wsrp-configuration.xml
epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/ExoPortletInvocationContext.java
epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortlet.java
epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletActionListener.java
epp/portal/branches/EPP_5_1_Branch/webui/portlet/src/main/java/org/exoplatform/webui/application/portlet/PortletURLBuilder.java
Log:
JBEPP-613: Update WSRP
Modified: epp/portal/branches/EPP_5_1_Branch/.classpath
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/.classpath 2010-11-11 16:24:41 UTC (rev 5045)
+++ epp/portal/branches/EPP_5_1_Branch/.classpath 2010-11-11 18:25:34 UTC (rev 5046)
@@ -83,6 +83,7 @@
<classpathentry excluding="**" kind="src" output="examples/portlets/struts-jpetstore/target/classes" path="examples/portlets/struts-jpetstore/src/main/resources"/>
<classpathentry kind="src" output="examples/portlets/struts-jpetstore/target/test-classes" path="examples/portlets/struts-jpetstore/src/test/java"/>
<classpathentry excluding="**" kind="src" output="examples/portlets/struts-jpetstore/target/test-classes" path="examples/portlets/struts-jpetstore/src/test/resources"/>
+ <classpathentry kind="src" output="starter/war/target/classes" path="starter/war/src/main/java"/>
<classpathentry kind="src" output="testsuite/selenium-snifftests/target/classes" path="testsuite/selenium-snifftests/src/main/java"/>
<classpathentry kind="src" output="testsuite/webuibasedsamples/target/classes" path="testsuite/webuibasedsamples/src/main/java"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
Modified: epp/portal/branches/EPP_5_1_Branch/component/wsrp/pom.xml
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/component/wsrp/pom.xml 2010-11-11 16:24:41 UTC (rev 5045)
+++ epp/portal/branches/EPP_5_1_Branch/component/wsrp/pom.xml 2010-11-11 18:25:34 UTC (rev 5046)
@@ -103,6 +103,10 @@
<groupId>org.chromattic</groupId>
<artifactId>chromattic.spi</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.gatein.wci</groupId>
+ <artifactId>wci-wci</artifactId>
+ </dependency>
<!-- Required to process Chromattic annotations -->
<dependency>
@@ -118,8 +122,10 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.gatein.wci</groupId>
- <artifactId>wci-wci</artifactId>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <version>1.8.5</version>
+ <scope>test</scope>
</dependency>
</dependencies>
Deleted: epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/MOPConsumerStructureProvider.java
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/MOPConsumerStructureProvider.java 2010-11-11 16:24:41 UTC (rev 5045)
+++ epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/MOPConsumerStructureProvider.java 2010-11-11 18:25:34 UTC (rev 5046)
@@ -1,214 +0,0 @@
-/*
- * JBoss, a division of Red Hat
- * Copyright 2010, 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.wsrp;
-
-import org.exoplatform.container.ExoContainer;
-import org.exoplatform.portal.mop.Described;
-import org.exoplatform.portal.pom.config.POMSession;
-import org.exoplatform.portal.pom.config.POMSessionManager;
-import org.exoplatform.portal.pom.data.PageKey;
-import org.exoplatform.portal.pom.spi.wsrp.WSRP;
-import org.gatein.common.util.ParameterValidation;
-import org.gatein.mop.api.content.Customization;
-import org.gatein.mop.api.workspace.ObjectType;
-import org.gatein.mop.api.workspace.Page;
-import org.gatein.mop.api.workspace.Site;
-import org.gatein.mop.api.workspace.Workspace;
-import org.gatein.mop.api.workspace.ui.UIComponent;
-import org.gatein.mop.api.workspace.ui.UIContainer;
-import org.gatein.mop.api.workspace.ui.UIWindow;
-import org.gatein.pc.api.PortletContext;
-import org.gatein.pc.api.PortletStateType;
-import org.gatein.pc.api.StatefulPortletContext;
-import org.gatein.wsrp.api.context.ConsumerStructureProvider;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:chris.laprun at jboss.com">Chris Laprun</a>
- * @version $Revision$
- */
-public class MOPConsumerStructureProvider implements ConsumerStructureProvider
-{
- private final POMSessionManager pomManager;
- private Map<String, PageInfo> pageInfos;
- private Map<String, String> windowIdToUUIDs;
-
- public MOPConsumerStructureProvider(ExoContainer container)
- {
- pomManager = (POMSessionManager)container.getComponentInstanceOfType(POMSessionManager.class);
- windowIdToUUIDs = new HashMap<String, String>();
- }
-
- public List<String> getPageIdentifiers()
- {
- if (pageInfos == null)
- {
- POMSession session = pomManager.getSession();
- Workspace workspace = session.getWorkspace();
- Collection<Site> sites = workspace.getSites(ObjectType.PORTAL_SITE);
-
- pageInfos = new HashMap<String, PageInfo>();
- for (Site site : sites)
- {
- Page page = site.getRootPage().getChild("pages");
- if (page != null)
- {
- processPage(page, true);
- }
- }
- }
-
- LinkedList<String> identifiers = new LinkedList<String>(pageInfos.keySet());
- Collections.sort(identifiers);
- return identifiers;
- }
-
- private void processPage(Page page, boolean ignoreCurrent)
- {
- if (!ignoreCurrent)
- {
- Described described = page.adapt(Described.class);
- PageInfo pageInfo = new PageInfo(page.getObjectId());
- pageInfos.put(described.getName(), pageInfo);
- UIContainer container = page.getRootComponent();
- processContainer(container, pageInfo);
- }
-
- Collection<Page> children = page.getChildren();
- if (ParameterValidation.existsAndIsNotEmpty(children))
- {
- for (Page child : children)
- {
- processPage(child, false);
- }
- }
- }
-
- public List<String> getWindowIdentifiersFor(String pageId)
- {
- PageInfo pageInfo = pageInfos.get(pageId);
- ParameterValidation.throwIllegalArgExceptionIfNull(pageInfo, "PageInfo for " + pageId);
-
- return pageInfo.getChildrenWindows();
- }
-
- private void processContainer(UIContainer container, PageInfo pageInfo)
- {
- List<UIComponent> components = container.getComponents();
- for (UIComponent component : components)
- {
- ObjectType<? extends UIComponent> type = component.getObjectType();
- if (ObjectType.WINDOW.equals(type))
- {
- Described described = component.adapt(Described.class);
- String name = described.getName();
- windowIdToUUIDs.put(name, component.getObjectId());
- pageInfo.addWindow(name);
- }
- else if (ObjectType.CONTAINER.equals(type))
- {
- processContainer((UIContainer)component, pageInfo);
- }
- else
- {
- // ignore
- }
- }
- }
-
- public void assignPortletToWindow(PortletContext portletContext, String windowId, String pageId)
- {
- String uuid = windowIdToUUIDs.get(windowId);
- ParameterValidation.throwIllegalArgExceptionIfNull(uuid, "UUID for " + windowId);
-
- // get the window
- POMSession session = pomManager.getSession();
- UIWindow window = session.findObjectById(ObjectType.WINDOW, uuid);
-
- // construct the new customization state
- WSRP wsrp = new WSRP();
- String portletId = portletContext.getId();
- wsrp.setPortletId(portletId);
- if (portletContext instanceof StatefulPortletContext)
- {
- StatefulPortletContext context = (StatefulPortletContext)portletContext;
- if (PortletStateType.OPAQUE.equals(context.getType()))
- {
- wsrp.setState((byte[])context.getState());
- }
- else
- {
- throw new IllegalArgumentException("Don't know how to deal with state: " + context.getState());
- }
- }
-
- // destroy existing customization as otherwise re-customizing will fail
- Customization<?> customization = window.getCustomization();
- customization.destroy();
-
- // and re-customize
- window.customize(WSRP.CONTENT_TYPE, portletId, wsrp);
-
- // mark page for cache invalidation otherwise DataCache will use the previous customization id when trying to set
- // the portlet state in UIPortlet.setState and will not find it resulting in an error
- Page page = window.getPage();
- session.scheduleForEviction(new PageKey("portal", page.getSite().getName(), page.getName()));
-
- // save
- session.close(true);
- }
-
- private static class PageInfo
- {
- private String uuid;
- private List<String> childrenWindows;
-
- private PageInfo(String uuid)
- {
- this.uuid = uuid;
- childrenWindows = new LinkedList<String>();
- }
-
- public String getUUID()
- {
- return uuid;
- }
-
- public List<String> getChildrenWindows()
- {
- return childrenWindows;
- }
-
- public void addWindow(String windowName)
- {
- childrenWindows.add(windowName);
- }
- }
-}
Modified: epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/WSRPServiceIntegration.java
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/WSRPServiceIntegration.java 2010-11-11 16:24:41 UTC (rev 5045)
+++ epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/WSRPServiceIntegration.java 2010-11-11 18:25:34 UTC (rev 5046)
@@ -27,7 +27,9 @@
import org.exoplatform.container.ExoContainerContext;
import org.exoplatform.container.configuration.ConfigurationManager;
import org.exoplatform.container.xml.InitParams;
+import org.exoplatform.portal.config.DataStorage;
import org.exoplatform.portal.pc.ExoKernelIntegration;
+import org.exoplatform.portal.pom.config.POMSessionManager;
import org.exoplatform.services.jcr.ext.hierarchy.NodeHierarchyCreator;
import org.exoplatform.services.listener.ListenerService;
import org.gatein.common.logging.Logger;
@@ -47,6 +49,9 @@
import org.gatein.portal.wsrp.state.producer.configuration.JCRProducerConfigurationService;
import org.gatein.portal.wsrp.state.producer.registrations.JCRRegistrationPersistenceManager;
import org.gatein.portal.wsrp.state.producer.state.JCRPortletStatePersistenceManager;
+import org.gatein.portal.wsrp.structure.MOPConsumerStructureProvider;
+import org.gatein.portal.wsrp.structure.MOPPortalStructureAccess;
+import org.gatein.portal.wsrp.structure.PortalStructureAccess;
import org.gatein.registration.RegistrationManager;
import org.gatein.registration.RegistrationPersistenceManager;
import org.gatein.registration.impl.RegistrationManagerImpl;
@@ -267,20 +272,28 @@
// add our Session event listener to the ListenerService for use in org.exoplatform.web.GenericHttpListener
ListenerService listenerService = (ListenerService)container.getComponentInstanceOfType(ListenerService.class);
SessionEventListenerAndBroadcaster sessionEventBroadcaster = new SessionEventListenerAndBroadcaster();
- sessionEventBroadcaster.setName("org.exoplatform.web.GenericHttpListener.sessionCreated");
- listenerService.addListener(sessionEventBroadcaster);
- sessionEventBroadcaster.setName("org.exoplatform.web.GenericHttpListener.sessionDestroyed");
- listenerService.addListener(sessionEventBroadcaster);
+ // events from org.exoplatform.web.GenericHttpListener
+ listenerService.addListener("org.exoplatform.web.GenericHttpListener.sessionCreated", sessionEventBroadcaster);
+ listenerService.addListener("org.exoplatform.web.GenericHttpListener.sessionDestroyed", sessionEventBroadcaster);
+
try
{
consumerRegistry = new JCRConsumerRegistry(container);
consumerRegistry.setFederatingPortletInvoker(federatingPortletInvoker);
consumerRegistry.setSessionEventBroadcaster(sessionEventBroadcaster);
+ // create ConsumerStructureProvider and register it to listen to page events
+ POMSessionManager sessionManager = (POMSessionManager)container.getComponentInstanceOfType(POMSessionManager.class);
+ PortalStructureAccess structureAccess = new MOPPortalStructureAccess(sessionManager);
+ MOPConsumerStructureProvider structureprovider = new MOPConsumerStructureProvider(structureAccess);
+ listenerService.addListener(DataStorage.PAGE_CREATED, structureprovider);
+ listenerService.addListener(DataStorage.PAGE_REMOVED, structureprovider);
+ listenerService.addListener(DataStorage.PAGE_UPDATED, structureprovider);
+
// migration service
MigrationService migrationService = new JCRMigrationService(container);
- migrationService.setStructureProvider(new MOPConsumerStructureProvider(container));
+ migrationService.setStructureProvider(structureprovider);
consumerRegistry.setMigrationService(migrationService);
consumerRegistry.start();
Modified: epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/JCRPersister.java
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/JCRPersister.java 2010-11-11 16:24:41 UTC (rev 5045)
+++ epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/JCRPersister.java 2010-11-11 18:25:34 UTC (rev 5046)
@@ -1,28 +1,28 @@
/*
-* 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.
-*/
+ * JBoss, a division of Red Hat
+ * Copyright 2010, 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.wsrp.state;
-import EDU.oswego.cs.dl.util.concurrent.FJTask;
import org.chromattic.api.Chromattic;
import org.chromattic.api.ChromatticBuilder;
import org.chromattic.api.ChromatticSession;
@@ -59,6 +59,8 @@
private String workspaceName;
private Map<Class, Class<? extends BaseMapping>> modelToMapping;
+ private ThreadLocal<ChromatticSession> sessionHolder = new ThreadLocal<ChromatticSession>();
+
public JCRPersister(ExoContainer container, String workspaceName)
{
this.workspaceName = workspaceName;
@@ -87,7 +89,7 @@
if (BaseMapping.class.isAssignableFrom(mappingClass))
{
Type[] interfaces = mappingClass.getGenericInterfaces();
- if(ParameterValidation.existsAndIsNotEmpty(interfaces))
+ if (ParameterValidation.existsAndIsNotEmpty(interfaces))
{
Class type = (Class)((ParameterizedType)interfaces[0]).getActualTypeArguments()[0];
modelToMapping.put(type, mappingClass);
@@ -101,28 +103,41 @@
public ChromatticSession getSession()
{
- return chrome.openSession();
+ if (sessionHolder.get() == null)
+ {
+ ChromatticSession session = chrome.openSession();
+ sessionHolder.set(session);
+ return session;
+ }
+ else
+ {
+ return sessionHolder.get();
+ }
}
- public void closeSession(ChromatticSession session, boolean save)
+ public void closeSession(boolean save)
{
+ ChromatticSession session = getSession();
if (save)
{
- session.save();
+ synchronized (this)
+ {
+ session.save();
+ }
}
session.close();
}
- public void save(ChromatticSession session)
+ public synchronized void save()
{
- session.save();
+ getSession().save();
}
public <T> boolean delete(T toDelete, StoresByPathManager<T> manager)
{
Class<? extends Object> modelClass = toDelete.getClass();
Class<? extends BaseMapping> baseMappingClass = modelToMapping.get(modelClass);
- if(baseMappingClass == null)
+ if (baseMappingClass == null)
{
throw new IllegalArgumentException("Cannot find a mapping class for " + modelClass.getName());
}
@@ -134,12 +149,12 @@
if (old != null)
{
session.remove(old);
- closeSession(session, true);
+ closeSession(true);
return true;
}
else
{
- closeSession(session, false);
+ closeSession(false);
return false;
}
Modified: epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/JCRConsumerRegistry.java
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/JCRConsumerRegistry.java 2010-11-11 16:24:41 UTC (rev 5045)
+++ epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/JCRConsumerRegistry.java 2010-11-11 18:25:34 UTC (rev 5046)
@@ -1,6 +1,6 @@
/*
* JBoss, a division of Red Hat
- * Copyright 2009, Red Hat Middleware, LLC, and individual
+ * Copyright 2010, 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.
@@ -49,7 +49,7 @@
*/
public class JCRConsumerRegistry extends AbstractConsumerRegistry implements StoresByPathManager<ProducerInfo>
{
-// private NewJCRPersister persister;
+ // private NewJCRPersister persister;
private JCRPersister persister;
private static final String PRODUCER_INFOS_PATH = ProducerInfosMapping.NODE_NAME;
@@ -78,12 +78,12 @@
info.setKey(key);
pim.initFrom(info);
- persister.closeSession(session, true);
+ persister.closeSession(true);
}
catch (Exception e)
{
e.printStackTrace(); // todo: fix me
- persister.closeSession(session, false);
+ persister.closeSession(false);
}
}
@@ -113,7 +113,7 @@
String newId = producerInfo.getId();
pim.initFrom(producerInfo);
- persister.closeSession(session, true);
+ persister.closeSession(true);
// if the consumer's id has changed, return the old one so that state can be updated
return (oldId.equals(newId)) ? null : oldId;
@@ -127,7 +127,7 @@
List<ProducerInfoMapping> mappings = producerInfosMapping.getProducerInfos();
- persister.closeSession(session, true);
+ persister.closeSession(true);
return new MappingToProducerInfoIterator(mappings.iterator());
}
Modified: epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/migration/JCRMigrationService.java
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/migration/JCRMigrationService.java 2010-11-11 16:24:41 UTC (rev 5045)
+++ epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/migration/JCRMigrationService.java 2010-11-11 18:25:34 UTC (rev 5046)
@@ -85,7 +85,7 @@
exportInfos.add(eim.toModel(null));
}
- persister.closeSession(session, false);
+ persister.closeSession(false);
exportInfosCount = exportInfos.size();
@@ -95,7 +95,7 @@
private ExportInfosMapping getExportInfosMapping(ChromatticSession session)
{
ExportInfosMapping exportInfosMapping = session.findByPath(ExportInfosMapping.class, ExportInfosMapping.NODE_NAME);
- if(exportInfosMapping == null)
+ if (exportInfosMapping == null)
{
exportInfosMapping = session.insert(ExportInfosMapping.class, ExportInfosMapping.NODE_NAME);
exportInfosCount = 0;
@@ -110,7 +110,7 @@
ExportInfoMapping eim = session.findByPath(ExportInfoMapping.class, getPathFor(exportTime));
- if(eim != null)
+ if (eim != null)
{
return eim.toModel(null);
}
@@ -126,7 +126,7 @@
ExportInfoMapping eim = session.findByPath(ExportInfoMapping.class, getChildPath(info));
long exportTime = info.getExportTime();
- if(eim != null)
+ if (eim != null)
{
throw new IllegalArgumentException("An ExportInfo with export time "
+ exportTime + " already exists!");
@@ -139,7 +139,7 @@
session.persist(exportInfosMapping, exportInfo, exportTimeAsString);
exportInfo.initFrom(info);
- persister.closeSession(session, true);
+ persister.closeSession(true);
exportInfosCount++;
}
}
@@ -159,7 +159,7 @@
public boolean isAvailableExportInfosEmpty()
{
- if(exportInfosCount == -1)
+ if (exportInfosCount == -1)
{
ChromatticSession session = persister.getSession();
ExportInfosMapping mappings = getExportInfosMapping(session);
Modified: epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/producer/configuration/JCRProducerConfigurationService.java
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/producer/configuration/JCRProducerConfigurationService.java 2010-11-11 16:24:41 UTC (rev 5045)
+++ epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/producer/configuration/JCRProducerConfigurationService.java 2010-11-11 18:25:34 UTC (rev 5046)
@@ -1,6 +1,6 @@
/*
* JBoss, a division of Red Hat
- * Copyright 2009, Red Hat Middleware, LLC, and individual
+ * Copyright 2010, 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.
@@ -47,7 +47,7 @@
private static String PRODUCER_CONFIGURATION_PATH = ProducerConfigurationMapping.NODE_NAME;
private InputStream defaultConfigurationIS;
-// private NewJCRPersister persister;
+ // private NewJCRPersister persister;
private JCRPersister persister;
public JCRProducerConfigurationService(ExoContainer container) throws Exception
@@ -96,7 +96,7 @@
}
- persister.closeSession(session, true);
+ persister.closeSession(true);
}
public void saveConfiguration() throws Exception
@@ -110,6 +110,6 @@
}
pcm.initFrom(configuration);
- persister.closeSession(session, true);
+ persister.closeSession(true);
}
}
Modified: epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/producer/registrations/JCRRegistrationPersistenceManager.java
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/producer/registrations/JCRRegistrationPersistenceManager.java 2010-11-11 16:24:41 UTC (rev 5045)
+++ epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/producer/registrations/JCRRegistrationPersistenceManager.java 2010-11-11 18:25:34 UTC (rev 5046)
@@ -1,24 +1,25 @@
/*
-* 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.
-*/
+ * JBoss, a division of Red Hat
+ * Copyright 2010, 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.wsrp.state.producer.registrations;
@@ -51,7 +52,7 @@
*/
public class JCRRegistrationPersistenceManager extends RegistrationPersistenceManagerImpl
{
-// private NewJCRPersister persister;
+ // private NewJCRPersister persister;
private JCRPersister persister;
private ConsumersAndGroupsMapping mappings;
@@ -73,7 +74,7 @@
{
mappings = session.insert(ConsumersAndGroupsMapping.class, ConsumersAndGroupsMapping.NODE_NAME);
}
- persister.save(session); // needed right now as the session must still be open to iterate over nodes
+ persister.save(); // needed right now as the session must still be open to iterate over nodes
for (ConsumerGroupMapping cgm : mappings.getConsumerGroups())
{
@@ -92,7 +93,7 @@
}
}
- persister.closeSession(session, false);
+ persister.closeSession(false);
}
@Override
@@ -115,12 +116,12 @@
RegistrationMapping rm = cm.createAndAddRegistrationMappingFrom(null);
registration = newRegistrationSPI(consumer, registrationProperties, rm.getPersistentKey());
rm.initFrom(registration);
- persister.closeSession(session, true);
+ persister.closeSession(true);
}
catch (Exception e)
{
e.printStackTrace(); // todo fix me
- persister.closeSession(session, false);
+ persister.closeSession(false);
}
return registration;
@@ -138,7 +139,7 @@
{
ChromatticSession session = persister.getSession();
session.remove(session.findById(clazz, id));
- persister.closeSession(session, true);
+ persister.closeSession(true);
}
@Override
@@ -154,12 +155,12 @@
mappings.getConsumers().add(cm);
cm.initFrom(consumer);
consumer.setPersistentKey(cm.getPersistentKey());
- persister.closeSession(session, true);
+ persister.closeSession(true);
}
catch (Exception e)
{
e.printStackTrace(); // todo: fix me
- persister.closeSession(session, false);
+ persister.closeSession(false);
}
return consumer;
@@ -175,34 +176,34 @@
{
ConsumerMapping cm = session.findById(ConsumerMapping.class, consumer.getPersistentKey());
cm.initFrom(consumer);
- persister.closeSession(session, true);
+ persister.closeSession(true);
}
catch (Exception e)
{
e.printStackTrace(); // todo: fix me
- persister.closeSession(session, false);
+ persister.closeSession(false);
}
return consumerSPI;
}
-
+
protected RegistrationSPI internalSaveChangesTo(Registration registration)
{
RegistrationSPI registrationSPI = super.internalSaveChangesTo(registration);
-
+
ChromatticSession session = persister.getSession();
try
{
RegistrationMapping cm = session.findById(RegistrationMapping.class, registration.getPersistentKey());
cm.initFrom(registration);
- persister.closeSession(session, true);
+ persister.closeSession(true);
}
catch (Exception e)
{
e.printStackTrace(); //todo: fix me
- persister.closeSession(session, false);
+ persister.closeSession(false);
}
-
+
return registrationSPI;
}
@@ -234,12 +235,12 @@
mappings.getConsumerGroups().add(cgm);
group.setPersistentKey(cgm.getPersistentKey());
cgm.initFrom(group);
- persister.closeSession(session, true);
+ persister.closeSession(true);
}
catch (Exception e)
{
e.printStackTrace(); // todo: fix me
- persister.closeSession(session, false);
+ persister.closeSession(false);
}
return group;
Modified: epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/producer/state/JCRPortletStatePersistenceManager.java
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/producer/state/JCRPortletStatePersistenceManager.java 2010-11-11 16:24:41 UTC (rev 5045)
+++ epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/producer/state/JCRPortletStatePersistenceManager.java 2010-11-11 18:25:34 UTC (rev 5046)
@@ -83,7 +83,7 @@
PortletStateMapping psm = pscm.getState();
psm.setProperties(propertyMap);
- persister.closeSession(session, true);
+ persister.closeSession(true);
}
@@ -103,7 +103,7 @@
context = pscm.toPortletStateContext();
}
- persister.closeSession(session, false);
+ persister.closeSession(false);
return context;
}
@@ -127,7 +127,7 @@
psm.setPortletID(pscm.getPortletId());
psm.setProperties(propertyMap);
- persister.closeSession(session, true);
+ persister.closeSession(true);
return pscm.getPersistentKey();
}
@@ -150,7 +150,7 @@
result = pscm.toPortletStateContext();
}
- persister.closeSession(session, true);
+ persister.closeSession(true);
return result;
}
Copied: epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/structure (from rev 4924, portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/structure)
Deleted: epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/structure/MOPConsumerStructureProvider.java
===================================================================
--- portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/structure/MOPConsumerStructureProvider.java 2010-11-03 20:48:19 UTC (rev 4924)
+++ epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/structure/MOPConsumerStructureProvider.java 2010-11-11 18:25:34 UTC (rev 5046)
@@ -1,283 +0,0 @@
-/*
- * JBoss, a division of Red Hat
- * Copyright 2010, 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.wsrp.structure;
-
-import org.exoplatform.portal.config.DataStorage;
-import org.exoplatform.portal.mop.Described;
-import org.exoplatform.portal.pom.spi.wsrp.WSRP;
-import org.exoplatform.services.listener.Event;
-import org.exoplatform.services.listener.Listener;
-import org.gatein.common.util.ParameterValidation;
-import org.gatein.mop.api.content.Customization;
-import org.gatein.mop.api.workspace.ObjectType;
-import org.gatein.mop.api.workspace.Page;
-import org.gatein.mop.api.workspace.ui.UIComponent;
-import org.gatein.mop.api.workspace.ui.UIContainer;
-import org.gatein.mop.api.workspace.ui.UIWindow;
-import org.gatein.pc.api.PortletContext;
-import org.gatein.pc.api.PortletStateType;
-import org.gatein.pc.api.StatefulPortletContext;
-import org.gatein.wsrp.api.context.ConsumerStructureProvider;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:chris.laprun at jboss.com">Chris Laprun</a>
- * @version $Revision$
- */
-public class MOPConsumerStructureProvider extends Listener<DataStorage, org.exoplatform.portal.config.model.Page> implements ConsumerStructureProvider
-{
- private final PortalStructureAccess structureAccess;
- private Map<String, PageInfo> pageInfos;
- private boolean pagesHaveBeenInitialized;
-
- public MOPConsumerStructureProvider(PortalStructureAccess structureAccess)
- {
- ParameterValidation.throwIllegalArgExceptionIfNull(structureAccess, "PortalStructureAccess");
-
- this.structureAccess = structureAccess;
- pageInfos = new HashMap<String, PageInfo>();
- }
-
- public List<String> getPageIdentifiers()
- {
- if (!pagesHaveBeenInitialized)
- {
- // initialize page information
- Collection<Page> pages = structureAccess.getPages();
- for (Page page : pages)
- {
- addPage(page);
- }
-
- pagesHaveBeenInitialized = true;
- }
-
- LinkedList<String> identifiers = new LinkedList<String>(pageInfos.keySet());
- Collections.sort(identifiers);
- return identifiers;
- }
-
- private void addPage(Page page)
- {
- Described described = page.adapt(Described.class);
- PageInfo pageInfo = new PageInfo(page.getObjectId(), described.getName());
- pageInfos.put(pageInfo.getName(), pageInfo);
- UIContainer container = page.getRootComponent();
- processContainer(container, pageInfo);
-
- Collection<Page> children = page.getChildren();
- if (ParameterValidation.existsAndIsNotEmpty(children))
- {
- for (Page child : children)
- {
- addPage(child);
- }
- }
- }
-
- public List<String> getWindowIdentifiersFor(String pageId)
- {
- PageInfo pageInfo = pageInfos.get(pageId);
- ParameterValidation.throwIllegalArgExceptionIfNull(pageInfo, "PageInfo for " + pageId);
-
- return pageInfo.getChildrenWindows();
- }
-
- private void processContainer(UIContainer container, PageInfo pageInfo)
- {
- if (container != null)
- {
- List<UIComponent> components = container.getComponents();
- for (UIComponent component : components)
- {
- ObjectType<? extends UIComponent> type = component.getObjectType();
- if (ObjectType.WINDOW.equals(type))
- {
- Described described = component.adapt(Described.class);
- String name = described.getName();
-
- pageInfo.addWindow(name, component.getObjectId());
- }
- else if (ObjectType.CONTAINER.equals(type))
- {
- processContainer((UIContainer)component, pageInfo);
- }
- else
- {
- // ignore
- }
- }
- }
- }
-
- public void assignPortletToWindow(PortletContext portletContext, String windowId, String pageId, String exportedPortletHandle)
- {
- PageInfo pageInfo = pageInfos.get(pageId);
- String uuid = pageInfo.getWindowUUID(windowId);
- ParameterValidation.throwIllegalArgExceptionIfNull(uuid, "UUID for " + windowId);
-
- // get the window
- UIWindow window = structureAccess.getWindowFrom(uuid);
-
- // construct the new customization state
- WSRP wsrp = new WSRP();
- String portletId = portletContext.getId();
- wsrp.setPortletId(portletId);
- if (portletContext instanceof StatefulPortletContext)
- {
- StatefulPortletContext context = (StatefulPortletContext)portletContext;
- if (PortletStateType.OPAQUE.equals(context.getType()))
- {
- wsrp.setState((byte[])context.getState());
- }
- else
- {
- throw new IllegalArgumentException("Don't know how to deal with state: " + context.getState());
- }
- }
-
- // destroy existing customization as otherwise re-customizing will fail
- Customization<?> customization = window.getCustomization();
- customization.destroy();
-
- // and re-customize
- window.customize(WSRP.CONTENT_TYPE, portletId, wsrp);
-
- // Change the window's name so that it's less confusing to users
- Described described = window.adapt(Described.class);
- String newName = exportedPortletHandle + " (remote)";
- described.setName(newName); // should be the same as ApplicationRegistryService.REMOTE_DISPLAY_NAME_SUFFIX
-
- // update window mappings
- pageInfo.updateWindowName(windowId, newName);
-
- structureAccess.saveChangesTo(window);
- }
-
- @Override
- public void onEvent(Event<DataStorage, org.exoplatform.portal.config.model.Page> event) throws Exception
- {
- String eventName = event.getEventName();
-
- // get the MOP page from the event data
- org.exoplatform.portal.config.model.Page portalPage = event.getData();
- Page page = structureAccess.getPageFrom(portalPage);
-
- if (page != null)
- {
- if (DataStorage.PAGE_CREATED.equals(eventName))
- {
- // add information for new page
- addPage(page);
- }
- else if (DataStorage.PAGE_REMOVED.equals(eventName))
- {
- removePage(page);
- }
- else if (DataStorage.PAGE_UPDATED.equals(eventName))
- {
- removePage(page);
- addPage(page);
- }
- }
- }
-
- private void removePage(Page page)
- {
- Described described = page.adapt(Described.class);
- String name = described.getName();
-
- PageInfo pageInfo = pageInfos.get(name);
- if (pageInfo != null)
- {
- // remove page info
- pageInfos.remove(name);
- }
- }
-
- private static class PageInfo
- {
- private final String uuid;
- private final Map<String, String> childrenWindows = new HashMap<String, String>();
- private final String name;
-
- private PageInfo(String uuid, String name)
- {
- this.uuid = uuid;
- this.name = name;
- }
-
- public String getUUID()
- {
- return uuid;
- }
-
- public List<String> getChildrenWindows()
- {
- return new ArrayList<String>(childrenWindows.keySet());
- }
-
- public void addWindow(String windowName, String uuid)
- {
- // add suffix in case we have several windows with the same name in the page
- if (childrenWindows.containsKey(windowName))
- {
- if (windowName.endsWith("|"))
- {
- windowName += "|";
- }
- else
- {
- windowName += windowName + " |";
- }
- }
-
- childrenWindows.put(windowName, uuid);
- }
-
- public void updateWindowName(String oldWindowName, String newWindowName)
- {
- String windowUUID = getWindowUUID(oldWindowName);
- childrenWindows.remove(oldWindowName);
- childrenWindows.put(newWindowName, windowUUID);
- }
-
- public String getName()
- {
- return name;
- }
-
- public String getWindowUUID(String windowId)
- {
- return childrenWindows.get(windowId);
- }
- }
-}
Copied: epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/structure/MOPConsumerStructureProvider.java (from rev 4924, portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/structure/MOPConsumerStructureProvider.java)
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/structure/MOPConsumerStructureProvider.java (rev 0)
+++ epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/structure/MOPConsumerStructureProvider.java 2010-11-11 18:25:34 UTC (rev 5046)
@@ -0,0 +1,308 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2010, 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.wsrp.structure;
+
+import org.exoplatform.portal.config.DataStorage;
+import org.exoplatform.portal.mop.Described;
+import org.exoplatform.portal.pom.spi.wsrp.WSRP;
+import org.exoplatform.services.listener.Event;
+import org.exoplatform.services.listener.Listener;
+import org.gatein.common.util.ParameterValidation;
+import org.gatein.mop.api.content.Customization;
+import org.gatein.mop.api.workspace.ObjectType;
+import org.gatein.mop.api.workspace.Page;
+import org.gatein.mop.api.workspace.ui.UIComponent;
+import org.gatein.mop.api.workspace.ui.UIContainer;
+import org.gatein.mop.api.workspace.ui.UIWindow;
+import org.gatein.pc.api.PortletContext;
+import org.gatein.pc.api.PortletStateType;
+import org.gatein.pc.api.StatefulPortletContext;
+import org.gatein.wsrp.api.context.ConsumerStructureProvider;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:chris.laprun at jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ */
+public class MOPConsumerStructureProvider extends Listener<DataStorage, org.exoplatform.portal.config.model.Page> implements ConsumerStructureProvider
+{
+ private final PortalStructureAccess structureAccess;
+ private Map<String, PageInfo> pageInfos;
+ private boolean pagesHaveBeenInitialized;
+
+ public MOPConsumerStructureProvider(PortalStructureAccess structureAccess)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(structureAccess, "PortalStructureAccess");
+
+ this.structureAccess = structureAccess;
+ pageInfos = new HashMap<String, PageInfo>();
+ }
+
+ public List<String> getPageIdentifiers()
+ {
+ if (!pagesHaveBeenInitialized)
+ {
+ // initialize page information
+ Collection<Page> pages = structureAccess.getPages();
+ for (Page page : pages)
+ {
+ addPage(page);
+ }
+
+ pagesHaveBeenInitialized = true;
+ }
+
+ LinkedList<String> identifiers = new LinkedList<String>(pageInfos.keySet());
+ Collections.sort(identifiers);
+ return identifiers;
+ }
+
+ private void addPage(Page page)
+ {
+ Described described = page.adapt(Described.class);
+ PageInfo pageInfo = new PageInfo(page.getObjectId(), described.getName(), page.getName());
+ pageInfos.put(pageInfo.getName(), pageInfo);
+ UIContainer container = page.getRootComponent();
+ processContainer(container, pageInfo);
+
+ Collection<Page> children = page.getChildren();
+ if (ParameterValidation.existsAndIsNotEmpty(children))
+ {
+ for (Page child : children)
+ {
+ addPage(child);
+ }
+ }
+ }
+
+ public List<String> getWindowIdentifiersFor(String pageId)
+ {
+ PageInfo pageInfo = pageInfos.get(pageId);
+ if (pageInfo == null)
+ {
+ throw new IllegalArgumentException("Page '" + pageId + "' does not exist.");
+ }
+
+ return pageInfo.getChildrenWindows();
+ }
+
+ private void processContainer(UIContainer container, PageInfo pageInfo)
+ {
+ if (container != null)
+ {
+ List<UIComponent> components = container.getComponents();
+ for (UIComponent component : components)
+ {
+ ObjectType<? extends UIComponent> type = component.getObjectType();
+ if (ObjectType.WINDOW.equals(type))
+ {
+ Described described = component.adapt(Described.class);
+ String name = described.getName();
+
+ pageInfo.addWindow(name, component.getObjectId());
+ }
+ else if (ObjectType.CONTAINER.equals(type))
+ {
+ processContainer((UIContainer)component, pageInfo);
+ }
+ else
+ {
+ // ignore
+ }
+ }
+ }
+ }
+
+ public void assignPortletToWindow(PortletContext portletContext, String windowId, String pageId, String exportedPortletHandle)
+ {
+ PageInfo pageInfo = pageInfos.get(pageId);
+ String uuid = pageInfo.getWindowUUID(windowId);
+ ParameterValidation.throwIllegalArgExceptionIfNull(uuid, "UUID for " + windowId);
+
+ // get the window
+ UIWindow window = structureAccess.getWindowFrom(uuid);
+
+ // construct the new customization state
+ WSRP wsrp = new WSRP();
+ String portletId = portletContext.getId();
+ wsrp.setPortletId(portletId);
+ if (portletContext instanceof StatefulPortletContext)
+ {
+ StatefulPortletContext context = (StatefulPortletContext)portletContext;
+ if (PortletStateType.OPAQUE.equals(context.getType()))
+ {
+ wsrp.setState((byte[])context.getState());
+ }
+ else
+ {
+ throw new IllegalArgumentException("Don't know how to deal with state: " + context.getState());
+ }
+ }
+
+ // destroy existing customization as otherwise re-customizing will fail
+ Customization<?> customization = window.getCustomization();
+ customization.destroy();
+
+ // and re-customize
+ window.customize(WSRP.CONTENT_TYPE, portletId, wsrp);
+
+ // Change the window's name so that it's less confusing to users
+ Described described = window.adapt(Described.class);
+ String newName = exportedPortletHandle + " (remote)";
+ described.setName(newName); // should be the same as ApplicationRegistryService.REMOTE_DISPLAY_NAME_SUFFIX
+
+ // update window mappings
+ pageInfo.updateWindowName(windowId, newName);
+
+ structureAccess.saveChangesTo(window);
+ }
+
+ @Override
+ public void onEvent(Event<DataStorage, org.exoplatform.portal.config.model.Page> event) throws Exception
+ {
+ String eventName = event.getEventName();
+
+ // get the MOP page from the event data
+ org.exoplatform.portal.config.model.Page portalPage = event.getData();
+ Page page = structureAccess.getPageFrom(portalPage);
+
+ if (page == null && DataStorage.PAGE_REMOVED.equals(eventName))
+ {
+ // if we try to remove a page, when we get this event, the page has already been removed from JCR
+ // so we need to work around that fact by retrieving the corresponding PageInfo from the portal page title
+ // which should match the Described name and check that it matches the internal name before removing it
+ removePage(portalPage.getTitle(), portalPage.getName());
+
+ return;
+ }
+
+ if (page != null)
+ {
+ if (DataStorage.PAGE_CREATED.equals(eventName))
+ {
+ // add information for new page
+ addPage(page);
+ }
+ else if (DataStorage.PAGE_UPDATED.equals(eventName))
+ {
+ removePage(page);
+ addPage(page);
+ }
+ }
+ }
+
+ private void removePage(Page page)
+ {
+ Described described = page.adapt(Described.class);
+ String name = described.getName();
+
+ removePage(name, page.getName());
+ }
+
+ private void removePage(String name, String internalName)
+ {
+ PageInfo pageInfo = pageInfos.get(name);
+ if (pageInfo != null && internalName.equals(pageInfo.getInternalName()))
+ {
+ // remove page info
+ pageInfos.remove(name);
+ }
+ }
+
+ private static class PageInfo
+ {
+ private final String uuid;
+ private final Map<String, String> childrenWindows = new HashMap<String, String>();
+
+ /** Name as provided by Described */
+ private final String name;
+
+ /** Name as automatically generated */
+ private final String internalName;
+
+ private PageInfo(String uuid, String name, String internalName)
+ {
+ this.uuid = uuid;
+ this.name = name;
+ this.internalName = internalName;
+ }
+
+ public String getUUID()
+ {
+ return uuid;
+ }
+
+ public String getInternalName()
+ {
+ return internalName;
+ }
+
+ public List<String> getChildrenWindows()
+ {
+ return new ArrayList<String>(childrenWindows.keySet());
+ }
+
+ public void addWindow(String windowName, String uuid)
+ {
+ // add suffix in case we have several windows with the same name in the page
+ if (childrenWindows.containsKey(windowName))
+ {
+ if (windowName.endsWith("|"))
+ {
+ windowName += "|";
+ }
+ else
+ {
+ windowName += windowName + " |";
+ }
+ }
+
+ childrenWindows.put(windowName, uuid);
+ }
+
+ public void updateWindowName(String oldWindowName, String newWindowName)
+ {
+ String windowUUID = getWindowUUID(oldWindowName);
+ childrenWindows.remove(oldWindowName);
+ childrenWindows.put(newWindowName, windowUUID);
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public String getWindowUUID(String windowId)
+ {
+ return childrenWindows.get(windowId);
+ }
+ }
+}
Deleted: epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/structure/MOPPortalStructureAccess.java
===================================================================
--- portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/structure/MOPPortalStructureAccess.java 2010-11-03 20:48:19 UTC (rev 4924)
+++ epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/structure/MOPPortalStructureAccess.java 2010-11-11 18:25:34 UTC (rev 5046)
@@ -1,111 +0,0 @@
-/*
- * JBoss, a division of Red Hat
- * Copyright 2010, 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.wsrp.structure;
-
-import org.exoplatform.portal.pom.config.POMSession;
-import org.exoplatform.portal.pom.config.POMSessionManager;
-import org.exoplatform.portal.pom.data.Mapper;
-import org.exoplatform.portal.pom.data.PageKey;
-import org.gatein.mop.api.workspace.ObjectType;
-import org.gatein.mop.api.workspace.Page;
-import org.gatein.mop.api.workspace.Site;
-import org.gatein.mop.api.workspace.Workspace;
-import org.gatein.mop.api.workspace.ui.UIWindow;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-/**
- * @author <a href="mailto:chris.laprun at jboss.com">Chris Laprun</a>
- * @version $Revision$
- */
-public class MOPPortalStructureAccess implements PortalStructureAccess
-{
- private static final String PAGES_CHILD_NAME = "pages";
- private final POMSessionManager pomManager;
-
- public MOPPortalStructureAccess(POMSessionManager pomManager)
- {
- this.pomManager = pomManager;
- }
-
- public Collection<Page> getPages()
- {
- POMSession session = pomManager.getSession();
- Workspace workspace = session.getWorkspace();
- Collection<Site> sites = workspace.getSites(ObjectType.PORTAL_SITE);
-
- List<Page> pages = new ArrayList<Page>(sites.size() * 10);
-
- for (Site site : sites)
- {
- Page pagesRoot = getPagesFrom(site);
- if (pagesRoot != null)
- {
- Collection<Page> children = pagesRoot.getChildren();
- for (Page child : children)
- {
- pages.add(child);
- }
- }
- }
-
- return pages;
- }
-
- public UIWindow getWindowFrom(String uuid)
- {
- POMSession session = pomManager.getSession();
- return session.findObjectById(ObjectType.WINDOW, uuid);
- }
-
- public void saveChangesTo(UIWindow window)
- {
- POMSession session = pomManager.getSession();
-
- // mark page for cache invalidation otherwise DataCache will use the previous customization id when trying to set
- // the portlet state in UIPortlet.setState and will not find it resulting in an error
- Page page = window.getPage();
- session.scheduleForEviction(new PageKey("portal", page.getSite().getName(), page.getName()));
-
- // save
- session.close(true);
- }
-
- public Page getPageFrom(org.exoplatform.portal.config.model.Page portalPage)
- {
- POMSession session = pomManager.getSession();
- Site site = session.getWorkspace().getSite(Mapper.parseSiteType(portalPage.getOwnerType()), portalPage.getOwnerId());
- return getPagesFrom(site).getChild(portalPage.getName());
- }
-
- private Page getPagesFrom(Site site)
- {
- // a site contains a root page with templates and pages
- // more info at http://code.google.com/p/chromattic/wiki/MOPUseCases
-
- return site.getRootPage().getChild(PAGES_CHILD_NAME);
- }
-}
Copied: epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/structure/MOPPortalStructureAccess.java (from rev 4924, portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/structure/MOPPortalStructureAccess.java)
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/structure/MOPPortalStructureAccess.java (rev 0)
+++ epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/structure/MOPPortalStructureAccess.java 2010-11-11 18:25:34 UTC (rev 5046)
@@ -0,0 +1,111 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2010, 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.wsrp.structure;
+
+import org.exoplatform.portal.pom.config.POMSession;
+import org.exoplatform.portal.pom.config.POMSessionManager;
+import org.exoplatform.portal.pom.data.Mapper;
+import org.exoplatform.portal.pom.data.PageKey;
+import org.gatein.mop.api.workspace.ObjectType;
+import org.gatein.mop.api.workspace.Page;
+import org.gatein.mop.api.workspace.Site;
+import org.gatein.mop.api.workspace.Workspace;
+import org.gatein.mop.api.workspace.ui.UIWindow;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:chris.laprun at jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ */
+public class MOPPortalStructureAccess implements PortalStructureAccess
+{
+ private static final String PAGES_CHILD_NAME = "pages";
+ private final POMSessionManager pomManager;
+
+ public MOPPortalStructureAccess(POMSessionManager pomManager)
+ {
+ this.pomManager = pomManager;
+ }
+
+ public Collection<Page> getPages()
+ {
+ POMSession session = pomManager.getSession();
+ Workspace workspace = session.getWorkspace();
+ Collection<Site> sites = workspace.getSites(ObjectType.PORTAL_SITE);
+
+ List<Page> pages = new ArrayList<Page>(sites.size() * 10);
+
+ for (Site site : sites)
+ {
+ Page pagesRoot = getPagesFrom(site);
+ if (pagesRoot != null)
+ {
+ Collection<Page> children = pagesRoot.getChildren();
+ for (Page child : children)
+ {
+ pages.add(child);
+ }
+ }
+ }
+
+ return pages;
+ }
+
+ public UIWindow getWindowFrom(String uuid)
+ {
+ POMSession session = pomManager.getSession();
+ return session.findObjectById(ObjectType.WINDOW, uuid);
+ }
+
+ public void saveChangesTo(UIWindow window)
+ {
+ POMSession session = pomManager.getSession();
+
+ // mark page for cache invalidation otherwise DataCache will use the previous customization id when trying to set
+ // the portlet state in UIPortlet.setState and will not find it resulting in an error
+ Page page = window.getPage();
+ session.scheduleForEviction(new PageKey("portal", page.getSite().getName(), page.getName()));
+
+ // save
+ session.close(true);
+ }
+
+ public Page getPageFrom(org.exoplatform.portal.config.model.Page portalPage)
+ {
+ POMSession session = pomManager.getSession();
+ Site site = session.getWorkspace().getSite(Mapper.parseSiteType(portalPage.getOwnerType()), portalPage.getOwnerId());
+ return getPagesFrom(site).getChild(portalPage.getName());
+ }
+
+ private Page getPagesFrom(Site site)
+ {
+ // a site contains a root page with templates and pages
+ // more info at http://code.google.com/p/chromattic/wiki/MOPUseCases
+
+ return site.getRootPage().getChild(PAGES_CHILD_NAME);
+ }
+}
Deleted: epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/structure/PortalStructureAccess.java
===================================================================
--- portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/structure/PortalStructureAccess.java 2010-11-03 20:48:19 UTC (rev 4924)
+++ epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/structure/PortalStructureAccess.java 2010-11-11 18:25:34 UTC (rev 5046)
@@ -1,44 +0,0 @@
-/*
- * JBoss, a division of Red Hat
- * Copyright 2010, 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.wsrp.structure;
-
-import org.gatein.mop.api.workspace.Page;
-import org.gatein.mop.api.workspace.ui.UIWindow;
-
-import java.util.Collection;
-
-/**
- * @author <a href="mailto:chris.laprun at jboss.com">Chris Laprun</a>
- * @version $Revision$
- */
-public interface PortalStructureAccess
-{
- Collection<Page> getPages();
-
- UIWindow getWindowFrom(String uuid);
-
- void saveChangesTo(UIWindow window);
-
- Page getPageFrom(org.exoplatform.portal.config.model.Page portalPage);
-}
Copied: epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/structure/PortalStructureAccess.java (from rev 4924, portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/structure/PortalStructureAccess.java)
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/structure/PortalStructureAccess.java (rev 0)
+++ epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/structure/PortalStructureAccess.java 2010-11-11 18:25:34 UTC (rev 5046)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2010, 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.wsrp.structure;
+
+import org.gatein.mop.api.workspace.Page;
+import org.gatein.mop.api.workspace.ui.UIWindow;
+
+import java.util.Collection;
+
+/**
+ * @author <a href="mailto:chris.laprun at jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ */
+public interface PortalStructureAccess
+{
+ Collection<Page> getPages();
+
+ UIWindow getWindowFrom(String uuid);
+
+ void saveChangesTo(UIWindow window);
+
+ Page getPageFrom(org.exoplatform.portal.config.model.Page portalPage);
+}
Copied: epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/test/java/org/gatein/portal/wsrp/structure (from rev 4924, portal/trunk/component/wsrp/src/test/java/org/gatein/portal/wsrp/structure)
Deleted: epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/test/java/org/gatein/portal/wsrp/structure/MOPConsumerStructureProviderTestCase.java
===================================================================
--- portal/trunk/component/wsrp/src/test/java/org/gatein/portal/wsrp/structure/MOPConsumerStructureProviderTestCase.java 2010-11-03 20:48:19 UTC (rev 4924)
+++ epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/test/java/org/gatein/portal/wsrp/structure/MOPConsumerStructureProviderTestCase.java 2010-11-11 18:25:34 UTC (rev 5046)
@@ -1,289 +0,0 @@
-/*
- * JBoss, a division of Red Hat
- * Copyright 2010, 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.wsrp.structure;
-
-import junit.framework.TestCase;
-import org.exoplatform.portal.config.DataStorage;
-import org.exoplatform.portal.mop.Described;
-import org.exoplatform.portal.pom.spi.wsrp.WSRP;
-import org.exoplatform.services.listener.Event;
-import org.gatein.mop.api.content.Customization;
-import org.gatein.mop.api.workspace.ObjectType;
-import org.gatein.mop.api.workspace.Page;
-import org.gatein.mop.api.workspace.ui.UIComponent;
-import org.gatein.mop.api.workspace.ui.UIContainer;
-import org.gatein.mop.api.workspace.ui.UIWindow;
-import org.gatein.pc.api.PortletContext;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.mockito.Mockito.*;
-
-/**
- * @author <a href="mailto:chris.laprun at jboss.com">Chris Laprun</a>
- * @version $Revision$
- */
-public class MOPConsumerStructureProviderTestCase extends TestCase
-{
- private MOPConsumerStructureProvider provider;
- private PortalStructureAccess structureAccess;
- private Page page1;
-
- public void testGetPageIdentifiers()
- {
- List<String> pageIdentifiers = provider.getPageIdentifiers();
- assertEquals(5, pageIdentifiers.size());
- assertTrue(pageIdentifiers.contains("page1"));
- assertTrue(pageIdentifiers.contains("page11"));
- assertTrue(pageIdentifiers.contains("page12"));
- assertTrue(pageIdentifiers.contains("page2"));
- assertTrue(pageIdentifiers.contains("page21"));
- }
-
- public void testGetWindowIdentifiersForInexistingPage()
- {
- List<String> windows = provider.getWindowIdentifiersFor("inexisting");
- assertTrue(windows.isEmpty());
- }
-
- public void testGetWindowIdentifiersFor()
- {
- checkWindows("page1", "window11", "window12");
- checkWindows("page2");
- checkWindows("page11", "window111", "window112");
- checkWindows("page12", "window121");
- checkWindows("page21", "window211");
- }
-
- public void testAssignPortletToWindow()
- {
- String newCustomizationId = "new";
- String newWindowName = "portlet";
- provider.assignPortletToWindow(PortletContext.createPortletContext(newCustomizationId), "window11", "page1", newWindowName);
- verify(structureAccess).getWindowFrom(getIdFor("window11"));
-
- UIWindow window11 = structureAccess.getWindowFrom(getIdFor("window11"));
- verify(structureAccess).saveChangesTo(window11);
-
- Described described = window11.adapt(Described.class);
- verify(described).setName(newWindowName + " (remote)");
-
- WSRP state = new WSRP();
- state.setPortletId(newCustomizationId);
- verify(window11).customize(WSRP.CONTENT_TYPE, newCustomizationId, state);
-
- Customization<?> customization = window11.getCustomization();
- assertEquals(WSRP.CONTENT_TYPE, customization.getType());
- }
-
- public void testPageCreationEvent() throws Exception
- {
- Page foo = createPage("foo", new String[]{"foo1"}, new String[]{"windowfoo1"});
- Page foo1 = foo.getChild("foo1");
- addWindows(foo1, "windowfoo11");
- org.exoplatform.portal.config.model.Page portalPage = mock(org.exoplatform.portal.config.model.Page.class);
- when(structureAccess.getPageFrom(portalPage)).thenReturn(foo);
-
- int pageNumber = provider.getPageIdentifiers().size();
-
- provider.onEvent(new Event<DataStorage, org.exoplatform.portal.config.model.Page>(DataStorage.PAGE_CREATED, null, portalPage));
-
- List<String> identifiers = provider.getPageIdentifiers();
- assertEquals(pageNumber + 2, identifiers.size());
- assertTrue(identifiers.contains("foo"));
- assertTrue(identifiers.contains("foo1"));
-
- checkWindows("foo", "windowfoo1");
- checkWindows("foo1", "windowfoo11");
-
- assertEquals(foo1.getRootComponent().get("windowfoo11"), structureAccess.getWindowFrom(getIdFor("windowfoo11")));
- }
-
- public void testPageDeletionEvent() throws Exception
- {
- org.exoplatform.portal.config.model.Page portalPage = mock(org.exoplatform.portal.config.model.Page.class);
- when(structureAccess.getPageFrom(portalPage)).thenReturn(page1);
-
- int pageNumber = provider.getPageIdentifiers().size();
-
- provider.onEvent(new Event<DataStorage, org.exoplatform.portal.config.model.Page>(DataStorage.PAGE_REMOVED, null, portalPage));
-
- List<String> identifiers = provider.getPageIdentifiers();
- assertEquals(pageNumber - 3, identifiers.size());
- assertFalse(identifiers.contains("page1"));
- assertFalse(identifiers.contains("page11"));
- assertFalse(identifiers.contains("page12"));
-
- assertNull(structureAccess.getWindowFrom(getIdFor("window11")));
- assertNull(structureAccess.getWindowFrom(getIdFor("window12")));
- assertNull(structureAccess.getWindowFrom(getIdFor("window111")));
- assertNull(structureAccess.getWindowFrom(getIdFor("window112")));
- assertNull(structureAccess.getWindowFrom(getIdFor("window121")));
- }
-
- public void testPageUpdatedEvent() throws Exception
- {
- // todo!
- }
-
- @Override
- protected void setUp() throws Exception
- {
- structureAccess = mock(PortalStructureAccess.class);
-
- page1 = createPage("page1", new String[]{"page11", "page12"}, new String[]{"window11", "window12"});
- Page page2 = createPage("page2", new String[]{"page21"}, null);
-
- Page page11 = page1.getChild("page11");
- addWindows(page11, "window111", "window112");
-
- Page page12 = page1.getChild("page12");
- addWindows(page12, "window121");
-
- Page page21 = page2.getChild("page21");
- addWindows(page21, "window211");
-
- ArrayList<Page> pages = new ArrayList<Page>();
- pages.add(page1);
- pages.add(page11);
- pages.add(page12);
- pages.add(page2);
- pages.add(page21);
- when(structureAccess.getPages()).thenReturn(pages);
-
- provider = new MOPConsumerStructureProvider(structureAccess);
-
- // needed to initialize state
- provider.getPageIdentifiers();
- }
-
- private void checkWindows(final String pageName, String... windowNames)
- {
- List<String> windows = provider.getWindowIdentifiersFor(pageName);
-
- if (windowNames != null)
- {
- assertEquals(windowNames.length, windows.size());
- for (String windowName : windowNames)
- {
- assertTrue(windows.contains(windowName));
- }
- }
- }
-
- private Page createPage(String name, String[] childrenPages, String[] windowNames)
- {
- Page page = mock(Page.class);
-
- when(page.getName()).thenThrow(new RuntimeException("Page.getName returns the internal name, not the human readable one"));
-
- // mock call to adapt
- Described described = mock(Described.class);
- when(described.getName()).thenReturn(name);
-
- when(page.adapt(Described.class)).thenReturn(described);
-
- if (childrenPages != null)
- {
- List<Page> children = new ArrayList<Page>(childrenPages.length);
- for (String pageId : childrenPages)
- {
- Page childPage = createPage(pageId, null, null);
- when(page.getChild(pageId)).thenReturn(childPage);
- children.add(childPage);
- }
-
- when(page.getChildren()).thenReturn(children);
- }
-
- addWindows(page, windowNames);
-
- return page;
- }
-
- private void addWindows(Page page, String... windowNames)
- {
- if (windowNames != null)
- {
- // mock page container
- UIContainer root = mock(UIContainer.class);
- when(page.getRootComponent()).thenReturn(root);
-
- // for each provided window name, create a mock UIWindow...
- List<UIComponent> children = new ArrayList<UIComponent>(windowNames.length);
- for (String windowName : windowNames)
- {
- UIWindow window = mock(UIWindow.class);
- when(window.getName()).thenThrow(new RuntimeException("Window.getName returns the internal name, not the human readable one"));
- when(window.getObjectId()).thenReturn(getIdFor(windowName));
-
- // need to use thenAnswer instead of thenReturn here because it doesn't play well with generics
- when(window.getObjectType()).thenAnswer(new Answer<Object>()
- {
- public Object answer(InvocationOnMock invocationOnMock) throws Throwable
- {
- return ObjectType.WINDOW;
- }
- });
-
- // mock call to adapt
- Described described = mock(Described.class);
- when(described.getName()).thenReturn(windowName);
-
- when(window.adapt(Described.class)).thenReturn(described);
-
- // mock Customization
- final Customization<WSRP> customization = mock(Customization.class);
- when(customization.getType()).thenReturn(WSRP.CONTENT_TYPE);
- when(window.getCustomization()).thenAnswer(new Answer<Object>()
- {
- public Object answer(InvocationOnMock invocationOnMock) throws Throwable
- {
- return customization;
- }
- });
-
- // add it to the list of windows for this page
- children.add(window);
-
- // make sure that we return the window when we ask for it from its uuid
- when(structureAccess.getWindowFrom(getIdFor(windowName))).thenReturn(window);
-
- // make sure that we return the window if we ask the root component for it
- when(root.get(windowName)).thenReturn(window);
- }
-
- // the container should return the list of windows when asked for its components
- when(root.getComponents()).thenReturn(children);
- }
- }
-
- private String getIdFor(String windowName)
- {
- return windowName + "Id";
- }
-}
Copied: epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/test/java/org/gatein/portal/wsrp/structure/MOPConsumerStructureProviderTestCase.java (from rev 4924, portal/trunk/component/wsrp/src/test/java/org/gatein/portal/wsrp/structure/MOPConsumerStructureProviderTestCase.java)
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/test/java/org/gatein/portal/wsrp/structure/MOPConsumerStructureProviderTestCase.java (rev 0)
+++ epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/test/java/org/gatein/portal/wsrp/structure/MOPConsumerStructureProviderTestCase.java 2010-11-11 18:25:34 UTC (rev 5046)
@@ -0,0 +1,302 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2010, 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.wsrp.structure;
+
+import junit.framework.TestCase;
+import org.exoplatform.portal.config.DataStorage;
+import org.exoplatform.portal.mop.Described;
+import org.exoplatform.portal.pom.spi.wsrp.WSRP;
+import org.exoplatform.services.listener.Event;
+import org.gatein.mop.api.content.Customization;
+import org.gatein.mop.api.workspace.ObjectType;
+import org.gatein.mop.api.workspace.Page;
+import org.gatein.mop.api.workspace.ui.UIComponent;
+import org.gatein.mop.api.workspace.ui.UIContainer;
+import org.gatein.mop.api.workspace.ui.UIWindow;
+import org.gatein.pc.api.PortletContext;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.mockito.Mockito.*;
+
+/**
+ * @author <a href="mailto:chris.laprun at jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ */
+public class MOPConsumerStructureProviderTestCase extends TestCase
+{
+ private MOPConsumerStructureProvider provider;
+ private PortalStructureAccess structureAccess;
+ private Page page1;
+
+ public void testGetPageIdentifiers()
+ {
+ List<String> pageIdentifiers = provider.getPageIdentifiers();
+ assertEquals(5, pageIdentifiers.size());
+ assertTrue(pageIdentifiers.contains("page1"));
+ assertTrue(pageIdentifiers.contains("page11"));
+ assertTrue(pageIdentifiers.contains("page12"));
+ assertTrue(pageIdentifiers.contains("page2"));
+ assertTrue(pageIdentifiers.contains("page21"));
+ }
+
+ public void testGetWindowIdentifiersForInexistingPage()
+ {
+ try
+ {
+ provider.getWindowIdentifiersFor("inexisting");
+ fail("Cannot retrieve windows for an inexistent page");
+ }
+ catch (IllegalArgumentException e)
+ {
+ // expected
+ }
+ }
+
+ public void testGetWindowIdentifiersFor()
+ {
+ checkWindows("page1", "window11", "window12");
+ checkWindows("page2");
+ checkWindows("page11", "window111", "window112");
+ checkWindows("page12", "window121");
+ checkWindows("page21", "window211");
+ }
+
+ public void testAssignPortletToWindow()
+ {
+ String newCustomizationId = "new";
+ String newWindowName = "portlet";
+ provider.assignPortletToWindow(PortletContext.createPortletContext(newCustomizationId), "window11", "page1", newWindowName);
+ verify(structureAccess).getWindowFrom(getIdFor("window11"));
+
+ UIWindow window11 = structureAccess.getWindowFrom(getIdFor("window11"));
+ verify(structureAccess).saveChangesTo(window11);
+
+ Described described = window11.adapt(Described.class);
+ verify(described).setName(newWindowName + " (remote)");
+
+ WSRP state = new WSRP();
+ state.setPortletId(newCustomizationId);
+ verify(window11).customize(WSRP.CONTENT_TYPE, newCustomizationId, state);
+
+ Customization<?> customization = window11.getCustomization();
+ assertEquals(WSRP.CONTENT_TYPE, customization.getType());
+ }
+
+ public void testPageCreationEvent() throws Exception
+ {
+ Page foo = createPage("foo", new String[]{"foo1"}, new String[]{"windowfoo1"});
+ Page foo1 = foo.getChild("foo1");
+ addWindows(foo1, "windowfoo11");
+ org.exoplatform.portal.config.model.Page portalPage = mock(org.exoplatform.portal.config.model.Page.class);
+ when(structureAccess.getPageFrom(portalPage)).thenReturn(foo);
+
+ int pageNumber = provider.getPageIdentifiers().size();
+
+ provider.onEvent(new Event<DataStorage, org.exoplatform.portal.config.model.Page>(DataStorage.PAGE_CREATED, null, portalPage));
+
+ List<String> identifiers = provider.getPageIdentifiers();
+ assertEquals(pageNumber + 2, identifiers.size());
+ assertTrue(identifiers.contains("foo"));
+ assertTrue(identifiers.contains("foo1"));
+
+ checkWindows("foo", "windowfoo1");
+ checkWindows("foo1", "windowfoo11");
+
+ assertEquals(foo1.getRootComponent().get("windowfoo11"), structureAccess.getWindowFrom(getIdFor("windowfoo11")));
+ }
+
+ public void testPageDeletionEvent() throws Exception
+ {
+ String pageToRemove = "page1";
+
+ org.exoplatform.portal.config.model.Page portalPage = mock(org.exoplatform.portal.config.model.Page.class);
+ when(portalPage.getName()).thenReturn(createInternalNameFrom(pageToRemove));
+ when(portalPage.getTitle()).thenReturn(pageToRemove);
+
+ // on delete, we actually get the event after the page has been removed from JCR so we don't have an actual page
+ when(structureAccess.getPageFrom(portalPage)).thenReturn(null);
+
+ int pageNumber = provider.getPageIdentifiers().size();
+
+ provider.onEvent(new Event<DataStorage, org.exoplatform.portal.config.model.Page>(DataStorage.PAGE_REMOVED, null, portalPage));
+
+ List<String> identifiers = provider.getPageIdentifiers();
+ assertEquals(pageNumber - 1, identifiers.size());
+ // deleting a page doesn't delete its children, see GTNPORTAL-1630
+ assertFalse(identifiers.contains(pageToRemove));
+ assertTrue(identifiers.contains("page11"));
+ assertTrue(identifiers.contains("page12"));
+ }
+
+ public void testPageUpdatedEvent() throws Exception
+ {
+ // todo!
+ }
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ structureAccess = mock(PortalStructureAccess.class);
+
+ page1 = createPage("page1", new String[]{"page11", "page12"}, new String[]{"window11", "window12"});
+ Page page2 = createPage("page2", new String[]{"page21"}, null);
+
+ Page page11 = page1.getChild("page11");
+ addWindows(page11, "window111", "window112");
+
+ Page page12 = page1.getChild("page12");
+ addWindows(page12, "window121");
+
+ Page page21 = page2.getChild("page21");
+ addWindows(page21, "window211");
+
+ ArrayList<Page> pages = new ArrayList<Page>();
+ pages.add(page1);
+ pages.add(page11);
+ pages.add(page12);
+ pages.add(page2);
+ pages.add(page21);
+ when(structureAccess.getPages()).thenReturn(pages);
+
+ provider = new MOPConsumerStructureProvider(structureAccess);
+
+ // needed to initialize state
+ provider.getPageIdentifiers();
+ }
+
+ private void checkWindows(final String pageName, String... windowNames)
+ {
+ List<String> windows = provider.getWindowIdentifiersFor(pageName);
+
+ if (windowNames != null)
+ {
+ assertEquals(windowNames.length, windows.size());
+ for (String windowName : windowNames)
+ {
+ assertTrue(windows.contains(windowName));
+ }
+ }
+ }
+
+ private Page createPage(String name, String[] childrenPages, String[] windowNames)
+ {
+ Page page = mock(Page.class);
+
+ when(page.getName()).thenReturn(createInternalNameFrom(name));
+
+ // mock call to adapt
+ Described described = mock(Described.class);
+ when(described.getName()).thenReturn(name);
+
+ when(page.adapt(Described.class)).thenReturn(described);
+
+ if (childrenPages != null)
+ {
+ List<Page> children = new ArrayList<Page>(childrenPages.length);
+ for (String pageId : childrenPages)
+ {
+ Page childPage = createPage(pageId, null, null);
+ when(page.getChild(pageId)).thenReturn(childPage);
+ children.add(childPage);
+ }
+
+ when(page.getChildren()).thenReturn(children);
+ }
+
+ addWindows(page, windowNames);
+
+ return page;
+ }
+
+ private String createInternalNameFrom(String name)
+ {
+ return name + "internal";
+ }
+
+ private void addWindows(Page page, String... windowNames)
+ {
+ if (windowNames != null)
+ {
+ // mock page container
+ UIContainer root = mock(UIContainer.class);
+ when(page.getRootComponent()).thenReturn(root);
+
+ // for each provided window name, create a mock UIWindow...
+ List<UIComponent> children = new ArrayList<UIComponent>(windowNames.length);
+ for (String windowName : windowNames)
+ {
+ UIWindow window = mock(UIWindow.class);
+ when(window.getName()).thenThrow(new RuntimeException("Window.getName returns the internal name, not the human readable one"));
+ when(window.getObjectId()).thenReturn(getIdFor(windowName));
+
+ // need to use thenAnswer instead of thenReturn here because it doesn't play well with generics
+ when(window.getObjectType()).thenAnswer(new Answer<Object>()
+ {
+ public Object answer(InvocationOnMock invocationOnMock) throws Throwable
+ {
+ return ObjectType.WINDOW;
+ }
+ });
+
+ // mock call to adapt
+ Described described = mock(Described.class);
+ when(described.getName()).thenReturn(windowName);
+
+ when(window.adapt(Described.class)).thenReturn(described);
+
+ // mock Customization
+ final Customization<WSRP> customization = mock(Customization.class);
+ when(customization.getType()).thenReturn(WSRP.CONTENT_TYPE);
+ when(window.getCustomization()).thenAnswer(new Answer<Object>()
+ {
+ public Object answer(InvocationOnMock invocationOnMock) throws Throwable
+ {
+ return customization;
+ }
+ });
+
+ // add it to the list of windows for this page
+ children.add(window);
+
+ // make sure that we return the window when we ask for it from its uuid
+ when(structureAccess.getWindowFrom(getIdFor(windowName))).thenReturn(window);
+
+ // make sure that we return the window if we ask the root component for it
+ when(root.get(windowName)).thenReturn(window);
+ }
+
+ // the container should return the list of windows when asked for its components
+ when(root.getComponents()).thenReturn(children);
+ }
+ }
+
+ private String getIdFor(String windowName)
+ {
+ return windowName + "Id";
+ }
+}
Modified: epp/portal/branches/EPP_5_1_Branch/pom.xml
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/pom.xml 2010-11-11 16:24:41 UTC (rev 5045)
+++ epp/portal/branches/EPP_5_1_Branch/pom.xml 2010-11-11 18:25:34 UTC (rev 5046)
@@ -48,7 +48,7 @@
<org.gatein.wci.version>2.0.2-GA</org.gatein.wci.version>
<org.gatein.pc.version>2.2.0-CR02</org.gatein.pc.version>
<org.picketlink.idm>1.1.7.CR01</org.picketlink.idm>
- <org.gatein.wsrp.version>2.0.0-Beta05</org.gatein.wsrp.version>
+ <org.gatein.wsrp.version>2.0.0-CR02</org.gatein.wsrp.version>
<org.gatein.mop.version>1.0.3-GA</org.gatein.mop.version>
<org.slf4j.version>1.5.6</org.slf4j.version>
<rhino.version>1.6R5</rhino.version>
Copied: epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/conf/wsrp/portal (from rev 4863, portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/wsrp/portal)
Copied: epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/conf/wsrp/portal/group (from rev 4863, portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/wsrp/portal/group)
Copied: epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/conf/wsrp/portal/group/platform (from rev 4863, portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/wsrp/portal/group/platform)
Copied: epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/conf/wsrp/portal/group/platform/administrators (from rev 4863, portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/wsrp/portal/group/platform/administrators)
Deleted: epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/conf/wsrp/portal/group/platform/administrators/navigation.xml
===================================================================
--- portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/wsrp/portal/group/platform/administrators/navigation.xml 2010-10-27 15:39:51 UTC (rev 4863)
+++ epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/conf/wsrp/portal/group/platform/administrators/navigation.xml 2010-11-11 18:25:34 UTC (rev 5046)
@@ -1,45 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
-
- Copyright (C) 2009 eXo Platform SAS.
-
- This is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of
- the License, or (at your option) any later version.
-
- This software is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this software; if not, write to the Free
- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-
--->
-
-<node-navigation
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.gatein.org/xml/ns/gatein_objects_1_0 http://www.gatein.org/xml/ns/gatein_objects_1_0"
- xmlns="http://www.gatein.org/xml/ns/gatein_objects_1_0">
- <priority>2</priority>
-
- <page-nodes>
- <!-- TODO: enable when the extension mechanism can handle child nodes properly -->
-<!-- <node>
- <uri>administration</uri>
- <name>administration</name>
- <label>#{administration.title}</label> -->
- <node>
- <!-- <uri>administration/wsrpConfiguration</uri> -->
- <uri>wsrpConfiguration</uri>
- <name>wsrpConfiguration</name>
- <!-- TODO: add a proper i18n label here -->
- <label>WSRP</label>
- <page-reference>group::/platform/administrators::wsrpConfiguration</page-reference>
- </node>
-<!-- </node> -->
- </page-nodes>
-</node-navigation>
Copied: epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/conf/wsrp/portal/group/platform/administrators/navigation.xml (from rev 4863, portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/wsrp/portal/group/platform/administrators/navigation.xml)
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/conf/wsrp/portal/group/platform/administrators/navigation.xml (rev 0)
+++ epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/conf/wsrp/portal/group/platform/administrators/navigation.xml 2010-11-11 18:25:34 UTC (rev 5046)
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+ Copyright (C) 2009 eXo Platform SAS.
+
+ This is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+
+-->
+
+<node-navigation
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.gatein.org/xml/ns/gatein_objects_1_0 http://www.gatein.org/xml/ns/gatein_objects_1_0"
+ xmlns="http://www.gatein.org/xml/ns/gatein_objects_1_0">
+ <priority>2</priority>
+
+ <page-nodes>
+ <!-- TODO: enable when the extension mechanism can handle child nodes properly -->
+<!-- <node>
+ <uri>administration</uri>
+ <name>administration</name>
+ <label>#{administration.title}</label> -->
+ <node>
+ <!-- <uri>administration/wsrpConfiguration</uri> -->
+ <uri>wsrpConfiguration</uri>
+ <name>wsrpConfiguration</name>
+ <!-- TODO: add a proper i18n label here -->
+ <label>WSRP</label>
+ <page-reference>group::/platform/administrators::wsrpConfiguration</page-reference>
+ </node>
+<!-- </node> -->
+ </page-nodes>
+</node-navigation>
Deleted: epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/conf/wsrp/portal/group/platform/administrators/pages.xml
===================================================================
--- portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/wsrp/portal/group/platform/administrators/pages.xml 2010-10-27 15:39:51 UTC (rev 4863)
+++ epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/conf/wsrp/portal/group/platform/administrators/pages.xml 2010-11-11 18:25:34 UTC (rev 5046)
@@ -1,44 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
-
- Copyright (C) 2009 eXo Platform SAS.
-
- This is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of
- the License, or (at your option) any later version.
-
- This software is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this software; if not, write to the Free
- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-
--->
-
-<page-set
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.gatein.org/xml/ns/gatein_objects_1_0 http://www.gatein.org/xml/ns/gatein_objects_1_0"
- xmlns="http://www.gatein.org/xml/ns/gatein_objects_1_0">
-
- <page>
- <name>wsrpConfiguration</name>
- <title>WSRP Admin</title>
- <access-permissions>manager:/platform/administrators</access-permissions>
- <edit-permission>manager:/platform/administrators</edit-permission>
- <portlet-application>
- <portlet>
- <application-ref>wsrp-admin-gui</application-ref>
- <portlet-ref>WSRPConfigurationPortlet</portlet-ref>
- </portlet>
- <title>WSRP Admin</title>
- <access-permissions>manager:/platform/administrators</access-permissions>
- <show-info-bar>false</show-info-bar>
- </portlet-application>
- </page>
-
-</page-set>
Copied: epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/conf/wsrp/portal/group/platform/administrators/pages.xml (from rev 4863, portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/wsrp/portal/group/platform/administrators/pages.xml)
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/conf/wsrp/portal/group/platform/administrators/pages.xml (rev 0)
+++ epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/conf/wsrp/portal/group/platform/administrators/pages.xml 2010-11-11 18:25:34 UTC (rev 5046)
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+ Copyright (C) 2009 eXo Platform SAS.
+
+ This is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+
+-->
+
+<page-set
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.gatein.org/xml/ns/gatein_objects_1_0 http://www.gatein.org/xml/ns/gatein_objects_1_0"
+ xmlns="http://www.gatein.org/xml/ns/gatein_objects_1_0">
+
+ <page>
+ <name>wsrpConfiguration</name>
+ <title>WSRP Admin</title>
+ <access-permissions>manager:/platform/administrators</access-permissions>
+ <edit-permission>manager:/platform/administrators</edit-permission>
+ <portlet-application>
+ <portlet>
+ <application-ref>wsrp-admin-gui</application-ref>
+ <portlet-ref>WSRPConfigurationPortlet</portlet-ref>
+ </portlet>
+ <title>WSRP Admin</title>
+ <access-permissions>manager:/platform/administrators</access-permissions>
+ <show-info-bar>false</show-info-bar>
+ </portlet-application>
+ </page>
+
+</page-set>
Modified: epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/conf/wsrp/wsrp-configuration.xml
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/conf/wsrp/wsrp-configuration.xml 2010-11-11 16:24:41 UTC (rev 5045)
+++ epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/conf/wsrp/wsrp-configuration.xml 2010-11-11 18:25:34 UTC (rev 5046)
@@ -44,6 +44,41 @@
</init-params>
</component>
+ <external-component-plugins>
+ <target-component>org.exoplatform.portal.config.UserPortalConfigService</target-component>
+ <component-plugin>
+ <!-- The name of the plugin -->
+ <name>new.portal.config.user.listener</name>
+ <!-- The name of the method to call on the UserPortalConfigService in order to register the NewPortalConfigs -->
+ <set-method>initListener</set-method>
+ <!-- The full qualified name of the NewPortalConfigListener -->
+ <type>org.exoplatform.portal.config.NewPortalConfigListener</type>
+ <description>this listener init the portal configuration</description>
+ <init-params>
+ <object-param>
+ <name>group.configuration</name>
+ <description>description</description>
+ <object type="org.exoplatform.portal.config.NewPortalConfig">
+ <field name="predefinedOwner">
+ <collection type="java.util.HashSet">
+ <value>
+ <string>platform/administrators</string>
+ </value>
+ </collection>
+ </field>
+ <field name="ownerType">
+ <string>group</string>
+ </field>
+ <field name="templateLocation">
+ <string>war:/conf/wsrp/portal</string>
+ </field>
+ </object>
+ </object-param>
+ </init-params>
+ </component-plugin>
+ </external-component-plugins>
+
+
<!--<external-component-plugins>
<target-component>org.exoplatform.commons.chromattic.ChromatticManager</target-component>
<component-plugin>
Modified: epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/ExoPortletInvocationContext.java
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/ExoPortletInvocationContext.java 2010-11-11 16:24:41 UTC (rev 5045)
+++ epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/ExoPortletInvocationContext.java 2010-11-11 18:25:34 UTC (rev 5046)
@@ -60,6 +60,7 @@
private static final String QMARK = "?";
private static final String EQ = "=";
private static final String AMP = "&";
+ private static final String XMLAMP = "&";
public ExoPortletInvocationContext(PortalRequestContext portalRequestContext, UIPortlet portlet)
{
@@ -95,6 +96,12 @@
public String renderURL(ContainerURL containerURL, URLFormat format)
{
+ boolean wantEscapeXML = false;
+ if (format != null && format.getWantEscapeXML() != null)
+ {
+ wantEscapeXML = format.getWantEscapeXML();
+ }
+
// todo: shouldn't we be using URLFormat to decide on the path to use at the beginning of the URL?
StringBuilder baseURL = new StringBuilder(this.portalRequestURI).append(QMARK)
.append(PortalRequestContext.UI_COMPONENT_ID).append(EQ).append(this.portletId);
@@ -119,30 +126,30 @@
if (!type.equals(Constants.PORTAL_RENDER))
{
- appendParameter(baseURL, Constants.TYPE_PARAMETER, type);
+ appendParameter(baseURL, Constants.TYPE_PARAMETER, type, wantEscapeXML);
}
if (format != null && format.getWantSecure() != null)
{
- appendParameter(baseURL, Constants.SECURE_PARAMETER, format.getWantSecure().toString());
+ appendParameter(baseURL, Constants.SECURE_PARAMETER, format.getWantSecure().toString(), wantEscapeXML);
}
StateString navigationalState = containerURL.getNavigationalState();
if (navigationalState != null && !navigationalState.getStringValue().equals(StateString.JBPNS_PREFIX))
{
- appendParameter(baseURL, NAVIGATIONAL_STATE_PARAM_NAME, navigationalState.getStringValue());
+ appendParameter(baseURL, NAVIGATIONAL_STATE_PARAM_NAME, navigationalState.getStringValue(), wantEscapeXML);
}
WindowState windowState = containerURL.getWindowState();
if (windowState != null)
{
- appendParameter(baseURL, Constants.WINDOW_STATE_PARAMETER, windowState.toString());
+ appendParameter(baseURL, Constants.WINDOW_STATE_PARAMETER, windowState.toString(), wantEscapeXML);
}
Mode mode = containerURL.getMode();
if (mode != null)
{
- appendParameter(baseURL, Constants.PORTLET_MODE_PARAMETER, mode.toString());
+ appendParameter(baseURL, Constants.PORTLET_MODE_PARAMETER, mode.toString(), wantEscapeXML);
}
if (containerURL instanceof ActionURL)
@@ -152,25 +159,25 @@
StateString state = actionURL.getInteractionState();
if (state != null && !state.getStringValue().equals(StateString.JBPNS_PREFIX))
{
- appendParameter(baseURL, INTERACTION_STATE_PARAM_NAME, state.getStringValue());
+ appendParameter(baseURL, INTERACTION_STATE_PARAM_NAME, state.getStringValue(), wantEscapeXML);
}
}
else if (containerURL instanceof ResourceURL)
{
ResourceURL resourceURL = (ResourceURL)containerURL;
- appendParameter(baseURL, Constants.RESOURCE_ID_PARAMETER, resourceURL.getResourceId());
+ appendParameter(baseURL, Constants.RESOURCE_ID_PARAMETER, resourceURL.getResourceId(), wantEscapeXML);
CacheLevel cachability = resourceURL.getCacheability();
if (cachability != null)
{
- appendParameter(baseURL, Constants.CACHELEVEL_PARAMETER, cachability.name());
+ appendParameter(baseURL, Constants.CACHELEVEL_PARAMETER, cachability.name(), wantEscapeXML);
}
StateString resourceState = resourceURL.getResourceState();
if (resourceState != null && !resourceState.getStringValue().equals(StateString.JBPNS_PREFIX))
{
- appendParameter(baseURL, RESOURCE_STATE_PARAM_NAME, resourceState.getStringValue());
+ appendParameter(baseURL, RESOURCE_STATE_PARAM_NAME, resourceState.getStringValue(), wantEscapeXML);
}
}
else
@@ -187,12 +194,12 @@
{
for (String value : values)
{
- appendParameter(baseURL, key, value);
+ appendParameter(baseURL, key, value, wantEscapeXML);
}
}
else
{
- appendParameter(baseURL, "removePP", key);
+ appendParameter(baseURL, "removePP", key, wantEscapeXML);
}
}
}
@@ -201,11 +208,18 @@
return baseURL.toString();
}
- private void appendParameter(StringBuilder builder, String name, String value)
+ private void appendParameter(StringBuilder builder, String name, String value, boolean wantEscapeXML)
{
if (value != null)
{
- builder.append(AMP).append(name).append(EQ).append(value);
+ if (wantEscapeXML)
+ {
+ builder.append(XMLAMP).append(name).append(EQ).append(value);
+ }
+ else
+ {
+ builder.append(AMP).append(name).append(EQ).append(value);
+ }
}
}
}
Modified: epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortlet.java
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortlet.java 2010-11-11 16:24:41 UTC (rev 5045)
+++ epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortlet.java 2010-11-11 18:25:34 UTC (rev 5046)
@@ -118,6 +118,8 @@
private static final String WSRP_PREFER_OPERATION = "wsrp-preferOperation";
private static final String WSRP_REQUIRES_REWRITE = "wsrp-requiresRewrite";
private static final String WSRP_NAVIGATIONAL_VALUES = "wsrp-navigationalValues";
+ private static final AbstractPortalContext PORTAL_CONTEXT = new AbstractPortalContext(Collections.singletonMap(
+ "javax.portlet.markup.head.element.support", "true"));
/** . */
private String storageId;
@@ -863,8 +865,7 @@
//TODO: ExoUserContext impl not tested
invocation.setUserContext(new ExoUserContext(servletRequest, userProfile));
invocation.setWindowContext(new AbstractWindowContext(storageName));
- invocation.setPortalContext(new AbstractPortalContext(Collections.singletonMap(
- "javax.portlet.markup.head.element.support", "true")));
+ invocation.setPortalContext(PORTAL_CONTEXT);
invocation.setSecurityContext(new AbstractSecurityContext(servletRequest));
//
Modified: epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletActionListener.java
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletActionListener.java 2010-11-11 16:24:41 UTC (rev 5045)
+++ epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletActionListener.java 2010-11-11 18:25:34 UTC (rev 5046)
@@ -388,7 +388,19 @@
if (portletResponse instanceof ErrorResponse)
{
ErrorResponse errorResponse = (ErrorResponse)portletResponse;
- throw (Exception)errorResponse.getCause();
+ if (errorResponse.getCause() != null)
+ {
+ throw (Exception)errorResponse.getCause();
+ }
+ else if (errorResponse.getMessage() != null)
+ {
+ throw new Exception("Received an error response with message : " + errorResponse.getMessage());
+ }
+ else
+ {
+ throw new Exception("Received an error response.");
+ }
+
}
else
{
Modified: epp/portal/branches/EPP_5_1_Branch/webui/portlet/src/main/java/org/exoplatform/webui/application/portlet/PortletURLBuilder.java
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/webui/portlet/src/main/java/org/exoplatform/webui/application/portlet/PortletURLBuilder.java 2010-11-11 16:24:41 UTC (rev 5045)
+++ epp/portal/branches/EPP_5_1_Branch/webui/portlet/src/main/java/org/exoplatform/webui/application/portlet/PortletURLBuilder.java 2010-11-11 18:25:34 UTC (rev 5046)
@@ -58,7 +58,7 @@
protected void createURL(StringBuilder builder, UIComponent targetComponent, String action, String targetBeanId,
Parameter[] params)
{
- String baseUrl = getBaseURL().replaceAll("&", AMP);
+ String baseUrl = getBaseURL();
builder.append(baseUrl).append(AMP).append(UIComponent.UICOMPONENT).append(EQUALS).append(
targetComponent.getId());
More information about the gatein-commits
mailing list