@Override public Set<String> keySet() { return ImmutableSet.copyOf(transform(list(), new Function<BlobMetadata, String>() { @Override public String apply(BlobMetadata from) { return from.getName(); } })); }
@Override public ListenableFuture<Blob> apply(BlobMetadata from) { return ablobstore.getBlob(container, from.getName()); }
@Override public MultipartUpload initiateMultipartUpload(String container, BlobMetadata blobMetadata, PutOptions options) { String uploadId = UUID.randomUUID().toString(); return MultipartUpload.create(container, blobMetadata.getName(), uploadId, blobMetadata, options); }
private MultipartUpload initiateMultipartUpload(String container, BlobMetadata blobMetadata, long partSize, PutOptions options) { Long contentLength = blobMetadata.getContentMetadata().getContentLength(); String uploadId = String.format(Locale.ENGLISH, "%s/slo/%.6f/%s/%s", blobMetadata.getName(), System.currentTimeMillis() / 1000.0, contentLength == null ? Long.valueOf(0) : contentLength, partSize); return MultipartUpload.create(container, blobMetadata.getName(), uploadId, blobMetadata, options); }
public Iterable<? extends BlobMetadata> list() { return transform(listStrategy.execute(containerName, options), new Function<BlobMetadata, BlobMetadata>() { public BlobMetadata apply(BlobMetadata from) { MutableBlobMetadata md = new MutableBlobMetadataImpl(from); if (options.getDir() != null) md.setName(pathStripper.apply(from.getName())); return md; } }); }
public Iterable<? extends BlobMetadata> list() { return transform(listStrategy.execute(containerName, options), new Function<BlobMetadata, BlobMetadata>() { public BlobMetadata apply(BlobMetadata from) { MutableBlobMetadata md = new MutableBlobMetadataImpl(from); if (options.getDir() != null) md.setName(pathStripper.apply(from.getName())); return md; } }); }
@Override public MultipartUpload initiateMultipartUpload(String container, BlobMetadata blobMetadata, PutOptions options) { String uploadId = UUID.randomUUID().toString(); // create a stub blob Blob blob = blobBuilder(MULTIPART_PREFIX + uploadId + "-" + blobMetadata.getName() + "-stub").payload(ByteSource.empty()).build(); putBlob(container, blob); return MultipartUpload.create(container, blobMetadata.getName(), uploadId, blobMetadata, options); }
protected <T extends BlobMetadata> T validateMetadata(T md, String container, String name) { assertEquals(md.getName(), name); assertEquals(md.getContainer(), container); assert md.getUri() != null; return md; }
@Override public MultipartUpload initiateMultipartUpload(String container, BlobMetadata blobMetadata, PutOptions options) { Bucket bucket = getBucket(container); MultipartUploadResponse response = api.getMultipartApi().startLargeFile(bucket.bucketId(), blobMetadata.getName(), blobMetadata.getContentMetadata().getContentType(), blobMetadata.getUserMetadata()); return MultipartUpload.create(container, blobMetadata.getName(), response.fileId(), blobMetadata, options); }
public MutableContentMetadata apply(BlobMetadata base) { MutableBlobMetadataImpl to = new MutableBlobMetadataImpl(); HttpUtils.copy(base.getContentMetadata(), to.getContentMetadata()); return new DelegatingMutableContentMetadata(base.getUri(), base.getName(), base.getUri() != null ? base.getUri() .getPath() : null, to.getContentMetadata()); }
public MutableContentMetadata apply(BlobMetadata base) { MutableBlobMetadataImpl to = new MutableBlobMetadataImpl(); HttpUtils.copy(base.getContentMetadata(), to.getContentMetadata()); return new DelegatingMutableContentMetadata(base.getUri(), base.getName(), base.getUri() != null ? base.getUri() .getPath() : null, to.getContentMetadata()); }
public MutableContentMetadata apply(BlobMetadata base) { MutableBlobMetadataImpl to = new MutableBlobMetadataImpl(); HttpUtils.copy(base.getContentMetadata(), to.getContentMetadata()); return new DelegatingMutableContentMetadata(base.getUri(), base.getName(), base.getUri() != null ? base.getUri() .getPath() : null, to.getContentMetadata()); }
public MutableContentMetadata apply(BlobMetadata base) { MutableBlobMetadataImpl to = new MutableBlobMetadataImpl(); HttpUtils.copy(base.getContentMetadata(), to.getContentMetadata()); return new DelegatingMutableContentMetadata(base.getUri(), base.getName(), base.getUri() != null ? base.getUri() .getPath() : null, to.getContentMetadata()); }
public MutableContentMetadata apply(BlobMetadata base) { MutableBlobMetadataImpl to = new MutableBlobMetadataImpl(); HttpUtils.copy(base.getContentMetadata(), to.getContentMetadata()); return new DelegatingMutableContentMetadata(base.getUri(), base.getName(), base.getUri() != null ? base.getUri() .getPath() : null, to.getContentMetadata()); }
public StorageMetadata apply(BlobMetadata input) { if (input.getContentMetadata().getContentType().equals("application/directory")) { return new StorageMetadataImpl(StorageType.RELATIVE_PATH, input.getProviderId(), input .getName(), input.getLocation(), input.getUri(), input.getETag(), input.getCreationDate(), input.getLastModified(), input.getUserMetadata()); } return input; } }), from.getNextMarker());
public StorageMetadata apply(BlobMetadata input) { if (input.getContentMetadata().getContentType().equals("application/directory")) { return new StorageMetadataImpl(StorageType.RELATIVE_PATH, input.getProviderId(), input .getName(), input.getLocation(), input.getUri(), input.getETag(), input.getCreationDate(), input.getLastModified(), input.getUserMetadata()); } return input; } }), from.getNextMarker());
public StorageMetadata apply(BlobMetadata input) { if (input.getContentMetadata().getContentType().equals("application/directory")) { return new StorageMetadataImpl(StorageType.RELATIVE_PATH, input.getProviderId(), input .getName(), input.getLocation(), input.getUri(), input.getETag(), input.getCreationDate(), input.getLastModified(), input.getUserMetadata()); } return input; } }), from.getNextMarker());
public SystemMetadata apply(BlobMetadata base) { return new SystemMetadata(base.getContentMetadata().getContentMD5(), null, base.getLastModified(), null, null, null, 1, null, base.getName(), null, (base.getContentMetadata().getContentLength() != null) ? base .getContentMetadata().getContentLength() : 0, FileType.REGULAR, "root"); }
public SystemMetadata apply(BlobMetadata base) { return new SystemMetadata(base.getContentMetadata().getContentMD5(), null, base.getLastModified(), null, null, null, 1, null, base.getName(), null, (base.getContentMetadata().getContentLength() != null) ? base .getContentMetadata().getContentLength() : 0, FileType.REGULAR, "root"); }
@Test public void testApplySetsName() { HttpResponse from = HttpResponse.builder() .statusCode(200).message("ok") .payload("") .addHeader(HttpHeaders.LAST_MODIFIED, "Wed, 09 Sep 2009 19:50:23 GMT").build(); from.getPayload().getContentMetadata().setContentType(MediaType.APPLICATION_JSON); from.getPayload().getContentMetadata().setContentLength(100l); BlobMetadata metadata = parser.apply(from); assertEquals(metadata.getName(), "key"); }