Package it.eng.spagobi.utilities.exceptions

Examples of it.eng.spagobi.utilities.exceptions.SpagoBIServiceException


            String dsMetadata = getDatasetTestMetadata(ds, h, profile)
            dsActiveDetail.setDsMetadata(dsMetadata);
          }             
        }else{
          logger.error("DataSet type is not existent");
          throw new SpagoBIServiceException(SERVICE_NAME,  "sbi.ds.dsTypeError");
        }
      } catch (Exception e) {
        logger.error("Error while getting dataset metadataa",e);
      }
    } 
View Full Code Here


        IEngUserProfile profile = getUserProfile();
        dataSetJSON = getDatasetTestResultList(ds, h, profile);         
      }             
    }else{
      logger.error("DataSet type is not existent");
      throw new SpagoBIServiceException(SERVICE_NAME,  "sbi.ds.dsTypeError");
    }
    return dataSetJSON;
  }
View Full Code Here

   *
   * @param e
   * @return
   */
  public SpagoBIEngineServiceException getWrappedException(String serviceName,  Throwable e) {
    SpagoBIServiceException serviceException = null;
    MessageBuilder msgBuild = new MessageBuilder();
    Locale locale = null
    RequestContainer requestContainer=RequestContainer.getRequestContainer();
    if(requestContainer!=null){
      SessionContainer permSess=requestContainer.getSessionContainer().getPermanentContainer();
      String lang=(String)permSess.getAttribute(SpagoBIConstants.AF_LANGUAGE);
      String country=(String)permSess.getAttribute(SpagoBIConstants.AF_COUNTRY);
      if(lang!=null && country!=null){
        locale=new Locale(lang,country,"");
      }
    }else{
      locale = GeneralUtilities.getDefaultLocale()
    }
   
    if(e instanceof SpagoBIServiceException) {
      // this mean that the service have catched the exception nicely
      serviceException = (SpagoBIServiceException)e;
      String sms = serviceException.getMessage();
      sms = msgBuild.getMessage(sms, locale)
      serviceException = new SpagoBIServiceException(serviceName, sms, e);
    } else {
      // otherwise an unpredicted exception has been raised.  
     
      // This is the last line of defense against exceptions. Bytheway all exceptions that are catched
      // only here for the first time can be considered as bugs in the exception handling mechanism. When
      // such an exception is raised the code in the service should be fixed in order to catch it before and add some meaningfull
      // informations on what have caused it.
      Throwable rootException = e;
      while(rootException.getCause() != null) {
        rootException = rootException.getCause();
      }
      String str = rootException.getMessage()!=null? rootException.getMessage(): rootException.getClass().getName();
      str = msgBuild.getMessage(str, locale)
      String message = "An unpredicted error occurred while executing service."
               + "\nThe root cause of the error is: " + str;
     
      serviceException = new SpagoBIServiceException(serviceName, message, e);
     
    }

    logError(serviceException);
   
View Full Code Here

    try {
      objDao = DAOFactory.getBIObjectDAO();
      objDao.setUserProfile(getUserProfile());
    } catch (EMFUserError e1) {
      logger.error(e1.getMessage(), e1);
      throw new SpagoBIServiceException(SERVICE_NAME,  "Error occurred");
    }

    String serviceType = this.getAttributeAsString(MESSAGE_DET);
    logger.debug("Service type "+serviceType);
    try {
      if (serviceType != null && serviceType.equalsIgnoreCase(DOC_SAVE)) {
        saveDocument();
      } else if (serviceType != null && serviceType.equalsIgnoreCase(DOC_UPDATE)) {
        updateWorksheetTemplate();
      }
    } catch (SpagoBIServiceException e) {
      throw e;
    } catch (Exception e) {
      logger.error("Error while updating document's template", e);
      throw new SpagoBIServiceException(SERVICE_NAME, "sbi.document.saveError", e);
    }
    logger.debug("OUT");
  }
View Full Code Here

     
      BIObject o = new BIObject();
      BIObject objAlreadyExisting = objDao.loadBIObjectByLabel(label);
      if(objAlreadyExisting!=null){
        logger.error("Document with the same label already exists");
        throw new SpagoBIServiceException(SERVICE_NAME,  "sbi.document.labelAlreadyExistent");
      }
      o.setName(name);
      o.setLabel(label);
      o.setDescription(description);
      o.setVisible(new Integer(1));
     
      if(engineId!=null){
        Engine engine = DAOFactory.getEngineDAO().loadEngineByID(new Integer(engineId));
        o.setEngine(engine);
      }else{
        List<Engine> engines = DAOFactory.getEngineDAO().loadAllEnginesForBIObjectType(type);
        if(engines!=null && !engines.isEmpty()){
          o.setEngine(engines.get(0));
        }
      }
     
      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>();
      for(int i=0; i< functsArrayJSon.length(); i++){
        String funcIdStr = functsArrayJSon.getString(i);
        Integer funcId = new Integer(funcIdStr);
        if (funcId.intValue() == -1) {
          // -1 stands for personal folder: check is it exists
          boolean exists = UserUtilities.userFunctionalityRootExists(userProfile);
          if (!exists) {
            // create personal folder if it doesn't exist
            UserUtilities.createUserFunctionalityRoot(userProfile);
          }
          // load personal folder to get its id
          LowFunctionality lf = UserUtilities.loadUserFunctionalityRoot(userProfile);
          funcId = lf.getId();
        }
        functionalities.add(funcId);
      }   
      o.setFunctionalities(functionalities);
     
      Domain objState = DAOFactory.getDomainDAO().loadDomainByCodeAndValue(SpagoBIConstants.DOC_STATE, SpagoBIConstants.DOC_STATE_REL);     
      Integer stateID = objState.getValueId();
      o.setStateID(stateID);
      o.setStateCode(objState.getValueCd());   
     
      BIObject orig_obj = objDao.loadBIObjectById(new Integer(orig_biobj_id));
      ObjTemplate objTemp = new ObjTemplate();
      byte[] content = null;
      if(template != null && template != ""){
        content = template.getBytes();
      }else if(smartFilterValues!=null){
        content = getSmartFilterTemplateContent();
      }else if(wk_definition!=null && query!=null && orig_obj!=null){
        ObjTemplate qbETemplate = orig_obj.getActiveTemplate();
        String templCont = new String(qbETemplate.getContent());
        WorksheetDriver q = new WorksheetDriver();
        String temp = q.composeWorksheetTemplate(wk_definition, query, null, templCont);
        content = temp.getBytes();
      }else{
        logger.error("Document template not available");
        throw new SpagoBIServiceException(SERVICE_NAME,  "sbi.document.saveError");
      }
     
      objTemp.setContent(content);
      objTemp.setCreationUser(creationUser);
      objTemp.setDimension(Long.toString(content.length/1000)+" KByte");
      objTemp.setName("template.sbiworksheet");
     
      try {
        if(id != null && !id.equals("") && !id.equals("0")){             
          o.setId(Integer.valueOf(id));
          objDao.modifyBIObject(o, objTemp);
          logger.debug("Document with id "+id+" updated");
          JSONObject attributesResponseSuccessJSON = new JSONObject();
          attributesResponseSuccessJSON.put("success", true);
          attributesResponseSuccessJSON.put("responseText", "Operation succeded");
          writeBackToClient( new JSONSuccess(attributesResponseSuccessJSON) );
        }else{
          Integer biObjectID = objDao.insertBIObject(o, objTemp);
          if(orig_biobj_id!=null && orig_biobj_id!=""){         
            List obj_pars = orig_obj.getBiObjectParameters();
            if(obj_pars!=null && !obj_pars.isEmpty()){
              Iterator it = obj_pars.iterator();
              while(it.hasNext()){
                BIObjectParameter par = (BIObjectParameter)it.next();
                par.setBiObjectID(biObjectID);
                par.setId(null);
                DAOFactory.getBIObjectParameterDAO().insertBIObjectParameter(par);
              }
            }
          }
          logger.debug("New document inserted");
          JSONObject attributesResponseSuccessJSON = new JSONObject();
          attributesResponseSuccessJSON.put("responseText", "Operation succeded");
          writeBackToClient( new JSONSuccess(attributesResponseSuccessJSON) );
        }

      } catch (Throwable e) {
        logger.error(e.getMessage(), e);
        throw new SpagoBIServiceException(SERVICE_NAME,"sbi.document.saveError", e);
      }
     
    } else {
      logger.error("Document name or label are missing");
      throw new SpagoBIServiceException(SERVICE_NAME,  "sbi.document.missingFieldsError");
   
  }
View Full Code Here

        selRole = null;
      }

      if(selRole!=null && !roles.contains(selRole)){
        logger.error("Security alert. Role not among the user ones");
        throw new SpagoBIServiceException(SERVICE_NAME, "Role selected is not permitted for user "+userProfile.getUserId())
      }

      // set this role as default one, or clear default role if not present
      String previousDefault = ((UserProfile)profile).getDefaultRole();
      logger.debug("previous default role "+previousDefault);
      logger.debug("new default role "+selRole);
      ((UserProfile)profile).setDefaultRole(selRole);
      logger.debug("default role set! ");

      // now I must refresh userProfile functions

      //String[] newFunctions = null;
      Collection coll = null;

      it.eng.spagobi.commons.dao.IUserFunctionalityDAO dao = DAOFactory.getUserFunctionalityDAO();

      // if new selROle is null refresh all the functionalities!
      if(selRole == null){
        logger.debug("Selected role is null, refresh all functionalities ");       
        Collection allRoles = profile.getRoles();
        String[] array = StringUtilities.convertCollectionInArray(allRoles);
        //String[] arrayFuncs = dao.readUserFunctionality(array);       
        String[] arrayFuncs = UserUtilities.readFunctionality(array);

        coll = StringUtilities.convertArrayInCollection(arrayFuncs);
        ((UserProfile)profile).setFunctionalities(coll);
        //        ISecurityServiceSupplier supplier = SecurityServiceSupplierFactory.createISecurityServiceSupplier();   
        //        SpagoBIUserProfile user = supplier.createUserProfile(profile.getUserUniqueIdentifier().toString());
        //        newFunctions = user.getRoles();

        if( coll == null ) StringUtilities.convertArrayInCollection(arrayFuncs);
        ((UserProfile)profile).setFunctionalities(coll);
      }
      else {
        // there is a default role selected so filter only its functionalities
        logger.debug("Selected role is not null, put right functionality");       
        String[] selRoleArray = new String[1];
        selRoleArray[0] = selRole;
        String[] arrayFuncs = UserUtilities.readFunctionality(selRoleArray);

        //String[] arrayFuncs = dao.readUserFunctionality(selRoleArray);
        //String[] arrayFuncs = UserUtilities.readFunctionality(selRoleArray);

        coll = StringUtilities.convertArrayInCollection(arrayFuncs);

        for (Iterator iterator = coll.iterator(); iterator.hasNext();) {
          Object object = (Object) iterator.next();
          logger.debug("functionality to add "+object.toString());
        }

        ((UserProfile)profile).setFunctionalities(coll);

        logger.debug("set functionalities for default role");
        // check if single functionality is included in role, else remove it
        //          for (int i = 0; i < funcsToRemove.length; i++) {
        //            String funcToRem = funcsToRemove[i];
        //            if(!coll.contains(funcToRem)){
        //              ((UserProfile)profile).getFunctionalities().remove(funcToRem);
        //            }
        //          }

      }

      //      if( coll == null ) StringUtilities.convertArrayInCollection(newFunctions);
      //      ((UserProfile)profile).setFunctionalities(coll);
      // end refresh of the functionalities
      logger.debug("FIltered functionalities for selected role "+selRole);

      try {
        writeBackToClient( new JSONAcknowledge() );
      } catch (IOException e) {
        String message = "Impossible to write back the responce to the client";
        throw new SpagoBIEngineServiceException(getActionName(), message, e);
      }

    } catch (Exception e) {
      throw new SpagoBIServiceException(SERVICE_NAME, "Exception occurred while retrieving metadata", e);
    } finally {
      logger.debug("OUT");
   

View Full Code Here

      String owner = (String)((UserProfile)profile).getUserId();
      try {
        objnote = DAOFactory.getObjNoteDAO().getExecutionNotesByOwner(obj.getId(), execIdentifier, owner);
      } catch (Exception e) {
        logger.error("Cannot load notes for document [id: " + obj.getId() + ", label: " + obj.getLabel() + ", name: " + obj.getName() + "]", e);
        throw new SpagoBIServiceException(SERVICE_NAME, "Cannot load notes", e);
      }
      String currentNotes = "";
      if (objnote != null) {
        logger.debug("Existing notes found with the same execution identifier");
        byte[] content = objnote.getContent();
        currentNotes = new String(content);
      }
      if (!"INSERT_NOTE".equalsIgnoreCase(MESSAGE) && !currentNotes.equals(previousNotes)) {
        logger.debug("Notes have been created by another user");
        resultStr = "conflict";
      } else {
        logger.debug("Saving notes...");
        try {
          saveNotes(execIdentifier, obj.getId(), notes, objnote, owner, visibility,profile);
          logger.debug("Notes saved");
          resultStr = "ok";
        } catch (Exception e) {
          throw new SpagoBIServiceException(SERVICE_NAME, "Error while saving notes", e);
        }
      }
     
      try {
        JSONObject result = new JSONObject();
        result.put("result", resultStr);
        writeBackToClient( new JSONSuccess( result ) );
      } catch (IOException e) {
        throw new SpagoBIServiceException(SERVICE_NAME, "Impossible to write back the responce to the client", e);
      } catch (JSONException e) {
        throw new SpagoBIServiceException(SERVICE_NAME, "Cannot serialize objects into a JSON object", e);
      }
    } finally {
      logger.debug("OUT");
    }
  }
View Full Code Here

      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);
          }
          logger.debug("Scheduled execution [id: " + snapshot.getId() + ", name: " + snapshot.getName() + "] deleted.");
        } else {
          logger.error("Cannot delete scheduled execution with id = " + snapshot.getBiobjId() + ": " +
              "it is not relevant to the current document [id: " + obj.getId() + ", label: " + obj.getLabel() + ", name: " + obj.getName() + "]");
          throw new SpagoBIServiceException(SERVICE_NAME, "Cannot delete scheduled execution: it is not relevant to the current document");
        }
       
      }
      try {
        JSONObject results = new JSONObject();
        results.put("result", "OK");
        writeBackToClient( new JSONSuccess( results ) );
      } catch (IOException e) {
        throw new SpagoBIServiceException(SERVICE_NAME, "Impossible to write back the responce to the client", e);
      } catch (JSONException e) {
        throw new SpagoBIServiceException(SERVICE_NAME, "Cannot serialize objects into a JSON object", e);
      }

    } finally {
      logger.debug("OUT");
    }
View Full Code Here

    logger.debug("Parameter [" + CALLBACK + "] is equals to [" + callback + "]");
   
    try {
      writeBackToClient( new JSONSuccess( parametersJSON, callback )  );
    } catch (IOException e) {
      throw new SpagoBIServiceException("Impossible to write back the responce to the client", e);
    }
  }
View Full Code Here

     
      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;
     
      try {
        JSONDataWriter writer = new JSONDataWriter();
        dataSetJSON = (JSONObject)writer.write(dataStore);
      } catch (Throwable e) {
        throw new SpagoBIServiceException("Impossible to serialize datastore", e);
      }
     
      try {
        writeBackToClient( new JSONSuccess( dataSetJSON, callback ) );
      } catch (IOException e) {
        throw new SpagoBIServiceException("Impossible to write back the responce to the client", e);
      }
    } catch (Throwable t) {
      throw SpagoBIEngineServiceExceptionHandler.getInstance().getWrappedException(getActionName(), getEngineInstance(), t);
    } finally {
      monitor.stop();
View Full Code Here

TOP

Related Classes of it.eng.spagobi.utilities.exceptions.SpagoBIServiceException

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.