shuber 2005/03/09 17:47:33 CET
Modified files:
core/src/java/org/jahia/services/applications
JahiaJ2SessionPortalURL.java
JetspeedDispatchingProvider.java
core/src/webapp/WEB-INF/etc/config process-pipeline.xml
core/src/webapp/WEB-INF/etc/jetspeed/conf/assembly
jetspeed-spring.xml
Added files:
core/src/java/org/jahia/operations/valves
J2ProcessActionValve.java
Log:
First implementation of Jetspeed 2 portlet action, mode & window state
processing, seems to work with a single portlet on a page.
-> Still missing are buttons for windows states and portlet modes around the
window.
Revision Changes Path
1.1 +103 -0
jahia/core/src/java/org/jahia/operations/valves/J2ProcessActionValve.java (new)
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/java/org/jahia/operations/valves/J2ProcessActionValve.java?rev=1.1&content-type=text/plain
1.9 +27 -4
jahia/core/src/java/org/jahia/services/applications/JahiaJ2SessionPortalURL.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/java/org/jahia/services/applications/JahiaJ2SessionPortalURL.java.diff?r1=1.8&r2=1.9&f=h
1.9 +108 -11
jahia/core/src/java/org/jahia/services/applications/JetspeedDispatchingProvider.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/java/org/jahia/services/applications/JetspeedDispatchingProvider.java.diff?r1=1.8&r2=1.9&f=h
1.2 +3 -0
jahia/core/src/webapp/WEB-INF/etc/config/process-pipeline.xml
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/webapp/WEB-INF/etc/config/process-pipeline.xml.diff?r1=1.1&r2=1.2&f=h
1.2 +3 -0
jahia/core/src/webapp/WEB-INF/etc/jetspeed/conf/assembly/jetspeed-spring.xml
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/webapp/WEB-INF/etc/jetspeed/conf/assembly/jetspeed-spring.xml.diff?r1=1.1&r2=1.2&f=h
Index: JahiaJ2SessionPortalURL.java
===================================================================
RCS file:
/home/cvs/repository/jahia/core/src/java/org/jahia/services/applications/JahiaJ2SessionPortalURL.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- JahiaJ2SessionPortalURL.java 23 Dec 2004 16:19:41 -0000 1.8
+++ JahiaJ2SessionPortalURL.java 9 Mar 2005 16:47:31 -0000 1.9
@@ -39,11 +39,28 @@
}
protected void decodePathAndNavigationalState(HttpServletRequest
request) {
+ String path = null;
+ String encodedNavigationalState = null;
+ if (request.getPathInfo() != null) {
+ if (request.getPathInfo().indexOf("/" +
getNavigationalStateParameterName() + "/") != -1) {
+ int navParamPos = request.getPathInfo().indexOf("/" +
getNavigationalStateParameterName() + "/");
+ int navParamLength = ("/" +
getNavigationalStateParameterName() + "/").length();
+ int navParamEnd = request.getPathInfo().indexOf("/",
navParamPos + navParamLength);
+ encodedNavigationalState =
request.getPathInfo().substring(navParamPos + navParamLength, navParamEnd);
+ }
+ path = request.getPathInfo();
+ int length = path.length();
+ if (length > 1 && path.endsWith("/")) {
+ path = path.substring(0, length - 1);
+ }
+ }
+ setPath(path);
+ setEncodedNavigationalState(encodedNavigationalState);
}
protected String createPortletURL(String encodedNavState, boolean
secure) {
- ParamBean paramBean = (ParamBean)
Jahia.getThreadParamBean().getRequest().getAttribute(PARAMBEAN_REQUEST_ATTRIBUTEKEY);
+ ParamBean paramBean = (ParamBean)
Jahia.getThreadParamBean().getRealRequest().getAttribute(PARAMBEAN_REQUEST_ATTRIBUTEKEY);
if (paramBean == null) {
// No context was set by Jahia, then we use default parent
behavior
return super.createPortletURL(encodedNavState, secure);
@@ -52,13 +69,19 @@
StringBuffer paramPart = new StringBuffer();
paramPart.append("/cache/bypass/appid/");
- String appUniqueID = (String)
Jahia.getThreadParamBean().getRequest().getAttribute(APPUNIQUEID_REQUEST_ATTRIBUTEKEY);
+ String appUniqueID = (String)
Jahia.getThreadParamBean().getRealRequest().getAttribute(APPUNIQUEID_REQUEST_ATTRIBUTEKEY);
paramPart.append(appUniqueID);
String resultURL = null;
try {
- if (getNavigationalState().getPortletWindowOfAction() != null) {
- resultURL =
paramBean.composeEngineUrl(JetspeedProcessActionEngine.ENGINE_NAME, new
Properties(), paramPart.toString());
+ if (encodedNavState != null) {
+ paramPart.append("/");
+ paramPart.append(getNavigationalStateParameterName());
+ paramPart.append("/");
+ paramPart.append(encodedNavState);
+ paramPart.append("/j2action/true/");
+ resultURL = paramBean.composePageUrl(paramBean.getPageID())
+ paramPart.toString();
+ // resultURL =
paramBean.composeEngineUrl(JetspeedProcessActionEngine.ENGINE_NAME, new
Properties(), paramPart.toString());
return resultURL;
} else {
resultURL = paramBean.composePageUrl(paramBean.getPageID())
+ paramPart.toString();
Index: JetspeedDispatchingProvider.java
===================================================================
RCS file:
/home/cvs/repository/jahia/core/src/java/org/jahia/services/applications/JetspeedDispatchingProvider.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- JetspeedDispatchingProvider.java 23 Dec 2004 16:19:41 -0000 1.8
+++ JetspeedDispatchingProvider.java 9 Mar 2005 16:47:31 -0000 1.9
@@ -59,11 +59,12 @@
import java.util.Map;
import org.jahia.services.usermanager.JahiaGroup;
-public class JetspeedDispatchingProvider implements DispatchingProvider,
UserRoleResolver {
+public class JetspeedDispatchingProvider implements DispatchingProvider,
+ UserRoleResolver {
private static org.apache.log4j.Logger logger =
org.apache.log4j.Logger.getLogger(
- JetspeedDispatchingProvider.class);
+ JetspeedDispatchingProvider.class);
/** the service unique instance */
private static JetspeedDispatchingProvider instance;
@@ -107,7 +108,97 @@
int windowID,
ParamBean jParams)
throws JahiaException {
- // TODO: process action here
+ try {
+
+ String entryPointDefName = entryPointInstance.getDefName();
+ int separatorPos = entryPointDefName.indexOf("###");
+ String portletDefName = entryPointDefName.substring(0,
separatorPos);
+ String portletEntityID =
entryPointDefName.substring(separatorPos +
+ "###".length());
+ int applicationID = entryPointInstance.getApplicationID();
+ ApplicationBean appBean = ServicesRegistry.getInstance().
+ getApplicationsManagerService().
+ getApplication(applicationID);
+ String jetspeedPathInfo = "";
+ String pathInfo = jParams.getRealRequest().getPathInfo();
+ if (pathInfo != null) {
+ int appIDPos = pathInfo.indexOf("/appID/");
+ if (appIDPos != -1) {
+ int J2PathPos = pathInfo.indexOf("/", appIDPos);
+ jetspeedPathInfo = pathInfo.substring(J2PathPos);
+ }
+ }
+ String dispatchURL =
+ "/jetspeed/portal" + jetspeedPathInfo +
+ "?pipeline=action-pipeline&portlet=" +
+ appBean.getName() + "::" + portletDefName + "&entity=" +
+ portletEntityID;
+ logger.debug("Using URL=[" + dispatchURL +
+ "] to dispatch to jetspeed");
+ StringBuffer emulURLBuf = new StringBuffer();
+ emulURLBuf.append(jParams.getRequest().getScheme());
+ emulURLBuf.append("://");
+ emulURLBuf.append(jParams.getRequest().getServerName());
+ emulURLBuf.append(":");
+ emulURLBuf.append(jParams.getRequest().getServerPort());
+ emulURLBuf.append(jParams.getRequest().getContextPath());
+ emulURLBuf.append(dispatchURL);
+ String emulURL = emulURLBuf.toString();
+
+ Map context = new HashMap();
+ context.put("org.jahia.services.applications.applicationBean",
+ appBean);
+ context.put("org.jahia.services.applications.windowID",
+ new Integer(windowID));
+ J2DispatchRequestWrapper request = new J2DispatchRequestWrapper(
+ jParams.getRealRequest(), context);
+ if (!jParams.getUser().getName().equals(JahiaUserManagerService.
+ GUEST_USERNAME)) {
+ request.setUserPrincipal(jParams.getUser());
+ request.setRemoteUser(jParams.getUser().getName());
+ request.setUserRoleResolver(this);
+ }
+ ServletIncludeResponseWrapper response = new
+ ServletIncludeResponseWrapper(jParams.getResponse(),
+ Integer.toString(windowID) +
"_" +
+ Integer.toString(
+
entryPointInstance.getID()),
+ emulURL, jParams, false, null);
+ request.setAttribute(JahiaJ2SessionPortalURL.
+ PARAMBEAN_REQUEST_ATTRIBUTEKEY, jParams);
+ request.setAttribute(JahiaJ2SessionPortalURL.
+ APPUNIQUEID_REQUEST_ATTRIBUTEKEY,
+ Integer.toString(windowID) + "_" +
+
Integer.toString(entryPointInstance.getID()));
+
+ ServletContext jetspeed = jParams.getContext();
//.getContext("/jetspeed");
+ if (jetspeed == null) {
+ String message =
+ "Dispatching ERROR: Failed to get /jetspeed webapp
context";
+ response.getWriter().println(message);
+ }
+
+ RequestDispatcher jsDispatcher = jetspeed.getRequestDispatcher(
+ dispatchURL);
+ if (jsDispatcher == null) {
+ String message =
+ "Dispatching ERROR: Failed to get a request dispatcher
for /jetspeed";
+ response.getWriter().println(message);
+ }
+
+ // TODO: set the content type from ...
+ response.setContentType("text/html");
+
+ jsDispatcher.include(request, response);
+
+ request.removeAttribute(JahiaJ2SessionPortalURL.
+ PARAMBEAN_REQUEST_ATTRIBUTEKEY);
+ request.removeAttribute(JahiaJ2SessionPortalURL.
+ APPUNIQUEID_REQUEST_ATTRIBUTEKEY);
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
+
}
/**
@@ -163,10 +254,14 @@
String emulURL = emulURLBuf.toString();
Map context = new HashMap();
- context.put("org.jahia.services.applications.applicationBean",
appBean);
- context.put("org.jahia.services.applications.windowID", new
Integer(windowID));
- J2DispatchRequestWrapper request = new
J2DispatchRequestWrapper(jParams.getRealRequest(), context);
- if
(!jParams.getUser().getName().equals(JahiaUserManagerService.GUEST_USERNAME)) {
+ context.put("org.jahia.services.applications.applicationBean",
+ appBean);
+ context.put("org.jahia.services.applications.windowID",
+ new Integer(windowID));
+ J2DispatchRequestWrapper request = new J2DispatchRequestWrapper(
+ jParams.getRealRequest(), context);
+ if (!jParams.getUser().getName().equals(JahiaUserManagerService.
+ GUEST_USERNAME)) {
request.setUserPrincipal(jParams.getUser());
request.setRemoteUser(jParams.getUser().getName());
request.setUserRoleResolver(this);
@@ -175,7 +270,8 @@
ServletIncludeResponseWrapper(jParams.getResponse(),
Integer.toString(windowID) +
"_" +
Integer.toString(
- entryPointInstance.getID()), emulURL, jParams, false, null);
+
entryPointInstance.getID()),
+ emulURL, jParams, false, null);
request.setAttribute(JahiaJ2SessionPortalURL.
PARAMBEAN_REQUEST_ATTRIBUTEKEY, jParams);
request.setAttribute(JahiaJ2SessionPortalURL.
@@ -208,7 +304,8 @@
request.removeAttribute(JahiaJ2SessionPortalURL.
PARAMBEAN_REQUEST_ATTRIBUTEKEY);
-
request.removeAttribute(JahiaJ2SessionPortalURL.APPUNIQUEID_REQUEST_ATTRIBUTEKEY);
+ request.removeAttribute(JahiaJ2SessionPortalURL.
+ APPUNIQUEID_REQUEST_ATTRIBUTEKEY);
result = response.getStringBuffer();
} catch (Throwable t) {
t.printStackTrace();
@@ -220,7 +317,8 @@
public boolean isUserInRole (Map context, Principal user, String
roleName) {
ApplicationBean appBean = (ApplicationBean) context.get(
"org.jahia.services.applications.applicationBean");
- int windowID = ((Integer)
context.get("org.jahia.services.applications.windowID")).intValue();
+ int windowID = ( (Integer) context.get(
+ "org.jahia.services.applications.windowID")).intValue();
JahiaGroup roleGroup = ServicesRegistry.getInstance().
getJahiaGroupManagerService().lookupGroup(0,
appBean.getID() + "_" + windowID + "_" + roleName);
@@ -246,5 +344,4 @@
}
-
}
Index: process-pipeline.xml
===================================================================
RCS file:
/home/cvs/repository/jahia/core/src/webapp/WEB-INF/etc/config/process-pipeline.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- process-pipeline.xml 24 Jun 2004 17:33:44 -0000 1.1
+++ process-pipeline.xml 9 Mar 2005 16:47:32 -0000 1.2
@@ -29,6 +29,9 @@
<className>org.jahia.operations.valves.CacheReadValve</className>
</valveDescriptor>
<valveDescriptor>
+ <className>org.jahia.operations.valves.J2ProcessActionValve</className>
+ </valveDescriptor>
+ <valveDescriptor>
<className>org.jahia.operations.valves.EngineValve</className>
</valveDescriptor>
<valveDescriptor>
Index: jetspeed-spring.xml
===================================================================
RCS file:
/home/cvs/repository/jahia/core/src/webapp/WEB-INF/etc/jetspeed/conf/assembly/jetspeed-spring.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- jetspeed-spring.xml 23 Dec 2004 16:19:50 -0000 1.1
+++ jetspeed-spring.xml 9 Mar 2005 16:47:32 -0000 1.2
@@ -248,7 +248,10 @@
class="org.apache.jetspeed.container.state.impl.JetspeedNavigationalStateComponent"
>
<constructor-arg
index="0"><value>org.apache.jetspeed.container.state.impl.SessionFullNavigationalState</value></constructor-arg>
+ <!--
<constructor-arg
index="1"><value>org.apache.jetspeed.container.url.impl.PathInfoEncodingPortalURL</value></constructor-arg>
+ -->
+ <constructor-arg
index="1"><value>org.jahia.services.applications.JahiaJ2SessionPortalURL</value></constructor-arg>
<constructor-arg
index="2"><value>org.apache.jetspeed.container.state.impl.JetspeedNavigationalStateCodec</value></constructor-arg>
</bean>
Index: J2ProcessActionValve.java
====================================================================
package org.jahia.operations.valves;
import org.jahia.pipelines.PipelineException;
import org.jahia.pipelines.valves.Valve;
import org.jahia.pipelines.valves.ValveContext;
import org.jahia.bin.Jahia;
import org.apache.jetspeed.request.RequestContextComponent;
import org.apache.jetspeed.Jetspeed;
import javax.servlet.http.HttpServletRequest;
import org.apache.jetspeed.PortalReservedParameters;
import org.apache.jetspeed.request.RequestContext;
import javax.servlet.ServletConfig;
import org.jahia.services.applications.JahiaJ2SessionPortalURL;
import javax.servlet.http.HttpServletResponse;
import org.apache.jetspeed.container.state.NavigationalStateComponent;
import org.jahia.params.ParamBean;
public class J2ProcessActionValve implements Valve {
private static org.apache.log4j.Logger logger =
org.apache.log4j.Logger.getLogger(J2ProcessActionValve.class);
public J2ProcessActionValve () {
}
/**
* initialize
*
* @todo Implement this org.jahia.pipelines.valves.Valve method
*/
public void initialize () {
}
/**
* invoke
*
* @param context Object
* @param valveContext ValveContext
* @throws PipelineException
* @todo Implement this org.jahia.pipelines.valves.Valve method
*/
public void invoke (Object context, ValveContext valveContext)
throws PipelineException {
RequestContextComponent contextComponent = null;
RequestContext requestContext = null;
ParamBean paramBean = (ParamBean) context;
try {
HttpServletRequest request = paramBean.getRequest();
HttpServletResponse response = paramBean.getResponse();
NavigationalStateComponent nav = (NavigationalStateComponent)
Jetspeed.getComponentManager().
getComponent(
NavigationalStateComponent.class);
boolean hasActionParam = false;
String pathInfo = request.getPathInfo();
if (pathInfo != null) {
if (pathInfo.indexOf("j2action") != -1) {
hasActionParam = true;
}
}
if (hasActionParam) {
logger.debug("Action parameter found.");
ServletConfig config = Jahia.getStaticServletConfig();
org.apache.jetspeed.engine.Engine engine =
Jetspeed.getEngine();
contextComponent = (RequestContextComponent) Jetspeed.
getComponentManager().getComponent(
RequestContextComponent.class);
requestContext = contextComponent.create(request, response,
config);
requestContext.setAttribute(PortalReservedParameters.PIPELINE,
PortalReservedParameters.ACTION_PIPELINE);
//
context.setAttribute(PortalReservedParameters.PORTLET_ENTITY, entityId);
// now let's set the request attributes required by the
// URL generation implementation.
request.setAttribute(JahiaJ2SessionPortalURL.
PARAMBEAN_REQUEST_ATTRIBUTEKEY,
paramBean);
request.setAttribute(JahiaJ2SessionPortalURL.
APPUNIQUEID_REQUEST_ATTRIBUTEKEY,
paramBean.getParameter("appid"));
engine.service(requestContext);
request.removeAttribute(JahiaJ2SessionPortalURL.
PARAMBEAN_REQUEST_ATTRIBUTEKEY);
request.removeAttribute(JahiaJ2SessionPortalURL.
APPUNIQUEID_REQUEST_ATTRIBUTEKEY);
}
} catch (Throwable t) {
logger.error("error in fusion access controller", t);
} finally {
if (contextComponent != null && requestContext != null) {
contextComponent.release(requestContext);
}
}
// continue valve processing...
valveContext.invokeNext(context);
}
}