Tabnine Logo
GoogleJsonError.getCode
Code IndexAdd Tabnine to your IDE (free)

How to use
getCode
method
in
com.google.api.client.googleapis.json.GoogleJsonError

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

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: apache/incubator-gobblin

} catch (GoogleJsonResponseException e) {
 GoogleJsonError error = e.getDetails();
 if (404 == error.getCode()) {
  throw new FileNotFoundException("File not found. Request: " + request);
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

if (jsonError != null) {
 BaseServiceException.Error error =
   new BaseServiceException.Error(jsonError.getCode(), reason(jsonError));
 code = error.getCode();
 reason = error.getReason();
origin: google/google-api-java-client-samples

public static Bucket createInProject(Storage storage, String project, Bucket bucket)
  throws IOException {
 try {
  Storage.Buckets.Insert insertBucket = storage.buckets().insert(project, bucket);
  return insertBucket.execute();
 } catch (GoogleJsonResponseException e) {
  GoogleJsonError error = e.getDetails();
  if (error != null && error.getCode() == HTTP_CONFLICT
    && error.getMessage().contains("You already own this bucket.")) {
   System.out.println("already exists");
   return bucket;
  }
  System.err.println(error.getMessage());
  throw e;
 }
}

origin: google/google-api-java-client-samples

/**
 * Main demo. An Analytics service object is instantiated and then it is used to traverse and
 * print all the Management API entities. If any exceptions occur, they are caught and printed.
 *
 * @param args command line args.
 */
public static void main(String args[]) {
 try {
  HTTP_TRANSPORT = GoogleNetHttpTransport.newTrustedTransport();
  DATA_STORE_FACTORY = new FileDataStoreFactory(DATA_STORE_DIR);
  Analytics analytics = initializeAnalytics();
  printManagementEntities(analytics);
 } catch (GoogleJsonResponseException e) {
  System.err.println("There was a service error: " + e.getDetails().getCode() + " : "
    + e.getDetails().getMessage());
 } catch (Throwable t) {
  t.printStackTrace();
 }
}
origin: google/google-api-java-client-samples

/**
 * Main demo. This first initializes an analytics service object. It then uses the Google
 * Analytics Management API to get the first profile ID for the authorized user. It then uses the
 * Core Reporting API to retrieve the top 25 organic search terms. Finally the results are printed
 * to the screen. If an API error occurs, it is printed here.
 *
 * @param args command line args.
 */
public static void main(String[] args) {
 try {
  httpTransport = GoogleNetHttpTransport.newTrustedTransport();
  dataStoreFactory = new FileDataStoreFactory(DATA_STORE_DIR);
  Analytics analytics = initializeAnalytics();
  String profileId = getFirstProfileId(analytics);
  if (profileId == null) {
   System.err.println("No profiles found.");
  } else {
   GaData gaData = executeDataQuery(analytics, profileId);
   printGaData(gaData);
  }
 } catch (GoogleJsonResponseException e) {
  System.err.println("There was a service error: " + e.getDetails().getCode() + " : "
    + e.getDetails().getMessage());
 } catch (Throwable t) {
  t.printStackTrace();
 }
}
origin: google/google-api-java-client-samples

/**
 * Main demo. This first initializes an analytics service object. It then uses the MCF API to
 * retrieve the top 25 source paths with most total conversions. It will also retrieve the top 25
 * organic sources with most total conversions. Finally the results are printed to the screen. If
 * an API error occurs, it is printed here.
 *
 * @param args command line args.
 */
public static void main(String[] args) {
 try {
  HTTP_TRANSPORT = GoogleNetHttpTransport.newTrustedTransport();
  DATA_STORE_FACTORY = new FileDataStoreFactory(DATA_STORE_DIR);
  Analytics analytics = initializeAnalytics();
  McfData mcfPathData = executePathQuery(analytics, TABLE_ID);
  printAllInfo(mcfPathData);
  McfData mcfInteractionData = executeInteractionQuery(analytics, TABLE_ID);
  printAllInfo(mcfInteractionData);
 } catch (GoogleJsonResponseException e) {
  System.err.println("There was a service error: " + e.getDetails().getCode() + " : "
    + e.getDetails().getMessage());
 } catch (Throwable t) {
  t.printStackTrace();
 }
}
origin: com.google.cloud.bigdataoss/util

/**
 * Determines if the given GoogleJsonError indicates 'item not found'.
 */
public boolean itemNotFound(GoogleJsonError e) {
 return e.getCode() == HttpStatusCodes.STATUS_CODE_NOT_FOUND;
}
origin: com.google.cloud.bigdataoss/util

/**
 * Determines if the given GoogleJsonError indicates 'precondition not met'
 */
public boolean preconditionNotMet(GoogleJsonError e) {
 return e.getCode() == STATUS_CODE_PRECONDITION_FAILED;
}
origin: GoogleCloudPlatform/bigdata-interop

/**
 * Determines if the given GoogleJsonError indicates 'item not found'.
 */
public boolean itemNotFound(GoogleJsonError e) {
 return e.getCode() == HttpStatusCodes.STATUS_CODE_NOT_FOUND;
}
origin: google/google-api-java-client-samples

/**
 * Main demo. This first initializes an Analytics service object. It then queries for the top 25
 * organic search keywords and traffic sources by visits. Finally each important part of the
 * response is printed to the screen.
 *
 * @param args command line args.
 */
public static void main(String[] args) {
 try {
  HTTP_TRANSPORT = GoogleNetHttpTransport.newTrustedTransport();
  DATA_STORE_FACTORY = new FileDataStoreFactory(DATA_STORE_DIR);
  Analytics analytics = initializeAnalytics();
  GaData gaData = executeDataQuery(analytics, TABLE_ID);
  printReportInfo(gaData);
  printProfileInfo(gaData);
  printQueryInfo(gaData);
  printPaginationInfo(gaData);
  printTotalsForAllResults(gaData);
  printColumnHeaders(gaData);
  printDataTable(gaData);
 } catch (GoogleJsonResponseException e) {
  System.err.println("There was a service error: " + e.getDetails().getCode() + " : "
    + e.getDetails().getMessage());
 } catch (Throwable t) {
  t.printStackTrace();
 }
}
origin: org.apache.beam/beam-sdks-java-extensions-google-cloud-platform-core

 @Override
 public void onFailure(GoogleJsonError e, HttpHeaders responseHeaders) throws IOException {
  if (e.getCode() == 404) {
   LOG.info(
     "Ignoring failed deletion of file {} which already does not exist: {}", file, e);
  } else {
   throw new IOException(String.format("Error trying to delete %s: %s", file, e));
  }
 }
});
origin: GoogleCloudPlatform/bigdata-interop

/** Determines if the given GoogleJsonError indicates that 'userProject' is missing in request */
public boolean userProjectMissing(GoogleJsonError e) {
 ErrorInfo errorInfo = getErrorInfo(e);
 return errorInfo != null
   && e.getCode() == STATUS_CODE_BAD_REQUEST
   && USER_PROJECT_MISSING.equals(errorInfo.getMessage());
}
origin: com.google.cloud.bigdataoss/util

/** Determines if the given GoogleJsonError indicates that 'userProject' is missing in request */
public boolean userProjectMissing(GoogleJsonError e) {
 ErrorInfo errorInfo = getErrorInfo(e);
 return errorInfo != null
   && e.getCode() == STATUS_CODE_BAD_REQUEST
   && USER_PROJECT_MISSING.equals(errorInfo.getMessage());
}
origin: google/mail-importer

@Override
public void onFailure(
  GoogleJsonError e, HttpHeaders responseHeaders)
  throws IOException {
 System.err.format("For message: %s, got error: %s\n",
   message.getId(), e.toPrettyString());
 if (e.getCode() == TOO_MANY_CONCURRENT_REQUESTS_FOR_USER) {
  request.queue(batches.nextBatch, this);
 }
}
origin: com.google.gcloud/gcloud-java-storage

 @Override
 public void onFailure(GoogleJsonError e, HttpHeaders responseHeaders) {
  if (e.getCode() == HTTP_NOT_FOUND) {
   deletes.put(tuple.x(), Tuple.<Boolean, StorageException>of(Boolean.FALSE, null));
  } else {
   deletes.put(tuple.x(), Tuple.<Boolean, StorageException>of(null, translate(e)));
  }
 }
});
origin: iterate-ch/cyberduck

@Override
public void onFailure(final GoogleJsonError e, final HttpHeaders responseHeaders) {
  log.warn(String.format("Failure deleting %s. %s", file, e.getMessage()));
  failures.add(new HttpResponseExceptionMappingService().map(
    new HttpResponseException(e.getCode(), e.getMessage())));
}
origin: com.google.gcloud/gcloud-java-storage

 @Override
 public void onFailure(GoogleJsonError e, HttpHeaders responseHeaders) {
  if (e.getCode() == HTTP_NOT_FOUND) {
   gets.put(tuple.x(),
     Tuple.<StorageObject, StorageException>of(null, null));
  } else {
   gets.put(tuple.x(),
     Tuple.<StorageObject, StorageException>of(null, translate(e)));
  }
 }
});
origin: com.mulesoft.google/google-api-commons

public BatchResponse<T> addError(GoogleJsonError error) {
  this.errors.addAll(error.getErrors());
  this.resultBuilder.addItem(BulkItem.<T>builder()
      .setSuccessful(false)
      .setStatusCode(String.valueOf(error.getCode()))
      .setMessage(error.getMessage())
  );
  
  return this;
}
com.google.api.client.googleapis.jsonGoogleJsonErrorgetCode

Javadoc

Returns the HTTP status code of this response or null for none.

Popular methods of GoogleJsonError

  • getMessage
    Returns the human-readable explanation of the error or null for none.
  • <init>
  • getErrors
    Returns the list of detailed errors or null for none.
  • setCode
    Sets the HTTP status code of this response or null for none.
  • setMessage
    Sets the human-readable explanation of the error or null for none.
  • setErrors
    Sets the list of detailed errors or null for none.
  • toPrettyString
  • get
  • setFactory
  • toString

Popular in Java

  • Finding current android device location
  • setScale (BigDecimal)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • getContentResolver (Context)
  • RandomAccessFile (java.io)
    Allows reading from and writing to a file in a random-access manner. This is different from the uni-
  • HttpURLConnection (java.net)
    An URLConnection for HTTP (RFC 2616 [http://tools.ietf.org/html/rfc2616]) used to send and receive d
  • KeyStore (java.security)
    KeyStore is responsible for maintaining cryptographic keys and their owners. The type of the syste
  • GregorianCalendar (java.util)
    GregorianCalendar is a concrete subclass of Calendarand provides the standard calendar used by most
  • Map (java.util)
    A Map is a data structure consisting of a set of keys and values in which each key is mapped to a si
  • ImageIO (javax.imageio)
  • Best plugins for Eclipse
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