/** * Create document for sent mail information * * @param processAttachmentsFolder * @param attachmentInfo */ private void createDocumentForMail(Folder processAttachmentsFolder, String attachmentInfo) { String docName = RepositoryUtility.createDocumentName( processAttachmentsFolder, DocumentMgmtUtility.stripOffSpecialCharacters(mailSubject), 0); DocumentInfo docInfo = DmsUtils.createDocumentInfo(docName); docInfo.setContentType(MimeTypesHelper.HTML.getType()); docInfo.setOwner(ContextPortalServices.getUser().getAccount()); // set correspondence data PrintDocumentAnnotations annotations = new PrintDocumentAnnotationsImpl(); annotations.setTemplateType(DocumentTemplate.CORRESPONDENCE_TEMPLATE); annotations.setRecipients(getToMailAddress()); annotations.setBlindCarbonCopyRecipients(bccMailAddress); annotations.setCarbonCopyRecipients(ccMailAddress); annotations.setFaxNumber(getFaxMailAddress()); annotations.setSendDate(Calendar.getInstance().getTime()); annotations.setAttachments(attachmentInfo); annotations.setSender(mailSender); annotations.setSubject(getMailSubject()); annotations.setFaxEnabled(false); annotations.setEmailEnabled(false); docInfo.setDocumentAnnotations(annotations); Document mailDocument = DocumentMgmtUtility.getDocumentManagementService() .createDocument( processAttachmentsFolder.getId(), docInfo, editor.getContent().getBytes(), null); DMSHelper.addAndSaveProcessAttachment(processInstance, mailDocument); }
/** @return dataPathContacts */ private List<DataPathValue> generateDataPathContacts() { List<DataPathValue> dataPathContacts = new ArrayList<DataPathValue>(); ProcessDefinition processDefinition = null; try { processDefinition = ContextPortalServices.getQueryService() .getProcessDefinition(processInstance.getProcessID()); } catch (Exception e) { trace.error(e); } if (processDefinition != null) { List<DataPath> list = processDefinition.getAllDataPaths(); for (int n = 0; n < list.size(); ++n) { DataPath dataPath = list.get(n); if (dataPath.getDirection().equals(Direction.IN) || dataPath.getDirection().equals(Direction.IN_OUT)) { Object dataValue = null; try { dataValue = ContextPortalServices.getWorkflowService() .getInDataPath(processInstance.getOID(), dataPath.getId()); } catch (Exception e) { trace.error(e); } if (dataValue != null && EMailAddressValidator.validateEmailAddress(dataValue.toString())) { dataPathContacts.add( new DataPathValue( dataPath.getId(), dataPath.getName(), dataValue != null ? dataValue.toString() : "")); } } } } return dataPathContacts; }
private Object getCurrentProcessInstanceDataValue(String path) { return ContextPortalServices.getWorkflowService().getInDataPath(processInstance.getOID(), path); }