private void storeAttachment(Attachment attachment, File attachmentDir) throws Exception { String attachmentName = attachment.getName(); String[] names = attachmentName.split("/"); String lastName = names[names.length-1]; try { File attachmentFile = new File(currentParent, lastName); is = attachment.getInputStream(); fos = new FileOutputStream(attachmentFile); infoObj.put(ATT_INFO_NAME, attachment.getName()); infoObj.put(ATT_INFO_CONTENT_TYPE, attachment.getContentType());
is = attachment.getInputStream(); throw new Exception("Error computing digest on attachment: "+attachment.getName(), e);
InputStreamReader isr = null; try { is = attachment.getInputStream(); isr = new InputStreamReader(is,"UTF-8"); StringWriter sw = new StringWriter();
if( null != attachments ) { for(Attachment attachment : attachments){ attachmentsByName.put(attachment.getName(), attachment); String attachmentName = attachment.getName(); String attachmentContentType = attachment.getContentType(); shouldUpload = shouldAttachmentBeUploaded( targetDoc
public void addAttachment(Attachment attachment){ attachments.put(attachment.getName(), attachment); } }
storeAttachment(attachment, attachmentDir); } catch(Exception e) { throw new Exception("Unable to store attachment: "+attachment.getName(), e);
if( attachmentNamesToUpload.contains(attachment.getName()) ) { InputStream is = attachment.getInputStream(); builder.key( attachment.getName() ); builder.object(); builder.value( attachment.getContentType() );
@Override public DocumentDigest computeDocumentDigest(Document doc) throws Exception { try { JSONObject json = doc.getJSONObject(); // Initialize digest DocumentDigest dd = new DocumentDigest(); dd.setType(DIGEST_COMPUTER_TYPE); // Compute digest of main document String mainDigest = this.computeDigestFromJsonObject(json); dd.setDocDigest(mainDigest); // Process each attachment Collection<Attachment> attachments = doc.getAttachments(); if( null != attachments ) { for(Attachment attachment : attachments){ String digest = computeAttachmentDigest(attachment); dd.addAttachmentDigest(attachment.getName(), digest); } } return dd; } catch(Exception e) { throw new Exception("Error while computing document digest for "+doc.getId(), e); } }