Author: sohil.shah(a)jboss.com
Date: 2007-11-13 11:25:06 -0500 (Tue, 13 Nov 2007)
New Revision: 8903
Modified:
branches/UIServer/core/src/main/org/jboss/portal/core/presentation/server/MainProcessor.java
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/action/server/LinkActivation.java
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/server/Processor.java
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/server/ProcessorRequest.java
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/service/UIServer.java
Log:
refactoring
Modified:
branches/UIServer/core/src/main/org/jboss/portal/core/presentation/server/MainProcessor.java
===================================================================
---
branches/UIServer/core/src/main/org/jboss/portal/core/presentation/server/MainProcessor.java 2007-11-13
15:43:48 UTC (rev 8902)
+++
branches/UIServer/core/src/main/org/jboss/portal/core/presentation/server/MainProcessor.java 2007-11-13
16:25:06 UTC (rev 8903)
@@ -45,6 +45,7 @@
import org.jboss.portal.theme.page.WindowContext;
import org.jboss.portal.theme.page.WindowResult;
+import org.jboss.portal.presentation.RequestContext;
import org.jboss.portal.presentation.server.Processor;
import org.jboss.portal.presentation.server.ProcessorRequest;
import org.jboss.portal.presentation.server.ProcessorResponse;
@@ -88,7 +89,7 @@
/**
*
*/
- public ProcessorResponse process(ProcessorRequest request) throws ServerException
+ public ProcessorResponse process(RequestContext requestContext, ProcessorRequest
request) throws ServerException
{
try
{
Modified:
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/action/server/LinkActivation.java
===================================================================
---
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/action/server/LinkActivation.java 2007-11-13
15:43:48 UTC (rev 8902)
+++
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/action/server/LinkActivation.java 2007-11-13
16:25:06 UTC (rev 8903)
@@ -24,6 +24,9 @@
import java.util.Map;
+import org.jboss.portal.uiserver.protocol.Portal;
+import org.jboss.portal.uiserver.protocol.PortalObject;
+
/**
* @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
*
@@ -43,7 +46,17 @@
/**
*
*/
- protected Map queryParameters = null;
+ protected Map queryParameters = null;
+
+ /**
+ * The Portal that the target object belongs to
+ */
+ protected Portal portal = null;
+
+ /**
+ * Target object where action needs to be performed
+ */
+ protected PortalObject target = null;
/**
*
@@ -98,4 +111,40 @@
{
this.url = url;
}
+
+ /**
+ *
+ * @return
+ */
+ public Portal getPortal()
+ {
+ return portal;
+ }
+
+ /**
+ *
+ * @param portal
+ */
+ public void setPortal(Portal portal)
+ {
+ this.portal = portal;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public PortalObject getTarget()
+ {
+ return target;
+ }
+
+ /**
+ *
+ * @param target
+ */
+ public void setTarget(PortalObject target)
+ {
+ this.target = target;
+ }
}
Modified:
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/server/Processor.java
===================================================================
---
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/server/Processor.java 2007-11-13
15:43:48 UTC (rev 8902)
+++
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/server/Processor.java 2007-11-13
16:25:06 UTC (rev 8903)
@@ -23,6 +23,7 @@
package org.jboss.portal.presentation.server;
import org.jboss.portal.server.ServerException;
+import org.jboss.portal.presentation.RequestContext;
/**
* UIServer calls the Processor to hand it
@@ -39,5 +40,5 @@
* @param request
* @throws ServerException
*/
- public ProcessorResponse process(ProcessorRequest request) throws ServerException;
+ public ProcessorResponse process(RequestContext requestContext,ProcessorRequest
request) throws ServerException;
}
Modified:
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/server/ProcessorRequest.java
===================================================================
---
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/server/ProcessorRequest.java 2007-11-13
15:43:48 UTC (rev 8902)
+++
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/server/ProcessorRequest.java 2007-11-13
16:25:06 UTC (rev 8903)
@@ -24,8 +24,6 @@
import java.io.Serializable;
-import org.jboss.portal.uiserver.protocol.Portal;
-import org.jboss.portal.uiserver.protocol.PortalObject;
import org.jboss.portal.server.ServerInvocation;
import org.jboss.portal.presentation.action.server.ServerAction;
@@ -39,18 +37,8 @@
*
*/
public class ProcessorRequest implements Serializable
-{
+{
/**
- * The Portal that the target object belongs to
- */
- private Portal portal = null;
-
- /**
- * Target object where action needs to be performed
- */
- private PortalObject target = null;
-
- /**
* The Portal action to be performed
*/
private ServerAction action = null;
@@ -64,12 +52,10 @@
*
*
*/
- public ProcessorRequest(ServerAction action, ServerInvocation serverInvocation, Portal
portal, PortalObject target)
+ public ProcessorRequest(ServerAction action, ServerInvocation serverInvocation)
{
this.action = action;
- this.serverInvocation = serverInvocation;
- this.portal = portal;
- this.target = target;
+ this.serverInvocation = serverInvocation;
}
/**
@@ -94,42 +80,6 @@
*
* @return
*/
- public Portal getPortal()
- {
- return portal;
- }
-
- /**
- *
- * @param portal
- */
- public void setPortal(Portal portal)
- {
- this.portal = portal;
- }
-
- /**
- *
- * @return
- */
- public PortalObject getTarget()
- {
- return target;
- }
-
- /**
- *
- * @param target
- */
- public void setTarget(PortalObject target)
- {
- this.target = target;
- }
-
- /**
- *
- * @return
- */
public ServerInvocation getServerInvocation()
{
return serverInvocation;
@@ -150,7 +100,7 @@
public String toString()
{
StringBuffer buffer = new StringBuffer();
- buffer.append("[action="+this.action+",
portal="+this.portal+", target="+this.target+"]");
+ buffer.append("[action="+this.action+"]");
return buffer.toString();
}
}
Modified:
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/service/UIServer.java
===================================================================
---
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/service/UIServer.java 2007-11-13
15:43:48 UTC (rev 8902)
+++
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/service/UIServer.java 2007-11-13
16:25:06 UTC (rev 8903)
@@ -29,10 +29,13 @@
import org.jboss.portal.uiserver.protocol.PortalObject;
import org.jboss.portal.uiserver.protocol.Portal;
+import org.jboss.portal.presentation.RequestContext;
+
import org.jboss.portal.presentation.server.ProcessorRequest;
import org.jboss.portal.presentation.server.ProcessorResponse;
import org.jboss.portal.presentation.server.PresentationServer;
import org.jboss.portal.presentation.action.server.ServerAction;
+import org.jboss.portal.presentation.action.server.LinkActivation;
import org.jboss.portal.presentation.action.server.GetActivation;
import org.jboss.portal.presentation.action.server.PostActivation;
@@ -77,65 +80,12 @@
public void handle(ServerInvocation invocation) throws ServerException
{
try
- {
- String portalRequestPath =
invocation.getServerContext().getPortalRequestPath();
-
- //Process the incoming request and produce a proper ProcessorRequest to be
- //processed by the core Portal component
- Portal portal = null;
- PortalObject target = null;
- StringTokenizer st = new StringTokenizer(portalRequestPath, "/");
- StringBuffer buffer = new StringBuffer("/");
- while(st.hasMoreTokens())
- {
- String token = st.nextToken();
- if(portal == null)
- {
- portal =
this.presentationServer.getPortalObjectReader().findPortal(token);
- if(portal != null)
- {
- buffer.append(token);
- if(st.hasMoreTokens())
- {
- buffer.append("/");
- }
- }
- }
- else
- {
- buffer.append(token);
- String id = buffer.toString();
- if(st.hasMoreTokens())
- {
- buffer.append("/");
- }
-
- if(target == null)
- {
- target = portal.findChild(id);
- if(target == null)
- {
- target =
this.presentationServer.getPortalObjectReader().findPortalObject(portal, id);
- }
- }
- else
- {
- PortalObject cour = target.findChild(id);
- if(cour == null)
- {
- target =
this.presentationServer.getPortalObjectReader().findPortalObject(target, id);
- }
- else
- {
- target = cour;
- }
- }
- }
- }
-
+ {
ServerAction serverAction = this.getServerAction(invocation);
- ProcessorRequest processorRequest = new ProcessorRequest(serverAction,
invocation, portal, target);
- ProcessorResponse processorResponse =
this.presentationServer.getProcessor().process(processorRequest);
+ ProcessorRequest processorRequest = new ProcessorRequest(serverAction,
invocation);
+ RequestContext requestContext = null; //Just use null until proper
implementation is provided
+ ProcessorResponse processorResponse =
this.presentationServer.getProcessor().process(requestContext,
+ processorRequest);
//Go ahead and render to the client based on ProcessorResponse received from the
core Portal
if(processorResponse != null)
@@ -209,7 +159,75 @@
post.setQueryParameters(invocationContext.getQueryParameterMap());
post.setBodyParameters(invocationContext.getBodyParameterMap());
serverAction = post;
- }
+ }
+
+ //If this is a link activation, then interpret the Portal and the PortalObject
that
+ //this link is targetted for
+ if(serverAction instanceof LinkActivation)
+ {
+ String portalRequestPath =
invocation.getServerContext().getPortalRequestPath();
+
+ //Process the incoming request and produce a proper ProcessorRequest to be
+ //processed by the core Portal component
+ Portal portal = null;
+ PortalObject target = null;
+ StringTokenizer st = new StringTokenizer(portalRequestPath, "/");
+ StringBuffer buffer = new StringBuffer("/");
+ while(st.hasMoreTokens())
+ {
+ String token = st.nextToken();
+ if(portal == null)
+ {
+ portal =
this.presentationServer.getPortalObjectReader().findPortal(token);
+ if(portal != null)
+ {
+ buffer.append(token);
+ if(st.hasMoreTokens())
+ {
+ buffer.append("/");
+ }
+ }
+ }
+ else
+ {
+ buffer.append(token);
+ String id = buffer.toString();
+ if(st.hasMoreTokens())
+ {
+ buffer.append("/");
+ }
+
+ if(target == null)
+ {
+ target = portal.findChild(id);
+ if(target == null)
+ {
+ target =
this.presentationServer.getPortalObjectReader().findPortalObject(portal, id);
+ }
+ }
+ else
+ {
+ PortalObject cour = target.findChild(id);
+ if(cour == null)
+ {
+ target =
this.presentationServer.getPortalObjectReader().findPortalObject(target, id);
+ }
+ else
+ {
+ target = cour;
+ }
+ }
+ }
+ }
+
+ //Setting up the proper targets for this link
+ ((LinkActivation)serverAction).setPortal(portal);
+ ((LinkActivation)serverAction).setTarget(target);
+ }
+
+
return serverAction;
}
+
+
}