Package it.eng.spago.error

Examples of it.eng.spago.error.EMFErrorHandler


      IEventNotifier eventNotifier = null;
      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());
View Full Code Here


      // url
      if (!EngineUtilities.isExternal(eng))
        if(eng.getClassName().equals("it.eng.spagobi.engines.kpi.SpagoBIKpiInternalEngine")){
          SourceBean request = null;
          SourceBean resp = null;
          EMFErrorHandler errorHandler = null;

          try {
            request = new SourceBean("");
            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);
          SessionContainer permSession = session.getPermanentContainer();
          //IEngUserProfile profile = new AnonymousCMSUserProfile();
          permSession.setAttribute(IEngUserProfile.ENG_USER_PROFILE, profile);
          errorHandler = defaultRequestContext.getErrorHandler();

          String className = eng.getClassName();
          logger.debug("Try instantiating class " + className
              + " for internal engine " + eng.getName() + "...");
          InternalEngineIFace internalEngine = null;
          // tries to instantiate the class for the internal engine
          try {
            if (className == null && className.trim().equals(""))
              throw new ClassNotFoundException();
            internalEngine = (InternalEngineIFace) Class.forName(className).newInstance();
          } catch (ClassNotFoundException cnfe) {
            logger.error("The class ['" + className
                + "'] for internal engine " + eng.getName()
                + " was not found.", cnfe);
            Vector params = new Vector();
            params.add(className);
            params.add(eng.getName());
            errorHandler.addError(new EMFUserError(EMFErrorSeverity.ERROR,
                2001, params));
            return response;
          } catch (Exception e) {
            logger.error("Error while instantiating class " + className, e);
            errorHandler.addError(new EMFUserError(EMFErrorSeverity.ERROR,
                100));
            return response;
          }
          try {
            reqContainer.setAttribute("scheduledExecution", "true");
            internalEngine.execute(reqContainer, biObject, resp);
          } catch (EMFUserError e) {
            logger.error("Error during engine execution", e);
            errorHandler.addError(e);
          } catch (Exception e) {
            logger.error("Error while engine execution", e);
            errorHandler.addError(new EMFUserError(EMFErrorSeverity.ERROR,
                100));
          }
          return response;
        }
        else if(eng.getClassName().equals("it.eng.spagobi.engines.chart.SpagoBIChartInternalEngine")){
          SourceBean request = null;
          EMFErrorHandler errorHandler = null;
          try {
            request = new SourceBean("");
          } catch (SourceBeanException e1) {
            e1.printStackTrace();
          }
View Full Code Here

    SessionContainer sessionContainer = requestContainer
        .getSessionContainer()
    SourceBean serviceRequest = requestContainer.getServiceRequest();
    ValidatorLocator locator = ValidatorLocator.getInstance();
    EMFErrorHandler errorHandler = responseContainer.getErrorHandler();
    TracerSingleton.log(Constants.NOME_MODULO, TracerSingleton.INFORMATION,
        "Validation::validateService:automaticValidation");
    // Controlli formali automatici reperiti dal file validation.xml.xml
    automaticValidation(serviceRequest, errorHandler);
    if (!errorHandler.getErrors().isEmpty()) {
      // Se i controlli formali hanno prodotto errori, non proseguo con
      // gli altri controlli
      return false;
    }
    return true;
View Full Code Here

    if(lang!=null && country!=null){
      locale=new Locale(lang,country,"");
    }   
    //defines the chart type for the correct execution
    ResponseContainer responseContainer=ResponseContainer.getResponseContainer();
    EMFErrorHandler errorHandler=responseContainer.getErrorHandler();
    String chartType = getChartType(obj, errorHandler);
    Template templateUtil = new Template();
    try{
      if (chartType != null && chartType.startsWith(HIGHCHART_TEMPLATE)){
        //gets the dataset object informations
View Full Code Here

    ChartImpl sbi=null;

    //RequestContainer requestContainer=RequestContainer.getRequestContainer();
    SourceBean serviceRequest=requestContainer.getServiceRequest();
    ResponseContainer responseContainer=ResponseContainer.getResponseContainer();
    EMFErrorHandler errorHandler=responseContainer.getErrorHandler();
    SourceBean content = getTemplate(obj.getId().toString());

    //    **************take informations on the chart type*****************
    try{
      String type=content.getName();
      String subtype = (String)content.getAttribute("type");
      String data=getDataset(obj);

      Map parametersMap=getParameters(obj);

      try{
        logger.debug("create the chart");
        // set the right chart type
        sbi=ChartImpl.createChart(type, subtype);
        sbi.setProfile(userProfile);
        sbi.setType(type);
        sbi.setSubtype(subtype);
        sbi.setData(data);
        sbi.setLocale(locale);
        sbi.setParametersObject(parametersMap);
        // configure the chart with template parameters
        sbi.configureChart(content);
        sbi.setLocalizedTitle();

        boolean linkable=sbi.isLinkable();
        if(linkable){
          logger.debug("Linkable chart, search in request for serieurlname or categoryurlname");
          String serieurlname="";
          String categoryurlname="";

          //checjk if is a linkable bar or pie
          boolean linkableBar=false;
          if(sbi instanceof LinkableBar)linkableBar=true;
          else linkableBar=false;


          //check is these parameters are in request, if not take them from template, if not use series and category by default

          if(linkableBar){
            if(serviceRequest!=null && serviceRequest.getAttribute("serieurlname")!=null){
              serieurlname=(String)serviceRequest.getAttribute("serieurlname");
              ((LinkableBar)sbi).setSerieUrlname(serieurlname);
            }
          }

          //category is defined both for pie and bar linkable charts
          if(serviceRequest!=null && serviceRequest.getAttribute("categoryurlname")!=null){
            categoryurlname=(String)serviceRequest.getAttribute("categoryurlname");
            ((ILinkableChart)sbi).setCategoryUrlName(categoryurlname);
          }


          //check if there are other parameters from the drill parameters whose value is in the request; elsewhere take them from template
          logger.debug("Linkable chart: search in the request for other parameters");
          HashMap< String, DrillParameter> drillParametersMap=new HashMap<String, DrillParameter>();

          if(((ILinkableChart)sbi).getDrillParametersMap()!= null){

            drillParametersMap=(HashMap)((ILinkableChart)sbi).getDrillParametersMap().clone();

            // if finds that a parameter is in the request substitute the value; but only if in RELATIVE MODE
            for (Iterator iterator = drillParametersMap.keySet().iterator(); iterator.hasNext();) {
              String name = (String) iterator.next();
              DrillParameter drillPar=drillParametersMap.get(name);
              String typePar=drillPar.getType();
              // if relative put new value!
              if(typePar.equalsIgnoreCase("relative")){
                if(serviceRequest!=null && serviceRequest.getAttribute(name)!=null){
                  String value=(String)serviceRequest.getAttribute(name);
                  ((ILinkableChart)sbi).getDrillParametersMap().remove(name);
                  drillPar.setValue(value);
                  ((ILinkableChart)sbi).getDrillParametersMap().put(name, drillPar);
                }
              }

            }
          }

        }




      }
      catch (Exception e) {
        logger.error("Error while creating the chart",e);
        EMFUserError userError = new EMFUserError(EMFErrorSeverity.ERROR, 2004);
        userError.setBundle("messages");
        throw userError;
      }


      datasets=retrieveDatasetValue(sbi);
      // create the chart


      //in the re-drawing case in document-composition check if serie or categories or cat_group have been set
      String serie=null;
      String category=null;
      String catGroup=null;
      if(serviceRequest!=null && serviceRequest.getAttribute("serie")!=null)
      {
        List series=(List)serviceRequest.getAttributeAsList("serie");
        for(Iterator it=series.iterator();it.hasNext();){
          serie=(String)it.next();
          response.setAttribute("serie",serie);
        }
      }

      if(serviceRequest!=null && serviceRequest.getAttribute("cat_group")!=null)
      {
        List catGroups=(List)serviceRequest.getAttributeAsList("cat_group");
        for(Iterator it=catGroups.iterator();it.hasNext();){
          catGroup=(String)it.next();
          response.setAttribute("cat_group",catGroup);
        }
      }

      // If categoryAll check is checked it overwrites previous informations about slider
      if(serviceRequest!=null && serviceRequest.getAttribute("categoryAll")!=null){
        response.setAttribute("category","0");
      }
      else if(serviceRequest!=null && serviceRequest.getAttribute("category")!=null)
      {
        Object catO=serviceRequest.getAttribute("category");
        category="";
        try{

          category=(String)catO;
        }
        catch (Exception e) {
          Integer catI=(Integer)catO;
          category=catI.toString();
        }
        // if category is 0 but categoryAll is not defined means that categoryAll has just been de-selected, so put category to 1
        if(category.equals("0"))
        {
          category="1";
        }
        response.setAttribute("category",category);
      }

      // if dinamically changed the number categories visualization
      if(serviceRequest!=null && serviceRequest.getAttribute("n_visualization")!=null){
        Object nVis=(Object)serviceRequest.getAttribute("n_visualization");
        response.setAttribute("n_visualization",nVis);
      }




      try{
        //chart = sbi.createChart(title,dataset);
        logger.debug("successfull chart creation");
        if(serviceRequest!=null && response!=null){
          String executionId =(String) serviceRequest.getAttribute("SBI_EXECUTION_ID");
          if (executionId != null) response.setAttribute("SBI_EXECUTION_ID",executionId);
          response.setAttribute("datasets",datasets);
          response.setAttribute(ObjectsTreeConstants.SESSION_OBJ_ATTR,obj);
          response.setAttribute(SpagoBIConstants.PUBLISHER_NAME, "CHARTKPI");
          response.setAttribute("sbi",sbi);
        }
      }
      catch (Exception eex) {
        EMFUserError userError = new EMFUserError(EMFErrorSeverity.ERROR, 2004);
        userError.setBundle("messages");
        throw userError;
      }

      logger.debug("OUT");


    }
    catch (EMFUserError e) {

      errorHandler.addError(e);

    }
    catch (Exception e) {
      EMFUserError userError = new EMFUserError(EMFErrorSeverity.ERROR, 101);
      logger.error("Generic Error");
      errorHandler.addError(userError);

    }

  }
View Full Code Here

    SpagoBITracer.debug(SpagoBIConstants.NAME_MODULE,
              "DetailBIObjectPublisher",
              "getPublisherName",
              "[BEGIN]");
   
    EMFErrorHandler errorHandler = responseContainer.getErrorHandler();
   
    // get the module response
    SourceBean moduleResponse = (SourceBean)responseContainer.getServiceResponse().getAttribute("DetailBIObjectModule");
   
    // if the module response is null throws an error and return the name of the errors publisher
    if(moduleResponse==null) {
      SpagoBITracer.major(SpagoBIConstants.NAME_MODULE,
                "DetailBIObjectPublisher",
                "getPublisherName",
                "Module response null");
      EMFUserError error = new EMFUserError(EMFErrorSeverity.ERROR, 10 );
      errorHandler.addError(error);
      //publisher = new String("error");
      return new String("error");
    }
   
    // if there are errors and they are only validation errors return the name for the detail publisher
    if(!errorHandler.isOK()) {
      if(GeneralUtilities.isErrorHandlerContainingOnlyValidationError(errorHandler)) {
        return "detailBIObject";
      }
    }   
   
    // if there are some errors into the errorHandler (not validation errors), return the name for the errors publisher
    if(!errorHandler.isOKBySeverity(EMFErrorSeverity.ERROR)) {
      return new String("error");
    }
       
        Object loop = moduleResponse.getAttribute("loopback");
        Object parametersLookupLoop = moduleResponse.getAttribute("parametersLookup");
View Full Code Here

        .getSessionContainer();
   
    SourceBean serviceRequest = requestContainer.getServiceRequest();

    ValidatorLocator locator = ValidatorLocator.getInstance();
    EMFErrorHandler errorHandler = responseContainer.getErrorHandler();

    TracerSingleton.log(Constants.NOME_MODULO, TracerSingleton.INFORMATION,
        "Validation::validateService:automaticValidation");

    // Controlli formali automatici reperiti dal file validation.xml.xml
    automaticValidation(serviceRequest, errorHandler);

    if (!errorHandler.getErrors().isEmpty()) {
      // Se i controlli formali hanno prodotto errori, non proseguo con
      // gli altri controlli
      return false;
    }
   
View Full Code Here

   */
  public String getPublisherName(RequestContainer requestContainer, ResponseContainer responseContainer) {

    logger.debug("IN");

    EMFErrorHandler errorHandler = responseContainer.getErrorHandler();
   
    // get the module response
    SourceBean moduleResponse = (SourceBean)responseContainer.getServiceResponse().getAttribute("MetadataBIObjectModule");
   
    // if the module response is null throws an error and return the name of the errors publisher
    if(moduleResponse==null) {
      logger.error("Module response null");
      EMFUserError error = new EMFUserError(EMFErrorSeverity.ERROR, 10 );
      errorHandler.addError(error);     
      return "error";
    }
   
    // if there are errors and they are only validation errors return the name for the detail publisher
    if(!errorHandler.isOK()) {
      if(GeneralUtilities.isErrorHandlerContainingOnlyValidationError(errorHandler)) {
        logger.info("Publish: metadataBIObject"  );
        return "metadataBIObject";
      }
    }
   
    // if there are some errors into the errorHandler (not validation errors), return the name for the errors publisher
    if(!errorHandler.isOKBySeverity(EMFErrorSeverity.ERROR)) {
      return new String("error");
    }

      logger.info("Publish: metadataBIObject"  );
      logger.debug("OUT");
View Full Code Here

    }
    List rowsVector = null;
    if (rowsSourceBean != null)
      rowsVector = rowsSourceBean.getAttributeAsList(DataRow.ROW_TAG);
    if (rowsSourceBean == null) {
      EMFErrorHandler engErrorHandler = serviceRequestContext.getErrorHandler();
      engErrorHandler.addError(new EMFUserError(EMFErrorSeverity.INFORMATION, 10001));
    }
    else
      for (int i = 0; i < rowsVector.size(); i++)
        paginator.addRow(rowsVector.get(i));   
   
View Full Code Here

     * @throws ServletException the servlet exception
     */
    public void service(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
      logger.debug("IN");
 
      EMFErrorHandler errorHandler = new EMFErrorHandler();
     
      //getting values from request:
      String message = (String) request.getParameter(MESSAGE);
      logger.debug( "Message: " + message);
     
      userId = (String) request.getParameter(USER_ID);
      if (userId == null || userId.equals(""))
        userId = (String) request.getParameter(USERNAME);
      logger.debug("Check syntax pwd for the user: " + userId);
     
      url = (String) request.getParameter(URL);
      logger.debug("Start url for final redirect: " + url);
     
      oldPwd = (String) request.getParameter(OLD_PWD);
      newPwd = (String) request.getParameter(NEW_PWD);
      newPwd2 = (String) request.getParameter(NEW_PWD2);
     
      try {
        request.setAttribute(USER_ID, userId);
        request.setAttribute(URL, url);
      if (message == null) {
        getServletContext().getRequestDispatcher(targetJsp).forward(request, response);
        return;
      }

      //gets the user bo from db
      ISbiUserDAO userDao = DAOFactory.getSbiUserDAO();
      tmpUser = userDao.loadSbiUserByUserId(userId);
     
      if (message.trim().equalsIgnoreCase("CHANGE_PWD")){ 
        if (PWD_OK == CheckPwd(tmpUser)){         
          //getting days number for calculate new expiration date
          IConfigDAO configDao = DAOFactory.getSbiConfigDAO();
          List lstConfigChecks = configDao.loadConfigParametersByProperties("changepwd.expired_time");
          Date beginDate = new Date();
          if (lstConfigChecks.size() > 0){
            Config check = (Config)lstConfigChecks.get(0);           
            if (check.isActive()){
              //define the new expired date             
              Date endDate = null;
              SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
              Calendar cal = Calendar.getInstance();
              cal.set(beginDate.getYear()+1900, beginDate.getMonth(), beginDate.getDate());
              //adds n days (getted from db)
              cal.add(Calendar.DATE, Integer.parseInt(check.getValueCheck()));
              try{
                endDate = StringUtilities.stringToDate(sdf.format(cal.getTime()), DATE_FORMAT);
                logger.debug ("End Date for expiration calculeted: " + endDate);
                tmpUser.setDtPwdBegin(beginDate);
                tmpUser.setDtPwdEnd(endDate);
              }catch(Exception e){
                logger.error("The control pwd goes on error: "+e);
                throw new EMFUserError(EMFErrorSeverity.ERROR, 14008, new Vector(), new HashMap());
              }
            }           
          }
          tmpUser.setDtLastAccess(beginDate); //reset last access date
          tmpUser.setPassword(Password.encriptPassword(newPwd));//SHA encrypt
          tmpUser.setFlgPwdBlocked(false); //reset blocking flag
          userDao.updateSbiUser(tmpUser, tmpUser.getId());
          logger.debug("Updated properties for user with id " + tmpUser.getId() + " - DtLastAccess: " + tmpUser.getDtLastAccess().toString());
          //if it's all ok, redirect on login page
          response.sendRedirect(url);
        }                   
      }
    } catch (EMFUserError eex) {
      errorHandler.addError(eex);
      request.setAttribute(SpagoBIConstants.AUTHENTICATION_FAILED_MESSAGE, eex.getDescription());
      getServletContext().getRequestDispatcher(targetJsp).forward(request, response);
      return;
    } catch (Exception ex) {
      EMFInternalError internalError = new EMFInternalError(EMFErrorSeverity.ERROR, ex);
      errorHandler.addError(internalError);
      request.setAttribute(SpagoBIConstants.AUTHENTICATION_FAILED_MESSAGE, ex.getMessage());
      getServletContext().getRequestDispatcher(targetJsp).forward(request, response);
      return;
    }
     
View Full Code Here

TOP

Related Classes of it.eng.spago.error.EMFErrorHandler

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.