Search in sources :

Example 1 with Ebms3PartProperties

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;
}
Also used : Ebms3PartProperties(com.helger.phase4.ebms3header.Ebms3PartProperties) Ebms3PartInfo(com.helger.phase4.ebms3header.Ebms3PartInfo) CommonsHashSet(com.helger.commons.collection.impl.CommonsHashSet) HttpHeaderMap(com.helger.commons.http.HttpHeaderMap) Map(java.util.Map) Nullable(javax.annotation.Nullable)

Aggregations

CommonsHashSet (com.helger.commons.collection.impl.CommonsHashSet)1 HttpHeaderMap (com.helger.commons.http.HttpHeaderMap)1 Ebms3PartInfo (com.helger.phase4.ebms3header.Ebms3PartInfo)1 Ebms3PartProperties (com.helger.phase4.ebms3header.Ebms3PartProperties)1 Map (java.util.Map)1 Nullable (javax.annotation.Nullable)1