1 9 package org.jboss.portal.portlet.tck; 10 11 import java.util.ArrayList ; 12 import java.util.List ; 13 14 import org.apache.log4j.Logger; 15 import org.jboss.portal.server.Portal; 16 import org.jboss.portal.server.PortalRequest; 17 import org.jboss.portal.server.PortalServer; 18 import org.jboss.portal.server.Window; 19 import org.jboss.portal.server.invocation.AttachmentKey; 20 import org.jboss.portal.server.invocation.Interceptor; 21 import org.jboss.portal.server.invocation.Invocation; 22 23 27 public class ViewInterceptor 28 implements Interceptor 29 { 30 31 private static Logger log = Logger.getLogger(ViewInterceptor.class); 32 33 private List windows = new ArrayList (); 36 37 public Object invoke(Invocation invocation) 38 { 39 try 40 { 41 PortalRequest req = (PortalRequest)invocation.getAttachment(AttachmentKey.PORTAL_REQUEST); 43 PortalServer container = req.getServer(); 44 Portal portal = container.getDefaultPortal(); 45 46 String [] values = req.getParameterValues("portletName"); 48 if (values != null) 49 { 50 StringBuffer tmp = new StringBuffer ("Portlet name request ["); 52 for (int i = 0;i < values.length;i++) 53 { 54 tmp.append(i == 0 ? "" : ",").append(values[i]); 55 } 56 tmp.append("]"); 57 log.debug(tmp); 58 59 windows.clear(); 60 for (int i = 0;i < values.length;i++) 61 { 62 String portletName = "/" + values[i]; 63 Window window = portal.getWindow(portletName); 64 if (window != null) 65 { 66 windows.add(window); 67 } 68 else 69 { 70 log.error("Cannot find window for the portlet " + portletName); 71 } 72 } 73 } 74 75 invocation.setAttachment(AttachmentKey.VIEW, new ArrayList (windows)); 77 invocation.setAttachment(AttachmentKey.PORTAL, portal); 78 return invocation.invokeNext(); 79 } 80 finally 81 { 82 invocation.removeAttachment(AttachmentKey.VIEW); 83 } 84 } 85 } 86 | Popular Tags |