Package com.jamonapi

Examples of com.jamonapi.Monitor


    private static final String ENGINE_NAME = "SpagoBIConsoleEngine";
 

  public void service(SourceBean serviceRequest, SourceBean serviceResponse)  {
    logger.debug("IN")
    Monitor monitor =MonitorFactory.start("SpagoBI_Console.ConsoleEngineStartAction.service");
    Locale locale;
    DataSetServiceProxy proxyDS = null;
    ConsoleEngineInstance consoleEngineInstance = null;
   
    try {
      setEngineName(ENGINE_NAME);
      super.service(serviceRequest, serviceResponse);
     
      logger.debug("User Id: " + getUserId());
      logger.debug("Audit Id: " + getAuditId());
      logger.debug("Document Id: " + getDocumentId());
      logger.debug("Template: " + getTemplateAsString());
           
      if(getAuditServiceProxy() != null) {
        logger.debug("Audit enabled: [TRUE]");
        getAuditServiceProxy().notifyServiceStartEvent();
      } else {
        logger.debug("Audit enabled: [FALSE]");
      }
     
      logger.debug("Creating engine instance ...");
     
      try {
        consoleEngineInstance = ConsoleEngine.createInstance( getTemplateAsJSONObject(), getEnv() );
      } catch(Throwable t) {
        SpagoBIEngineStartupException serviceException;
        String msg = "Impossible to create engine instance for document [" + getDocumentId() + "].";
        Throwable rootException = t;
        while(rootException.getCause() != null) {
          rootException = rootException.getCause();
        }
        String str = rootException.getMessage()!=null? rootException.getMessage(): rootException.getClass().getName();
        msg += "\nThe root cause of the error is: " + str;
        serviceException = new SpagoBIEngineStartupException(ENGINE_NAME, msg, t);
       
       
        throw serviceException;
      }
      logger.debug("Engine instance succesfully created");
     
      locale = (Locale)consoleEngineInstance.getEnv().get(EngineConstants.ENV_LOCALE);
     
      setAttributeInSession( ENGINE_INSTANCE, consoleEngineInstance);   
      setAttribute(ENGINE_INSTANCE, consoleEngineInstance);
     
      setAttribute(LANGUAGE, locale.getLanguage());
      setAttribute(COUNTRY, locale.getCountry());

     
    } 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 {
      monitor.stop();
      logger.debug("OUT");
    }
  }
View Full Code Here


   * @param state
   * @param profile
   * @return
   */
  public static boolean canTest(String state, List folders, IEngUserProfile profile) {
    Monitor monitor =MonitorFactory.start("spagobi.core.ObjectAccessVerifier.canTest");
    logger.debug("IN.state=" + state);
    boolean canTest = false;
    if(isAbleToExec(state, profile)) {

      Iterator folderIt = folders.iterator();
      while(folderIt.hasNext()){
        LowFunctionality folder =(LowFunctionality) folderIt.next();
        canTest = canTestInternal(folder, profile);
        if (canTest){
          logger.debug("OUT.return true");
          monitor.stop();
          return true;
        }
      }
      logger.debug("OUT.return false");
      monitor.stop();
      return false;

    } else{
      logger.debug("OUT.return false");
      monitor.stop();
      return false;
    }
  }
View Full Code Here

    return visibleInstances ;

  }

  public static boolean isAbleToExec(String state, IEngUserProfile profile) {
    Monitor monitor =MonitorFactory.start("spagobi.core.ObjectAccessVerifier.isAbleToExec");
    logger.debug("IN.state=" + state);
    if (state.equals("REL")) {
      logger.debug("OUT.return true");
      monitor.stop();
      return true;
    }
    else if (state.equals("DEV")) {
      try {
        if(profile.isAbleToExecuteAction(SpagoBIConstants.DOCUMENT_MANAGEMENT_ADMIN)||profile.isAbleToExecuteAction(SpagoBIConstants.DOCUMENT_MANAGEMENT_DEV)){
          logger.debug("OUT.return true");
          return true;
        }else if (profile.isAbleToExecuteAction(SpagoBIConstants.DOCUMENT_MANAGEMENT_USER)||profile.isAbleToExecuteAction(SpagoBIConstants.DOCUMENT_MANAGEMENT_TEST)){
          logger.debug("OUT.return false");
          return false;
        }
      } catch (EMFInternalError e) {
        logger.error(e);
      }
    }
    else if (state.equals("TEST")) {
      try {
        if(profile.isAbleToExecuteAction(SpagoBIConstants.DOCUMENT_MANAGEMENT_ADMIN)||profile.isAbleToExecuteAction(SpagoBIConstants.DOCUMENT_MANAGEMENT_TEST)){
          logger.debug("OUT.return true");
          return true;
        }else if (profile.isAbleToExecuteAction(SpagoBIConstants.DOCUMENT_MANAGEMENT_USER)||profile.isAbleToExecuteAction(SpagoBIConstants.DOCUMENT_MANAGEMENT_DEV)){
          logger.debug("OUT.return false");
          return false;
        }
      } catch (EMFInternalError e) {
        logger.error(e);
      }
    } 
    logger.debug("OUT");
    monitor.stop();
    return false;
  }
View Full Code Here

   * @param profile The user profile
   *
   * @return A boolean control value
   */
  public static boolean canDevBIObject(Integer biObjectID, IEngUserProfile profile) {
    Monitor monitor =MonitorFactory.start("spagobi.core.ObjectAccessVerifier.canDevBIObject(Integer biObjectID, IEngUserProfile profile)");
    boolean toReturn = false;
    try {
      logger.debug("IN: obj id = [" + biObjectID + "]; user id = [" + ((UserProfile) profile).getUserId() + "]");
      // if user is administrator, he can develop, no need to make any query to database
      if (profile.isAbleToExecuteAction(SpagoBIConstants.DOCUMENT_MANAGEMENT_ADMIN)) {
        logger.debug("User [" + ((UserProfile) profile).getUserId() + "] is administrator. He can develop every document");
        monitor.stop();
        return true;
      }
      BIObject obj = DAOFactory.getBIObjectDAO().loadBIObjectById(biObjectID);
      toReturn = canDevBIObject(obj, profile);
    } catch (Exception e) {
      logger.error(e);
      monitor.stop();
      return false;
    }
    logger.debug("OUT: returning " + toReturn);
    monitor.stop();
    return toReturn;
  }
View Full Code Here

   * @param profile The user profile
   *
   * @return A boolean control value
   */
  public static boolean canDevBIObject(BIObject obj, IEngUserProfile profile) {
    Monitor monitor =MonitorFactory.start("spagobi.core.ObjectAccessVerifier.canDevBIObject(BIObject obj, IEngUserProfile profile)");
    boolean toReturn = false;
    try {
      logger.debug("IN: obj label = [" + obj.getLabel() + "]; user id = [" + ((UserProfile) profile).getUserId() + "]");
      // if user is administrator, he can develop, no need to make any query to database
      if (profile.isAbleToExecuteAction(SpagoBIConstants.DOCUMENT_MANAGEMENT_ADMIN)) {
        logger.debug("User [" + ((UserProfile) profile).getUserId() + "] is administrator. He can develop every document");
        monitor.stop();
        return true;
      }
      // if user is not an administrator and document is not in DEV state, document cannot be developed
      if (!"DEV".equals(obj.getStateCode())) {
        logger.debug("User [" + ((UserProfile) profile).getUserId() + "] is not an administrator and document is not in DEV state, so it cannot be developed");
        monitor.stop();
        return true;
      }
      // if user is not an administrator and document is in DEV state, we must see if he has development permission
      List folders = obj.getFunctionalities();
      Iterator it = folders.iterator();
      while (it.hasNext()) {
        Integer folderId = (Integer) it.next();
        boolean canDevInFolder = canDev(folderId, profile);
        if (canDevInFolder) {
          logger.debug("User can develop in functionality with id = " + folderId);
          toReturn = true;
          break;
        }
      }
    } catch (Exception e) {
      logger.error("Error while loading BIObject", e);
      monitor.stop();
      return false;
    }
    logger.debug("OUT: returning " + toReturn);
    monitor.stop();
    return toReturn;
  }
View Full Code Here

   *                user profile
   *
   * @return A boolean control value
   */
  public static boolean canExec(Integer folderId, IEngUserProfile profile) {
    Monitor monitor =MonitorFactory.start("spagobi.core.ObjectAccessVerifier.canExec");
    logger.debug("IN");
    LowFunctionality folder = null;
    try {
      folder = DAOFactory.getLowFunctionalityDAO().loadLowFunctionalityByID(folderId, false);
    } catch (Exception e) {
      logger.error("Exception in loadLowFunctionalityByID", e);

      return false;
    } finally {
      monitor.stop();
      logger.debug("OUT");
    }
    return canExecInternal(folder, profile);
  }
View Full Code Here

   *                user profile
   * @return A boolean control value
   */
  private static boolean canExecInternal(LowFunctionality folder, IEngUserProfile profile) {
    logger.debug("IN");
    Monitor monitor =MonitorFactory.start("spagobi.core.ObjectAccessVerifier.canExecInternal");


    Collection roles = null;

    try {
      roles = ((UserProfile)profile).getRolesForUse();
    } catch (EMFInternalError emfie) {
      logger.error("EMFInternalError in profile.getRoles");
      logger.debug("OUT.return false");
      monitor.stop();
      return false;
    }

    if(folder.getCodType().equalsIgnoreCase("USER_FUNCT")){
      monitor.stop();
      return true;
    }
   
    Role[] execRoles = folder.getExecRoles();
    List execRoleNames = new ArrayList();
    for (int i = 0; i < execRoles.length; i++) {
      Role role = execRoles[i];
      execRoleNames.add(role.getName());
    }

    Iterator iterRoles = roles.iterator();
    String roleName = "";
    while (iterRoles.hasNext()) {
      roleName = (String) iterRoles.next();
      if (execRoleNames.contains(roleName)) {
        logger.debug("OUT.return true");
        monitor.stop();
        return true;
      }
    }
    logger.debug("OUT.return false");
    monitor.stop();
    return false;

  }
View Full Code Here

   * @param profile
   *                user profile
   * @return A boolean control value
   */
  private static boolean canTestInternal(LowFunctionality folder, IEngUserProfile profile) {
    Monitor monitor =MonitorFactory.start("spagobi.core.ObjectAccessVerifier.canTestInternal");
    logger.debug("IN");
    Collection roles = null;

    try {
      roles = ((UserProfile)profile).getRolesForUse();
    } catch (EMFInternalError emfie) {
      logger.error("EMFInternalError in profile.getRoles", emfie);
      monitor.stop();
      return false;
    }

    Role[] testRoles = folder.getTestRoles();
    List testRoleNames = new ArrayList();
    for (int i = 0; i < testRoles.length; i++) {
      Role role = testRoles[i];
      testRoleNames.add(role.getName());
    }

    Iterator iterRoles = roles.iterator();
    String roleName = "";
    while (iterRoles.hasNext()) {
      roleName = (String) iterRoles.next();
      if (testRoleNames.contains(roleName)) {
        logger.debug("OUT. return true");
        monitor.stop();
        return true;
      }
    }
    logger.debug("OUT. return false");
    monitor.stop();
    return false;

  }
View Full Code Here

   *                user profile
   * @return A boolean control value
   */
  private static boolean canDevInternal(Integer folderId, IEngUserProfile profile) {
    logger.debug("IN");
    Monitor monitor =MonitorFactory.start("spagobi.core.ObjectAccessVerifier.canDevInternal");
    Collection roles = null;
    try {
        roles = ((UserProfile)profile).getRolesForUse();
     
    } catch (EMFInternalError emfie) {
      logger.error("EMFInternalError in profile.getRoles", emfie);
      logger.debug("OUT. return false");
      monitor.stop();
      return false;
    }

    LowFunctionality funct = null;
    try {
      funct = DAOFactory.getLowFunctionalityDAO().loadLowFunctionalityByID(folderId, false);
    } catch (Exception e) {
      logger.error("EMFInternalError in loadLowFunctionalityByID", e);
      logger.debug("OUT. return false");
      monitor.stop();
      return false;
    }
    Role[] devRoles = funct.getDevRoles();
    List devRoleNames = new ArrayList();
    for (int i = 0; i < devRoles.length; i++) {
      Role role = devRoles[i];
      devRoleNames.add(role.getName());
    }

    Iterator iterRoles = roles.iterator();
    String roleName = "";
    while (iterRoles.hasNext()) {
      roleName = (String) iterRoles.next();
      if (devRoleNames.contains(roleName)) {

        logger.debug("OUT. return true");
        monitor.stop();
        return true;
      }
    }
    logger.debug("OUT. return false");
    monitor.stop();
    return false;

  }
View Full Code Here

   * @throws EMFInternalError
   *                 the EMF internal error
   */
  public static boolean canSee(BIObject obj, IEngUserProfile profile) throws EMFInternalError {
    logger.debug("IN");
    Monitor monitor =MonitorFactory.start("spagobi.core.ObjectAccessVerifier.canSee(BIObject obj, IEngUserProfile profile)");
    boolean canSee = false;
    if (obj == null){
      logger.warn("BIObject in input is null!!");
      monitor.stop();
      throw new EMFInternalError(EMFErrorSeverity.ERROR, "BIObject in input is null!!");
    }
    if (profile == null){
      logger.warn("User profile in input is null!!");
      monitor.stop();
      throw new EMFInternalError(EMFErrorSeverity.ERROR, "User profile in input is null!!");
    }
    String state = obj.getStateCode();
    if ("SUSP".equalsIgnoreCase(state)) {
      monitor.stop();
      return false;
    }


    List foldersId = obj.getFunctionalities();
    if (foldersId == null || foldersId.size() == 0){
      logger.warn("BIObject does not belong to any functionality!!");
      monitor.stop();
      throw new EMFInternalError(EMFErrorSeverity.ERROR, "BIObject does not belong to any functionality!!");
    }
    Iterator foldersIdIt = foldersId.iterator();
    while (foldersIdIt.hasNext()) {
      Integer folderId = (Integer) foldersIdIt.next();
      boolean canDev = canDev(state, folderId, profile);
      if (canDev) {
        canSee = true;
        break;
      }
      boolean canTest = canTest(state, folderId, profile);
      if (canTest) {
        canSee = true;
        break;
      }
      boolean canExec = canExec(state, folderId, profile);
      if (canExec) {
        // administrators, developers, testers, behavioural model administrators can see that document
        if (profile.isAbleToExecuteAction(SpagoBIConstants.DOCUMENT_MANAGEMENT_ADMIN// for administrators
            || profile.isAbleToExecuteAction(SpagoBIConstants.DOCUMENT_MANAGEMENT_DEV// for developers
            || profile.isAbleToExecuteAction(SpagoBIConstants.DOCUMENT_MANAGEMENT_TEST// for testers
            || profile.isAbleToExecuteAction(SpagoBIConstants.PARAMETER_MANAGEMENT)) {  // for behavioral model administrators
          canSee = true;
        } else {
          canSee = checkProfileVisibility(obj, profile);
        }
        break;
      }
    }
    monitor.stop();
    logger.debug("OUT.canSee=" + canSee);
    return canSee;
  }
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.