use of com.helger.phase4.ebms3header.Ebms3PartProperties in project phase4 by phax.
the class MessageHelperMethods method createEbms3PartInfo.
@Nullable
public static Ebms3PartInfo createEbms3PartInfo(@Nullable final IAS4Attachment aAttachment) {
if (aAttachment == null)
return null;
final ICommonsSet<String> aUsedPropertyNames = new CommonsHashSet<>();
final Ebms3PartProperties aEbms3PartProperties = new Ebms3PartProperties();
aEbms3PartProperties.addProperty(createEbms3Property(PART_PROPERTY_MIME_TYPE, aAttachment.getUncompressedMimeType()));
aUsedPropertyNames.add(PART_PROPERTY_MIME_TYPE);
if (aAttachment.hasCharset()) {
aEbms3PartProperties.addProperty(createEbms3Property(PART_PROPERTY_CHARACTER_SET, aAttachment.getCharset().name()));
aUsedPropertyNames.add(PART_PROPERTY_CHARACTER_SET);
}
if (aAttachment.hasCompressionMode()) {
aEbms3PartProperties.addProperty(createEbms3Property(PART_PROPERTY_COMPRESSION_TYPE, aAttachment.getCompressionMode().getMimeTypeAsString()));
aUsedPropertyNames.add(PART_PROPERTY_COMPRESSION_TYPE);
}
// Add all custom part properties (since 0.12.0)
for (final Map.Entry<String, String> aEntry : aAttachment.customPartProperties().entrySet()) if (aUsedPropertyNames.add(aEntry.getKey()))
aEbms3PartProperties.addProperty(createEbms3Property(aEntry.getKey(), aEntry.getValue()));
final Ebms3PartInfo aEbms3PartInfo = new Ebms3PartInfo();
aEbms3PartInfo.setHref(PREFIX_CID + aAttachment.getId());
aEbms3PartInfo.setPartProperties(aEbms3PartProperties);
return aEbms3PartInfo;
}
Aggregations