Package it.eng.spagobi.services.proxy

Examples of it.eng.spagobi.services.proxy.EventServiceProxy


    Map startEventParams = new HashMap();
    startEventParams.put(EVENT_TYPE, DOCUMENT_EXECUTION_START);
    startEventParams.put(BIOBJECT_ID, _parameters.get(EngineConstants.ENV_DOCUMENT_ID));
 
    Integer startEventId = null;
    EventServiceProxy eventServiceProxy = (EventServiceProxy)_parameters.get( EngineConstants.ENV_EVENT_SERVICE_PROXY);
   
 
    try {
 
        String startEventParamsStr = getParamsStr(startEventParams);
 
        eventServiceProxy.fireEvent(startExecutionEventDescription + parametersList, startEventParamsStr,
          TALEND_ROLES_HANDLER_CLASS_NAME, TALEND_PRESENTAION_HANDLER_CLASS_NAME);
        logger.debug("Start Fire Event");
 
    } catch (Exception e) {
        logger.error("problems while registering the start process event", e);
    }
 
    if (_command == null) {
        logger.error("No command to be executed");
        return;
    }
 
    Map endEventParams = new HashMap();
    endEventParams.put(EVENT_TYPE, DOCUMENT_EXECUTION_END);
    // endEventParams.put("biobj-path", params.get(TEMPLATE_PATH));
    endEventParams.put(BIOBJECT_ID, _parameters.get("document"));
    if (startEventId != null) {
        endEventParams.put(START_EVENT_ID, startEventId.toString());
    }
 
    String endExecutionEventDescription = null;
    BufferedReader input = null;
    try {
        logger.debug("Java Command:"+_command);
        logger.debug("Executable Job Dir:"+_executableJobDir);
        Process p = Runtime.getRuntime().exec(_command, _envr, _executableJobDir);
 
        // any error message?
            StreamGobbler errorGobbler = new
                StreamGobbler(p.getErrorStream(), "ERROR");           
           
            // any output?
            StreamGobbler outputGobbler = new
                StreamGobbler(p.getInputStream(), "OUTPUT");
               
            // kick them off
            errorGobbler.start();
            outputGobbler.start();
                                 
       
       
        int exitCode = p.waitFor();
      
             
        //CODICE DA USARE EVENTUALMENTE IN FUTURO CON ALTRE MODIFICHE:
        /*this.talendJobClass = Class.forName(talendJobClassName);
        this.runJob = this.talendJobClass.getMethod("runJob", new  Class[]{String[].class});
        int status = ((Integer)runJob.invoke(null,  mainMethodParams)).intValue(); */
       
        endExecutionEventDescription = "${talend.execution.executionOk}<br/>";
        endEventParams.put("operation-result", "success");
 
    } catch (Throwable e) {
        logger.error("Error while executing command " + _command, e);
        endExecutionEventDescription = "${talend.execution.executionKo}<br/>";
        endEventParams.put("operation-result", "failure");
    } finally {
        if (_filesToBeDeletedAfterJobExecution != null && _filesToBeDeletedAfterJobExecution.size() > 0) {
      Iterator it = _filesToBeDeletedAfterJobExecution.iterator();
      while (it.hasNext()) {
          File aFile = (File) it.next();
          if (aFile != null && aFile.exists())
        FileUtils.deleteDirectory(aFile);
      }
        }
        if (input != null) {
      try {
          input.close();
      } catch (IOException e) {
          e.printStackTrace();
      }
        }
    }
 
    try {
 
        String endEventParamsStr = getParamsStr(endEventParams);
 
        eventServiceProxy.fireEvent(endExecutionEventDescription + parametersList, endEventParamsStr,
          TALEND_ROLES_HANDLER_CLASS_NAME, TALEND_PRESENTAION_HANDLER_CLASS_NAME);
        logger.debug("End fire event");
 
    } catch (Exception e) {
        logger.error("problems while registering the end process event", e);
View Full Code Here


    return auditProxy;
  }

  public EventServiceProxy getEventServiceProxy() {
    if (eventProxy == null) {
      eventProxy = new EventServiceProxy(getUserIdentifier(),
          getHttpSession());
    }

    return eventProxy;
  }
View Full Code Here

    Map startEventParams = new HashMap();       
    startEventParams.put(EventServiceProxy.EVENT_TYPE, EventServiceProxy.DOCUMENT_EXECUTION_START);
    startEventParams.put(EventServiceProxy.BIOBJECT_ID, _parameters.get("document"));

    Integer startEventId = null;
    EventServiceProxy eventServiceProxy=new EventServiceProxy(userId,_session);

    try {
      eventServiceProxy.fireEvent(startExecutionEventDescription + parametersList, startEventParams, TALEND_ROLES_HANDLER_CLASS_NAME, TALEND_PRESENTAION_HANDLER_CLASS_NAME);

    } catch (Exception e) {
      logger.error(this.getClass().getName() + ":run: problems while registering the start process event", e);
    }

    if (_command == null) {
      logger.error("No command to be executed");
      return;
    }

    Map endEventParams = new HashMap();       
    endEventParams.put(EventServiceProxy.EVENT_TYPE, EventServiceProxy.DOCUMENT_EXECUTION_END);
    endEventParams.put(EventServiceProxy.BIOBJECT_ID, _parameters.get("document"));
    if (startEventId != null) {
      endEventParams.put(EventServiceProxy.START_EVENT_ID, startEventId.toString());
    }

    String endExecutionEventDescription = null;
    BufferedReader input = null;
    try {

      Process p = Runtime.getRuntime().exec(_command, _envr, _executableJobDir);

      /*
      input = new BufferedReader (new InputStreamReader(p.getInputStream()));
      while ((line = input.readLine()) != null) {
        logger.debug(line);
        //System.out.println(line);
      }*/

      endExecutionEventDescription = "${talend.execution.executionOk}<br/>";
      endEventParams.put("operation-result", "success");

    } catch (Exception e){
      logger.error("Error while executing command " + _command, e);
      endExecutionEventDescription = "${talend.execution.executionKo}<br/>";
      endEventParams.put("operation-result", "failure");
    } finally {
      //clean temporary files
      if (_filesToBeDeletedAfterJobExecution != null && _filesToBeDeletedAfterJobExecution.size() > 0) {
        Iterator it = _filesToBeDeletedAfterJobExecution.iterator();
        while (it.hasNext()) {
          File aFile = (File) it.next();
          if (aFile != null && aFile.exists()) FileUtils.deleteDirectory(aFile);
        }
      }
      if (input != null) {
        try {
          input.close();
        } catch (IOException e) {
          e.printStackTrace();
          logger.error("IO error");
        }
      }
    }
    try
      eventServiceProxy.fireEvent(endExecutionEventDescription + parametersList, endEventParams, TALEND_ROLES_HANDLER_CLASS_NAME, TALEND_PRESENTAION_HANDLER_CLASS_NAME);
    } catch (Exception e) {
      logger.error(":run: problems while registering the end process event: "+e);
    }


View Full Code Here

  }


     public EventServiceProxy getEventServiceProxy() {
       if(eventServiceProxy == null ) {
         eventServiceProxy = new EventServiceProxy(getUserIdentifier(), getHttpSession());
       }    
       return eventServiceProxy;
     }
View Full Code Here

      AuditServiceProxy auditServiceProxy=null;
      Object auditO=parameters.get(EngineConstants.ENV_AUDIT_SERVICE_PROXY);     
      if(auditO!=null) auditServiceProxy=(AuditServiceProxy)auditO;
      Object eventO=parameters.get(EngineConstants.ENV_EVENT_SERVICE_PROXY);
      EventServiceProxy eventServiceProxy=null;
      eventServiceProxy=(EventServiceProxy)eventO;

      Object executionRoleO=parameters.get(SpagoBIConstants.EXECUTION_ROLE);
      String executionRole=executionRoleO!=null ? executionRoleO.toString() : "";
View Full Code Here

TOP

Related Classes of it.eng.spagobi.services.proxy.EventServiceProxy

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.