@Test public void testSimpleLog() throws Exception { EasyMock.replay(workflow, instance); operation.start(workflow, null); }
@Override public WorkflowOperationResult start(WorkflowInstance workflowInstance, JobContext context) throws WorkflowOperationException { WorkflowOperationInstance operation = workflowInstance.getCurrentOperation(); String directoryPath = StringUtils.trimToNull(operation.getConfiguration("directory")); File directory = null; if (directoryPath != null) { directory = new File(directoryPath); try { FileUtils.forceMkdir(directory); } catch (IOException e) { throw new WorkflowOperationException(String.format("Failed to create output directory '%s'", directoryPath), e); } } boolean logMediaPackageJSON = BooleanUtils.toBoolean(operation.getConfiguration("mediapackage-json")); boolean logMediaPackageXML = BooleanUtils.toBoolean(operation.getConfiguration("mediapackage-xml")); boolean logWorkflowInstance = BooleanUtils.toBoolean(operation.getConfiguration("workflowinstance-xml")); if (!(logMediaPackageJSON || logMediaPackageXML || logWorkflowInstance)) { logMediaPackageJSON = true; } MediaPackage mediaPackage = workflowInstance.getMediaPackage(); if (logMediaPackageJSON) { String filename = String.format("workflow-%d-%d-mediapackage-%s.json", workflowInstance.getId(), operation.getId(), mediaPackage.getIdentifier()); saveOrLog(MediaPackageParser.getAsJSON(mediaPackage), directory, filename); } if (logMediaPackageXML) { String filename = String.format("workflow-%d-%d-mediapackage-%s.xml", workflowInstance.getId(), operation.getId(), mediaPackage.getIdentifier()); saveOrLog(MediaPackageParser.getAsXml(mediaPackage), directory, filename); } if (logWorkflowInstance) { String filename = String.format("workflow-%d-%d.xml", workflowInstance.getId(), operation.getId()); try { saveOrLog(WorkflowParser.toXml(workflowInstance), directory, filename); } catch (WorkflowParsingException e) { throw new WorkflowOperationException(e); } } return createResult(mediaPackage, Action.CONTINUE); }
LoggingWorkflowOperationHandler extends AbstractWorkflowOperationHandler { @Override public WorkflowOperationResult start(WorkflowInstance workflowInstance, JobContext context) throws WorkflowOperationException { WorkflowOperationInstance operation = workflowInstance.getCurrentOperation(); String directoryPath = StringUtils.trimToNull(operation.getConfiguration("directory")); File directory = null; if (directoryPath != null) { directory = new File(directoryPath); try { FileUtils.forceMkdir(directory); } catch (IOException e) { throw new WorkflowOperationException(String.format("Failed to create output directory '%s'", directoryPath), e); } } boolean logMediaPackageJSON = BooleanUtils.toBoolean(operation.getConfiguration("mediapackage-json")); boolean logMediaPackageXML = BooleanUtils.toBoolean(operation.getConfiguration("mediapackage-xml")); boolean logWorkflowInstance = BooleanUtils.toBoolean(operation.getConfiguration("workflowinstance-xml")); if (!(logMediaPackageJSON || logMediaPackageXML || logWorkflowInstance)) { logMediaPackageJSON = true; } MediaPackage mediaPackage = workflowInstance.getMediaPackage(); if (logMediaPackageJSON) { String filename = String.format("workflow-%d-%d-mediapackage-%s.json", workflowInstance.getId(), operation.getId(), mediaPackage.getIdentifier()); saveOrLog(MediaPackageParser.getAsJSON(mediaPackage), directory, filename); } if (logMediaPackageXML) { String filename = String.format("workflow-%d-%d-mediapackage-%s.xml", workflowInstance.getId(), operation.getId(), mediaPackage.getIdentifier()); saveOrLog(MediaPackageParser.getAsXml(mediaPackage), directory, filename); } if (logWorkflowInstance) { String filename = String.format("workflow-%d-%d.xml", workflowInstance.getId(), operation.getId()); try { saveOrLog(WorkflowParser.toXml(workflowInstance), directory, filename); } catch (WorkflowParsingException e) { throw new WorkflowOperationException(e); } } return createResult(mediaPackage, Action.CONTINUE); } }
LoggingWorkflowOperationHandler extends AbstractWorkflowOperationHandler { @Override public WorkflowOperationResult start(WorkflowInstance workflowInstance, JobContext context) throws WorkflowOperationException { WorkflowOperationInstance operation = workflowInstance.getCurrentOperation(); String directoryPath = StringUtils.trimToNull(operation.getConfiguration("directory")); File directory = null; if (directoryPath != null) { directory = new File(directoryPath); try { FileUtils.forceMkdir(directory); } catch (IOException e) { throw new WorkflowOperationException(String.format("Failed to create output directory '%s'", directoryPath), e); } } boolean logMediaPackageJSON = BooleanUtils.toBoolean(operation.getConfiguration("mediapackage-json")); boolean logMediaPackageXML = BooleanUtils.toBoolean(operation.getConfiguration("mediapackage-xml")); boolean logWorkflowInstance = BooleanUtils.toBoolean(operation.getConfiguration("workflowinstance-xml")); if (!(logMediaPackageJSON || logMediaPackageXML || logWorkflowInstance)) { logMediaPackageJSON = true; } MediaPackage mediaPackage = workflowInstance.getMediaPackage(); if (logMediaPackageJSON) { String filename = String.format("workflow-%d-%d-mediapackage-%s.json", workflowInstance.getId(), operation.getId(), mediaPackage.getIdentifier()); saveOrLog(MediaPackageParser.getAsJSON(mediaPackage), directory, filename); } if (logMediaPackageXML) { String filename = String.format("workflow-%d-%d-mediapackage-%s.xml", workflowInstance.getId(), operation.getId(), mediaPackage.getIdentifier()); saveOrLog(MediaPackageParser.getAsXml(mediaPackage), directory, filename); } if (logWorkflowInstance) { String filename = String.format("workflow-%d-%d.xml", workflowInstance.getId(), operation.getId()); try { saveOrLog(WorkflowParser.toXml(workflowInstance), directory, filename); } catch (WorkflowParsingException e) { throw new WorkflowOperationException(e); } } return createResult(mediaPackage, Action.CONTINUE); }  }
LoggingWorkflowOperationHandler extends AbstractWorkflowOperationHandler { @Override public WorkflowOperationResult start(WorkflowInstance workflowInstance, JobContext context) throws WorkflowOperationException { WorkflowOperationInstance operation = workflowInstance.getCurrentOperation(); String directoryPath = StringUtils.trimToNull(operation.getConfiguration("directory")); File directory = null; if (directoryPath != null) { directory = new File(directoryPath); try { FileUtils.forceMkdir(directory); } catch (IOException e) { throw new WorkflowOperationException(String.format("Failed to create output directory '%s'", directoryPath), e); } } boolean logMediaPackageJSON = BooleanUtils.toBoolean(operation.getConfiguration("mediapackage-json")); boolean logMediaPackageXML = BooleanUtils.toBoolean(operation.getConfiguration("mediapackage-xml")); boolean logWorkflowInstance = BooleanUtils.toBoolean(operation.getConfiguration("workflowinstance-xml")); if (!(logMediaPackageJSON || logMediaPackageXML || logWorkflowInstance)) { logMediaPackageJSON = true; } MediaPackage mediaPackage = workflowInstance.getMediaPackage(); if (logMediaPackageJSON) { String filename = String.format("workflow-%d-%d-mediapackage-%s.json", workflowInstance.getId(), operation.getId(), mediaPackage.getIdentifier()); saveOrLog(MediaPackageParser.getAsJSON(mediaPackage), directory, filename); } if (logMediaPackageXML) { String filename = String.format("workflow-%d-%d-mediapackage-%s.xml", workflowInstance.getId(), operation.getId(), mediaPackage.getIdentifier()); saveOrLog(MediaPackageParser.getAsXml(mediaPackage), directory, filename); } if (logWorkflowInstance) { String filename = String.format("workflow-%d-%d.xml", workflowInstance.getId(), operation.getId()); try { saveOrLog(WorkflowParser.toXml(workflowInstance), directory, filename); } catch (WorkflowParsingException e) { throw new WorkflowOperationException(e); } } return createResult(mediaPackage, Action.CONTINUE); }  @Override WorkflowOperationResult start(WorkflowInstance workflowInstance, JobContext context); }
LoggingWorkflowOperationHandler extends AbstractWorkflowOperationHandler { @Override public WorkflowOperationResult start(WorkflowInstance workflowInstance, JobContext context) throws WorkflowOperationException { WorkflowOperationInstance operation = workflowInstance.getCurrentOperation(); String directoryPath = StringUtils.trimToNull(operation.getConfiguration("directory")); File directory = null; if (directoryPath != null) { directory = new File(directoryPath); try { FileUtils.forceMkdir(directory); } catch (IOException e) { throw new WorkflowOperationException(String.format("Failed to create output directory '%s'", directoryPath), e); } } boolean logMediaPackageJSON = BooleanUtils.toBoolean(operation.getConfiguration("mediapackage-json")); boolean logMediaPackageXML = BooleanUtils.toBoolean(operation.getConfiguration("mediapackage-xml")); boolean logWorkflowInstance = BooleanUtils.toBoolean(operation.getConfiguration("workflowinstance-xml")); if (!(logMediaPackageJSON || logMediaPackageXML || logWorkflowInstance)) { logMediaPackageJSON = true; } MediaPackage mediaPackage = workflowInstance.getMediaPackage(); if (logMediaPackageJSON) { String filename = String.format("workflow-%d-%d-mediapackage-%s.json", workflowInstance.getId(), operation.getId(), mediaPackage.getIdentifier()); saveOrLog(MediaPackageParser.getAsJSON(mediaPackage), directory, filename); } if (logMediaPackageXML) { String filename = String.format("workflow-%d-%d-mediapackage-%s.xml", workflowInstance.getId(), operation.getId(), mediaPackage.getIdentifier()); saveOrLog(MediaPackageParser.getAsXml(mediaPackage), directory, filename); } if (logWorkflowInstance) { String filename = String.format("workflow-%d-%d.xml", workflowInstance.getId(), operation.getId()); try { saveOrLog(WorkflowParser.toXml(workflowInstance), directory, filename); } catch (WorkflowParsingException e) { throw new WorkflowOperationException(e); } } return createResult(mediaPackage, Action.CONTINUE); }  @Override WorkflowOperationResult start(WorkflowInstance workflowInstance, JobContext context);  }