net.rim.pushsdk.push.request
Class PushRequestServiceImpl

java.lang.Object
  extended by net.rim.pushsdk.push.request.PushRequestServiceImpl
All Implemented Interfaces:
PushRequestService

public class PushRequestServiceImpl
extends Object
implements PushRequestService

Default implementation of the PushRequestService, defining operations to manage push requests.

Note: This implementation is thread safe as long as the collaborating objects are thread safe as well.

Dependencies that must be injected to properly initialize this object for use:
- pushRequestDAO
- pushApplicationService
- pushRequestDetailService
- pushSDKProperties

Author:
dstrelbytsky

Constructor Summary
PushRequestServiceImpl()
           
 
Method Summary
 void addPushRequest(PushRequest pushRequest)
          Adds the specified push request to the persistent store.
 void deleteCompletedPushRequests(String pushApplicationId, Date toDate, String deletedBy)
          Deletes completed push requests for the specified push application that are older than the provided date.
 void deletePushRequest(String pushId)
          Deletes a push request with the given push id.
 void deletePushRequests(List<String> pushIds)
          Deletes push requests with the given push ids.
 void deletePushRequests(String pushApplicationId, Date toDate, String deletedBy)
          Deletes push requests for the specified push application that are older than the provided date.
 List<PushRequest> findAll()
          Finds all push requests.
 List<PushRequest> findByAppId(String id)
          Finds all push requests associated with a specified push application.
 List<PushRequest> findByDateRange(Date fromDate, Date toDate, int startIndex, int endIndex)
          Finds all push requests by the specified date range.
 PushRequest findById(String id)
          Finds a push request by the specified id.
 List<PushRequest> findByStatusCode(StatusCode statusCode)
          Deprecated. 
 List<PushRequest> findIncomplete(String applicationId)
          Finds all push requests that are incomplete for a given push application.
 int getSizeByDateRange(Date fromDate, Date toDate)
          Gets size of all push requests by the specified date range.
 void setPushApplicationService(PushApplicationService pushApplicationService)
          Support for dependency injection.
 void setPushRequestDAO(PushRequestDAO pushRequestDAO)
          Support for dependency injection.
 void setPushRequestDetailService(PushRequestDetailService pushRequestDetailService)
          Support for dependency injection.
 void setPushSDKProperties(PushSDKProperties pushSDKProperties)
          Support for dependency injection.
 void updatePushRequest(PushRequest pushRequest)
          Deprecated. 
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PushRequestServiceImpl

public PushRequestServiceImpl()
Method Detail

setPushRequestDAO

public void setPushRequestDAO(PushRequestDAO pushRequestDAO)
Description copied from interface: PushRequestService
Support for dependency injection. Sets the PushRequestDAO to use.

Specified by:
setPushRequestDAO in interface PushRequestService
Parameters:
pushRequestDAO - an instance of a PushRequestDAO implementation

setPushRequestDetailService

public void setPushRequestDetailService(PushRequestDetailService pushRequestDetailService)
Description copied from interface: PushRequestService
Support for dependency injection. Sets the PushRequestDetailService to use.

Specified by:
setPushRequestDetailService in interface PushRequestService
Parameters:
pushRequestDetailService - an instance of a PushRequestDetailService implementation

setPushApplicationService

public void setPushApplicationService(PushApplicationService pushApplicationService)
Description copied from interface: PushRequestService
Support for dependency injection. Sets the PushApplicationService to use.

Specified by:
setPushApplicationService in interface PushRequestService
Parameters:
pushApplicationService - an instance of a PushApplicationService implementation

setPushSDKProperties

public void setPushSDKProperties(PushSDKProperties pushSDKProperties)
Description copied from interface: PushRequestService
Support for dependency injection. Inject an implementation of a PushSDKProperties collaborating object - this is used to read global configuration properties.

Specified by:
setPushSDKProperties in interface PushRequestService
Parameters:
pushSDKProperties - an instance of a PushSDKProperties implementation (must be thread safe)

addPushRequest

public void addPushRequest(PushRequest pushRequest)
                    throws PushSDKException
Description copied from interface: PushRequestService
Adds the specified push request to the persistent store.

Specified by:
addPushRequest in interface PushRequestService
Parameters:
pushRequest - the push request to create
Throws:
PushSDKException - if any errors occur

updatePushRequest

@Deprecated
public void updatePushRequest(PushRequest pushRequest)
                       throws PushSDKException
Deprecated. 

Description copied from interface: PushRequestService
Updates the specified push request status and status description (no push request details are updated) in the persistent store.

Specified by:
updatePushRequest in interface PushRequestService
Parameters:
pushRequest - the push request to update
Throws:
PushSDKException - if any errors occur

deletePushRequests

public void deletePushRequests(String pushApplicationId,
                               Date toDate,
                               String deletedBy)
                        throws PushSDKException
Description copied from interface: PushRequestService
Deletes push requests for the specified push application that are older than the provided date. If push application id is null, all push requests older than the the specified date will be deleted. If the provided date is null, all push requests for the specified push application will be deleted.

Specified by:
deletePushRequests in interface PushRequestService
Parameters:
pushApplicationId - id of the push application for which the corresponding push requests should be deleted
toDate - specifies the cut off date for the push request deletion
deletedBy - the id of the user deleting the push requests; used for logging purposes only
Throws:
PushSDKException - if any errors occur

deleteCompletedPushRequests

public void deleteCompletedPushRequests(String pushApplicationId,
                                        Date toDate,
                                        String deletedBy)
                                 throws PushSDKException
Description copied from interface: PushRequestService
Deletes completed push requests for the specified push application that are older than the provided date. If push application id is null, all push requests older than the the specified date will be deleted. If the provided date is null, all push requests for the specified push application will be deleted.

Specified by:
deleteCompletedPushRequests in interface PushRequestService
Parameters:
pushApplicationId - id of the push application for which the corresponding push requests should be deleted
toDate - specifies the cut off date for the push request deletion
deletedBy - the id of the user deleting the push requests; used for logging purposes only
Throws:
PushSDKException - if any errors occur

deletePushRequests

public void deletePushRequests(List<String> pushIds)
                        throws PushSDKException
Description copied from interface: PushRequestService
Deletes push requests with the given push ids.

Specified by:
deletePushRequests in interface PushRequestService
Parameters:
pushIds - ids of the requests to be deleted
Throws:
PushSDKException - if any errors occur

deletePushRequest

public void deletePushRequest(String pushId)
                       throws PushSDKException
Description copied from interface: PushRequestService
Deletes a push request with the given push id.

Specified by:
deletePushRequest in interface PushRequestService
Parameters:
pushId - id of the request to be deleted
Throws:
PushSDKException - if any errors occur

findAll

public List<PushRequest> findAll()
                          throws PushSDKException
Description copied from interface: PushRequestService
Finds all push requests.

Specified by:
findAll in interface PushRequestService
Returns:
list of pushRequests, empty if not found
Throws:
PushSDKException - if any errors occur

findByAppId

public List<PushRequest> findByAppId(String id)
                              throws PushSDKException
Description copied from interface: PushRequestService
Finds all push requests associated with a specified push application.

Specified by:
findByAppId in interface PushRequestService
Parameters:
id - id of the push application
Returns:
list of pushRequests, empty if not found
Throws:
PushSDKException - if any errors occur

findByDateRange

public List<PushRequest> findByDateRange(Date fromDate,
                                         Date toDate,
                                         int startIndex,
                                         int endIndex)
                                  throws PushSDKException
Description copied from interface: PushRequestService
Finds all push requests by the specified date range.

Specified by:
findByDateRange in interface PushRequestService
Parameters:
fromDate - inclusive from date parameter of the range
toDate - inclusive to date parameter of the range
startIndex - the index of the first entry to be retrieved
endIndex - the index of the last entry to be retrieved
Returns:
list of pushRequests, empty if not found
Throws:
PushSDKException - if any errors occur

getSizeByDateRange

public int getSizeByDateRange(Date fromDate,
                              Date toDate)
                       throws PushSDKException
Description copied from interface: PushRequestService
Gets size of all push requests by the specified date range.

Specified by:
getSizeByDateRange in interface PushRequestService
Parameters:
fromDate - inclusive from date parameter of the range
toDate - inclusive to date parameter of the range
Returns:
number of push requests in the date range
Throws:
PushSDKException - if any errors occur

findById

public PushRequest findById(String id)
                     throws PushSDKException
Description copied from interface: PushRequestService
Finds a push request by the specified id.

Specified by:
findById in interface PushRequestService
Parameters:
id - id of the push request to find
Returns:
the pushRequest, null if not found
Throws:
PushSDKException - if any errors occur

findByStatusCode

@Deprecated
public List<PushRequest> findByStatusCode(StatusCode statusCode)
                                   throws PushSDKException
Deprecated. 

Description copied from interface: PushRequestService
Finds all push requests by the specified status code.

Specified by:
findByStatusCode in interface PushRequestService
Parameters:
statusCode - status code of the push request
Returns:
list of pushRequests, empty if not found
Throws:
PushSDKException - if any errors occur

findIncomplete

public List<PushRequest> findIncomplete(String applicationId)
                                 throws PushSDKException
Description copied from interface: PushRequestService
Finds all push requests that are incomplete for a given push application. In other words, finds all push requests for a given push application that have at least one push request detail (one address) that is still in a pending state.

Note: This method will only return push requests where the push application has a service level of 'Push Plus' and has its 'storePushRequests' flag set to 'true'.

Note: A large number of push request/push request details in the persistent store may make this query take a long time to complete.

Specified by:
findIncomplete in interface PushRequestService
Parameters:
applicationId - application for which to find the incomplete pushes
Returns:
list of incomplete push requests
Throws:
PushSDKException - if any errors occur


Copyright © 2011 Research In Motion. All Rights Reserved.