You are viewing a plain text version of this content. The canonical link for it is here.
Posted to wsrp4j-dev@portals.apache.org by cz...@apache.org on 2006/02/03 15:29:19 UTC
svn commit: r374677 [2/2] - in /portals/wsrp4j/trunk/sandbox/wsrp4j:
commons/src/java/org/apache/wsrp4j/commons/exception/
commons/src/java/org/apache/wsrp4j/commons/persistence/driver/
commons/src/java/org/apache/wsrp4j/commons/util/ consumer-swingcon...
Modified: portals/wsrp4j/trunk/sandbox/wsrp4j/commons/src/java/org/apache/wsrp4j/commons/util/WindowStates.java
URL: http://svn.apache.org/viewcvs/portals/wsrp4j/trunk/sandbox/wsrp4j/commons/src/java/org/apache/wsrp4j/commons/util/WindowStates.java?rev=374677&r1=374676&r2=374677&view=diff
==============================================================================
--- portals/wsrp4j/trunk/sandbox/wsrp4j/commons/src/java/org/apache/wsrp4j/commons/util/WindowStates.java (original)
+++ portals/wsrp4j/trunk/sandbox/wsrp4j/commons/src/java/org/apache/wsrp4j/commons/util/WindowStates.java Fri Feb 3 06:28:31 2006
@@ -21,8 +21,7 @@
/**
* @version $Id$
*/
-public class WindowStates implements java.io.Serializable
-{
+public class WindowStates implements java.io.Serializable {
private String _value_;
private static HashMap _table_ = new HashMap();
@@ -42,8 +41,7 @@
public static final WindowStates maximized = new WindowStates(_maximized);
public static final WindowStates solo = new WindowStates(_solo);
- public String getValue()
- {
+ public String getValue() {
return _value_;
}
@@ -55,8 +53,7 @@
* @return The WSRP <code>WindowStates</code> represented by the passed
* string
*/
- public static WindowStates fromValue(String value)
- {
+ public static WindowStates fromValue(String value) {
return (WindowStates)_table_.get(value);
}
@@ -68,28 +65,23 @@
* @return The WSRP <code>WindowStates</code> represented by the passed
* string
*/
- public static WindowStates fromString(String value)
- {
+ public static WindowStates fromString(String value) {
return fromValue(value);
}
- public boolean equals(java.lang.Object obj)
- {
+ public boolean equals(java.lang.Object obj) {
return (obj == this);
}
- public int hashCode()
- {
+ public int hashCode() {
return toString().hashCode();
}
- public String toString()
- {
+ public String toString() {
return _value_;
}
- public java.lang.Object readResolve() throws java.io.ObjectStreamException
- {
+ public java.lang.Object readResolve() throws java.io.ObjectStreamException {
return fromValue(_value_);
}
@@ -100,22 +92,16 @@
* directly the normal state is returned.
*
* @return The <code>javax.portlet.WindowState</code> which corresponds
- * to the given wsrp state.
- **/
- public static WindowState getJsrPortletStateFromWsrpState(
- WindowStates wsrpState)
- {
- if (wsrpState == null)
- {
+ * to the given wsrp state.
+ */
+ public static WindowState getJsrPortletStateFromWsrpState(WindowStates wsrpState) {
+ if (wsrpState == null) {
return WindowState.NORMAL;
- } else if(wsrpState.equals(WindowStates.maximized))
- {
+ } else if(wsrpState.equals(WindowStates.maximized)) {
return WindowState.MAXIMIZED;
- } else if(wsrpState.equals(WindowStates.minimized))
- {
+ } else if(wsrpState.equals(WindowStates.minimized)) {
return WindowState.MINIMIZED;
- } else if(wsrpState.equals(WindowStates.normal))
- {
+ } else if(wsrpState.equals(WindowStates.normal)) {
return WindowState.NORMAL;
}
@@ -131,25 +117,19 @@
* should be resolved as portlet window state defined in wsrp.
* @return
**/
- public static WindowStates getWsrpStateFromJsrPortletState(
- WindowState portletState)
- {
- if(portletState.equals(WindowState.MAXIMIZED))
- {
+ public static WindowStates getWsrpStateFromJsrPortletState(WindowState portletState) {
+ if(portletState.equals(WindowState.MAXIMIZED)) {
return WindowStates.maximized;
- } else if(portletState.equals(WindowState.MINIMIZED))
- {
+ } else if(portletState.equals(WindowState.MINIMIZED)) {
return WindowStates.minimized;
- } else if(portletState.equals(WindowState.NORMAL))
- {
+ } else if(portletState.equals(WindowState.NORMAL)) {
return WindowStates.normal;
}
return WindowStates.normal;
}
- public static String[] getWindowStatesAsStringArray()
- {
+ public static String[] getWindowStatesAsStringArray() {
return (String[])_table_.keySet().toArray();
}
}
Modified: portals/wsrp4j/trunk/sandbox/wsrp4j/consumer-swingconsumer/src/java/org/apache/wsrp4j/consumer/swingconsumer/driver/AggregationImpl.java
URL: http://svn.apache.org/viewcvs/portals/wsrp4j/trunk/sandbox/wsrp4j/consumer-swingconsumer/src/java/org/apache/wsrp4j/consumer/swingconsumer/driver/AggregationImpl.java?rev=374677&r1=374676&r2=374677&view=diff
==============================================================================
--- portals/wsrp4j/trunk/sandbox/wsrp4j/consumer-swingconsumer/src/java/org/apache/wsrp4j/consumer/swingconsumer/driver/AggregationImpl.java (original)
+++ portals/wsrp4j/trunk/sandbox/wsrp4j/consumer-swingconsumer/src/java/org/apache/wsrp4j/consumer/swingconsumer/driver/AggregationImpl.java Fri Feb 3 06:28:31 2006
@@ -33,401 +33,354 @@
import org.apache.wsrp4j.commons.util.Modes;
import org.apache.wsrp4j.commons.util.WindowStates;
-import org.apache.wsrp4j.commons.consumer.interfaces.consumer.
- ConsumerEnvironment;
+import org.apache.wsrp4j.commons.consumer.interfaces.consumer.ConsumerEnvironment;
import org.apache.wsrp4j.commons.consumer.interfaces.page.Page;
import org.apache.wsrp4j.commons.consumer.interfaces.portlet.PortletKey;
import org.apache.wsrp4j.commons.consumer.interfaces.portlet.WSRPPortlet;
-import org.apache.wsrp4j.commons.consumer.interfaces.portletdriver.
- PortletDriver;
+import org.apache.wsrp4j.commons.consumer.interfaces.portletdriver.PortletDriver;
import org.apache.wsrp4j.commons.consumer.interfaces.producer.Producer;
import org.apache.wsrp4j.commons.consumer.interfaces.urlgenerator.URLGenerator;
import org.apache.wsrp4j.consumer.swingconsumer.interfaces.Aggregation;
import org.apache.wsrp4j.consumer.swingconsumer.interfaces.Request;
-import org.apache.wsrp4j.consumer.swingconsumer.interfaces.
- SimplePortletWindowSession;
-
+import org.apache.wsrp4j.consumer.swingconsumer.interfaces.SimplePortletWindowSession;
/**
- * Implementation of an aggregation for the swing consumer.
- * The aggregation is used to display the
- * markup of remote portlets aggregated on a page.
- * It also adds the markup for the portlets decoration.
- *
+ * Implementation of an aggregation for the swing consumer. The aggregation is
+ * used to display the markup of remote portlets aggregated on a page. It also
+ * adds the markup for the portlets decoration.
+ *
* @version $Id$
*/
public class AggregationImpl implements Aggregation {
-
+
private ConsumerEnvironment consumerEnv;
-
+
private SwingConsumer consumer;
-
+
// instance key of the entity which is in maximized window state
private String maxPortletInstanceKey;
-
+
// log and trace support
- private Logger logger =
- LogManager.getLogManager().getLogger(this.getClass());
-
+ private Logger logger = LogManager.getLogManager().getLogger(this.getClass());
+
/**
- * Construct a new <code>AggregationImpl</code> object by providing
- * a reference to the consumer environment object, whcih is used to
- * access all consumer side registries and handlers.
- **/
- public AggregationImpl(ConsumerEnvironment consumerEnv,
- SwingConsumer consumer) {
-
+ * Construct a new <code>AggregationImpl</code> object by providing a
+ * reference to the consumer environment object, whcih is used to access all
+ * consumer side registries and handlers.
+ */
+ public AggregationImpl(ConsumerEnvironment consumerEnv, SwingConsumer consumer) {
+
this.consumerEnv = consumerEnv;
this.consumer = consumer;
}
-
+
/**
* Render a page and return the generated markup.
- *
- * @param page The page object which should be rendered
- * @param request Request object
- *
+ *
+ * @param page
+ * The page object which should be rendered
+ * @param request
+ * Request object
+ *
* @return The markup of the page.
- **/
+ */
public String renderPage(Page page, Request request) {
-
+
String MN = "renderPage";
if (logger.isLogging(Logger.TRACE_HIGH)) {
logger.entry(Logger.TRACE_HIGH, MN);
}
-
+
try {
StringBuffer pageMarkup = new StringBuffer();
PortletKey portletKey = null;
WSRPPortlet portlet = null;
SimplePortletWindowSession windowSession = null;
String content = "";
-
+
maxPortletInstanceKey = page.getMaximizedPortletInstanceKey();
-
+
if (maxPortletInstanceKey != null) {
-
+
pageMarkup.append("<table width='100%'>");
-
+
} else {
-
+
pageMarkup.append("<table>");
-
+
}
-
+
if (maxPortletInstanceKey == null) {
-
+
Iterator portletInstanceKeys = page.getPortletInstanceKeys();
for (int i = 0; portletInstanceKeys.hasNext(); i++) {
-
- String portletInstanceKey =
- (String) portletInstanceKeys.next();
-
- System.out.println("Portletinstance key " +
- portletInstanceKey);
-
+
+ String portletInstanceKey = (String) portletInstanceKeys.next();
+
+ System.out.println("Portletinstance key " + portletInstanceKey);
+
portletKey = page.getPortletKey(portletInstanceKey);
-
+
if (portletKey == null) {
System.out.println("Portletkey on page is null");
}
-
- portlet = consumerEnv.getPortletRegistry().
- getPortlet(portletKey);
-
+
+ portlet = consumerEnv.getPortletRegistry().getPortlet(portletKey);
+
try {
- windowSession = consumer.getSimplePortletWindowSession(
- portlet, portletInstanceKey);
+ windowSession = consumer.getSimplePortletWindowSession(portlet,
+ portletInstanceKey);
content = getMarkup(portlet, windowSession, request);
} catch (WSRPException e) {
content = e.toHTMLString();
}
-
+
if (((i % 2) == 0) && (portletInstanceKeys.hasNext())) {
-
+
pageMarkup.append(" <tr>");
pageMarkup.append(" <td valign='top'>");
- pageMarkup.append("<table><tr><td>" + content +
- "</td></tr></table>");
+ pageMarkup.append("<table><tr><td>" + content + "</td></tr></table>");
pageMarkup.append(" </td>");
} else if ((i % 2) == 1) {
pageMarkup.append(" <td valign='top'>");
- pageMarkup.append("<table><tr><td>" + content +
- "</td></tr></table>");
+ pageMarkup.append("<table><tr><td>" + content + "</td></tr></table>");
pageMarkup.append(" </td>");
pageMarkup.append(" </tr>");
} else {
pageMarkup.append(" <tr>");
pageMarkup.append(" <td valign='top'>");
- pageMarkup.append("<table><tr><td>" + content +
- "</td></tr></table>");
+ pageMarkup.append("<table><tr><td>" + content + "</td></tr></table>");
pageMarkup.append(" </td>");
pageMarkup.append(" </tr>");
}
}
} else {
portletKey = page.getPortletKey(maxPortletInstanceKey);
-
- portlet = consumerEnv.getPortletRegistry().
- getPortlet(portletKey);
-
+
+ portlet = consumerEnv.getPortletRegistry().getPortlet(portletKey);
+
try {
- windowSession = consumer.getSimplePortletWindowSession(
- portlet, maxPortletInstanceKey);
+ windowSession = consumer.getSimplePortletWindowSession(portlet,
+ maxPortletInstanceKey);
content = getMarkup(portlet, windowSession, request);
} catch (WSRPException e) {
content = e.toHTMLString();
}
-
+
pageMarkup.append(" <tr>");
pageMarkup.append(" <td>");
- pageMarkup.append("<table width='100%'><tr><td>" +
- content + "</td></tr></table>");
+ pageMarkup.append("<table width='100%'><tr><td>" + content + "</td></tr></table>");
pageMarkup.append(" </td>");
pageMarkup.append(" </tr>");
}
-
+
pageMarkup.append("</table>");
-
+
if (logger.isLogging(Logger.TRACE_HIGH)) {
logger.exit(Logger.TRACE_HIGH, MN);
}
-
+
return pageMarkup.toString();
-
+
} catch (Exception ex) {
if (logger.isLogging(Logger.ERROR)) {
String message = "Rendering of page failed.";
logger.text(Logger.ERROR, MN, ex, message);
logger.exit(Logger.TRACE_HIGH, MN);
}
-
+
return ex.getMessage();
}
-
+
}
-
- private String addPortletFrame(String content, WSRPPortlet portlet,
+
+ private String addPortletFrame(String content, WSRPPortlet portlet,
SimplePortletWindowSession windowSession, String title) {
-
+
String MN = "addPortletFrame";
if (logger.isLogging(Logger.TRACE_HIGH)) {
logger.entry(Logger.TRACE_HIGH, MN);
}
-
+
String bgcolor = "0000bb";
if (portlet.isConsumerConfigured()) {
bgcolor = "0000ff";
}
-
+
StringBuffer markup = new StringBuffer();
-
+
if (maxPortletInstanceKey != null) {
-
+
markup.append("<table width='100%'>");
markup.append("<tr>");
-
+
} else {
-
+
markup.append("<table>");
markup.append("<tr>");
}
-
- markup.append(
- "<td bgcolor='#"
- + bgcolor
- + "'><font color='white'><b>"
- + title
- + " - "
- + portlet.getPortletKey()
- + "</font></b></td>");
- markup.append(
- "<td align='right' bgcolor='#"
- + bgcolor
- + "'><font color='white'>"
- + getView(portlet, windowSession)
- + getEdit(portlet, windowSession)
- + getHelp(portlet, windowSession)
- + getPreview(portlet, windowSession)
- + getMinimize(portlet, windowSession)
- + getNormalize(portlet, windowSession)
- + getMaximize(portlet, windowSession)
- + getSolo(portlet, windowSession)
+
+ markup.append("<td bgcolor='#" + bgcolor + "'><font color='white'><b>" + title + " - "
+ + portlet.getPortletKey() + "</font></b></td>");
+ markup.append("<td align='right' bgcolor='#" + bgcolor + "'><font color='white'>"
+ + getView(portlet, windowSession) + getEdit(portlet, windowSession)
+ + getHelp(portlet, windowSession) + getPreview(portlet, windowSession)
+ + getMinimize(portlet, windowSession) + getNormalize(portlet, windowSession)
+ + getMaximize(portlet, windowSession) + getSolo(portlet, windowSession)
+ "</font></td>");
markup.append("</tr>");
markup.append("<tr>");
markup.append("<td colspan='2'>" + content + "</td>");
markup.append("</tr><tr>");
- markup.append(
- "<td bgcolor='#"
- + bgcolor
- + "'><font color='white'><i>"
- + getCloneLink(windowSession.getWindowID())
- + "</i></font></td>");
- markup.append(
- "<td align='right' bgcolor='#"
- + bgcolor
- + "'><font color='white'><i>"
- + getViewPropertyLink(windowSession.getWindowID())
- + "</i></font></td>");
+ markup.append("<td bgcolor='#" + bgcolor + "'><font color='white'><i>"
+ + getCloneLink(windowSession.getWindowID()) + "</i></font></td>");
+ markup.append("<td align='right' bgcolor='#" + bgcolor + "'><font color='white'><i>"
+ + getViewPropertyLink(windowSession.getWindowID()) + "</i></font></td>");
markup.append("</tr></table>");
-
- System.out.println(
- "[INFO] Markup of portlet :" +
- portlet.getPortletContext().getPortletHandle() +
- "\n" + markup.toString());
-
+
+ System.out.println("[INFO] Markup of portlet :"
+ + portlet.getPortletContext().getPortletHandle() + "\n" + markup.toString());
+
if (logger.isLogging(Logger.TRACE_HIGH)) {
logger.exit(Logger.TRACE_HIGH, MN);
}
return markup.toString();
}
-
+
/**
- * Get the title of an portlet instance depending on the window state from
+ * Get the title of an portlet instance depending on the window state from
* the portlet description.
- **/
- private String getPortletTitle(WSRPPortlet portlet,
- SimplePortletWindowSession windowSession) {
-
+ */
+ private String getPortletTitle(WSRPPortlet portlet, SimplePortletWindowSession windowSession) {
+
String MN = "getPortletTitle";
if (logger.isLogging(Logger.TRACE_HIGH)) {
logger.entry(Logger.TRACE_HIGH, MN);
}
-
+
String title = "";
-
+
try {
-
- Producer producer = consumerEnv.getProducerRegistry().
- getProducer(portlet.getPortletKey().getProducerId());
- PortletDescription portletDescription =
- producer.getPortletDescription(portlet.getParent());
-
+
+ Producer producer = consumerEnv.getProducerRegistry().getProducer(
+ portlet.getPortletKey().getProducerId());
+ PortletDescription portletDescription = producer.getPortletDescription(portlet
+ .getParent());
+
if (portletDescription != null) {
-
+
LocalizedString locTitle = null;
- if (windowSession.getWindowState().equalsIgnoreCase(
- WindowStates._minimized)) {
-
+ if (windowSession.getWindowState().equalsIgnoreCase(WindowStates._minimized)) {
+
locTitle = portletDescription.getShortTitle();
-
+
}
-
+
if (locTitle == null) {
locTitle = portletDescription.getTitle();
}
-
+
if (locTitle != null) {
title = locTitle.getValue();
}
-
+
}
-
+
} catch (WSRPException e) {
-
+
title = "No title available!";
-
+
}
-
+
if (logger.isLogging(Logger.TRACE_HIGH)) {
logger.exit(Logger.TRACE_HIGH, MN);
}
-
+
return title;
}
-
+
/**
* Get a html link to clone an portlet
- **/
+ */
private String getCloneLink(String portletInstanceKey) {
- return "<a href='"
- + Constants.PORTLET_INSTANCE_KEY
- + Constants.EQUALS
- + portletInstanceKey
- + Constants.NEXT_PARAM
- + SwingConsumer.CLONE_PORTLET
- + "'>Clone</a>";
+ return "<a href='" + Constants.PORTLET_INSTANCE_KEY + Constants.EQUALS + portletInstanceKey
+ + Constants.NEXT_PARAM + SwingConsumer.CLONE_PORTLET + "'>Clone</a>";
}
-
+
/**
* Get a html link to activate the property window
- **/
+ */
private String getViewPropertyLink(String portletInstanceKey) {
- return "<a href='"
- + Constants.PORTLET_INSTANCE_KEY
- + Constants.EQUALS
- + portletInstanceKey
- + Constants.NEXT_PARAM
- + SwingConsumer.VIEW_PROP
- + "'>View Properties</a> ";
+ return "<a href='" + Constants.PORTLET_INSTANCE_KEY + Constants.EQUALS + portletInstanceKey
+ + Constants.NEXT_PARAM + SwingConsumer.VIEW_PROP + "'>View Properties</a> ";
}
-
+
/**
* Get a html link to switch the portlet in the portlet mode (md)
- *
- * @param name A descriptive name of the portlet mode. This name is
- * displayed in the link
- * @param md The new portlet mode
- * @param portlet The portlet
- * @param windowSession The session of the portlet
- *
- * @return A html link which should switch the portlet in a new portlet
- * mode on activation.
- **/
- private String getModeLink(String name, String md, WSRPPortlet portlet,
+ *
+ * @param name
+ * A descriptive name of the portlet mode. This name is displayed
+ * in the link
+ * @param md
+ * The new portlet mode
+ * @param portlet
+ * The portlet
+ * @param windowSession
+ * The session of the portlet
+ *
+ * @return A html link which should switch the portlet in a new portlet mode
+ * on activation.
+ */
+ private String getModeLink(String name, String md, WSRPPortlet portlet,
SimplePortletWindowSession windowSession) {
-
+
String MN = "getModeLink";
if (logger.isLogging(Logger.TRACE_HIGH)) {
logger.entry(Logger.TRACE_HIGH, MN);
}
-
+
// if the portlet is already in this mode, do nothing
if (windowSession.getMode().equalsIgnoreCase(md)) {
return "";
}
-
+
MarkupType[] markupTypes = null;
-
+
try {
-
- Producer producer = consumerEnv.getProducerRegistry().
- getProducer(portlet.getPortletKey().getProducerId());
- PortletDescription desc =
- producer.getPortletDescription(portlet.getParent());
-
+
+ Producer producer = consumerEnv.getProducerRegistry().getProducer(
+ portlet.getPortletKey().getProducerId());
+ PortletDescription desc = producer.getPortletDescription(portlet.getParent());
+
if (desc != null) {
-
- markupTypes = producer.getPortletDescription(
- portlet.getParent()).getMarkupTypes();
-
+
+ markupTypes = producer.getPortletDescription(portlet.getParent()).getMarkupTypes();
+
} else {
-
+
markupTypes = new MarkupType[1];
markupTypes[0].setMimeType(Constants.MIME_TYPE_HTML);
-
+
}
-
+
} catch (WSRPException e) {
-
+
if (logger.isLogging(Logger.TRACE_HIGH)) {
logger.exit(Logger.TRACE_HIGH, MN);
}
-
+
return "";
}
-
+
String portletInstanceKey = windowSession.getWindowID();
-
+
for (int i = 0; i < markupTypes.length; i++) {
- //hello world is not setting mime type, so this is null,
+ // hello world is not setting mime type, so this is null,
// default to HTML
boolean doHTML = false;
if (markupTypes[i].getMimeType() != null) {
- if (markupTypes[i].getMimeType().equalsIgnoreCase(
- Constants.MIME_TYPE_HTML)) {
+ if (markupTypes[i].getMimeType().equalsIgnoreCase(Constants.MIME_TYPE_HTML)) {
doHTML = true;
}
} else {
@@ -435,300 +388,270 @@
}
if (doHTML) {
String[] modes = markupTypes[i].getModes();
-
+
// check if the new mode is supported by the portlet
for (int j = 0; j < modes.length; j++) {
-
+
if (modes[j].equalsIgnoreCase(md)) {
-
+
if (logger.isLogging(Logger.TRACE_HIGH)) {
logger.exit(Logger.TRACE_HIGH, MN);
}
-
- return "<a href='"
- + Constants.PORTLET_INSTANCE_KEY
- + Constants.EQUALS
- + portletInstanceKey
- + Constants.NEXT_PARAM
- + SwingConsumer.CHANGE_MODE
- + Constants.EQUALS
- + md
- + "'>"
- + name
+
+ return "<a href='" + Constants.PORTLET_INSTANCE_KEY + Constants.EQUALS
+ + portletInstanceKey + Constants.NEXT_PARAM
+ + SwingConsumer.CHANGE_MODE + Constants.EQUALS + md + "'>" + name
+ "</a> ";
}
}
-
+
} else {
-
+
// TODO: Support other markupTypes
-
+
}
-
+
}
-
+
if (logger.isLogging(Logger.TRACE_HIGH)) {
logger.exit(Logger.TRACE_HIGH, MN);
}
-
+
return "";
}
-
- private String getView(WSRPPortlet portlet,
- SimplePortletWindowSession session) {
-
+
+ private String getView(WSRPPortlet portlet, SimplePortletWindowSession session) {
+
return getModeLink("View", Modes._view, portlet, session);
}
-
- private String getEdit(WSRPPortlet portlet,
- SimplePortletWindowSession session) {
-
+
+ private String getEdit(WSRPPortlet portlet, SimplePortletWindowSession session) {
+
return getModeLink("Edit", Modes._edit, portlet, session);
}
-
- private String getHelp(WSRPPortlet portlet,
- SimplePortletWindowSession session) {
-
+
+ private String getHelp(WSRPPortlet portlet, SimplePortletWindowSession session) {
+
return getModeLink("Help", Modes._help, portlet, session);
}
-
- private String getPreview(WSRPPortlet portlet,
- SimplePortletWindowSession session) {
-
+
+ private String getPreview(WSRPPortlet portlet, SimplePortletWindowSession session) {
+
return getModeLink("Preview", Modes._preview, portlet, session);
}
-
+
/**
* Get a html link to switch the portlet in the window state (st)
- *
- * @param name A descriptive name of the window state. This name is
- * displayed in the link
- * @param st The new window state
- * @param portlet The portlet
- * @param windowSession The session of the portlet
- *
- * @return A html link which should switch the portlet in a new window
- * state on activation.
- **/
- private String getStateLink(String name, String st, WSRPPortlet portlet,
+ *
+ * @param name
+ * A descriptive name of the window state. This name is displayed
+ * in the link
+ * @param st
+ * The new window state
+ * @param portlet
+ * The portlet
+ * @param windowSession
+ * The session of the portlet
+ *
+ * @return A html link which should switch the portlet in a new window state
+ * on activation.
+ */
+ private String getStateLink(String name, String st, WSRPPortlet portlet,
SimplePortletWindowSession windowSession) {
-
+
String MN = "getStateLink";
if (logger.isLogging(Logger.TRACE_HIGH)) {
logger.entry(Logger.TRACE_HIGH, MN);
}
-
+
// if the portlet is already in this windows state do nothing
if (windowSession.getWindowState().equalsIgnoreCase(st)) {
if (logger.isLogging(Logger.TRACE_HIGH)) {
logger.exit(Logger.TRACE_HIGH, MN);
}
-
+
return "";
}
-
+
MarkupType[] markupTypes = null;
-
+
try {
-
- Producer producer = consumerEnv.getProducerRegistry().
- getProducer(portlet.getPortletKey().getProducerId());
- PortletDescription desc =
- producer.getPortletDescription(portlet.getParent());
-
+
+ Producer producer = consumerEnv.getProducerRegistry().getProducer(
+ portlet.getPortletKey().getProducerId());
+ PortletDescription desc = producer.getPortletDescription(portlet.getParent());
+
if (desc != null) {
-
- markupTypes = producer.getPortletDescription(
- portlet.getParent()).getMarkupTypes();
-
+
+ markupTypes = producer.getPortletDescription(portlet.getParent()).getMarkupTypes();
+
} else {
-
+
markupTypes = new MarkupType[1];
markupTypes[0].setMimeType(Constants.MIME_TYPE_HTML);
-
+
}
-
+
} catch (WSRPException e) {
// TODO
return "";
}
-
+
String portletInstanceKey = windowSession.getWindowID();
-
+
for (int i = 0; i < markupTypes.length; i++) {
-
+
boolean doHTML = false;
if (markupTypes[i].getMimeType() != null) {
- if (markupTypes[i].getMimeType().equalsIgnoreCase(
- Constants.MIME_TYPE_HTML)) {
+ if (markupTypes[i].getMimeType().equalsIgnoreCase(Constants.MIME_TYPE_HTML)) {
doHTML = true;
}
} else {
doHTML = true;
}
if (doHTML) {
-
+
String[] windowStates = markupTypes[i].getWindowStates();
-
+
// check if the new window state is supported by the portlet
for (int j = 0; j < windowStates.length; j++) {
-
+
if (windowStates[j].equalsIgnoreCase(st)) {
if (logger.isLogging(Logger.TRACE_HIGH)) {
logger.exit(Logger.TRACE_HIGH, MN);
}
-
- return "<a href='"
- + Constants.PORTLET_INSTANCE_KEY
- + Constants.EQUALS
- + portletInstanceKey
- + Constants.NEXT_PARAM
- + SwingConsumer.CHANGE_STATE
- + Constants.EQUALS
- + st
- + "'>"
- + name
+
+ return "<a href='" + Constants.PORTLET_INSTANCE_KEY + Constants.EQUALS
+ + portletInstanceKey + Constants.NEXT_PARAM
+ + SwingConsumer.CHANGE_STATE + Constants.EQUALS + st + "'>" + name
+ "</a> ";
}
-
+
}
} else {
-
+
// TODO: support other markup types
-
+
}
}
-
+
if (logger.isLogging(Logger.TRACE_HIGH)) {
logger.exit(Logger.TRACE_HIGH, MN);
}
-
+
return "";
}
-
- private String getSolo(WSRPPortlet portlet,
- SimplePortletWindowSession session) {
-
+
+ private String getSolo(WSRPPortlet portlet, SimplePortletWindowSession session) {
+
return getStateLink("Solo", WindowStates._solo, portlet, session);
}
-
- private String getMinimize(WSRPPortlet portlet,
- SimplePortletWindowSession session) {
-
+
+ private String getMinimize(WSRPPortlet portlet, SimplePortletWindowSession session) {
+
return getStateLink("Min", WindowStates._minimized, portlet, session);
}
-
- private String getNormalize(WSRPPortlet portlet,
- SimplePortletWindowSession session) {
-
+
+ private String getNormalize(WSRPPortlet portlet, SimplePortletWindowSession session) {
+
return getStateLink("Norm", WindowStates._normal, portlet, session);
}
-
- private String getMaximize(WSRPPortlet portlet,
- SimplePortletWindowSession session) {
-
+
+ private String getMaximize(WSRPPortlet portlet, SimplePortletWindowSession session) {
+
return getStateLink("Max", WindowStates._maximized, portlet, session);
}
-
+
/**
* Retrieve the markup generated by the portlet
- **/
- private String getMarkup(
- WSRPPortlet portlet,
- SimplePortletWindowSession windowSession,
+ */
+ private String getMarkup(WSRPPortlet portlet, SimplePortletWindowSession windowSession,
Request request) {
String MN = "getMarkup";
if (logger.isLogging(Logger.TRACE_HIGH)) {
logger.entry(Logger.TRACE_HIGH, MN);
}
-
+
// markup returned of the remote portlet
- String markup = "Error occurred! <br>No response from the remote " +
- "portlet:" + portlet.getPortletKey().toString();
-
+ String markup = "Error occurred! <br>No response from the remote " + "portlet:"
+ + portlet.getPortletKey().toString();
+
// The complete markup including the portlet frame
String content = null;
-
+
// The title of the portlet
String title = "No title available!";
-
+
try {
- WSRPRequestImpl wsrpRequest =
- new WSRPRequestImpl(windowSession, request, consumerEnv);
-
+ WSRPRequestImpl wsrpRequest = new WSRPRequestImpl(windowSession, request, consumerEnv);
+
Map addParams = new HashMap();
- addParams.put(Constants.PORTLET_INSTANCE_KEY,
- windowSession.getWindowID());
-
- URLGenerator urlGenerator =
- URLGeneratorImpl.getInstance(consumer.getConsumerURL(),
+ addParams.put(Constants.PORTLET_INSTANCE_KEY, windowSession.getWindowID());
+
+ URLGenerator urlGenerator = URLGeneratorImpl.getInstance(consumer.getConsumerURL(),
addParams);
consumerEnv.getTemplateComposer().setURLGenerator(urlGenerator);
consumerEnv.getURLRewriter().setURLGenerator(urlGenerator);
-
- PortletDriver portletDriver =
- portletDriver = consumerEnv.getPortletDriverRegistry().
- getPortletDriver(portlet);
- MarkupResponse response =
- portletDriver.getMarkup(wsrpRequest,
- consumer.getCurrentUserID());
-
+
+ PortletDriver portletDriver = portletDriver = consumerEnv.getPortletDriverRegistry()
+ .getPortletDriver(portlet);
+ MarkupResponse response = portletDriver.getMarkup(wsrpRequest, consumer
+ .getCurrentUserID());
+
if (response != null) {
SessionContext sessionContext = response.getSessionContext();
if (sessionContext != null && windowSession != null) {
- windowSession.getPortletSession().
- setSessionContext(sessionContext);
+ windowSession.getPortletSession().setSessionContext(sessionContext);
}
-
+
MarkupContext markupContext = response.getMarkupContext();
if (markupContext != null) {
-
+
// by default return an empty markup string
markup = "";
-
+
if (markupContext.getMarkupString() != null) {
markup = markupContext.getMarkupString();
} else if (markupContext.getMarkupBinary() != null) {
// markup binary should be provided base64 encoded
- if (markupContext.getMimeType().equalsIgnoreCase(
- Constants.MIME_TYPE_HTML)) {
-
+ if (markupContext.getMimeType().equalsIgnoreCase(Constants.MIME_TYPE_HTML)) {
+
// Swing Consumer only supportes text/html
- // byte[] decoded =
- // Base64.decode(markupContext.getMarkupBinary());
+ // byte[] decoded =
+ // Base64.decode(markupContext.getMarkupBinary());
// markup = new String(decoded, Constants.UTF_8);
}
}
-
+
// by default deliver an empty markup string
- // this can occur when markupString and markupBinary were
+ // this can occur when markupString and markupBinary were
// null
-
+
title = markupContext.getPreferredTitle();
if (title == null || title.length() == 0) {
-
+
title = getPortletTitle(portlet, windowSession);
}
-
+
}
}
-
+
} catch (WSRPException e) {
-
+
markup = e.toString();
-
+
}
-
+
// add a frame around the portlet
content = addPortletFrame(markup, portlet, windowSession, title);
-
+
windowSession.updateMarkupCache(null);
-
+
if (logger.isLogging(Logger.TRACE_HIGH)) {
logger.exit(Logger.TRACE_HIGH, MN);
}
-
+
return content;
}
-
+
}
Modified: portals/wsrp4j/trunk/sandbox/wsrp4j/consumer/src/java/org/apache/wsrp4j/consumer/proxyportlet/impl/ConsumerEnvironmentImpl.java
URL: http://svn.apache.org/viewcvs/portals/wsrp4j/trunk/sandbox/wsrp4j/consumer/src/java/org/apache/wsrp4j/consumer/proxyportlet/impl/ConsumerEnvironmentImpl.java?rev=374677&r1=374676&r2=374677&view=diff
==============================================================================
--- portals/wsrp4j/trunk/sandbox/wsrp4j/consumer/src/java/org/apache/wsrp4j/consumer/proxyportlet/impl/ConsumerEnvironmentImpl.java (original)
+++ portals/wsrp4j/trunk/sandbox/wsrp4j/consumer/src/java/org/apache/wsrp4j/consumer/proxyportlet/impl/ConsumerEnvironmentImpl.java Fri Feb 3 06:28:31 2006
@@ -27,20 +27,18 @@
import org.apache.wsrp4j.commons.util.WindowStates;
/**
- * Class implements the consumer environment interface for the
- * proxy portlet consumer.
+ * Class implements the consumer environment interface for the proxy portlet
+ * consumer.
*
* @version $Id$
*/
-public class ConsumerEnvironmentImpl extends GenericConsumerEnvironment
-{
+public class ConsumerEnvironmentImpl extends GenericConsumerEnvironment {
private static String CONSUMER_AGENT = "WSRP4J proxy portlet consumer v0.1";
- private String registryPath = null;
+ private String registryPath;
- public ConsumerEnvironmentImpl()
- {
+ public ConsumerEnvironmentImpl() {
// set the name of the consumer agent
setConsumerAgent(CONSUMER_AGENT);
@@ -68,10 +66,10 @@
// define portlet state change behaviour
setPortletStateChange(StateChange.readWrite);
- // define the mime types the consumer supports
+ // define the mime types the consumer supports
setMimeTypes(new String[] { Constants.MIME_TYPE_HTML });
- // define the character sets the consumer supports
+ // define the character sets the consumer supports
setCharacterEncodingSet(new String[] { Constants.UTF_8 });
// set the authentication method the consumer uses
@@ -80,22 +78,19 @@
// set consumer components
setUserRegistry(UserRegistryImpl.getInstance());
setSessionHandler(SessionHandlerImpl.getInstance(this));
- //setProducerRegistry(ProducerRegistryImpl.getInstance());
+ // setProducerRegistry(ProducerRegistryImpl.getInstance());
setPortletRegistry(PortletRegistryImpl.getInstance());
setTemplateComposer(URLTemplateComposerImpl.getInstance());
setURLRewriter(URLRewriterImpl.getInstance());
setPortletDriverRegistry(PortletDriverRegistryImpl.getInstance(this));
}
- public void setRegistryPath(String path)
- {
+ public void setRegistryPath(String path) {
this.registryPath = path;
}
- public ProducerRegistry getProducerRegistry()
- {
- if (super.getProducerRegistry() == null)
- {
+ public ProducerRegistry getProducerRegistry() {
+ if (super.getProducerRegistry() == null) {
setProducerRegistry(ProducerRegistryImpl.getInstance(registryPath));
}
Modified: portals/wsrp4j/trunk/sandbox/wsrp4j/consumer/src/java/org/apache/wsrp4j/consumer/proxyportlet/impl/GroupSessionImpl.java
URL: http://svn.apache.org/viewcvs/portals/wsrp4j/trunk/sandbox/wsrp4j/consumer/src/java/org/apache/wsrp4j/consumer/proxyportlet/impl/GroupSessionImpl.java?rev=374677&r1=374676&r2=374677&view=diff
==============================================================================
--- portals/wsrp4j/trunk/sandbox/wsrp4j/consumer/src/java/org/apache/wsrp4j/consumer/proxyportlet/impl/GroupSessionImpl.java (original)
+++ portals/wsrp4j/trunk/sandbox/wsrp4j/consumer/src/java/org/apache/wsrp4j/consumer/proxyportlet/impl/GroupSessionImpl.java Fri Feb 3 06:28:31 2006
@@ -22,24 +22,18 @@
/**
* @version $Id$
*/
-public class GroupSessionImpl extends GenericGroupSessionImpl
-{
+public class GroupSessionImpl extends GenericGroupSessionImpl {
- public GroupSessionImpl(String groupID, String portletServicesURL)
- throws WSRPException
- {
+ public GroupSessionImpl(String groupID, String portletServicesURL) throws WSRPException {
super(groupID, portletServicesURL);
}
- public PortletSession getPortletSession(String portletHandle)
- {
+ public PortletSession getPortletSession(String portletHandle) {
if (portletHandle == null)
return null;
- PortletSession portletSession =
- (PortletSession)this.portletSessions.get(portletHandle);
- if (portletSession == null)
- {
+ PortletSession portletSession = (PortletSession) this.portletSessions.get(portletHandle);
+ if (portletSession == null) {
portletSession = new PortletSessionImpl(portletHandle);
addPortletSession(portletSession);
}
Modified: portals/wsrp4j/trunk/sandbox/wsrp4j/consumer/src/java/org/apache/wsrp4j/consumer/proxyportlet/impl/PortletRegistryImpl.java
URL: http://svn.apache.org/viewcvs/portals/wsrp4j/trunk/sandbox/wsrp4j/consumer/src/java/org/apache/wsrp4j/consumer/proxyportlet/impl/PortletRegistryImpl.java?rev=374677&r1=374676&r2=374677&view=diff
==============================================================================
--- portals/wsrp4j/trunk/sandbox/wsrp4j/consumer/src/java/org/apache/wsrp4j/consumer/proxyportlet/impl/PortletRegistryImpl.java (original)
+++ portals/wsrp4j/trunk/sandbox/wsrp4j/consumer/src/java/org/apache/wsrp4j/consumer/proxyportlet/impl/PortletRegistryImpl.java Fri Feb 3 06:28:31 2006
@@ -21,20 +21,16 @@
/**
* @version $Id$
*/
-public class PortletRegistryImpl extends GenericPortletRegistryImpl
-{
+public class PortletRegistryImpl extends GenericPortletRegistryImpl {
private static PortletRegistry instance;
- private PortletRegistryImpl()
- {
+ private PortletRegistryImpl() {
super();
}
- public static PortletRegistry getInstance()
- {
- if (instance == null)
- {
+ public static PortletRegistry getInstance() {
+ if (instance == null) {
instance = new PortletRegistryImpl();
}
Modified: portals/wsrp4j/trunk/sandbox/wsrp4j/consumer/src/java/org/apache/wsrp4j/consumer/proxyportlet/impl/PortletSessionImpl.java
URL: http://svn.apache.org/viewcvs/portals/wsrp4j/trunk/sandbox/wsrp4j/consumer/src/java/org/apache/wsrp4j/consumer/proxyportlet/impl/PortletSessionImpl.java?rev=374677&r1=374676&r2=374677&view=diff
==============================================================================
--- portals/wsrp4j/trunk/sandbox/wsrp4j/consumer/src/java/org/apache/wsrp4j/consumer/proxyportlet/impl/PortletSessionImpl.java (original)
+++ portals/wsrp4j/trunk/sandbox/wsrp4j/consumer/src/java/org/apache/wsrp4j/consumer/proxyportlet/impl/PortletSessionImpl.java Fri Feb 3 06:28:31 2006
@@ -25,52 +25,44 @@
/**
* @version $Id$
*/
-public class PortletSessionImpl extends GenericPortletSessionImpl
-{
-
- // logger
- private static final Logger logger =
- LogManager.getLogManager().getLogger(PortletSessionImpl.class);
-
- public PortletSessionImpl(String handle)
- {
- super(handle);
+public class PortletSessionImpl extends GenericPortletSessionImpl {
+
+ // logger
+ private static final Logger logger = LogManager.getLogManager().getLogger(
+ PortletSessionImpl.class);
+
+ public PortletSessionImpl(String handle) {
+ super(handle);
}
/**
- * Get the <code>PortletWindowSession</code> of the portlet window with
+ * Get the <code>PortletWindowSession</code> of the portlet window with
* the given ID.
*
- * @param windowID The ID of the portlet window
- * @return The <code>PorletWindowSession</code> with the given ID.
- **/
- public PortletWindowSession getPortletWindowSession(String windowID)
- {
- final String MN ="getPortletWindowSession";
-
- if (logger.isLogging(Logger.TRACE_HIGH))
- {
- logger.entry(Logger.TRACE_HIGH, MN);
- }
-
- PortletWindowSession session =
- (PortletWindowSession)this.windowSessions.get(windowID);
- if (session == null)
- {
+ * @param windowID
+ * The ID of the portlet window
+ * @return The <code>PorletWindowSession</code> with the given ID.
+ */
+ public PortletWindowSession getPortletWindowSession(String windowID) {
+ final String MN = "getPortletWindowSession";
+
+ if (logger.isLogging(Logger.TRACE_HIGH)) {
+ logger.entry(Logger.TRACE_HIGH, MN);
+ }
+
+ PortletWindowSession session = (PortletWindowSession) this.windowSessions.get(windowID);
+ if (session == null) {
session = new GenericPortletWindowSessionImpl(windowID, this);
this.windowSessions.put(windowID, session);
-
- if (logger.isLogging(Logger.TRACE_HIGH))
- {
- logger.text(Logger.TRACE_HIGH, MN,
- "created windowSession with ID: " + windowID);
+
+ if (logger.isLogging(Logger.TRACE_HIGH)) {
+ logger.text(Logger.TRACE_HIGH, MN, "created windowSession with ID: " + windowID);
}
}
- if (logger.isLogging(Logger.TRACE_HIGH))
- {
- logger.exit(Logger.TRACE_HIGH, MN);
- }
+ if (logger.isLogging(Logger.TRACE_HIGH)) {
+ logger.exit(Logger.TRACE_HIGH, MN);
+ }
return session;
}
Modified: portals/wsrp4j/trunk/sandbox/wsrp4j/consumer/src/java/org/apache/wsrp4j/consumer/proxyportlet/impl/ProducerRegistryImpl.java
URL: http://svn.apache.org/viewcvs/portals/wsrp4j/trunk/sandbox/wsrp4j/consumer/src/java/org/apache/wsrp4j/consumer/proxyportlet/impl/ProducerRegistryImpl.java?rev=374677&r1=374676&r2=374677&view=diff
==============================================================================
--- portals/wsrp4j/trunk/sandbox/wsrp4j/consumer/src/java/org/apache/wsrp4j/consumer/proxyportlet/impl/ProducerRegistryImpl.java (original)
+++ portals/wsrp4j/trunk/sandbox/wsrp4j/consumer/src/java/org/apache/wsrp4j/consumer/proxyportlet/impl/ProducerRegistryImpl.java Fri Feb 3 06:28:31 2006
@@ -21,56 +21,47 @@
import org.apache.wsrp4j.commons.persistence.ClientPersistentFactory;
import org.apache.wsrp4j.commons.persistence.driver.PersistentAccess;
-
/**
* @version $Id$
*/
-public class ProducerRegistryImpl extends GenericPersistentProducerRegistryImpl
-{
+public class ProducerRegistryImpl extends GenericPersistentProducerRegistryImpl {
private static ProducerRegistry instance;
- private ProducerRegistryImpl(String path)
- {
+ private ProducerRegistryImpl(String path) {
super();
// restore producers from persistent file store
- try
- {
+ try {
- ClientPersistentFactory persistentFactory =
- PersistentAccess.getClientPersistentFactory();
-// ((ClientPersistentFactoryImpl)persistentFactory).setPath(path);
+ ClientPersistentFactory persistentFactory = PersistentAccess
+ .getClientPersistentFactory();
+ // ((ClientPersistentFactoryImpl)persistentFactory).setPath(path);
persistentHandler = persistentFactory.getPersistentHandler();
persistentDataObject = persistentFactory.getProducerList();
restore();
- } catch (Throwable t)
- {
+ } catch (Throwable t) {
t.printStackTrace();
- if (t instanceof WSRPException)
- {
+ if (t instanceof WSRPException) {
- //TODO: throw exception
- } else
- {
+ // TODO: throw exception
+ } else {
- //TODO: throw exception
+ // TODO: throw exception
}
}
}
/**
* Get an instance of the singleton producer registry object
- **/
- public static ProducerRegistry getInstance(String path)
- {
- if (instance == null)
- {
+ */
+ public static ProducerRegistry getInstance(String path) {
+ if (instance == null) {
instance = new ProducerRegistryImpl(path);
}
Modified: portals/wsrp4j/trunk/sandbox/wsrp4j/consumer/src/java/org/apache/wsrp4j/consumer/proxyportlet/impl/ProxyPortlet.java
URL: http://svn.apache.org/viewcvs/portals/wsrp4j/trunk/sandbox/wsrp4j/consumer/src/java/org/apache/wsrp4j/consumer/proxyportlet/impl/ProxyPortlet.java?rev=374677&r1=374676&r2=374677&view=diff
==============================================================================
--- portals/wsrp4j/trunk/sandbox/wsrp4j/consumer/src/java/org/apache/wsrp4j/consumer/proxyportlet/impl/ProxyPortlet.java (original)
+++ portals/wsrp4j/trunk/sandbox/wsrp4j/consumer/src/java/org/apache/wsrp4j/consumer/proxyportlet/impl/ProxyPortlet.java Fri Feb 3 06:28:31 2006
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.wsrp4j.consumer.proxyportlet.impl;
@@ -101,10 +100,10 @@
public class ProxyPortlet extends GenericPortlet {
// stores consumer specific information
- private ConsumerEnvironment consumerEnv = null;
+ private ConsumerEnvironment consumerEnv;
// used to validate producer responses
- private static ParameterChecker checker = null;
+ private static ParameterChecker checker;
// logger
private static final Logger logger =
Modified: portals/wsrp4j/trunk/sandbox/wsrp4j/consumer/src/java/org/apache/wsrp4j/consumer/proxyportlet/impl/SessionHandlerImpl.java
URL: http://svn.apache.org/viewcvs/portals/wsrp4j/trunk/sandbox/wsrp4j/consumer/src/java/org/apache/wsrp4j/consumer/proxyportlet/impl/SessionHandlerImpl.java?rev=374677&r1=374676&r2=374677&view=diff
==============================================================================
--- portals/wsrp4j/trunk/sandbox/wsrp4j/consumer/src/java/org/apache/wsrp4j/consumer/proxyportlet/impl/SessionHandlerImpl.java (original)
+++ portals/wsrp4j/trunk/sandbox/wsrp4j/consumer/src/java/org/apache/wsrp4j/consumer/proxyportlet/impl/SessionHandlerImpl.java Fri Feb 3 06:28:31 2006
@@ -26,60 +26,46 @@
/**
* @version $Id$
*/
-public class SessionHandlerImpl implements SessionHandler
-{
+public class SessionHandlerImpl implements SessionHandler {
private PortletSession portletSession;
+
private ConsumerEnvironment consumerEnv;
private static SessionHandler instance;
- private SessionHandlerImpl(ConsumerEnvironment consumerEnv)
- {
+ private SessionHandlerImpl(ConsumerEnvironment consumerEnv) {
this.consumerEnv = consumerEnv;
}
- public static SessionHandler getInstance(ConsumerEnvironment consumerEnv)
- {
- if (instance == null)
- {
+ public static SessionHandler getInstance(ConsumerEnvironment consumerEnv) {
+ if (instance == null) {
instance = new SessionHandlerImpl(consumerEnv);
}
return instance;
}
- public void setPortletSession(PortletSession portletSession)
- {
+ public void setPortletSession(PortletSession portletSession) {
this.portletSession = portletSession;
}
- public UserSessionMgr getUserSession(String producerID, String userID)
- throws WSRPException
- {
- if (portletSession == null)
- {
- try
- {
- throw new Exception("PortletSession is null. " +
- "Call setPortletSession() first.");
- } catch (Exception e)
- {
+ public UserSessionMgr getUserSession(String producerID, String userID) throws WSRPException {
+ if (portletSession == null) {
+ try {
+ throw new Exception("PortletSession is null. " + "Call setPortletSession() first.");
+ } catch (Exception e) {
e.printStackTrace();
}
- } else
- {
+ } else {
- Producer producer = consumerEnv.getProducerRegistry().
- getProducer(producerID);
+ Producer producer = consumerEnv.getProducerRegistry().getProducer(producerID);
- if (producer != null)
- {
+ if (producer != null) {
String markupURL = producer.getMarkupInterfaceEndpoint();
- return new UserSessionImpl(producerID, userID, markupURL,
- portletSession);
+ return new UserSessionImpl(producerID, userID, markupURL, portletSession);
}
}
Modified: portals/wsrp4j/trunk/sandbox/wsrp4j/consumer/src/java/org/apache/wsrp4j/consumer/proxyportlet/impl/URLTemplateComposerImpl.java
URL: http://svn.apache.org/viewcvs/portals/wsrp4j/trunk/sandbox/wsrp4j/consumer/src/java/org/apache/wsrp4j/consumer/proxyportlet/impl/URLTemplateComposerImpl.java?rev=374677&r1=374676&r2=374677&view=diff
==============================================================================
--- portals/wsrp4j/trunk/sandbox/wsrp4j/consumer/src/java/org/apache/wsrp4j/consumer/proxyportlet/impl/URLTemplateComposerImpl.java (original)
+++ portals/wsrp4j/trunk/sandbox/wsrp4j/consumer/src/java/org/apache/wsrp4j/consumer/proxyportlet/impl/URLTemplateComposerImpl.java Fri Feb 3 06:28:31 2006
@@ -18,178 +18,139 @@
import org.apache.wsrp4j.commons.consumer.interfaces.urlgenerator.URLGenerator;
import org.apache.wsrp4j.commons.consumer.interfaces.urlgenerator.URLTemplateComposer;
-
/**
- * <p>This class implements the URLTemplateComposer interface providing methods
- * to generate URL templates.</p>
- * <p>The generated templates will be transmitted to Producers (or respectively
- * portlets) that are willing to properly write URLs for a Consumer.
- * (With templates the Consumer indicates how it needs URLs formatted in order
- * to process them properly.)</p>
- * @version $Id$
+ * <p>
+ * This class implements the URLTemplateComposer interface providing methods to
+ * generate URL templates.
+ * </p>
+ * <p>
+ * The generated templates will be transmitted to Producers (or respectively
+ * portlets) that are willing to properly write URLs for a Consumer. (With
+ * templates the Consumer indicates how it needs URLs formatted in order to
+ * process them properly.)
+ * </p>
+ *
+ * @version $Id: URLTemplateComposerImpl.java 327457 2005-08-23 19:28:12Z
+ * dlouzan $
*/
-public class URLTemplateComposerImpl implements URLTemplateComposer
-{
+public class URLTemplateComposerImpl implements URLTemplateComposer {
private static URLTemplateComposer instance;
+
private URLGenerator urlGenerator;
- public static URLTemplateComposer getInstance()
- {
- if (instance == null)
- {
+ public static URLTemplateComposer getInstance() {
+ if (instance == null) {
instance = new URLTemplateComposerImpl();
}
return instance;
}
- private URLTemplateComposerImpl()
- {
+ private URLTemplateComposerImpl() {
}
/**
* Sets the url generator to be used.
*/
- public void setURLGenerator(URLGenerator urlGenerator)
- {
+ public void setURLGenerator(URLGenerator urlGenerator) {
this.urlGenerator = urlGenerator;
}
- public String createBlockingActionTemplate(
- boolean includePortletHandle,
- boolean includeUserContextKey,
- boolean includePortletInstanceKey,
- boolean includeSessionID)
- {
-
- String template = null;
-
- //TODO: Template processing Pluto case
+ public String createBlockingActionTemplate(boolean includePortletHandle,
+ boolean includeUserContextKey, boolean includePortletInstanceKey,
+ boolean includeSessionID) {
+
+ String template = null;
+
+ // TODO: Template processing Pluto case
return template;
}
- public String createSecureBlockingActionTemplate(
- boolean includePortletHandle,
- boolean includeUserContextKey,
- boolean includePortletInstanceKey,
- boolean includeSessionID)
- {
-
- String template = null;
-
- //TODO: Template processing Pluto case
-/*
-
- if (this.urlGenerator != null)
- {
- template =
- createTemplate(
- urlGenerator.getBlockingActionURL(null),
- false,
- true,
- true,
- true,
- true,
- true,
- false,
- false,
- includePortletHandle,
- includeUserContextKey,
- includePortletInstanceKey,
- includeSessionID);
- }
-*/
+ public String createSecureBlockingActionTemplate(boolean includePortletHandle,
+ boolean includeUserContextKey, boolean includePortletInstanceKey,
+ boolean includeSessionID) {
+
+ String template = null;
+
+ // TODO: Template processing Pluto case
+ /*
+ *
+ * if (this.urlGenerator != null) { template = createTemplate(
+ * urlGenerator.getBlockingActionURL(null), false, true, true, true,
+ * true, true, false, false, includePortletHandle,
+ * includeUserContextKey, includePortletInstanceKey, includeSessionID); }
+ */
return template;
}
- public String createRenderTemplate(
- boolean includePortletHandle,
- boolean includeUserContextKey,
- boolean includePortletInstanceKey,
- boolean includeSessionID)
- {
+ public String createRenderTemplate(boolean includePortletHandle, boolean includeUserContextKey,
+ boolean includePortletInstanceKey, boolean includeSessionID) {
String template = null;
- //TODO: Template processing Pluto case
+ // TODO: Template processing Pluto case
return template;
}
- public String createSecureRenderTemplate(
- boolean includePortletHandle,
- boolean includeUserContextKey,
- boolean includePortletInstanceKey,
- boolean includeSessionID)
- {
+ public String createSecureRenderTemplate(boolean includePortletHandle,
+ boolean includeUserContextKey, boolean includePortletInstanceKey,
+ boolean includeSessionID) {
String template = null;
- //TODO: Template processing Pluto case
+ // TODO: Template processing Pluto case
return template;
}
- public String createResourceTemplate(
- boolean includePortletHandle,
- boolean includeUserContextKey,
- boolean includePortletInstanceKey,
- boolean includeSessionID)
- {
+ public String createResourceTemplate(boolean includePortletHandle,
+ boolean includeUserContextKey, boolean includePortletInstanceKey,
+ boolean includeSessionID) {
String template = null;
-
- //TODO: Template processing Pluto case
+
+ // TODO: Template processing Pluto case
return template;
}
- public String createSecureResourceTemplate(
- boolean includePortletHandle,
- boolean includeUserContextKey,
- boolean includePortletInstanceKey,
- boolean includeSessionID)
- {
+ public String createSecureResourceTemplate(boolean includePortletHandle,
+ boolean includeUserContextKey, boolean includePortletInstanceKey,
+ boolean includeSessionID) {
String template = null;
-
- //TODO: Template processing Pluto case
-
+
+ // TODO: Template processing Pluto case
+
return template;
}
- public String createDefaultTemplate(
- boolean includePortletHandle,
- boolean includeUserContextKey,
- boolean includePortletInstanceKey,
- boolean includeSessionID)
- {
+ public String createDefaultTemplate(boolean includePortletHandle,
+ boolean includeUserContextKey, boolean includePortletInstanceKey,
+ boolean includeSessionID) {
String template = null;
- //TODO: Template processing Pluto case
-
+ // TODO: Template processing Pluto case
+
return template;
}
- public String createSecureDefaultTemplate(
- boolean includePortletHandle,
- boolean includeUserContextKey,
- boolean includePortletInstanceKey,
- boolean includeSessionID)
- {
+ public String createSecureDefaultTemplate(boolean includePortletHandle,
+ boolean includeUserContextKey, boolean includePortletInstanceKey,
+ boolean includeSessionID) {
String template = null;
- //TODO: Template processing Pluto case
-
+ // TODO: Template processing Pluto case
+
return template;
}
- public String getNamespacePrefix()
- {
+ public String getNamespacePrefix() {
return urlGenerator.getNamespacedToken("");
}
Modified: portals/wsrp4j/trunk/sandbox/wsrp4j/consumer/src/java/org/apache/wsrp4j/consumer/proxyportlet/impl/UserRegistryImpl.java
URL: http://svn.apache.org/viewcvs/portals/wsrp4j/trunk/sandbox/wsrp4j/consumer/src/java/org/apache/wsrp4j/consumer/proxyportlet/impl/UserRegistryImpl.java?rev=374677&r1=374676&r2=374677&view=diff
==============================================================================
--- portals/wsrp4j/trunk/sandbox/wsrp4j/consumer/src/java/org/apache/wsrp4j/consumer/proxyportlet/impl/UserRegistryImpl.java (original)
+++ portals/wsrp4j/trunk/sandbox/wsrp4j/consumer/src/java/org/apache/wsrp4j/consumer/proxyportlet/impl/UserRegistryImpl.java Fri Feb 3 06:28:31 2006
@@ -18,24 +18,19 @@
import org.apache.wsrp4j.commons.consumer.interfaces.user.UserRegistry;
import org.apache.wsrp4j.commons.consumer.driver.GenericUserRegistryImpl;
-
/**
* @version $Id$
*/
-public class UserRegistryImpl extends GenericUserRegistryImpl
-{
+public class UserRegistryImpl extends GenericUserRegistryImpl {
private static UserRegistry instance;
- private UserRegistryImpl()
- {
+ private UserRegistryImpl() {
super();
}
- public static UserRegistry getInstance()
- {
- if (instance == null)
- {
+ public static UserRegistry getInstance() {
+ if (instance == null) {
instance = new UserRegistryImpl();
}
Modified: portals/wsrp4j/trunk/sandbox/wsrp4j/consumer/src/java/org/apache/wsrp4j/consumer/proxyportlet/impl/UserSessionImpl.java
URL: http://svn.apache.org/viewcvs/portals/wsrp4j/trunk/sandbox/wsrp4j/consumer/src/java/org/apache/wsrp4j/consumer/proxyportlet/impl/UserSessionImpl.java?rev=374677&r1=374676&r2=374677&view=diff
==============================================================================
--- portals/wsrp4j/trunk/sandbox/wsrp4j/consumer/src/java/org/apache/wsrp4j/consumer/proxyportlet/impl/UserSessionImpl.java (original)
+++ portals/wsrp4j/trunk/sandbox/wsrp4j/consumer/src/java/org/apache/wsrp4j/consumer/proxyportlet/impl/UserSessionImpl.java Fri Feb 3 06:28:31 2006
@@ -29,16 +29,14 @@
/**
* @version $Id$
*/
-public class UserSessionImpl extends GenericUserSessionImpl
-{
+public class UserSessionImpl extends GenericUserSessionImpl {
private PortletSession portletSession;
+
private Map userSession;
- public UserSessionImpl(String producerID, String userID,
- String portletServicesURL, PortletSession portletSession)
- throws WSRPException
- {
+ public UserSessionImpl(String producerID, String userID, String portletServicesURL,
+ PortletSession portletSession) throws WSRPException {
super(producerID, userID, portletServicesURL);
@@ -47,15 +45,11 @@
setGroupSessionTable(getGroupSessionTable());
}
- private Hashtable getGroupSessionTable()
- {
+ private Hashtable getGroupSessionTable() {
- if ((groupSessions = (Hashtable)userSession.get(
- ConsumerConstants.WSRP_GROUPSESSIONS)) == null)
- {
+ if ((groupSessions = (Hashtable) userSession.get(ConsumerConstants.WSRP_GROUPSESSIONS)) == null) {
groupSessions = new Hashtable();
- userSession.put(ConsumerConstants.WSRP_GROUPSESSIONS,
- groupSessions);
+ userSession.put(ConsumerConstants.WSRP_GROUPSESSIONS, groupSessions);
}
return groupSessions;
@@ -63,21 +57,17 @@
/**
* Get the group session for this group ID
- *
- * @param groupID ID of the portlet application
+ *
+ * @param groupID
+ * ID of the portlet application
* @return The group session for the provided group ID
- **/
- public GroupSessionMgr getGroupSession(String groupID) throws WSRPException
- {
- if (groupID != null)
- {
- GroupSessionMgr groupSession =
- (GroupSessionMgr) this.groupSessions.get(groupID);
- if (groupSession == null)
- {
+ */
+ public GroupSessionMgr getGroupSession(String groupID) throws WSRPException {
+ if (groupID != null) {
+ GroupSessionMgr groupSession = (GroupSessionMgr) this.groupSessions.get(groupID);
+ if (groupSession == null) {
- groupSession = new GroupSessionImpl(groupID,
- this.getMarkupInterfaceURL());
+ groupSession = new GroupSessionImpl(groupID, this.getMarkupInterfaceURL());
addGroupSession(groupSession);
}
@@ -86,12 +76,10 @@
return null;
}
- public WSRP_v1_Markup_PortType getWSRPBaseService()
- {
+ public WSRP_v1_Markup_PortType getWSRPBaseService() {
WSRP_v1_Markup_PortType markupPort = null;
- if ((markupPort = (WSRP_v1_Markup_PortType)userSession.get(
- ConsumerConstants.WSRP_MARKUP_PORT)) == null)
- {
+ if ((markupPort = (WSRP_v1_Markup_PortType) userSession
+ .get(ConsumerConstants.WSRP_MARKUP_PORT)) == null) {
markupPort = super.getWSRPBaseService();
userSession.put(ConsumerConstants.WSRP_MARKUP_PORT, markupPort);
}
@@ -100,12 +88,9 @@
return markupPort;
}
- public boolean isInitCookieRequired()
- {
+ public boolean isInitCookieRequired() {
Boolean initCookieReq = null;
- if ((initCookieReq = (Boolean)userSession.get(
- ConsumerConstants.WSRP_INIT_COOKIE_REQ)) == null)
- {
+ if ((initCookieReq = (Boolean) userSession.get(ConsumerConstants.WSRP_INIT_COOKIE_REQ)) == null) {
initCookieReq = new Boolean(super.isInitCookieRequired());
setInitCookieRequired(initCookieReq.booleanValue());
}
@@ -113,19 +98,14 @@
return initCookieReq.booleanValue();
}
- public void setInitCookieRequired(boolean initCookieRequired)
- {
- userSession.put(ConsumerConstants.WSRP_INIT_COOKIE_REQ,
- new Boolean(initCookieRequired));
+ public void setInitCookieRequired(boolean initCookieRequired) {
+ userSession.put(ConsumerConstants.WSRP_INIT_COOKIE_REQ, new Boolean(initCookieRequired));
super.setInitCookieRequired(initCookieRequired);
}
- public boolean isInitCookieDone()
- {
+ public boolean isInitCookieDone() {
Boolean initCookieDone = null;
- if ((initCookieDone = (Boolean)userSession.get(
- ConsumerConstants.WSRP_INIT_COOKIE_DONE)) == null)
- {
+ if ((initCookieDone = (Boolean) userSession.get(ConsumerConstants.WSRP_INIT_COOKIE_DONE)) == null) {
initCookieDone = new Boolean(super.isInitCookieDone());
setInitCookieDone(initCookieDone.booleanValue());
}
@@ -133,32 +113,24 @@
return initCookieDone.booleanValue();
}
- public void setInitCookieDone(boolean initCookieDone)
- {
- userSession.put(ConsumerConstants.WSRP_INIT_COOKIE_DONE,
- new Boolean(initCookieDone));
+ public void setInitCookieDone(boolean initCookieDone) {
+ userSession.put(ConsumerConstants.WSRP_INIT_COOKIE_DONE, new Boolean(initCookieDone));
super.setInitCookieRequired(initCookieDone);
}
- private Map getUserSessionMap()
- {
+ private Map getUserSessionMap() {
String key = createKey();
- Map myMap = (Map)this.portletSession.getAttribute(key,
- PortletSession.APPLICATION_SCOPE);
+ Map myMap = (Map) this.portletSession.getAttribute(key, PortletSession.APPLICATION_SCOPE);
- if (myMap == null)
- {
+ if (myMap == null) {
myMap = new Hashtable();
- this.portletSession.setAttribute(key, myMap,
- PortletSession.APPLICATION_SCOPE);
+ this.portletSession.setAttribute(key, myMap, PortletSession.APPLICATION_SCOPE);
}
return myMap;
}
- private String createKey()
- {
- return "user :" + this.getUserID() + " producer:" +
- this.getProducerID();
+ private String createKey() {
+ return "user :" + this.getUserID() + " producer:" + this.getProducerID();
}
}