use of com.google.api.services.storage.model.ComposeRequest.SourceObjects.ObjectPreconditions in project google-cloud-java by GoogleCloudPlatform.
the class HttpStorageRpc method compose.
@Override
public StorageObject compose(Iterable<StorageObject> sources, StorageObject target, Map<Option, ?> targetOptions) {
ComposeRequest request = new ComposeRequest();
request.setDestination(target);
List<ComposeRequest.SourceObjects> sourceObjects = new ArrayList<>();
for (StorageObject source : sources) {
ComposeRequest.SourceObjects sourceObject = new ComposeRequest.SourceObjects();
sourceObject.setName(source.getName());
Long generation = source.getGeneration();
if (generation != null) {
sourceObject.setGeneration(generation);
sourceObject.setObjectPreconditions(new ObjectPreconditions().setIfGenerationMatch(generation));
}
sourceObjects.add(sourceObject);
}
request.setSourceObjects(sourceObjects);
try {
return storage.objects().compose(target.getBucket(), target.getName(), request).setIfMetagenerationMatch(Option.IF_METAGENERATION_MATCH.getLong(targetOptions)).setIfGenerationMatch(Option.IF_GENERATION_MATCH.getLong(targetOptions)).execute();
} catch (IOException ex) {
throw translate(ex);
}
}
Aggregations