Author: julien(a)jboss.com
Date: 2008-06-09 05:23:18 -0400 (Mon, 09 Jun 2008)
New Revision: 10951
Added:
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/PageContentContext.java
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/WindowContentContext.java
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/portlet/PortletPageContextImpl.java
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/portlet/PortletWindowContextImpl.java
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/portlet/controller/PresentationPageContext.java
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/portlet/controller/PresentationWindowContext.java
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/content/
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/content/PageContentContextImpl.java
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/content/WindowContentContextImpl.java
Removed:
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/PortalNodeAdapter.java
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/PortalNodeState.java
Modified:
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/PresentationServerImpl.java
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/ContentHandler.java
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/markup/MarkupContent.java
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/markup/MarkupContentHandler.java
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/portlet/PortletContent.java
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/portlet/PortletContentHandler.java
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/portlet/controller/PresentationPortletControllerContext.java
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/portlet/spi/PresentationInstanceContext.java
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/portlet/spi/PresentationWindowContext.java
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/object/WindowNode.java
Log:
improve and refactor
Modified:
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/PresentationServerImpl.java
===================================================================
---
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/PresentationServerImpl.java 2008-06-08
17:24:16 UTC (rev 10950)
+++
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/PresentationServerImpl.java 2008-06-09
09:23:18 UTC (rev 10951)
@@ -28,10 +28,13 @@
import org.jboss.portal.presentation.portal.model.object.PageNode;
import org.jboss.portal.presentation.portal.model.object.PortalNodeManager;
import org.jboss.portal.presentation.portal.model.layout.ObjectElement;
+import org.jboss.portal.presentation.portal.model.content.PageContentContextImpl;
import org.jboss.portal.presentation.impl.state.structural.adapter.StructuralAdapter;
import org.jboss.portal.presentation.portal.content.protocol.ContentAction;
import org.jboss.portal.presentation.portal.content.ContentHandlerRegistry;
import org.jboss.portal.presentation.portal.content.ContentHandler;
+import org.jboss.portal.presentation.portal.content.PageContentContext;
+import org.jboss.portal.presentation.portal.content.WindowContentContext;
import org.jboss.portal.presentation.model.content.WindowContent;
import org.jboss.portal.presentation.protocol.ErrorResponse;
import org.jboss.portal.presentation.protocol.ProtocolAction;
@@ -95,7 +98,11 @@
ContentHandler handler = contentHandlerRegistry.getContentHandler(contentType);
- return handler.render(window, client);
+ PageContentContext pageContext = new
PageContentContextImpl((PageNode)window.getParent());
+
+ WindowContentContext windowContext = pageContext.getWindowContext("node."
+ window.getId());
+
+ return handler.render(windowContext, client);
}
public PresentationResponse process(PresentationClient client, PresentationRequest
request) throws PresentationServerException
@@ -144,9 +151,15 @@
ContentHandler handler =
contentHandlerRegistry.getContentHandler(contentType);
//
- ProtocolResponse response = handler.process(window, client, contentAction);
+ PageContentContext pageContext = new
PageContentContextImpl((PageNode)window.getParent());
//
+ WindowContentContext windowContext =
pageContext.getWindowContext("node." + window.getId());
+
+ //
+ ProtocolResponse response = handler.process(windowContext, client,
contentAction);
+
+ //
if (response == null)
{
PageNode page = (PageNode)window.getParent();
Modified:
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/ContentHandler.java
===================================================================
---
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/ContentHandler.java 2008-06-08
17:24:16 UTC (rev 10950)
+++
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/ContentHandler.java 2008-06-09
09:23:18 UTC (rev 10951)
@@ -36,8 +36,8 @@
public interface ContentHandler
{
- ProtocolResponse process(WindowNode window, PresentationClient client, ContentAction
action) throws PresentationServerException;
+ ProtocolResponse process(WindowContentContext windowContentContext, PresentationClient
client, ContentAction action) throws PresentationServerException;
- WindowContent render(WindowNode window, PresentationClient client) throws
PresentationServerException;
+ WindowContent render(WindowContentContext windowContentContext, PresentationClient
client) throws PresentationServerException;
}
Added:
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/PageContentContext.java
===================================================================
---
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/PageContentContext.java
(rev 0)
+++
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/PageContentContext.java 2008-06-09
09:23:18 UTC (rev 10951)
@@ -0,0 +1,41 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.portal.content;
+
+import java.util.Collection;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
+ * @version $Revision: 630 $
+ */
+public interface PageContentContext
+{
+
+ String getId();
+
+ Collection<? extends WindowContentContext> getWindowContexts();
+
+ WindowContentContext getWindowContext(String windowId);
+
+}
+
Added:
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/WindowContentContext.java
===================================================================
---
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/WindowContentContext.java
(rev 0)
+++
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/WindowContentContext.java 2008-06-09
09:23:18 UTC (rev 10951)
@@ -0,0 +1,40 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.portal.content;
+
+import org.jboss.portal.presentation.portal.model.object.WindowNode;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
+ * @version $Revision: 630 $
+ */
+public interface WindowContentContext
+{
+
+ String getId();
+
+ WindowNode.Content getContent();
+
+ PageContentContext getPageContext();
+
+}
Modified:
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/markup/MarkupContent.java
===================================================================
---
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/markup/MarkupContent.java 2008-06-08
17:24:16 UTC (rev 10950)
+++
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/markup/MarkupContent.java 2008-06-09
09:23:18 UTC (rev 10951)
@@ -52,9 +52,4 @@
{
return "markup";
}
-
- public WindowContent render(WindowNode window, PresentationClient client,
PortletInvoker portletInvoker) throws PresentationServerException
- {
- return new WindowContent(0, "blah", "markup");
- }
}
Modified:
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/markup/MarkupContentHandler.java
===================================================================
---
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/markup/MarkupContentHandler.java 2008-06-08
17:24:16 UTC (rev 10950)
+++
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/markup/MarkupContentHandler.java 2008-06-09
09:23:18 UTC (rev 10951)
@@ -23,8 +23,8 @@
package org.jboss.portal.presentation.portal.content.markup;
import org.jboss.portal.presentation.portal.content.ContentHandler;
+import org.jboss.portal.presentation.portal.content.WindowContentContext;
import org.jboss.portal.presentation.portal.content.protocol.ContentAction;
-import org.jboss.portal.presentation.portal.model.object.WindowNode;
import org.jboss.portal.presentation.model.content.WindowContent;
import org.jboss.portal.presentation.client.PresentationClient;
import org.jboss.portal.presentation.server.PresentationServerException;
@@ -37,14 +37,14 @@
public class MarkupContentHandler implements ContentHandler
{
- public ProtocolResponse process(WindowNode window, PresentationClient client,
ContentAction action) throws PresentationServerException
+ public ProtocolResponse process(WindowContentContext windowContentContext,
PresentationClient client, ContentAction action) throws PresentationServerException
{
throw new UnsupportedOperationException();
}
- public WindowContent render(WindowNode window, PresentationClient client) throws
PresentationServerException
+ public WindowContent render(WindowContentContext windowContentContext,
PresentationClient client) throws PresentationServerException
{
- String markup = ((MarkupContent)window.getContent()).getMarkup();
+ String markup = ((MarkupContent)windowContentContext.getContent()).getMarkup();
return new WindowContent(0, "blah", markup);
}
}
Modified:
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/portlet/PortletContent.java
===================================================================
---
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/portlet/PortletContent.java 2008-06-08
17:24:16 UTC (rev 10950)
+++
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/portlet/PortletContent.java 2008-06-09
09:23:18 UTC (rev 10951)
@@ -23,17 +23,6 @@
package org.jboss.portal.presentation.portal.content.portlet;
import org.jboss.portal.presentation.portal.model.object.WindowNode;
-import org.jboss.portal.presentation.portal.model.object.PageNode;
-import
org.jboss.portal.presentation.portal.content.portlet.controller.PresentationPortletControllerContext;
-import
org.jboss.portal.presentation.portal.content.portlet.controller.PresentationPortletPageNavigationalState;
-import org.jboss.portal.presentation.model.content.WindowContent;
-import org.jboss.portal.presentation.client.PresentationClient;
-import org.jboss.portal.presentation.server.PresentationServerException;
-import org.jboss.portal.portlet.controller.PortletController;
-import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
-import org.jboss.portal.portlet.invocation.response.FragmentResponse;
-import org.jboss.portal.portlet.PortletInvokerException;
-import org.jboss.portal.portlet.PortletInvoker;
/**
* @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
@@ -59,44 +48,4 @@
{
return "portlet";
}
-
- public WindowContent render(WindowNode window, PresentationClient client,
PortletInvoker portletInvoker) throws PresentationServerException
- {
- try
- {
- PageNode page = (PageNode)window.getParent();
-
- //
- PortletController controller = new PortletController();
-
- //
- PresentationPortletControllerContext portletControllerContext = new
PresentationPortletControllerContext(
- client,
- page,
- portletInvoker);
-
- //
- PresentationPortletPageNavigationalState pageNavigationalState = new
PresentationPortletPageNavigationalState(
- portletControllerContext,
- client.getNavigationalStateContext(),
- PresentationPortletPageNavigationalState.READ_ONLY_MODE);
-
- PortletInvocationResponse response = controller.render(portletControllerContext,
null, pageNavigationalState, window.getId());
-
- //
- if (response instanceof FragmentResponse)
- {
- FragmentResponse fragment = (FragmentResponse)response;
- return new WindowContent(0, fragment.getTitle(), fragment.getContent());
- }
- else
- {
- return new WindowContent(0, "Unexpected response for window " +
window.getId(), "");
- }
- }
- catch (PortletInvokerException e)
- {
- throw new PresentationServerException(e);
- }
- }
}
Modified:
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/portlet/PortletContentHandler.java
===================================================================
---
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/portlet/PortletContentHandler.java 2008-06-08
17:24:16 UTC (rev 10950)
+++
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/portlet/PortletContentHandler.java 2008-06-09
09:23:18 UTC (rev 10951)
@@ -23,12 +23,12 @@
package org.jboss.portal.presentation.portal.content.portlet;
import org.jboss.portal.presentation.portal.content.ContentHandler;
+import org.jboss.portal.presentation.portal.content.WindowContentContext;
import org.jboss.portal.presentation.portal.content.protocol.ContentAction;
import
org.jboss.portal.presentation.portal.content.portlet.controller.PresentationPortletControllerContext;
import
org.jboss.portal.presentation.portal.content.portlet.controller.PresentationPortletPageNavigationalState;
+import
org.jboss.portal.presentation.portal.content.portlet.controller.PresentationPageContext;
import
org.jboss.portal.presentation.portal.content.portlet.protocol.PortletContainerAction;
-import org.jboss.portal.presentation.portal.model.object.WindowNode;
-import org.jboss.portal.presentation.portal.model.object.PageNode;
import org.jboss.portal.presentation.model.content.WindowContent;
import org.jboss.portal.presentation.client.PresentationClient;
import org.jboss.portal.presentation.server.PresentationServerException;
@@ -67,18 +67,21 @@
this.portletInvoker = portletInvoker;
}
- public ProtocolResponse process(WindowNode window, PresentationClient client,
ContentAction action) throws PresentationServerException
+ private PresentationPageContext createPortletPageContext(WindowContentContext
windowContentContext)
{
+ return new PortletPageContextImpl(portletInvoker,
windowContentContext.getPageContext());
+ }
+
+ public ProtocolResponse process(WindowContentContext windowContentContext,
PresentationClient client, ContentAction action) throws PresentationServerException
+ {
PortletContainerAction pcAction = (PortletContainerAction)action;
//
- PageNode page = (PageNode)window.getParent();
+ PresentationPageContext portletPageContext =
createPortletPageContext(windowContentContext);
//
PresentationPortletControllerContext portletControllerContext = new
PresentationPortletControllerContext(
- client,
- page,
- portletInvoker);
+ client, portletPageContext);
PresentationPortletPageNavigationalState pageNavigationalState = new
PresentationPortletPageNavigationalState(
portletControllerContext,
@@ -128,9 +131,6 @@
PageUpdateResponse pageUpdate = (PageUpdateResponse)response;
//
- NavigationalStateContext nsc = client.getNavigationalStateContext();
-
- //
PresentationPortletPageNavigationalState blah =
(PresentationPortletPageNavigationalState)pageUpdate.getPageNavigationalState();
//
@@ -146,20 +146,18 @@
return null;
}
- public WindowContent render(WindowNode window, PresentationClient client) throws
PresentationServerException
+ public WindowContent render(WindowContentContext windowContentContext,
PresentationClient client) throws PresentationServerException
{
try
{
- PageNode page = (PageNode)window.getParent();
+ PresentationPageContext portletPageContext =
createPortletPageContext(windowContentContext);
//
PortletController controller = new PortletController();
//
PresentationPortletControllerContext portletControllerContext = new
PresentationPortletControllerContext(
- client,
- page,
- portletInvoker);
+ client, portletPageContext);
//
PresentationPortletPageNavigationalState pageNavigationalState = new
PresentationPortletPageNavigationalState(
@@ -167,7 +165,7 @@
client.getNavigationalStateContext(),
PresentationPortletPageNavigationalState.READ_ONLY_MODE);
- PortletInvocationResponse response = controller.render(portletControllerContext,
null, pageNavigationalState, window.getId());
+ PortletInvocationResponse response = controller.render(portletControllerContext,
null, pageNavigationalState, windowContentContext.getId());
//
if (response instanceof FragmentResponse)
@@ -177,7 +175,7 @@
}
else
{
- return new WindowContent(0, "Unexpected response for window " +
window.getId(), "");
+ return new WindowContent(0, "Unexpected response for window " +
windowContentContext.getId(), "");
}
}
catch (PortletInvokerException e)
Added:
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/portlet/PortletPageContextImpl.java
===================================================================
---
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/portlet/PortletPageContextImpl.java
(rev 0)
+++
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/portlet/PortletPageContextImpl.java 2008-06-09
09:23:18 UTC (rev 10951)
@@ -0,0 +1,107 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.portal.content.portlet;
+
+import org.jboss.portal.presentation.portal.model.object.WindowNode;
+import
org.jboss.portal.presentation.portal.content.portlet.controller.PresentationPageContext;
+import
org.jboss.portal.presentation.portal.content.portlet.controller.PresentationWindowContext;
+import org.jboss.portal.presentation.portal.content.PageContentContext;
+import org.jboss.portal.presentation.portal.content.WindowContentContext;
+import org.jboss.portal.portlet.Portlet;
+import org.jboss.portal.portlet.PortletContext;
+import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.PortletInvoker;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
+ * @version $Revision: 630 $
+ */
+public class PortletPageContextImpl implements PresentationPageContext
+{
+
+ /** . */
+ private final PageContentContext page;
+
+ /** A map of window ids to window contexts. */
+ private final Map<String, PortletWindowContextImpl> windows;
+
+ /** . */
+ final PortletInvoker portletInvoker;
+
+ public PortletPageContextImpl(PortletInvoker portletInvoker, PageContentContext page)
+ {
+ Map<String, PortletWindowContextImpl> windows = new HashMap<String,
PortletWindowContextImpl>();
+
+ //
+ for (WindowContentContext child : page.getWindowContexts())
+ {
+ WindowNode.Content content = child.getContent();
+
+ //
+ if (content instanceof PortletContent)
+ {
+ PortletContent portletContent = (PortletContent)content;
+
+ //
+ try
+ {
+ Portlet portlet =
portletInvoker.getPortlet(PortletContext.createPortletContext(portletContent.getRef()));
+
+ //
+ String windowId = child.getId();
+
+ //
+ windows.put(windowId, new PortletWindowContextImpl(windowId, portlet,
this));
+ }
+ catch (PortletInvokerException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ //
+ this.page = page;
+ this.windows = windows;
+ this.portletInvoker = portletInvoker;
+ }
+
+ public String getId()
+ {
+ return page.getId();
+ }
+
+ public Set<String> getWindowIds()
+ {
+ return windows.keySet();
+ }
+
+ public PresentationWindowContext getWindowContext(String windowId)
+ {
+ return windows.get(windowId);
+ }
+}
Added:
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/portlet/PortletWindowContextImpl.java
===================================================================
---
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/portlet/PortletWindowContextImpl.java
(rev 0)
+++
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/portlet/PortletWindowContextImpl.java 2008-06-09
09:23:18 UTC (rev 10951)
@@ -0,0 +1,77 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.portal.content.portlet;
+
+import org.jboss.portal.portlet.Portlet;
+import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.invocation.PortletInvocation;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import org.jboss.portal.portlet.info.PortletInfo;
+import
org.jboss.portal.presentation.portal.content.portlet.controller.PresentationWindowContext;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
+ * @version $Revision: 630 $
+ */
+public class PortletWindowContextImpl implements PresentationWindowContext
+{
+
+ /** . */
+ private final String id;
+
+ /** . */
+ private final Portlet portlet;
+
+ /** . */
+ private final PortletPageContextImpl pageContext;
+
+ public PortletWindowContextImpl(String id, Portlet portlet, PortletPageContextImpl
pageContext)
+ {
+ this.id = id;
+ this.portlet = portlet;
+ this.pageContext = pageContext;
+ }
+
+ public String getId()
+ {
+ return id;
+ }
+
+ public Portlet getPortlet()
+ {
+ return portlet;
+ }
+
+ public PortletInfo getPortletInfo()
+ {
+ return portlet.getInfo();
+ }
+
+ public PortletInvocationResponse invoke(PortletInvocation portletInvocation) throws
PortletInvokerException
+ {
+ portletInvocation.setTarget(portlet.getContext());
+
+ //
+ return pageContext.portletInvoker.invoke(portletInvocation);
+ }
+}
Added:
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/portlet/controller/PresentationPageContext.java
===================================================================
---
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/portlet/controller/PresentationPageContext.java
(rev 0)
+++
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/portlet/controller/PresentationPageContext.java 2008-06-09
09:23:18 UTC (rev 10951)
@@ -0,0 +1,38 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.portal.content.portlet.controller;
+
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
+ * @version $Revision: 630 $
+ */
+public interface PresentationPageContext
+{
+ String getId();
+
+ Set<String> getWindowIds();
+
+ PresentationWindowContext getWindowContext(String windowId);
+}
Modified:
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/portlet/controller/PresentationPortletControllerContext.java
===================================================================
---
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/portlet/controller/PresentationPortletControllerContext.java 2008-06-08
17:24:16 UTC (rev 10950)
+++
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/portlet/controller/PresentationPortletControllerContext.java 2008-06-09
09:23:18 UTC (rev 10951)
@@ -22,10 +22,7 @@
******************************************************************************/
package org.jboss.portal.presentation.portal.content.portlet.controller;
-import org.jboss.portal.portlet.PortletInvoker;
import org.jboss.portal.portlet.PortletInvokerException;
-import org.jboss.portal.portlet.PortletContext;
-import org.jboss.portal.portlet.Portlet;
import org.jboss.portal.portlet.NoSuchPortletException;
import org.jboss.portal.portlet.impl.spi.AbstractUserContext;
import org.jboss.portal.portlet.controller.PortletControllerContext;
@@ -47,16 +44,10 @@
import
org.jboss.portal.presentation.portal.content.portlet.spi.PresentationClientContext;
import
org.jboss.portal.presentation.portal.content.portlet.spi.PresentationPortalContext;
import
org.jboss.portal.presentation.portal.content.portlet.spi.PresentationSecurityContext;
-import org.jboss.portal.presentation.portal.content.portlet.PortletContent;
-import org.jboss.portal.presentation.portal.model.object.PageNode;
-import org.jboss.portal.presentation.portal.model.object.PortalNode;
-import org.jboss.portal.presentation.portal.model.object.WindowNode;
import org.jboss.portal.presentation.client.PresentationClient;
import javax.servlet.http.Cookie;
import java.util.List;
-import java.util.Map;
-import java.util.HashMap;
import java.util.Set;
/**
@@ -67,86 +58,40 @@
{
/** . */
- private final PageNode page;
+ private final PresentationPageContext pageContext;
/** . */
- private final PortletInvoker invoker;
-
- /** . */
private final StateControllerContext stateControllerContext;
- /** A map of window ids to portlets. */
- private final Map<String, Portlet> portlets;
-
- /** A map of window ids to windows. */
- private final Map<String, WindowNode> windows;
-
/** . */
private final PresentationClient client;
/** . */
private final EventControllerContext eventControllerContext;
- public PresentationPortletControllerContext(
- PresentationClient client,
- PageNode page,
- PortletInvoker invoker)
+ public PresentationPortletControllerContext(PresentationClient client,
PresentationPageContext pageContext)
{
- Map<String, Portlet> portlets = new HashMap<String, Portlet>();
- Map<String, WindowNode> windows = new HashMap<String, WindowNode>();
//
- for (PortalNode child : page.getChildren())
- {
- if (child instanceof WindowNode)
- {
- WindowNode.Content content = ((WindowNode)child).getContent();
-
- //
- if (content instanceof PortletContent)
- {
- PortletContent portletContent = (PortletContent)content;
-
- //
- try
- {
- Portlet portlet =
invoker.getPortlet(PortletContext.createPortletContext(portletContent.getRef()));
-
- //
- portlets.put(child.getId(), portlet);
- windows.put(child.getId(), (WindowNode)child);
- }
- catch (PortletInvokerException e)
- {
- e.printStackTrace();
- }
- }
- }
- }
-
- //
this.client = client;
- this.page = page;
- this.invoker = invoker;
+ this.pageContext = pageContext;
this.stateControllerContext = new PresentationStateControllerContext(this);
- this.portlets = portlets;
- this.windows = windows;
this.eventControllerContext = new PresentationEventControllerContext(this);
}
public String getPageId()
{
- return page.getId();
+ return pageContext.getId();
}
public Set<String> getWindowIds()
{
- return windows.keySet();
+ return pageContext.getWindowIds();
}
public PortletInfo getPortletInfo(String windowId)
{
- return portlets.get(windowId).getInfo();
+ return pageContext.getWindowContext(windowId).getPortletInfo();
}
public PortletInvocationContext createPortletInvocationContext(String windowId,
PortletPageNavigationalState pageNavigationalState)
@@ -179,9 +124,15 @@
PresentationPortletInvocationContext ctx =
(PresentationPortletInvocationContext)portletInvocation.getContext();
//
- WindowNode window = windows.get(ctx.getWindowId());
+
org.jboss.portal.presentation.portal.content.portlet.controller.PresentationWindowContext
window = pageContext.getWindowContext(ctx.getWindowId());
//
+ if (window == null)
+ {
+ throw new NoSuchPortletException(ctx.getWindowId());
+ }
+
+ //
portletInvocation.setServerContext(new PresentationServerContext(client));
portletInvocation.setSecurityContext(new PresentationSecurityContext());
portletInvocation.setClientContext(new PresentationClientContext());
@@ -191,17 +142,7 @@
portletInvocation.setWindowContext(new PresentationWindowContext(window));
//
- Portlet portlet = portlets.get(ctx.getWindowId());
- if (portlet == null)
- {
- throw new NoSuchPortletException(ctx.getWindowId());
- }
-
- //
- portletInvocation.setTarget(portlet.getContext());
-
- //
- return invoker.invoke(portletInvocation);
+ return window.invoke(portletInvocation);
}
public EventControllerContext getEventControllerContext()
Added:
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/portlet/controller/PresentationWindowContext.java
===================================================================
---
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/portlet/controller/PresentationWindowContext.java
(rev 0)
+++
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/portlet/controller/PresentationWindowContext.java 2008-06-09
09:23:18 UTC (rev 10951)
@@ -0,0 +1,41 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.portal.content.portlet.controller;
+
+import org.jboss.portal.portlet.info.PortletInfo;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import org.jboss.portal.portlet.invocation.PortletInvocation;
+import org.jboss.portal.portlet.PortletInvokerException;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
+ * @version $Revision: 630 $
+ */
+public interface PresentationWindowContext
+{
+ String getId();
+
+ PortletInfo getPortletInfo();
+
+ PortletInvocationResponse invoke(PortletInvocation portletInvocation) throws
PortletInvokerException;
+}
Modified:
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/portlet/spi/PresentationInstanceContext.java
===================================================================
---
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/portlet/spi/PresentationInstanceContext.java 2008-06-08
17:24:16 UTC (rev 10950)
+++
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/portlet/spi/PresentationInstanceContext.java 2008-06-09
09:23:18 UTC (rev 10951)
@@ -25,7 +25,7 @@
import org.jboss.portal.portlet.StateEvent;
import org.jboss.portal.portlet.spi.InstanceContext;
import org.jboss.portal.portlet.state.AccessMode;
-import org.jboss.portal.presentation.portal.model.object.WindowNode;
+import
org.jboss.portal.presentation.portal.content.portlet.controller.PresentationWindowContext;
/**
* @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
@@ -35,9 +35,9 @@
{
/** . */
- private final WindowNode window;
+ private final
org.jboss.portal.presentation.portal.content.portlet.controller.PresentationWindowContext
window;
- public PresentationInstanceContext(WindowNode window)
+ public PresentationInstanceContext(PresentationWindowContext window)
{
this.window = window;
}
Modified:
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/portlet/spi/PresentationWindowContext.java
===================================================================
---
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/portlet/spi/PresentationWindowContext.java 2008-06-08
17:24:16 UTC (rev 10950)
+++
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/portlet/spi/PresentationWindowContext.java 2008-06-09
09:23:18 UTC (rev 10951)
@@ -23,7 +23,6 @@
package org.jboss.portal.presentation.portal.content.portlet.spi;
import org.jboss.portal.portlet.spi.WindowContext;
-import org.jboss.portal.presentation.portal.model.object.WindowNode;
/**
* @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
@@ -33,9 +32,9 @@
{
/** . */
- private final WindowNode window;
+ private final
org.jboss.portal.presentation.portal.content.portlet.controller.PresentationWindowContext
window;
- public PresentationWindowContext(WindowNode window)
+ public
PresentationWindowContext(org.jboss.portal.presentation.portal.content.portlet.controller.PresentationWindowContext
window)
{
this.window = window;
}
Deleted:
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/PortalNodeAdapter.java
===================================================================
---
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/PortalNodeAdapter.java 2008-06-08
17:24:16 UTC (rev 10950)
+++
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/PortalNodeAdapter.java 2008-06-09
09:23:18 UTC (rev 10951)
@@ -1,288 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2008, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.presentation.portal.model;
-
-import org.jboss.portal.presentation.impl.state.structural.adapter.StructuralAdapter;
-import org.jboss.portal.presentation.portal.model.layout.LayoutStructure;
-import org.jboss.portal.presentation.portal.model.layout.LayoutElement;
-import org.jboss.portal.presentation.portal.model.layout.StructureElement;
-import org.jboss.portal.presentation.portal.model.layout.NestedStructure;
-import org.jboss.portal.presentation.portal.model.layout.ObjectStructure;
-import org.jboss.portal.presentation.portal.model.layout.LayoutStore;
-import org.jboss.portal.presentation.portal.model.layout.LayoutObject;
-import org.jboss.portal.presentation.portal.model.layout.ObjectElement;
-import org.jboss.portal.presentation.portal.model.object.PortalNodeManager;
-import org.jboss.portal.presentation.portal.model.object.PortalNode;
-import org.jboss.portal.presentation.portal.model.object.PageNode;
-import org.jboss.portal.presentation.portal.model.object.WindowNode;
-import org.jboss.portal.presentation.model.ui.UIObject;
-import org.jboss.portal.presentation.model.ui.UIPane;
-import org.jboss.portal.presentation.model.ui.UIWindow;
-import org.jboss.portal.presentation.state.structural.StructuralState;
-import org.jboss.portal.common.NotYetImplemented;
-
-import java.util.Collection;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.Collections;
-import java.io.Serializable;
-
-/**
- * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
- * @version $Revision: 630 $
- */
-public class PortalNodeAdapter implements StructuralAdapter<Object>
-{
-
- /** . */
- private PortalNodeManager nodeManager;
-
- /** . */
- private LayoutStore layoutStore;
-
- public PortalNodeAdapter(PortalNodeManager nodeManager, LayoutStore layoutStore)
- {
- this.nodeManager = nodeManager;
- this.layoutStore = layoutStore;
- }
-
- public String getRootId()
- {
- return "node." + nodeManager.getRoot().getId();
- }
-
- public Object getNode(String id)
- {
- if (id.startsWith("node."))
- {
- return nodeManager.getNode(id.substring(5));
- }
- else if (id.startsWith("structure."))
- {
- return layoutStore.getObject(id.substring(10));
- }
- else
- {
- throw new IllegalArgumentException("Unrecognized id " + id);
- }
- }
-
- public Object getParent(Object o)
- {
- if (o instanceof PortalNode)
- {
- return ((PortalNode)o).getParent();
- }
- else if (o instanceof LayoutElement)
- {
- LayoutStructure layout = ((LayoutElement)o).getStructure();
-
- //
- if (layout instanceof NestedStructure)
- {
- return ((NestedStructure)layout).getStructureElement();
- }
- else
- {
- ObjectStructure objectStructure = (ObjectStructure)layout;
- String objectId = objectStructure.getObjectRef();
- return nodeManager.getNode(objectId);
- }
- }
- else
- {
- throw new NotYetImplemented();
- }
- }
-
- public Collection<?> getChilren(Object o)
- {
- if (o instanceof PortalNode)
- {
- if (o instanceof PageNode)
- {
- String layoutStructureId = ((PageNode)o).getLayoutStructureId();
-
- //
- LayoutStructure layoutStructure =
(LayoutStructure)layoutStore.getObject(layoutStructureId);
-
- //
- return layoutStructure.getElements();
- }
- else
- {
- return ((PortalNode)o).getChildren();
- }
- }
- else if (o instanceof LayoutElement)
- {
- if (o instanceof StructureElement)
- {
- return ((StructureElement)o).getNestedStructure().getElements();
- }
- else
- {
- return Collections.emptyList();
- }
- }
- else
- {
- throw new NotYetImplemented();
- }
- }
-
- public String getId(Object o)
- {
- if (o instanceof PortalNode)
- {
- return "node." + ((PortalNode)o).getId();
- }
- else if (o instanceof LayoutObject)
- {
- return "structure." + ((LayoutObject)o).getId();
- }
- else
- {
- throw new NotYetImplemented();
- }
- }
-
- public Class<? extends UIObject> getType(Object o)
- {
- if (o instanceof PortalNode)
- {
- return ((PortalNode)o).getType();
- }
- else if (o instanceof LayoutElement)
- {
- if (o instanceof StructureElement)
- {
- return UIPane.class;
- }
- else if (o instanceof ObjectElement)
- {
- return UIWindow.class;
- }
- else
- {
- throw new NotYetImplemented();
- }
- }
- else
- {
- throw new NotYetImplemented();
- }
- }
-
- public String getName(Object o)
- {
- if (o instanceof PortalNode)
- {
- return ((PortalNode)o).getName();
- }
- else if (o instanceof LayoutObject)
- {
- // no natural name, for now use id
- return ((LayoutObject)o).getId();
- }
- else
- {
- throw new NotYetImplemented();
- }
- }
-
- public Map<String, Serializable> getProperties(Object o)
- {
- if (o instanceof PageNode)
- {
- PageNode page = (PageNode)o;
-
- //
- String layoutStructureId = ((PageNode)o).getLayoutStructureId();
-
- //
- LayoutStructure layoutStructure =
(LayoutStructure)layoutStore.getObject(layoutStructureId);
-
- //
- Map<String, Serializable> properties = new HashMap<String,
Serializable>(page.getProperties());
-
- //
- properties.putAll(layoutStructure.getState().getProperties());
-
- //
- return properties;
- }
- else if (o instanceof PortalNode)
- {
- return ((PortalNode)o).getProperties();
- }
- else if (o instanceof LayoutObject)
- {
- if (o instanceof ObjectElement)
- {
- ObjectElement element = (ObjectElement)o;
-
- //
- String windowId = element.getObjectRef();
-
- //
- WindowNode window = (WindowNode)nodeManager.getNode(windowId);
-
- //
- Map<String, Serializable> properties = new HashMap<String,
Serializable>(window.getProperties());
-
- //
- properties.putAll(element.getState().getProperties());
-
- //
- return properties;
- }
- else
- {
- return ((LayoutObject)o).getState().getProperties();
- }
- }
- else
- {
- throw new NotYetImplemented();
- }
- }
-
- public StructuralState getState(Object o)
- {
- Class<? extends UIObject> type = getType(o);
- String name = getName(o);
- Map<String, Serializable> properties = getProperties(o);
-
- //
- return new PortalNodeState(type, name, properties);
- }
-
- public void lock(Object o)
- {
- }
-
- public void unlock(Object o)
- {
- }
-}
Deleted:
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/PortalNodeState.java
===================================================================
---
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/PortalNodeState.java 2008-06-08
17:24:16 UTC (rev 10950)
+++
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/PortalNodeState.java 2008-06-09
09:23:18 UTC (rev 10951)
@@ -1,99 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2008, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.presentation.portal.model;
-
-import org.jboss.portal.presentation.model.ui.UIObject;
-import org.jboss.portal.presentation.state.structural.StructuralState;
-
-import java.util.Map;
-import java.io.Serializable;
-
-/**
- * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
- * @version $Revision: 630 $
- */
-class PortalNodeState implements StructuralState
-{
-
- /** . */
- private final Class<? extends UIObject> type;
-
- /** . */
- private final String name;
-
- /** . */
- private final Map<String, Serializable> properties;
-
- public PortalNodeState(
- Class<? extends UIObject> type,
- String name,
- Map<String, Serializable> properties)
- {
- this.type = type;
- this.name = name;
- this.properties = properties;
- }
-
- public Class<? extends UIObject> getType()
- {
- return type;
- }
-
- public String getName()
- {
- return name;
- }
-
- public Map<String, Serializable> getProperties()
- {
- return properties;
- }
-
- public boolean equals(Object obj)
- {
- if (obj == this)
- {
- return true;
- }
- if (obj instanceof PortalNodeState)
- {
- PortalNodeState that = (PortalNodeState)obj;
-
- //
- if (!that.type.equals(this.type))
- {
- return false;
- }
-
- //
- if (!that.name.equals(this.name))
- {
- return false;
- }
-
- //
- return that.properties.equals(this.properties);
- }
- return false;
- }
-}
Added:
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/content/PageContentContextImpl.java
===================================================================
---
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/content/PageContentContextImpl.java
(rev 0)
+++
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/content/PageContentContextImpl.java 2008-06-09
09:23:18 UTC (rev 10951)
@@ -0,0 +1,82 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.portal.model.content;
+
+import org.jboss.portal.presentation.portal.content.PageContentContext;
+import org.jboss.portal.presentation.portal.content.WindowContentContext;
+import org.jboss.portal.presentation.portal.model.object.PageNode;
+import org.jboss.portal.presentation.portal.model.object.PortalNode;
+import org.jboss.portal.presentation.portal.model.object.WindowNode;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
+ * @version $Revision: 630 $
+ */
+public class PageContentContextImpl implements PageContentContext
+{
+
+ /** . */
+ private final String id;
+
+ /** . */
+ private final Map<String, WindowContentContextImpl> windowContexts;
+
+ public PageContentContextImpl(PageNode page)
+ {
+ Map<String, WindowContentContextImpl> windowContexts = new HashMap<String,
WindowContentContextImpl>();
+
+ //
+ for (PortalNode child : page.getChildren())
+ {
+ if (child instanceof WindowNode)
+ {
+ WindowNode window = (WindowNode)child;
+ WindowContentContextImpl windowContext = new WindowContentContextImpl(this,
window);
+ windowContexts.put(windowContext.getId(), windowContext);
+ }
+ }
+
+ //
+ this.id = "node." + page.getId();
+ this.windowContexts = windowContexts;
+ }
+
+ public String getId()
+ {
+ return id;
+ }
+
+ public Collection<? extends WindowContentContext> getWindowContexts()
+ {
+ return windowContexts.values();
+ }
+
+ public WindowContentContext getWindowContext(String windowId)
+ {
+ return windowContexts.get(windowId);
+ }
+}
Added:
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/content/WindowContentContextImpl.java
===================================================================
---
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/content/WindowContentContextImpl.java
(rev 0)
+++
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/content/WindowContentContextImpl.java 2008-06-09
09:23:18 UTC (rev 10951)
@@ -0,0 +1,66 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.portal.model.content;
+
+import org.jboss.portal.presentation.portal.content.WindowContentContext;
+import org.jboss.portal.presentation.portal.content.PageContentContext;
+import org.jboss.portal.presentation.portal.model.object.WindowNode;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
+ * @version $Revision: 630 $
+ */
+public class WindowContentContextImpl implements WindowContentContext
+{
+
+ /** . */
+ private final String id;
+
+ /** . */
+ private final WindowNode.Content content;
+
+ /** . */
+ private final PageContentContextImpl pageContext;
+
+ public WindowContentContextImpl(PageContentContextImpl pageContext, WindowNode
window)
+ {
+ this.id = "node." + window.getId();
+ this.content = window.getContent();
+ this.pageContext = pageContext;
+ }
+
+ public String getId()
+ {
+ return id;
+ }
+
+ public WindowNode.Content getContent()
+ {
+ return content;
+ }
+
+ public PageContentContext getPageContext()
+ {
+ return pageContext;
+ }
+}
Modified:
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/object/WindowNode.java
===================================================================
---
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/object/WindowNode.java 2008-06-08
17:24:16 UTC (rev 10950)
+++
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/object/WindowNode.java 2008-06-09
09:23:18 UTC (rev 10951)
@@ -24,10 +24,6 @@
import org.jboss.portal.presentation.model.ui.UIObject;
import org.jboss.portal.presentation.model.ui.UIWindow;
-import org.jboss.portal.presentation.model.content.WindowContent;
-import org.jboss.portal.presentation.client.PresentationClient;
-import org.jboss.portal.presentation.server.PresentationServerException;
-import org.jboss.portal.portlet.PortletInvoker;
/**
* @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
@@ -61,9 +57,6 @@
public static abstract class Content
{
- public abstract WindowContent render(WindowNode window, PresentationClient client,
PortletInvoker portletInvoker) throws PresentationServerException;
-
public abstract String getType();
-
}
}