/** Process a multipart body part */ private boolean processMultipart(JCas jCas, Multipart mp, String sourceUri) throws IOException { boolean doneBody = false; for (Entity e : mp.getBodyParts()) { if (e.getFilename() != null) { // Part has a filename, and is therefore an attachment String extension = FilenameUtils.getExtension(e.getFilename()).toLowerCase(); if (ignoreExtensionsList.contains(extension)) { getMonitor().info("Skipping attachment {}", e.getFilename()); continue; } attachments.put(sourceUri + "/" + e.getFilename(), e.getBody()); } else if (!doneBody) { // Part has no filename, and we've not already processed a part to use as a body processBody(jCas, e.getBody(), sourceUri); // Add metadata for (Field f : e.getParent().getHeader().getFields()) { addMetadata(jCas, f.getName(), f.getBody()); } doneBody = true; } } return doneBody; }
/** Process a multipart body part */ private boolean processMultipart(JCas jCas, Multipart mp, String sourceUri) throws IOException { boolean doneBody = false; for (Entity e : mp.getBodyParts()) { if (e.getFilename() != null) { // Part has a filename, and is therefore an attachment String extension = FilenameUtils.getExtension(e.getFilename()).toLowerCase(); if (ignoreExtensionsList.contains(extension)) { getMonitor().info("Skipping attachment {}", e.getFilename()); continue; } attachments.put(sourceUri + "/" + e.getFilename(), e.getBody()); } else if (!doneBody) { // Part has no filename, and we've not already processed a part to use as a body processBody(jCas, e.getBody(), sourceUri); // Add metadata for (Field f : e.getParent().getHeader().getFields()) { addMetadata(jCas, f.getName(), f.getBody()); } doneBody = true; } } return doneBody; }