Author: julien(a)jboss.com
Date: 2008-04-08 06:48:23 -0400 (Tue, 08 Apr 2008)
New Revision: 10516
Removed:
modules/presentation/trunk/classic/src/main/java/org/jboss/portal/presentation/classic/protocol/Constants.java
Modified:
modules/presentation/trunk/build/pom.xml
modules/presentation/trunk/classic/pom.xml
modules/presentation/trunk/classic/src/main/java/org/jboss/portal/presentation/classic/ClassicPresentationClient.java
modules/presentation/trunk/classic/src/main/java/org/jboss/portal/presentation/classic/protocol/ActionDecoder.java
modules/presentation/trunk/classic/src/main/java/org/jboss/portal/presentation/classic/protocol/ActionEncoder.java
modules/presentation/trunk/pom.xml
modules/presentation/trunk/presentation/pom.xml
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/client2/PresentationClient.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/protocol/LinkActivation.java
Log:
updates to PF
Modified: modules/presentation/trunk/build/pom.xml
===================================================================
--- modules/presentation/trunk/build/pom.xml 2008-04-08 05:26:51 UTC (rev 10515)
+++ modules/presentation/trunk/build/pom.xml 2008-04-08 10:48:23 UTC (rev 10516)
@@ -20,9 +20,8 @@
<artifactId>module-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
- <name>JBoss Portal Presentation Module</name>
+ <name>JBoss Portal Presentation Framework - Parent Module</name>
<
url>http://www.jboss.com/products/jbossmc</url>
- <description>JBoss Portal Presentation Module</description>
<properties>
<version.sun.servlet>2.4</version.sun.servlet>
Modified: modules/presentation/trunk/classic/pom.xml
===================================================================
--- modules/presentation/trunk/classic/pom.xml 2008-04-08 05:26:51 UTC (rev 10515)
+++ modules/presentation/trunk/classic/pom.xml 2008-04-08 10:48:23 UTC (rev 10516)
@@ -10,8 +10,8 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>presentation-classic</artifactId>
<packaging>jar</packaging>
- <name>JBoss Portal Presentation Framework</name>
-
+ <name>JBoss Portal Presentation Framework - Classic Module</name>
+
<dependencies>
<dependency>
Modified:
modules/presentation/trunk/classic/src/main/java/org/jboss/portal/presentation/classic/ClassicPresentationClient.java
===================================================================
---
modules/presentation/trunk/classic/src/main/java/org/jboss/portal/presentation/classic/ClassicPresentationClient.java 2008-04-08
05:26:51 UTC (rev 10515)
+++
modules/presentation/trunk/classic/src/main/java/org/jboss/portal/presentation/classic/ClassicPresentationClient.java 2008-04-08
10:48:23 UTC (rev 10516)
@@ -50,9 +50,14 @@
import org.jboss.portal.presentation.protocol.ShowUIObjectResponse;
import org.jboss.portal.web.WebRequest;
import org.jboss.portal.web.WebResponse;
+import org.jboss.portal.web.ServletContextDispatcher;
+import org.jboss.portal.web.ServletContainer;
+import org.jboss.portal.web.impl.DefaultServletContainerFactory;
+import org.jboss.portal.portlet.URLFormat;
import java.io.PrintWriter;
import java.io.IOException;
+import java.io.Writer;
import java.util.Collection;
/**
@@ -92,6 +97,40 @@
return null;
}
+ public String renderURL(ProtocolAction action, URLFormat format) throws
IllegalArgumentException
+ {
+ if (action == null)
+ {
+ throw new IllegalArgumentException("No null action can be rendered");
+ }
+
+ //
+ String link = encoder.encode(action);
+
+ //
+ if (link == null)
+ {
+ throw new IllegalArgumentException("The action " + action + "
cannot be rendered");
+ }
+
+ //
+ return link;
+ }
+
+ public void renderURL(Writer writer, ProtocolAction action, URLFormat format) throws
IOException
+ {
+ writer.write(renderURL(action, format));
+ }
+
+ public ServletContextDispatcher getDispatcher()
+ {
+ ServletContainer container =
DefaultServletContainerFactory.getInstance().getServletContainer();
+ return new ServletContextDispatcher(
+ req,
+ resp,
+ container);
+ }
+
public void process() throws IOException, PresentationServerException
{
ProtocolAction action = decoder.decode(req);
Modified:
modules/presentation/trunk/classic/src/main/java/org/jboss/portal/presentation/classic/protocol/ActionDecoder.java
===================================================================
---
modules/presentation/trunk/classic/src/main/java/org/jboss/portal/presentation/classic/protocol/ActionDecoder.java 2008-04-08
05:26:51 UTC (rev 10515)
+++
modules/presentation/trunk/classic/src/main/java/org/jboss/portal/presentation/classic/protocol/ActionDecoder.java 2008-04-08
10:48:23 UTC (rev 10516)
@@ -24,10 +24,10 @@
import org.jboss.portal.presentation.protocol.ProtocolAction;
import org.jboss.portal.presentation.protocol.ViewUIObjectAction;
+import org.jboss.portal.presentation.protocol.GetActivation;
+import org.jboss.portal.presentation.protocol.PostActivation;
import org.jboss.portal.web.WebRequest;
-import java.util.Map;
-
/**
* @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
* @version $Revision: 630 $
@@ -50,6 +50,34 @@
String targetId = pathInfo.substring("/view/".length());
action = new ViewUIObjectAction(targetId);
}
+ else if (pathInfo.startsWith("/invoke/"))
+ {
+ int from = "/invoke/".length();
+
+ //
+ String path = null;
+ int to = pathInfo.indexOf('/', from + 1);
+ if (to == -1)
+ {
+ to = pathInfo.length();
+ }
+ else
+ {
+ path = pathInfo.substring(to + 1);
+ }
+
+ //
+ String targetId = pathInfo.substring(from, to);
+
+ //
+ switch (request.getVerb())
+ {
+ case GET:
+ return new GetActivation(targetId, path,
request.getQueryParameterMap());
+ case POST:
+ return new PostActivation(targetId, path,
request.getQueryParameterMap(), request.getBody());
+ }
+ }
}
//
Modified:
modules/presentation/trunk/classic/src/main/java/org/jboss/portal/presentation/classic/protocol/ActionEncoder.java
===================================================================
---
modules/presentation/trunk/classic/src/main/java/org/jboss/portal/presentation/classic/protocol/ActionEncoder.java 2008-04-08
05:26:51 UTC (rev 10515)
+++
modules/presentation/trunk/classic/src/main/java/org/jboss/portal/presentation/classic/protocol/ActionEncoder.java 2008-04-08
10:48:23 UTC (rev 10516)
@@ -24,7 +24,12 @@
import org.jboss.portal.presentation.protocol.ProtocolAction;
import org.jboss.portal.presentation.protocol.ViewUIObjectAction;
+import org.jboss.portal.presentation.protocol.LinkActivation;
+import org.jboss.portal.presentation.protocol.UIObjectAction;
+import org.jboss.portal.common.text.FastURLEncoder;
+import java.util.Map;
+
/**
* @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
* @version $Revision: 630 $
@@ -34,13 +39,61 @@
public String encode(ProtocolAction action)
{
- if (action instanceof ViewUIObjectAction)
+ if (action instanceof UIObjectAction)
{
- ViewUIObjectAction viewObjectAction = (ViewUIObjectAction)action;
+ UIObjectAction objectAction = (UIObjectAction)action;
- return "/view/" + viewObjectAction.getTargetId();
+ //
+ String targetId =
FastURLEncoder.getUTF8Instance().encode(objectAction.getTargetId());
+
+ //
+ if (action instanceof ViewUIObjectAction)
+ {
+ return "/view/" + targetId;
+ }
+ else if (action instanceof LinkActivation)
+ {
+ LinkActivation linkActivationAction = (LinkActivation)action;
+
+ //
+ StringBuilder builder = new StringBuilder("/invoke/" + targetId);
+
+ //
+ if (linkActivationAction.getPath() != null)
+ {
+ builder.append(linkActivationAction.getPath());
+ }
+
+ //
+ boolean empty = true;
+ if (linkActivationAction.getQueryParameters() != null)
+ {
+ for (Map.Entry<String, String[]> queryParameterEntry :
linkActivationAction.getQueryParameters().entrySet())
+ {
+ String queryParameterName = queryParameterEntry.getKey();
+
+ //
+ for (String queryParameterValue : queryParameterEntry.getValue())
+ {
+ if (!empty)
+ {
+ builder.append('&');
+ }
+
+ //
+
builder.append(FastURLEncoder.getUTF8Instance().encode(queryParameterName));
+ builder.append('=');
+
builder.append(FastURLEncoder.getUTF8Instance().encode(queryParameterValue));
+ }
+ }
+ }
+
+ //
+ return builder.toString();
+ }
}
+ //
return null;
}
Deleted:
modules/presentation/trunk/classic/src/main/java/org/jboss/portal/presentation/classic/protocol/Constants.java
===================================================================
---
modules/presentation/trunk/classic/src/main/java/org/jboss/portal/presentation/classic/protocol/Constants.java 2008-04-08
05:26:51 UTC (rev 10515)
+++
modules/presentation/trunk/classic/src/main/java/org/jboss/portal/presentation/classic/protocol/Constants.java 2008-04-08
10:48:23 UTC (rev 10516)
@@ -1,45 +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.classic.protocol;
-
-/**
- * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
- * @version $Revision: 630 $
- */
-final class Constants
-{
-
- /** . */
- public static final String ACTION_PARAM = "action";
-
- /** . */
- public static final String TARGET_ID_PARAM = "id";
-
- /** . */
- public static final String VIEW_UI_OBJECT_ACTION = "view";
-
- private Constants()
- {
- }
-
-}
Modified: modules/presentation/trunk/pom.xml
===================================================================
--- modules/presentation/trunk/pom.xml 2008-04-08 05:26:51 UTC (rev 10515)
+++ modules/presentation/trunk/pom.xml 2008-04-08 10:48:23 UTC (rev 10516)
@@ -4,7 +4,7 @@
<groupId>org.jboss.portal.presentation</groupId>
<artifactId>module-aggregator</artifactId>
<packaging>pom</packaging>
- <name>JBoss Portal Presentation Module</name>
+ <name>JBoss Portal Presentation Framework - Aggregator Module</name>
<version>1.0.0-SNAPSHOT</version>
<
url>http://labs.jboss.com/jbossportal</url>
Modified: modules/presentation/trunk/presentation/pom.xml
===================================================================
--- modules/presentation/trunk/presentation/pom.xml 2008-04-08 05:26:51 UTC (rev 10515)
+++ modules/presentation/trunk/presentation/pom.xml 2008-04-08 10:48:23 UTC (rev 10516)
@@ -10,8 +10,8 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>presentation-presentation</artifactId>
<packaging>jar</packaging>
- <name>JBoss Portal Presentation Framework</name>
-
+ <name>JBoss Portal Presentation Framework - Presentation Module</name>
+
<dependencies>
<dependency>
<groupId>sun-servlet</groupId>
Modified:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/client2/PresentationClient.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/client2/PresentationClient.java 2008-04-08
05:26:51 UTC (rev 10515)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/client2/PresentationClient.java 2008-04-08
10:48:23 UTC (rev 10516)
@@ -23,7 +23,13 @@
package org.jboss.portal.presentation.client2;
import org.jboss.portal.presentation.state.navigational.NavigationalStateContext;
+import org.jboss.portal.presentation.protocol.ProtocolAction;
+import org.jboss.portal.portlet.URLFormat;
+import org.jboss.portal.web.ServletContextDispatcher;
+import java.io.IOException;
+import java.io.Writer;
+
/**
* The contract that defines the services that the client provides to the server during a
presentation server invocation.
*
@@ -33,6 +39,38 @@
public interface PresentationClient
{
+ /**
+ * Renders the provided action as an hyperlink.
+ *
+ * @param action the action to render
+ * @param format the url format
+ * @return the rendered url
+ * @throws IllegalArgumentException if the action is null or cannot be rendered
+ */
+ String renderURL(ProtocolAction action, URLFormat format) throws
IllegalArgumentException;
+
+ /**
+ * Renders the provided action as an hyperlink.
+ *
+ * @param writer the writer
+ * @param action the action to render
+ * @param format the url format
+ * @throws IllegalArgumentException if the action is null or cannot be rendered
+ * @throws IOException any IOException thrown by the writer
+ */
+ void renderURL(Writer writer, ProtocolAction action, URLFormat format) throws
IOException;
+
+ /**
+ * Returns the navigational state context provided by the client.
+ *
+ * @return the navigational state context
+ */
NavigationalStateContext getNavigationalStateContext();
+ /**
+ * Returns the servlet context dispatcher.
+ *
+ * @return the servlet context dispatcher
+ */
+ ServletContextDispatcher getDispatcher();
}
Modified:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/protocol/LinkActivation.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/protocol/LinkActivation.java 2008-04-08
05:26:51 UTC (rev 10515)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/protocol/LinkActivation.java 2008-04-08
10:48:23 UTC (rev 10516)
@@ -42,6 +42,19 @@
super(targetId);
//
+ if (path != null)
+ {
+ if (path.length() == 0)
+ {
+ throw new IllegalArgumentException("Empty path are not accepted");
+ }
+ if (path.charAt(0) != '/')
+ {
+ throw new IllegalArgumentException("Path values must start with
'/':" + path);
+ }
+ }
+
+ //
this.path = path;
this.queryParameters = queryParameters;
}