portals-pluto-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From msnickl...@apache.org
Subject [05/22] portals-pluto git commit: Added some additional tracing to the demo portlets
Date Mon, 16 Feb 2015 15:54:47 GMT
Added some additional tracing to the demo portlets


Project: http://git-wip-us.apache.org/repos/asf/portals-pluto/repo
Commit: http://git-wip-us.apache.org/repos/asf/portals-pluto/commit/aabd8d95
Tree: http://git-wip-us.apache.org/repos/asf/portals-pluto/tree/aabd8d95
Diff: http://git-wip-us.apache.org/repos/asf/portals-pluto/diff/aabd8d95

Branch: refs/heads/V3Prototype
Commit: aabd8d95ad607dfe582ff0c96b7b7ae7a9b95b3a
Parents: 60205ca
Author: Scott Nicklous <msnicklous@apache.org>
Authored: Thu Feb 5 16:58:11 2015 +0100
Committer: Scott Nicklous <msnicklous@apache.org>
Committed: Thu Feb 5 16:58:11 2015 +0100

----------------------------------------------------------------------
 .../java/basic/portlet/ColorSelPortlet.java     | 37 +++++++++++++++-----
 .../src/main/java/basic/portlet/Constants.java  |  3 --
 .../java/basic/portlet/MessageBoxPortlet.java   |  4 ++-
 .../src/main/webapp/WEB-INF/portlet.xml         |  2 +-
 4 files changed, 32 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/aabd8d95/PortletHubDemo/src/main/java/basic/portlet/ColorSelPortlet.java
----------------------------------------------------------------------
diff --git a/PortletHubDemo/src/main/java/basic/portlet/ColorSelPortlet.java b/PortletHubDemo/src/main/java/basic/portlet/ColorSelPortlet.java
index c6447dc..102d2d5 100644
--- a/PortletHubDemo/src/main/java/basic/portlet/ColorSelPortlet.java
+++ b/PortletHubDemo/src/main/java/basic/portlet/ColorSelPortlet.java
@@ -21,6 +21,9 @@ package basic.portlet;
 import static basic.portlet.Constants.*;
 
 import java.io.IOException;
+import java.util.Arrays;
+import java.util.Enumeration;
+import java.util.logging.Logger;
 
 import javax.portlet.ActionRequest;
 import javax.portlet.ActionResponse;
@@ -40,12 +43,16 @@ import javax.xml.namespace.QName;
 public class ColorSelPortlet extends GenericPortlet {
 
    // Set up logging
+   private static final String LOG_CLASS = ColorSelPortlet.class.getName();
+   private final Logger logger = Logger.getLogger(LOG_CLASS);
+
    // private static final String LOG_CLASS = ColorSelPortlet.class.getName();
    // private final Logger logger = Logger.getLogger(LOG_CLASS);
 
    protected void doView(RenderRequest req, RenderResponse resp)
          throws PortletException, IOException {
 
+      logger.fine("Doing view.");
       
       resp.setContentType("text/html");
 
@@ -85,20 +92,32 @@ public class ColorSelPortlet extends GenericPortlet {
          resp.setRenderParameter(PARAM_FG_COLOR, vals);
       }
       
-      String val = req.getParameter(PARAM_SUBTYPE);
-      if (val != null) {
-         resp.setRenderParameter(PARAM_SUBTYPE, val);
+      String subType = req.getParameter(PARAM_SUBTYPE);
+      if (subType != null) {
+         resp.setRenderParameter(PARAM_SUBTYPE, subType);
       }
       
-      val = req.getParameter(PARAM_MSG_INPUT);
-      if (val != null) {
-         resp.setRenderParameter(PARAM_MSG_INPUT, val);
+      String text = req.getParameter(PARAM_MSG_INPUT);
+      if (text != null) {
+         resp.setRenderParameter(PARAM_MSG_INPUT, text);
       }
       
-      String msg = val + DELIM + clr;
-      QName qn = new QName(EVENT_NAMESPACE, EVENT_NAME);
-      resp.setEvent(qn, msg);
+      String msg = text + DELIM + clr;
+
+      // there should only be one publishing event, so take the first QName
+      Enumeration<QName> eqn = getPublishingEventQNames();
+      if (eqn.hasMoreElements()) {
+         QName qn = eqn.nextElement(); 
+         resp.setEvent(qn, msg);
+         logger.fine("Firing event with QName: " + qn.toString());
+      } else {
+         logger.warning("No publishing event QName available. Check portlet deployment descriptor.");
+      }
       
+      StringBuilder sb = new StringBuilder("Color: ").append(Arrays.toString(vals));
+      sb.append(", Submission type: ").append(subType);
+      sb.append(", Text: ").append(text);
+      logger.fine(sb.toString());
    }
 
 }

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/aabd8d95/PortletHubDemo/src/main/java/basic/portlet/Constants.java
----------------------------------------------------------------------
diff --git a/PortletHubDemo/src/main/java/basic/portlet/Constants.java b/PortletHubDemo/src/main/java/basic/portlet/Constants.java
index fad97d7..e36609c 100644
--- a/PortletHubDemo/src/main/java/basic/portlet/Constants.java
+++ b/PortletHubDemo/src/main/java/basic/portlet/Constants.java
@@ -46,8 +46,5 @@ public class Constants {
    public final static String PARAM_NUM_MSGS = "numMsgs";
    public final static String ATTRIB_MSGS = "msgs";
    
-   public final static String EVENT_NAMESPACE = "http://www.apache.org/portals/pluto/pub-render-params/ResourcePortlet";
-   public final static String EVENT_NAME = "Message";
-   
    public final static String DELIM = ";%;";
 }

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/aabd8d95/PortletHubDemo/src/main/java/basic/portlet/MessageBoxPortlet.java
----------------------------------------------------------------------
diff --git a/PortletHubDemo/src/main/java/basic/portlet/MessageBoxPortlet.java b/PortletHubDemo/src/main/java/basic/portlet/MessageBoxPortlet.java
index f8363b0..4fb730a 100644
--- a/PortletHubDemo/src/main/java/basic/portlet/MessageBoxPortlet.java
+++ b/PortletHubDemo/src/main/java/basic/portlet/MessageBoxPortlet.java
@@ -103,7 +103,7 @@ public class MessageBoxPortlet extends GenericPortlet {
          msgs.clear();
       }
       
-      logger.fine("MBP: Processing message event. Current # messages = " + msgs.size());
+      logger.fine("Processing message event. Current # messages = " + msgs.size());
 
       try {
          // Both pieces of info are transported in a delimted string rather than 
@@ -161,6 +161,8 @@ public class MessageBoxPortlet extends GenericPortlet {
          writer.write(msg);
       }
 
+      int n = msgs.size();
+      logger.fine("Served messages. latest message: " + (n > 0 ? msgs.get(n-1) : "null"));
    }
 
 }

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/aabd8d95/PortletHubDemo/src/main/webapp/WEB-INF/portlet.xml
----------------------------------------------------------------------
diff --git a/PortletHubDemo/src/main/webapp/WEB-INF/portlet.xml b/PortletHubDemo/src/main/webapp/WEB-INF/portlet.xml
index f81145e..9a516e3 100644
--- a/PortletHubDemo/src/main/webapp/WEB-INF/portlet.xml
+++ b/PortletHubDemo/src/main/webapp/WEB-INF/portlet.xml
@@ -1,6 +1,6 @@
 <portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_3_0.xsd" 
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
-           xmlns:rp="http://www.apache.org/portals/pluto/pub-render-params/ResourcePortlet"
+             xmlns:rp="http://www.apache.org/portals/pluto/pub-render-params/ResourcePortlet"
              xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_3_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_3_0.xsd"

              version="3.0"
     		id="ph.resource.portlet">


Mime
View raw message