portals-pluto-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From msnickl...@apache.org
Subject [13/13] portals-pluto git commit: Completed implementation of static page resource configuration for portlets. Portlets can now declare dependencies on page resources either through annotation or through the portlet deployment descriptor. The Pluro RI wi
Date Fri, 13 May 2016 11:07:05 GMT
Completed implementation of static page resource configuration for portlets.
Portlets can now declare dependencies on page resources either through annotation
or through the portlet deployment descriptor. The Pluro RI will aggregate
the resources onto the portal page containing the portlets. Modified the
PortletHubDemo portlets to configure a dependency on the portlet hub through
annotation. Modified the PortletV3Demo to configure a dependency on the
portlet hub in the deployment descriptor.

Modified the Pluto page configuration file to no longer load the portlet hub
javascript API by default. It is now only loaded if configured by a portlet
on the page.

Introduced a dependency name:PortletHub, scope:javax.portlet, version:3.0.0
for the portlet hub page resource with the intention of standardizing it in
the spec.

Changed the pluto-driver POM file to aggregate the portlet hub API with the
portlet hub implmentation into a single file.


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

Branch: refs/heads/master
Commit: f22690c6768278871c3dc3336db7057806083e93
Parents: bbbcac5
Author: Scott Nicklous <msnicklous@apache.org>
Authored: Fri May 13 11:52:30 2016 +0200
Committer: Scott Nicklous <msnicklous@apache.org>
Committed: Fri May 13 11:52:30 2016 +0200

----------------------------------------------------------------------
 .../java/basic/portlet/ColorSelPortlet.java     |  4 +-
 .../java/basic/portlet/ImageSelPortlet.java     |  4 +-
 .../java/basic/portlet/MessageBoxPortlet.java   |  4 +-
 .../java/basic/portlet/ParamTestPortlet.java    |  4 +-
 .../basic/portlet/PartialActionPortlet.java     |  4 +-
 .../java/basic/portlet/ResourcePortlet.java     |  2 +
 .../src/main/webapp/WEB-INF/portlet.xml         | 24 ++++++++
 .../pluto/driver/PortalDriverServlet.java       | 59 ++++++++++++++------
 .../driver/services/portal/PageResourceId.java  |  7 ++-
 pluto-portal/pom.xml                            | 36 ++++++++++--
 .../resources/pluto-portal-driver-config.xml    | 18 +++---
 11 files changed, 127 insertions(+), 39 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/f22690c6/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 80ac367..d8c89df 100644
--- a/PortletHubDemo/src/main/java/basic/portlet/ColorSelPortlet.java
+++ b/PortletHubDemo/src/main/java/basic/portlet/ColorSelPortlet.java
@@ -43,6 +43,7 @@ import javax.portlet.RenderResponse;
 import javax.portlet.ResourceRequest;
 import javax.portlet.ResourceResponse;
 import javax.portlet.annotations.ActionMethod;
+import javax.portlet.annotations.Dependency;
 import javax.portlet.annotations.LocaleString;
 import javax.portlet.annotations.PortletConfiguration;
 import javax.portlet.annotations.PortletQName;
@@ -53,7 +54,8 @@ import javax.xml.namespace.QName;
  * An example color selection portlet that uses the portlet hub.
  */
 @PortletConfiguration(portletName = "PH-ColorSelPortlet", publicParams = "color", 
-                      title = @LocaleString("PH Color Selection Portlet"))
+                      title = @LocaleString("PH Color Selection Portlet"),
+                      dependencies = @Dependency(name="PortletHub", scope="javax.portlet",
version="3.0.0"))
 public class ColorSelPortlet extends GenericPortlet {
 
    // Set up logging

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/f22690c6/PortletHubDemo/src/main/java/basic/portlet/ImageSelPortlet.java
----------------------------------------------------------------------
diff --git a/PortletHubDemo/src/main/java/basic/portlet/ImageSelPortlet.java b/PortletHubDemo/src/main/java/basic/portlet/ImageSelPortlet.java
index 7256b41..55dae9d 100644
--- a/PortletHubDemo/src/main/java/basic/portlet/ImageSelPortlet.java
+++ b/PortletHubDemo/src/main/java/basic/portlet/ImageSelPortlet.java
@@ -38,6 +38,7 @@ import javax.portlet.RenderRequest;
 import javax.portlet.RenderResponse;
 import javax.portlet.ResourceRequest;
 import javax.portlet.ResourceResponse;
+import javax.portlet.annotations.Dependency;
 import javax.portlet.annotations.LocaleString;
 import javax.portlet.annotations.PortletConfiguration;
 
@@ -46,7 +47,8 @@ import javax.portlet.annotations.PortletConfiguration;
  * A demo portlet for selecting images
  */
 @PortletConfiguration(portletName = "ImageSelPortlet", publicParams = "imgName", 
-                      title = @LocaleString("PH Image Selection Portlet"))
+                      title = @LocaleString("PH Image Selection Portlet"),
+                      dependencies = @Dependency(name="PortletHub", scope="javax.portlet",
version="3.0.0"))
 public class ImageSelPortlet extends GenericPortlet {
 
    // Set up logging

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/f22690c6/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 0eff878..322bc4a 100644
--- a/PortletHubDemo/src/main/java/basic/portlet/MessageBoxPortlet.java
+++ b/PortletHubDemo/src/main/java/basic/portlet/MessageBoxPortlet.java
@@ -40,6 +40,7 @@ import javax.portlet.RenderRequest;
 import javax.portlet.RenderResponse;
 import javax.portlet.ResourceRequest;
 import javax.portlet.ResourceResponse;
+import javax.portlet.annotations.Dependency;
 import javax.portlet.annotations.EventMethod;
 import javax.portlet.annotations.LocaleString;
 import javax.portlet.annotations.PortletConfiguration;
@@ -49,7 +50,8 @@ import javax.portlet.annotations.PortletQName;
  * A demo portlet that displays messages sent via event
  */
 @PortletConfiguration(portletName = "MessageBoxPortlet", publicParams = "color", 
-                      title = @LocaleString("PH Message Box Portlet"))
+                      title = @LocaleString("PH Message Box Portlet"),
+                      dependencies = @Dependency(name="PortletHub", scope="javax.portlet",
version="3.0.0"))
 public class MessageBoxPortlet extends GenericPortlet {
 
    // Set up logging

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/f22690c6/PortletHubDemo/src/main/java/basic/portlet/ParamTestPortlet.java
----------------------------------------------------------------------
diff --git a/PortletHubDemo/src/main/java/basic/portlet/ParamTestPortlet.java b/PortletHubDemo/src/main/java/basic/portlet/ParamTestPortlet.java
index 8d182ca..586f552 100644
--- a/PortletHubDemo/src/main/java/basic/portlet/ParamTestPortlet.java
+++ b/PortletHubDemo/src/main/java/basic/portlet/ParamTestPortlet.java
@@ -38,6 +38,7 @@ import javax.portlet.RenderRequest;
 import javax.portlet.RenderResponse;
 import javax.portlet.ResourceRequest;
 import javax.portlet.ResourceResponse;
+import javax.portlet.annotations.Dependency;
 import javax.portlet.annotations.LocaleString;
 import javax.portlet.annotations.PortletConfiguration;
 
@@ -48,7 +49,8 @@ import javax.portlet.annotations.PortletConfiguration;
  * @author Scott Nicklous
  */
 @PortletConfiguration(portletName = "ParamTestPortlet", publicParams = {"color", "imgName"},
-                        title = @LocaleString("PH Parameter Test Portlet"))
+                        title = @LocaleString("PH Parameter Test Portlet"),
+                        dependencies = @Dependency(name="PortletHub", scope="javax.portlet",
version="3.0.0"))
 public class ParamTestPortlet extends GenericPortlet {
 
    // Set up logging

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/f22690c6/PortletHubDemo/src/main/java/basic/portlet/PartialActionPortlet.java
----------------------------------------------------------------------
diff --git a/PortletHubDemo/src/main/java/basic/portlet/PartialActionPortlet.java b/PortletHubDemo/src/main/java/basic/portlet/PartialActionPortlet.java
index 4f6c365..e819a5f 100644
--- a/PortletHubDemo/src/main/java/basic/portlet/PartialActionPortlet.java
+++ b/PortletHubDemo/src/main/java/basic/portlet/PartialActionPortlet.java
@@ -39,6 +39,7 @@ import javax.portlet.ResourceRequest;
 import static javax.portlet.ResourceRequest.*;
 
 import javax.portlet.ResourceResponse;
+import javax.portlet.annotations.Dependency;
 import javax.portlet.annotations.LocaleString;
 import javax.portlet.annotations.PortletConfiguration;
 
@@ -46,7 +47,8 @@ import javax.portlet.annotations.PortletConfiguration;
  * A demo portlet exercising the partial action processing sequence
  */
 @PortletConfiguration(portletName = "PartialActionPortlet", publicParams = "color",
-                        title = @LocaleString("PH Partial Action Portlet"))
+                        title = @LocaleString("PH Partial Action Portlet"),
+                        dependencies = @Dependency(name="PortletHub", scope="javax.portlet",
version="3.0.0"))
 public class PartialActionPortlet extends GenericPortlet {
 
    // Set up logging

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/f22690c6/PortletHubDemo/src/main/java/basic/portlet/ResourcePortlet.java
----------------------------------------------------------------------
diff --git a/PortletHubDemo/src/main/java/basic/portlet/ResourcePortlet.java b/PortletHubDemo/src/main/java/basic/portlet/ResourcePortlet.java
index 52f8d78..f3f59a6 100644
--- a/PortletHubDemo/src/main/java/basic/portlet/ResourcePortlet.java
+++ b/PortletHubDemo/src/main/java/basic/portlet/ResourcePortlet.java
@@ -39,6 +39,7 @@ import javax.portlet.RenderRequest;
 import javax.portlet.RenderResponse;
 import javax.portlet.ResourceRequest;
 import javax.portlet.ResourceResponse;
+import javax.portlet.annotations.Dependency;
 import javax.portlet.annotations.EventDefinition;
 import javax.portlet.annotations.LocaleString;
 import javax.portlet.annotations.PortletApplication;
@@ -73,6 +74,7 @@ import javax.portlet.annotations.Supports;
       )
 @PortletConfiguration(portletName = "PH-ResourcePortlet-PRP",
       title={@LocaleString("PH Resource Portlet")},
+      dependencies = @Dependency(name="PortletHub", scope="javax.portlet", version="3.0.0"),
       supportedLocales = {"en"},
       supports = @Supports(mimeType = "text/html", portletModes = "VIEW"),
       publicParams = {"color", "imgName"}

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/f22690c6/PortletV3Demo/src/main/webapp/WEB-INF/portlet.xml
----------------------------------------------------------------------
diff --git a/PortletV3Demo/src/main/webapp/WEB-INF/portlet.xml b/PortletV3Demo/src/main/webapp/WEB-INF/portlet.xml
index 2cce7d0..e57d73a 100644
--- a/PortletV3Demo/src/main/webapp/WEB-INF/portlet.xml
+++ b/PortletV3Demo/src/main/webapp/WEB-INF/portlet.xml
@@ -23,6 +23,12 @@
 
       <supported-public-render-parameter>photo</supported-public-render-parameter>
       <supported-public-render-parameter>color</supported-public-render-parameter>
+      
+      <dependency>
+         <name>PortletHub</name>
+         <scope>javax.portlet</scope>
+         <version>3.0.0</version>
+      </dependency>
    </portlet>
 
    <portlet>
@@ -67,6 +73,12 @@
       </portlet-info>
 
       <supported-public-render-parameter>photo</supported-public-render-parameter>
+      
+      <dependency>
+         <name>PortletHub</name>
+         <scope>javax.portlet</scope>
+         <version>3.0.0</version>
+      </dependency>
    </portlet>
 
    <portlet>
@@ -91,6 +103,12 @@
          <qname>rp:Message</qname>
       </supported-publishing-event>
       <supported-public-render-parameter>color</supported-public-render-parameter>
+      
+      <dependency>
+         <name>PortletHub</name>
+         <scope>javax.portlet</scope>
+         <version>3.0.0</version>
+      </dependency>
    </portlet>
 
    <portlet>
@@ -256,6 +274,12 @@
       <portlet-info>
          <title>V3 Fragment Identifier Test Portlet</title>
       </portlet-info>
+      
+      <dependency>
+         <name>PortletHub</name>
+         <scope>javax.portlet</scope>
+         <version>3.0.0</version>
+      </dependency>
    </portlet>
 
    <portlet>

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/f22690c6/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalDriverServlet.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalDriverServlet.java
b/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalDriverServlet.java
index b49c8e6..1ede5ba 100644
--- a/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalDriverServlet.java
+++ b/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalDriverServlet.java
@@ -36,6 +36,7 @@ import org.apache.pluto.container.HeaderData;
 import org.apache.pluto.container.PortletContainer;
 import org.apache.pluto.container.PortletContainerException;
 import org.apache.pluto.container.om.portlet.ContainerRuntimeOption;
+import org.apache.pluto.container.om.portlet.Dependency;
 import org.apache.pluto.container.om.portlet.PortletDefinition;
 import org.apache.pluto.driver.config.DriverConfiguration;
 import org.apache.pluto.driver.core.PortalRequestContext;
@@ -258,7 +259,7 @@ public class PortalDriverServlet extends HttpServlet {
       ServletContext sc = req.getServletContext();
       DriverConfiguration dc = (DriverConfiguration) sc.getAttribute(AttributeKeys.DRIVER_CONFIG);
       StringBuilder markup = new StringBuilder(128);
-      
+      List<PageResourceId> portletdeps = new ArrayList<PageResourceId>();
 
       for (String pid : purl.getPortletIds()) {
 
@@ -267,34 +268,41 @@ public class PortalDriverServlet extends HttpServlet {
          HeaderData hd = null;
 
          try {
+
+            String appName = wcfg.getContextPath();
+            String portletName = PortletWindowConfig.parsePortletName(pid);
+            PortletDefinition pd = dc.getPortletRegistryService().getPortletApplication(appName)
+                  .getPortlet(portletName);
+
             if (purl.isVersion3(pid)) {
                hd = container.doHeader(pwin, req, resp);
-            } else if (purl.getVersion(pid).equalsIgnoreCase("2.0")) {
 
-               String appName = wcfg.getContextPath();
-               String portletName = PortletWindowConfig.parsePortletName(pid);
-               PortletDefinition pd = dc.getPortletRegistryService().getPortletApplication(appName)
-                     .getPortlet(portletName);
+               // collect the page dependencies
+               for (Dependency dep : pd.getDependencies()) {
+                  portletdeps.add(new PageResourceId(dep.getName(), dep.getScope(), dep.getVersion()));
+               }
+               
+            } else if (purl.getVersion(pid).equalsIgnoreCase("2.0")) {
                ContainerRuntimeOption crt = pd.getContainerRuntimeOption("javax.portlet.renderHeaders");
                if (crt != null) {
                   List<String> headers = crt.getValues();
                   if (headers.size() == 1 && headers.get(0).equalsIgnoreCase("true"))
{
-                    hd = container.doRender(pwin, req, resp, PortletRequest.RENDER_HEADERS);
+                     hd = container.doRender(pwin, req, resp, PortletRequest.RENDER_HEADERS);
                   }
                }
             }
-            
+
             if (hd != null) {
-               
+
                // handle markup for document head section
                markup.append(hd.getHeadSectionMarkup()).append("\n");
-               
+
                // add the cookies to the response
                List<Cookie> cookies = hd.getCookies();
                for (Cookie c : cookies) {
                   resp.addCookie(c);
                }
-               
+
                // Add the HTTP headers to the response
                Map<String, List<String>> headers = hd.getHttpHeaders();
                for (String name : headers.keySet()) {
@@ -303,7 +311,7 @@ public class PortalDriverServlet extends HttpServlet {
                   }
                }
             }
-            
+
          } catch (PortletContainerException ex) {
             LOG.error(ex.getMessage(), ex);
             throw new ServletException(ex);
@@ -316,19 +324,34 @@ public class PortalDriverServlet extends HttpServlet {
       // Set the header section markup provided by the portlets as an attribute
       // The main rendering JSP uses this when rendering the head section.
       req.setAttribute(AttributeKeys.HEAD_SECTION_MARKUP, markup.toString());
-      
+
       // Now generate the markup for the configured page resources
       markup.setLength(0);
       PageResources pr = dc.getRenderConfigService().getPageResources();
-      
+
       // start with the default page resources
-      List<PageResourceId> deps = new ArrayList<PageResourceId>(
-            dc.getRenderConfigService().getDefaultPageDependencies());
-      
+      List<PageResourceId> deps = new ArrayList<PageResourceId>(dc.getRenderConfigService()
+            .getDefaultPageDependencies());
+
       // add in the page-specific resources
       List<PageResourceId> pagedeps = purl.getPageConfig(req.getServletContext()).getPageResources();
       deps.addAll(pagedeps);
-      
+
+      // and finally the portlet dependencies
+      deps.addAll(portletdeps);
+
+      if (LOG.isDebugEnabled()) {
+         StringBuilder txt = new StringBuilder(128);
+         txt.append("Page dependency list.");
+         txt.append(" total deps: ").append(deps.size());
+         txt.append(", page deps: ").append(pagedeps.size());
+         txt.append(", portlet deps: ").append(portletdeps.size());
+         for (PageResourceId id : deps) {
+            txt.append("\n   ").append(id.toString());
+         }
+         LOG.debug(txt.toString());
+      }
+
       // Set the markup resulting from the specified page resources as an attribute
       // The main rendering JSP uses this when rendering the head section.
       markup.append(pr.getMarkup(deps, req.getContextPath()));

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/f22690c6/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/PageResourceId.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/PageResourceId.java
b/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/PageResourceId.java
index 2ed835e..758b587 100644
--- a/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/PageResourceId.java
+++ b/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/PageResourceId.java
@@ -171,7 +171,12 @@ public class PageResourceId implements Comparable<PageResourceId>
{
       return true;
    }
 
-   // for ordering IDs according to version
+   /**
+    * Allows page resource IDs to be compared and ordered. 
+    * <p>
+    * Note that it doesn't really make much since to order page resource IDs unless they

+    * they refer to the same type of resource (meaning that they differ only in version).
+    */
    @Override
    public int compareTo(PageResourceId id) {
       if (!equals(id)) {

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/f22690c6/pluto-portal/pom.xml
----------------------------------------------------------------------
diff --git a/pluto-portal/pom.xml b/pluto-portal/pom.xml
index b80620c..4e9836f 100644
--- a/pluto-portal/pom.xml
+++ b/pluto-portal/pom.xml
@@ -193,11 +193,37 @@
       <plugin>
          <groupId>net.alchim31.maven</groupId>
          <artifactId>yuicompressor-maven-plugin</artifactId>
-         <configuration>
-            <excludes>
-               <exclude>**/*.css</exclude>   
-            </excludes>
-         </configuration>
+         <executions>
+            <execution>
+                 <id>aggregate</id>
+                 <goals>
+                   <goal>compress</goal>
+                 </goals>                      
+                 <configuration>
+                    <excludes>
+                       <exclude>**/*.css</exclude>
+                    </excludes>
+                    <aggregations>
+                       <aggregation>
+                          <insertNewLine>true</insertNewLine>
+                          <output>${project.build.directory}/${project.build.finalName}/javascript/portletHub.js</output>
+                          <includes>
+                             <include>${basedir}/src/main/webapp/javascript/portletHubImpl.js</include>
+                             <include>${basedir}/src/main/webapp/javascript/portlet.js</include>
+                          </includes>
+                       </aggregation>
+                       <aggregation>
+                          <insertNewLine>true</insertNewLine>
+                          <output>${project.build.directory}/${project.build.finalName}/javascript/portletHub-min.js</output>
+                          <includes>
+                             <include>${project.build.directory}/${project.build.finalName}/javascript/portletHubImpl-min.js</include>
+                             <include>${project.build.directory}/${project.build.finalName}/javascript/portlet-min.js</include>
+                          </includes>
+                       </aggregation>
+                    </aggregations>
+                 </configuration>
+            </execution>
+         </executions>
       </plugin>
     </plugins>
   </build>

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/f22690c6/pluto-portal/src/main/resources/pluto-portal-driver-config.xml
----------------------------------------------------------------------
diff --git a/pluto-portal/src/main/resources/pluto-portal-driver-config.xml b/pluto-portal/src/main/resources/pluto-portal-driver-config.xml
index 14ff632..7b36a34 100644
--- a/pluto-portal/src/main/resources/pluto-portal-driver-config.xml
+++ b/pluto-portal/src/main/resources/pluto-portal-driver-config.xml
@@ -103,6 +103,14 @@ limitations under the License.
     </page-resource>
     <page-resource>
       <identifier>
+        <name>PortletHub</name>
+        <scope>javax.portlet</scope>
+        <version>3.0.0</version>
+      </identifier>
+      <source type="script">/javascript/portletHub.js</source>
+    </page-resource>
+    <page-resource>
+      <identifier>
         <name>jquery.js</name>
         <scope>org.apache.portals</scope>
         <version>2.2.2</version>
@@ -133,16 +141,6 @@ limitations under the License.
       <scope>org.apache.portals</scope>
       <version>3.0.0</version>
     </default-resource>
-    <default-resource>
-      <name>portlet.js</name>
-      <scope>org.apache.portals</scope>
-      <version>3.0.0</version>
-    </default-resource>
-    <default-resource>
-      <name>portletHubImpl.js</name>
-      <scope>org.apache.portals</scope>
-      <version>3.0.0</version>
-    </default-resource>
   </page-resources>
 
 


Mime
View raw message