@Test public void testTemplateInFile() throws Exception { operation.setConfiguration(EmailWorkflowOperationHandler.TO_PROPERTY, DEFAULT_TO); operation.setConfiguration(EmailWorkflowOperationHandler.CC_PROPERTY, DEFAULT_CC); operation.setConfiguration(EmailWorkflowOperationHandler.BCC_PROPERTY, DEFAULT_BCC); operation.setConfiguration(EmailWorkflowOperationHandler.SUBJECT_PROPERTY, DEFAULT_SUBJECT); operation.setConfiguration(EmailWorkflowOperationHandler.BODY_TEMPLATE_FILE_PROPERTY, "template1"); WorkflowOperationResult result = operationHandler.start(workflowInstance, null); Assert.assertEquals(Action.CONTINUE, result.getAction()); Assert.assertEquals(DEFAULT_TO, capturedTo.getValue()); Assert.assertEquals(DEFAULT_CC, capturedCC.getValue()); Assert.assertEquals(DEFAULT_BCC, capturedBCC.getValue()); Assert.assertEquals(DEFAULT_SUBJECT, capturedSubject.getValue()); Assert.assertEquals("This is the media package: 3e7bb56d-2fcc-4efe-9f0e-d6e56422f557", capturedBody.getValue()); }
@Override public WorkflowOperationResult start(WorkflowInstance workflowInstance, JobContext context) throws WorkflowOperationException { WorkflowOperationInstance operation = workflowInstance.getCurrentOperation(); MediaPackage srcPackage = workflowInstance.getMediaPackage(); String to = processDestination(workflowInstance, operation, TO_PROPERTY); String cc = processDestination(workflowInstance, operation, CC_PROPERTY); String bcc = processDestination(workflowInstance, operation, BCC_PROPERTY); String subject = applyTemplateIfNecessary(workflowInstance, operation, SUBJECT_PROPERTY); String bodyText = null; String body = operation.getConfiguration(BODY_PROPERTY); Boolean isHTML = BooleanUtils.toBoolean(operation.getConfiguration(IS_HTML)); String bodyTemplateFile = operation.getConfiguration(BODY_TEMPLATE_FILE_PROPERTY); if (body == null && bodyTemplateFile == null) { bodyText = srcPackage.getTitle() + "(" + srcPackage.getIdentifier().toString() + ")"; } else if (body != null) { bodyText = applyTemplateIfNecessary(workflowInstance, operation, BODY_PROPERTY); } else { bodyText = applyTemplateIfNecessary(workflowInstance, operation, BODY_TEMPLATE_FILE_PROPERTY); } try { logger.debug( "Sending e-mail notification with subject {} and body {} to {}, CC addresses {} and BCC addresses {}", subject, bodyText, to, cc, bcc); smtpService.send(to, cc, bcc, subject, bodyText, isHTML); logger.info("E-mail notification sent to {}, CC addresses {} and BCC addresses {}", to, cc, bcc); } catch (MessagingException e) { throw new WorkflowOperationException(e); } return createResult(srcPackage, Action.CONTINUE); }
EmailWorkflowOperationHandler extends AbstractWorkflowOperationHandler { @Override public WorkflowOperationResult start(WorkflowInstance workflowInstance, JobContext context) throws WorkflowOperationException { WorkflowOperationInstance operation = workflowInstance.getCurrentOperation(); MediaPackage srcPackage = workflowInstance.getMediaPackage(); String to = processDestination(workflowInstance, operation, TO_PROPERTY); String cc = processDestination(workflowInstance, operation, CC_PROPERTY); String bcc = processDestination(workflowInstance, operation, BCC_PROPERTY); String subject = applyTemplateIfNecessary(workflowInstance, operation, SUBJECT_PROPERTY); String bodyText = null; String body = operation.getConfiguration(BODY_PROPERTY); Boolean isHTML = BooleanUtils.toBoolean(operation.getConfiguration(IS_HTML)); String bodyTemplateFile = operation.getConfiguration(BODY_TEMPLATE_FILE_PROPERTY); if (body == null && bodyTemplateFile == null) { bodyText = srcPackage.getTitle() + "(" + srcPackage.getIdentifier().toString() + ")"; } else if (body != null) { bodyText = applyTemplateIfNecessary(workflowInstance, operation, BODY_PROPERTY); } else { bodyText = applyTemplateIfNecessary(workflowInstance, operation, BODY_TEMPLATE_FILE_PROPERTY); } try { logger.debug( "Sending e-mail notification with subject {} and body {} to {}, CC addresses {} and BCC addresses {}", subject, bodyText, to, cc, bcc); smtpService.send(to, cc, bcc, subject, bodyText, isHTML); logger.info("E-mail notification sent to {}, CC addresses {} and BCC addresses {}", to, cc, bcc); } catch (MessagingException e) { throw new WorkflowOperationException(e); } return createResult(srcPackage, Action.CONTINUE); } }
EmailWorkflowOperationHandler extends AbstractWorkflowOperationHandler { @Override public WorkflowOperationResult start(WorkflowInstance workflowInstance, JobContext context) throws WorkflowOperationException { WorkflowOperationInstance operation = workflowInstance.getCurrentOperation(); MediaPackage srcPackage = workflowInstance.getMediaPackage(); String to = processDestination(workflowInstance, operation, TO_PROPERTY); String cc = processDestination(workflowInstance, operation, CC_PROPERTY); String bcc = processDestination(workflowInstance, operation, BCC_PROPERTY); String subject = applyTemplateIfNecessary(workflowInstance, operation, SUBJECT_PROPERTY); String bodyText = null; String body = operation.getConfiguration(BODY_PROPERTY); Boolean isHTML = BooleanUtils.toBoolean(operation.getConfiguration(IS_HTML)); String bodyTemplateFile = operation.getConfiguration(BODY_TEMPLATE_FILE_PROPERTY); if (body == null && bodyTemplateFile == null) { bodyText = srcPackage.getTitle() + "(" + srcPackage.getIdentifier().toString() + ")"; } else if (body != null) { bodyText = applyTemplateIfNecessary(workflowInstance, operation, BODY_PROPERTY); } else { bodyText = applyTemplateIfNecessary(workflowInstance, operation, BODY_TEMPLATE_FILE_PROPERTY); } try { logger.debug( "Sending e-mail notification with subject {} and body {} to {}, CC addresses {} and BCC addresses {}", subject, bodyText, to, cc, bcc); smtpService.send(to, cc, bcc, subject, bodyText, isHTML); logger.info("E-mail notification sent to {}, CC addresses {} and BCC addresses {}", to, cc, bcc); } catch (MessagingException e) { throw new WorkflowOperationException(e); } return createResult(srcPackage, Action.CONTINUE); }  }
EmailWorkflowOperationHandler extends AbstractWorkflowOperationHandler { @Override public WorkflowOperationResult start(WorkflowInstance workflowInstance, JobContext context) throws WorkflowOperationException { WorkflowOperationInstance operation = workflowInstance.getCurrentOperation(); MediaPackage srcPackage = workflowInstance.getMediaPackage(); String to = processDestination(workflowInstance, operation, TO_PROPERTY); String cc = processDestination(workflowInstance, operation, CC_PROPERTY); String bcc = processDestination(workflowInstance, operation, BCC_PROPERTY); String subject = applyTemplateIfNecessary(workflowInstance, operation, SUBJECT_PROPERTY); String bodyText = null; String body = operation.getConfiguration(BODY_PROPERTY); Boolean isHTML = BooleanUtils.toBoolean(operation.getConfiguration(IS_HTML)); String bodyTemplateFile = operation.getConfiguration(BODY_TEMPLATE_FILE_PROPERTY); if (body == null && bodyTemplateFile == null) { bodyText = srcPackage.getTitle() + "(" + srcPackage.getIdentifier().toString() + ")"; } else if (body != null) { bodyText = applyTemplateIfNecessary(workflowInstance, operation, BODY_PROPERTY); } else { bodyText = applyTemplateIfNecessary(workflowInstance, operation, BODY_TEMPLATE_FILE_PROPERTY); } try { logger.debug( "Sending e-mail notification with subject {} and body {} to {}, CC addresses {} and BCC addresses {}", subject, bodyText, to, cc, bcc); smtpService.send(to, cc, bcc, subject, bodyText, isHTML); logger.info("E-mail notification sent to {}, CC addresses {} and BCC addresses {}", to, cc, bcc); } catch (MessagingException e) { throw new WorkflowOperationException(e); } return createResult(srcPackage, Action.CONTINUE); }  @Override WorkflowOperationResult start(WorkflowInstance workflowInstance, JobContext context); }
EmailWorkflowOperationHandler extends AbstractWorkflowOperationHandler { @Override public WorkflowOperationResult start(WorkflowInstance workflowInstance, JobContext context) throws WorkflowOperationException { WorkflowOperationInstance operation = workflowInstance.getCurrentOperation(); MediaPackage srcPackage = workflowInstance.getMediaPackage(); String to = processDestination(workflowInstance, operation, TO_PROPERTY); String cc = processDestination(workflowInstance, operation, CC_PROPERTY); String bcc = processDestination(workflowInstance, operation, BCC_PROPERTY); String subject = applyTemplateIfNecessary(workflowInstance, operation, SUBJECT_PROPERTY); String bodyText = null; String body = operation.getConfiguration(BODY_PROPERTY); Boolean isHTML = BooleanUtils.toBoolean(operation.getConfiguration(IS_HTML)); String bodyTemplateFile = operation.getConfiguration(BODY_TEMPLATE_FILE_PROPERTY); if (body == null && bodyTemplateFile == null) { bodyText = srcPackage.getTitle() + "(" + srcPackage.getIdentifier().toString() + ")"; } else if (body != null) { bodyText = applyTemplateIfNecessary(workflowInstance, operation, BODY_PROPERTY); } else { bodyText = applyTemplateIfNecessary(workflowInstance, operation, BODY_TEMPLATE_FILE_PROPERTY); } try { logger.debug( "Sending e-mail notification with subject {} and body {} to {}, CC addresses {} and BCC addresses {}", subject, bodyText, to, cc, bcc); smtpService.send(to, cc, bcc, subject, bodyText, isHTML); logger.info("E-mail notification sent to {}, CC addresses {} and BCC addresses {}", to, cc, bcc); } catch (MessagingException e) { throw new WorkflowOperationException(e); } return createResult(srcPackage, Action.CONTINUE); }  @Override WorkflowOperationResult start(WorkflowInstance workflowInstance, JobContext context);  }