1 23 package org.infoglue.deliver.portal; 24 25 import javax.portlet.PortletException; 26 import javax.servlet.ServletConfig ; 27 import javax.servlet.http.HttpServletRequest ; 28 import javax.servlet.http.HttpServletResponse ; 29 30 import org.apache.commons.logging.Log; 31 import org.apache.commons.logging.LogFactory; 32 import org.apache.pluto.PortletContainerException; 33 import org.apache.pluto.om.window.PortletWindow; 34 import org.apache.pluto.portalImpl.core.PortletContainerFactory; 35 import org.apache.pluto.portalImpl.services.ServiceManager; 36 import org.apache.pluto.services.information.InformationProviderAccess; 37 import org.infoglue.deliver.portal.information.DynamicInformationProviderIG; 38 import org.infoglue.deliver.portal.services.PortletWindowRegistryService; 39 40 48 public class PortalService 49 { 50 private static final Log log = LogFactory.getLog(PortalService.class); 51 52 62 63 public boolean service(HttpServletRequest request, HttpServletResponse response) throws PortalException 64 { 65 log.debug("*** service start"); 66 ServletConfig cfg = ServletConfigContainer.getContainer().getServletConfig(); 67 if (cfg == null) 68 { 69 throw new RuntimeException ("ServletConfig is null (the PortalServletDispatcher should initiate it)"); 70 } 71 72 String portletWindowId = null; 74 75 try 76 { 77 DynamicInformationProviderIG provider = (DynamicInformationProviderIG) InformationProviderAccess.getDynamicProvider(request); 78 portletWindowId = provider.getPortalURL().getActionWindowID(); 79 } 80 catch (Throwable e) 81 { 82 log.error("Failed to locate DynamicInformationProviderIG", e); 83 throw new PortalException(e); 84 } 85 86 if (portletWindowId == null) 88 { 89 log.debug("null actionwindow - no actionrequest returning false"); 90 return false; 91 } 92 else 93 { 94 log.debug("actionwindow found [" + portletWindowId + "]"); 95 } 96 97 PortletWindowRegistryService windowService = (PortletWindowRegistryService) ServiceManager.getService(PortletWindowRegistryService.class); 99 PortletWindow actionWindow = windowService.getPortletWindow(portletWindowId); 100 101 if (actionWindow == null) 102 { 103 log.error("PortletWindow action requested but not found: " + portletWindowId); 104 return false; 105 } 106 107 try 109 { 110 log.debug("ask container to process portlet action"); 111 PortletContainerFactory.getPortletContainer().processPortletAction(actionWindow, request, response); 112 log.debug("action sent and executed without exception"); 113 } 114 catch (PortletException e) 115 { 116 log.error("PortletException: ", e); 117 throw new PortalException(e); 118 } 119 catch (PortletContainerException e) 120 { 121 log.error("PortletContainerException: ", e); 122 throw new PortalException(e); 123 } 124 catch (Exception e) 127 { 128 log.error("Unknown exception [" + e.getClass().getName() + "]", e); 129 throw new PortalException(e); 130 } 131 132 return true; 133 } 134 135 } | Popular Tags |