use of com.helger.phase4.ebms3header.Ebms3AgreementRef in project phase4 by phax.
the class MessageHelperMethods method createEbms3CollaborationInfo.
@Nonnull
public static Ebms3CollaborationInfo createEbms3CollaborationInfo(@Nullable final String sAgreementRefPMode, @Nullable final String sAgreementRefValue, @Nullable final String sServiceType, @Nonnull @Nonempty final String sServiceValue, @Nonnull @Nonempty final String sAction, @Nonnull final String sConversationID) {
ValueEnforcer.notEmpty(sServiceValue, "ServiceValue");
ValueEnforcer.notEmpty(sAction, "Action");
ValueEnforcer.notNull(sConversationID, "ConversationID");
final Ebms3CollaborationInfo aEbms3CollaborationInfo = new Ebms3CollaborationInfo();
if (StringHelper.hasText(sAgreementRefValue)) {
final Ebms3AgreementRef aEbms3AgreementRef = new Ebms3AgreementRef();
if (StringHelper.hasText(sAgreementRefPMode))
aEbms3AgreementRef.setPmode(sAgreementRefPMode);
aEbms3AgreementRef.setValue(sAgreementRefValue);
aEbms3CollaborationInfo.setAgreementRef(aEbms3AgreementRef);
}
{
final Ebms3Service aEbms3Service = new Ebms3Service();
aEbms3Service.setType(sServiceType);
aEbms3Service.setValue(sServiceValue);
aEbms3CollaborationInfo.setService(aEbms3Service);
}
aEbms3CollaborationInfo.setAction(sAction);
aEbms3CollaborationInfo.setConversationId(sConversationID);
return aEbms3CollaborationInfo;
}
use of com.helger.phase4.ebms3header.Ebms3AgreementRef in project phase4 by phax.
the class PeppolCompatibilityValidator method validateUserMessage.
@Override
public void validateUserMessage(@Nonnull final Ebms3UserMessage aUserMsg, @Nonnull final ErrorList aErrorList) {
ValueEnforcer.notNull(aUserMsg, "UserMsg");
if (aUserMsg.getMessageInfo() == null) {
aErrorList.add(_createError("MessageInfo is missing"));
} else {
if (StringHelper.hasNoText(aUserMsg.getMessageInfo().getMessageId()))
aErrorList.add(_createError("MessageInfo/MessageId is missing"));
{
// Check if originalSender and finalRecipient are present
// Since these two properties are mandatory
final Ebms3MessageProperties aMessageProperties = aUserMsg.getMessageProperties();
if (aMessageProperties == null)
aErrorList.add(_createError("MessageProperties is missing but 'originalSender' and 'finalRecipient' properties are required"));
else {
final List<Ebms3Property> aProps = aMessageProperties.getProperty();
if (aProps.isEmpty())
aErrorList.add(_createError("MessageProperties/Property must not be empty"));
else {
String sOriginalSenderC1 = null;
String sFinalRecipientC4 = null;
for (final Ebms3Property sProperty : aProps) {
if (sProperty.getName().equals(CAS4.ORIGINAL_SENDER))
sOriginalSenderC1 = sProperty.getValue();
else if (sProperty.getName().equals(CAS4.FINAL_RECIPIENT))
sFinalRecipientC4 = sProperty.getValue();
}
if (StringHelper.hasNoText(sOriginalSenderC1))
aErrorList.add(_createError("MessageProperties/Property '" + CAS4.ORIGINAL_SENDER + "' property is empty or not existant but mandatory"));
if (StringHelper.hasNoText(sFinalRecipientC4))
aErrorList.add(_createError("MessageProperties/Property '" + CAS4.FINAL_RECIPIENT + "' property is empty or not existant but mandatory"));
}
}
}
}
if (aUserMsg.getPartyInfo() == null) {
aErrorList.add(_createError("PartyInfo is missing"));
} else {
final Ebms3From aFrom = aUserMsg.getPartyInfo().getFrom();
if (aFrom != null) {
if (aFrom.getPartyIdCount() > 1)
aErrorList.add(_createError("PartyInfo/From must contain no more than one PartyID"));
else if (aFrom.getPartyIdCount() == 1) {
if (!PeppolPMode.DEFAULT_PARTY_TYPE_ID.equals(aFrom.getPartyIdAtIndex(0).getType())) {
aErrorList.add(_createError("PartyInfo/From[0]/@type must be '" + PeppolPMode.DEFAULT_PARTY_TYPE_ID + "' instead of '" + aFrom.getPartyIdAtIndex(0).getType() + "'"));
}
}
}
final Ebms3To aTo = aUserMsg.getPartyInfo().getTo();
if (aTo != null) {
if (aTo.getPartyIdCount() > 1)
aErrorList.add(_createError("PartyInfo/To must contain no more than one PartyID"));
else if (aTo.getPartyIdCount() == 1) {
if (!PeppolPMode.DEFAULT_PARTY_TYPE_ID.equals(aTo.getPartyIdAtIndex(0).getType())) {
aErrorList.add(_createError("PartyInfo/To[0]/@type must be '" + PeppolPMode.DEFAULT_PARTY_TYPE_ID + "' instead of '" + aTo.getPartyIdAtIndex(0).getType() + "'"));
}
}
}
}
if (aUserMsg.getCollaborationInfo() == null) {
aErrorList.add(_createError("CollaborationInfo is missing"));
} else {
final Ebms3AgreementRef aAgreementRef = aUserMsg.getCollaborationInfo().getAgreementRef();
if (aAgreementRef == null) {
aErrorList.add(_createError("CollaborationInfo/AgreementRef is missing"));
} else {
if (!PeppolPMode.DEFAULT_AGREEMENT_ID.equals(aAgreementRef.getValue()))
aErrorList.add(_createError("CollaborationInfo/AgreementRef must be '" + PeppolPMode.DEFAULT_AGREEMENT_ID + "' instead of '" + aAgreementRef.getValue() + "'"));
if (StringHelper.hasText(aAgreementRef.getType()))
aErrorList.add(_createError("CollaborationInfo/AgreementRef/@type must not be set"));
}
}
}
use of com.helger.phase4.ebms3header.Ebms3AgreementRef in project phase4 by phax.
the class ENTSOGCompatibilityValidator method validateUserMessage.
@Override
public void validateUserMessage(@Nonnull final Ebms3UserMessage aUserMsg, @Nonnull final ErrorList aErrorList) {
ValueEnforcer.notNull(aUserMsg, "UserMsg");
if (aUserMsg.getMessageInfo() == null) {
aErrorList.add(_createError("MessageInfo is missing"));
} else {
if (StringHelper.hasNoText(aUserMsg.getMessageInfo().getMessageId()))
aErrorList.add(_createError("MessageInfo/MessageId is missing"));
if (StringHelper.hasText(aUserMsg.getMessageInfo().getRefToMessageId()))
aErrorList.add(_createError("MessageInfo/RefToMessageId must not be set"));
}
if (aUserMsg.getPartyInfo() == null) {
aErrorList.add(_createError("PartyInfo is missing"));
} else {
final Ebms3From aFrom = aUserMsg.getPartyInfo().getFrom();
if (aFrom != null) {
if (aFrom.getPartyIdCount() > 1)
aErrorList.add(_createError("PartyInfo/From must contain no more than one PartyID"));
}
final Ebms3To aTo = aUserMsg.getPartyInfo().getTo();
if (aTo != null) {
if (aTo.getPartyIdCount() > 1)
aErrorList.add(_createError("PartyInfo/To must contain no more than one PartyID"));
}
}
if (aUserMsg.getCollaborationInfo() == null) {
aErrorList.add(_createError("CollaborationInfo is missing"));
} else {
final Ebms3AgreementRef aAgreementRef = aUserMsg.getCollaborationInfo().getAgreementRef();
if (StringHelper.hasNoText(aAgreementRef.getValue()))
aErrorList.add(_createError("CollaborationInfo/AgreementRef value is missing"));
if (aAgreementRef.getPmode() != null)
aErrorList.add(_createError("CollaborationInfo/PMode has not to be set!"));
}
}
Aggregations