1 5 6 package org.exoplatform.services.portletcontainer.impl.servlet; 7 8 import org.apache.commons.logging.Log; 9 import org.exoplatform.container.PortalContainer; 10 import org.exoplatform.container.RootContainer; 11 import org.exoplatform.services.log.LogService; 12 import org.exoplatform.services.portletcontainer.PortletContainerException; 13 import org.exoplatform.services.portletcontainer.helper.PortletWindowInternal; 14 import org.exoplatform.services.portletcontainer.impl.PortletApplicationHandler; 15 import org.exoplatform.services.portletcontainer.impl.PortletContainerDispatcher; 16 import org.exoplatform.services.portletcontainer.pci.Input; 17 import org.exoplatform.services.portletcontainer.pci.Output; 18 19 import javax.servlet.ServletConfig ; 20 import javax.servlet.ServletException ; 21 import javax.servlet.http.HttpServlet ; 22 import javax.servlet.http.HttpServletRequest ; 23 import javax.servlet.http.HttpServletResponse ; 24 import java.util.Locale ; 25 import java.util.ResourceBundle ; 26 27 34 public class ServletWrapper extends HttpServlet { 35 36 public void init(ServletConfig servletConfig) throws ServletException { 37 super.init(servletConfig); 38 39 } 40 41 protected void service(HttpServletRequest servletRequest, HttpServletResponse servletResponse) 42 throws ServletException , java.io.IOException { 43 PortalContainer manager = PortalContainer.getInstance(); 44 LogService logService = (LogService) RootContainer.getInstance(). 45 getComponentInstanceOfType(LogService.class); 46 PortletApplicationHandler handler = (PortletApplicationHandler) manager. 47 getComponentInstanceOfType(PortletApplicationHandler.class); 48 Log log = logService.getLog("org.exoplatform.services.portletcontainer"); 49 log.debug("Service method of ServletWrapper entered"); 50 log.debug("Encoding used : " + servletRequest.getCharacterEncoding()); 51 boolean isToGetBundle = false; 52 Boolean b = (Boolean )servletRequest.getAttribute(PortletContainerDispatcher.IS_TO_GET_BUNDLE); 53 if(b != null) 54 isToGetBundle = b.booleanValue(); 55 if(isToGetBundle){ 56 log.debug("Get bundle"); 57 String portletAppName = (String ) servletRequest.getAttribute(PortletContainerDispatcher.PORTLET_APPLICATION_NAME); 58 String portletName = (String ) servletRequest.getAttribute(PortletContainerDispatcher.PORTLET_NAME); 59 ResourceBundle bundle = handler.getBundle(portletAppName, portletName, 60 ((Locale )servletRequest.getAttribute(PortletContainerDispatcher.LOCALE_FOR_BUNDLE))); 61 servletRequest.setAttribute(PortletContainerDispatcher.BUNDLE, bundle); 62 return; 63 } 64 65 PortletWindowInternal windowInfo = (PortletWindowInternal) servletRequest.getAttribute(PortletContainerDispatcher.WINDOW_INFO); 66 Input input = (Input) servletRequest.getAttribute(PortletContainerDispatcher.INPUT); 67 Output output = (Output) servletRequest.getAttribute(PortletContainerDispatcher.OUTPUT); 68 boolean isAction = ((Boolean )servletRequest.getAttribute(PortletContainerDispatcher.IS_ACTION)).booleanValue(); 69 try { 70 handler.process(getServletContext(), servletRequest, 71 servletResponse, input, output, windowInfo, isAction); 72 } catch (PortletContainerException e) { 73 log.error("An error occured while processing the portlet request", e); 74 throw new ServletException ("An error occured while processing the portlet request", e); 75 } 76 } 77 } 78 | Popular Tags |