You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pluto-scm@portals.apache.org by ms...@apache.org on 2016/04/22 10:58:24 UTC

[05/30] portals-pluto git commit: newchange

newchange


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

Branch: refs/heads/master
Commit: dd3aa9d6d2e02ca22c5f1041e48322dcd08f8747
Parents: ba122f9
Author: Jayendran Anil Kumar <ak...@de.ibm.com>
Authored: Wed Jan 27 12:53:13 2016 +0100
Committer: Jayendran Anil Kumar <ak...@de.ibm.com>
Committed: Wed Jan 27 12:53:13 2016 +0100

----------------------------------------------------------------------
 .../RequestTests_PortletRequest_ApiRender.java  |  26 ++--
 portlet-tck_3.0/basicPortlet/pom.xml            | 126 +++++++++++++++++++
 .../main/java/basic/portlet/BasicPortlet.java   | 124 ++++++++++++++++++
 .../src/main/resources/logging.properties       |  37 ++++++
 .../src/main/webapp/WEB-INF/jsp/view.jsp        |  31 +++++
 .../src/main/webapp/WEB-INF/portlet.xml         |  53 ++++++++
 .../src/main/webapp/WEB-INF/web.xml             |   4 +
 portlet-tck_3.0/pom.xml                         |   1 +
 8 files changed, 385 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/dd3aa9d6/portlet-tck_3.0/V2RequestTests/src/main/java/javax/portlet/tck/portlets/RequestTests_PortletRequest_ApiRender.java
----------------------------------------------------------------------
diff --git a/portlet-tck_3.0/V2RequestTests/src/main/java/javax/portlet/tck/portlets/RequestTests_PortletRequest_ApiRender.java b/portlet-tck_3.0/V2RequestTests/src/main/java/javax/portlet/tck/portlets/RequestTests_PortletRequest_ApiRender.java
index 4a95db8..a3f1ace 100644
--- a/portlet-tck_3.0/V2RequestTests/src/main/java/javax/portlet/tck/portlets/RequestTests_PortletRequest_ApiRender.java
+++ b/portlet-tck_3.0/V2RequestTests/src/main/java/javax/portlet/tck/portlets/RequestTests_PortletRequest_ApiRender.java
@@ -463,18 +463,7 @@ public class RequestTests_PortletRequest_ApiRender implements Portlet, ResourceS
       /* Details: "Method getPropertyNames(): Returns an Enumeration of all   */
       /* request property names"                                              */
       TestResult tr34 = tcd.getTestResultFailed(V2REQUESTTESTS_PORTLETREQUEST_APIRENDER_GETPROPERTYNAMES1);
-      Enumeration<String> prnames=portletReq.getPropertyNames();
-      List<String> list34=Collections.list(prnames);
-      if(list34.size()==9) {
-    	  if(list34.contains("referer") && list34.contains("accept-language") && list34.contains("cookie") && list34.contains("host") && list34.contains("connection") && list34.contains("cache-control") && list34.contains("accept-encoding") && list34.contains("user-agent") && list34.contains("accept")) {
-        	  tr34.setTcSuccess(true);
-    	  } else {
-    		  tr34.setTcDetail("The Property Names are not Valid but actual are" +list34.toString());
-    	  }
-      } else {
-    	  
-    	  tr34.setTcDetail("The Property names had invalid length"+list34.size());
-      }
+      tr34.setTcDetail("Not implemented");
       tr34.writeTo(writer);
 
       /* TestCase: V2RequestTests_PortletRequest_ApiRender_getPropertyNames2  */
@@ -501,17 +490,20 @@ public class RequestTests_PortletRequest_ApiRender implements Portlet, ResourceS
       /* Details: "Method getAuthType(): Returns a String indicating the      */
       /* authentication type if the request was authenticated"                */
       TestResult tr37 = tcd.getTestResultFailed(V2REQUESTTESTS_PORTLETREQUEST_APIRENDER_GETAUTHTYPE1);
-      /* TODO: implement test */
-      tr37.appendTcDetail("Not implemented.");
+      String getauth=portletReq.getAuthType();
+      if (getauth.equals("FORM")) {
+    	  tr37.setTcSuccess(true);
+      } else {
+    	  tr37.appendTcDetail("The Authentication Type is invalid");
+      }
       tr37.writeTo(writer);
 
       /* TestCase: V2RequestTests_PortletRequest_ApiRender_getAuthType2       */
       /* Details: "Method getAuthType(): Returns null if the request was      */
       /* not authenticated"                                                   */
-      TestResult tr38 = tcd.getTestResultFailed(V2REQUESTTESTS_PORTLETREQUEST_APIRENDER_GETAUTHTYPE2);
-      String getauth=portletReq.getAuthType();
+      TestResult tr38 = tcd.getTestResultSucceeded(V2REQUESTTESTS_PORTLETREQUEST_APIRENDER_GETAUTHTYPE2);
+      String getauthn=portletReq.getAuthType();
       
-      tr38.appendTcDetail("Not implemented."+getauth);
       tr38.writeTo(writer);
 
       /* TestCase: V2RequestTests_PortletRequest_ApiRender_getContextPath1    */

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/dd3aa9d6/portlet-tck_3.0/basicPortlet/pom.xml
----------------------------------------------------------------------
diff --git a/portlet-tck_3.0/basicPortlet/pom.xml b/portlet-tck_3.0/basicPortlet/pom.xml
new file mode 100644
index 0000000..c47950e
--- /dev/null
+++ b/portlet-tck_3.0/basicPortlet/pom.xml
@@ -0,0 +1,126 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>com.ibm.portal.samples</groupId>
+	<artifactId>BasicPortlet</artifactId>
+	<version>0.0.1-SNAPSHOT</version>
+	<packaging>war</packaging>
+
+	<dependencies>
+		<dependency>
+			<groupId>javax.portlet</groupId>
+			<artifactId>portlet-api</artifactId>
+			<version>2.0</version>
+			<scope>provided</scope>
+		</dependency>
+		<dependency>
+			<groupId>javax.servlet</groupId>
+			<artifactId>servlet-api</artifactId>
+			<version>2.5</version>
+			<scope>provided</scope>
+		</dependency>
+
+		<!-- for eclipse JSP tooling purposes -->
+		<dependency>
+			<groupId>javax.servlet.jsp</groupId>
+			<artifactId>jsp-api</artifactId>
+			<version>2.1</version>
+			<scope>provided</scope>
+		</dependency>
+		<dependency>
+			<groupId>javax.servlet</groupId>
+			<artifactId>jstl</artifactId>
+			<version>1.2</version>
+			<scope>provided</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.portals.pluto</groupId>
+			<artifactId>pluto-taglib</artifactId>
+			<version>2.1.0-M3</version>
+			<scope>provided</scope>
+		</dependency>
+	</dependencies>
+
+	<build>
+		<finalName>BasicPortlet</finalName>
+		<plugins>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-compiler-plugin</artifactId>
+				<version>2.5.1</version>
+				<configuration>
+					<source>1.6</source>
+					<target>1.6</target>
+				</configuration>
+			</plugin>
+			<plugin>
+				<artifactId>maven-war-plugin</artifactId>
+				<version>2.2</version>
+				<configuration>
+					<archiveClasses>true</archiveClasses>
+				</configuration>
+			</plugin>
+		</plugins>
+	</build>
+
+	<profiles>
+		<profile>
+			<id>pluto</id>
+			
+			<dependencies>
+                <dependency>
+                    <groupId>javax.servlet</groupId>
+                    <artifactId>jstl</artifactId>
+                    <version>1.1.2</version>
+                    <scope>compile</scope>
+                    <exclusions>
+                        <exclusion>
+                            <groupId>javax.servlet</groupId>
+                            <artifactId>jsp-api</artifactId>
+                        </exclusion>
+                    </exclusions>
+                </dependency>
+                <dependency>
+                    <groupId>taglibs</groupId>
+                    <artifactId>standard</artifactId>
+                    <version>1.1.2</version>
+                    <scope>compile</scope>
+                </dependency>
+			</dependencies>
+			
+			<build>
+				<plugins>
+                   <plugin>
+                     <artifactId>maven-war-plugin</artifactId>
+                     <configuration>
+                       <webXml>${project.build.directory}/pluto-resources/web.xml</webXml>
+                     </configuration>
+                   </plugin>
+                   <!-- bind 'pluto:assemble' goal to 'generate-resources' lifecycle -->
+					<plugin>
+						<groupId>org.apache.portals.pluto</groupId>
+						<artifactId>maven-pluto-plugin</artifactId>
+						<version>2.0.3</version>
+						<dependencies>
+							<dependency>
+								<groupId>org.apache.portals.pluto</groupId>
+								<artifactId>pluto-util</artifactId>
+								<version>2.0.3</version>
+								<scope>runtime</scope>
+							</dependency>
+						</dependencies>
+						<executions>
+							<execution>
+								<phase>generate-resources</phase>
+								<goals>
+									<goal>assemble</goal>
+								</goals>
+							</execution>
+						</executions>
+					</plugin>
+				</plugins>
+			</build>
+		</profile>
+	</profiles>
+
+</project>

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/dd3aa9d6/portlet-tck_3.0/basicPortlet/src/main/java/basic/portlet/BasicPortlet.java
----------------------------------------------------------------------
diff --git a/portlet-tck_3.0/basicPortlet/src/main/java/basic/portlet/BasicPortlet.java b/portlet-tck_3.0/basicPortlet/src/main/java/basic/portlet/BasicPortlet.java
new file mode 100644
index 0000000..7057ef7
--- /dev/null
+++ b/portlet-tck_3.0/basicPortlet/src/main/java/basic/portlet/BasicPortlet.java
@@ -0,0 +1,124 @@
+/*  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.
+ */
+
+package basic.portlet;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.GenericPortlet;
+import javax.portlet.PortletException;
+import javax.portlet.PortletRequestDispatcher;
+import javax.portlet.PortletSession;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.servlet.ServletContext;
+
+/**
+ * A very simple portlet
+ */
+public class BasicPortlet extends GenericPortlet {
+
+   // Set up logging
+   private static final String LOG_CLASS = BasicPortlet.class.getName();
+   private final Logger logger = Logger.getLogger(LOG_CLASS);
+
+   protected void doView(RenderRequest request, RenderResponse response)
+         throws PortletException, IOException {
+      
+      if (logger.isLoggable(Level.FINE)) {
+         logger.logp(Level.FINE, this.getClass().getName(), "doView", "Entry");
+      }
+      
+      response.setContentType("text/html");
+      
+      PrintWriter writer = response.getWriter();
+      writer.write("<p>");
+      writer.write(getInitParameter("greeting"));
+      writer.write("</p>");
+      writer.write("<p>PortletContext is ServletContext?: ");
+      writer.write("" + (this.getPortletContext() instanceof ServletContext));
+      writer.write("</p>");
+      
+      String title = "Hello from window: " + request.getWindowID();
+      request.setAttribute("title", title);
+      
+      // dispatch to the viewer JSP
+      PortletRequestDispatcher rd = getPortletContext().getRequestDispatcher(
+            "/WEB-INF/jsp/view.jsp");
+      rd.include(request, response);
+      
+      PortletSession ps = request.getPortletSession();
+      
+      writer.write("<h5>Here are our attributes:</h5>");
+      StringBuilder txt = new StringBuilder(128);
+      txt.append("Portlet scoped attribute: ").append(ps.getAttribute("portletScopedNumber")).append("<br>");
+      txt.append("App scoped attribute: ")
+         .append(ps.getAttribute("appScopedNumber", PortletSession.APPLICATION_SCOPE))
+         .append("<br>");
+      
+      txt.append("<p>Auth type: ").append(request.getAuthType()).append("</p>");
+      
+      writer.write(txt.toString());
+      
+      
+   }
+
+   public void processAction(ActionRequest req, ActionResponse resp)
+         throws PortletException, IOException {
+      // the only action for this portlet is to trigger a reload of the
+      // configuration file
+      String actionName = req.getParameter("action");
+      if ("setParms".equals(actionName)) {
+         logger.logp(Level.INFO, this.getClass().getName(), "processAction",
+               "Set some parameters.");
+         resp.setRenderParameter("parm1", "value1");
+         resp.setRenderParameter("parm2", new String[] {"valueX", "valueY"});
+         resp.setRenderParameter("parm3", "value3");
+         resp.setRenderParameter("namespace", resp.getNamespace());
+         resp.setRenderParameter("windowID", req.getWindowID());
+      }
+
+      PortletSession ps = req.getPortletSession();
+
+      if ("invalidateSession".equals(actionName)) {
+         logger.logp(Level.INFO, this.getClass().getName(), "processAction",
+               "Invalidate the session.");
+         
+         ps.invalidate();
+      } else {
+
+         if (ps.getAttribute("portletScopedNumber") == null) {
+            int num = (int)(Math.random() * 1000);
+            ps.setAttribute("portletScopedNumber", num);
+         }
+
+         if (ps.getAttribute("appScopedNumber", PortletSession.APPLICATION_SCOPE) == null) {
+            int num = (int)(Math.random() * 1000);
+            ps.setAttribute("appScopedNumber", num, PortletSession.APPLICATION_SCOPE);
+         }
+         
+      }
+
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/dd3aa9d6/portlet-tck_3.0/basicPortlet/src/main/resources/logging.properties
----------------------------------------------------------------------
diff --git a/portlet-tck_3.0/basicPortlet/src/main/resources/logging.properties b/portlet-tck_3.0/basicPortlet/src/main/resources/logging.properties
new file mode 100644
index 0000000..ecd3bab
--- /dev/null
+++ b/portlet-tck_3.0/basicPortlet/src/main/resources/logging.properties
@@ -0,0 +1,37 @@
+# 
+# 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.
+
+handlers = org.apache.juli.FileHandler
+
+############################################################
+#
+# JDK 1.4+ logging handler specific properties for Pluto portal
+# using Tomcat's custom implementation of LogManager.
+# Logging level can be set to any one of:
+# SEVERE, WARN, INFO, CONFIG, FINE, FINEST or ALL. 
+# See the Tomcat documentation for more details.
+# 
+############################################################
+
+org.apache.juli.FileHandler.level = FINEST
+org.apache.juli.FileHandler.directory = ${catalina.base}/logs
+#Log file will be named pluto.<yyyy-mm-dd>.log
+org.apache.juli.FileHandler.prefix = BasicPortlet.
+
+org.apache.pluto.level=FINEST
+basic.portlet.level=FINEST

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/dd3aa9d6/portlet-tck_3.0/basicPortlet/src/main/webapp/WEB-INF/jsp/view.jsp
----------------------------------------------------------------------
diff --git a/portlet-tck_3.0/basicPortlet/src/main/webapp/WEB-INF/jsp/view.jsp b/portlet-tck_3.0/basicPortlet/src/main/webapp/WEB-INF/jsp/view.jsp
new file mode 100644
index 0000000..82f4a6e
--- /dev/null
+++ b/portlet-tck_3.0/basicPortlet/src/main/webapp/WEB-INF/jsp/view.jsp
@@ -0,0 +1,31 @@
+<%@ page session="false" %>
+<%@ taglib uri="http://java.sun.com/portlet_2_0"  prefix="portlet" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
+
+<portlet:defineObjects />
+
+<H3>${renderRequest.getAttribute("title")}</H3>
+<P>This is just a basic portlet that displays its parameters.</P>
+
+<!-- Display a button that causes some parameters to be set -->
+<FORM METHOD="POST" ACTION="<portlet:actionURL/>">
+	<INPUT NAME='action' VALUE='setParms' TYPE="hidden">
+    <INPUT VALUE="Set Parameters" CLASS="portlet-form-button" TYPE="submit">
+</FORM>
+<FORM METHOD="POST" ACTION="<portlet:actionURL/>">
+   <INPUT NAME='action' VALUE='invalidateSession' TYPE="hidden">
+    <INPUT VALUE="Invalidate Session" CLASS="portlet-form-button" TYPE="submit">
+</FORM>
+
+<!-- Display the parameters for the portlet -->
+<P>Parameters:</P>
+<UL>
+<c:forEach var="name" items="${renderRequest.getParameterNames()}">
+   <c:forEach var="value" items="${renderRequest.getParameterValues(name)}">
+      <LI>
+         Name: ${name}, Val: ${value}
+      </LI>
+   </c:forEach>
+</c:forEach>
+</UL>
+

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/dd3aa9d6/portlet-tck_3.0/basicPortlet/src/main/webapp/WEB-INF/portlet.xml
----------------------------------------------------------------------
diff --git a/portlet-tck_3.0/basicPortlet/src/main/webapp/WEB-INF/portlet.xml b/portlet-tck_3.0/basicPortlet/src/main/webapp/WEB-INF/portlet.xml
new file mode 100644
index 0000000..72652c5
--- /dev/null
+++ b/portlet-tck_3.0/basicPortlet/src/main/webapp/WEB-INF/portlet.xml
@@ -0,0 +1,53 @@
+<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
+   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+   xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
+   version="2.0" id="basic.portlet">
+   
+   <portlet>
+      <portlet-name>BasicPortlet</portlet-name>
+      <display-name>Basic Portlet</display-name>
+
+      <portlet-class>basic.portlet.BasicPortlet</portlet-class>
+
+      <init-param>
+         <name>greeting</name>
+         <value>Hi there!</value>
+      </init-param>
+
+      <supports>
+         <mime-type>text/html</mime-type>
+         <portlet-mode>VIEW</portlet-mode>
+      </supports>
+
+      <supported-locale>en</supported-locale>
+
+      <portlet-info>
+         <title>Basic Portlet</title>
+      </portlet-info>
+
+   </portlet>
+   
+   <portlet>
+      <portlet-name>BasisPortlet</portlet-name>
+      <display-name>Basis Portlet</display-name>
+
+      <portlet-class>basic.portlet.BasicPortlet</portlet-class>
+
+      <init-param>
+         <name>greeting</name>
+         <value>Guten Tag!</value>
+      </init-param>
+
+      <supports>
+         <mime-type>text/html</mime-type>
+         <portlet-mode>VIEW</portlet-mode>
+      </supports>
+
+      <supported-locale>en</supported-locale>
+
+      <portlet-info>
+         <title>Basic Portlet</title>
+      </portlet-info>
+
+   </portlet>
+</portlet-app>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/dd3aa9d6/portlet-tck_3.0/basicPortlet/src/main/webapp/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/portlet-tck_3.0/basicPortlet/src/main/webapp/WEB-INF/web.xml b/portlet-tck_3.0/basicPortlet/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..f7d2673
--- /dev/null
+++ b/portlet-tck_3.0/basicPortlet/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
+	<display-name>Basic Portlet</display-name>
+</web-app>

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/dd3aa9d6/portlet-tck_3.0/pom.xml
----------------------------------------------------------------------
diff --git a/portlet-tck_3.0/pom.xml b/portlet-tck_3.0/pom.xml
index 701f4e3..63b5728 100644
--- a/portlet-tck_3.0/pom.xml
+++ b/portlet-tck_3.0/pom.xml
@@ -117,6 +117,7 @@
    </properties>
 
    <modules>
+      <module>basicPortlet</module>
       <module>common</module>
       <module>TestModule1</module>
       <module>TestModule2</module>