Package it.eng.spagobi.commons.bo

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


  public UserProfile getUserProfile() {
    return (UserProfile) getParameterFromSession(IEngUserProfile.ENG_USER_PROFILE);
  }

  public String getUserId() {
    UserProfile profile = null;

    if (userId == null) {
      userId = (String) getUserProfile().getUserId();
    }
View Full Code Here


   
    return service;
    }
   
    public IEngUserProfile getUserProfile() throws SecurityException{
      UserProfile userProfile;
     
      logger.debug("IN");
     
      userProfile = null;
    try {
            SpagoBIUserProfile user = lookUp().getUserProfile(readTicket(), userId);
            if (user!=null) userProfile = new UserProfile(user);
            else logger.error("Error occured while retrieving user profile of user [" + userId + "] from service [" + SERVICE_NAME + "] at endpoint [" + serviceUrl + "]. user is null!");
        } catch (Throwable e) {
            logger.error("Error occured while retrieving user profile of user [" + userId + "] from service [" + SERVICE_NAME + "] at endpoint [" + serviceUrl + "]");
            throw new SecurityException("Error occured while retrieving user profile of user [" + userId + "] from service [" + SERVICE_NAME + "] at endpoint [" + serviceUrl + "]", e);
        }finally{
View Full Code Here

  public UserProfile getUserProfile() {
    return (UserProfile) getAttributeFromSession( IEngUserProfile.ENG_USER_PROFILE );
  }

    public String getUserId() {
      UserProfile profile = null;
     
      if(userId == null) {   
          userId = (String)getUserProfile().getUserId();
      }
     
View Full Code Here

     * @return IEngUserProfile with user profile
     *
     * @throws SecurityException if the process has generated an error
     */
    public IEngUserProfile getUserProfile() throws SecurityException{
      UserProfile userProfile;
     
      logger.debug("IN");
     
      userProfile = null;
    try {
            SpagoBIUserProfile user = lookUp().getUserProfile(readTicket(), userId);
            if (user!=null) userProfile = new UserProfile(user);
            else logger.error("Error occured while retrieving user profile of user [" + userId + "] from service [" + SERVICE_NAME + "] at endpoint [" + serviceUrl + "]. user is null!");
        } catch (Throwable e) {
            logger.error("Error occured while retrieving user profile of user [" + userId + "] from service [" + SERVICE_NAME + "] at endpoint [" + serviceUrl + "]");
            throw new SecurityException("Error occured while retrieving user profile of user [" + userId + "] from service [" + SERVICE_NAME + "] at endpoint [" + serviceUrl + "]", e);
        }finally{
View Full Code Here

   
    try {
      // retrieving execution instance from session, no need to check if user is able to execute the current document
      ExecutionInstance executionInstance = getContext().getExecutionInstance( ExecutionInstance.class.getName() );
      BIObject obj = executionInstance.getBIObject();
      UserProfile userProfile = (UserProfile) this.getUserProfile();
      ISubObjectDAO dao = null;
      try {
        dao = DAOFactory.getSubObjectDAO();
      } catch (EMFUserError e) {
        logger.error("Error while istantiating DAO", e);
        throw new SpagoBIServiceException(SERVICE_NAME, "Cannot access database", e);
      }
      String ids = this.getAttributeAsString(SUBOBJECT_ID);
      // ids contains the id of the subobjects to be deleted separated by ,
      String[] idArray = ids.split(",");
      for (int i = 0; i < idArray.length; i++) {
        Integer id = new Integer(idArray[i]);
        SubObject subObject = null;
        try {
          subObject = dao.getSubObject(id);
        } catch (EMFUserError e) {
          logger.error("SubObject with id = " + id + " not found", e);
          throw new SpagoBIServiceException(SERVICE_NAME, "Customized view not found", e);
        }
        if (subObject.getBiobjId().equals(obj.getId())) {
          boolean canDeleteSubObject = false;
          if (userProfile.isAbleToExecuteAction(SpagoBIConstants.DOCUMENT_MANAGEMENT_ADMIN)
              || subObject.getOwner().equals(userProfile.getUserId().toString())) {
            canDeleteSubObject = true;
          }
          if (canDeleteSubObject) {
            logger.info("User [id: " + userProfile.getUserUniqueIdentifier() + ", userId: " + userProfile.getUserId() + ", name: " + userProfile.getUserName() + "] " +
                "is deleting customized view [id: " + subObject.getId() + ", name: " + subObject.getName() + "] ...");
            try {
              dao.deleteSubObject(id);
            } catch (EMFUserError e) {
              throw new SpagoBIServiceException(SERVICE_NAME, "Error while deleting customized view", e);
            }
            logger.debug("Customized view [id: " + subObject.getId() + ", name: " + subObject.getName() + "] deleted.");
          } else {
            logger.error("User [id: " + userProfile.getUserUniqueIdentifier() + ", userId: " + userProfile.getUserId() + ", name: " + userProfile.getUserName() + "] cannot delete customized view");
            throw new SpagoBIServiceException(SERVICE_NAME, "User cannot delete customized view");
          }
        } else {
          logger.error("Cannot delete customized view with id = " + subObject.getBiobjId() + ": " +
              "it is not relevant to the current document [id: " + obj.getId() + ", label: " + obj.getLabel() + ", name: " + obj.getName() + "]");
View Full Code Here

      Domain objType = DAOFactory.getDomainDAO().loadDomainByCodeAndValue(SpagoBIConstants.BIOBJ_TYPE, type);
      Integer biObjectTypeID = objType.getValueId();
      o.setBiObjectTypeID(biObjectTypeID);
      o.setBiObjectTypeCode(objType.getValueCd());
         
      UserProfile userProfile = (UserProfile) this.getUserProfile();
      String creationUser =  userProfile.getUserId().toString();
      o.setCreationUser(creationUser);
      if(dataSourceId!=null && dataSourceId!=""){
        o.setDataSourceId(new Integer(dataSourceId));
     
      List<Integer> functionalities = new ArrayList<Integer>();
View Full Code Here

    logger.debug("IN");
    byte[] content = getTemplateContent();
    ObjTemplate objTemp = createNewTemplate(content);
    ExecutionInstance executionInstance = getContext().getExecutionInstance( ExecutionInstance.class.getName() );
    BIObject biobj = executionInstance.getBIObject();
    UserProfile userProfile = (UserProfile) this.getUserProfile();
    logger.info("User with unique identifier " + userProfile.getUserUniqueIdentifier() + ", id " + userProfile.getUserId()
        + ", name " + userProfile.getUserName() + " is updating document with id " + biobj.getId()
        + ", label " + biobj.getLabel() + ", name " + biobj.getName() + "; new template is:");
    logger.info(new String(objTemp.getContent()));
    objDao.modifyBIObject(biobj, objTemp);
    logger.debug("Template of document with id " + biobj.getId() + ", label " + biobj.getLabel() + ", name " + biobj.getName() + " updated");
    JSONObject response = new JSONObject();
View Full Code Here

  protected ObjTemplate createNewTemplate(byte[] content) {
    logger.debug("IN");
    ObjTemplate objTemp = new ObjTemplate();
    objTemp.setContent(content);
    UserProfile userProfile = (UserProfile) this.getUserProfile();
    objTemp.setCreationUser(userProfile.getUserId().toString());
    objTemp.setDimension(Long.toString(content.length/1000)+" KByte");
    objTemp.setName("template.sbiworksheet");
    logger.debug("OUT");
    return objTemp;
  }
View Full Code Here

    List objects;
   
    logger.debug("IN");
   
    try {
      UserProfile profile = (UserProfile)getUserProfile();

      Vector<String> fieldsToSearch = new Vector<String>();
      String valueFilter = getAttributeAsString(SpagoBIConstants.VALUE_FILTER);
     
      String attributes = getAttributeAsString(ATTRIBUTES);
      String metaDataToSearch = null;
      if(attributes != null){
        if(attributes.equalsIgnoreCase("ALL")){//SEARCH IN ALL FIELDS
          fieldsToSearch.add(IndexingConstants.BIOBJ_LABEL);
          fieldsToSearch.add(IndexingConstants.BIOBJ_NAME);
          fieldsToSearch.add(IndexingConstants.BIOBJ_DESCR);
          fieldsToSearch.add(IndexingConstants.METADATA);
          //search metadata binary content
          fieldsToSearch.add(IndexingConstants.CONTENTS);
          //search subobject fields
          fieldsToSearch.add(IndexingConstants.SUBOBJ_DESCR);
          fieldsToSearch.add(IndexingConstants.SUBOBJ_NAME);
        }else if(attributes.equalsIgnoreCase("LABEL")){//SEARCH IN LABEL DOC
          fieldsToSearch.add(IndexingConstants.BIOBJ_LABEL);
        }else if(attributes.equalsIgnoreCase("NAME")){//SEARCH IN NAME DOC
          fieldsToSearch.add(IndexingConstants.BIOBJ_NAME);
        }else if(attributes.equalsIgnoreCase("DESCRIPTION")){//SEARCH IN DESCRIPTION DOC
          fieldsToSearch.add(IndexingConstants.BIOBJ_DESCR);
        }else{//SEARCH IN CATEGORIES DOC
          //get categories name
          metaDataToSearch = attributes;
          //fieldsToSearch.add(IndexingConstants.METADATA);
          fieldsToSearch.add(IndexingConstants.CONTENTS);
        }
       
      }

      boolean similar = getAttributeAsBoolean(SIMILAR);

      logger.debug("Parameter [" + SpagoBIConstants.VALUE_FILTER + "] is equal to [" + valueFilter + "]");
      String indexBasePath = "";
      String jndiBean = SingletonConfig.getInstance().getConfigValue("SPAGOBI.RESOURCE_PATH_JNDI_NAME");
      if (jndiBean != null) {
        indexBasePath = SpagoBIUtilities.readJndiResource(jndiBean);
      }
      String index = indexBasePath+"/idx";
      IndexReader reader;
      HashMap returned = null;
      try{
        reader = IndexReader.open(FSDirectory.open(new File(index)), true);
        // read-only=true
        IndexSearcher searcher = new IndexSearcher(reader);
       
       
          String[] fields = new String[fieldsToSearch.size()];     
          fieldsToSearch.toArray(fields);

        //getting  documents
       
        if(similar){
          returned = LuceneSearcher.searchIndexFuzzy(searcher, valueFilter, index, fields, metaDataToSearch);
        }else{
          returned = LuceneSearcher.searchIndex(searcher, valueFilter, index, fields, metaDataToSearch);
        }
        ScoreDoc [] hits = (ScoreDoc [])returned.get("hits");
       
        objects = new ArrayList();
        if(hits != null) {
                  for(int i=0; i<hits.length; i++) {
                  ScoreDoc hit = hits[i];
                  Document doc = searcher.doc(hit.doc);
                    String biobjId = doc.get(IndexingConstants.BIOBJ_ID);

                    BIObject obj =DAOFactory.getBIObjectDAO().loadBIObjectForDetail(Integer.valueOf(biobjId));
                    if(obj != null){
                  boolean canSee = ObjectsAccessVerifier.canSee(obj, profile);
                    if (canSee) {
                      objects.add(obj);
                    }                 
                    }
                  }
        }
        searcher.close();
      } catch (CorruptIndexException e) {
        logger.error(e.getMessage(), e);
        throw new SpagoBIException("Index corrupted", e);
       
      } catch (IOException e) {
        logger.error(e.getMessage(), e);
        throw new SpagoBIException("Unable to read index", e);
       
      } // only searching, so
      catch (ParseException e) {
        logger.error(e.getMessage(), e);
        throw new SpagoBIException("Wrong query syntax", e);
       
      }
     
   
      JSONArray documentsJSON = (JSONArray)SerializerFactory.getSerializer("application/json").serialize( objects, null);
      for(int i=0; i<documentsJSON.length();i++){
        JSONObject jsonobj = documentsJSON.getJSONObject(i);
        String biobjid = jsonobj.getString("id");
        String summary = (String)returned.get(biobjid);
        jsonobj.put("summary", summary);
        String views = (String)returned.get(biobjid+"-views");
        jsonobj.put("views", views);
      }
      Collection func = profile.getFunctionalities();
     
      if(func.contains("SeeMetadataFunctionality")){
        JSONObject showmetadataAction = new JSONObject();
        showmetadataAction.put("name", "showmetadata");
        showmetadataAction.put("description", "Show Metadata");
View Full Code Here

   
    try {
      // retrieving execution instance from session, no need to check if user is able to execute the current document
      ExecutionInstance executionInstance = getContext().getExecutionInstance( ExecutionInstance.class.getName() );
      BIObject obj = executionInstance.getBIObject();
      UserProfile userProfile = (UserProfile) this.getUserProfile();
      ISnapshotDAO dao = null;
      try {
        dao = DAOFactory.getSnapshotDAO();
      } catch (EMFUserError e) {
        logger.error("Error while istantiating DAO", e);
        throw new SpagoBIServiceException(SERVICE_NAME, "Cannot access database", e);
      }
      String ids = this.getAttributeAsString(SNAPSHOT_ID);
      // ids contains the id of the snapshots to be deleted separated by ,
      String[] idArray = ids.split(",");
      for (int i = 0; i < idArray.length; i++) {
        Integer id = new Integer(idArray[i]);
        Snapshot snapshot = null;
        try {
          snapshot = dao.loadSnapshot(id);
        } catch (EMFUserError e) {
          logger.error("Snapshot with id = " + id + " not found", e);
          throw new SpagoBIServiceException(SERVICE_NAME, "Scheduled execution not found", e);
        }
        if (snapshot.getBiobjId().equals(obj.getId())) {
          logger.info("User [id: " + userProfile.getUserUniqueIdentifier() + ", userId: " + userProfile.getUserId() + ", name: " + userProfile.getUserName() + "] " +
              "is deleting scheduled execution [id: " + snapshot.getId() + ", name: " + snapshot.getName() + "] ...");
          try {
            dao.deleteSnapshot(id);
          } catch (EMFUserError e) {
            throw new SpagoBIServiceException(SERVICE_NAME, "Error while deleting scheduled execution", 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.