Author: alain_defrance
Date: 2010-10-13 09:59:23 -0400 (Wed, 13 Oct 2010)
New Revision: 4655
Added:
portal/branches/wci/component/wsrp/src/main/java/org/gatein/portal/wsrp/MOPConsumerStructureProvider.java
Removed:
portal/branches/wci/component/wsrp/src/main/java/org/gatein/portal/wsrp/MOPPortalStructureProvider.java
Modified:
portal/branches/wci/component/pc/src/main/java/org/exoplatform/portal/pc/ExoKernelIntegration.java
portal/branches/wci/component/wsrp/src/main/java/org/gatein/portal/wsrp/WSRPServiceIntegration.java
portal/branches/wci/pom.xml
Log:
merged from trunk 4654
Modified:
portal/branches/wci/component/pc/src/main/java/org/exoplatform/portal/pc/ExoKernelIntegration.java
===================================================================
---
portal/branches/wci/component/pc/src/main/java/org/exoplatform/portal/pc/ExoKernelIntegration.java 2010-10-13
13:49:59 UTC (rev 4654)
+++
portal/branches/wci/component/pc/src/main/java/org/exoplatform/portal/pc/ExoKernelIntegration.java 2010-10-13
13:59:23 UTC (rev 4655)
@@ -159,4 +159,9 @@
portletApplicationRegistry.stop();
}
}
+
+ public PortletApplicationDeployer getPortletApplicationRegistry()
+ {
+ return portletApplicationRegistry;
+ }
}
Copied:
portal/branches/wci/component/wsrp/src/main/java/org/gatein/portal/wsrp/MOPConsumerStructureProvider.java
(from rev 4654,
portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/MOPConsumerStructureProvider.java)
===================================================================
---
portal/branches/wci/component/wsrp/src/main/java/org/gatein/portal/wsrp/MOPConsumerStructureProvider.java
(rev 0)
+++
portal/branches/wci/component/wsrp/src/main/java/org/gatein/portal/wsrp/MOPConsumerStructureProvider.java 2010-10-13
13:59:23 UTC (rev 4655)
@@ -0,0 +1,214 @@
+/*
+ * 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@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);
+ }
+ }
+}
Deleted:
portal/branches/wci/component/wsrp/src/main/java/org/gatein/portal/wsrp/MOPPortalStructureProvider.java
===================================================================
---
portal/branches/wci/component/wsrp/src/main/java/org/gatein/portal/wsrp/MOPPortalStructureProvider.java 2010-10-13
13:49:59 UTC (rev 4654)
+++
portal/branches/wci/component/wsrp/src/main/java/org/gatein/portal/wsrp/MOPPortalStructureProvider.java 2010-10-13
13:59:23 UTC (rev 4655)
@@ -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@jboss.com">Chris
Laprun</a>
- * @version $Revision$
- */
-public class MOPPortalStructureProvider implements ConsumerStructureProvider
-{
- private final POMSessionManager pomManager;
- private Map<String, PageInfo> pageInfos;
- private Map<String, String> windowIdToUUIDs;
-
- public MOPPortalStructureProvider(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:
portal/branches/wci/component/wsrp/src/main/java/org/gatein/portal/wsrp/WSRPServiceIntegration.java
===================================================================
---
portal/branches/wci/component/wsrp/src/main/java/org/gatein/portal/wsrp/WSRPServiceIntegration.java 2010-10-13
13:49:59 UTC (rev 4654)
+++
portal/branches/wci/component/wsrp/src/main/java/org/gatein/portal/wsrp/WSRPServiceIntegration.java 2010-10-13
13:59:23 UTC (rev 4655)
@@ -27,6 +27,7 @@
import org.exoplatform.container.ExoContainerContext;
import org.exoplatform.container.configuration.ConfigurationManager;
import org.exoplatform.container.xml.InitParams;
+import org.exoplatform.portal.pc.ExoKernelIntegration;
import org.exoplatform.services.jcr.ext.hierarchy.NodeHierarchyCreator;
import org.exoplatform.services.listener.ListenerService;
import org.gatein.common.logging.Logger;
@@ -85,11 +86,12 @@
private ConsumerRegistry consumerRegistry;
private ExoContainer container;
+ private final ExoKernelIntegration exoKernelIntegration;
private final boolean bypass;
private static final String WSRP_ADMIN_GUI_CONTEXT_PATH =
"/wsrp-admin-gui";
public WSRPServiceIntegration(ExoContainerContext context, InitParams params,
ConfigurationManager configurationManager,
- org.exoplatform.portal.pc.ExoKernelIntegration pc,
NodeHierarchyCreator nhc) throws Exception
+ ExoKernelIntegration pc, NodeHierarchyCreator nhc)
throws Exception
{
// IMPORTANT: even though PC ExoKernelIntegration and NodeHierarchyCreator is not
used anywhere in the code, it's still needed for pico
// to properly make sure that this service is started after the PC one. Yes, Pico
is crap. :/
@@ -114,6 +116,8 @@
container = context.getContainer();
+ exoKernelIntegration = pc;
+
bypass = false;
}
else
@@ -124,6 +128,7 @@
producerConfigLocation = null;
consumersConfigLocation = null;
configurationIS = null;
+ exoKernelIntegration = null;
bypass = true;
}
}
@@ -212,6 +217,7 @@
producer.setPortletInvoker(wsrpPortletInvoker);
producer.setRegistrationManager(registrationManager);
producer.setConfigurationService(producerConfigurationService);
+ exoKernelIntegration.getPortletApplicationRegistry().addListener(producer);
producer.start();
}
@@ -238,7 +244,7 @@
// migration service
MigrationService migrationService = new JCRMigrationService(container);
- migrationService.setStructureProvider(new
MOPPortalStructureProvider(container));
+ migrationService.setStructureProvider(new
MOPConsumerStructureProvider(container));
consumerRegistry.setMigrationService(migrationService);
consumerRegistry.start();
Modified: portal/branches/wci/pom.xml
===================================================================
--- portal/branches/wci/pom.xml 2010-10-13 13:49:59 UTC (rev 4654)
+++ portal/branches/wci/pom.xml 2010-10-13 13:59:23 UTC (rev 4655)
@@ -48,7 +48,7 @@
<org.gatein.wci.version>2.1.0-Alpha01-SNAPSHOT</org.gatein.wci.version>
<org.gatein.pc.version>2.2.0-Beta05</org.gatein.pc.version>
<org.picketlink.idm>1.1.6.GA</org.picketlink.idm>
- <org.gatein.wsrp.version>2.0.0-Beta01</org.gatein.wsrp.version>
+
<org.gatein.wsrp.version>2.0.0-Beta02-SNAPSHOT</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>