|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.vodafone360.people.service.io.Request
public class Request
Container class for Requests issued from client to People server via the transport layer. A request consists of a payload, an identifier for the engine responsible for handling this request, a request type and a request id which is generated on creation of the request.
Nested Class Summary | |
---|---|
static class |
Request.Type
Request types, these are based on the content requested from, or delivered to, the server, and whether the returned response contains a type identifier or not. |
Field Summary | |
---|---|
boolean |
expired
true if the request has expired |
private java.lang.String |
mApiMethodName
Name of method on the backend. |
private byte |
mAuthenticationType
Represents the authentication type that needs to be taken into account when executing this specific request. |
private long |
mAuthTimestamp
The timestamp when the request's auth was calculated. |
private long |
mCreationTimestamp
The timestamp when this request was created. |
EngineManager.EngineId |
mEngineId
Handle of Engine associated with this RPG message. |
private long |
mExpiryDate
The expiry date calculated when the request gets executed. |
private boolean |
mIsActive
active flag - set to true once we have actually issued a request |
private boolean |
mIsFireAndForget
If true, this method is a fire and forget method and will not expect any responses to come in. |
private java.util.Hashtable<java.lang.String,java.lang.Object> |
mParameters
|
private int |
mRequestId
RPG message request id. |
private long |
mTimeout
The timeout set for the request. -1 if not set. |
Request.Type |
mType
RPG Message type - as defined above. |
static byte |
USE_API
|
static byte |
USE_BOTH
|
static byte |
USE_RPG
|
Constructor Summary | |
---|---|
Request(java.lang.String apiMethodName,
Request.Type type,
EngineManager.EngineId engineId,
boolean isFireAndForget,
long timeout)
Constructor used for constructing internal (RPG/API) requests. |
|
Request(java.lang.String externalUrl,
java.lang.String urlParams,
EngineManager.EngineId engineId)
Constructor used for constructing an external request used for fetching e.g. images. |
Method Summary | |
---|---|
void |
addData(java.lang.String varName,
java.lang.Boolean value)
Create new NameValue and adds it to list of params |
void |
addData(java.lang.String varName,
byte[] value)
Adds byte array to parameter list |
void |
addData(java.lang.String name,
java.util.Hashtable<java.lang.String,?> nv)
Adds element to list of params |
void |
addData(java.lang.String varName,
java.lang.Integer value)
Create new NameValue and adds it to list of params |
void |
addData(java.lang.String name,
java.util.List<java.lang.String> value)
Adds element to list of params |
void |
addData(java.lang.String varName,
java.lang.Long value)
Create new NameValue and adds it to list of params |
void |
addData(java.lang.String varName,
java.lang.String value)
Create new NameValue and adds it to list of params |
void |
addData(java.lang.String name,
java.util.Vector<java.lang.Object> value)
Adds element to list of params |
private void |
calculateAuth()
Calculate the Auth value for this Requester. |
void |
calculateExpiryDate()
Calculates the expiry date based on the timeout. |
java.lang.String |
getApiMethodName()
Returns the API call this request will use. |
java.lang.String |
getAuth()
Gets the auth of this request. |
byte |
getAuthenticationType()
Returns the authentication type of this request. |
long |
getAuthTimestamp()
Gets the time stamp when this request's hash was calculated. |
long |
getCreationTimestamp()
Gets the time stamp when this request was created. |
long |
getExpiryDate()
Gets the calculated expiry date. |
int |
getRequestId()
Gets the request ID of this request. |
long |
getTimeout()
Gets the set timeout. |
boolean |
isActive()
Is request active - i.e has it been issued |
boolean |
isFireAndForget()
Returns true if the method is a fire and forget method. |
private byte[] |
makeBody()
Creates the body of the request using the parameter list. |
void |
setActive(boolean isActive)
Sets whether this request is active or not. |
void |
setRequestId(int requestId)
Sets the request ID for this request. |
java.lang.String |
toString()
Returns a description of the contents of this object |
void |
writeToOutputStream(java.io.OutputStream os,
boolean writeRpgHeader)
Serializes the request's data structure to the passed output stream enabling the connection to easily prepare one or multiple) requests. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private java.util.Hashtable<java.lang.String,java.lang.Object> mParameters
private java.lang.String mApiMethodName
public Request.Type mType
public EngineManager.EngineId mEngineId
private boolean mIsActive
private long mTimeout
private long mExpiryDate
public boolean expired
private long mAuthTimestamp
private long mCreationTimestamp
private byte mAuthenticationType
Represents the authentication type that needs to be taken into account when executing this specific request. There are 3 types of authentication types:
public static final byte USE_API
public static final byte USE_RPG
public static final byte USE_BOTH
private boolean mIsFireAndForget
private int mRequestId
Constructor Detail |
---|
public Request(java.lang.String apiMethodName, Request.Type type, EngineManager.EngineId engineId, boolean isFireAndForget, long timeout)
apiMethodName
- The method name of the call, e.g.
"identities/getavailableidentities".type
- RPG message type.engId
- The engine ID. Will be used for routing the response to this
request back to the engine that can process it.needsUserAuthentication
- If true we need to authenticate this
request by providing the session in the auth. This requires
the user to be logged in.isFireAndForget
- True if the request is a fire and forget request.timeout
- the timeout in milliseconds before the request throws a
timeout exceptionpublic Request(java.lang.String externalUrl, java.lang.String urlParams, EngineManager.EngineId engineId)
externalUrl
- The external URL of the object to fetch.urlParams
- THe parameters to add to the URL of this request.engineId
- The ID of the engine that will be called back once the
response for this request comes in.Method Detail |
---|
public boolean isActive()
public void setActive(boolean isActive)
Sets whether this request is active or not. An active request is a request that is currently being sent to the server and awaiting a response.
The reason is that an active request should not be sent twice.
isActive
- True if the request is active, false otherwise.public java.lang.String toString()
toString
in class java.lang.Object
public void addData(java.lang.String name, java.util.Hashtable<java.lang.String,?> nv)
name
- key name for object to be added to parameter listnv
- object which will be addedpublic void addData(java.lang.String name, java.util.Vector<java.lang.Object> value)
name
- key name for object to be added to parameter listvalue
- object which will be addedpublic void addData(java.lang.String name, java.util.List<java.lang.String> value)
name
- key name for object to be added to parameter listvalue
- object which will be addedpublic void addData(java.lang.String varName, byte[] value)
varName
- namevalue
- byte[] array to be addedpublic void addData(java.lang.String varName, java.lang.String value)
varName
- namevalue
- string valuepublic void addData(java.lang.String varName, java.lang.Long value)
varName
- namevalue
- Long valuepublic void addData(java.lang.String varName, java.lang.Integer value)
varName
- namevalue
- Integer valuepublic void addData(java.lang.String varName, java.lang.Boolean value)
varName
- namevalue
- Boolean valuepublic byte getAuthenticationType()
public int getRequestId()
public void setRequestId(int requestId)
requestId
- The request ID to set.public long getAuthTimestamp()
public long getCreationTimestamp()
public long getTimeout()
public long getExpiryDate()
public java.lang.String getApiMethodName()
public boolean isFireAndForget()
public void writeToOutputStream(java.io.OutputStream os, boolean writeRpgHeader)
os
- The output stream to serialise this request to.writeRpgHeader
- If true the RPG header is written.private byte[] makeBody() throws java.io.IOException
java.io.IOException
- Thrown if anything goes wrong using the hessian
encoder.public java.lang.String getAuth()
private void calculateAuth()
public void calculateExpiryDate()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
JavaDoc