Package it.eng.spago.base

Examples of it.eng.spago.base.ResponseContainer


          auditManager.updateAudit(auditId, new Long(System.currentTimeMillis()), null, "EXECUTION_STARTED", null,
            null);
      }
    }
   
    ResponseContainer responseContainer = ResponseContainer.getResponseContainer();
    EMFErrorHandler errorHandler = responseContainer.getErrorHandler();
    //setting locale, formats, profile, parameters, startDate, endDate
    setGeneralVariables(requestContainer);

    if (obj == null) {
      logger.error("The input object is null.");
View Full Code Here


            SourceBean serviceRequest = null;
            EMFErrorHandler emfErrorHandler = null;
           
            RequestContainer requestContainer = new RequestContainer();
            RequestContainer.setRequestContainer(requestContainer);
            ResponseContainer responseContainer = new ResponseContainer();
            ResponseContainer.setResponseContainer(responseContainer);
            RequestContextIFace requestContext = new DefaultRequestContext(requestContainer,
                    responseContainer);
           
            // try to get from the request the loopback attribute. If present the method has to serve
            // a loopback request (the method has been called from the doRenderService)
            // if not present is a normal request
            boolean isLoop = request.getAttribute(Constants.PUBLISHING_MODE_LOOPBACK) != null;
            if(isLoop) {
              // remove from the request the loopback attribute
              request.removeAttribute(Constants.PUBLISHING_MODE_LOOPBACK);
              //String responseContainerName = (String)request.getAttribute(Constants.RESPONSE_CONTAINER);
             
              //**************** START MODFIFICATION ZERBETTO 09-10-2006 ****************
              // get from the session the previous response container name
              //String responseContainerName = (String)request.getPortletSession().getAttribute(RESPONSE_CONTAINER_NAME);
              // get from the session the previous response container
              //ResponseContainer loopbackResponseContainer = (ResponseContainer)request.getPortletSession().getAttribute(responseContainerName);
              ResponseContainer loopbackResponseContainer = (ResponseContainer)request.getPortletSession().getAttribute(Constants.RESPONSE_CONTAINER);
              //**************** END MODFIFICATION ZERBETTO 09-10-2006 ****************
             
                TracerSingleton.log(
                    Constants.NOME_MODULO,
                    TracerSingleton.DEBUG,
                    "AdapterPortlet::service: loop-back rilevato");
                serviceRequest =
                    loopbackResponseContainer.getLoopbackServiceRequest();
                if (serviceRequest == null)
                    serviceRequest = new SourceBean(Constants.SERVICE_REQUEST);
                else {
                    Object newServiceRequest =
                        serviceRequest.getAttribute(Constants.SERVICE_REQUEST);
                    if ((newServiceRequest != null)
                        && (newServiceRequest instanceof SourceBean))
                        serviceRequest = (SourceBean) newServiceRequest;
                } // if (serviceRequest == null)
                emfErrorHandler = loopbackResponseContainer.getErrorHandler();
                if (emfErrorHandler == null)
                    emfErrorHandler = new EMFErrorHandler();
            } // if (isLoop)
            else {
              monitor = MonitorFactory.start("controller.adapter.portlet");
View Full Code Here

    //  responseContainer = (ResponseContainer)session.getAttribute(responseContainerName);
    //else
    //  TracerSingleton.log(Constants.NOME_MODULO, TracerSingleton.INFORMATION, "AdapterPortlet::doView: responseContainerName nullo");
    // if request container is not null set into RequestContainer ThreadLocal variable
      RequestContainer requestContainer = (RequestContainer)session.getAttribute(Constants.REQUEST_CONTAINER);
      ResponseContainer responseContainer = (ResponseContainer)session.getAttribute(Constants.RESPONSE_CONTAINER);
      TracerSingleton.log(
                Constants.NOME_MODULO,
                TracerSingleton.DEBUG,
                "AdapterPortlet::doView: request container retrieved from session: " + requestContainer);
      TracerSingleton.log(
                Constants.NOME_MODULO,
                TracerSingleton.DEBUG,
                "AdapterPortlet::doView: response container retrieved from session: " + responseContainer);
    //**************** END MODFIFICATION ZERBETTO 09-10-2006 ****************
   
    if(requestContainer != null)
      RequestContainer.setRequestContainer(requestContainer);
        Boolean isHttpResponseFreezed = null;
        if (responseContainer != null)
          isHttpResponseFreezed = (Boolean) responseContainer.getAttribute(
                Constants.HTTP_RESPONSE_FREEZED);
        if ((isHttpResponseFreezed == null)
            || (!isHttpResponseFreezed.booleanValue())) {
          String resource = null;
          // if requestContainer and responseContainer are null meansthat is the first invocation of
          // the doView method, so it's necessaty to get from the portlet configuration the type
          // of service to execute
          if (requestContainer == null && responseContainer == null) {
            // ***************** START SERVICE ***********************************************
            String serviceType = getPortletConfig().getInitParameter(SERVICE_TYPE);
            String serviceName = getPortletConfig().getInitParameter(SERVICE_NAME);
            if(serviceType==null) {
              TracerSingleton.log(
                  Constants.NOME_MODULO,
                          TracerSingleton.CRITICAL,
                          "AdapterPortlet::doView: type of start service not find (ACTION/PAGE/JSP)");
              //System.out.println("AdapterPortlet::doView: type of start service not find (ACTION/PAGE/JSP)");
            }
            if(!serviceType.equalsIgnoreCase(SERVICE_JSP) &&
               !serviceType.equalsIgnoreCase(SERVICE_ACTION) &&
               !serviceType.equalsIgnoreCase(SERVICE_PAGE) ) {
                TracerSingleton.log(
                  Constants.NOME_MODULO,
                          TracerSingleton.CRITICAL,
                          "AdapterPortlet::doView: type of start service unknow (ACTION/PAGE/JSP)");
                //System.out.println("AdapterPortlet::doView: type of start service unknow (ACTION/PAGE/JSP)");
                return;
            }
            if(serviceName==null) {
              TracerSingleton.log(
                  Constants.NOME_MODULO,
                          TracerSingleton.CRITICAL,
                          "AdapterPortlet::doView: name of start service not find");
              System.out.println("AdapterPortlet::doView: name of start service not find");
              return;
            }               
            if(serviceType.equalsIgnoreCase(SERVICE_JSP)) {
              RouterPortlet router = new RouterPortlet(serviceName);
                    try {
                        router.route(getPortletContext(), request, response);  
                  } catch (Exception ex) {
                      TracerSingleton.log(
                          Constants.NOME_MODULO,
                          TracerSingleton.CRITICAL,
                          "AdapterPortlet::doView: Error during the route to " + serviceName, ex);
                      System.out.println("AdapterPortlet::doView: Error during the route to "
                                      + serviceName + " (see log file)");
                  }  
            } else {
              if(serviceType.equalsIgnoreCase(SERVICE_ACTION)) {
                request.setAttribute("ACTION_NAME", serviceName);
              } else {
                request.setAttribute("PAGE", serviceName);
              }
              try{
               
                //**************** START MODFIFICATION ZERBETTO 09-10-2006 ****************
                //HashMap map = (HashMap)processService(request, response);
                      //requestContainerName = (String) map.get(REQUEST_CONTAINER_NAME);
                      //responseContainerName = (String) map.get(RESPONSE_CONTAINER_NAME);
                      // the new request and response name are set into the session and into the request
                      // for the recursive call to the doRenderService
                      //session.setAttribute(REQUEST_CONTAINER_NAME, requestContainerName);
                        //session.setAttribute(RESPONSE_CONTAINER_NAME, responseContainerName);
                        //request.setAttribute(REQUEST_CONTAINER_NAME, requestContainerName);
                        //request.setAttribute(RESPONSE_CONTAINER_NAME, responseContainerName);
                processService(request, response);
                        //**************** END MODFIFICATION ZERBETTO 09-10-2006 ****************
                       
                      // recall the method for presentation
                        doRenderService(request, response);
                        return;                        
              } catch (Exception e) {
                TracerSingleton.log(
                              Constants.NOME_MODULO,
                              TracerSingleton.CRITICAL,
                              "AdapterPortlet::doView: Error during the process of the "
                + serviceType + " service " + serviceName, e);
                System.out.println("AdapterPortlet::doView: Error during the process of the "
                + serviceType + " service " + serviceName + " (see log file)");
              }
            }
            // *******************************************************************
          } else {
              Exception serviceException = (Exception)responseContainer.getAttribute(PORTLET_EXCEPTION);
                RequestContextIFace requestContext =
                    new DefaultRequestContext(requestContainer, responseContainer);
                PublisherConfiguration publisher =
                  Publisher.getPublisherConfiguration(requestContext,
                      serviceException);
View Full Code Here

     * @throws Exception the exception
     */
    private void prepareRender(RequestContextIFace requestContext, PublisherConfiguration publisher) throws Exception {

    RequestContainer requestContainer = requestContext.getRequestContainer();
    ResponseContainer responseContainer = requestContext.getResponseContainer();

    // Prepare service request for loopback management
        try {
            SourceBean loopbackServiceRequest = new SourceBean(Constants.SERVICE_REQUEST);
            loopbackServiceRequest.setAttribute(Navigator.NAVIGATOR_DISABLED, "TRUE");
           
            SourceBean renderingConfig = publisher.getRenderingConfig();
            List resourcesConfig = renderingConfig.getAttributeAsList("RESOURCES.PARAMETER");
            for (int j = 0; j < resourcesConfig.size(); j++) {
                SourceBean consequence = (SourceBean) resourcesConfig.get(j);
                String parameterName = (String) consequence.getAttribute("NAME");
                String parameterScope = (String) consequence.getAttribute("SCOPE");
                String parameterType = (String) consequence.getAttribute("TYPE");
                String parameterValue = (String) consequence.getAttribute("VALUE");
                Object inParameterValue = null;
                if (parameterType.equalsIgnoreCase("ABSOLUTE"))
                    inParameterValue = parameterValue;
                else {
                  inParameterValue = ContextScooping.getScopedParameter(requestContainer,
                                responseContainer,
                                parameterValue, parameterScope, consequence);
                }
               
                if (inParameterValue == null)
                    continue;
                if (inParameterValue instanceof SourceBean)
                    loopbackServiceRequest.setAttribute((SourceBean) inParameterValue);
                else
                    loopbackServiceRequest.setAttribute(parameterName, inParameterValue);
            } // for (int j = 0; j < consequences.size(); j++)
            responseContainer.setLoopbackServiceRequest(loopbackServiceRequest);
        } // try
        catch (SourceBeanException sbe) {
            TracerSingleton.log(Constants.NOME_MODULO, TracerSingleton.CRITICAL,
                    "Publisher::getPublisher:", sbe);
        } // catch (SourceBeanException sbe)
View Full Code Here

   */
  public void prepareRender(RequestContextIFace requestContext, PublisherConfiguration publisher, Object additionalResources) throws Exception {
    super.prepareRender(requestContext, publisher, additionalResources);

    RequestContainer requestContainer = requestContext.getRequestContainer();
    ResponseContainer responseContainer = requestContext.getResponseContainer();

    // Prepare service request for loopback management
        try {
            SourceBean loopbackServiceRequest = new SourceBean(Constants.SERVICE_REQUEST);
            loopbackServiceRequest.setAttribute(Navigator.NAVIGATOR_DISABLED, "TRUE");
           
            SourceBean renderingConfig = publisher.getRenderingConfig();
            List resourcesConfig = renderingConfig.getAttributeAsList("RESOURCES.PARAMETER");
            for (int j = 0; j < resourcesConfig.size(); j++) {
                SourceBean consequence = (SourceBean) resourcesConfig.get(j);
                String parameterName = (String) consequence.getAttribute("NAME");
                String parameterScope = (String) consequence.getAttribute("SCOPE");
                String parameterType = (String) consequence.getAttribute("TYPE");
                String parameterValue = (String) consequence.getAttribute("VALUE");
                Object inParameterValue = null;
                if (parameterType.equalsIgnoreCase("ABSOLUTE"))
                    inParameterValue = parameterValue;
                else {
                  inParameterValue = ContextScooping.getScopedParameter(requestContainer,
                                responseContainer,
                                parameterValue, parameterScope, consequence);
                }
               
                if (inParameterValue == null)
                    continue;
                if (inParameterValue instanceof SourceBean)
                    loopbackServiceRequest.setAttribute((SourceBean) inParameterValue);
                else
                    loopbackServiceRequest.setAttribute(parameterName, inParameterValue);
            } // for (int j = 0; j < consequences.size(); j++)
            // light navigator id propagation
            SourceBean serviceRequest = requestContainer.getServiceRequest();
            String lightNavigatorId = (String) serviceRequest.getAttribute(LightNavigationManager.LIGHT_NAVIGATOR_ID);
            if (lightNavigatorId != null && !lightNavigatorId.trim().equals("")) {
              loopbackServiceRequest.setAttribute(LightNavigationManager.LIGHT_NAVIGATOR_ID, lightNavigatorId);
            }
           
            responseContainer.setLoopbackServiceRequest(loopbackServiceRequest);
        } // try
        catch (SourceBeanException sbe) {
            TracerSingleton.log(Constants.NOME_MODULO, TracerSingleton.CRITICAL,
                    "Publisher::getPublisher:", sbe);
        } // catch (SourceBeanException sbe)
View Full Code Here

            resp = new SourceBean("");
          } catch (SourceBeanException e1) {
            e1.printStackTrace();
          }
          RequestContainer reqContainer = new RequestContainer();
          ResponseContainer resContainer = new ResponseContainer();
          reqContainer.setServiceRequest(request);
          resContainer.setServiceResponse(resp);
          DefaultRequestContext defaultRequestContext = new DefaultRequestContext(
              reqContainer, resContainer);
          resContainer.setErrorHandler(new EMFErrorHandler());
          RequestContainer.setRequestContainer(reqContainer);
          ResponseContainer.setResponseContainer(resContainer);
          Locale locale = new Locale("it","IT","");
          SessionContainer session = new SessionContainer(true);
          reqContainer.setSessionContainer(session);
View Full Code Here

   */
  public void service(SourceBean request, SourceBean response) throws Exception {
    String message = (String) request.getAttribute("MESSAGEDET");
    logger.debug("begin of detail Data Source service with message =" +message);
    RequestContainer requestContainer = this.getRequestContainer()
    ResponseContainer responseContainer = this.getResponseContainer()
    SessionContainer session = requestContainer.getSessionContainer();
    SessionContainer permanentSession = session.getPermanentContainer();
    profile = (IEngUserProfile) permanentSession.getAttribute(IEngUserProfile.ENG_USER_PROFILE);
   
    EMFErrorHandler errorHandler = getErrorHandler();
View Full Code Here

          SourceBean serviceRequest = null;
            EMFErrorHandler emfErrorHandler = null;
            EMFExceptionHandler exceptionHandler = new EMFExceptionHandler();
           
            // Retrieve LOOP responseContainer, if any
            ResponseContainer loopbackResponseContainer = ResponseContainer.getResponseContainer();
           
            RequestContainer requestContainer = new RequestContainer();
            RequestContainer.setRequestContainer(requestContainer);
           
            ResponseContainer responseContainer = new ResponseContainer();
            ResponseContainer.setResponseContainer(responseContainer);
           
            requestContext = new DefaultRequestContext(requestContainer,
                    responseContainer);
           
            // Retrieve HTTP session
            HttpSession session = request.getSession(true);

          eventNotifier = EventNotifierFactory.getEventNotifier();
          eventNotifier.notifyEvent(
                new ServiceStartEvent(session),
                requestContext);           
          // Trace only after calling listener, so the session id can be written on log files
            TracerSingleton.log(Constants.NOME_MODULO, TracerSingleton.DEBUG,
                      "AdapterHTTP::service: invocato");

            boolean loopback = (request.getAttribute(Constants.PUBLISHING_MODE_LOOPBACK) != null);
            if (loopback) {
                TracerSingleton.log(Constants.NOME_MODULO, TracerSingleton.DEBUG,
                "AdapterHTTP::service: loop-back rilevato");

                // remove from the request the loopback attribute
              request.removeAttribute(Constants.PUBLISHING_MODE_LOOPBACK);
           
                loopbackResponseContainer = ResponseContainerAccess.getResponseContainer(request);
                serviceRequest = loopbackResponseContainer.getLoopbackServiceRequest();
                if (serviceRequest == null) {
                    serviceRequest = new SourceBean(Constants.SERVICE_REQUEST);
                } else {
                    Object newServiceRequest = serviceRequest
                            .getAttribute(Constants.SERVICE_REQUEST);
                    if ((newServiceRequest != null) && (newServiceRequest instanceof SourceBean))
                        serviceRequest = (SourceBean) newServiceRequest;
                } // if (serviceRequest == null)
                requestContainer.setServiceRequest(serviceRequest);
               
                // The errors are kept in loop mode, so retrieve old error handler
                emfErrorHandler = loopbackResponseContainer.getErrorHandler();
               
                if (emfErrorHandler == null) {
                    emfErrorHandler = new EMFErrorHandler();
                }
            } // if (loopbackResponseContainer != null)
            else {
                monitor = MonitorFactory.start("controller.adapter.http");
                serviceRequest = new SourceBean(Constants.SERVICE_REQUEST);
                requestContainer.setServiceRequest(serviceRequest);

                // Get header parameter before parsing the request
                setHttpRequestData(request, requestContainer);
               
                // Check if the service was invoked with the .action or .page URL
                handleServiceName(serviceRequest, requestContainer);
               
                boolean isMultipart = ServletFileUpload.isMultipartContent(new ServletRequestContext(request));
                if (isMultipart) {
                  handleMultipartForm(request, requestContext);
                } else {
                  handleSimpleForm(request, requestContext);
                }

                emfErrorHandler = new EMFErrorHandler();
            } // if (loopbackResponseContainer != null) else

           
            //***************** NAVIGATION CONTROL *******************************************************
            serviceRequest = LightNavigationManager.controlLightNavigation(request, serviceRequest);
            requestContainer.setServiceRequest(serviceRequest);
            //********************************************************************************************
           
            Exception serviceException = null;
            CoordinatorIFace coordinator = null;
            try {
              responseContainer.setErrorHandler(emfErrorHandler);
             
              String channelType = Constants.HTTP_CHANNEL;
              String channelTypeParameter = (String) (serviceRequest
                      .getAttribute(Constants.CHANNEL_TYPE));
              String channelTypeHeader = (String) (requestContainer.getAttribute(HTTP_ACCEPT_HEADER));
              if (((channelTypeParameter != null) && channelTypeParameter
                      .equalsIgnoreCase(Constants.WAP_CHANNEL))
                      || ((channelTypeHeader != null) && (channelTypeHeader.indexOf(WAP_MIME_TYPE) != -1)))
                  channelType = Constants.WAP_CHANNEL;
              requestContainer.setChannelType(channelType);
              requestContainer.setInternalRequest(request);
              requestContainer.setInternalResponse(response);
              requestContainer.setAdapterConfig(getServletConfig());
              TracerSingleton.log(Constants.NOME_MODULO, TracerSingleton.DEBUG,
                      "AdapterHTTP::service: requestContainer", requestContainer);
              TracerSingleton.log(Constants.NOME_MODULO, TracerSingleton.DEBUG,
                      "AdapterHTTP::service: sessionContainer", requestContainer
                              .getSessionContainer());
 
              SourceBean serviceResponse = new SourceBean(Constants.SERVICE_RESPONSE);
              responseContainer.setServiceResponse(serviceResponse);

              checkSession(session, requestContext);
                Navigator.checkNavigation(requestContainer);
             
              // Refresh service request because Navigator services can changed it
              serviceRequest = requestContainer.getServiceRequest();
             
              // Suspend/Resume service
              handleSuspendResume(serviceRequest, requestContainer);
             
              coordinator = DispatcherManager.getCoordinator(requestContext);
              if (coordinator == null) {
                  TracerSingleton.log(Constants.NOME_MODULO, TracerSingleton.WARNING,
                          "AdapterHTTP::service: coordinator nullo !");
                  serviceException = new Exception("Coordinatore non trovato");
                  emfErrorHandler.addError(new EMFInternalError(EMFErrorSeverity.ERROR,
                          "Coordinatore non trovato !"));
              } // if (coordinator == null)
              else {
                  ((RequestContextIFace) coordinator).setRequestContext(requestContext);
                  responseContainer.setBusinessType(coordinator.getBusinessType());
                  responseContainer.setBusinessName(coordinator.getBusinessName());
                  responseContainer.setPublisherName(coordinator.getPublisherName());
                      coordinator.service(serviceRequest, serviceResponse);
                     
                    ((RequestContextIFace) coordinator).setRequestContext(null);
//                    requestContainer.setInternalRequest(null);
              } // if (coordinator == null) else
View Full Code Here

     *
     * @throws Exception the exception
     */
    private void render(RequestContextIFace requestContext, Exception serviceException)
            throws Exception {
        ResponseContainer responseContainer = requestContext.getResponseContainer();
      
        Boolean isHttpResponseFreezed = (Boolean) responseContainer
                .getAttribute(Constants.HTTP_RESPONSE_FREEZED);
        if ((isHttpResponseFreezed == null) || (!isHttpResponseFreezed.booleanValue())) {
         
          // Retrieve publisher configuration for current service
            PublisherConfiguration publisherConfig = Publisher.getPublisherConfiguration(requestContext,
View Full Code Here

   * @throws Exception the exception
   */
  public void service(SourceBean request, SourceBean response) throws Exception {
    // RECOVER REQUEST CONTAINER, SESSION CONTAINER, USER PROFILE AND ERROR HANDLER
    RequestContainer requestContainer = this.getRequestContainer()
    ResponseContainer responseContainer = this.getResponseContainer()
    session = requestContainer.getSessionContainer();
    SessionContainer permanentSession = session.getPermanentContainer();
    profile = (IEngUserProfile) permanentSession.getAttribute(IEngUserProfile.ENG_USER_PROFILE);
    biobjDAO = DAOFactory.getBIObjectDAO();
    biobjDAO.setUserProfile(profile);
View Full Code Here

TOP

Related Classes of it.eng.spago.base.ResponseContainer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.