@Test(expected = WorkflowOperationException.class) public void testNoMediaPackage() throws Exception { operationHandler.start(workflowInstance, null); }
@Override public WorkflowOperationResult start(WorkflowInstance workflowInstance, JobContext context) throws WorkflowOperationException { final WorkflowOperationInstance operation = workflowInstance.getCurrentOperation(); final String configuredMediaPackageID = trimToEmpty(operation.getConfiguration(MEDIA_PACKAGE_ID)); final String configuredWorkflowDefinition = trimToEmpty(operation.getConfiguration(WORKFLOW_DEFINITION)); Opt<MediaPackage> mpOpt = assetManager.getMediaPackage(configuredMediaPackageID); if (mpOpt.isNone()) { throw new WorkflowOperationException(format("Media package %s not found", configuredMediaPackageID)); } final MediaPackage mp = mpOpt.get(); final Map<String, String> properties = new HashMap<>(); for (String key : operation.getConfigurationKeys()) { if (MEDIA_PACKAGE_ID.equals(key) || WORKFLOW_DEFINITION.equals(key)) { continue; } properties.put(key, operation.getConfiguration(key)); } try { final WorkflowDefinition workflowDefinition = workflowService.getWorkflowDefinitionById( configuredWorkflowDefinition); logger.info("Starting '{}' workflow for media package '{}'", configuredWorkflowDefinition, configuredMediaPackageID); workflowService.start(workflowDefinition, mp, properties); } catch (NotFoundException e) { throw new WorkflowOperationException(format("Workflow Definition '%s' not found", configuredWorkflowDefinition)); } catch (Exception e) { throw new WorkflowOperationException(e); } return createResult(WorkflowOperationResult.Action.CONTINUE); }
StartWorkflowWorkflowOperationHandler extends AbstractWorkflowOperationHandler { @Override public WorkflowOperationResult start(WorkflowInstance workflowInstance, JobContext context) throws WorkflowOperationException { final WorkflowOperationInstance operation = workflowInstance.getCurrentOperation(); final String configuredMediaPackageID = trimToEmpty(operation.getConfiguration(MEDIA_PACKAGE_ID)); final String configuredWorkflowDefinition = trimToEmpty(operation.getConfiguration(WORKFLOW_DEFINITION)); Opt<MediaPackage> mpOpt = assetManager.getMediaPackage(configuredMediaPackageID); if (mpOpt.isNone()) { throw new WorkflowOperationException(format("Media package %s not found", configuredMediaPackageID)); } final MediaPackage mp = mpOpt.get(); final Map<String, String> properties = new HashMap<>(); for (String key : operation.getConfigurationKeys()) { if (MEDIA_PACKAGE_ID.equals(key) || WORKFLOW_DEFINITION.equals(key)) { continue; } properties.put(key, operation.getConfiguration(key)); } try { final WorkflowDefinition workflowDefinition = workflowService.getWorkflowDefinitionById( configuredWorkflowDefinition); logger.info("Starting '{}' workflow for media package '{}'", configuredWorkflowDefinition, configuredMediaPackageID); workflowService.start(workflowDefinition, mp, properties); } catch (NotFoundException e) { throw new WorkflowOperationException(format("Workflow Definition '%s' not found", configuredWorkflowDefinition)); } catch (Exception e) { throw new WorkflowOperationException(e); } return createResult(WorkflowOperationResult.Action.CONTINUE); } }
StartWorkflowWorkflowOperationHandler extends AbstractWorkflowOperationHandler { @Override public WorkflowOperationResult start(WorkflowInstance workflowInstance, JobContext context) throws WorkflowOperationException { final WorkflowOperationInstance operation = workflowInstance.getCurrentOperation(); final String configuredMediaPackageID = trimToEmpty(operation.getConfiguration(MEDIA_PACKAGE_ID)); final String configuredWorkflowDefinition = trimToEmpty(operation.getConfiguration(WORKFLOW_DEFINITION)); Opt<MediaPackage> mpOpt = assetManager.getMediaPackage(configuredMediaPackageID); if (mpOpt.isNone()) { throw new WorkflowOperationException(format("Media package %s not found", configuredMediaPackageID)); } final MediaPackage mp = mpOpt.get(); final Map<String, String> properties = new HashMap<>(); for (String key : operation.getConfigurationKeys()) { if (MEDIA_PACKAGE_ID.equals(key) || WORKFLOW_DEFINITION.equals(key)) { continue; } properties.put(key, operation.getConfiguration(key)); } try { final WorkflowDefinition workflowDefinition = workflowService.getWorkflowDefinitionById( configuredWorkflowDefinition); logger.info("Starting '{}' workflow for media package '{}'", configuredWorkflowDefinition, configuredMediaPackageID); workflowService.start(workflowDefinition, mp, properties); } catch (NotFoundException e) { throw new WorkflowOperationException(format("Workflow Definition '%s' not found", configuredWorkflowDefinition)); } catch (Exception e) { throw new WorkflowOperationException(e); } return createResult(WorkflowOperationResult.Action.CONTINUE); }  }
StartWorkflowWorkflowOperationHandler extends AbstractWorkflowOperationHandler { @Override public WorkflowOperationResult start(WorkflowInstance workflowInstance, JobContext context) throws WorkflowOperationException { final WorkflowOperationInstance operation = workflowInstance.getCurrentOperation(); final String configuredMediaPackageID = trimToEmpty(operation.getConfiguration(MEDIA_PACKAGE_ID)); final String configuredWorkflowDefinition = trimToEmpty(operation.getConfiguration(WORKFLOW_DEFINITION)); Opt<MediaPackage> mpOpt = assetManager.getMediaPackage(configuredMediaPackageID); if (mpOpt.isNone()) { throw new WorkflowOperationException(format("Media package %s not found", configuredMediaPackageID)); } final MediaPackage mp = mpOpt.get(); final Map<String, String> properties = new HashMap<>(); for (String key : operation.getConfigurationKeys()) { if (MEDIA_PACKAGE_ID.equals(key) || WORKFLOW_DEFINITION.equals(key)) { continue; } properties.put(key, operation.getConfiguration(key)); } try { final WorkflowDefinition workflowDefinition = workflowService.getWorkflowDefinitionById( configuredWorkflowDefinition); logger.info("Starting '{}' workflow for media package '{}'", configuredWorkflowDefinition, configuredMediaPackageID); workflowService.start(workflowDefinition, mp, properties); } catch (NotFoundException e) { throw new WorkflowOperationException(format("Workflow Definition '%s' not found", configuredWorkflowDefinition)); } catch (Exception e) { throw new WorkflowOperationException(e); } return createResult(WorkflowOperationResult.Action.CONTINUE); }  void setAssetManager(AssetManager assetManager); void setWorkflowService(WorkflowService workflowService); @Override WorkflowOperationResult start(WorkflowInstance workflowInstance, JobContext context); }
StartWorkflowWorkflowOperationHandler extends AbstractWorkflowOperationHandler { @Override public WorkflowOperationResult start(WorkflowInstance workflowInstance, JobContext context) throws WorkflowOperationException { final WorkflowOperationInstance operation = workflowInstance.getCurrentOperation(); final String configuredMediaPackageID = trimToEmpty(operation.getConfiguration(MEDIA_PACKAGE_ID)); final String configuredWorkflowDefinition = trimToEmpty(operation.getConfiguration(WORKFLOW_DEFINITION)); Opt<MediaPackage> mpOpt = assetManager.getMediaPackage(configuredMediaPackageID); if (mpOpt.isNone()) { throw new WorkflowOperationException(format("Media package %s not found", configuredMediaPackageID)); } final MediaPackage mp = mpOpt.get(); final Map<String, String> properties = new HashMap<>(); for (String key : operation.getConfigurationKeys()) { if (MEDIA_PACKAGE_ID.equals(key) || WORKFLOW_DEFINITION.equals(key)) { continue; } properties.put(key, operation.getConfiguration(key)); } try { final WorkflowDefinition workflowDefinition = workflowService.getWorkflowDefinitionById( configuredWorkflowDefinition); logger.info("Starting '{}' workflow for media package '{}'", configuredWorkflowDefinition, configuredMediaPackageID); workflowService.start(workflowDefinition, mp, properties); } catch (NotFoundException e) { throw new WorkflowOperationException(format("Workflow Definition '%s' not found", configuredWorkflowDefinition)); } catch (Exception e) { throw new WorkflowOperationException(e); } return createResult(WorkflowOperationResult.Action.CONTINUE); }  void setAssetManager(AssetManager assetManager); void setWorkflowService(WorkflowService workflowService); @Override WorkflowOperationResult start(WorkflowInstance workflowInstance, JobContext context); static final String MEDIA_PACKAGE_ID; static final String WORKFLOW_DEFINITION; }