portals-portalapps-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From woon...@apache.org
Subject svn commit: r881895 - in /portals/applications/webcontent/trunk: webcontent-jar/ webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/portlet/ webcontent-war/src/main/webapp/WEB-INF/view/
Date Wed, 18 Nov 2009 19:36:34 GMT
Author: woonsan
Date: Wed Nov 18 19:36:33 2009
New Revision: 881895

URL: http://svn.apache.org/viewvc?rev=881895&view=rev
Log:
APA-17: Removing portlet 2.0 api dependency in iframe portlet. (However, it still leverages
resource urls via reflection anyway if available.)

Added:
    portals/applications/webcontent/trunk/webcontent-war/src/main/webapp/WEB-INF/view/iframe-record-visit.jsp
  (with props)
Modified:
    portals/applications/webcontent/trunk/webcontent-jar/pom.xml
    portals/applications/webcontent/trunk/webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/portlet/IFrameGenericPortlet.java

Modified: portals/applications/webcontent/trunk/webcontent-jar/pom.xml
URL: http://svn.apache.org/viewvc/portals/applications/webcontent/trunk/webcontent-jar/pom.xml?rev=881895&r1=881894&r2=881895&view=diff
==============================================================================
--- portals/applications/webcontent/trunk/webcontent-jar/pom.xml (original)
+++ portals/applications/webcontent/trunk/webcontent-jar/pom.xml Wed Nov 18 19:36:33 2009
@@ -29,6 +29,7 @@
   <name>Apache Portals Applications Web Content JAR</name>
 
   <properties>
+    <portlet-api.version>1.0</portlet-api.version>
     <portals.portlet2-api-spec.version>1.0</portals.portlet2-api-spec.version>
     <javax.servlet.version>2.4</javax.servlet.version>
     <org.apache.portals.bridges.common.version>1.0.4</org.apache.portals.bridges.common.version>
@@ -53,6 +54,14 @@
   <dependencies>
 
     <!-- Build Dependencies -->
+    <!--
+    <dependency>
+      <groupId>portlet-api</groupId>
+      <artifactId>portlet-api</artifactId>
+      <version>${portlet-api.version}</version>
+      <scope>provided</scope>
+    </dependency>
+    -->
     <dependency>
       <groupId>org.apache.portals</groupId>
       <artifactId>portlet-api_2.0_spec</artifactId>

Modified: portals/applications/webcontent/trunk/webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/portlet/IFrameGenericPortlet.java
URL: http://svn.apache.org/viewvc/portals/applications/webcontent/trunk/webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/portlet/IFrameGenericPortlet.java?rev=881895&r1=881894&r2=881895&view=diff
==============================================================================
--- portals/applications/webcontent/trunk/webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/portlet/IFrameGenericPortlet.java
(original)
+++ portals/applications/webcontent/trunk/webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/portlet/IFrameGenericPortlet.java
Wed Nov 18 19:36:33 2009
@@ -25,18 +25,15 @@
 
 import javax.portlet.ActionRequest;
 import javax.portlet.ActionResponse;
-import javax.portlet.MimeResponse;
 import javax.portlet.PortletConfig;
 import javax.portlet.PortletException;
 import javax.portlet.PortletPreferences;
 import javax.portlet.PortletURL;
 import javax.portlet.RenderRequest;
 import javax.portlet.RenderResponse;
-import javax.portlet.ResourceRequest;
-import javax.portlet.ResourceResponse;
-import javax.portlet.ResourceURL;
 import javax.portlet.WindowState;
 
+import org.apache.commons.beanutils.MethodUtils;
 import org.apache.commons.collections.keyvalue.DefaultMapEntry;
 import org.apache.commons.lang.BooleanUtils;
 import org.apache.commons.lang.ClassUtils;
@@ -66,6 +63,8 @@
     
     private boolean isPortlet10Container;
     
+    private String recordVisitResourcePage = "/WEB-INF/view/iframe-record-visit.jsp"; 
+    
     @Override
     public void init(PortletConfig config) throws PortletException
     {
@@ -96,6 +95,13 @@
         maxAttributes.put("SCROLLING", "AUTO");
         maxAttributes.put("STYLE", "");
         
+        String param = config.getInitParameter("recordVisitResourcePage");
+        
+        if (param != null)
+        {
+            recordVisitResourcePage = param;
+        }
+        
         try
         {
             ClassUtils.getPublicMethod(PortletConfig.class, "getDefaultNamespace", new Class[0]);
@@ -144,7 +150,6 @@
         appendAttribute(prefs, content, attribute, maxAttributes);
     }
     
-    @Override
     protected void doHeaders(RenderRequest request, RenderResponse response) 
     {
         PortletPreferences prefs = request.getPreferences();
@@ -160,12 +165,19 @@
                 handlerScript = request.getContextPath() + "/javascript/iframe_handler.js";
             }
             
-            Element headElem = response.createElement("script");
-            headElem.setAttribute("id", IFRAME_AUTORESIZE_SCRIPT_ID);
-            headElem.setAttribute("language", "JavaScript");
-            headElem.setAttribute("type", "text/javascript");
-            headElem.setAttribute("src", handlerScript);
-            response.addProperty(MimeResponse.MARKUP_HEAD_ELEMENT, headElem);
+            try
+            {
+                Element headElem = (Element) MethodUtils.invokeMethod(response, "createElement",
new Object [] { "script" });
+                headElem.setAttribute("id", IFRAME_AUTORESIZE_SCRIPT_ID);
+                headElem.setAttribute("language", "JavaScript");
+                headElem.setAttribute("type", "text/javascript");
+                headElem.setAttribute("src", handlerScript);
+                MethodUtils.invokeMethod(response, "addProperty", new Object [] { "javax.portlet.markup.head.element",
headElem });
+            }
+            catch (Exception e)
+            {
+                throw new RuntimeException("Failed to invoke portlet 2.0 api.", e);
+            }
         }
     }
     
@@ -234,26 +246,10 @@
         super.doCustom(request, response);
     }
     
-    @Override
-    public void serveResource(ResourceRequest request, ResourceResponse response) throws
PortletException, IOException 
-    {
-        String resourceId = request.getResourceID();
-        
-        if ("visit".equals(resourceId))
-        {
-            String url = request.getParameter("URL");
-            
-            if (!StringUtils.isBlank(url))
-            {
-                PortletMessaging.publish(request, IFRAME_SRC_URL, url.trim());
-            }
-        }
-    }
-    
     /**
      * Render IFRAME content
      */
-    protected void doIFrame(RenderRequest request, RenderResponse response) throws IOException
+    protected void doIFrame(RenderRequest request, RenderResponse response) throws PortletException,
IOException
     {
         PortletPreferences prefs = request.getPreferences();
         String source = getURLSource(request, response, prefs);
@@ -288,11 +284,18 @@
             if (!isPortlet10Container)
             {
                 // append a resource url string as an attribute to enable the handler javascript
to invoke.
-                ResourceURL visitPageResourceURL = response.createResourceURL();
-                visitPageResourceURL.setResourceID("visit");
-                content.append(" ").append("visitresourceurl").append("=\"");
-                visitPageResourceURL.write(content, true);
-                content.append("\"");
+                try
+                {
+                    Object visitPageResourceURL = MethodUtils.invokeMethod(response, "createResourceURL",
null);
+                    MethodUtils.invokeMethod(visitPageResourceURL, "setResourceID", new Object
[] { recordVisitResourcePage });
+                    content.append(" ").append("visitresourceurl").append("=\"");
+                    MethodUtils.invokeMethod(visitPageResourceURL, "write", new Object []
{ content, Boolean.TRUE });
+                    content.append("\"");
+                }
+                catch (Exception e)
+                {
+                    throw new PortletException("Failed to invoke portlet 2.0 api.", e);
+                }
             }
             else
             {

Added: portals/applications/webcontent/trunk/webcontent-war/src/main/webapp/WEB-INF/view/iframe-record-visit.jsp
URL: http://svn.apache.org/viewvc/portals/applications/webcontent/trunk/webcontent-war/src/main/webapp/WEB-INF/view/iframe-record-visit.jsp?rev=881895&view=auto
==============================================================================
--- portals/applications/webcontent/trunk/webcontent-war/src/main/webapp/WEB-INF/view/iframe-record-visit.jsp
(added)
+++ portals/applications/webcontent/trunk/webcontent-war/src/main/webapp/WEB-INF/view/iframe-record-visit.jsp
Wed Nov 18 19:36:33 2009
@@ -0,0 +1,28 @@
+<%--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+    http://www.apache.org/licenses/LICENSE-2.0
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+--%>
+<%@ page language="java" import="javax.portlet.PortletRequest, org.apache.portals.messaging.PortletMessaging,
org.apache.portals.applications.webcontent.portlet.IFrameGenericPortlet" session="true" %>
+<%
+String url = request.getParameter("URL");
+
+if (url != null && !"".equals(url.trim()))
+{
+    PortletRequest portletRequest = (PortletRequest) request.getAttribute("javax.portlet.request");
+    
+    if (portletRequest != null)
+    {
+        PortletMessaging.publish(portletRequest, IFrameGenericPortlet.IFRAME_SRC_URL, url.trim());
+    }
+}
+%>

Propchange: portals/applications/webcontent/trunk/webcontent-war/src/main/webapp/WEB-INF/view/iframe-record-visit.jsp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/applications/webcontent/trunk/webcontent-war/src/main/webapp/WEB-INF/view/iframe-record-visit.jsp
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/applications/webcontent/trunk/webcontent-war/src/main/webapp/WEB-INF/view/iframe-record-visit.jsp
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message