Package it.eng.spagobi.utilities.exceptions

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


      boolean deleted = dsDao.deleteInactiveDataSetVersion(dsVersionID)
      if(deleted){
        logger.debug("Dataset Version deleted");
        writeBackToClient( new JSONAcknowledge("Operation succeded") );
      }else{
        throw new SpagoBIServiceException(SERVICE_NAME,"sbi.ds.deleteVersion");
      }
    } catch (Throwable e) {
      logger.error("Exception occurred while retrieving dataset version to delete", e);
      throw new SpagoBIServiceException(SERVICE_NAME,"sbi.ds.deleteVersion", e);
    }
  }
View Full Code Here


      dsDao.deleteAllInactiveDataSetVersions(dsID);
      logger.debug("All Older Dataset versions deleted");
      writeBackToClient( new JSONAcknowledge("Operation succeded") );
    } catch (Throwable e) {
      logger.error("Exception occurred while retrieving dataset to delete", e);
      throw new SpagoBIServiceException(SERVICE_NAME,"sbi.ds.deleteVersion", e);
    }
  }
View Full Code Here

      attributesResponseSuccessJSON.put("responseText", "Operation succeded");
      attributesResponseSuccessJSON.put("result", version);
      writeBackToClient( new JSONSuccess(attributesResponseSuccessJSON) );
    } catch (Throwable e) {
      logger.error("Exception occurred while retrieving dataset to restore", e);
      throw new SpagoBIServiceException(SERVICE_NAME,"sbi.ds.restoreVersionError", e);
    }
  }
View Full Code Here

      File dir = new File(filePath);
         String[] fileNames = dir.list();
         getSessionContainer().setAttribute("fileNames", fileNames)
    } catch (EMFUserError e) {
      logger.error(e.getMessage(), e);
      throw new SpagoBIServiceException(SERVICE_NAME,"sbi.ds.dsTypesRetrieve", e);
    }
  }
View Full Code Here

        }
        GuiDataSetDetail dsActiveDetail = constructDataSetDetail(dsType);
        ds.setActiveDetail(dsActiveDetail)
      }else{
        logger.error("DataSet type is not existent");
        throw new SpagoBIServiceException(SERVICE_NAME,  "sbi.ds.dsTypeError");
      }
    }   
    return ds;
  }
View Full Code Here

            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

    try {
      userDao = DAOFactory.getSbiUserDAO();
      userDao.setUserProfile(getUserProfile());
    } catch (EMFUserError e1) {
      logger.error(e1.getMessage(), e1);
      throw new SpagoBIServiceException(SERVICE_NAME,  "Error occurred");
    }
    Locale locale = getLocale();

    String serviceType = this.getAttributeAsString(MESSAGE_DET);
    logger.debug("Service type "+serviceType);
    if (serviceType != null && serviceType.equalsIgnoreCase(USERS_LIST)) {
     
      try {       
        Integer start = getAttributeAsInteger( START );
        Integer limit = getAttributeAsInteger( LIMIT );
       
        if(start==null){
          start = START_DEFAULT;
        }
        if(limit==null){
          limit = LIMIT_DEFAULT;
        }

        Integer totalResNum = userDao.countUsers();
        List<UserBO> users = userDao.loadPagedUsersList(start, limit);
        logger.debug("Loaded users list");
        JSONArray usersJSON = (JSONArray) SerializerFactory.getSerializer("application/json").serialize(users,  locale);
        JSONObject usersResponseJSON = createJSONResponseUsers(usersJSON, totalResNum);

        writeBackToClient(new JSONSuccess(usersResponseJSON));

      } catch (Throwable e) {
        logger.error("Exception occurred while retrieving users", e);
        throw new SpagoBIServiceException(SERVICE_NAME,
            "Exception occurred while retrieving users", e);
      }
    } else if (serviceType != null  && serviceType.equalsIgnoreCase(USER_INSERT)) {
      Integer id = getAttributeAsInteger(ID);
      String userId = getAttributeAsString(USER_ID);
      String fullName = getAttributeAsString(FULL_NAME);
      String password = getAttributeAsString(PASSWORD);
      JSONArray rolesJSON = getAttributeAsJSONArray(ROLES);
      JSONArray attributesJSON = getAttributeAsJSONArray(ATTRIBUTES);
      if (userId != null) {
        SbiUser user = new SbiUser();
        user.setUserId(userId);
        user.setFullName(fullName);
        if(password != null && password.length() > 0){
          try {
            user.setPassword(Password.encriptPassword(password));
          } catch (Exception e) {
            logger.error("Impossible to encript Password", e);
            throw new SpagoBIServiceException(SERVICE_NAME,
                "Impossible to encript Password",e);
          }
        }
       
        if(id!=null){
          user.setId(id);
        }
        try {
          HashMap<Integer, String> attrList = null;
          if(attributesJSON != null){
            attrList = deserializeAttributesJSONArray(attributesJSON);
          }
         
          List rolesList = null;
          if(rolesJSON != null){
            rolesList = deserializeRolesJSONArray(rolesJSON);
          }
         
          id = userDao.fullSaveOrUpdateSbiUser(user, rolesList, attrList);
          logger.debug("User updated or Inserted");
          JSONObject attributesResponseSuccessJSON = new JSONObject();
          attributesResponseSuccessJSON.put("success", true);
          attributesResponseSuccessJSON.put("responseText", "Operation succeded");
          attributesResponseSuccessJSON.put("id", id);
          writeBackToClient( new JSONSuccess(attributesResponseSuccessJSON) );

        } catch (EMFUserError e) {
          logger.error("Exception occurred while saving new user", e);
          writeErrorsBackToClient();
          throw new SpagoBIServiceException(SERVICE_NAME,  "Exception occurred while saving new user",  e);
        } catch (IOException e) {
          logger.error("Exception occurred while writing response to client", e);
          throw new SpagoBIServiceException(SERVICE_NAME,
              "Exception occurred while writing response to client",
              e);
        } catch (JSONException e) {
          logger.error("JSON Exception", e);
          e.printStackTrace();
        }
      }else{
        logger.error("User name missing");
        throw new SpagoBIServiceException(SERVICE_NAME,  "Please enter user name");
      }
    } else if (serviceType != null  && serviceType.equalsIgnoreCase(USER_DELETE)) {
      Integer id = getAttributeAsInteger(ID);
      try {
        userDao.deleteSbiUserById(id);
        logger.debug("User deleted");
        writeBackToClient( new JSONAcknowledge("Operation succeded") );

      } catch (Throwable e) {
        logger.error("Exception occurred while retrieving user to delete", e);
        throw new SpagoBIServiceException(SERVICE_NAME,
            "Exception occurred while retrieving user to delete",
            e);
      }
    }else if(serviceType == null){
      try {
        List<SbiAttribute> attributes = DAOFactory.getSbiAttributeDAO().loadSbiAttributes();
        List<SbiExtRoles> roles = DAOFactory.getRoleDAO().loadAllRoles();
        getSessionContainer().setAttribute("attributesList", attributes);
        getSessionContainer().setAttribute("rolesList", roles);
       
      } catch (EMFUserError e) {
        logger.error(e.getMessage(), e);
        throw new SpagoBIServiceException(SERVICE_NAME,
            "Exception retrieving role types",
            e);
      }
    }
    logger.debug("OUT");
View Full Code Here

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

    Locale locale = getLocale();

    String serviceType = this.getAttributeAsString(MESSAGE_DET);
    logger.debug("Service type "+serviceType);
    if (serviceType != null && serviceType.equalsIgnoreCase(ROLES_LIST)) {
      try {
        Integer start = getAttributeAsInteger( START );
        Integer limit = getAttributeAsInteger( LIMIT );
       
        if(start==null){
          start = START_DEFAULT;
        }
        if(limit==null){
          limit = LIMIT_DEFAULT;
        }

        Integer totalResNum = roleDao.countRoles();
        List<Role> roles = roleDao.loadPagedRolesList(start, limit);       
       
        //ArrayList<Role> roles = (ArrayList<Role>)roleDao.loadAllRoles();
        logger.debug("Loaded roles list");
        JSONArray rolesJSON = (JSONArray) SerializerFactory.getSerializer("application/json").serialize(roles,  locale);
        JSONObject rolesResponseJSON = createJSONResponseRoles(rolesJSON,totalResNum);

        writeBackToClient(new JSONSuccess(rolesResponseJSON));

      } catch (Throwable e) {
        logger.error(e.getMessage(), e);
        throw new SpagoBIServiceException(SERVICE_NAME,
            "Exception occurred while retrieving roles", e);
      }
    } else if (serviceType != null  && serviceType.equalsIgnoreCase(ROLE_INSERT)) {
      String name = getAttributeAsString(NAME);
      String roleTypeCD = getAttributeAsString(ROLE_TYPE_CD);
      String code = getAttributeAsString(CODE);
      String description = getAttributeAsString(DESCRIPTION);
     
      Boolean saveSubobjects= getAttributeAsBoolean(SAVE_SUBOBJECTS);
      Boolean seeSubobjects= getAttributeAsBoolean(SEE_SUBOBJECTS);
      Boolean seeViewpoints= getAttributeAsBoolean(SEE_VIEWPOINTS);
      Boolean seeSnapshots= getAttributeAsBoolean(SEE_SNAPSHOTS);
      Boolean seeNotes= getAttributeAsBoolean(SEE_NOTES);
      Boolean sendMail= getAttributeAsBoolean(SEND_MAIL);
      Boolean saveIntoPersonalFolder= getAttributeAsBoolean(SAVE_INTO_PERSONAL_FOLDER);
      Boolean saveRememberMe= getAttributeAsBoolean(SAVE_REMEMBER_ME);
      Boolean seeMetadata= getAttributeAsBoolean(SEE_METADATA);
      Boolean saveMetadata= getAttributeAsBoolean(SAVE_METADATA);
      Boolean buildQbeQuery= getAttributeAsBoolean(BUILD_QBE_QUERY);

      if (name != null) {
        //checks for unique role name
        try {
          Role existentRole = DAOFactory.getRoleDAO().loadByName(name);
          if(existentRole != null){
            String id = getAttributeAsString(ID);
            if(id == null || id.equals("") || id.equals("0")){
              throw new SpagoBIServiceException(SERVICE_NAME,  "Role Name already present.");
            }
          }
        } catch (EMFUserError e1) {
          logger.error(e1.getMessage(), e1);
          throw new SpagoBIServiceException(SERVICE_NAME,
              "Exception occurred while retrieving role by name", e1);
        }

          List<Domain> domains = (List<Domain>)getSessionContainer().getAttribute("roleTypes");

          HashMap<String, Integer> domainIds = new HashMap<String, Integer> ();
          for(int i=0; i< domains.size(); i++){
            domainIds.put(domains.get(i).getValueCd(), domains.get(i).getValueId());
          }
         
          Integer roleTypeID = domainIds.get(roleTypeCD);
          if(roleTypeID == null){
            logger.error("Role type CD not existing");
            throw new SpagoBIServiceException(SERVICE_NAME,  "Role Type ID is undefined");
          }
         
        Role role = new Role();
        role.setCode(code);
        role.setDescription(description);
        role.setName(name);
        role.setRoleTypeCD(roleTypeCD);
        role.setRoleTypeID(roleTypeID);
        role.setIsAbleToBuildQbeQuery(buildQbeQuery);
        role.setIsAbleToSaveIntoPersonalFolder(saveIntoPersonalFolder);
        role.setIsAbleToSaveMetadata(saveMetadata);
        role.setIsAbleToSaveRememberMe(saveRememberMe);
        role.setIsAbleToSaveSubobjects(saveSubobjects);
        role.setIsAbleToSeeMetadata(seeMetadata);
        role.setIsAbleToSeeNotes(seeNotes);
        role.setIsAbleToSeeSnapshots(seeSnapshots);
        role.setIsAbleToSeeSubobjects(seeSubobjects);
        role.setIsAbleToSeeViewpoints(seeViewpoints);
        role.setIsAbleToSendMail(sendMail);
        try {
          String id = getAttributeAsString(ID);
          if(id != null && !id.equals("") && !id.equals("0")){             
            role.setId(Integer.valueOf(id));
            roleDao.modifyRole(role);
            logger.debug("Role "+id+" updated");
            JSONObject attributesResponseSuccessJSON = new JSONObject();
            attributesResponseSuccessJSON.put("success", true);
            attributesResponseSuccessJSON.put("responseText", "Operation succeded");
            writeBackToClient( new JSONSuccess(attributesResponseSuccessJSON) );
          }else{
            Integer roleID = roleDao.insertRoleComplete(role);
            logger.debug("New Role inserted");
            JSONObject attributesResponseSuccessJSON = new JSONObject();
            attributesResponseSuccessJSON.put("success", true);
            attributesResponseSuccessJSON.put("responseText", "Operation succeded");
            attributesResponseSuccessJSON.put("id", roleID);
            writeBackToClient( new JSONSuccess(attributesResponseSuccessJSON) );
          }

        } catch (Throwable e) {
          logger.error(e.getMessage(), e);
          throw new SpagoBIServiceException(SERVICE_NAME,
              "Exception occurred while saving new role",
              e);
        }

      }else{
        logger.error("Missing role name");
        throw new SpagoBIServiceException(SERVICE_NAME,  "Please enter role name");
      }
    } else if (serviceType != null  && serviceType.equalsIgnoreCase(ROLE_DELETE)) {
      Integer id = getAttributeAsInteger(ID);
      try {
        Role aRole = roleDao.loadByID(id);
        roleDao.eraseRole(aRole);
        logger.debug("Role deleted");
        writeBackToClient( new JSONAcknowledge("Operazion succeded") );

      } catch (Throwable e) {
        logger.error("Exception occurred while deleting role", e);
        throw new SpagoBIServiceException(SERVICE_NAME,
            "Exception occurred while deleting role",
            e);
      }
    } else if (serviceType != null  && serviceType.equalsIgnoreCase(ROLES_SYNCHRONIZATION)) {
      try {
        RoleSynchronizer roleSynch = new RoleSynchronizer();
        roleSynch.synchronize();
        logger.debug("Roles synchronized");
        JSONObject attributesResponseSuccessJSON = new JSONObject();
        attributesResponseSuccessJSON.put("success", true);
        attributesResponseSuccessJSON.put("responseText", "Operation succeded");
        writeBackToClient( new JSONSuccess(attributesResponseSuccessJSON) );

      } catch (Throwable e) {
        logger.error("Exception occurred while syncronize roles", e);
        throw new SpagoBIServiceException(SERVICE_NAME,
            "Exception occurred while syncronize role",
            e);
      }
    }else if(serviceType == null){
      try {
        List<Domain> domains = DAOFactory.getDomainDAO().loadListDomainsByType("ROLE_TYPE");
        getSessionContainer().setAttribute("roleTypes", domains);
      } catch (EMFUserError e) {
        logger.error(e.getMessage(), e);
        throw new SpagoBIServiceException(SERVICE_NAME,
            "Exception retrieving role types",
            e);
      }
    }
    logger.debug("OUT");
View Full Code Here

    try {
      attrDao = DAOFactory.getSbiAttributeDAO();
      attrDao.setUserProfile(getUserProfile());
    } catch (EMFUserError e1) {
      logger.error(e1.getMessage(), e1);
      throw new SpagoBIServiceException(SERVICE_NAME,  "Error occurred");
    }
    HttpServletRequest httpRequest = getHttpRequest();

    Locale locale = getLocale();

    String serviceType = this.getAttributeAsString(MESSAGE_DET);
    logger.debug("Service type "+serviceType);
   
    if (serviceType != null && serviceType.contains(ATTR_LIST)) {
      String name = null;
      String description =null;
      String idStr = null;
      try {
        BufferedReader b =httpRequest.getReader();
        if(b!=null){
          String respJsonObject = b.readLine();
          if(respJsonObject!=null){
            JSONObject responseJSON = deserialize(respJsonObject);
            JSONObject samples = responseJSON.getJSONObject(SAMPLES);
            if(!samples.isNull(ID)){
              idStr = samples.getString(ID);
            }
           
            //checks if it is empty attribute to start insert
            boolean isNewAttr = this.getAttributeAsBoolean(IS_NEW_ATTR);

            if(!isNewAttr){
              if(!samples.isNull(NAME)){
               
                name = samples.getString(NAME);
                if (GenericValidator.isBlankOrNull(name) ||
                    !GenericValidator.matchRegexp(name, ALPHANUMERIC_STRING_REGEXP_NOSPACE)||
                      !GenericValidator.maxLength(name, nameMaxLenght)){
                  logger.error("Either the field name is blank or it exceeds maxlength or it is not alfanumeric");
                  EMFValidationError e = new EMFValidationError(EMFErrorSeverity.ERROR, description, "9000","");
                  getHttpResponse().setStatus(404)
                  JSONObject attributesResponseSuccessJSON = new JSONObject();
                  attributesResponseSuccessJSON.put("success", false);
                  attributesResponseSuccessJSON.put("message", "Either the field name is blank or it exceeds maxlength or it is not alfanumeric");
                  attributesResponseSuccessJSON.put("data", "[]");
                 
                  writeBackToClient( new JSONSuccess(attributesResponseSuccessJSON) );

                  return;
 
                }
              }
              if(!samples.isNull(DESCRIPTION)){
                description = samples.getString(DESCRIPTION);
 
                if (GenericValidator.isBlankOrNull(description) ||
                    !GenericValidator.matchRegexp(description, ALPHANUMERIC_STRING_REGEXP_NOSPACE) ||
                        !GenericValidator.maxLength(description, descriptionMaxLenght)){
                  logger.error("Either the field description is blank or it exceeds maxlength or it is not alfanumeric");
 
                  EMFValidationError e = new EMFValidationError(EMFErrorSeverity.ERROR, description, "9000","");
                  getHttpResponse().setStatus(404)
                  JSONObject attributesResponseSuccessJSON = new JSONObject();
                  attributesResponseSuccessJSON.put("success", false);
                  attributesResponseSuccessJSON.put("message", "Either the field description is blank or it exceeds maxlength or it is not alfanumeric");
                  attributesResponseSuccessJSON.put("data", "[]");
                  writeBackToClient( new JSONSuccess(attributesResponseSuccessJSON) );
                  return;
                }
              }
           
              SbiAttribute attribute = new SbiAttribute();
              if(description!=null){
                attribute.setDescription(description);
              }
              if(name!=null){
                attribute.setAttributeName(name);
              }
              boolean isNewAttrForRes = true;
              if(idStr!=null && !idStr.equals("")){
                Integer attributeId = new Integer(idStr);
                attribute.setAttributeId(attributeId.intValue());
                isNewAttrForRes = false;
              }
              Integer attrID = attrDao.saveOrUpdateSbiAttribute(attribute);
              logger.debug("Attribute updated");

              ArrayList<SbiAttribute> attributes = new ArrayList<SbiAttribute> ();
              attribute.setAttributeId(attrID);
              attributes.add(attribute);
             
              getAttributesListAdded(locale,attributes,isNewAttrForRes, attrID);

            }
            //else the List of attributes will be sent to the client
          }else{
            getAttributesList(locale,attrDao);
          }
        }else{
          getAttributesList(locale,attrDao);
        }

      } catch (Throwable e) {
        logger.error(e.getMessage(), e);
        getHttpResponse().setStatus(404);               
        try {
          JSONObject attributesResponseSuccessJSON = new JSONObject();
          attributesResponseSuccessJSON.put("success", true);
          attributesResponseSuccessJSON.put("message", "Exception occurred while saving attribute");
          attributesResponseSuccessJSON.put("data", "[]");
          writeBackToClient( new JSONSuccess(attributesResponseSuccessJSON) )
        } catch (IOException e1) {
          logger.error(e1.getMessage(), e1);
        } catch (JSONException e2) {
          logger.error(e2.getMessage(), e2);
        }
        throw new SpagoBIServiceException(SERVICE_NAME,
            "Exception occurred while retrieving attributes", e);
      }
    } else if (serviceType != null  && serviceType.equalsIgnoreCase(ATTR_DELETE)) {
     
      String idStr = null;
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.