use of com.helger.phase4.model.pmode.PModePayloadService in project phase4 by phax.
the class PModePayloadServiceJsonConverter method convertToNative.
@Nonnull
public static PModePayloadService convertToNative(@Nonnull final IJsonObject aElement) {
final String sCompressionModeID = aElement.getAsString(COMPRESSION_MODE);
final EAS4CompressionMode eCompressionMode = EAS4CompressionMode.getFromIDOrNull(sCompressionModeID);
if (sCompressionModeID != null && eCompressionMode == null)
throw new IllegalStateException("Invalid compression mode ID '" + sCompressionModeID + "' provided!");
return new PModePayloadService(eCompressionMode);
}
use of com.helger.phase4.model.pmode.PModePayloadService in project phase4 by phax.
the class PModePayloadServiceMicroTypeConverter method convertToNative.
@Nonnull
public PModePayloadService convertToNative(@Nonnull final IMicroElement aElement) {
final String sCompressionModeID = aElement.getAttributeValue(ATTR_COMPRESSION_MODE);
final EAS4CompressionMode eCompressionMode = EAS4CompressionMode.getFromIDOrNull(sCompressionModeID);
if (sCompressionModeID != null && eCompressionMode == null)
throw new IllegalStateException("Invalid compression mode ID '" + sCompressionModeID + "' provided!");
return new PModePayloadService(eCompressionMode);
}
use of com.helger.phase4.model.pmode.PModePayloadService in project phase4 by phax.
the class PModeMicroTypeConverter method convertToNative.
@Nonnull
public PMode convertToNative(@Nonnull final IMicroElement aElement) {
final PModeParty aInitiator = MicroTypeConverter.convertToNative(aElement.getFirstChildElement(ELEMENT_INITIATOR), PModeParty.class);
final PModeParty aResponder = MicroTypeConverter.convertToNative(aElement.getFirstChildElement(ELEMENT_RESPONDER), PModeParty.class);
final String sAgreement = aElement.getAttributeValue(ATTR_AGREEMENT);
final String sMEP = aElement.getAttributeValue(ATTR_MEP);
final EMEP eMEP = EMEP.getFromIDOrNull(sMEP);
if (eMEP == null)
throw new IllegalStateException("Failed to resolve MEP '" + sMEP + "'");
final String sMEPBinding = aElement.getAttributeValue(ATTR_MEP_BINDING);
final EMEPBinding eMEPBinding = EMEPBinding.getFromIDOrNull(sMEPBinding);
if (eMEPBinding == null)
throw new IllegalStateException("Failed to resolve MEPBinding '" + sMEPBinding + "'");
final PModeLeg aLeg1 = MicroTypeConverter.convertToNative(aElement.getFirstChildElement(ELEMENT_LEG1), PModeLeg.class);
final PModeLeg aLeg2 = MicroTypeConverter.convertToNative(aElement.getFirstChildElement(ELEMENT_LEG2), PModeLeg.class);
final PModePayloadService aPayloadService = MicroTypeConverter.convertToNative(aElement.getFirstChildElement(ELEMENT_PAYLOADSERVICE), PModePayloadService.class);
final PModeReceptionAwareness aReceptionAwareness = MicroTypeConverter.convertToNative(aElement.getFirstChildElement(ELEMENT_RECEPETIONAWARENESS), PModeReceptionAwareness.class);
return new PMode(getStubObject(aElement), aInitiator, aResponder, sAgreement, eMEP, eMEPBinding, aLeg1, aLeg2, aPayloadService, aReceptionAwareness);
}
use of com.helger.phase4.model.pmode.PModePayloadService in project phase4 by phax.
the class CEFPMode method createCEFPMode.
/**
* One-Way Version of the CEF pmode uses one-way push
*
* @param sInitiatorID
* Initiator ID
* @param sResponderID
* Responder ID
* @param sResponderAddress
* Responder URL
* @param aPModeIDProvider
* PMode ID provider
* @param bPersist
* <code>true</code> to persist the PMode in the PModeManager,
* <code>false</code> to have it only in memory.
* @return New PMode
*/
@Nonnull
public static PMode createCEFPMode(@Nonnull @Nonempty final String sInitiatorID, @Nonnull @Nonempty final String sResponderID, @Nullable final String sResponderAddress, @Nonnull final IPModeIDProvider aPModeIDProvider, final boolean bPersist) {
final PModeParty aInitiator = PModeParty.createSimple(sInitiatorID, CAS4.DEFAULT_INITIATOR_URL);
final PModeParty aResponder = PModeParty.createSimple(sResponderID, CAS4.DEFAULT_RESPONDER_URL);
final PMode aPMode = new PMode(aPModeIDProvider.getPModeID(sInitiatorID, sResponderID), aInitiator, aResponder, DEFAULT_AGREEMENT_ID, EMEP.ONE_WAY, EMEPBinding.PUSH, generatePModeLeg(sResponderAddress), (PModeLeg) null, (PModePayloadService) null, generatePModeReceptionAwareness());
if (bPersist) {
// Ensure it is stored
MetaAS4Manager.getPModeMgr().createOrUpdatePMode(aPMode);
}
return aPMode;
}
use of com.helger.phase4.model.pmode.PModePayloadService in project phase4 by phax.
the class ENTSOGCompatibilityValidator method validatePMode.
@Override
public void validatePMode(@Nonnull final IPMode aPMode, @Nonnull final ErrorList aErrorList) {
ValueEnforcer.isTrue(aErrorList.isEmpty(), () -> "Errors in global PMode validation: " + aErrorList.toString());
try {
MetaAS4Manager.getPModeMgr().validatePMode(aPMode);
} catch (final PModeValidationException ex) {
aErrorList.add(_createError(ex.getMessage()));
}
final EMEP eMEP = aPMode.getMEP();
final EMEPBinding eMEPBinding = aPMode.getMEPBinding();
if ((eMEP == EMEP.ONE_WAY && eMEPBinding == EMEPBinding.PUSH) || (eMEP == EMEP.TWO_WAY && eMEPBinding == EMEPBinding.PUSH_PUSH)) {
// Valid
} else {
aErrorList.add(_createError("An invalid combination of PMode MEP (" + eMEP + ") and MEP binding (" + eMEPBinding + ") was specified, valid are only one-way/push and two-way/push-push."));
}
// Leg1 must be present
final PModeLeg aPModeLeg1 = aPMode.getLeg1();
if (aPModeLeg1 == null) {
aErrorList.add(_createError("PMode.Leg[1] is missing"));
} else {
_checkIfLegIsValid(aErrorList, aPModeLeg1, "PMode.Leg[1].");
}
if (aPMode.getLeg2() != null) {
aErrorList.add(_createError("PMode.Leg[2] must not be present"));
}
final PModePayloadService aPayloadService = aPMode.getPayloadService();
if (aPayloadService != null) {
final EAS4CompressionMode eCompressionMode = aPayloadService.getCompressionMode();
if (eCompressionMode != null) {
if (!eCompressionMode.equals(EAS4CompressionMode.GZIP))
aErrorList.add(_createError("PMode.PayloadService.CompressionMode must be " + EAS4CompressionMode.GZIP + " instead of " + eCompressionMode));
} else {
aErrorList.add(_createError("PMode.PayloadService.CompressionMode is missing"));
}
} else {
aErrorList.add(_createError("PMode.PayloadService is missing"));
}
}
Aggregations