Package it.eng.spagobi.utilities.exceptions

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


        } else {
          subObjectsList = DAOFactory.getSubObjectDAO().getAccessibleSubObjects(biobjectId, userProfile);
        }
      } catch (EMFUserError e) {
        logger.error("Error while recovering subobjects list for document with id = " + biobjectId, e);
        throw new SpagoBIServiceException(SERVICE_NAME, "Cannot load customized views", e);
      } catch (EMFInternalError e) {
        logger.error("Error while recovering information about user", e);
        throw new SpagoBIServiceException(SERVICE_NAME, "Error while recovering information about user", e);
      }
     
      try {
        JSONArray subObjectsListJSON = (JSONArray) SerializerFactory.getSerializer("application/json").serialize( subObjectsList,null );
        JSONObject results = new JSONObject();
        results.put("results", subObjectsListJSON);
        writeBackToClient( new JSONSuccess( results ) );
      } catch (IOException e) {
        throw new SpagoBIServiceException(SERVICE_NAME, "Impossible to write back the responce to the client", e);
      } catch (SerializationException e) {
        throw new SpagoBIServiceException(SERVICE_NAME, "Cannot serialize objects", 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


    Domain engineType;
    try {
      engineType = DAOFactory.getDomainDAO().loadDomainById(
          engine.getEngineTypeId());
    } catch (EMFUserError e) {
      throw new SpagoBIServiceException("Impossible to load engine type domain", e);
    }

    // IF THE ENGINE IS EXTERNAL
    if ("EXT".equalsIgnoreCase(engineType.getValueCd())) {
      // instance the driver class
      String driverClassName = engine.getDriverName();
      IEngineDriver aEngineDriver = null;
      try {
        aEngineDriver = (IEngineDriver) Class.forName(driverClassName).newInstance();
      } catch (Exception e) {
        throw new SpagoBIServiceException("Cannot istantiate engine driver class: " + driverClassName, e);
      }
      // get the map of the parameters
      Map mapPars = aEngineDriver.getParameterMap(object, userProfile, executionRole);
      // adding "system" parameters
      addSystemParametersForExternalEngines(mapPars, locale);
View Full Code Here

   
      dataSet = null;
      try {
        dataSet = getConsoleEngineInstance().getDataSetServiceProxy().getDataSetByLabel( 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 + "]");
       
     
      Assert.assertNotNull(dataSet, "Impossible to find a dataset whose label is [" + dataSetLabel + "]");
View Full Code Here

      results.put("message", message);
      results.put("results", emptyListJSON);
      results.put("totalCount", emptyListJSON.length());
      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);
    }
  }
View Full Code Here

        Assert.assertNotNull(usr, "User identifier not spicified");       
        Assert.assertNotNull(usr, "Password not spicified");
       
        if( supplier.checkAuthentication(usr, pwd) == null) {
          logger.warn("An attempt to authenticate with wrong credential has made [" + usr + "/" + pwd +"]");
          throw new SpagoBIServiceException(SERVICE_NAME, "An attempt to authenticate with wrong credential has made [" + usr + "/" + pwd +"]");
        }
       
      } else {
        usr = UserUtilities.getUserId(this.getHttpRequest());
        Assert.assertNotNull(usr, "User identifier not found. Cannot build user profile object");
       
      }
     
      logger.info("User ["+ usr + "] has been autheticated succesfully");
     
      profile = UserUtilities.getUserProfile( usr );
      Assert.assertNotNull(profile, "Impossible to load profile for the user [" + usr + "]");

     
      logger.info("User ["+ usr + "] profile has been loaded succesfully");
     
      // Propagate user profile
      getSessionContainer().getPermanentContainer().setAttribute(IEngUserProfile.ENG_USER_PROFILE, profile);
     
      // Propagate THEME  if present
      if (theme != null && theme.length() > 0){
        getSessionContainer().getPermanentContainer().setAttribute(SpagoBIConstants.THEME, theme);
      }
     
      // Propagate BACK URL if present
      if (!StringUtilities.isEmpty( backUrl )){
        getHttpSession().setAttribute(SpagoBIConstants.BACK_URL, backUrl);   
      }
           
      // Propagate locale
      Locale locale = MessageBuilder.getBrowserLocaleFromSpago();
      logger.debug("User ["+ usr + "] loacale has been set to [" + locale.getLanguage() + "/" + locale.getCountry() + "]");
      if (locale != null) {
        getSessionContainer().getPermanentContainer().setAttribute(Constants.USER_LANGUAGE, locale.getLanguage());
        getSessionContainer().getPermanentContainer().setAttribute(Constants.USER_COUNTRY, locale.getCountry());
      }
     
      String username = (String)((UserProfile)profile).getUserId();
      if (!UserUtilities.userFunctionalityRootExists(username)) {
        logger.debug("Funcitonality root not yet exists for " + username)
        UserUtilities.createUserFunctionalityRoot(profile);
      } else{
        logger.debug("Funcitonality root already exists for " + username);         
      }

      MenuUtilities.getMenuItems(request, response, profile)
      try {
        JSONObject results = new JSONObject();
        results.put("username", username);
        results.put("userid", profile.getUserUniqueIdentifier());
        writeBackToClient( new JSONSuccess( results, callback ) );
      } catch (IOException e) {
        throw new SpagoBIServiceException("Impossible to write back the responce to the client", e);
      }
    } catch(Throwable t) {
      SpagoBIServiceExceptionHandler.getInstance().getWrappedException(SERVICE_NAME, t);
    } finally {
      logger.info("User ["+ usr + "] has been logged in succesfully");
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 + "]");
        /*
      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);
      //dataStore.getMetaData().getFieldMeta(fieldIndex).setProperty("detail", true);
     
     
     
      dataSetJSON = null;
     
      try {
        JSONDataWriter writer = new JSONDataWriter();
       
        Object resultNumber = dataStore.getMetaData().getProperty("resultNumber");
        if(resultNumber == null) dataStore.getMetaData().setProperty("resultNumber", new Integer((int)dataStore.getRecordsCount()));
       
        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

     
      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 = consoleEngineInstance.getAnalyticalDrivers();
      dataSet.setParamsMap(params);
      dataSet.setUserProfileAttributes(UserProfileUtils.getProfileAttributes( (UserProfile) this.getEnv().get(EngineConstants.ENV_USER_PROFILE)));
      //dataSet.setParamsMap(getEnv());
      //gets the max number of rows for the table
      String strRowLimit = ConsoleEngineConfig.getInstance().getProperty("CONSOLE-TABLE-ROWS-LIMIT");
      int rowLimit = (strRowLimit == null)? 0 : Integer.parseInt(strRowLimit);
      Monitor monitorLD =MonitorFactory.start("SpagoBI_Console.GetConsoleDataAction.service.LoadData");
      if (rowLimit > 0){
        dataSet.loadData(-1, -1, rowLimit);
      }else{
        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");
     
      JSONObject results = new JSONObject();
      try {
        JSONDataWriter writer = new JSONDataWriter();
       
        Object resultNumber = dataStore.getMetaData().getProperty("resultNumber");
        if(resultNumber == null) dataStore.getMetaData().setProperty("resultNumber", new Integer((int)dataStore.getRecordsCount()));
        /*
        //gets the max number of rows for the table
        String strRowLimit = ConsoleEngineConfig.getInstance().getProperty("CONSOLE-TABLE-ROWS-LIMIT");
        int rowLimit = (strRowLimit == null)? 0 : Integer.parseInt(strRowLimit);
       
 
        if (rowLimit > 0){
          IDataStore tmpDS = new DataStore();
          for(int index = 0; index<dataStore.getRecordsCount() && index<rowLimit; index++){
            IRecord record = dataStore.getRecordAt(index);
            tmpDS.appendRecord(record);
          }
          //set the original datastore with the new one
          dataStore = tmpDS;
        }
*/
        JSONObject dataSetJSON = (JSONObject)writer.write(dataStore);       
        results = dataSetJSON;
      } catch (Throwable e) {
        throw new SpagoBIServiceException("Impossible to serialize datastore", e);
      }
     
      try {
        writeBackToClient( new JSONSuccess( results, 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

      Assert.assertNotNull(response, "An internal error occurred while generating service response. Service response cannot be null");
           
      try {
        writeBackToClient( new JSONSuccess( response ) );
      } catch (IOException e) {
        throw new SpagoBIServiceException(SERVICE_NAME, "Impossible to write back the responce to the client", e);
      }
    } finally {
      logger.debug("OUT");
    }
  }
View Full Code Here

      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);
      }
      Assert.assertNotNull(dao, "An internal error occurred while istantiating DAO. DAO cannot be null.");

      snapshot = null;
      try {
        snapshot = dao.loadSnapshot(snapshotId);
      } catch (EMFUserError e) {
        logger.error("Snapshot with id = " + snapshotId + " not found", e);
        throw new SpagoBIServiceException(SERVICE_NAME, "Scheduled execution not found", e);
      }
      Assert.assertNotNull(dao, "An internal error occurred while loading snapshot [" + snapshotId + "]. Snapshot cannot be null.");
     
      obj = executionInstance.getBIObject();
      if (obj.getId().equals(snapshot.getBiobjId())) {
        executionInstance.setSnapshot(snapshot);
        url = executionInstance.getSnapshotUrl();
        response = new JSONObject();
        try {
          response.put("url", url);
        } catch (JSONException e) {
          throw new SpagoBIServiceException("Cannot serialize the url [" + url + "] to the client", e);
        }
      } else {
        throw new SpagoBIServiceException(SERVICE_NAME, "Required scheduled execution is not relevant to current document");
      }
    } finally {
      logger.debug("OUT");
    }
   
View Full Code Here

        JSONObject executionInstanceJSON = this.getAttributeAsJSONObject( PARAMETERS );
        executionInstance.refreshParametersValues(executionInstanceJSON, false);
        try {
          errors = executionInstance.getParametersErrors();
        } catch (Exception e) {
          throw new SpagoBIServiceException(SERVICE_NAME, "Cannot evaluate errors on parameters validation", e);
        }
      //}

      if ( errors != null && errors.size() > 0) {
        // there are errors on parameters validation, send errors' descriptions to the client
        JSONArray errorsArray = new JSONArray();
        Iterator errorsIt = errors.iterator();
        while (errorsIt.hasNext()) {
          EMFUserError error = (EMFUserError) errorsIt.next();
          errorsArray.put(error.getDescription());
        }
        try {
          response.put("errors", errorsArray);
        } catch (JSONException e) {
          throw new SpagoBIServiceException(SERVICE_NAME, "Cannot serialize errors to the client", e);
        }
      } else {
     
        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);
        }
 
        SubObject subObject = null;
        try {
          subObject = dao.getSubObject(subObjectId);
        } catch (EMFUserError e) {
          logger.error("SubObject with id = " + subObjectId + " not found", e);
          throw new SpagoBIServiceException(SERVICE_NAME, "Customized view not found", e);
        }
       
        BIObject obj = executionInstance.getBIObject();
        if (obj.getId().equals(subObject.getBiobjId())) {
          boolean canExecuteSubObject = false;
          if (userProfile.isAbleToExecuteAction(SpagoBIConstants.DOCUMENT_MANAGEMENT_ADMIN)) {
            canExecuteSubObject = true;
          } else {
            if (subObject.getIsPublic() || subObject.getOwner().equals(userProfile.getUserId().toString())) {
              canExecuteSubObject = true;
            }
          }
          if (canExecuteSubObject) {
            executionInstance.setSubObject(subObject);
            String url = executionInstance.getSubObjectUrl(locale);
            url += "&isFromCross=" + (isFromCross == true ? "true" : "false");
            try {
              response.put("url", url);
            } catch (JSONException e) {
              throw new SpagoBIServiceException("Cannot serialize the url [" + url + "] to the client", e);
            }
          } else {
            throw new SpagoBIServiceException(SERVICE_NAME, "User cannot execute required customized view");
          }
        } else {
          throw new SpagoBIServiceException(SERVICE_NAME, "Required subobject is not relevant to current document");
        }
      }
    } catch (EMFInternalError e) {
      throw new SpagoBIServiceException(SERVICE_NAME, "An internal error has occured", e);
    } finally {
      logger.debug("OUT");
    }
    return response;
  }
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.