Package it.eng.spagobi.utilities.exceptions

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


      List errors = null;
      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 {
        // there are no errors, we can proceed, so calculate the execution url and send it back to the client
        String url = executionInstance.getExecutionUrl(locale);
        url += "&isFromCross=" + (isFromCross == true ? "true" : "false");
        try {
          response.put("url", url);
        } catch (JSONException e) {
          throw new SpagoBIServiceException(SERVICE_NAME, "Cannot serialize the url [" + url + "] to the client", e);
        }
      }
    } finally {
      logger.debug("OUT");
    }
View Full Code Here


      List snapshotsList = null;
      try {
        snapshotsList = DAOFactory.getSnapshotDAO().getSnapshots(biobjectId);
      } catch (EMFUserError e) {
        logger.error("Error while recovering snapshots list for document with id = " + biobjectId, e);
        throw new SpagoBIServiceException(SERVICE_NAME, "Cannot load scheduled executions", e);
      }
     
      try {
        JSONArray snapshotsListJSON = (JSONArray) SerializerFactory.getSerializer("application/json").serialize( snapshotsList ,null);
        JSONObject results = new JSONObject();
        results.put("results", snapshotsListJSON);
        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

     
      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.GetWarningListAction.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

        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 saving metadata", e);
    } finally {
      logger.debug("OUT");
    }
  }
View Full Code Here

      logger.info("Loading document with label = [" + documentLabel + "] ...");
      try {
        obj = DAOFactory.getBIObjectDAO().loadBIObjectByLabel(documentLabel);
      } catch (EMFUserError error) {
        logger.error("Object with label equals to [" + documentLabel + "] not found");
        throw new SpagoBIServiceException(SERVICE_NAME, "Object with label equals to [" + documentLabel + "] not found", error);
      }   
    } else if ( documentId != null ) {
      logger.info("Loading biobject with id = [" + documentId + "] ...");
      try {
        obj = DAOFactory.getBIObjectDAO().loadBIObjectById(documentId);
      } catch (EMFUserError error) {
        logger.error("Object with id equals to [" + documentId + "] not found");
        throw new SpagoBIServiceException(SERVICE_NAME, "Object with id equals to [" + documentId + "] not found", error);
      }
    } else {
      Assert.assertUnreachable("At least one between [" + DOCUMENT_ID + "] and [" + DOCUMENT_LABEL + "] parameter must be specified on request");
    }
    Assert.assertNotNull(obj, "Impossible to load document [" (StringUtilities.isEmpty(documentLabel)? documentId: documentLabel) + "]");
    logger.info("... docuemnt loaded succesfully");
     
    // retrive roles for execution
    try {
      roleNames = ObjectsAccessVerifier.getCorrectRolesForExecution(obj.getId(), profile);
    } catch (Throwable t) {
      throw new SpagoBIServiceException(SERVICE_NAME, t);     
    }
   
    if (roleNames == null || roleNames.size() == 0) {
      logger.warn("Object cannot be executed by any role of the user");
      throw new SpagoBIServiceException(SERVICE_NAME, "Object cannot be executed by any role of the user");
    } else {
      roles = new ArrayList();
      Iterator it = roleNames.iterator();
      while(it.hasNext()) {
        String roleName = (String)it.next();
        try {
          Role role = DAOFactory.getRoleDAO().loadByName(roleName);
          roles.add(role);
        } catch (EMFUserError error) {
          logger.error("Role with name equals to [" + roleName + "] not found");
          throw new SpagoBIServiceException(SERVICE_NAME, "Role with name equals to [" + roleName + "] not found", error);
        }
       
      }
    }
   
    JSONObject rolesJSON = null;
    try {
      JSONArray  dataJSON = (JSONArray)SerializerFactory.getSerializer("application/json").serialize( roles,null );
      rolesJSON = (JSONObject)JSONStoreFeedTransformer.getInstance().transform(dataJSON,
          "id", "name", "description", new String[]{"id", "name", "description"}, new Integer(roleNames.size()));
    } catch (SerializationException e) {
      e.printStackTrace();
    }
   
    try {
      writeBackToClient( new JSONSuccess( rolesJSON ) );
    } 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.debug("OUT");
View Full Code Here

      IBIObjectDAO dao = null;
      try {
        dao = DAOFactory.getBIObjectDAO();
      } catch (EMFUserError e) {
        logger.error("Error while istantiating DAO", e);
        throw new SpagoBIServiceException(SERVICE_NAME, "Cannot access database", e);
      }
      String ids = this.getAttributeAsString(OBJECT_ID);
      String func = this.getAttributeAsString(FUNCT_ID);
      Integer iFunc = new Integer(func);
      logger.debug("Input Folder:" + func);
      logger.debug("Input Object:" + ids);
      // ids contains the id of the object to be deleted separated by ,
      String[] idArray = ids.split(",");
      for (int i = 0; i < idArray.length; i++) {
        Integer id = new Integer(idArray[i]);
        BIObject biObject = null;
        try {
          biObject = dao.loadBIObjectById(id);
        } catch (EMFUserError e) {
          logger.error("BIObject with id = " + id + " not found", e);
          throw new SpagoBIServiceException(SERVICE_NAME, "Customized view not found", e);
        }

        if (userProfile.isAbleToExecuteAction(SpagoBIConstants.DOCUMENT_MANAGEMENT_ADMIN)) {
          // delete document
          try {
            dao.eraseBIObject(biObject, iFunc);
            logger.debug("Object deleted by administrator");
          } catch (EMFUserError e) {
            logger.error("Error to delete Document", e);
            throw new SpagoBIServiceException(SERVICE_NAME, "Error to delete Document", e);
          }
        } else {
          String userId = ((UserProfile)userProfile).getUserId().toString();
          ILowFunctionalityDAO functDAO = DAOFactory.getLowFunctionalityDAO();
          LowFunctionality lowFunc = functDAO.loadLowFunctionalityByID(iFunc, false);

          if(lowFunc==null){
            logger.error("Functionality does not exist");
            throw new Exception("Functionality does not exist");         
          }

          if(lowFunc.getPath().equals("/"+userId)){ // folder is current user one
            dao.eraseBIObject(biObject, iFunc);
            logger.debug("Object deleted");
          }
          else{
            logger.error("Functionality is not user's one");
            throw new Exception("Functionality  is not user's one");         
          }
        }

      }
      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);
      }
    } catch (EMFInternalError e) {
      throw new SpagoBIServiceException(SERVICE_NAME, "An internal error has occured", e);
   
    } catch (Exception e) {
      throw new SpagoBIServiceException(SERVICE_NAME, "An internal error has occured", e);
    } finally {
      logger.debug("OUT");
    }
  }
View Full Code Here

            } else {
              Assert.assertUnreachable("attributes of PARAMETERS JSONObject can be only JSONArray or String");
            }
          }
        } catch (JSONException e) {
          throw new SpagoBIServiceException("parameter JSONObject is malformed", e);
        }
      }
      // END converts JSON object with document's parameters into an hashmap
     
      // START get the relevant biobject parameter
      biObjectParameter = null;
      List parameters = obj.getBiObjectParameters();
      for(int i = 0; i < parameters.size(); i++) {
        BIObjectParameter p = (BIObjectParameter) parameters.get(i);
        if( biparameterId.equalsIgnoreCase( p.getParameterUrlName() ) ) {
          biObjectParameter = p;
          break;
        }
      }
      Assert.assertNotNull(biObjectParameter, "Impossible to find parameter [" + biparameterId + "]" );
      // END get the relevant biobject parameter
     
      lovProvDet = executionInstance.getLovDetail(biObjectParameter);
     
      // START get the lov result
      String lovResult = null;
      try {
        // get the result of the lov
        IEngUserProfile profile = getUserProfile();

        // get from cache, if available
        LovResultCacheManager executionCacheManager = new LovResultCacheManager();
        lovResult = executionCacheManager.getLovResult(profile, biObjectParameter, executionInstance, true);
       
        // get all the rows of the result
        LovResultHandler lovResultHandler = new LovResultHandler(lovResult);   
        rows = lovResultHandler.getRows();
     
      } catch (Exception e) {
        throw new SpagoBIServiceException(SERVICE_NAME, "Impossible to get parameter's values", e);
      }
     
      Assert.assertNotNull(lovResult, "Impossible to get parameter's values" );
      // END get the lov result
     
      // START filtering the list by filtering toolbar
      try {
        if(filtersJSON != null) {
          String valuefilter = (String) filtersJSON.get(SpagoBIConstants.VALUE_FILTER);
          String columnfilter = (String) filtersJSON.get(SpagoBIConstants.COLUMN_FILTER);
          String typeFilter = (String) filtersJSON.get(SpagoBIConstants.TYPE_FILTER);
          String typeValueFilter = (String) filtersJSON.get(SpagoBIConstants.TYPE_VALUE_FILTER);
          rows = DelegatedBasicListService.filterList(rows, valuefilter, typeValueFilter, columnfilter, typeFilter);
        }
      } catch (JSONException e) {
        throw new SpagoBIServiceException(SERVICE_NAME, "Impossible to read filter's configuration", e);
      }
      // END filtering the list by filtering toolbar
     
     
      // START filtering for correlation (only for DependenciesPostProcessingLov, i.e. scripts, java classes and fixed lists)
      biParameterExecDependencies = executionInstance
          .getDependencies(biObjectParameter);
      if (lovProvDet instanceof DependenciesPostProcessingLov
          && selectedParameterValues != null
          && biParameterExecDependencies != null
          && biParameterExecDependencies.size() > 0) {
        rows = ((DependenciesPostProcessingLov) lovProvDet)
            .processDependencies(rows, selectedParameterValues,
                biParameterExecDependencies);
      }
      // END filtering for correlation
     
     
      // START building JSON object to be returned
      JSONObject valuesJSON;
      try {
        JSONArray valuesDataJSON = new JSONArray();
       
        valueColumn = lovProvDet.getValueColumnName();
        displayColumn = lovProvDet.getDescriptionColumnName();
        descriptionColumn = displayColumn;
       
       
       
        int lb = (start != null)? start.intValue(): 0;
        int ub = (limit != null)? lb + limit.intValue(): rows.size() - lb;
        ub = (ub > rows.size())? rows.size(): ub;
       
        for (int q = lb; q < ub; q++) {
          SourceBean row = (SourceBean) rows.get(q);
          JSONObject valueJSON = new JSONObject();
         
          if(MODE_COMPLETE.equalsIgnoreCase( mode )) {
            List columns = row.getContainedAttributes();
            for(int i = 0; i < columns.size(); i++) {
              SourceBeanAttribute attribute = (SourceBeanAttribute)columns.get(i);           
              valueJSON.put(attribute.getKey().toUpperCase(), attribute.getValue());
            }
          } else {
            String value = (String) row.getAttribute(valueColumn);
            String description = (String) row.getAttribute(descriptionColumn);         
            valueJSON.put("value", value);
            valueJSON.put("label", description);
            valueJSON.put("description", description)
          }         
         
          valuesDataJSON.put(valueJSON);
        }
       
        String[] visiblecolumns;
       
        if(MODE_COMPLETE.equalsIgnoreCase( mode )) {
          visiblecolumns = (String[])lovProvDet.getVisibleColumnNames().toArray(new String[0]);
          for(int j = 0; j< visiblecolumns.length; j++) {
            visiblecolumns[j] = visiblecolumns[j].toUpperCase();
          }
        } else {
         
          valueColumn = "value";
          displayColumn = "label";
          descriptionColumn = "description";
         
          visiblecolumns = new String[]{"value", "label", "description"};
        }
       
        valuesJSON = (JSONObject)JSONStoreFeedTransformer.getInstance().transform(valuesDataJSON,
            valueColumn.toUpperCase(), displayColumn.toUpperCase(), descriptionColumn.toUpperCase(), visiblecolumns, new Integer(rows.size()));
      } catch (Exception e) {
        throw new SpagoBIServiceException("Impossible to serialize response", e);
      }
      // END building JSON object to be returned
     
     
      try {
        writeBackToClient( new JSONSuccess( valuesJSON ) );
      } catch (IOException e) {
        throw new SpagoBIServiceException("Impossible to write back the responce to the client", e);
      }
   
    } finally {
      logger.debug("OUT");
    }   
View Full Code Here

           
     
      try {
        writeBackToClient( new JSONSuccess(meta) );
      } catch (IOException e) {
        throw new SpagoBIServiceException(SERVICE_NAME, "Impossible to write back the responce to the client", e);
      }
     
    } catch(Throwable t) {
      throw SpagoBIEngineServiceExceptionHandler.getInstance().getWrappedException(getActionName(), getEngineInstance(), t);
    } finally {
View Full Code Here

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

    serviceType = this.getAttributeAsString(MESSAGE_DET);
    logger.debug("Parameter [" + MESSAGE_DET + "] is equal to ["
        + serviceType + "]");

    if (serviceType != null) {
      if (serviceType.equalsIgnoreCase(CONFIG_LIST)) {
        doConfigList();
      } else if (serviceType.equalsIgnoreCase(CONFIG_DELETE)) {
        doDelete();
      } else if (serviceType.equalsIgnoreCase(CONFIG_SAVE)) {
        doSave();
      } else {
        throw new SpagoBIServiceException(SERVICE_NAME,
            "Unable to execute service [" + serviceType + "]");
      }
    } else {
      logger.warn("The service type is missing");
    }
View Full Code Here

      config = readConfig();
      configTemp = configDao.loadConfigParametersByLabel(config
          .getLabel());
    } catch (Throwable e) {
      logger.error("Exception occurred while saving config data", e);
      throw new SpagoBIServiceException(SERVICE_NAME,
          "Impossible to save config", e);
    }
    if (configTemp != null && !configTemp.getId().equals(config.getId())) {
      throw new SpagoBIServiceException(SERVICE_NAME,
          "Label already in use");
    }
    try {
      configDao.saveConfig(config);
      JSONObject response = new JSONObject();
      response.put("ID", config.getId());
      writeBackToClient(new JSONSuccess(response));
    } catch (Throwable e) {
      logger.error("Exception occurred while saving config data", e);
      throw new SpagoBIServiceException(SERVICE_NAME,
          "Impossible to save config", e);
    } finally {
      logger.debug("OUT");
    }
  }
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.