Package com.jamonapi

Examples of com.jamonapi.Monitor


   * @throws EMFInternalError
   *                 the EMF internal error
   */
  public static boolean canSee(LowFunctionality lowFunctionality, IEngUserProfile profile) throws EMFInternalError {
    boolean canSee = false;
    Monitor monitor =MonitorFactory.start("spagobi.core.ObjectAccessVerifier.canSee(LowFunctionality lowFunctionality, IEngUserProfile profile)");
    logger.debug("IN: lowFunctionality path = [" + lowFunctionality.getPath() + "]; userId = [" + ((UserProfile) profile).getUserId() + "]");
    // if it is root folder, anybody can see it
    if (lowFunctionality.getParentId() == null) {
      canSee = true;
    } else {
      // if user is administrator, he can see all functionalities
      if (profile.isAbleToExecuteAction(SpagoBIConstants.DOCUMENT_MANAGEMENT_ADMIN)) {
        canSee = true;
      } else {
        // if user can exec or dev or test on functionality, he can see it, otherwise he cannot see it
        if (ObjectsAccessVerifier.canExec(lowFunctionality.getId(), profile) ||
            ObjectsAccessVerifier.canTest(lowFunctionality.getId(), profile) ||
            ObjectsAccessVerifier.canDev(lowFunctionality.getId(), profile)) {
          canSee = true;
        } else {
          canSee = false;
        }
      }
    }
    logger.debug("OUT.canSee=" + canSee);
    monitor.stop();
    return canSee;
  }
View Full Code Here


   * @param profile
   * @return true if document profiled visibility constraints are satisfied by the user
   * @throws EMFInternalError
   */
  public static boolean checkProfileVisibility(BIObject obj, IEngUserProfile profile) throws EMFInternalError {
    Monitor monitor =MonitorFactory.start("spagobi.core.ObjectAccessVerifier.checkProfileVisibility");

    logger.debug("IN: obj label is [" + obj.getLabel() + "]; user is [" + ((UserProfile)profile).getUserId().toString() + "]");
    boolean toReturn = true;
    String profVisibility = obj.getProfiledVisibility();
    if (profVisibility == null || profVisibility.trim().equals("")) {
      logger.debug("Biobject with label [" + obj.getLabel() + "] has no profile visibility contraints.");
      monitor.stop();
      return true;
    }
    logger.debug("Biobject with label [" + obj.getLabel() + "] has profile visibility contraints = [" + profVisibility + "]");
    String[] constraints = profVisibility.split(" AND ");
    for (int i = 0; i < constraints.length; i++) {
      String constraint = constraints[i];
      logger.debug("Examining constraint [" + constraint + "] ...");
      int index = constraint.indexOf("=");
      if (index == -1) {
        logger.error("Constraint [" + constraint + "] is not correct!! It should have the syntax PROFILE_ATTRIBUTE_NAME=VALUE. It will be ignored.");
        continue;
      }
      String profileAttrName = constraint.substring(0, index).trim();
      String value = constraint.substring(index + 1).trim();
      if (!profile.getUserAttributeNames().contains(profileAttrName)) {
        logger.debug("User profile hasn't the required profile attribute [" + profileAttrName + "], it does not satisfy constraint");
        toReturn = false;
        break;
      }
      Object profileAttr = profile.getUserAttribute(profileAttrName);
      if (profileAttr == null) {
        logger.debug("User profile attribute [" + profileAttrName + "] is null, it does not satisfy constraint");
        toReturn = false;
        break;
      }
      String profileAttrStr = profileAttr.toString();
      if (profileAttrStr.startsWith("{")) {
        // the profile attribute is multi-value
        String[] values = null;
        try {
          values = GeneralUtilities.findAttributeValues(profileAttrStr);
        } catch (Exception e) {
          logger.error("Error while reading profile attribute", e);
          logger.debug("User profile attribute [" + profileAttrName + "] does not satisfy constraint");
          toReturn = false;
          break;
        }
        if (!Arrays.asList(values).contains(value)) {
          logger.debug("User profile attribute [" + profileAttrName + "] does not contain [" + value + "] value, it does not satisfy constraint");
          toReturn = false;
          break;
        }
      } else {
        // the profile attribute is single-value
        if (!profileAttrStr.equals(value)) {
          logger.debug("User profile attribute [" + profileAttrName + "] is not equal to [" + value + "], it does not satisfy constraint");
          toReturn = false;
          break;
        }
      }
    }
    logger.debug("OUT.canSee=" + toReturn);
    monitor.stop();
    return toReturn;
  }
View Full Code Here

   * @return the list of correct roles of the input profile for the execution of the document with the specified input
   * @throws EMFUserError
   * @throws EMFInternalError
   */
  public static List getCorrectRolesForExecution(Integer objectId , IEngUserProfile profile) throws EMFInternalError, EMFUserError {
    Monitor monitor =MonitorFactory.start("spagobi.core.ObjectAccessVerifier.getCorrectRolesForExecution");
    logger.debug("IN");
    List correctRoles = null;
    if (profile.isAbleToExecuteAction(SpagoBIConstants.DOCUMENT_MANAGEMENT_DEV)
        || profile.isAbleToExecuteAction(SpagoBIConstants.DOCUMENT_MANAGEMENT_USER)
        || profile.isAbleToExecuteAction(SpagoBIConstants.DOCUMENT_MANAGEMENT_ADMIN)) {
      logger.debug("User is able to execute action");
      correctRoles = DAOFactory.getBIObjectDAO()
      .getCorrectRolesForExecution(objectId, profile);
    } else {
      logger.debug("User is NOT able to execute action");
      correctRoles = DAOFactory.getBIObjectDAO()
      .getCorrectRolesForExecution(objectId);
    }
    logger.debug("OUT");
    monitor.stop();
    return correctRoles;
  }
View Full Code Here

    IDataStore dataStore;
    JSONObject dataSetJSON;
   
   
    logger.debug("IN");
    Monitor monitor =MonitorFactory.start("SpagoBI_Console.ExecuteDataSetAction.service");
   
    try {
      super.service(request,response);
     
      dataSetLabel = getAttributeAsString( DATASET_LABEL );
      logger.debug("Parameter [" + DATASET_LABEL + "] is equals to [" + dataSetLabel + "]");     
      Assert.assertTrue(!StringUtilities.isEmpty( dataSetLabel ), "Parameter [" + DATASET_LABEL + "] cannot be null or empty");
     
      callback = getAttributeAsString( CALLBACK );
      logger.debug("Parameter [" + CALLBACK + "] is equals to [" + callback + "]");
     
      dataSet = null;
      try {
        dataSet = getDataSet(dataSetLabel);
      } catch(Throwable t) {
        throw new SpagoBIServiceException("Impossible to find a dataset whose label is [" + dataSetLabel + "]", t);
      }
      Assert.assertNotNull(dataSet, "Impossible to find a dataset whose label is [" + dataSetLabel + "]");
      Monitor monitorLD =MonitorFactory.start("SpagoBI_Console.ExecuteDataSetAction.service.LoadData")
      dataSet.loadData();
      monitorLD.stop();
      dataStore = dataSet.getDataStore();
      Assert.assertNotNull(dataStore, "The dataStore returned by loadData method of the class [" + dataSet.getClass().getName()+ "] cannot be null");
         
     
      dataSetJSON = null;
View Full Code Here

    logger.debug("OUT");
  }

  private void initBIParameters() {
    logger.debug("IN");
    Monitor monitor =MonitorFactory.start("spagobi.ExecutionInstance.initBIParameters");
    List tmpBIObjectParameters = object.getBiObjectParameters();
    Iterator it = tmpBIObjectParameters.iterator();
    BIObjectParameter aBIObjectParameter = null;
    while (it.hasNext()){
      aBIObjectParameter = (BIObjectParameter) it.next();
      logger.debug("Parameter Label:"+aBIObjectParameter.getLabel());
      // check if the script return an unique value and preload it
      Parameter par = aBIObjectParameter.getParameter();
      if(par != null) {
        ModalitiesValue paruse = par.getModalityValue();
        if (!paruse.getITypeCd().equals("MAN_IN") && paruse.getSelectionType().equals("COMBOBOX")) {  // load values only if not a lookup           
          try {
            String lovProv = paruse.getLovProvider();
            ILovDetail lovProvDet = LovDetailFactory.getLovFromXML(lovProv);
            LovResultCacheManager executionCacheManager = new LovResultCacheManager();
            String lovResult = executionCacheManager.getLovResult(this.userProfile, aBIObjectParameter, this, true);

            LovResultHandler lovResultHandler = new LovResultHandler(lovResult);
            // if the lov is single value and the parameter value is not set, the parameter value
            // is the lov result
            if(lovResultHandler.isSingleValue() && aBIObjectParameter.getParameterValues() == null) {
              aBIObjectParameter.setParameterValues(lovResultHandler.getValues(lovProvDet.getValueColumnName()));
              aBIObjectParameter.setHasValidValues(true);
              aBIObjectParameter.setTransientParmeters(true);
            }
          } catch (Exception e) {
            logger.error(e);
            continue;
          }
        }
      }
    }
    monitor.stop();
    logger.debug("OUT");
  }
View Full Code Here

    logger.debug("OUT");
  }

  public void refreshParametersValues(Map parametersMap, boolean transientMode) {
    logger.debug("IN");
    Monitor monitor =MonitorFactory.start("spagobi.ExecutionInstance.refreshParametersValues");
    List biparams = object.getBiObjectParameters();
    Iterator iterParams = biparams.iterator();
    while (iterParams.hasNext()) {
      BIObjectParameter biparam = (BIObjectParameter) iterParams.next();
      refreshParameter(biparam, parametersMap, transientMode);
    }
    monitor.stop();
    logger.debug("OUT");
  }
View Full Code Here

    String message;
    String user;
    String callback;

    logger.debug("IN");
    Monitor monitor =MonitorFactory.start("SpagoBI_Console.ExecuteUpdateAction.service")
       
    try {
      super.service(request,response);
      consoleEngineInstance = getConsoleEngineInstance();
     
      //check for mandatory parameters            
      user = getAttributeAsString( USER_ID );
      logger.debug("Parameter [" + USER_ID + "] is equals to [" + user + "]");     
      Assert.assertTrue(!StringUtilities.isEmpty( user ), "Parameter [" + USER_ID + "] cannot be null or empty");
     
      callback = getAttributeAsString( CALLBACK );
      logger.debug("Parameter [" + CALLBACK + "] is equals to [" + callback + "]");
     
      IDataSource ds = consoleEngineInstance.getDataSource();           
      DataSourceUtilities utility = new DataSourceUtilities(ds);
      //gets hashmap with all parameters     
      Map<String , Object> params;
      params = getAttributesAsMap()
      JSONObject metaParams = getAttributeAsJSONObject( "metaParams" );
      logger.debug("Parameter [metaParams] is equals to [" + metaParams + "]");
     
      boolean result = utility.executeUpdateQuery(params, metaParams);
      if ( !result ){
        throw new ConsoleEngineRuntimeException("Impossible to perform update statement");   
      }
     
      try {
        writeBackToClient( new JSONAcknowledge() );
      } catch (IOException e) {
        String msg = "Impossible to write back the responce to the client";
        throw new SpagoBIEngineServiceException(getActionName(), msg, e);
      }
     
    } catch (Throwable t) {
      throw SpagoBIEngineServiceExceptionHandler.getInstance().getWrappedException(getActionName(), getEngineInstance(), t);
    } finally {
      monitor.stop();
      logger.debug("OUT");
    }
  }
View Full Code Here

    String message;
    String user;
    String callback;
   
    logger.debug("IN");
    Monitor monitor =MonitorFactory.start("SpagoBI_Console.ExecuteButtonAction.service");
   
    try {
      super.service(request,response);
      ConsoleEngineInstance consoleEngineInstance = getConsoleEngineInstance();
   
      message = getAttributeAsString( MESSAGE );
      logger.debug("Parameter [" + MESSAGE + "] is equals to [" + message + "]");     
      Assert.assertTrue(!StringUtilities.isEmpty( message ), "Parameter [" + MESSAGE + "] cannot be null or empty");
     
      user = getAttributeAsString( USER_ID );
      logger.debug("Parameter [" + USER_ID + "] is equals to [" + user + "]");     
      Assert.assertTrue(!StringUtilities.isEmpty( user ), "Parameter [" + USER_ID + "] cannot be null or empty");
     
      callback = getAttributeAsString( CALLBACK );
      logger.debug("Parameter [" + CALLBACK + "] is equals to [" + callback + "]");
     
     
      //for initial test:
      getEmptyResult(message);
     
    } catch (Throwable t) {
      throw SpagoBIEngineServiceExceptionHandler.getInstance().getWrappedException(getActionName(), getEngineInstance(), t);
    } finally {
      monitor.stop();
      logger.debug("OUT");
    }
  }
View Full Code Here

    IDataStore dataStore;
    JSONObject dataSetJSON;
   
   
    logger.debug("IN");
    Monitor monitor =MonitorFactory.start("SpagoBI_Console.GetErrorListAction.service")
   
    try {
      super.service(request,response);
      ConsoleEngineInstance consoleEngineInstance = getConsoleEngineInstance();
   
      dataSetLabel = getAttributeAsString( DATASET_LABEL );
      logger.debug("Parameter [" + DATASET_LABEL + "] is equals to [" + dataSetLabel + "]");     
      Assert.assertTrue(!StringUtilities.isEmpty( dataSetLabel ), "Parameter [" + DATASET_LABEL + "] cannot be null or empty");
     
      callback = getAttributeAsString( CALLBACK );
      logger.debug("Parameter [" + CALLBACK + "] is equals to [" + callback + "]");
     
      rowId = getAttributeAsString( ID );
      logger.debug("Parameter [" + ID + "] is equals to [" + rowId + "]");
      Assert.assertNotNull(rowId, "Input parameters [" + ID + "] cannot be null");
     
      dataSet = null;
      try {
        dataSet = getDataSet(dataSetLabel);
      } catch(Throwable t) {
        throw new SpagoBIServiceException("Impossible to find a dataset whose label is [" + dataSetLabel + "]", t);
      }
      Assert.assertNotNull(dataSet, "Impossible to find a dataset whose label is [" + dataSetLabel + "]");
        /*
      Map params = new HashMap();
      params.put("id", rowId);
      dataSet.setParamsMap(params);
      */
      Map params = consoleEngineInstance.getAnalyticalDrivers();
      params.put("id", rowId);
      dataSet.setParamsMap(params);
      dataSet.setUserProfileAttributes(UserProfileUtils.getProfileAttributes( (UserProfile) this.getEnv().get(EngineConstants.ENV_USER_PROFILE)));
      Monitor monitorLD =MonitorFactory.start("SpagoBI_Console.GetErrorListAction.service.LoadData")
     
      dataSet.loadData();
      monitorLD.stop();
      dataStore = dataSet.getDataStore();
      Assert.assertNotNull(dataStore, "The dataStore returned by loadData method of the class [" + dataSet.getClass().getName()+ "] cannot be null");
         
      dataStore.getMetaData().setProperty("detailProperty", ERRORS_DETAIL_COLUMN);
      //int fieldIndex = dataStore.getMetaData().getFieldIndex(ERRORS_DETAIL_COLUMN);
View Full Code Here

    String pidParam = null;
    Integer resourceIdParam = null;
   

    logger.debug("IN");
    Monitor monitor =MonitorFactory.start("SpagoBI_Console.NotifyStartAction.service")

    conn = null;
    stmt = null;
    try {
      super.service(request,response);
   
     
      //check for mandatory parameters            
      user = getAttributeAsString( USER_ID );
      logger.debug("Parameter [" + USER_ID + "] is equals to [" + user + "]");     
      Assert.assertTrue(!StringUtilities.isEmpty( user ), "Parameter [" + USER_ID + "] cannot be null or empty");
     
      idService = this.getAttributeAsInteger( ID_SERVICE );
      logger.debug("Parameter [" + ID_SERVICE + "] is equals to [" + idService + "]");     
      Assert.assertNotNull(idService, "Parameter [" + ID_SERVICE + "] cannot be null or empty");
     
      pid = getAttributeAsString( PID );
      logger.debug("Parameter [" + PID + "] is equals to [" + pid + "]");     
      Assert.assertTrue(!StringUtilities.isEmpty( pid ), "Parameter [" + PID + "] cannot be null or empty");
     
      resourceName = getAttributeAsString( RESOURCE_NAME );
      logger.debug("Parameter [" + RESOURCE_NAME + "] is equals to [" + resourceName + "]");     
      Assert.assertTrue(!StringUtilities.isEmpty( resourceName ), "Parameter [" + RESOURCE_NAME + "] cannot be null or empty");
     
      formatDate = getAttributeAsString( FORMAT_DATE );
      logger.debug("Parameter [" + FORMAT_DATE + "] is equals to [" + formatDate + "]");     

     
      dataSource = getConsoleEngineInstance().getDataSource()
      conn = dataSource.getConnection();
      conn.setAutoCommit(false);

     
      sql = "INSERT INTO SERVICE_INSTANCE "
          + "(ID_SERVICE_INSTANCE, " +          // 1
              "ID_SERVICE, " +            // 2
              "ID_TARGET_SERVICE_INSTANCE, " +    // 3
              "MESSAGE_ID, " +            // 4
              "CORRELATION_ID, " +          // 5
              "STATE, " +                // 6
              "STARTDATE, " +              // 7
              "ENDDATE, " +              // 8
              "LABEL, " +                // 9
              "MARKER, " +              // 10
              "MONITOR_CHECK, " +            // 11
              "ERRORS_CHECK, " +            // 12
              "ALARMS_CHECK, " +            // 13
              "VIEWS_CHECK, " +            // 14
              "USER_ID, " +              // 15
              "TS_UPDATE, " +              // 16
              "RESOURCE_ID) "              // 17
          + "VALUES "
          + " (?, ?, NULL, NULL, NULL, " +
            "0, ?, to_date('12/12/9999','dd/MM/yyyy'), ?, 0, " +
            "0, 0, 0, 0, NULL, ?, ?)";
           
      if (formatDate != null){
        //sets the format specified into template
        String dateStr = new SimpleDateFormat(formatDate).format(new Timestamp(System.currentTimeMillis())); //HH --> hh24
        sysDate = Timestamp.valueOf(dateStr);
      }else{
        sysDate = new Timestamp( System.currentTimeMillis() );
      }
     
      // sysDate = new Date( System.currentTimeMillis() );
      logger.debug("Query parameter [sysDate] is equals to [" + sysDate + "]");     
     
      idServiceInstanceParam = getIdServiceInstance(conn);
      logger.debug("Query parameter [idServiceInstanceParam] is equals to [" + idServiceInstanceParam + "]");     
     
      idServiceParam = idService;
      logger.debug("Query parameter [idServiceParam] is equals to [" + idServiceParam + "]");   
   
      pidParam = pid;
      logger.debug("Query parameter [pid] is equals to [" + pidParam + "]");     
     
      resourceIdParam = getResourceId(conn, resourceName);
      logger.debug("Query parameter [resourceIdParam] is equals to [" + resourceIdParam + "]");     
   
      try {
        stmt = conn.prepareStatement(sql);
      } catch (SQLException e) {
        throw new ConsoleEngineRuntimeException("Impossible to create a prepared statement for query [" + sql + "]", e);
      }
     
      try {
        stmt.setDouble(1, idServiceInstanceParam);
        stmt.setInt(2, idServiceParam);
        //stmt.setDate(3, sysDate);
        stmt.setTimestamp(3, sysDate);
        stmt.setString(4, pidParam);
        //stmt.setDate(5, sysDate);
        stmt.setTimestamp(5, sysDate);
        stmt.setInt(6, resourceIdParam.intValue());
      } catch (SQLException e) {
        throw new ConsoleEngineRuntimeException("Impossible to set the value of the parameter [resourceName] to [" + resourceName + "] in query [" + sql + "]", e);
      }
      logger.debug("Prameters has been  succesfully replaced in statement  [" + stmt.toString() + "]");
     
      try {
        stmt.executeUpdate();
      } catch (SQLException e) {
          logger.error("Query parameter [pid] is equals to [" + pidParam + "]");
          logger.error("Query parameter [resourceIdParam] is equals to [" + resourceIdParam + "]");
          logger.error("Query parameter [idServiceParam] is equals to [" + idServiceParam + "]");
          logger.error("Query parameter [sysDate] is equals to [" + sysDate + "]");
          logger.error("Query parameter [idServiceInstanceParam] is equals to [" + idServiceInstanceParam + "]");
        throw new ConsoleEngineRuntimeException("Impossible to execute statement [" + stmt.toString() + "]", e);
      }
      logger.debug("Statement [" + stmt.toString() + "] has been  succesfully executed");
   
      conn.commit();
               
      try {
        writeBackToClient( new JSONAcknowledge() );
      } catch (IOException e) {
        String msg = "Impossible to write back the responce to the client";
        throw new SpagoBIEngineServiceException(getActionName(), msg, e);
      }
     
    } catch (Throwable t) {
      throw SpagoBIEngineServiceExceptionHandler.getInstance().getWrappedException(getActionName(), getEngineInstance(), t);
    } finally {
      releaseResources(conn, stmt, null);
      monitor.stop();
      logger.debug("OUT");
    }
  }
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.