Source:
Pair<AttachmentInfo, Metacard> parseAttachments( List<Attachment> contentParts, String transformerParam) { if (contentParts.size() == 1) { Attachment contentPart = contentParts.get(0); InputStream attachmentInputStream = null; try { attachmentInputStream = contentPart.getDataHandler().getInputStream(); } catch (IOException e) { LOGGER.info("IOException reading stream from file attachment in multipart body", e); } return new ImmutablePair<>( attachmentParser.generateAttachmentInfo( attachmentInputStream, contentPart.getContentType().toString(), contentPart .getContentDisposition() .getParameter(FILENAME_CONTENT_DISPOSITION_PARAMETER_NAME)), null); } List<Attribute> attributes = new ArrayList<>(contentParts.size()); Metacard metacard = null; AttachmentInfo attachmentInfo = null; for (Attachment attachment : contentParts) { String name = attachment.getContentDisposition().getParameter("name"); String parsedName = (name.startsWith("parse.")) ? name.substring(6) : name; try { InputStream inputStream = attachment.getDataHandler().getInputStream(); if (name.equals("parse.resource")) { attachmentInfo = attachmentParser.generateAttachmentInfo( inputStream, attachment.getContentType().toString(), attachment .getContentDisposition() .getParameter(FILENAME_CONTENT_DISPOSITION_PARAMETER_NAME)); } else if (name.equals("parse.metadata")) { metacard = parseMetadata(transformerParam, metacard, attachment, inputStream); } else { parseOverrideAttributes(attributes, parsedName, inputStream); } } catch (IOException e) { LOGGER.debug( "Unable to get input stream for mime attachment. Ignoring override attribute: {}", name, e); } } if (attachmentInfo == null) { throw new IllegalArgumentException("No parse.resource specified in request."); } if (metacard == null) { metacard = new MetacardImpl(); } for (Attribute attribute : attributes) { metacard.setAttribute(attribute); } return new ImmutablePair<>(attachmentInfo, metacard); }

Target:
Pair<AttachmentInfo, Metacard> parseAttachments( List<Attachment> contentParts, String transformerParam) { if (contentParts.size() == 1) { Attachment contentPart = contentParts.get(0); InputStream attachmentInputStream = null; try { attachmentInputStream = contentPart.getDataHandler().getInputStream(); } catch (IOException e) { LOGGER.debug("IOException reading stream from file attachment in multipart body.", e); } return new ImmutablePair<>( attachmentParser.generateAttachmentInfo( attachmentInputStream, contentPart.getContentType().toString(), contentPart .getContentDisposition() .getParameter(FILENAME_CONTENT_DISPOSITION_PARAMETER_NAME)), null); } List<Attribute> attributes = new ArrayList<>(contentParts.size()); Metacard metacard = null; AttachmentInfo attachmentInfo = null; for (Attachment attachment : contentParts) { String name = attachment.getContentDisposition().getParameter("name"); String parsedName = (name.startsWith("parse.")) ? name.substring(6) : name; try { InputStream inputStream = attachment.getDataHandler().getInputStream(); if (name.equals("parse.resource")) { attachmentInfo = attachmentParser.generateAttachmentInfo( inputStream, attachment.getContentType().toString(), attachment .getContentDisposition() .getParameter(FILENAME_CONTENT_DISPOSITION_PARAMETER_NAME)); } else if (name.equals("parse.metadata")) { metacard = parseMetadata(transformerParam, metacard, attachment, inputStream); } else { parseOverrideAttributes(attributes, parsedName, inputStream); } } catch (IOException e) { LOGGER.debug( "Unable to get input stream for mime attachment. Ignoring override attribute: {}", name, e); } } if (attachmentInfo == null) { throw new IllegalArgumentException("No parse.resource specified in request."); } if (metacard == null) { metacard = new MetacardImpl(); } for (Attribute attribute : attributes) { metacard.setAttribute(attribute); } return new ImmutablePair<>(attachmentInfo, metacard); }