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/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 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/workflow/mahnlauf-de-1.0.4-mailplugin.bpmn b/workflow/mahnlauf-de-1.0.4-mailplugin.bpmn new file mode 100644 index 0000000..b80e003 --- /dev/null +++ b/workflow/mahnlauf-de-1.0.4-mailplugin.bpmn @@ -0,0 +1,1204 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +<itemvalue>$workflowstatus</itemvalue> + +]]> + + + +]]> + + + + + + + + + + + + + + StartEvent_1 + Task_1 + IntermediateCatchEvent_3 + EndEvent_3 + IntermediateCatchEvent_1 + IntermediateCatchEvent_5 + ExclusiveGateway_2 + IntermediateCatchEvent_4 + Task_2 + ExclusiveGateway_1 + IntermediateCatchEvent_2 + IntermediateCatchEvent_8 + IntermediateCatchEvent_7 + Task_3 + IntermediateCatchEvent_9 + IntermediateCatchEvent_6 + + + + + SequenceFlow_4 + + + + + + $lasteventdate - dbtr.name (dbtr.number)]]> + + + true + + + + + + + + + + + + + + + + + + + + + $workflowgroup - $workflowstatus]]> + SequenceFlow_6 + SequenceFlow_15 + SequenceFlow_10 + SequenceFlow_18 + + + + + + SequenceFlow_10 + SequenceFlow_13 + + + + + + $lasteventdate - dbtr.name (dbtr.number)]]> + + + + + + + + + + + + true + + + + + + + + + + + + + + + + + $workflowgroup - $workflowstatus]]> + SequenceFlow_14 + SequenceFlow_4 + SequenceFlow_1 + SequenceFlow_2 + SequenceFlow_3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + false + + + + SequenceFlow_6 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + false + + + + + + + SequenceFlow_14 + + + + + + + + + + + + + + + + + + + + + + + +]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + home +Mahnwesen]]> + + + + + + + + + + + + false + + + + SequenceFlow_2 + SequenceFlow_16 + + + DataOutput_1 + + + DataOutput_1 + + + + + + + + SequenceFlow_17 + SequenceFlow_8 + SequenceFlow_9 + + + + + + Html-Header +E-Mail - Mahnlauf-dunning.level (DE) +
+description
+
+

+Debitor: dbtr.name (dbtr.number) +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
RechnungsnummerDatumFälligkeitRechnungsbetragSaldoMahnstufe
invoice.numberinvoice.dateinvoice.duedateinvoice.total invoice.currencyinvoice.saldo invoice.currency$workflowstatus
Saldodunning.saldo dunning.currency
+ +E-Mail - Mahnlauf Footer (DE) +Html-Footer +]]>
+
+ + mail.subject_de]]> + + + + + + + + + + + +
+ SequenceFlow_8 + SequenceFlow_11 + + +
+ + + + Html-Header +E-Mail - Mahnlauf-dunning.level (EN) +
+description
+
+

+Debitor: dbtr.name (dbtr.number) +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
Invoice No.DateExpiry DateInvoice AmountBalanceDunning Level
invoice.numberinvoice.dateinvoice.duedateinvoice.total invoice.currencyinvoice.saldo invoice.currencyworkflowstatus_en
Saldodunning.saldo dunning.currency
+E-Mail - Mahnlauf Footer (EN) +Html-Footer +]]>
+
+ + mail.subject_en]]> + + + + + + + + + + + +
+ SequenceFlow_9 + SequenceFlow_12 + + +
+ + workitem['invoice.language'] && workitem['invoice.language'][0]=="DE" + + + + + + + SequenceFlow_11 + SequenceFlow_12 + SequenceFlow_15 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Mahnwesen]]> + + + + + + + + + + + + false + + + SequenceFlow_1 + + + + + + + + + + $lasteventdate - dbtr.name (dbtr.number)]]> + + + true + + + + + + + + + + + + + + + + + + + + + $workflowgroup - $workflowstatus]]> + SequenceFlow_5 + SequenceFlow_13 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + home]]> + + + + + + + + + + + + false + + + + + + + SequenceFlow_3 + SequenceFlow_5 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + false + + + + SequenceFlow_16 + SequenceFlow_19 + SequenceFlow_17 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + home]]> + + + + + + + + + + + + false + + + 0) { + var liste=workitem.get("dbtr.mail"); + for (i = 0; i < liste.length; i++) { + validateMail(liste[i]); + } +} + + +function validateMail(mail) { + if (/^(?=.{1,64}@)[A-Za-z0-9_-]+(\.[A-Za-z0-9_-]+)*@[^-][A-Za-z0-9-]+(\.[A-Za-z0-9-]+)*(\.[A-Za-z]{2,})$/.test(mail)) { + // OK + } else { + result.isValid=false; + result.errorMessage='Bitte geben Sie eine gültige E-Mail Adresse ein ('+ mail + ')!'; + } +} +]]> + + + + SequenceFlow_18 + SequenceFlow_19 + + + + + + + + + + + + + + + + + + + + + + + +]]> + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +