Package it.eng.spagobi.commons.bo

Examples of it.eng.spagobi.commons.bo.UserProfile


     
      if (!image.exists() || image.isDirectory()) {
        throw new FileNotFoundException("Could not find file [" + fileName + "]");
      }
     
      UserProfile userProfile = (UserProfile) getEnv().get(EngineConstants.ENV_USER_PROFILE);
      logger.info("User [id : " + userProfile.getUserId() + ", name : " + userProfile.getUserName() + "] " +
          "is getting file [" + image.getAbsolutePath() + "]");
     
      String mimetype = MimeUtils.getMimeType(image);
     
      try {
View Full Code Here


      FileItem uploaded = (FileItem) request.getAttribute("UPLOADED_FILE");
      if (uploaded == null) {
        throw new SpagoBIEngineServiceException(getActionName(), "No file was uploaded");
      }
       
      UserProfile userProfile = (UserProfile) getEnv().get(EngineConstants.ENV_USER_PROFILE);
      logger.info("User [id : " + userProfile.getUserId() + ", name : " + userProfile.getUserName() + "] " +
          "is uploading file [" + uploaded.getName() + "] with size [" + uploaded.getSize() + "]");
     
      checkUploadedFile(uploaded);
     
      logger.debug("Saving file...");
View Full Code Here

    String jpaQueryStr = statement.getQueryString();
    Integer maxSize = QbeEngineConfig.getInstance().getResultLimit();     
    logger.debug("Configuration setting  [" + "QBE.QBE-SQL-RESULT-LIMIT.value" + "] is equals to [" + (maxSize != null? maxSize: "none") + "]");
    boolean isMaxResultsLimitBlocking = QbeEngineConfig.getInstance().isMaxResultLimitBlocking();
    logger.debug("Executable query (HQL/JPQL): [" +  jpaQueryStr+ "]");
    UserProfile userProfile = (UserProfile)getEnv().get(EngineConstants.ENV_USER_PROFILE);
    auditlogger.info("[" + userProfile.getUserId() + "]:: HQL/JPQL: " + jpaQueryStr)
   
    try {
      logger.debug("Executing query ...");
      dataSet = QbeDatasetFactory.createDataSet(statement);
      dataSet.setAbortOnOverflow(isMaxResultsLimitBlocking);
     
      Map userAttributes = new HashMap();
      UserProfile profile = (UserProfile)this.getEnv().get(EngineConstants.ENV_USER_PROFILE);
      Iterator it = profile.getUserAttributeNames().iterator();
      while(it.hasNext()) {
        String attributeName = (String)it.next();
        Object attributeValue = profile.getUserAttribute(attributeName);
        userAttributes.put(attributeName, attributeValue);
      }
      dataSet.addBinding("attributes", userAttributes);
      dataSet.addBinding("parameters", this.getEnv());
      dataSet.loadData(start, limit, (maxSize == null? -1: maxSize.intValue()));
View Full Code Here

        Monitor monitor =MonitorFactory.start("spagobi.service.security.isAuthorized");
  try {
          validateTicket(token, userId);
    SpagoBIUserProfile profile= supplier.createUserProfile(userId);
    profile.setFunctions(UserUtilities.readFunctionality(profile.getRoles()));
    UserProfile userProfile=new UserProfile(profile);     
    return ObjectsAccessVerifier.canExec(new Integer(idFolder), userProfile);
  } catch (SecurityException e) {
      logger.error("SecurityException", e);
      return false;
  } finally {
View Full Code Here

     * Checks if the user is able to build dataset
     */
    private void checkUser() {
      logger.debug("IN");
      try {
        UserProfile profile = this.getUserProfile();
        if (!profile.isAbleToExecuteAction("DatasetManagement")) {
          throw new SecurityException("User [" +
              "unique identifier: " + profile.getUserUniqueIdentifier() +
              "user id : " + profile.getUserId() +
              "name: " + profile.getUserName() +
              "] cannot build dataset!!");
        }
      } catch (Throwable t) {
        throw new SpagoBIRuntimeException("Cannot verify if user is able to build dataset", t);
      } finally {
View Full Code Here

        logger.debug("Executing query ...");
        dataSet = QbeDatasetFactory.createDataSet(statement);
        dataSet.setAbortOnOverflow(true);
       
        Map userAttributes = new HashMap();
        UserProfile profile = (UserProfile)this.getEnv().get(EngineConstants.ENV_USER_PROFILE);
        Iterator it = profile.getUserAttributeNames().iterator();
        while(it.hasNext()) {
          String attributeName = (String)it.next();
          Object attributeValue = profile.getUserAttribute(attributeName);
          userAttributes.put(attributeName, attributeValue);
        }
        dataSet.addBinding("attributes", userAttributes);
        dataSet.addBinding("parameters", this.getEnv());
        dataSet.loadData();
View Full Code Here

     
      String jpaQueryStr = statement.getQueryString();
      String sqlQuery = statement.getSqlQueryString();
      logger.debug("Executable query (HQL/JPQL): [" +  jpaQueryStr+ "]");
      //logger.debug("Executable query (SQL): [" + sqlQuery + "]");
      UserProfile userProfile = (UserProfile)getEnv().get(EngineConstants.ENV_USER_PROFILE);
      //auditlogger.info("[" + userProfile.getUserId() + "]:: HQL: " + hqlQuery);
      //auditlogger.info("[" + userProfile.getUserId() + "]:: SQL: " + sqlQuery);
     
      // STEP 3: transform the sql query
      FilterQueryTransformer transformer = new FilterQueryTransformer();
      List selectFields = SqlUtils.getSelectFields(sqlQuery);
     
      List queryFields = query.getDataMartSelectFields(true);
      for(int i = 0; i < queryFields.size(); i++) {
        ISelectField queryField = (ISelectField)queryFields.get(i);
        String[] f = (String[])selectFields.get(i)
        transformer.addColumn(f[1]!=null? f[1]:f[0], f[1]!=null? f[1]:f[0]);       
      }
     
      for(int i = 0; i < filters.length(); i++) {
        JSONObject filter = filters.getJSONObject(i);
        String columnName = filter.getString("columnName");
        String value = filter.getString("value");
       
        int fieldIndex = query.getSelectFieldIndex(columnName);       
        String[] f = (String[])selectFields.get(fieldIndex);   
        transformer.addFilter(f[1]!=null? f[1]:f[0], value);
      }
     
      sqlQuery = (String)transformer.transformQuery(sqlQuery);
     
      // put the query into session
      this.setAttributeInSession(LAST_DETAIL_QUERY, sqlQuery);
     
      // STEP 4: execute the query
     
      try {
        logger.debug("Executing query: [" + sqlQuery + "]");
        auditlogger.info("[" + userProfile.getUserId() + "]:: SQL: " + sqlQuery);
       
        dataSet = new JDBCDataSet();
        //Session session = getDatamartModel().getDataSource().getSessionFactory().openSession();
        ConnectionDescriptor connection = (ConnectionDescriptor)getDataSource().getConfiguration().loadDataSourceProperties().get("connection");
        DataSource dataSource = new DataSource();
        dataSource.setJndi(connection.getJndiName());
        dataSource.setHibDialectName(connection.getDialect());
        dataSource.setUrlConnection(connection.getUrl());
        dataSource.setDriver(connection.getDriverClass());
        dataSource.setUser(connection.getUsername());
        dataSource.setPwd(connection.getPassword());
        dataSet.setDataSource(dataSource);
        dataSet.setQuery(sqlQuery);
        dataSet.loadData(start, limit, -1);
        dataStore = dataSet.getDataStore();
        IDataStoreMetaData dataStoreMetadata = dataStore.getMetaData();
        for(int i = 0; i < dataStoreMetadata.getFieldCount(); i++) {
          ISelectField queryField = (ISelectField)queryFields.get(i);
          dataStoreMetadata.changeFieldAlias(i, queryField.getAlias());
        }
      } catch (Exception e) {
        logger.debug("Query execution aborted because of an internal exceptian");
        SpagoBIEngineServiceException exception;
        String message;
       
        message = "An error occurred in " + getActionName() + " service while executing query: [" +  statement.getQueryString() + "]";       
        exception = new SpagoBIEngineServiceException(getActionName(), message, e);
        exception.addHint("Check if the query is properly formed: [" + statement.getQueryString() + "]");
        exception.addHint("Check connection configuration");
        exception.addHint("Check the qbe jar file");
       
        throw exception;
      }
      logger.debug("Query executed succesfully");
     
     
      //dataStore.getMetaData().setProperty("resultNumber", new Integer( (int)dataStore.getRecordsCount() ));
     
      resultNumber = (Integer)dataStore.getMetaData().getProperty("resultNumber");
      Assert.assertNotNull(resultNumber, "property [resultNumber] of the dataStore returned by loadData method of the class [" + dataSet.getClass().getName()+ "] cannot be null");
      logger.debug("Total records: " + resultNumber);     
     
     
      boolean overflow = maxSize != null && resultNumber >= maxSize;
      if (overflow) {
        logger.warn("Query results number [" + resultNumber + "] exceeds max result limit that is [" + maxSize + "]");
        auditlogger.info("[" + userProfile.getUserId() + "]:: max result limit [" + maxSize + "] exceeded with SQL: " + sqlQuery);
      }
           
      dataSetWriter = new JSONDataWriter();
      gridDataFeed = (JSONObject)dataSetWriter.write(dataStore);
     
View Full Code Here

    Iterator it;
    String attributesName;
    JSONArray nodes;
    JSONObject node;
    JSONObject nodeAttributes;
    UserProfile userProfile;
    logger.debug("IN");
   
    try {
      super.service(request, response)
     
      Assert.assertNotNull(getEngineInstance(), "It's not possible to execute " + this.getActionName() + " service before having properly created an instance of EngineInstance class");
      Assert.assertNotNull(getEngineInstance().getEnv(), "It's not possible to execute " + this.getActionName() + " service before having properly created an instance of Env");
     
      userProfile = (UserProfile)getEnv().get(EngineConstants.ENV_USER_PROFILE);
     
     
      nodes = new JSONArray();
      it = userProfile.getUserAttributeNames().iterator();
      while(it.hasNext()) {
        attributesName = (String)it.next();
        node = new JSONObject();
        node.put("id", attributesName);
        node.put("text", attributesName);
View Full Code Here

        logger.debug("Executing query ...");
        dataSet = QbeDatasetFactory.createDataSet(statement);
        dataSet.setAbortOnOverflow(true);
       
        Map userAttributes = new HashMap();
        UserProfile profile = (UserProfile)this.getEnv().get(EngineConstants.ENV_USER_PROFILE);
        Iterator it = profile.getUserAttributeNames().iterator();
        while(it.hasNext()) {
          String attributeName = (String)it.next();
          Object attributeValue = profile.getUserAttribute(attributeName);
          userAttributes.put(attributeName, attributeValue);
        }
        dataSet.addBinding("attributes", userAttributes);
        dataSet.addBinding("parameters", this.getEnv());
        dataSet.loadData(start, limit, (maxSize == null? -1: maxSize.intValue()));
View Full Code Here

      String lovProv = modVal.getLovProvider();
        ILovDetail lovDet = LovDetailFactory.getLovFromXML(lovProv);
      List profAttrToFill = getProfileAttributesToFill(lovDet);
      if(profAttrToFill.size()!=0) {
        //  create a fake user profile
          UserProfile userProfile=new UserProfile((String)((UserProfile)profile).getUserId());
        // copy all the roles, functionalities of the original profile
          userProfile.setFunctionalities(profile.getFunctionalities());
          userProfile.setRoles(((UserProfile)profile).getRolesForUse());
          userProfile.setDefaultRole(((UserProfile)profile).getDefaultRole());
         
        // copy attributes and add the missing ones
        Map attributes = new HashMap();
        Collection origAttrNames = profile.getUserAttributeNames();
          Iterator origAttrNamesIter = origAttrNames.iterator();
          while(origAttrNamesIter.hasNext()) {
            String profileAttrName = (String)origAttrNamesIter.next();
            String profileAttrValue = profile.getUserAttribute(profileAttrName).toString();
            attributes.put(profileAttrName, profileAttrValue);
          }
          Iterator profAttrToFillIter = profAttrToFill.iterator();
          while(profAttrToFillIter.hasNext()) {
            String profileAttrName = (String)profAttrToFillIter.next();
            String profileAttrValue = (String)request.getAttribute(profileAttrName);
            if(profileAttrValue!=null) {
              attributes.put(profileAttrName, profileAttrValue);
            }
          }
          userProfile.setAttributes(attributes);
          session.setAttribute(SpagoBIConstants.USER_PROFILE_FOR_TEST, userProfile);
      }
      response.setAttribute("testLov", "true");
      return;
    } catch (Exception e) {
View Full Code Here

TOP

Related Classes of it.eng.spagobi.commons.bo.UserProfile

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.