Tabnine Logo
EmoResponse.getEntity
Code IndexAdd Tabnine to your IDE (free)

How to use
getEntity
method
in
com.bazaarvoice.emodb.client.EmoResponse

Best Java code snippets using com.bazaarvoice.emodb.client.EmoResponse.getEntity (Showing top 10 results out of 315)

origin: bazaarvoice/emodb

private EmoApiKey getApiKeyFromResponse(EmoResponse response) {
  if (response.getStatus() == Response.Status.OK.getStatusCode()) {
    return response.getEntity(EmoApiKey.class);
  } else if (response.getStatus() == Response.Status.NOT_FOUND.getStatusCode()) {
    return null;
  }
  throw convertException(new EmoClientException(response));
}
origin: bazaarvoice/emodb

protected RuntimeException convertException(EmoClientException e) {
  EmoResponse response = e.getResponse();
  String exceptionType = response.getFirstHeader("X-BV-Exception");
  if (response.getStatus() == Response.Status.BAD_REQUEST.getStatusCode() &&
      IllegalArgumentException.class.getName().equals(exceptionType)) {
    return new IllegalArgumentException(response.getEntity(String.class), e);
  } else if (response.getStatus() == Response.Status.NOT_FOUND.getStatusCode() &&
      UnknownMoveException.class.getName().equals(exceptionType)) {
    return response.getEntity(UnknownMoveException.class);
  } else if (response.getStatus() == Response.Status.FORBIDDEN.getStatusCode() &&
      UnauthorizedException.class.getName().equals(exceptionType)) {
    if (response.hasEntity()) {
      return (RuntimeException) response.getEntity(UnauthorizedException.class).initCause(e);
    } else {
      return (RuntimeException) new UnauthorizedException().initCause(e);
    }
  } else if (response.getStatus() == Response.Status.SERVICE_UNAVAILABLE.getStatusCode() &&
      ServiceUnavailableException.class.getName().equals(exceptionType)) {
    if (response.hasEntity()) {
      return (RuntimeException) response.getEntity(ServiceUnavailableException.class).initCause(e);
    } else {
      return (RuntimeException) new ServiceUnavailableException().initCause(e);
    }
  }
  return e;
}
origin: bazaarvoice/emodb

  return new IllegalArgumentException(response.getEntity(String.class), e);
    return (RuntimeException) response.getEntity(UnknownSubscriptionException.class).initCause(e);
  } else {
    return (RuntimeException) new UnknownSubscriptionException().initCause(e);
  return response.getEntity(UnknownMoveException.class);
} else if (response.getStatus() == Response.Status.NOT_FOUND.getStatusCode() &&
    UnknownReplayException.class.getName().equals(exceptionType)) {
  return response.getEntity(UnknownReplayException.class);
} else if (response.getStatus() == Response.Status.FORBIDDEN.getStatusCode() &&
    UnauthorizedSubscriptionException.class.getName().equals(exceptionType)) {
  if (response.hasEntity()) {
    return (RuntimeException) response.getEntity(UnauthorizedSubscriptionException.class).initCause(e);
  } else {
    return (RuntimeException) new UnauthorizedSubscriptionException().initCause(e);
    UnauthorizedException.class.getName().equals(exceptionType)) {
  if (response.hasEntity()) {
    return (RuntimeException) response.getEntity(UnauthorizedException.class).initCause(e);
  } else {
    return (RuntimeException) new UnauthorizedException().initCause(e);
    ServiceUnavailableException.class.getName().equals(exceptionType)) {
  if (response.hasEntity()) {
    return (RuntimeException) response.getEntity(ServiceUnavailableException.class).initCause(e);
  } else {
    return (RuntimeException) new ServiceUnavailableException().initCause(e);
origin: bazaarvoice/emodb

  return new IllegalArgumentException(response.getEntity(String.class), e);
} else if (JsonStreamProcessingException.class.getName().equals(exceptionType)) {
  return new JsonStreamProcessingException(response.getEntity(String.class));
} else if (DeltaSizeLimitException.class.getName().equals(exceptionType)) {
  return response.getEntity(DeltaSizeLimitException.class);
} else if (AuditSizeLimitException.class.getName().equals(exceptionType)) {
  return response.getEntity(AuditSizeLimitException.class);
  TableExistsException.class.getName().equals(exceptionType)) {
if (response.hasEntity()) {
  return (RuntimeException) response.getEntity(TableExistsException.class).initCause(e);
} else {
  return (RuntimeException) new TableExistsException().initCause(e);
  UnknownTableException.class.getName().equals(exceptionType)) {
if (response.hasEntity()) {
  return (RuntimeException) response.getEntity(UnknownTableException.class).initCause(e);
} else {
  return (RuntimeException) new UnknownTableException().initCause(e);
  UnknownPlacementException.class.getName().equals(exceptionType)) {
if (response.hasEntity()) {
  return (RuntimeException) response.getEntity(UnknownPlacementException.class).initCause(e);
} else {
  return (RuntimeException) new UnknownPlacementException().initCause(e);
  StashNotAvailableException.class.getName().equals(exceptionType)) {
if (response.hasEntity()) {
  return (RuntimeException) response.getEntity(StashNotAvailableException.class).initCause(e);
origin: com.bazaarvoice.emodb/emodb-sor-client-common

  return new IllegalArgumentException(response.getEntity(String.class), e);
} else if (JsonStreamProcessingException.class.getName().equals(exceptionType)) {
  return new JsonStreamProcessingException(response.getEntity(String.class));
} else if (DeltaSizeLimitException.class.getName().equals(exceptionType)) {
  return response.getEntity(DeltaSizeLimitException.class);
} else if (AuditSizeLimitException.class.getName().equals(exceptionType)) {
  return response.getEntity(AuditSizeLimitException.class);
  TableExistsException.class.getName().equals(exceptionType)) {
if (response.hasEntity()) {
  return (RuntimeException) response.getEntity(TableExistsException.class).initCause(e);
} else {
  return (RuntimeException) new TableExistsException().initCause(e);
  UnknownTableException.class.getName().equals(exceptionType)) {
if (response.hasEntity()) {
  return (RuntimeException) response.getEntity(UnknownTableException.class).initCause(e);
} else {
  return (RuntimeException) new UnknownTableException().initCause(e);
  UnknownPlacementException.class.getName().equals(exceptionType)) {
if (response.hasEntity()) {
  return (RuntimeException) response.getEntity(UnknownPlacementException.class).initCause(e);
} else {
  return (RuntimeException) new UnknownPlacementException().initCause(e);
  StashNotAvailableException.class.getName().equals(exceptionType)) {
if (response.hasEntity()) {
  return (RuntimeException) response.getEntity(StashNotAvailableException.class).initCause(e);
origin: bazaarvoice/emodb

return new IllegalArgumentException(response.getEntity(String.class), e);
  return (RuntimeException) response.getEntity(TableExistsException.class).initCause(e);
} else {
  return (RuntimeException) new TableExistsException().initCause(e);
  UnknownTableException.class.getName().equals(exceptionType)) {
if (response.hasEntity()) {
  return (RuntimeException) response.getEntity(UnknownTableException.class).initCause(e);
} else {
  return (RuntimeException) new UnknownTableException().initCause(e);
  BlobNotFoundException.class.getName().equals(exceptionType)) {
if (response.hasEntity()) {
  return (RuntimeException) response.getEntity(BlobNotFoundException.class).initCause(e);
} else {
  return (RuntimeException) new BlobNotFoundException().initCause(e);
  UnknownPlacementException.class.getName().equals(exceptionType)) {
if (response.hasEntity()) {
  return (RuntimeException) response.getEntity(UnknownPlacementException.class).initCause(e);
} else {
  return (RuntimeException) new UnknownPlacementException().initCause(e);
  RangeNotSatisfiableException.class.getName().equals(exceptionType)) {
if (response.hasEntity()) {
  return (RuntimeException) response.getEntity(RangeNotSatisfiableException.class).initCause(e);
} else {
  return (RuntimeException) new RangeNotSatisfiableException(null, -1, -1).initCause(e);
origin: com.bazaarvoice.emodb/emodb-blob-client-common

return new IllegalArgumentException(response.getEntity(String.class), e);
  return (RuntimeException) response.getEntity(TableExistsException.class).initCause(e);
} else {
  return (RuntimeException) new TableExistsException().initCause(e);
  UnknownTableException.class.getName().equals(exceptionType)) {
if (response.hasEntity()) {
  return (RuntimeException) response.getEntity(UnknownTableException.class).initCause(e);
} else {
  return (RuntimeException) new UnknownTableException().initCause(e);
  BlobNotFoundException.class.getName().equals(exceptionType)) {
if (response.hasEntity()) {
  return (RuntimeException) response.getEntity(BlobNotFoundException.class).initCause(e);
} else {
  return (RuntimeException) new BlobNotFoundException().initCause(e);
  UnknownPlacementException.class.getName().equals(exceptionType)) {
if (response.hasEntity()) {
  return (RuntimeException) response.getEntity(UnknownPlacementException.class).initCause(e);
} else {
  return (RuntimeException) new UnknownPlacementException().initCause(e);
  RangeNotSatisfiableException.class.getName().equals(exceptionType)) {
if (response.hasEntity()) {
  return (RuntimeException) response.getEntity(RangeNotSatisfiableException.class).initCause(e);
} else {
  return (RuntimeException) new RangeNotSatisfiableException(null, -1, -1).initCause(e);
origin: bazaarvoice/emodb

if (InvalidEmoPermissionException.class.getName().equals(exceptionType)) {
  if (response.hasEntity()) {
    return (RuntimeException) response.getEntity(InvalidEmoPermissionException.class).initCause(e);
  } else {
    return (RuntimeException) new InvalidEmoPermissionException().initCause(e);
  return new IllegalArgumentException(response.getEntity(String.class), e);
} else if (JsonStreamProcessingException.class.getName().equals(exceptionType)) {
  return new JsonStreamProcessingException(response.getEntity(String.class));
if (EmoApiKeyExistsException.class.getName().equals(exceptionType)) {
  if (response.hasEntity()) {
    return (RuntimeException) response.getEntity(EmoApiKeyExistsException.class).initCause(e);
  } else {
    return (RuntimeException) new EmoApiKeyExistsException().initCause(e);
    return (RuntimeException) response.getEntity(EmoRoleExistsException.class).initCause(e);
  } else {
    return (RuntimeException) new EmoRoleExistsException().initCause(e);
if (EmoApiKeyNotFoundException.class.getName().equals(exceptionType)) {
  if (response.hasEntity()) {
    return (RuntimeException) response.getEntity(EmoApiKeyNotFoundException.class).initCause(e);
  } else {
    return (RuntimeException) new EmoApiKeyNotFoundException().initCause(e);
    return (RuntimeException) response.getEntity(EmoRoleNotFoundException.class).initCause(e);
  } else {
    return (RuntimeException) new EmoRoleNotFoundException().initCause(e);
origin: bazaarvoice/emodb

@Override
public PollResult poll(String apiKey, @PartitionKey String subscription, Duration claimTtl, int limit) {
  checkNotNull(subscription, "subscription");
  checkNotNull(claimTtl, "claimTtl");
  URI uri = getPollUriBuilder(subscription, claimTtl, limit).build();
  EmoResponse response = _client.resource(uri)
      .queryParam("includeTags", "true")
      .accept(MediaType.APPLICATION_JSON_TYPE)
      .header(ApiKeyRequest.AUTHENTICATION_HEADER, apiKey)
      .get(EmoResponse.class);
  if (response.getStatus() != Response.Status.OK.getStatusCode()) {
    throw convertException(new EmoClientException(response));
  }
  Iterator<Event> events = response.getEntity(new TypeReference<Iterator<Event>>() {});
  boolean moreEvents;
  String databusEmpty = response.getFirstHeader(POLL_DATABUS_EMPTY_HEADER);
  if (databusEmpty != null) {
    // Use the header value from the server to determine if the databus subscription is empty
    moreEvents = !Boolean.parseBoolean(databusEmpty);
  } else {
    // Must be polling an older version of Emo which did not include this header.  Infer whether the queue
    // is empty based on whether any results were returned.
    moreEvents = events.hasNext();
  }
  return new PollResult(events, limit, moreEvents);
}
origin: bazaarvoice/emodb

@Override
public EmoRole getRole(String apiKey, EmoRoleKey roleKey) {
  checkNotNull(roleKey, "roleKey");
  URI uri = _uac.clone()
      .segment("role")
      .segment(roleKey.getGroup())
      .segment(roleKey.getId())
      .build();
  EmoResponse response = _client.resource(uri)
      .accept(MediaType.APPLICATION_JSON_TYPE)
      .header(ApiKeyRequest.AUTHENTICATION_HEADER, apiKey)
      .get(EmoResponse.class);
  if (response.getStatus() == Response.Status.OK.getStatusCode()) {
    return response.getEntity(EmoRole.class);
  } else if (response.getStatus() == Response.Status.NOT_FOUND.getStatusCode()) {
    return null;
  }
  throw convertException(new EmoClientException(response));
}
com.bazaarvoice.emodb.clientEmoResponsegetEntity

Javadoc

Returns the response entity transformed to the given type reference.

Popular methods of EmoResponse

  • getFirstHeader
  • getStatus
  • hasEntity
  • getLocation
  • getEntityInputStream
  • getHeaders
  • getLastModified

Popular in Java

  • Making http post requests using okhttp
  • notifyDataSetChanged (ArrayAdapter)
  • compareTo (BigDecimal)
  • getSharedPreferences (Context)
  • URLEncoder (java.net)
    This class is used to encode a string using the format required by application/x-www-form-urlencoded
  • Enumeration (java.util)
    A legacy iteration interface.New code should use Iterator instead. Iterator replaces the enumeration
  • LinkedList (java.util)
    Doubly-linked list implementation of the List and Dequeinterfaces. Implements all optional list oper
  • JFileChooser (javax.swing)
  • FileUtils (org.apache.commons.io)
    General file manipulation utilities. Facilities are provided in the following areas: * writing to a
  • Reflections (org.reflections)
    Reflections one-stop-shop objectReflections scans your classpath, indexes the metadata, allows you t
  • Top plugins for Android Studio
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