/**
  * Action의 기준 경로를 반환한다.
  *
  * @param actionContext Action Context
  * @return Action의 기준 경로
  */
 public static String getActionBasePath(ActionContext actionContext) {
   String workingPath =
       ConfigurationManagerHelper.getConfigurationManagerHelper()
           .getConfigurationManager()
           .get("working.path");
   String jobId =
       actionContext.getWorkflowContext().getGlobalVariables().getProperty("JOB_STRING_ID");
   Date current =
       (Date)
           actionContext
               .getWorkflowContext()
               .getSchedulerContext()
               .getJobExecutionContext()
               .getMergedJobDataMap()
               .get(JobVariable.CURRENT);
   String workflowId = actionContext.getWorkflowContext().getWorkflowId();
   return workingPath
       + "/"
       + DateUtils.parseDate(current, "yyyy")
       + "/"
       + DateUtils.parseDate(current, "MM")
       + "/"
       + DateUtils.parseDate(current, "dd")
       + "/"
       + workflowId
       + "/"
       + jobId
       + "/"
       + JVMIDUtils.generateUUID();
 }
示例#2
0
 /**
  * Quartz Job Scheduler의 Job Data Map을 반환한다.
  *
  * @return Job Data Map
  */
 public JobDataMap getJobDataMap() {
   return actionContext
       .getWorkflowContext()
       .getSchedulerContext()
       .getJobExecutionContext()
       .getMergedJobDataMap();
 }
示例#3
0
 /** Action Handler 실행중 에러가 발생한 경우 에러를 처리한다. */
 private void fail() {
   try {
     actionContext.changeState(State.FAIL);
   } catch (Exception fe) {
     logger.warn("Action의 상태를 Fail로 기록할 수 없습니다. Data Store가 정상적이지 않을 수 있습니다.", fe);
   }
 }
示例#4
0
  @Override
  public void execute(WorkflowContext context) {
    this.actionContext = context.getCurrentActionContext();

    ELService service = this.actionContext.getWorkflowContext().getBean(ELService.class);
    this.evaluator = service.createEvaluator();
    this.globalVariables = actionContext.getWorkflowContext().getGlobalVariables();

    this.actionBasePath = ActionBasePathGenerator.getActionBasePath(actionContext);
    FileSystemUtils.testCorrentAndCreateDir(actionBasePath);

    this.logPath = actionBasePath + "/action.log";

    long actionLogMaxSize =
        ConfigurationManagerHelper.getConfigurationManagerHelper()
            .getConfigurationManager()
            .getLong("action.log.max.size");
    this.fileWriter = new FileWriter(logger, logPath, actionLogMaxSize);

    try {
      actionContext.changeState(State.PREPARE);
      before();

      actionContext.changeState(State.RUNNING);
      executeInternal();

      after();
      actionContext.changeState(State.SUCCESS);
    } catch (Exception ex) {
      actionContext.setObject(JobVariable.ACTION_EXCEPTION, ex);
      fail();
      String message =
          MessageFormatter.format(
                  "Cannot execute '{}' of action",
                  new String[] {context.getCurrentActionDescription()})
              .getMessage();
      throw new WorkflowException(message, ex);
    } finally {
      if (fileWriter != null) {
        try {
          fileWriter.close();
        } catch (Exception ex) {
        }
      }
    }
  }
示例#5
0
 /**
  * Workflow History를 반환한다.
  *
  * @return Workflow History
  */
 public WorkflowHistory getWorkflowHistory() {
   return (WorkflowHistory)
       actionContext.getWorkflowContext().getObject(JobVariable.WORKFLOW_HISTORY);
 }
示例#6
0
 /**
  * Action History를 반환한다.
  *
  * @return Action History
  */
 public ActionHistory getActionHistory() {
   return (ActionHistory) actionContext.getObject(JobVariable.ACTION_HISTORY);
 }