1 16 package org.apache.cocoon.portal.wsrp.adapter; 17 18 import java.util.Enumeration ; 19 import java.util.HashMap ; 20 import java.util.Map ; 21 22 import org.apache.cocoon.environment.ObjectModelHelper; 23 import org.apache.cocoon.environment.Request; 24 import org.apache.cocoon.portal.PortalService; 25 import org.apache.cocoon.portal.coplet.CopletInstanceData; 26 import org.apache.cocoon.portal.event.Event; 27 import org.apache.cocoon.portal.event.aspect.EventAspect; 28 import org.apache.cocoon.portal.event.aspect.EventAspectContext; 29 30 38 public class WSRPEventAspect implements EventAspect { 39 40 public static final String REQUEST_PARAMETER_NAME = "cocoon-wsrpevent"; 41 42 45 public void process(EventAspectContext context, PortalService service) { 46 final Request request = ObjectModelHelper.getRequest(context.getObjectModel()); 47 final String [] values = request.getParameterValues("cocoon-wsrpevent"); 48 if ( values != null && values.length == 1 ) { 49 final Map parameters = new HashMap (); 51 final Enumeration parameterNames = request.getParameterNames(); 52 while ( parameterNames.hasMoreElements() ) { 53 final String name = (String )parameterNames.nextElement(); 54 if ( !REQUEST_PARAMETER_NAME.equals(name) ) { 55 final String value = request.getParameter(name); 56 parameters.put(name, value); 57 } 58 } 59 final String copletid = values[0]; 60 final CopletInstanceData cid = service.getComponentManager().getProfileManager().getCopletInstanceData(copletid); 61 62 final Event e = new WSRPEvent(cid, parameters); 63 service.getComponentManager().getEventManager().send(e); 64 } 65 context.invokeNext(service); 66 } 67 } 68 | Popular Tags |