Package it.eng.spagobi.utilities.exceptions

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


      JSONArray grantsJSON = (JSONArray) SerializerFactory.getSerializer("application/json").serialize( grants, null);
      JSONObject grantsJSONObject = new JSONObject();
      grantsJSONObject.put("rows", grantsJSON);
      writeBackToClient( new JSONSuccess( grantsJSONObject ) );
    } catch (Exception e) {
      throw new SpagoBIServiceException(SERVICE_NAME, "Impossible to serialize the responce to the client", e);
    }
  }
View Full Code Here


 
    try {
      JSONObject grantsJSON = (JSONObject) SerializerFactory.getSerializer("application/json").serialize( grant, null);
      writeBackToClient( new JSONSuccess( grantsJSON ) );
    } catch (Exception e) {
      throw new SpagoBIServiceException(SERVICE_NAME, "Impossible to serialize the responce to the client", e);
    }
  }
View Full Code Here

 
    try {
      JSONArray grantsJSON = (JSONArray) SerializerFactory.getSerializer("application/json").serialize( ous, null);
      writeBackToClient( new JSONSuccess( grantsJSON ) );
    } 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, "Impossible to serialize the responce to the client", e);
    }
  }
View Full Code Here

      ousWithGrants = orUnitDao.getChildrenNodesWithGrants(nodeId, grantId);
    } try {
      JSONArray grantsJSON = (JSONArray) SerializerFactory.getSerializer("application/json").serialize( ousWithGrants, null);
      writeBackToClient( new JSONSuccess( grantsJSON ) );
    } 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, "Impossible to serialize the responce to the client", e);
    }
  }
View Full Code Here

        grantsJSON.put(MODEL_INSTANCE_NODES, modelInstances);
      }
     
      writeBackToClient( new JSONSuccess( grantsJSON ) );
    } 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, "Impossible to serialize the responce to the client", e);
    } catch (Exception e) {
      throw new SpagoBIServiceException(SERVICE_NAME, "Impossible to serialize the responce to the client", e);
    }
  }
View Full Code Here

  private void eraseGrant(Integer grantId){
    orUnitDao.eraseGrant(grantId);
    try {
      writeBackToClient( new JSONAcknowledge() );
    } catch (IOException e) {
      throw new SpagoBIServiceException(SERVICE_NAME, "Impossible to write back the responce to the client", e);
    }
  }
View Full Code Here

      logger.debug("prepared nodes to save of size:"+grantNodes.size());
      orUnitDao.insertNodeGrants(grantNodes, grant.getId());
      logger.debug("end saving process");
      writeBackToClient( new JSONAcknowledge() );
    } catch (IOException e) {
      throw new SpagoBIServiceException(SERVICE_NAME, "Impossible to write back the responce to the client", e);
    } catch (Exception e) {
      throw new SpagoBIServiceException(SERVICE_NAME, "Impossible to serialize the responce to the client", e);
    }
  }
View Full Code Here

    try {
      try {
        OrganizationalUnitSynchronizer sinc = new OrganizationalUnitSynchronizer();
        sinc.synchronize();
      } catch (Throwable t) {
        throw new SpagoBIServiceException(SERVICE_NAME, "Error while synchronizating organizational units: " + t.getMessage(), t);
      }
      try {
        writeBackToClient( new JSONAcknowledge() );
      } 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

    try {
      resDao = DAOFactory.getResourceDAO();
      resDao.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(RESOURCES_LIST)) {
     
      try {   
       
        Integer start = getAttributeAsInteger( START );
        Integer limit = getAttributeAsInteger( LIMIT );
       
        if(start==null){
          start = START_DEFAULT;
        }
        if(limit==null){
          limit = LIMIT_DEFAULT;
        }

        Integer totalResNum = resDao.countResources();
        List resources = resDao.loadPagedResourcesList(start,limit);
        logger.debug("Loaded resources list");
        JSONArray resourcesJSON = (JSONArray) SerializerFactory.getSerializer("application/json").serialize(resources, locale);
        JSONObject resourcesResponseJSON = createJSONResponseResources(resourcesJSON, totalResNum);

        writeBackToClient(new JSONSuccess(resourcesResponseJSON));

      } 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(RESOURCE_INSERT)) {
      String id = getAttributeAsString(ID);
      String code = getAttributeAsString(CODE);
      String name = getAttributeAsString(NAME);
      String description = getAttributeAsString(DESCRIPTION);
      String tablename = getAttributeAsString(TABLE_NAME);
      String columnname = getAttributeAsString(COLUMN_NAME);
      String resourceTypeCD = getAttributeAsString(NODE_TYPE_CODE);   
     
      List<Domain> domains = (List<Domain>)getSessionContainer().getAttribute("nodeTypesList");
     
        HashMap<String, Integer> domainIds = new HashMap<String, Integer> ();
        if(domains != null){
          for(int i=0; i< domains.size(); i++){
            domainIds.put(domains.get(i).getValueCd(), domains.get(i).getValueId());
          }
        }
       
        Integer resourceTypeID = domainIds.get(resourceTypeCD);
        if(resourceTypeID == null){
          logger.error("Resource type CD does not exist");
          throw new SpagoBIServiceException(SERVICE_NAME,  "Resource Type ID is undefined");
        }

      if (name != null && resourceTypeID != null && code != null) {
        Resource res = new Resource();
        res.setName(name);
        res.setType(resourceTypeCD);
        res.setTypeId(resourceTypeID);
        res.setCode(code);
       
        if(description != null){
          res.setDescr(description);
       
        if(tablename != null){
          res.setTable_name(tablename);
        }
        if(columnname != null){
          res.setColumn_name(columnname);
        }       
       
        try {
          if(id != null && !id.equals("") && !id.equals("0")){             
            res.setId(Integer.valueOf(id));
            resDao.modifyResource(res);
            logger.debug("Resource "+id+" updated");
            JSONObject attributesResponseSuccessJSON = new JSONObject();
            attributesResponseSuccessJSON.put("success", true);
            attributesResponseSuccessJSON.put("responseText", "Operation succeded");
            attributesResponseSuccessJSON.put("id", id);
            writeBackToClient( new JSONSuccess(attributesResponseSuccessJSON) );
          }else{
            Integer resourceID = resDao.insertResource(res);
            logger.debug("New Resource inserted");
            JSONObject attributesResponseSuccessJSON = new JSONObject();
            attributesResponseSuccessJSON.put("success", true);
            attributesResponseSuccessJSON.put("responseText", "Operation succeded");
            attributesResponseSuccessJSON.put("id", resourceID);
            writeBackToClient( new JSONSuccess(attributesResponseSuccessJSON) );
          }

        } catch (Throwable e) {
          logger.error(e.getMessage(), e);
          throw new SpagoBIServiceException(SERVICE_NAME,
              "Exception occurred while saving new resource", e);
        }
               
      }else{
        logger.error("Resource name, code or type are missing");
        throw new SpagoBIServiceException(SERVICE_NAME,  "Please fill resource name, code and type");
      }
    } else if (serviceType != null  && serviceType.equalsIgnoreCase(RESOURCE_DELETE)) {
      Integer id = getAttributeAsInteger(ID);
      try {
        resDao.deleteResource(id);
        logger.debug("Resource deleted");
        writeBackToClient( new JSONAcknowledge("Operation succeded") );
      } catch (Throwable e) {
        logger.error("Exception occurred while retrieving resource to delete", e);
        throw new SpagoBIServiceException(SERVICE_NAME,
            "Exception occurred while retrieving resource to delete", e);
      }
    }else if(serviceType == null){
      try {
        List nodeTypes = DAOFactory.getDomainDAO().loadListDomainsByType(RESOURCE_DOMAIN_TYPE);
        getSessionContainer().setAttribute("nodeTypesList", nodeTypes);
       
      } catch (EMFUserError e) {
        logger.error(e.getMessage(), e);
        throw new SpagoBIServiceException(SERVICE_NAME,
            "Exception retrieving resources types", e);
      }
    }
    logger.debug("OUT");
  }
View Full Code Here

          }
        }
      }
      writeBackToClient( new JSONSuccess( result ) );
    } 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);
    } catch (EMFInternalError e) {
      throw new SpagoBIServiceException(SERVICE_NAME, "Service internal error", e);
    } catch (EMFUserError e) {
      throw new SpagoBIServiceException(SERVICE_NAME, "Service internal error", 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.