@Override public void setDigest(String digest) { blob.setDigest(digest); }
protected void setMemberValue(Blob blob, String name, Object value) throws PropertyNotFoundException { if (NAME.equals(name)) { blob.setFilename((String) value); } else if (MIME_TYPE.equals(name)) { blob.setMimeType((String) value); } else if (ENCODING.equals(name)) { blob.setEncoding((String) value); } else if (DIGEST.equals(name)) { blob.setDigest((String) value); } else { throw new PropertyNotFoundException(name); } }
@Override public String getHash() { Blob blob = getBlob(); if (blob != null) { String h = blob.getDigest(); if (h == null) { h = getMD5Digest(); blob.setDigest(h); } return h; } return "NullBlob"; }
public static Blob getBlobFromMap(Map<String, Object> mapValue) { if (mapValue == null) { return null; } String uri = (String) mapValue.get(URI); if (uri == null || "".equals(uri)) { return null; } String filename = (String) mapValue.get(FILE_NAME); String mimeType = (String) mapValue.get(MIME_TYPE); String encoding = (String) mapValue.get(ENCODING); String digest = (String) mapValue.get(DIGEST); try { BlobHolderAdapterService service = Framework.getService(BlobHolderAdapterService.class); if (service == null) { throw new NuxeoException("BlobHolderAdapterService not found"); } Blob blob = service.getExternalBlobForUri(uri); if (filename != null) { blob.setFilename(filename); } blob.setMimeType(mimeType); blob.setEncoding(encoding); // TODO maybe check if digest is still a match to the retrieved blob blob.setDigest(digest); return blob; } catch (IOException e) { throw new NuxeoException(e); } }
protected List<Blob> loadBlobs(List<Map<String, String>> blobInfos) { log.debug("Loading blobs from the file system: " + blobInfos); List<Blob> blobs = new ArrayList<>(); for (Map<String, String> info : blobInfos) { File blobFile = new File(cacheDir, info.get("file")); Blob blob = new FileBlob(blobFile); blob.setEncoding(info.get("encoding")); blob.setMimeType(info.get("mimetype")); blob.setFilename(info.get("filename")); blob.setDigest(info.get("digest")); blobs.add(blob); } return blobs; }
Blob b = Blobs.createBlob(bytes, mimeType, encoding); b.setFilename((String) record.get(AvroConstants.CONTENT_NAME)); b.setDigest((String) record.get(AvroConstants.DIGEST)); return b; } catch (IOException e) {
blob.setDigest(contentMd5);
protected void checkBlob(Document doc, BlobAccessor accessor) { Blob blob = accessor.getBlob(); if (!(blob instanceof ManagedBlob)) { return; } // compare current provider with expected String expectedProviderId = getProviderId(doc, blob, accessor.getXPath()); if (((ManagedBlob) blob).getProviderId().equals(expectedProviderId)) { return; } // re-write blob // TODO add APIs so that blob providers can copy blobs efficiently from each other Blob newBlob; try (InputStream in = blob.getStream()) { newBlob = Blobs.createBlob(in, blob.getMimeType(), blob.getEncoding()); newBlob.setFilename(blob.getFilename()); newBlob.setDigest(blob.getDigest()); } catch (IOException e) { throw new RuntimeException(e); } accessor.setBlob(newBlob); }