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


      meta.put("description", analysisMetadata.getDescription());       
      meta.put("scope", analysisMetadata.getScope());
           
     
      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) {
View Full Code Here

      responseJSON = analysisStateJSON;
     
      logger.debug("Genarated response: " + responseJSON.toString());
     
      try {
        writeBackToClient( new JSONSuccess(responseJSON) );
      } catch (IOException e) {
        String message = "Impossible to write back the responce to the client";
        throw new SpagoBIEngineServiceException(getActionName(), message, e);
      }     
     
View Full Code Here

      responseJSON.put("hierarchies", hierarchiesJSON);
     
      logger.info(responseJSON.toString());
     
      try {
        writeBackToClient( new JSONSuccess(responseJSON) );
      } catch (IOException e) {
        String message = "Impossible to write back the responce to the client";
        throw new SpagoBIEngineServiceException(getActionName(), message, e);
      }   
    } catch (Throwable t) {
View Full Code Here

      } // if no more in session is completed
      else statusWI=WorkEvent.WORK_COMPLETED;

      info=GeneralUtils.buildJSONObject(pid,statusWI);
      try {
        writeBackToClient( new JSONSuccess(info));
      } catch (IOException e) {
        String message = "Impossible to write back the responce to the client";
        throw new SpagoBIEngineServiceException(getActionName(), message, e);
      }
    }
View Full Code Here

        // if not in action mode don't send the response
        if(actionMode){
          try {
            info=GeneralUtils.buildJSONObject(pId,statusWI);
            writeBackToClient( new JSONSuccess(info));

          } catch (IOException e) {
            String message = "Impossible to write back the responce to the client";
            throw new SpagoBIEngineServiceException(getActionName(), message, e);
          }
        }
      }
      else{ // WORK is rejected
        if(actionMode){
          try {
            statusWI=fooRemoteWorkItem.getStatus();
            info=GeneralUtils.buildJSONObject(pId,statusWI);
            writeBackToClient( new JSONSuccess(info));
          } catch (IOException e) {
            String message = "Impossible to write back the responce to the client";
            throw new SpagoBIEngineServiceException(getActionName(), message, e);
          }
        }
View Full Code Here

    }
    else{   // if pidO not found just return an empty xml Object
      try {

        info=GeneralUtils.buildJSONObject(pid,0);
        writeBackToClient( new JSONSuccess(info));
      } catch (Exception e) {
        String message = "Impossible to write back the responce to the client";
        throw new SpagoBIEngineServiceException(getActionName(), message, e);
      }

      return;


    }

    super.service(request, response);
    HttpSession session=getHttpSession();

    // Get document id, must find
//    String document_id=null;
//    Object document_idO=null;
//    document_idO=request.getAttribute("DOCUMENT_ID");
//    if(document_idO!=null){
//      document_id=document_idO.toString();
//    }
//    else{
//      document_id="";
//      logger.error("could not retrieve document id");
//      throw new SpagoBIEngineServiceException(getActionName(), "could not find document id");
//    }

    CommonjWorkContainer container=null;
    ProcessesStatusContainer processesStatusContainer = ProcessesStatusContainer.getInstance();
    Object o=processesStatusContainer.getPidContainerMap().get(pid);
    //recover from session, if does not find means work is completed
    //Object o=session.getAttribute("SBI_PROCESS_"+document_id);
    try{
      int statusWI;

      if(o!=null){      // object found in session, work could be not started, running or completed

        container=(CommonjWorkContainer)o;
        FooRemoteWorkItem fooRwi=container.getFooRemoteWorkItem();
        WorkItem wi=container.getWorkItem();

        // if WorkItem is not set means work has never been started
        if(fooRwi!=null && wi!=null){
          statusWI=wi.getStatus();
          // if finds that work is finished delete the attribute from session
          if(statusWI==WorkEvent.WORK_COMPLETED){
            logger.debug("Work is finished - remove from session");
            //session.removeAttribute("SBI_PROCESS_"+document_id);
            processesStatusContainer.getPidContainerMap().remove(pid);
          }
        }
        else{
          // if not workitem is set means that is not started yet or has been cancelled by listener!?!
          statusWI=0;
        }
      }
      else{
        // No more present in session, so it has been deleted
        statusWI=WorkEvent.WORK_COMPLETED;
      }

      info=GeneralUtils.buildJSONObject(pid,statusWI);
      logger.debug(GeneralUtils.getEventMessage(statusWI));
      try {
        writeBackToClient( new JSONSuccess(info));
      } catch (IOException e) {
        String message = "Impossible to write back the responce to the client";
        throw new SpagoBIEngineServiceException(getActionName(), message, e);
      }
View Full Code Here

    }
    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 {
View Full Code Here

      logger.debug("Delete config");
      Integer id = this.getAttributeAsInteger("ID");
      configDao.delete(id);
      JSONObject response = new JSONObject();
      response.put("ID", id);
      writeBackToClient(new JSONSuccess(response));

    } catch (Throwable e) {
      logger.error("Exception occurred while retrieving config data", e);
      throw new SpagoBIServiceException(SERVICE_NAME,
          "Impossible to delete config", e);
View Full Code Here

      JSONArray configListJSON = (JSONArray) SerializerFactory
          .getSerializer("application/json").serialize(configList,
              this.getLocale());
      JSONObject response = new JSONObject();
      response.put("response", configListJSON);
      writeBackToClient(new JSONSuccess(response));

    } catch (Throwable e) {
      logger.error("Exception occurred while retrieving config data", e);
      throw new SpagoBIServiceException(SERVICE_NAME,
          "Exception occurred while retrieving config data", 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.