@Override public RewriteResponse continueRewrite(RewriteResponse previousResponse) { Span span = startSpan(HttpStorageRpcSpans.SPAN_NAME_CONTINUE_REWRITE); Scope scope = tracer.withSpan(span); try { return rewrite(previousResponse.rewriteRequest, previousResponse.rewriteToken); } finally { scope.close(); span.end(); } }
@Override public RewriteResponse openRewrite(RewriteRequest rewriteRequest) { Span span = startSpan(HttpStorageRpcSpans.SPAN_NAME_OPEN_REWRITE); Scope scope = tracer.withSpan(span); try { return rewrite(rewriteRequest, null); } finally { scope.close(); span.end(); } }
@Override public StorageObject patch(StorageObject storageObject, Map<Option, ?> options) { Span span = startSpan(HttpStorageRpcSpans.SPAN_NAME_PATCH_OBJECT); Scope scope = tracer.withSpan(span); try { return patchCall(storageObject, options).execute(); } catch (IOException ex) { span.setStatus(Status.UNKNOWN.withDescription(ex.getMessage())); throw translate(ex); } finally { scope.close(); span.end(); } }
@Override public Notification createNotification(String bucket, Notification notification) { Span span = startSpan(HttpStorageRpcSpans.SPAN_NAME_CREATE_NOTIFICATION); Scope scope = tracer.withSpan(span); try { return storage.notifications().insert(bucket, notification).execute(); } catch (IOException ex) { span.setStatus(Status.UNKNOWN.withDescription(ex.getMessage())); throw translate(ex); } finally { scope.close(); span.end(); } }
@Override public ObjectAccessControl createDefaultAcl(ObjectAccessControl acl) { Span span = startSpan(HttpStorageRpcSpans.SPAN_NAME_CREATE_OBJECT_DEFAULT_ACL); Scope scope = tracer.withSpan(span); try { return storage.defaultObjectAccessControls().insert(acl.getBucket(), acl).execute(); } catch (IOException ex) { span.setStatus(Status.UNKNOWN.withDescription(ex.getMessage())); throw translate(ex); } finally { scope.close(); span.end(); } }
@Override public StorageObject get(StorageObject object, Map<Option, ?> options) { Span span = startSpan(HttpStorageRpcSpans.SPAN_NAME_GET_OBJECT); Scope scope = tracer.withSpan(span); try { return getCall(object, options).execute(); } catch (IOException ex) { span.setStatus(Status.UNKNOWN.withDescription(ex.getMessage())); StorageException serviceException = translate(ex); if (serviceException.getCode() == HTTP_NOT_FOUND) { return null; } throw serviceException; } finally { scope.close(); span.end(); } }
@Override public List<Notification> listNotifications(String bucket) { Span span = startSpan(HttpStorageRpcSpans.SPAN_NAME_LIST_NOTIFICATIONS); Scope scope = tracer.withSpan(span); try { return storage.notifications().list(bucket).execute().getItems(); } catch (IOException ex) { span.setStatus(Status.UNKNOWN.withDescription(ex.getMessage())); throw translate(ex); } finally { scope.close(); span.end(); } }
@Override public List<ObjectAccessControl> listDefaultAcls(String bucket) { Span span = startSpan(HttpStorageRpcSpans.SPAN_NAME_LIST_OBJECT_DEFAULT_ACLS); Scope scope = tracer.withSpan(span); try { return storage.defaultObjectAccessControls().list(bucket).execute().getItems(); } catch (IOException ex) { span.setStatus(Status.UNKNOWN.withDescription(ex.getMessage())); throw translate(ex); } finally { scope.close(); span.end(); } }
@Override public boolean delete(StorageObject blob, Map<Option, ?> options) { Span span = startSpan(HttpStorageRpcSpans.SPAN_NAME_DELETE_OBJECT); Scope scope = tracer.withSpan(span); try { deleteCall(blob, options).execute(); return true; } catch (IOException ex) { span.setStatus(Status.UNKNOWN.withDescription(ex.getMessage())); StorageException serviceException = translate(ex); if (serviceException.getCode() == HTTP_NOT_FOUND) { return false; } throw serviceException; } finally { scope.close(); span.end(); } }
@Override public ServiceAccount getServiceAccount(String projectId) { Span span = startSpan(HttpStorageRpcSpans.SPAN_NAME_GET_SERVICE_ACCOUNT); Scope scope = tracer.withSpan(span); try { return storage.projects().serviceAccount().get(projectId).execute(); } catch (IOException ex) { span.setStatus(Status.UNKNOWN.withDescription(ex.getMessage())); throw translate(ex); } finally { scope.close(); span.end(); } } }
@Override public ObjectAccessControl getDefaultAcl(String bucket, String entity) { Span span = startSpan(HttpStorageRpcSpans.SPAN_NAME_GET_OBJECT_DEFAULT_ACL); Scope scope = tracer.withSpan(span); try { return storage.defaultObjectAccessControls().get(bucket, entity).execute(); } catch (IOException ex) { span.setStatus(Status.UNKNOWN.withDescription(ex.getMessage())); StorageException serviceException = translate(ex); if (serviceException.getCode() == HTTP_NOT_FOUND) { return null; } throw serviceException; } finally { scope.close(); span.end(); } }
@Override public Policy setIamPolicy(String bucket, Policy policy, Map<Option, ?> options) { Span span = startSpan(HttpStorageRpcSpans.SPAN_NAME_SET_BUCKET_IAM_POLICY); Scope scope = tracer.withSpan(span); try { return storage .buckets() .setIamPolicy(bucket, policy) .setUserProject(Option.USER_PROJECT.getString(options)) .execute(); } catch (IOException ex) { span.setStatus(Status.UNKNOWN.withDescription(ex.getMessage())); throw translate(ex); } finally { scope.close(); span.end(); } }
@Override public ObjectAccessControl patchDefaultAcl(ObjectAccessControl acl) { Span span = startSpan(HttpStorageRpcSpans.SPAN_NAME_PATCH_OBJECT_DEFAULT_ACL); Scope scope = tracer.withSpan(span); try { return storage .defaultObjectAccessControls() .patch(acl.getBucket(), acl.getEntity(), acl) .execute(); } catch (IOException ex) { span.setStatus(Status.UNKNOWN.withDescription(ex.getMessage())); throw translate(ex); } finally { scope.close(); span.end(); } }
@Override public Policy getIamPolicy(String bucket, Map<Option, ?> options) { Span span = startSpan(HttpStorageRpcSpans.SPAN_NAME_GET_BUCKET_IAM_POLICY); Scope scope = tracer.withSpan(span); try { return storage .buckets() .getIamPolicy(bucket) .setUserProject(Option.USER_PROJECT.getString(options)) .execute(); } catch (IOException ex) { span.setStatus(Status.UNKNOWN.withDescription(ex.getMessage())); throw translate(ex); } finally { scope.close(); span.end(); } }
@Override public BucketAccessControl createAcl(BucketAccessControl acl, Map<Option, ?> options) { Span span = startSpan(HttpStorageRpcSpans.SPAN_NAME_CREATE_BUCKET_ACL); Scope scope = tracer.withSpan(span); try { return storage .bucketAccessControls() .insert(acl.getBucket(), acl) .setUserProject(Option.USER_PROJECT.getString(options)) .execute(); } catch (IOException ex) { span.setStatus(Status.UNKNOWN.withDescription(ex.getMessage())); throw translate(ex); } finally { scope.close(); span.end(); } }
@Override public List<BucketAccessControl> listAcls(String bucket, Map<Option, ?> options) { Span span = startSpan(HttpStorageRpcSpans.SPAN_NAME_LIST_BUCKET_ACLS); Scope scope = tracer.withSpan(span); try { return storage .bucketAccessControls() .list(bucket) .setUserProject(Option.USER_PROJECT.getString(options)) .execute() .getItems(); } catch (IOException ex) { span.setStatus(Status.UNKNOWN.withDescription(ex.getMessage())); throw translate(ex); } finally { scope.close(); span.end(); } }
@Override public Bucket lockRetentionPolicy(Bucket bucket, Map<Option, ?> options) { Span span = startSpan(HttpStorageRpcSpans.SPAN_LOCK_RETENTION_POLICY); Scope scope = tracer.withSpan(span); try { return storage .buckets() .lockRetentionPolicy(bucket.getName(), Option.IF_METAGENERATION_MATCH.getLong(options)) .setUserProject(Option.USER_PROJECT.getString(options)) .execute(); } catch (IOException ex) { span.setStatus(Status.UNKNOWN.withDescription(ex.getMessage())); throw translate(ex); } finally { scope.close(); span.end(); } }
@Override public BucketAccessControl patchAcl(BucketAccessControl acl, Map<Option, ?> options) { Span span = startSpan(HttpStorageRpcSpans.SPAN_NAME_PATCH_BUCKET_ACL); Scope scope = tracer.withSpan(span); try { return storage .bucketAccessControls() .patch(acl.getBucket(), acl.getEntity(), acl) .setUserProject(Option.USER_PROJECT.getString(options)) .execute(); } catch (IOException ex) { span.setStatus(Status.UNKNOWN.withDescription(ex.getMessage())); throw translate(ex); } finally { scope.close(); span.end(); } }
@Override public ObjectAccessControl createAcl(ObjectAccessControl acl) { Span span = startSpan(HttpStorageRpcSpans.SPAN_NAME_CREATE_OBJECT_ACL); Scope scope = tracer.withSpan(span); try { return storage .objectAccessControls() .insert(acl.getBucket(), acl.getObject(), acl) .setGeneration(acl.getGeneration()) .execute(); } catch (IOException ex) { span.setStatus(Status.UNKNOWN.withDescription(ex.getMessage())); throw translate(ex); } finally { scope.close(); span.end(); } }
@Override public ObjectAccessControl patchAcl(ObjectAccessControl acl) { Span span = startSpan(HttpStorageRpcSpans.SPAN_NAME_PATCH_OBJECT_ACL); Scope scope = tracer.withSpan(span); try { return storage .objectAccessControls() .patch(acl.getBucket(), acl.getObject(), acl.getEntity(), acl) .setGeneration(acl.getGeneration()) .execute(); } catch (IOException ex) { span.setStatus(Status.UNKNOWN.withDescription(ex.getMessage())); throw translate(ex); } finally { scope.close(); span.end(); } }