Package it.eng.spagobi.utilities.service

Examples of it.eng.spagobi.utilities.service.JSONSuccess


      if(!result.trim().toLowerCase().startsWith("ok")) {
        throw new SpagoBIEngineServiceException(getActionName(), result);
      }
     
      try {
        writeBackToClient( new JSONSuccess( result ) );
      } catch (IOException e) {
        String message = "Impossible to write back the responce to the client";
        throw new SpagoBIEngineServiceException(getActionName(), message, e);
      }
     
View Full Code Here


     
      queryJSON = serializeQuery(query);
      nodeJSON = createNode(queryJSON);
     
      try {
        writeBackToClient( new JSONSuccess(nodeJSON) );
      } catch (IOException e) {
        String message = "Impossible to write back the responce to the client";
        throw new SpagoBIEngineServiceException(getActionName(), message, e);
      }
     
View Full Code Here

        List<SbiUdp> udpList = udpDao.loadPagedUdpList(start,limit);
        logger.debug("Loaded udp list");
        JSONArray udpJSON = (JSONArray) SerializerFactory.getSerializer("application/json").serialize(udpList,locale);
        JSONObject udpResponseJSON = createJSONResponseUdp(udpJSON, totalNum);

        writeBackToClient(new JSONSuccess(udpResponseJSON));

      } catch (Throwable e) {
        logger.error(e.getMessage(), e);
        try {
          writeBackToClient("Exception occurred while retrieving user defined properties");
        } catch (IOException e1) {
          logger.error(e1.getMessage(), e1);
        }
        throw new SpagoBIServiceException(SERVICE_NAME,
            "Exception occurred while retrieving user defined properties", e);
      }
     
    }else if(serviceType != null && serviceType.equals(UDP_DETAIL)){
      try {
        String name = getAttributeAsString(NAME);
        String label = getAttributeAsString(LABEL);
        String description = getAttributeAsString(DESCRIPTION);
        String typeStr = getAttributeAsString(TYPE);     
        Domain tmpDomain = daoDomain.loadDomainByCodeAndValue(UDP_TYPES, typeStr);
        Integer type = tmpDomain.getValueId();
        String familyStr = getAttributeAsString(FAMILY);
        tmpDomain = daoDomain.loadDomainByCodeAndValue(UDP_FAMILIES, familyStr);
        Integer family = tmpDomain.getValueId();
        Boolean isMultivalue = Boolean.valueOf(getAttributeAsBoolean(IS_MULTIVALUE));
       
        String id = getAttributeAsString(ID);
       
        SbiUdp udp = new SbiUdp();
        udp.setName(name);
        udp.setLabel(label);
        udp.setDescription(description);
        udp.setTypeId(type);
        udp.setFamilyId(family);
        udp.setIsMultivalue(isMultivalue);
     
        if(id != null && !id.equals("") && !id.equals("0")){             
          udp.setUdpId(Integer.valueOf(id));
          udpDao.update(udp);
          logger.debug("User attribute "+id+" updated");
          JSONObject attributesResponseSuccessJSON = new JSONObject()
          attributesResponseSuccessJSON.put("success", true)
          attributesResponseSuccessJSON.put("responseText", "Operation succeded");
          writeBackToClient( new JSONSuccess(attributesResponseSuccessJSON) );
        }else{
          Integer udpID = udpDao.insert(udp);
          logger.debug("New User Attribute inserted");
          JSONObject attributesResponseSuccessJSON = new JSONObject();
          attributesResponseSuccessJSON.put("success", true);
          attributesResponseSuccessJSON.put("responseText", "Operation succeded");
          attributesResponseSuccessJSON.put("id", udpID);
          writeBackToClient( new JSONSuccess(attributesResponseSuccessJSON) );
        }
      } catch (JSONException e) {
        logger.error(e.getMessage(), e);
        throw new SpagoBIServiceException(SERVICE_NAME,
            "Exception occurred while saving new user attribute",
View Full Code Here

     
      String callback = getAttributeAsString( CALLBACK );
     
      try {
        if(callback == null) {
          writeBackToClient( new JSONSuccess( array ));
        } else {
          writeBackToClient( new JSONSuccess( array, callback ));
        }
      } catch (IOException e) {
        String message = "Impossible to write back the responce to the client";
        throw new SpagoBIEngineServiceException(getActionName(), message, e);
      }
View Full Code Here

      } catch(Throwable t) {
        throw new SpagoBIEngineServiceException(getActionName(), "Impossible to serialize selected fields list", t);
      }
     
      try {
        writeBackToClient( new JSONSuccess(results) );
      } catch (IOException e) {
        throw new SpagoBIEngineServiceException(getActionName(), "Impossible to write back the responce to the client", e);
      }
     
    }  finally {
View Full Code Here

     
      JSONObject toReturn = new JSONObject();
      toReturn.put("sql", sqlQuery);
     
      try {
        writeBackToClient( new JSONSuccess(toReturn) );
      } catch (IOException e) {
        String message = "Impossible to write back the responce to the client";
        throw new SpagoBIEngineServiceException(getActionName(), message, e);
      }
     
View Full Code Here

     
      CrossTab crossTab = new CrossTab(dataStore, crosstabDefinition);
      JSONObject crossTabDefinition = crossTab.getJSONCrossTab();
     
      try {
        writeBackToClient( new JSONSuccess(crossTabDefinition) );
      } catch (IOException e) {
        String message = "Impossible to write back the responce to the client";
        throw new SpagoBIEngineServiceException(getActionName(), message, e);
      }
     
View Full Code Here

        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);
View Full Code Here

      Integer totalItemsNum = dsDao.countDatasets();
      List<SbiDataSetConfig> items = getListOfGenericDatasetsForKpi(dsDao);
      logger.debug("Loaded items list");
      JSONArray itemsJSON = (JSONArray) SerializerFactory.getSerializer("application/json").serialize(items, locale);
      JSONObject responseJSON = createJSONResponse(itemsJSON, totalItemsNum);
      writeBackToClient(new JSONSuccess(responseJSON));

    } catch (Throwable e) {
      logger.error("Exception occurred while retrieving items", e);
      throw new SpagoBIServiceException(SERVICE_NAME, "sbi.general.retrieveItemsError", e);
    }
View Full Code Here

      Integer totalItemsNum = dsDao.countDatasets();
      List<GuiGenericDataSet> items = getListOfGenericDatasets(dsDao);
      logger.debug("Loaded items list");
      JSONArray itemsJSON = (JSONArray) SerializerFactory.getSerializer("application/json").serialize(items, locale);
      JSONObject responseJSON = createJSONResponse(itemsJSON, totalItemsNum);
      writeBackToClient(new JSONSuccess(responseJSON));

    } catch (Throwable e) {
      logger.error("Exception occurred while retrieving items", e);
      throw new SpagoBIServiceException(SERVICE_NAME,  "sbi.general.retrieveItemsError", e);
    }
View Full Code Here

TOP

Related Classes of it.eng.spagobi.utilities.service.JSONSuccess

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.