1 7 package org.exoplatform.services.portletcontainer.test.portlet; 8 9 import java.io.IOException ; 10 import java.io.PrintWriter ; 11 import java.util.Enumeration ; 12 13 import javax.portlet.ActionRequest; 14 import javax.portlet.ActionResponse; 15 import javax.portlet.GenericPortlet; 16 import javax.portlet.PortletConfig; 17 import javax.portlet.PortletException; 18 import javax.portlet.RenderRequest; 19 import javax.portlet.RenderResponse; 20 21 25 public class PortletToTestAccessToHeaders extends GenericPortlet { 26 27 private static String [] arrayOfHeaders = {"header1", "header2", "header3"}; 28 29 public void init(PortletConfig portletConfig) throws PortletException { 30 } 31 32 public void processAction(ActionRequest actionRequest, ActionResponse actionResponse) 33 throws PortletException, IOException { 34 String headerValue = actionRequest.getProperty("header1"); 35 if(!"header-value1".equals(headerValue)) 36 throw new PortletException("exception in processAction of PortletToTestAccessToHeaders"); 37 38 Enumeration e = actionRequest.getPropertyNames(); 39 while (e.hasMoreElements()) { 40 String element = (String ) e.nextElement(); 41 if(!("header1".equals(element) || "header2".equals(element) || 42 "header3".equals(element) || "test".equals(element))) 43 throw new PortletException("exception in processAction of PortletToTestAccessToHeaders"); 44 } 45 46 e = actionRequest.getProperties("header2"); 47 while (e.hasMoreElements()) { 48 String element = (String ) e.nextElement(); 49 if(!"header-value2".equals(element)) 50 throw new PortletException("exception in processAction of PortletToTestAccessToHeaders"); 51 } 52 53 e = actionRequest.getProperties("header3"); 54 while (e.hasMoreElements()) { 55 String element = (String ) e.nextElement(); 56 if(!("header-value3-1".equals(element) || "header-value3-2".equals(element) || "header-value3-3".equals(element))) 57 throw new PortletException("exception in processAction of PortletToTestAccessToHeaders"); 58 } 59 60 actionResponse.setRenderParameter("status", "Everything is ok"); 61 } 62 63 public void render(RenderRequest renderRequest, RenderResponse renderResponse) 64 throws PortletException, IOException { 65 renderResponse.setContentType("text/html"); 66 PrintWriter w = renderResponse.getWriter(); 67 w.println("Everything is ok"); 68 } 69 70 public void destroy() { 71 } 72 } 73 | Popular Tags |