Author: chris.laprun(a)jboss.com
Date: 2010-09-13 16:54:23 -0400 (Mon, 13 Sep 2010)
New Revision: 4179
Modified:
portal/branches/wsrp2-integration/component/wsrp/src/main/java/org/gatein/portal/wsrp/MOPPortalStructureProvider.java
Log:
- Use Described mixin to get the name of components. Currently causing issues with the GUI
as the underlying model object in WorkspaceObjectImpl sometimes ends being null causing
NPEs. Mitigating by caching pageIdToUUIDs but problem still present for windowIdToUUIDs.
:(
- Started trying to implement re-customization of window.
- Adapted for method signature change and typo fix in PortalStructureProvider.
Modified:
portal/branches/wsrp2-integration/component/wsrp/src/main/java/org/gatein/portal/wsrp/MOPPortalStructureProvider.java
===================================================================
---
portal/branches/wsrp2-integration/component/wsrp/src/main/java/org/gatein/portal/wsrp/MOPPortalStructureProvider.java 2010-09-13
20:49:31 UTC (rev 4178)
+++
portal/branches/wsrp2-integration/component/wsrp/src/main/java/org/gatein/portal/wsrp/MOPPortalStructureProvider.java 2010-09-13
20:54:23 UTC (rev 4179)
@@ -27,9 +27,9 @@
import org.exoplatform.commons.chromattic.ChromatticLifeCycle;
import org.exoplatform.commons.chromattic.ChromatticManager;
import org.exoplatform.container.ExoContainer;
+import org.exoplatform.portal.mop.Described;
import org.exoplatform.portal.pom.spi.wsrp.WSRP;
import org.gatein.common.util.ParameterValidation;
-import org.gatein.mop.api.content.ContentType;
import org.gatein.mop.api.content.Customization;
import org.gatein.mop.api.workspace.ObjectType;
import org.gatein.mop.api.workspace.Page;
@@ -38,6 +38,9 @@
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.PortalStructureProvider;
import java.util.Collection;
@@ -67,27 +70,30 @@
public List<String> getPageIdentifiers()
{
- ChromatticSession session = lifeCycle.getChromattic().openSession();
- Workspace workspace = session.findByPath(Workspace.class,
"mop:workspace");
- Collection<Site> sites = workspace.getSites(ObjectType.PORTAL_SITE);
+ if (pageIdToUUIDs.isEmpty())
+ {
+ ChromatticSession session = lifeCycle.getChromattic().openSession();
+ Workspace workspace = session.findByPath(Workspace.class,
"mop:workspace");
+ Collection<Site> sites = workspace.getSites(ObjectType.PORTAL_SITE);
- for (Site site : sites)
- {
- Page page = site.getRootPage().getChild("pages");
- if (page != null)
+ for (Site site : sites)
{
- processPage(page, true);
+ Page page = site.getRootPage().getChild("pages");
+ if (page != null)
+ {
+ processPage(page, true);
+ }
}
+
+ /*POMSession session = (POMSession) lifeCycle.getChromattic().openSession();
+ Iterator<Page> pages = session.findObjects(ObjectType.PAGE,
ObjectType.PORTAL_SITE, null, null);
+ while (pages.hasNext())
+ {
+ Page page = pages.next();
+ pageIdToUUIDs.put(page.getName(), page.getObjectId());
+ }*/
}
- /*POMSession session = (POMSession) lifeCycle.getChromattic().openSession();
- Iterator<Page> pages = session.findObjects(ObjectType.PAGE,
ObjectType.PORTAL_SITE, null, null);
- while (pages.hasNext())
- {
- Page page = pages.next();
- pageIdToUUIDs.put(page.getName(), page.getObjectId());
- }*/
-
LinkedList<String> identifiers = new
LinkedList<String>(pageIdToUUIDs.keySet());
Collections.sort(identifiers);
return identifiers;
@@ -97,7 +103,8 @@
{
if (!ignoreCurrent)
{
- pageIdToUUIDs.put(page.getName(), page.getObjectId());
+ Described described = page.adapt(Described.class);
+ pageIdToUUIDs.put(described.getName(), page.getObjectId());
}
Collection<Page> children = page.getChildren();
@@ -110,7 +117,7 @@
}
}
- public List<String> getWindowIndentifiersFor(String pageId)
+ public List<String> getWindowIdentifiersFor(String pageId)
{
ChromatticSession session = lifeCycle.getChromattic().openSession();
String uuid = pageIdToUUIDs.get(pageId);
@@ -132,7 +139,8 @@
ObjectType<? extends UIComponent> type = component.getObjectType();
if (ObjectType.WINDOW.equals(type))
{
- String name = component.getName();
+ Described described = component.adapt(Described.class);
+ String name = described.getName();
windowIdToUUIDs.put(name, component.getObjectId());
windows.add(name);
}
@@ -147,17 +155,33 @@
}
}
- public void assignPortletToWindow(String portletId, String windowId, String pageId)
+ public void assignPortletToWindow(PortletContext portletContext, String windowId,
String pageId)
{
ChromatticSession session = lifeCycle.getChromattic().openSession();
String uuid = windowIdToUUIDs.get(windowId);
ParameterValidation.throwIllegalArgExceptionIfNull(uuid, "UUID for " +
windowId);
UIWindow window = session.findById(UIWindow.class, uuid);
- /*WSRP wsrp = new WSRP();
+ WSRP wsrp = new WSRP();
+ String portletId = portletContext.getId();
wsrp.setPortletId(portletId);
- wsrp.setState();
- window.customize(WSRP.CONTENT_TYPE, portletId, wsrp);*/
+ 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
Customization<?> customization = window.getCustomization();
-// window.customize()
+ customization.destroy();
+
+ // and re-customize
+ window.customize(WSRP.CONTENT_TYPE, portletId, wsrp);
}
}
Show replies by date