Package it.eng.spago.exception

Examples of it.eng.spago.exception.EMFExceptionHandler


      RequestContextIFace requestContext = null;

        try {
          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

            } // try
            catch (Exception ex) {
              ServiceIFace service = (coordinator != null)? coordinator.getService() : null;
              exceptionHandler.handleException(ex, service, requestContext);
            } // catch (Exception ex)
           
//            requestContainer.setInternalResponse(null);
//            requestContainer.setAdapterConfig(null);
            // nel caso in cui sia attiva la persistenza della sessione
View Full Code Here


      RequestContextIFace requestContext = null;

        try {
          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

            } // try
            catch (Exception ex) {
              ServiceIFace service = (coordinator != null)? coordinator.getService() : null;
              exceptionHandler.handleException(ex, service, requestContext);
            } // catch (Exception ex)
           
//            requestContainer.setInternalResponse(null);
//            requestContainer.setAdapterConfig(null);
            // nel caso in cui sia attiva la persistenza della sessione
View Full Code Here

      RequestContextIFace requestContext = null;

        try {
          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

            } // try
            catch (Exception ex) {
              ServiceIFace service = (coordinator != null)? coordinator.getService() : null;
              exceptionHandler.handleException(ex, service, requestContext);
            } // catch (Exception ex)
           
//            requestContainer.setInternalResponse(null);
//            requestContainer.setAdapterConfig(null);
            // nel caso in cui sia attiva la persistenza della sessione
View Full Code Here

TOP

Related Classes of it.eng.spago.exception.EMFExceptionHandler

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.