Skip to content

Commit db0cd1b

Browse files
committed
Some post processing for #247
1 parent 55853fb commit db0cd1b

File tree

2 files changed

+37
-38
lines changed

2 files changed

+37
-38
lines changed

phase4-dbnalliance-client/pom.xml

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,31 +49,26 @@
4949
<artifactId>phase4-dynamic-discovery</artifactId>
5050
</dependency>
5151
<dependency>
52-
<groupId>com.helger</groupId>
53-
<artifactId>ph-xhe</artifactId>
54-
<version>4.0.1</version>
55-
<type>jar</type>
52+
<groupId>com.helger.phase4</groupId>
53+
<artifactId>phase4-profile-dbnalliance</artifactId>
5654
</dependency>
55+
5756
<dependency>
5857
<groupId>com.helger.peppol</groupId>
59-
<artifactId>peppol-commons</artifactId>
58+
<artifactId>peppol-id</artifactId>
6059
<version>${peppol-commons.version}</version>
6160
</dependency>
6261
<dependency>
6362
<groupId>com.helger.peppol</groupId>
64-
<artifactId>dbnalliance-xhe</artifactId>
65-
<version>9.4.1-SNAPSHOT</version>
66-
<type>jar</type>
67-
</dependency>
68-
<dependency>
69-
<groupId>com.helger.phase4</groupId>
70-
<artifactId>phase4-profile-dbnalliance</artifactId>
63+
<artifactId>peppol-commons</artifactId>
64+
<version>${peppol-commons.version}</version>
7165
</dependency>
7266
<dependency>
7367
<groupId>com.helger.peppol</groupId>
74-
<artifactId>peppol-id</artifactId>
68+
<artifactId>dbnalliance-xhe</artifactId>
7569
<version>${peppol-commons.version}</version>
7670
</dependency>
71+
7772
<dependency>
7873
<groupId>jakarta.servlet</groupId>
7974
<artifactId>jakarta.servlet-api</artifactId>

phase4-dbnalliance-client/src/main/java/com/helger/phase4/dbnalliance/Phase4DBNAllianceSender.java

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@
1616
*/
1717
package com.helger.phase4.dbnalliance;
1818

19+
import java.nio.charset.StandardCharsets;
1920
import java.security.cert.X509Certificate;
2021
import java.time.OffsetDateTime;
22+
import java.util.UUID;
2123
import java.util.function.Consumer;
2224

2325
import javax.annotation.Nonnull;
@@ -27,10 +29,10 @@
2729

2830
import org.slf4j.Logger;
2931
import org.slf4j.LoggerFactory;
32+
import org.w3c.dom.Element;
3033

3134
import com.helger.commons.ValueEnforcer;
3235
import com.helger.commons.annotation.Nonempty;
33-
import com.helger.commons.datetime.XMLOffsetDateTime;
3436
import com.helger.commons.state.ESuccess;
3537
import com.helger.peppol.smp.ESMPTransportProfile;
3638
import com.helger.peppol.utils.PeppolCertificateHelper;
@@ -56,15 +58,13 @@
5658
import com.helger.xhe.v10.CXHE10;
5759
import com.helger.xhe.v10.XHE10Marshaller;
5860
import com.helger.xhe.v10.XHE10XHEType;
59-
import java.nio.charset.StandardCharsets;
60-
import java.util.UUID;
61-
import org.w3c.dom.Element;
6261

6362
/**
6463
* This class contains all the specifics to send AS4 messages with the
6564
* DBNAlliance profile. See <code>sendAS4Message</code> as the main method to
6665
* trigger the sending, with all potential customization.
6766
*
67+
* @author Robinson Artemio Garcia Meléndez
6868
* @author Philip Helger
6969
*/
7070
@Immutable
@@ -75,39 +75,38 @@ public final class Phase4DBNAllianceSender
7575

7676
private Phase4DBNAllianceSender ()
7777
{}
78-
78+
7979
@Nullable
8080
private static XHE10XHEType _createXHE (@Nonnull final IParticipantIdentifier aSenderID,
8181
@Nonnull final IParticipantIdentifier aReceiverID,
8282
@Nonnull final IDocumentTypeIdentifier aDocTypeID,
8383
@Nonnull final IProcessIdentifier aProcID,
8484
@Nonnull final Element aPayloadElement,
85-
final boolean bClonePayloadElement
86-
)
85+
final boolean bClonePayloadElement)
8786
{
8887
final DBNAllianceXHEData aData = new DBNAllianceXHEData (IF);
8988
aData.setFromParty (aSenderID.getScheme (), aSenderID.getValue ());
9089
aData.setToParty (aReceiverID.getScheme (), aReceiverID.getValue ());
9190
aData.setID (UUID.randomUUID ().toString ());
9291
aData.setCreationDateAndTime (MetaAS4Manager.getTimestampMgr ().getCurrentXMLDateTime ());
93-
92+
9493
final DBNAlliancePayload aPayload = new DBNAlliancePayload (IF);
9594
aPayload.setCustomizationID (null, aDocTypeID.getValue ());
9695
aPayload.setProfileID (aProcID.getScheme (), aProcID.getValue ());
97-
96+
9897
// Not cloning the payload element is for saving memory only (if it can be
9998
// ensured, the source payload element is not altered externally of course)
10099
if (bClonePayloadElement)
101100
aPayload.setPayloadContent (aPayloadElement);
102101
else
103102
aPayload.setPayloadContentNoClone (aPayloadElement);
104-
105-
aData.addPayload(aPayload);
106-
103+
104+
aData.addPayload (aPayload);
105+
107106
// check with logging
108107
if (!aData.areAllFieldsSet (true))
109108
throw new IllegalArgumentException ("The DBNAlliance XHE data is incomplete. See logs for details.");
110-
109+
111110
return DBNAllianceXHEDocumentWriter.createExchangeHeaderEnvelope (aData);
112111
}
113112

@@ -124,6 +123,7 @@ public static DBNAllianceUserMessageBuilder builder ()
124123
/**
125124
* Abstract DBNAlliance UserMessage builder class with sanity methods.
126125
*
126+
* @author Robinson Artemio Garcia Meléndez
127127
* @author Philip Helger
128128
* @param <IMPLTYPE>
129129
* The implementation type
@@ -132,8 +132,9 @@ public abstract static class AbstractDBNAllianceUserMessageBuilder <IMPLTYPE ext
132132
extends
133133
AbstractAS4UserMessageBuilderMIMEPayload <IMPLTYPE>
134134
{
135-
// C4
135+
// C1
136136
protected IParticipantIdentifier m_aSenderID;
137+
// C4
137138
protected IParticipantIdentifier m_aReceiverID;
138139
protected IDocumentTypeIdentifier m_aDocTypeID;
139140
protected IProcessIdentifier m_aProcessID;
@@ -165,10 +166,10 @@ protected AbstractDBNAllianceUserMessageBuilder ()
165166
throw new IllegalStateException ("Failed to init AS4 Client builder", ex);
166167
}
167168
}
168-
169+
169170
/**
170-
* Set the sender participant ID of the message. The participant ID must
171-
* be provided prior to sending.
171+
* Set the sender participant ID of the message. The participant ID must be
172+
* provided prior to sending.
172173
*
173174
* @param aSenderID
174175
* The sender participant ID. May not be <code>null</code>.
@@ -486,17 +487,18 @@ protected void customizeBeforeSending () throws Phase4Exception
486487
* The builder class for sending AS4 messages using DBNAlliance profile
487488
* specifics. Use {@link #sendMessage()} to trigger the main transmission.
488489
*
490+
* @author Robinson Artemio Garcia Meléndez
489491
* @author Philip Helger
490492
*/
491493
public static class DBNAllianceUserMessageBuilder extends
492494
AbstractDBNAllianceUserMessageBuilder <DBNAllianceUserMessageBuilder>
493495
{
494-
496+
495497
private Element m_aPayloadElement;
496-
498+
497499
public DBNAllianceUserMessageBuilder ()
498500
{}
499-
501+
500502
/**
501503
* Set the payload element to be used, if it is available as a parsed DOM
502504
* element. Internally the DOM element will be cloned before sending it out.
@@ -511,12 +513,13 @@ public DBNAllianceUserMessageBuilder ()
511513
public DBNAllianceUserMessageBuilder payload (@Nonnull final Element aPayloadElement)
512514
{
513515
ValueEnforcer.notNull (aPayloadElement, "Payload");
514-
ValueEnforcer.notNull (aPayloadElement.getNamespaceURI (), "Payload.NamespaceURI");
516+
ValueEnforcer.notEmpty (aPayloadElement.getNamespaceURI (), "Payload.NamespaceURI");
515517
m_aPayloadElement = aPayloadElement;
516518
return this;
517519
}
518-
520+
519521
@Override
522+
@OverridingMethodsMustInvokeSuper
520523
protected ESuccess finishFields () throws Phase4Exception
521524
{
522525
// Ensure a DOM element is present
@@ -529,14 +532,15 @@ protected ESuccess finishFields () throws Phase4Exception
529532
bClonePayloadElement = true;
530533
}
531534
else
532-
throw new IllegalStateException ("Unexpected - element are not present");
535+
throw new IllegalStateException ("Unexpected - element is not present");
533536

534537
// Consistency check
535-
if (CXHE10.NAMESPACE_URI_XHE.equals(aPayloadElement.getNamespaceURI ()))
538+
if (CXHE10.NAMESPACE_URI_XHE.equals (aPayloadElement.getNamespaceURI ()))
536539
throw new Phase4DBNAllianceException ("You cannot set a Exchange Header Envelope as the payload for the regular builder. The XHE is created automatically inside of this builder.");
537540

538541
// Optional payload validation
539-
// _validatePayload (aPayloadElement, m_aVESRegistry, m_aVESID, m_aValidationResultHandler);
542+
// _validatePayload (aPayloadElement, m_aVESRegistry, m_aVESID,
543+
// m_aValidationResultHandler);
540544

541545
// Perform SMP lookup
542546
if (super.finishFields ().isFailure ())

0 commit comments

Comments
 (0)