Tabnine Logo
com.google.api.client.googleapis.json
Code IndexAdd Tabnine to your IDE (free)

How to use com.google.api.client.googleapis.json

Best Java code snippets using com.google.api.client.googleapis.json (Showing top 20 results out of 486)

origin: googleapis/google-cloud-java

private static String reason(GoogleJsonError error) {
 if (error.getErrors() != null && !error.getErrors().isEmpty()) {
  return error.getErrors().get(0).getReason();
 }
 return null;
}
origin: googleapis/google-cloud-java

 private static String message(IOException exception) {
  if (exception instanceof GoogleJsonResponseException) {
   GoogleJsonError details = ((GoogleJsonResponseException) exception).getDetails();
   if (details != null) {
    return details.getMessage();
   }
  }
  return exception.getMessage();
 }
}
origin: apache/incubator-gobblin

@Override
public boolean delete(Path path, boolean recursive) throws IOException {
 Preconditions.checkArgument(recursive, "Non-recursive is not supported.");
 String fileId = toFileId(path);
 LOG.debug("Deleting file: " + fileId);
 try {
  client.files().delete(fileId).execute();
 } catch (GoogleJsonResponseException e) {
  GoogleJsonError error = e.getDetails();
  if (404 == error.getCode()) { //Non-existing file id
   return false;
  }
  throw e;
 }
 return true;
}
origin: googleapis/google-cloud-java

if (exception instanceof HttpResponseException) {
 if (exception instanceof GoogleJsonResponseException) {
  GoogleJsonError jsonError = ((GoogleJsonResponseException) exception).getDetails();
  if (jsonError != null) {
   BaseServiceException.Error error =
     new BaseServiceException.Error(jsonError.getCode(), reason(jsonError));
   code = error.getCode();
   reason = error.getReason();
   retryable = error.isRetryable(idempotent, retryableErrors);
   if (reason != null) {
    GoogleJsonError.ErrorInfo errorInfo = jsonError.getErrors().get(0);
    location = errorInfo.getLocation();
    debugInfo = (String) errorInfo.get("debugInfo");
   code = ((GoogleJsonResponseException) exception).getStatusCode();
   retryable = BaseServiceException.isRetryable(code, null, idempotent, retryableErrors);
origin: googleapis/google-cloud-java

private static ExceptionData makeExceptionData(
  GoogleJsonError googleJsonError,
  boolean idempotent,
  Set<BaseServiceException.Error> retryableErrors) {
 int code = googleJsonError.getCode();
 String reason = reason(googleJsonError);
 ExceptionData.Builder exceptionData = ExceptionData.newBuilder();
 exceptionData
   .setMessage(googleJsonError.getMessage())
   .setCause(null)
   .setRetryable(BaseServiceException.isRetryable(code, reason, idempotent, retryableErrors))
   .setCode(code)
   .setReason(reason);
 if (reason != null) {
  GoogleJsonError.ErrorInfo errorInfo = googleJsonError.getErrors().get(0);
  exceptionData.setLocation(errorInfo.getLocation());
  exceptionData.setDebugInfo((String) errorInfo.get("debugInfo"));
 } else {
  exceptionData.setLocation(null);
  exceptionData.setDebugInfo(null);
 }
 return exceptionData.build();
}
origin: googleapis/google-cloud-java

assertSame(cause, exception.getCause());
GoogleJsonError error = new GoogleJsonError();
error.setCode(503);
error.setMessage("message");
exception = new DnsException(error, true);
assertEquals(503, exception.getCode());
origin: googleapis/google-cloud-java

@Test
public void testGetChangeRequestNotFound() {
 EasyMock.reset(batchMock);
 Capture<RpcBatch.Callback<Change>> callback = Capture.newInstance();
 Capture<Map<DnsRpc.Option, Object>> capturedOptions = Capture.newInstance();
 batchMock.addGetChangeRequest(
   EasyMock.eq(ZONE_NAME),
   EasyMock.eq(CHANGE_REQUEST_COMPLETE.getGeneratedId()),
   EasyMock.capture(callback),
   EasyMock.capture(capturedOptions));
 EasyMock.replay(batchMock);
 DnsBatchResult<ChangeRequest> batchResult =
   dnsBatch.getChangeRequest(ZONE_NAME, CHANGE_REQUEST_COMPLETE.getGeneratedId());
 assertEquals(0, capturedOptions.getValue().size());
 RpcBatch.Callback<Change> capturedCallback = callback.getValue();
 GoogleJsonError error = new GoogleJsonError();
 GoogleJsonError.ErrorInfo errorInfo = new GoogleJsonError.ErrorInfo();
 errorInfo.setReason("reason");
 errorInfo.setLocation("entity.parameters.changeId");
 error.setCode(404);
 error.setErrors(ImmutableList.of(errorInfo));
 capturedCallback.onFailure(error);
 assertNull(batchResult.get());
}
origin: googleapis/google-cloud-java

@Test
public void testGetZoneNotFound() {
 EasyMock.reset(batchMock);
 Capture<RpcBatch.Callback<ManagedZone>> callback = Capture.newInstance();
 Capture<Map<DnsRpc.Option, Object>> capturedOptions = Capture.newInstance();
 batchMock.addGetZone(
   EasyMock.eq(ZONE_NAME), EasyMock.capture(callback), EasyMock.capture(capturedOptions));
 EasyMock.replay(batchMock);
 DnsBatchResult<Zone> batchResult = dnsBatch.getZone(ZONE_NAME);
 assertEquals(0, capturedOptions.getValue().size());
 GoogleJsonError error = new GoogleJsonError();
 error.setCode(404);
 RpcBatch.Callback<ManagedZone> capturedCallback = callback.getValue();
 capturedCallback.onFailure(error);
 assertNull(batchResult.get());
}
origin: googleapis/google-cloud-java

@Test
public void testDeleteAllArray() {
 BlobId blobId1 = BlobId.of(BUCKET_NAME1, BLOB_NAME1);
 BlobId blobId2 = BlobId.of(BUCKET_NAME1, BLOB_NAME2);
 RpcBatch batchMock = EasyMock.createMock(RpcBatch.class);
 Capture<RpcBatch.Callback<Void>> callback1 = Capture.newInstance();
 Capture<RpcBatch.Callback<Void>> callback2 = Capture.newInstance();
 batchMock.addDelete(
   EasyMock.eq(blobId1.toPb()),
   EasyMock.capture(callback1),
   EasyMock.eq(ImmutableMap.<StorageRpc.Option, Object>of()));
 batchMock.addDelete(
   EasyMock.eq(blobId2.toPb()),
   EasyMock.capture(callback2),
   EasyMock.eq(ImmutableMap.<StorageRpc.Option, Object>of()));
 EasyMock.expect(storageRpcMock.createBatch()).andReturn(batchMock);
 batchMock.submit();
 EasyMock.replay(storageRpcMock, batchMock);
 initializeService();
 List<Boolean> result = storage.delete(blobId1, blobId2);
 callback1.getValue().onSuccess(null);
 callback2.getValue().onFailure(new GoogleJsonError());
 assertEquals(2, result.size());
 assertTrue(result.get(0));
 assertFalse(result.get(1));
 EasyMock.verify(batchMock);
}
origin: pentaho/pentaho-kettle

if ( gjre.getDetails() != null && gjre.getDetails().getMessage() != null ) {
 exceptionToDisplay = new IOException( gjre.getDetails().getMessage(), gjre );
origin: apache/incubator-gobblin

 fileList = request.execute();
} catch (GoogleJsonResponseException e) {
 GoogleJsonError error = e.getDetails();
 if (404 == error.getCode()) {
  throw new FileNotFoundException("File not found. Request: " + request);
origin: googleapis/google-cloud-java

assertEquals(exception, serviceException.getCause());
GoogleJsonError error = new GoogleJsonError();
error.setCode(CODE);
error.setMessage(MESSAGE);
serviceException = new BaseHttpServiceException(error, IDEMPOTENT, EMPTY_RETRYABLE_ERRORS);
assertEquals(CODE, serviceException.getCode());
origin: googleapis/google-cloud-java

GoogleJsonError error = new GoogleJsonError();
error.setCode(404);
capturedCallback.onFailure(error);
try {
origin: googleapis/google-cloud-java

@Test
public void testDeleteAllIterable() {
 BlobId blobId1 = BlobId.of(BUCKET_NAME1, BLOB_NAME1);
 BlobId blobId2 = BlobId.of(BUCKET_NAME1, BLOB_NAME2);
 RpcBatch batchMock = EasyMock.createMock(RpcBatch.class);
 Capture<RpcBatch.Callback<Void>> callback1 = Capture.newInstance();
 Capture<RpcBatch.Callback<Void>> callback2 = Capture.newInstance();
 batchMock.addDelete(
   EasyMock.eq(blobId1.toPb()),
   EasyMock.capture(callback1),
   EasyMock.eq(ImmutableMap.<StorageRpc.Option, Object>of()));
 batchMock.addDelete(
   EasyMock.eq(blobId2.toPb()),
   EasyMock.capture(callback2),
   EasyMock.eq(ImmutableMap.<StorageRpc.Option, Object>of()));
 EasyMock.expect(storageRpcMock.createBatch()).andReturn(batchMock);
 batchMock.submit();
 EasyMock.replay(storageRpcMock, batchMock);
 initializeService();
 List<Boolean> result = storage.delete(blobId1, blobId2);
 callback1.getValue().onSuccess(null);
 callback2.getValue().onFailure(new GoogleJsonError());
 assertEquals(2, result.size());
 assertTrue(result.get(0));
 assertFalse(result.get(1));
 EasyMock.verify(batchMock);
}
origin: googleapis/google-cloud-java

assertSame(cause, exception.getCause());
GoogleJsonError error = new GoogleJsonError();
error.setCode(503);
error.setMessage("message");
exception = new StorageException(error);
assertEquals(503, exception.getCode());
origin: googleapis/google-cloud-java

GoogleJsonError error = new GoogleJsonError();
error.setCode(404);
capturedCallback.onFailure(error);
try {
origin: googleapis/google-cloud-java

@Test
public void testUpdateAllIterable() {
 RpcBatch batchMock = EasyMock.createMock(RpcBatch.class);
 Capture<RpcBatch.Callback<StorageObject>> callback1 = Capture.newInstance();
 Capture<RpcBatch.Callback<StorageObject>> callback2 = Capture.newInstance();
 batchMock.addPatch(
   EasyMock.eq(BLOB_INFO1.toPb()),
   EasyMock.capture(callback1),
   EasyMock.eq(ImmutableMap.<StorageRpc.Option, Object>of()));
 batchMock.addPatch(
   EasyMock.eq(BLOB_INFO2.toPb()),
   EasyMock.capture(callback2),
   EasyMock.eq(ImmutableMap.<StorageRpc.Option, Object>of()));
 EasyMock.expect(storageRpcMock.createBatch()).andReturn(batchMock);
 batchMock.submit();
 EasyMock.replay(storageRpcMock, batchMock);
 initializeService();
 List<Blob> resultBlobs = storage.update(ImmutableList.of(BLOB_INFO1, BLOB_INFO2));
 callback1.getValue().onSuccess(BLOB_INFO1.toPb());
 callback2.getValue().onFailure(new GoogleJsonError());
 assertEquals(2, resultBlobs.size());
 assertEquals(new Blob(storage, new BlobInfo.BuilderImpl(BLOB_INFO1)), resultBlobs.get(0));
 assertNull(resultBlobs.get(1));
 EasyMock.verify(batchMock);
}
origin: googleapis/google-cloud-java

@Test
public void testUpdateAllArray() {
 RpcBatch batchMock = EasyMock.createMock(RpcBatch.class);
 Capture<RpcBatch.Callback<StorageObject>> callback1 = Capture.newInstance();
 Capture<RpcBatch.Callback<StorageObject>> callback2 = Capture.newInstance();
 batchMock.addPatch(
   EasyMock.eq(BLOB_INFO1.toPb()),
   EasyMock.capture(callback1),
   EasyMock.eq(ImmutableMap.<StorageRpc.Option, Object>of()));
 batchMock.addPatch(
   EasyMock.eq(BLOB_INFO2.toPb()),
   EasyMock.capture(callback2),
   EasyMock.eq(ImmutableMap.<StorageRpc.Option, Object>of()));
 EasyMock.expect(storageRpcMock.createBatch()).andReturn(batchMock);
 batchMock.submit();
 EasyMock.replay(storageRpcMock, batchMock);
 initializeService();
 List<Blob> resultBlobs = storage.update(BLOB_INFO1, BLOB_INFO2);
 callback1.getValue().onSuccess(BLOB_INFO1.toPb());
 callback2.getValue().onFailure(new GoogleJsonError());
 assertEquals(2, resultBlobs.size());
 assertEquals(new Blob(storage, new BlobInfo.BuilderImpl(BLOB_INFO1)), resultBlobs.get(0));
 assertNull(resultBlobs.get(1));
 EasyMock.verify(batchMock);
}
origin: googleapis/google-cloud-java

@Test
public void testGetAllArrayIterable() {
 BlobId blobId1 = BlobId.of(BUCKET_NAME1, BLOB_NAME1);
 BlobId blobId2 = BlobId.of(BUCKET_NAME1, BLOB_NAME2);
 RpcBatch batchMock = EasyMock.createMock(RpcBatch.class);
 Capture<RpcBatch.Callback<StorageObject>> callback1 = Capture.newInstance();
 Capture<RpcBatch.Callback<StorageObject>> callback2 = Capture.newInstance();
 batchMock.addGet(
   EasyMock.eq(blobId1.toPb()),
   EasyMock.capture(callback1),
   EasyMock.eq(ImmutableMap.<StorageRpc.Option, Object>of()));
 batchMock.addGet(
   EasyMock.eq(blobId2.toPb()),
   EasyMock.capture(callback2),
   EasyMock.eq(ImmutableMap.<StorageRpc.Option, Object>of()));
 EasyMock.expect(storageRpcMock.createBatch()).andReturn(batchMock);
 batchMock.submit();
 EasyMock.replay(storageRpcMock, batchMock);
 initializeService();
 List<Blob> resultBlobs = storage.get(ImmutableList.of(blobId1, blobId2));
 callback1.getValue().onSuccess(BLOB_INFO1.toPb());
 callback2.getValue().onFailure(new GoogleJsonError());
 assertEquals(2, resultBlobs.size());
 assertEquals(new Blob(storage, new BlobInfo.BuilderImpl(BLOB_INFO1)), resultBlobs.get(0));
 assertNull(resultBlobs.get(1));
 EasyMock.verify(batchMock);
}
origin: googleapis/google-cloud-java

@Test
public void testGetAllArray() {
 BlobId blobId1 = BlobId.of(BUCKET_NAME1, BLOB_NAME1);
 BlobId blobId2 = BlobId.of(BUCKET_NAME1, BLOB_NAME2);
 RpcBatch batchMock = EasyMock.createMock(RpcBatch.class);
 Capture<RpcBatch.Callback<StorageObject>> callback1 = Capture.newInstance();
 Capture<RpcBatch.Callback<StorageObject>> callback2 = Capture.newInstance();
 batchMock.addGet(
   EasyMock.eq(blobId1.toPb()),
   EasyMock.capture(callback1),
   EasyMock.eq(ImmutableMap.<StorageRpc.Option, Object>of()));
 batchMock.addGet(
   EasyMock.eq(blobId2.toPb()),
   EasyMock.capture(callback2),
   EasyMock.eq(ImmutableMap.<StorageRpc.Option, Object>of()));
 EasyMock.expect(storageRpcMock.createBatch()).andReturn(batchMock);
 batchMock.submit();
 EasyMock.replay(storageRpcMock, batchMock);
 initializeService();
 List<Blob> resultBlobs = storage.get(blobId1, blobId2);
 callback1.getValue().onSuccess(BLOB_INFO1.toPb());
 callback2.getValue().onFailure(new GoogleJsonError());
 assertEquals(2, resultBlobs.size());
 assertEquals(new Blob(storage, new BlobInfo.BuilderImpl(BLOB_INFO1)), resultBlobs.get(0));
 assertNull(resultBlobs.get(1));
 EasyMock.verify(batchMock);
}
com.google.api.client.googleapis.json

Most used classes

  • GoogleJsonResponseException
    Exception thrown when an error status code is detected in an HTTP response to a Google API that uses
  • GoogleJsonError
    Data class representing the Google JSON error response content, as documented for example in Error M
  • GoogleJsonError$ErrorInfo
    Detailed error information.
  • GoogleJsonErrorContainer
    Data class representing a container of GoogleJsonError.
  • AbstractJsonFeedParser$StopAtItems
  • DiscoveryDocument$APIDefinition,
  • DiscoveryDocument$ServiceDefinition,
  • DiscoveryDocument,
  • GoogleApi,
  • GoogleJsonRpcHttpTransport,
  • JsonCParser,
  • JsonFeedParser,
  • JsonMultiKindFeedParser
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now