Package com.jamonapi

Examples of com.jamonapi.Monitor


     *
     * @return the content
     */
    public Content readTemplateByLabel(String token, String user, String label, HashMap attributes) {

  Monitor monitor =MonitorFactory.start("spagobi.service.content.readTemplate");
        logger.debug("IN");
        try {
            validateTicket(token,user);
            ContentServiceImplSupplier c=new ContentServiceImplSupplier();
      return c.readTemplateByLabel(user, label, attributes);
  } catch (Exception e) {
      logger.error("Exception",e);
      return null;
  }finally{
      monitor.stop();
      logger.debug("OUT");
  }       
    }
View Full Code Here


     *
     * @return the content
     */
    public Content readSubObjectContent(String token,String user,String subObjectId){
        logger.debug("IN");
        Monitor monitor =MonitorFactory.start("spagobi.service.content.readSubObjectContent");
        try {
            validateTicket(token,user);
            return readSubObjectContent(user,subObjectId);
  } catch (SecurityException e) {
      logger.error("SecurityException",e);
      return null;
  }finally{
      monitor.stop();     
      logger.debug("OUT");
  }

    }
View Full Code Here

     *
     * @return the content
     */
    public Content readSubObjectContent(String token,String user,String subObjectName, Integer objId){
        logger.debug("IN");
        Monitor monitor =MonitorFactory.start("spagobi.service.content.readSubObjectContent");
        try {
            validateTicket(token,user);
            return readSubObjectContent(user, subObjectName, objId);
  } catch (SecurityException e) {
      logger.error("SecurityException",e);
      return null;
  }finally{
      monitor.stop();     
      logger.debug("OUT");
  }

    }
View Full Code Here

     *
     * @return the string
     */
    public String saveSubObject(String token,String user,String documentiId,String analysisName,String analysisDescription,String visibilityBoolean,String content){
        logger.debug("IN");
        Monitor monitor =MonitorFactory.start("spagobi.service.content.saveSubObject");
        try {
            validateTicket(token,user);
            IEngUserProfile profile = GeneralUtilities.createNewUserProfile(user);
            if (!profile.getFunctionalities().contains(SpagoBIConstants.SAVE_SUBOBJECT_FUNCTIONALITY)) {
              logger.debug("KO - User " + user + " cannot save subobjects");
              return "KO - You cannot save subobjects";
            }
            String userId = ((UserProfile)profile).getUserId().toString();
            //return saveSubObject(user,documentiId,analysisName,analysisDescription,visibilityBoolean,content);
            return saveSubObject(userId,documentiId,analysisName,analysisDescription,visibilityBoolean,content);
  } catch (SecurityException e) {
      logger.error("SecurityException",e);
      return null;
  } catch (Exception e) {
      logger.error(e);
      return null;
  }finally{
      monitor.stop();    
      logger.debug("OUT");
 

    }
View Full Code Here

     *
     * @return the string
     */
    public String saveObjectTemplate(String token,String user,String documentiId,String templateName,String content){
        logger.debug("IN");
        Monitor monitor =MonitorFactory.start("spagobi.service.content.saveObjectTemplate");
        try {
            validateTicket(token,user);
            return saveObjectTemplate(user,documentiId,templateName,content);
  } catch (SecurityException e) {
      logger.error("SecurityException",e);
      return null;
  }finally{
      monitor.stop();    
      logger.debug("OUT");
  }

    }
View Full Code Here

  super();
    }

    //read the template of svg file from the db and create a content object
    public Content readMap(String token,String user,String mapName){
      Monitor monitor =MonitorFactory.start("spagobi.service.content.readMap");
        logger.debug("IN");
        logger.debug("mapName = " +mapName);
        Content content = new Content();
        try {
            validateTicket(token,user);
            GeoMap tmpMap =  DAOFactory.getSbiGeoMapsDAO().loadMapByName(mapName);
            if (tmpMap == null) {
              logger.info("Map with name " + mapName + " not found on db.");
              return null;
            }
            byte[] template = DAOFactory.getBinContentDAO().getBinContent(tmpMap.getBinId());
  
            if (template == null)
            {
              logger.info("Template map is empty. Try uploadyng the svg.");
              return null;
            }
            BASE64Encoder bASE64Encoder = new BASE64Encoder();
          content.setContent(bASE64Encoder.encode(template));
          logger.debug("template read");
          content.setFileName(mapName +".svg");
         
          return content;
       
    } catch (Throwable e) {
        logger.error("Exception",e);
        throw new RuntimeException("Exception occured while retrieving map from db", e);
    }finally{
        monitor.stop();
        logger.debug("OUT");
    }       
    }
View Full Code Here

     * @return the string
     */
    public String mapCatalogue(String token, String user, String operation,String path,String featureName,String mapName) {

  logger.debug("IN");
  Monitor monitor =MonitorFactory.start("spagobi.service.content.mapCatalogue");
  try {
      validateTicket(token, user);
      return mapCatalogue(user, operation, path, featureName, mapName);
  } catch (SecurityException e) {
      logger.error("SecurityException", e);
      return null;
  } finally {
      monitor.stop();
      logger.debug("OUT");
 

    }
View Full Code Here

    /* (non-Javadoc)
     * @see javax.servlet.http.HttpServlet#service(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
     */
    public void service(HttpServletRequest request, HttpServletResponse response)
            throws IOException, ServletException {
        Monitor monitor = null;
      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());
                  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
            // forza la scrittura sul database
            synchronized (session) {
                session.setAttribute(Constants.REQUEST_CONTAINER, session.getAttribute(Constants.REQUEST_CONTAINER));
            } // synchronized (session)
           
            TracerSingleton.log(Constants.NOME_MODULO, TracerSingleton.DEBUG,
                    "AdapterHTTP::service: responseContainer", responseContainer);
            TracerSingleton.log(Constants.NOME_MODULO, TracerSingleton.DEBUG,
                    "AdapterHTTP::service: sessionContainer", requestContainer
                            .getSessionContainer());

            if (serializeSession) {
                TracerSingleton
                        .log(Constants.NOME_MODULO, TracerSingleton.DEBUG,
                                "AdapterHTTP::service: sessionContainer size ["
                                        + Serializer.serialize(requestContainer
                                                .getSessionContainer()).length + "]");
            }

            render(requestContext, serviceException);
        } // try
        catch (Exception ex) {
            TracerSingleton.log(Constants.NOME_MODULO, TracerSingleton.CRITICAL,
                    "AdapterHTTP::service: ", ex);
        } // catch (Excpetion ex) try
        finally {
            RequestContainer.delRequestContainer();
            ResponseContainer.delResponseContainer();
            if (monitor != null) {
                monitor.stop();
            }
           
            if (eventNotifier != null) {
              eventNotifier.notifyEvent(
                new ServiceEndEvent(null),
View Full Code Here

    String executionContext;
    String executionId;
    String documentLabel;
    String outputType;
   
    Monitor hitsPrimary = null;
        Monitor hitsByDate = null;
        Monitor hitsByUserId = null;
        Monitor hitsByDocumentId = null;
        Monitor hitsByExecutionContext = null;
   
   
    logger.debug("IN");   
   
    try {
      setEngineName(ENGINE_NAME);
      super.service(serviceRequest, serviceResponse);
     
      //if(true) throw new SpagoBIEngineStartupException(getEngineName(), "Test exception");
           
      logger.debug("User Id: " + getUserId());
      logger.debug("Audit Id: " + getAuditId());
      logger.debug("Document Id: " + getDocumentId());
      logger.debug("Template: " + getTemplateAsSourceBean())
     
      hitsPrimary = MonitorFactory.startPrimary("GeoEngine.requestHits");
          hitsByDate = MonitorFactory.start("GeoEngine.requestHits." + DateFormat.getDateInstance(DateFormat.SHORT).format(new Date()));
          hitsByUserId = MonitorFactory.start("GeoEngine.requestHits." + getUserId());
          hitsByDocumentId = MonitorFactory.start("GeoEngine.requestHits." + getDocumentId());
     
     
      executionContext = getAttributeAsString( EXECUTION_CONTEXT );
      logger.debug("Parameter [" + EXECUTION_CONTEXT + "] is equal to [" + executionContext + "]");
     
      executionId = getAttributeAsString( EXECUTION_ID );
      logger.debug("Parameter [" + EXECUTION_ID + "] is equal to [" + executionId + "]");
     
      documentLabel = getAttributeAsString( DOCUMENT_LABEL );
      logger.debug("Parameter [" + DOCUMENT_LABEL + "] is equal to [" + documentLabel + "]");
     
      outputType = getAttributeAsString(OUTPUT_TYPE);
      logger.debug("Parameter [" + OUTPUT_TYPE + "] is equal to [" + outputType + "]");
     
      logger.debug("Execution context: " + executionContext);
      String isDocumentCompositionModeActive = (executionContext != null && executionContext.equalsIgnoreCase("DOCUMENT_COMPOSITION") )? "TRUE": "FALSE";
      logger.debug("Document composition mode active: " + isDocumentCompositionModeActive);
     
      hitsByExecutionContext = MonitorFactory.start("GeoEngine.requestHits." + (isDocumentCompositionModeActive.equalsIgnoreCase("TRUE")?"compositeDocument": "singleDocument"));
     
     
      env = getEnv("TRUE".equalsIgnoreCase(isDocumentCompositionModeActive), documentLabel, executionId);
      if( outputType != null ) {
        env.put(GeoEngineConstants.ENV_OUTPUT_TYPE, outputType);
      }     
     
      geoEngineInstance = GeoEngine.createInstance(getTemplateAsSourceBean(), env);
      geoEngineInstance.setAnalysisMetadata( getAnalysisMetadata() );
     
      analysisStateRowData = getAnalysisStateRowData();
      if(analysisStateRowData != null) {
        logger.debug("AnalysisStateRowData: " + new String(analysisStateRowData));
        analysisState = new GeoEngineAnalysisState( );
        analysisState.load( analysisStateRowData );
        logger.debug("AnalysisState: " + analysisState.toString());
      } else {
        logger.debug("AnalysisStateRowData: NULL");
      }
      if(analysisState != null) {
        geoEngineInstance.setAnalysisState( analysisState );
      }
     
      String selectedMeasureName  = getAttributeAsString("default_kpi");
      logger.debug("Parameter [" + "default_kpi" + "] is equal to [" + selectedMeasureName + "]");
     
      if(!StringUtilities.isEmpty(selectedMeasureName)) {
        geoEngineInstance.getMapRenderer().setSelectedMeasureName(selectedMeasureName);
      }
     
     
      if("TRUE".equalsIgnoreCase(isDocumentCompositionModeActive)){
        setAttribute(DynamicPublisher.PUBLISHER_NAME, "SIMPLE_UI_PUBLISHER");
      } else {
        setAttribute(DynamicPublisher.PUBLISHER_NAME, "AJAX_UI_PUBLISHER");
      }
     
     
      String id = getAttributeAsString("SBI_EXECUTION_ID");
      setAttributeInSession(GEO_ENGINE_INSTANCE, geoEngineInstance);         
    } catch (Exception e) {
      SpagoBIEngineStartupException serviceException = null;
           
      if(e instanceof SpagoBIEngineStartupException) {
        serviceException = (SpagoBIEngineStartupException)e;
      } else {
        Throwable rootException = e;
        while(rootException.getCause() != null) {
          rootException = rootException.getCause();
        }
        String str = rootException.getMessage()!=null? rootException.getMessage(): rootException.getClass().getName();
        String message = "An unpredicted error occurred while executing " + getEngineName() + " service."
                 + "\nThe root cause of the error is: " + str;
       
        serviceException = new SpagoBIEngineStartupException(getEngineName(), message, e);
      }
     
      throw serviceException;
    } finally {
      if(hitsByExecutionContext != null) hitsByExecutionContext.stop();
      if(hitsByDocumentId != null) hitsByDocumentId.stop();
      if(hitsByUserId != null) hitsByUserId.stop();
      if(hitsByDate != null) hitsByDate.stop();
      if(hitsPrimary != null) hitsPrimary.stop();
     
    }
   

    // Put draw Map Action
   
    String outputFormat = null;
    File maptmpfile = null;
    boolean inlineResponse;
    String responseFileName;
    Monitor totalTimeMonitor = null;
    Monitor totalTimePerFormatMonitor = null;
    Monitor flushingResponseTotalTimeMonitor = null;
    Monitor errorHitsMonitor = null;
 
    logger.debug("IN");
   
    try {   
      super.service(serviceRequest, serviceResponse);
     
      totalTimeMonitor = MonitorFactory.start("GeoEngine.drawMapAction.totalTime");
     
      //executionId = getAttributeAsString( "SBI_EXECUTION_ID" );
     
      outputFormat = getAttributeAsString( OUTPUT_FORMAT );   
      logger.debug("Parameter [" + OUTPUT_FORMAT + "] is equal to [" + outputFormat + "]");
     
     
      inlineResponse = getAttributeAsBoolean( INLINE_RESPONSE, true );   
      logger.debug("Parameter [" + INLINE_RESPONSE + "] is equal to [" + inlineResponse + "]");
     
      if(getAuditServiceProxy() != null) getAuditServiceProxy().notifyServiceStartEvent();

      IEngineInstance iEngInst=(IEngineInstance)getAttributeFromSession( EngineConstants.ENGINE_INSTANCE );
      GeoEngineInstance geoInstance=(GeoEngineInstance)iEngInst;

      if(outputFormat == null) {
        logger.info("Parameter [" + outputFormat + "] not specified into request");
       
        //outputFormat = (String)((GeoEngineInstance)).getEnv().get(GeoEngineConstants.ENV_OUTPUT_TYPE);
        outputFormat = (String)geoInstance.getEnv().get(GeoEngineConstants.ENV_OUTPUT_TYPE);
        logger.debug("Env Parameter [" + GeoEngineConstants.ENV_OUTPUT_TYPE + "] is equal to [" + outputFormat + "]");
      }
     
      if(outputFormat == null) {
        logger.info("Parameter [" + GeoEngineConstants.ENV_OUTPUT_TYPE + "] not specified into environment");
        outputFormat = DEFAULT_OUTPUT_TYPE;
      }
     
      totalTimePerFormatMonitor = MonitorFactory.start("GeoEngine.drawMapAction." + outputFormat + "totalTime");
     
     
      try {
        if(outputFormat.equalsIgnoreCase(GeoEngineConstants.PDF)){
          maptmpfile = geoInstance.renderMap( GeoEngineConstants.JPEG );
         
        }else{
          maptmpfile = geoInstance.renderMap( outputFormat );
        }
      } catch (Throwable t) {
         throw new DrawMapServiceException(getActionName(), "Impossible to render map", t);
      }
     
      responseFileName = "map.svg";
     
      IStreamEncoder encoder = null;
      File tmpFile = null;
      if(outputFormat.equalsIgnoreCase(GeoEngineConstants.JPEG)) {
        encoder = new SVGMapConverter();
        responseFileName =  "map.jpeg";
      }else if(outputFormat.equalsIgnoreCase(GeoEngineConstants.PDF)){
       
        encoder = new SVGMapConverter();
        BufferedInputStream bis = null;
       
        String dirS = System.getProperty("java.io.tmpdir");
        File imageFile = null;
        bis = new BufferedInputStream( new FileInputStream(maptmpfile) );
        try {
          int contentLength = 0;
          int b = -1;
          String contentFileName = "tempJPEGExport";
          freezeHttpResponse();
                   
          File dir = new File(dirS);
          imageFile = File.createTempFile("tempJPEGExport", ".jpeg" , dir);
          FileOutputStream stream = new FileOutputStream(imageFile);
         
          encoder.encode(bis,stream);
         
          stream.flush();
          stream.close();   
         
          File dirF = new File(dirS);
            tmpFile = File.createTempFile("tempPDFExport", ".pdf", dirF);
            Document pdfDocument = new Document();
            PdfWriter docWriter = PdfWriter.getInstance(pdfDocument, new FileOutputStream(tmpFile));
            pdfDocument.open();
            Image jpg = Image.getInstance(imageFile.getPath());
            jpg.setRotation(new Double(Math.PI/2).floatValue());
            jpg.scaleAbsolute(770, 520);
            pdfDocument.add(jpg);
            pdfDocument.close();
            docWriter.close();
            maptmpfile = tmpFile;
         
        } finally {
          bis.close();
          if(imageFile!=null)imageFile.delete();
        }   

        responseFileName =  "map.pdf";
        encoder = null;
       
      }
     
      try {
        flushingResponseTotalTimeMonitor = MonitorFactory.start("GeoEngine.drawMapAction.flushResponse.totalTime");
        writeBackToClient(maptmpfile, encoder, inlineResponse, responseFileName, getContentType(outputFormat));
       
      } catch(IOException e) {
        logger.error("error while flushing output", e);
        if(getAuditServiceProxy() != null) getAuditServiceProxy().notifyServiceErrorEvent( "Error while flushing output" );
        throw new DrawMapServiceException(getActionName(), "Error while flushing output", e);
      }
     
      if(getAuditServiceProxy() != null) getAuditServiceProxy().notifyServiceEndEvent( );
     
      maptmpfile.delete()
      if(tmpFile!=null)tmpFile.delete();
     
    } catch (Throwable t) {
      errorHitsMonitor = MonitorFactory.start("GeoEngine.errorHits");
      errorHitsMonitor.stop();
      DrawMapServiceException wrappedException;
      if(t instanceof DrawMapServiceException) {
        wrappedException = (DrawMapServiceException)t;
      } else {
        wrappedException = new DrawMapServiceException(getActionName(), "An unpredicted error occurred while executing " + getActionName() + " service", t);
View Full Code Here

    String executionContext;
    String executionId;
    String documentLabel;
    String outputType;
   
    Monitor hitsPrimary = null;
        Monitor hitsByDate = null;
        Monitor hitsByUserId = null;
        Monitor hitsByDocumentId = null;
        Monitor hitsByExecutionContext = null;
   
   
    logger.debug("IN");   
   
    try {
      setEngineName(ENGINE_NAME);
      super.service(serviceRequest, serviceResponse);
     
      //if(true) throw new SpagoBIEngineStartupException(getEngineName(), "Test exception");
           
      logger.debug("User Id: " + getUserId());
      logger.debug("Audit Id: " + getAuditId());
      logger.debug("Document Id: " + getDocumentId());
      //logger.debug("Template: " + getTemplateAsSourceBean()); 
     
      hitsPrimary = MonitorFactory.startPrimary("GeoEngine.requestHits");
          hitsByDate = MonitorFactory.start("GeoEngine.requestHits." + DateFormat.getDateInstance(DateFormat.SHORT).format(new Date()));
          hitsByUserId = MonitorFactory.start("GeoEngine.requestHits." + getUserId());
          hitsByDocumentId = MonitorFactory.start("GeoEngine.requestHits." + getDocumentId());
     
     
      executionContext = getAttributeAsString( EXECUTION_CONTEXT );
      logger.debug("Parameter [" + EXECUTION_CONTEXT + "] is equal to [" + executionContext + "]");
     
      executionId = getAttributeAsString( EXECUTION_ID );
      logger.debug("Parameter [" + EXECUTION_ID + "] is equal to [" + executionId + "]");
     
      documentLabel = getAttributeAsString( DOCUMENT_LABEL );
      logger.debug("Parameter [" + DOCUMENT_LABEL + "] is equal to [" + documentLabel + "]");
     
      outputType = getAttributeAsString(OUTPUT_TYPE);
      logger.debug("Parameter [" + OUTPUT_TYPE + "] is equal to [" + outputType + "]");
     
      logger.debug("Execution context: " + executionContext);
      String isDocumentCompositionModeActive = (executionContext != null && executionContext.equalsIgnoreCase("DOCUMENT_COMPOSITION") )? "TRUE": "FALSE";
      logger.debug("Document composition mode active: " + isDocumentCompositionModeActive);
     
      hitsByExecutionContext = MonitorFactory.start("GeoEngine.requestHits." + (isDocumentCompositionModeActive.equalsIgnoreCase("TRUE")?"compositeDocument": "singleDocument"));
     
     
      env = getEnv("TRUE".equalsIgnoreCase(isDocumentCompositionModeActive), documentLabel, executionId);
      if( outputType != null ) {
        env.put(GeoEngineConstants.ENV_OUTPUT_TYPE, outputType);
      }     
     
      try {
      geoEngineInstance = GeoEngine.createInstance(getTemplateAsSourceBean(), env);
      } catch (Throwable t) {
        Throwable rootException = t;
        while(rootException.getCause() != null) {
          rootException = rootException.getCause();
        }
        String str = rootException.getMessage()!=null? rootException.getMessage(): rootException.getClass().getName();
       
        SpagoBIEngineStartupException se = new SpagoBIEngineStartupException(getEngineName(), "Impossible to create engine instance. \nThe root cause of the error is: " + str, t);
        throw se;
      }
     
      geoEngineInstance.setAnalysisMetadata( getAnalysisMetadata() );
     
      analysisStateRowData = getAnalysisStateRowData();
      if(analysisStateRowData != null) {
        logger.debug("AnalysisStateRowData: " + new String(analysisStateRowData));
        analysisState = new GeoEngineAnalysisState( );
        analysisState.load( analysisStateRowData );
        logger.debug("AnalysisState: " + analysisState.toString());
      } else {
        logger.debug("AnalysisStateRowData: NULL");
      }
      if(analysisState != null) {
        geoEngineInstance.setAnalysisState( analysisState );
      }
     
      String selectedMeasureName  = getAttributeAsString("default_kpi");
      logger.debug("Parameter [" + "default_kpi" + "] is equal to [" + selectedMeasureName + "]");
     
      if(!StringUtilities.isEmpty(selectedMeasureName)) {
        geoEngineInstance.getMapRenderer().setSelectedMeasureName(selectedMeasureName);
      }
     
     
      if("TRUE".equalsIgnoreCase(isDocumentCompositionModeActive)){
        setAttribute(DynamicPublisher.PUBLISHER_NAME, "SIMPLE_UI_PUBLISHER");
      } else {
        setAttribute(DynamicPublisher.PUBLISHER_NAME, "AJAX_UI_PUBLISHER");
      }
     
     
      String id = getAttributeAsString("SBI_EXECUTION_ID");
      setAttributeInSession(GEO_ENGINE_INSTANCE, geoEngineInstance);         
    } catch (Exception e) {
      SpagoBIEngineStartupException serviceException = null;
           
      if(e instanceof SpagoBIEngineStartupException) {
        serviceException = (SpagoBIEngineStartupException)e;
      } else {
        Throwable rootException = e;
        while(rootException.getCause() != null) {
          rootException = rootException.getCause();
        }
        String str = rootException.getMessage()!=null? rootException.getMessage(): rootException.getClass().getName();
        String message = "An unpredicted error occurred while executing " + getEngineName() + " service."
                 + "\nThe root cause of the error is: " + str;
       
        serviceException = new SpagoBIEngineStartupException(getEngineName(), message, e);
      }
     
      throw serviceException;
    } finally {
      if(hitsByExecutionContext != null) hitsByExecutionContext.stop();
      if(hitsByDocumentId != null) hitsByDocumentId.stop();
      if(hitsByUserId != null) hitsByUserId.stop();
      if(hitsByDate != null) hitsByDate.stop();
      if(hitsPrimary != null) hitsPrimary.stop();
     
View Full Code Here

TOP

Related Classes of com.jamonapi.Monitor

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.