Cumulus4j API
(1.1.1)

org.cumulus4j.store.crypto.keymanager.messagebroker.pmf
Class PendingRequest

java.lang.Object
  extended by org.cumulus4j.store.crypto.keymanager.messagebroker.pmf.PendingRequest

public class PendingRequest
extends Object

Persistent container holding a Request and optionally the corresponding Response. Used by MessageBrokerPMF to transmit messages via a backing-database.

Author:
Marco หงุ่ยตระกูล-Schulze - marco at nightlabs dot de

Nested Class Summary
static class PendingRequest.FetchGroup
          Fetch-groups for PendingRequest.
 
Constructor Summary
protected PendingRequest()
          Internal constructor only used by JDO.
  PendingRequest(Request request)
          Create an instance of PendingRequest for the given request.
 
Method Summary
 boolean equals(Object obj)
           
 Date getCreationTimestamp()
          Get the timestamp when this PendingRequest was instantiated.
 String getCryptoSessionIDPrefix()
          Get the cryptoSessionIDPrefix of the Request that was passed to PendingRequest(Request).
 Date getLastStatusChangeTimestamp()
          Get the timestamp when the status was changed the last time.
static PendingRequest getOldestPendingRequest(PersistenceManager pm, String cryptoSessionIDPrefix, PendingRequestStatus status)
          Get the oldest PendingRequest matching the given criteria.
static PendingRequest getPendingRequest(PersistenceManager pm, String requestID)
          Get the PendingRequest uniquely identified by the given requestID.
static Collection<PendingRequest> getPendingRequestsWithLastStatusChangeTimestampOlderThanTimestamp(PersistenceManager pm, Date timestamp)
           
 Request getRequest()
          Get the Request that was passed to PendingRequest(Request).
 String getRequestID()
          Get the requestID of the Request that was passed to PendingRequest(Request).
 Response getResponse()
          Get the Response previously set or null, if none is set, yet.
 PendingRequestStatus getStatus()
          Get the current status.
 int hashCode()
           
 void setResponse(Response response)
          Set the Response.
 void setStatus(PendingRequestStatus status)
          Set the current status.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PendingRequest

protected PendingRequest()
Internal constructor only used by JDO. Never call this constructor directly!


PendingRequest

public PendingRequest(Request request)
Create an instance of PendingRequest for the given request.

Parameters:
request - the request to be processed and thus temporarily stored in the database; must not be null.
Method Detail

getPendingRequestsWithLastStatusChangeTimestampOlderThanTimestamp

public static Collection<PendingRequest> getPendingRequestsWithLastStatusChangeTimestampOlderThanTimestamp(PersistenceManager pm,
                                                                                                           Date timestamp)

getOldestPendingRequest

public static PendingRequest getOldestPendingRequest(PersistenceManager pm,
                                                     String cryptoSessionIDPrefix,
                                                     PendingRequestStatus status)
Get the oldest PendingRequest matching the given criteria.

Parameters:
pm - the PersistenceManager for accessing the message-transfer-database. Must not be null.
cryptoSessionIDPrefix - the cryptoSessionIDPrefix used as criterion to filter the candidate-PendingRequests. Must not be null.
status - the status used as criterion to filter the candidate-PendingRequests. Must not be null.
Returns:
the oldest PendingRequest matching the given criteria or null if there is no PendingRequest in the datastore which matches the criteria.

getPendingRequest

public static PendingRequest getPendingRequest(PersistenceManager pm,
                                               String requestID)
Get the PendingRequest uniquely identified by the given requestID. If no such PendingRequest exists, return null.

Parameters:
pm - the PersistenceManager for accessing the message-transfer-database. Must not be null.
requestID - the unique identifier of the PendingRequest to obtain. Must not be null.
Returns:
the PendingRequest identified by the given requestID or null, if no such object exists in the datastore.

getRequestID

public String getRequestID()
Get the requestID of the Request that was passed to PendingRequest(Request). This property is the primary key of this class.

Returns:
the request's requestID.

getCryptoSessionIDPrefix

public String getCryptoSessionIDPrefix()
Get the cryptoSessionIDPrefix of the Request that was passed to PendingRequest(Request).

Returns:
the request's cryptoSessionIDPrefix.

getStatus

public PendingRequestStatus getStatus()
Get the current status.

Returns:
the current status. Can be null, if the instance was not yet persisted.
See Also:
setStatus(PendingRequestStatus)

setStatus

public void setStatus(PendingRequestStatus status)
Set the current status. This method will automatically update the lastStatusChangeTimestamp.

Parameters:
status - the new status; must not be null (because of NullValue.EXCEPTION).
See Also:
getStatus()

getRequest

public Request getRequest()
Get the Request that was passed to PendingRequest(Request).

Returns:
the request; never null.

getResponse

public Response getResponse()
Get the Response previously set or null, if none is set, yet.

Returns:
the response or null.

setResponse

public void setResponse(Response response)
Set the Response.

Parameters:
response - the response.

getCreationTimestamp

public Date getCreationTimestamp()
Get the timestamp when this PendingRequest was instantiated.

Returns:
when was this PendingRequest created.

getLastStatusChangeTimestamp

public Date getLastStatusChangeTimestamp()
Get the timestamp when the status was changed the last time.

Returns:
the timestamp of the last status-change.

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

Cumulus4j API
(1.1.1)

Copyright © 2013 NightLabs Consulting GmbH. All Rights Reserved.