public abstract class AbstractCommand extends Object implements CouchCommand
| Modifier and Type | Field and Description |
|---|---|
protected String |
body |
protected CommandHandler |
commandHandler |
protected HandleableException |
handlerException |
protected HttpMethod |
method |
protected String |
url |
HTTP_ACCEPTED, HTTP_BAD_REQUEST, HTTP_CREATED, HTTP_EXPECTATION_FAILED, HTTP_NO_CONTENT, HTTP_NOT_FOUND, HTTP_NOT_MODIFIED, HTTP_OK, HTTP_RESET_CONTENT| Constructor and Description |
|---|
AbstractCommand() |
AbstractCommand(String url) |
AbstractCommand(String url,
String body) |
| Modifier and Type | Method and Description |
|---|---|
HttpMethod |
asDelete() |
HttpMethod |
asGet() |
HttpMethod |
asHead() |
HttpMethod |
asPost() |
HttpMethod |
asPut() |
protected String |
errorFormat(org.apache.http.client.methods.HttpRequestBase http,
org.apache.http.StatusLine statusLine,
String json) |
protected String |
getContentEncode(org.apache.http.client.methods.HttpRequestBase http) |
protected String |
getContentType(org.apache.http.client.methods.HttpRequestBase http) |
protected org.apache.http.HttpEntity |
getEntity() |
protected String |
getRevision(Queryable queryable) |
protected void |
injectAutoIdentity(ObjectProxy<?> proxy,
Object param,
String id,
String rev,
String properName,
PropertyAccess accessId,
PropertyAccess accessRev) |
protected void |
injectIdentity(ObjectProxy<?> proxy,
Object param,
String id,
String rev,
PropertyAccess accessId,
PropertyAccess accessRev) |
protected boolean |
isAccepted(int statusCode)
202 Accepted
|
protected boolean |
isCreated(int statusCode)
201 Created
|
protected boolean |
isExpectationFailed(int statusCode)
417 Expectation Faile
|
protected boolean |
isNotFound(int statusCode)
Verify if http status represents a record not found
|
protected boolean |
isOk(int statusCode) |
protected void |
printRequest(org.apache.http.client.methods.HttpRequestBase req) |
protected void |
printResponse(org.apache.http.client.methods.CloseableHttpResponse resp,
String json) |
protected void |
setBookmark(String bookmark,
Queryable queryable) |
Command |
with(CommandHandler commandHandler)
Configure the life-cycle of command
|
Command |
with(HandleableException handlerException)
Configure the handler exception for the command
|
<T> Command |
with(T stmt)
The statement to run this command
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetBodyprotected HandleableException handlerException
protected CommandHandler commandHandler
protected HttpMethod method
public AbstractCommand()
public AbstractCommand(String url)
public AbstractCommand(String url, String body)
public <T> Command with(T stmt)
Commandwith in interface CommandT - Type responsible to execute the statement into database.
For example: Statement for JDBC or Cassandra, EntityManager for JPA,
bucket for Couchbase etcstmt - a statement implementation to run the command.public Command with(HandleableException handlerException)
Commandpublic Command with(CommandHandler commandHandler)
Commandprotected org.apache.http.HttpEntity getEntity()
protected String getContentType(org.apache.http.client.methods.HttpRequestBase http)
protected String getContentEncode(org.apache.http.client.methods.HttpRequestBase http)
protected String errorFormat(org.apache.http.client.methods.HttpRequestBase http, org.apache.http.StatusLine statusLine, String json)
public HttpMethod asPut()
asPut in interface CouchCommandpublic HttpMethod asPost()
asPost in interface CouchCommandpublic HttpMethod asDelete()
asDelete in interface CouchCommandpublic HttpMethod asGet()
asGet in interface CouchCommandpublic HttpMethod asHead()
asHead in interface CouchCommandprotected boolean isNotFound(int statusCode)
statusCode - HTTP status codetrue when the resource it's not found, false otherwise.protected boolean isOk(int statusCode)
protected boolean isCreated(int statusCode)
The request has been fulfilled and resulted in a new resource being created. The newly created resource can be referenced by the URI(s) returned in the entity of the response, with the most specific URI for the resource given by a Location header field. The response SHOULD include an entity containing a list of resource characteristics and location(s) from which the user or user agent can choose the one most appropriate. The entity format is specified by the media type given in the Content-Type header field. The origin server MUST create the resource before returning the 201 status code. If the action cannot be carried out immediately, the server SHOULD respond with 202 (Accepted) response instead.
statusCode - HTTP status codetrue when is 202 code, false otherwiseprotected boolean isAccepted(int statusCode)
The request has been accepted for processing, but the processing has not been completed. The request might or might not eventually be acted upon, as it might be disallowed when processing actually takes place. There is no facility for re-sending a status code from an asynchronous operation such as this.
The 202 response is intentionally non-committal. Its purpose is to allow a server to accept a request for some other process (perhaps a batch-oriented process that is only run once per day) without requiring that the user agent's connection to the server persist until the process is completed. The entity returned with this response SHOULD include an indication of the request's current status and either a pointer to a status monitor or some estimate of when the user can expect the request to be fulfilled.
statusCode - HTTP status codetrue when is 202 code, false otherwiseprotected boolean isExpectationFailed(int statusCode)
The expectation given in an Expect request-header field (see section 14.20) could not be met by this server, or, if the server is a proxy, the server has unambiguous evidence that the request could not be met by the next-hop server.
statusCode - HTTP status codetrue when is 202 code, false otherwiseprotected String getRevision(Queryable queryable)
protected void injectIdentity(ObjectProxy<?> proxy, Object param, String id, String rev, PropertyAccess accessId, PropertyAccess accessRev)
protected void injectAutoIdentity(ObjectProxy<?> proxy, Object param, String id, String rev, String properName, PropertyAccess accessId, PropertyAccess accessRev)
protected void setBookmark(String bookmark, Queryable queryable)
protected void printRequest(org.apache.http.client.methods.HttpRequestBase req)
protected void printResponse(org.apache.http.client.methods.CloseableHttpResponse resp, String json)
Copyright © 2012–2020 jkniv, copyleft code. All rights reserved.