use of com.helger.commons.annotation.ContainsSoftMigration in project ph-web by phax.
the class EmailDataMicroTypeConverter method convertToNative.
@Nonnull
@ContainsSoftMigration
public EmailData convertToNative(@Nonnull final IMicroElement eEmailData) {
final String sEmailType = eEmailData.getAttributeValue(ATTR_TYPE);
final EEmailType eEmailType = EEmailType.getFromIDOrNull(sEmailType);
final EmailData aEmailData = new EmailData(eEmailType);
final IMicroElement eFrom = eEmailData.getFirstChildElement(ELEMENT_FROM);
aEmailData.setFrom(_readEmailAddress(eFrom));
for (final IMicroElement eReplyTo : eEmailData.getAllChildElements(ELEMENT_REPLYTO)) aEmailData.replyTo().add(_readEmailAddress(eReplyTo));
for (final IMicroElement eTo : eEmailData.getAllChildElements(ELEMENT_TO)) aEmailData.to().add(_readEmailAddress(eTo));
for (final IMicroElement eCc : eEmailData.getAllChildElements(ELEMENT_CC)) aEmailData.cc().add(_readEmailAddress(eCc));
for (final IMicroElement eBcc : eEmailData.getAllChildElements(ELEMENT_BCC)) aEmailData.bcc().add(_readEmailAddress(eBcc));
final LocalDateTime aSentDateTime = eEmailData.getAttributeValueWithConversion(ATTR_SENTDATETIME, LocalDateTime.class);
if (aSentDateTime != null)
aEmailData.setSentDateTime(aSentDateTime);
else {
// Soft migration
final String sSentDate = eEmailData.getAttributeValue("sentdate");
if (sSentDate != null) {
final ZonedDateTime aDT = PDTWebDateHelper.getZonedDateTimeFromXSD(sSentDate);
if (aDT != null)
aEmailData.setSentDateTime(aDT.toLocalDateTime());
}
}
aEmailData.setSubject(eEmailData.getAttributeValue(ATTR_SUBJECT));
aEmailData.setBody(MicroHelper.getChildTextContent(eEmailData, ELEMENT_BODY));
final IMicroElement eAttachments = eEmailData.getFirstChildElement(ELEMENT_ATTACHMENTS);
if (eAttachments != null) {
// Default way: use converter
aEmailData.setAttachments(MicroTypeConverter.convertToNative(eAttachments, EmailAttachmentList.class));
} else {
// For legacy stuff:
final EmailAttachmentList aAttachments = new EmailAttachmentList();
for (final IMicroElement eAttachment : eEmailData.getAllChildElements("attachment")) aAttachments.addAttachment(MicroTypeConverter.convertToNative(eAttachment, EmailAttachment.class));
if (!aAttachments.isEmpty())
aEmailData.setAttachments(aAttachments);
}
for (final IMicroElement eCustom : eEmailData.getAllChildElements(ELEMENT_CUSTOM)) aEmailData.attrs().putIn(eCustom.getAttributeValue(ATTR_ID), eCustom.getTextContent());
return aEmailData;
}
use of com.helger.commons.annotation.ContainsSoftMigration in project phoss-smp by phax.
the class SMPEndpointMicroTypeConverter method convertToNative.
@Nonnull
@ContainsSoftMigration
public SMPEndpoint convertToNative(@Nonnull final IMicroElement aElement) {
final String sTransportProfile = aElement.getAttributeValue(ATTR_TRANSPORT_PROFILE);
final String sEndpointReference = aElement.getAttributeValue(ATTR_ENDPOINT_REFERENCE);
final String sRequireBusinessLevelSignature = aElement.getAttributeValue(ATTR_REQUIRE_BUSINESS_LEVEL_SIGNATURE);
final boolean bRequireBusinessLevelSignature = StringParser.parseBool(sRequireBusinessLevelSignature, SMPEndpoint.DEFAULT_REQUIRES_BUSINESS_LEVEL_SIGNATURE);
final String sMinimumAuthenticationLevel = aElement.getAttributeValue(ATTR_MINIMUM_AUTHENTICATION_LEVEL);
XMLOffsetDateTime aServiceActivationDate = aElement.getAttributeValueWithConversion(ATTR_SERVICE_ACTIVATION_DATE, XMLOffsetDateTime.class);
if (aServiceActivationDate == null) {
final LocalDateTime aServiceActivationDateLDT = aElement.getAttributeValueWithConversion(ATTR_SERVICE_ACTIVATION_DATE, LocalDateTime.class);
if (aServiceActivationDateLDT != null)
aServiceActivationDate = XMLOffsetDateTime.of(aServiceActivationDateLDT, null);
}
XMLOffsetDateTime aServiceExpirationDate = aElement.getAttributeValueWithConversion(ATTR_SERVICE_EXPIRATION_DATE, XMLOffsetDateTime.class);
if (aServiceExpirationDate == null) {
final LocalDateTime aServiceExpirationDateLDT = aElement.getAttributeValueWithConversion(ATTR_SERVICE_EXPIRATION_DATE, LocalDateTime.class);
if (aServiceExpirationDateLDT != null)
aServiceExpirationDate = XMLOffsetDateTime.of(aServiceExpirationDateLDT, null);
}
final String sCertificate = MicroHelper.getChildTextContentTrimmed(aElement, ELEMENT_CERTIFICATE);
final String sServiceDescription = MicroHelper.getChildTextContentTrimmed(aElement, ELEMENT_SERVICE_DESCRIPTION);
final String sTechnicalContactUrl = aElement.getAttributeValue(ATTR_TECHNICAL_CONTACT_URL);
final String sTechnicalInformationUrl = aElement.getAttributeValue(ATTR_TECHNICAL_INFORMATION_URL);
final String sExtension = MicroHelper.getChildTextContentTrimmed(aElement, ELEMENT_EXTENSION);
return new SMPEndpoint(sTransportProfile, sEndpointReference, bRequireBusinessLevelSignature, sMinimumAuthenticationLevel, aServiceActivationDate, aServiceExpirationDate, sCertificate, sServiceDescription, sTechnicalContactUrl, sTechnicalInformationUrl, sExtension);
}
use of com.helger.commons.annotation.ContainsSoftMigration in project phoss-smp by phax.
the class SMPParticipantMigrationMicroTypeConverter method convertToNative.
@Nonnull
@ContainsSoftMigration
public SMPParticipantMigration convertToNative(@Nonnull final IMicroElement aElement) {
final String sID = aElement.getAttributeValue(ATTR_ID);
final String sDirection = aElement.getAttributeValue(ATTR_DIRECTION);
final EParticipantMigrationDirection eDirection = EParticipantMigrationDirection.getFromIDOrNull(sDirection);
if (eDirection == null)
throw new IllegalStateException("Failed to resolve Participant Migration Direction with ID '" + sDirection + "'");
String sState = aElement.getAttributeValue(ATTR_STATE);
if (sState == null) {
// Migration
sState = EParticipantMigrationState.IN_PROGRESS.getID();
}
final EParticipantMigrationState eState = EParticipantMigrationState.getFromIDOrNull(sState);
if (eState == null)
throw new IllegalStateException("Failed to resolve Participant Migration State with ID '" + sState + "'");
final SimpleParticipantIdentifier aParticipantID = MicroTypeConverter.convertToNative(aElement.getFirstChildElement(ELEMENT_PARTICIPANT_IDENTIFIER), SimpleParticipantIdentifier.class);
final LocalDateTime aInitiationDT = aElement.getAttributeValueWithConversion(ATTR_INITIATION_DATETIME, LocalDateTime.class);
final String sMigrationKey = aElement.getAttributeValue(ATTR_MIGRATION_KEY);
return new SMPParticipantMigration(sID, eDirection, eState, aParticipantID, aInitiationDT, sMigrationKey);
}
use of com.helger.commons.annotation.ContainsSoftMigration in project phase4 by phax.
the class AS4DuplicateItemMicroTypeConverter method convertToNative.
@Nonnull
@ContainsSoftMigration
public AS4DuplicateItem convertToNative(@Nonnull final IMicroElement aElement) {
OffsetDateTime aODT = aElement.getAttributeValueWithConversion(ATTR_DT, OffsetDateTime.class);
if (aODT == null) {
// Soft migration
final LocalDateTime aLDT = aElement.getAttributeValueWithConversion(ATTR_DT, LocalDateTime.class);
if (aLDT != null)
aODT = OffsetDateTime.of(aLDT, ZoneOffset.UTC);
}
final String sMsgID = aElement.getAttributeValue(ATTR_MESSAGE_ID);
final String sProfileID = aElement.getAttributeValue(ATTR_PROFILE_ID);
final String sPModeID = aElement.getAttributeValue(ATTR_PMODE_ID);
return new AS4DuplicateItem(aODT, sMsgID, sProfileID, sPModeID);
}
use of com.helger.commons.annotation.ContainsSoftMigration in project ph-web by phax.
the class EmailAttachmentMicroTypeConverter method convertToNative.
@Nonnull
@ContainsSoftMigration
public EmailAttachment convertToNative(@Nonnull final IMicroElement eAttachment) {
final String sFilename = eAttachment.getAttributeValue(ATTR_FILENAME);
final String sCharset = eAttachment.getAttributeValue(ATTR_CHARSET);
final Charset aCharset = sCharset == null ? null : CharsetHelper.getCharsetFromName(sCharset);
String sContentType = eAttachment.getAttributeValue(ATTR_CONTENT_TYPE);
if (sContentType == null) {
// Soft migration 8.6.3
sContentType = FileTypeMap.getDefaultFileTypeMap().getContentType(sFilename);
}
final String sDisposition = eAttachment.getAttributeValue(ATTR_DISPOSITION);
EEmailAttachmentDisposition eDisposition = EEmailAttachmentDisposition.getFromIDOrNull(sDisposition);
if (eDisposition == null) {
// migration
eDisposition = EmailAttachment.DEFAULT_DISPOSITION;
}
final byte[] aContent = Base64.safeDecode(eAttachment.getTextContent());
return new EmailAttachment(sFilename, aContent, aCharset, sContentType, eDisposition);
}
Aggregations