use of com.google.cloud.storage.spi.v1.StorageRpc.RewriteResponse in project google-cloud-java by GoogleCloudPlatform.
the class StorageImpl method copy.
@Override
public CopyWriter copy(final CopyRequest copyRequest) {
final StorageObject source = copyRequest.getSource().toPb();
final Map<StorageRpc.Option, ?> sourceOptions = optionMap(copyRequest.getSource().getGeneration(), null, copyRequest.getSourceOptions(), true);
final StorageObject targetObject = copyRequest.getTarget().toPb();
final Map<StorageRpc.Option, ?> targetOptions = optionMap(copyRequest.getTarget().getGeneration(), copyRequest.getTarget().getMetageneration(), copyRequest.getTargetOptions());
try {
RewriteResponse rewriteResponse = runWithRetries(new Callable<RewriteResponse>() {
@Override
public RewriteResponse call() {
return storageRpc.openRewrite(new StorageRpc.RewriteRequest(source, sourceOptions, copyRequest.overrideInfo(), targetObject, targetOptions, copyRequest.getMegabytesCopiedPerChunk()));
}
}, getOptions().getRetrySettings(), EXCEPTION_HANDLER, getOptions().getClock());
return new CopyWriter(getOptions(), rewriteResponse);
} catch (RetryHelperException e) {
throw StorageException.translateAndThrow(e);
}
}
Aggregations