diff --git a/office-alexander-logistics-app/pom.xml b/office-alexander-logistics-app/pom.xml index e50f971..43cd36a 100644 --- a/office-alexander-logistics-app/pom.xml +++ b/office-alexander-logistics-app/pom.xml @@ -6,7 +6,7 @@ office-alexander-logistics com.alexander-logistics - 1.3.2 + 1.3.3 office-alexander-logistics-app war diff --git a/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/mail/MailPlugin.java b/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/mail/MailPlugin.java new file mode 100644 index 0000000..0e55d2e --- /dev/null +++ b/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/mail/MailPlugin.java @@ -0,0 +1,86 @@ +package com.alexanderlogistics.mail; + +import java.util.Optional; +import java.util.logging.Logger; + +import org.eclipse.microprofile.config.inject.ConfigProperty; +import org.imixs.workflow.ItemCollection; +import org.imixs.workflow.exceptions.PluginException; + +import jakarta.inject.Inject; +import jakarta.mail.MessagingException; +import jakarta.mail.internet.InternetAddress; +import jakarta.mail.internet.MimeMessage; + +/** + * Dieses Plugin überschreibt einfach nur From und Sender im Header. Ist in + * neuen Versionen von Imixs-Workflow 6.2.2 automatisch gelöst. + * + */ +public class MailPlugin extends org.imixs.marty.profile.MailPlugin { + private static final Logger logger = Logger.getLogger(MailPlugin.class.getName()); + + @Inject + @ConfigProperty(name = "mail.authenticatedSender") + Optional mailAuthenticatedSender; + + /** + * This method adds the attachments of the blob workitem to the MimeMessage + */ + @Override + public ItemCollection run(ItemCollection documentContext, ItemCollection documentActivity) throws PluginException { + // run default functionality + ItemCollection result = super.run(documentContext, documentActivity); + boolean debug = true; // immer debuggen!! + + // now get the Mail Session object and adapt sender and from!! + MimeMessage mailMessage = (MimeMessage) super.getMailMessage(); + if (mailMessage != null) { + + try { + /* + * Now Set Sender, From and ReplyTo addresses... + */ + logger.info("├── 📭 AGL: New mail message..."); + // compute From address - can be overwritten by env mail.defaultSender + InternetAddress adr = getInternetAddress(getFrom(documentContext, documentActivity)); + if (adr == null) { + // in case of null we set an empty address here. This can happen in case + // of a RunAs Service EJB where the user context can not be resolved to a valid + // smtp address + if (debug) { + logger.warning("│   ├── from address was resolved to null"); + } + // we will force a MessagingException... + adr = new InternetAddress(""); + } else { + // Test if a mailAuthenticatedSender.isPresent()) + if (mailAuthenticatedSender.isPresent()) { + logger.info("│   ├── set authenticatedSender"); + logger.info("│   ├── set sender='" + mailAuthenticatedSender.get() + "'"); + mailMessage.setHeader("Sender", mailAuthenticatedSender.get()); + } + // default - current sender + mailMessage.setFrom(adr); + logger.info("│   ├── from:" + adr.getAddress()); + + // Dow we have a replay to? + String sReplyTo = getReplyTo(documentContext, documentActivity); + if ((sReplyTo == null) || (sReplyTo.isEmpty())) { + sReplyTo = adr.getAddress(); + } + logger.info("│   ├── replyTo:" + sReplyTo); + InternetAddress[] resplysAdrs = new InternetAddress[1]; + resplysAdrs[0] = getInternetAddress(sReplyTo); + mailMessage.setReplyTo(resplysAdrs); + + } + + } catch (MessagingException e) { + throw new PluginException(MailPlugin.class.getSimpleName(), ERROR_MAIL_MESSAGE, e.getMessage(), e); + } + } + return result; + } + +} diff --git a/pom.xml b/pom.xml index 1de42dc..44e6d75 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 com.alexander-logistics office-alexander-logistics - 1.3.2 + 1.3.3 pom Imixs Office Workflow - Custom Build diff --git a/workflow/debug-de-1.0.0.bpmn b/workflow/debug-de-1.0.0.bpmn new file mode 100644 index 0000000..592b991 --- /dev/null +++ b/workflow/debug-de-1.0.0.bpmn @@ -0,0 +1,2005 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ExclusiveGateway_4 + Task_2 + ExclusiveGateway_1 + StartEvent_1 + IntermediateCatchEvent_3 + ExclusiveGateway_5 + IntermediateCatchEvent_13 + IntermediateCatchEvent_5000-20 + EventBasedGateway_3 + IntermediateThrowEvent_3 + IntermediateCatchEvent_5 + IntermediateCatchEvent_1 + Task_5 + IntermediateCatchEvent_9 + Task_6 + EndEvent_2 + + event_UAojSg + DataObject_2 + event_bf72XA + + + Task_5005 + IntermediateCatchEvent_5005-10 + ExclusiveGateway_6 + IntermediateCatchEvent_2 + EventBasedGateway_2 + IntermediateCatchEvent_5005-20 + IntermediateCatchEvent_5005-30 + ExclusiveGateway_3 + IntermediateThrowEvent_2 + + + + Task_5000 + EventBasedGateway_4 + IntermediateCatchEvent_15 + IntermediateCatchEvent_16 + IntermediateThrowEvent_1 + IntermediateCatchEvent_5000-10 + + + + + + + + + + txtlastcomment]]> + + + + + + + + + debug.name]]> + + + true + + + + + + + + + + + + + $workflowgroup - $workflowstatus]]> + SequenceFlow_31 + SequenceFlow_1 + SequenceFlow_32 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ]]> + + + + + + + + + $editor.]]> + + + false + + + + SequenceFlow_31 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + home]]> + + + + + + + + + space.name]]> + + + false + + + + + + + SequenceFlow_12 + SequenceFlow_24 + + + SequenceFlow_0 + SequenceFlow_15 + SequenceFlow_33 + + + + + + + SequenceFlow_0 + + + + + + + + + txtlastcomment]]> + + + + + + + + + debug.name]]> + + + true + + + + + + + + + + + + + + + $workflowgroup - $workflowstatus]]> + SequenceFlow_38 + SequenceFlow_13 + SequenceFlow_37 + + + + + + + + + + + + + + _subject]]> + + + + + + + + + _amount (Brutto € _amount_brutto) +_description]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + home +space.name]]> + + + + + + + + + + + + false + + + + SequenceFlow_8 + SequenceFlow_51 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ]]> + + + + + + + + + $editor.]]> + + + false + + + + SequenceFlow_38 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + home +space.name]]> + + + + + + + + + + + + false + + + + + + + SequenceFlow_10 + SequenceFlow_14 + + + SequenceFlow_37 + SequenceFlow_8 + SequenceFlow_10 + + + + + + + + + + + + + + + txtlastcomment]]> + + + + + + + + + debug.name]]> + + + true + + + + + + + + + + + + + + + + + + $workflowgroup - $workflowstatus]]> + SequenceFlow_33 + SequenceFlow_20 + SequenceFlow_2 + sequenceFlow_MKDlnQ + sequenceFlow_rnA8ZA + + + + + + + + + + + + $creator + + + + + + + $created + + + + + + + + + + + + + + + + + + +]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + false + + + + SequenceFlow_20 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + home]]> + + + + + + + + + + + + false + + + + + + + SequenceFlow_29 + SequenceFlow_52 + + + SequenceFlow_32 + SequenceFlow_29 + SequenceFlow_30 + + + + + + + + + + + + _subject]]> + + + + + + + + + _amount (Brutto € _amount_brutto) +_description]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + home]]> + + + + + + + + + + + + false + + + + SequenceFlow_30 + SequenceFlow_7 + + + + + + + + + + + + + + + + + txtlastcomment]]> + + + + + + + + + debug.name]]> + + + true + + + + + + + + + + + + + + $workflowgroup - $workflowstatus]]> + SequenceFlow_4 + SequenceFlow_47 + + + SequenceFlow_47 + SequenceFlow_22 + + + + + + + + + + + + + + + + + + + SequenceFlow_24 + SequenceFlow_13 + SequenceFlow_16 + + + + + + + + + + + SequenceFlow_18 + SequenceFlow_1 + SequenceFlow_5 + + + + + + + + SequenceFlow_7 + SequenceFlow_5 + SequenceFlow_4 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + false + + + + + + SequenceFlow_6 + SequenceFlow_18 + + + + SequenceFlow_51 + SequenceFlow_16 + SequenceFlow_6 + + + + + + + SequenceFlow_15 + + + + + + + + SequenceFlow_52 + + + + + SequenceFlow_14 + + + + + + + + + + + SequenceFlow_11 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + home]]> + + + + + + + + + + + + false + + + + + + + + + + + + + + + SequenceFlow_3 + SequenceFlow_9 + + + + + + SequenceFlow_9 + + + + + + + + + + + + + txtlastcomment]]> + + + + + + + + + debug.name]]> + + + true + + + + + + + + + + + + + + $workflowgroup - $workflowstatus]]> + SequenceFlow_11 + SequenceFlow_41 + SequenceFlow_22 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + home]]> + + + + + + + + + + + + false + + + + + + + SequenceFlow_41 + + + + + + SequenceFlow_2 + SequenceFlow_3 + SequenceFlow_12 + + + + + + + + + + Wurde ein Prozess Team festgelegt, erfolgt eine Genehmigung. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $uniqueid + 60000 + + my-documents/cosmos + .pdf + 500.00 + Finance + + ]]> + + + + + + + + + + + + false + + + + sequenceFlow_MKDlnQ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + false + + + + + + + + + + + + + + + + + + + sequenceFlow_rnA8ZA + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +