net.rim.pushsdk.push
Class PushServiceImpl

java.lang.Object
  extended by net.rim.pushsdk.push.PushServiceImpl
All Implemented Interfaces:
PushService

public class PushServiceImpl
extends Object
implements PushService

Default implementation of the PushService. It defines operations to send push messages, cancel a previously submitted message or query the status of a previously submitted message. All the methods in this implementation require the use of a persistent store.

Note: This implementation is thread safe as long as the collaborating objects are thread safe as well. It is mandatory that all setters for collaborating objects are called prior to using the methods in this class.

Dependencies that must be injected to properly initialize this object for use:
- subscriptionService
- pushApplicationService
- pushRequestService
- pushRequestDetailService
- papService
- pushSDKProperties
- pushIdGenerator
- pushCountService
- pushStatsService

Author:
mdicesare, mdandrea

Field Summary
protected  PushApplicationService pushAppService
           
 
Fields inherited from interface net.rim.pushsdk.push.PushService
ADDRESS_COUNT_PARAMETER, APPID_REQUEST_PARAMETER
 
Constructor Summary
PushServiceImpl()
           
 
Method Summary
 CancelResult cancel(String applicationId, String pushId)
          Sends a cancel request using the attributes specified.
 CancelResult cancel(String applicationId, String pushId, List<String> addresses)
          Sends a cancel request using the attributes specified.
 CancelResult cancel(String applicationId, String pushId, String address)
          Sends a cancel request using the attributes specified.
 PushResult push(PushParameters pushParameters)
          Sends a push request to a push application using the characteristics in the specified PushParameters.
 void setPapService(PapService papService)
          Support for dependency injection.
 void setPushApplicationService(PushApplicationService pushAppService)
          Support for dependency injection.
 void setPushCountService(PushCountService pushCountService)
          Support for dependency injection.
 void setPushIdGenerator(IdGenerator pushIdGenerator)
          Support for dependency injection.
 void setPushRequestDetailService(PushRequestDetailService pushRequestDetailService)
          Support for dependency injection.
 void setPushRequestService(PushRequestService pushRequestService)
          Support for dependency injection.
 void setPushSDKProperties(PushSDKProperties pushSDKProperties)
          Support for dependency injection.
 void setPushStatsService(PushStatsService pushStatsService)
          Support for dependency injection.
 void setSubscriptionService(SubscriptionService subscriptionService)
          Support for dependency injection.
 StatusResult statusQueryAll(String applicationId, String pushId)
          Queries the status of a previously submitted push request for all addresses.
 StatusResult statusQueryAll(String applicationId, String pushId, List<String> addresses)
          Queries the status of a previously submitted push request.
 StatusResult statusQueryAll(String applicationId, String pushId, String address)
          Queries the status of a previously submitted push request.
 StatusResult statusQueryCompleted(String applicationId, String pushId)
          Queries the status of a push request for addresses to which delivery has completed.
 StatusResult statusQueryFailed(String applicationId, String pushId)
          Queries the status of a push request for addresses to which delivery has failed.
 StatusResult statusQueryPending(String applicationId, String pushId)
          Queries the status of a push request for addresses to which delivery is pending.
protected  PushApplication validateAppForPush(String applicationId)
          Validates that a push application being pushed to exists, is active, and has not expired.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pushAppService

protected PushApplicationService pushAppService
Constructor Detail

PushServiceImpl

public PushServiceImpl()
Method Detail

setPushSDKProperties

public void setPushSDKProperties(PushSDKProperties pushSDKProperties)
Description copied from interface: PushService
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 PushService
Parameters:
pushSDKProperties - an instance of a PushSDKProperties implementation (must be thread safe)

setPushIdGenerator

public void setPushIdGenerator(IdGenerator pushIdGenerator)
Description copied from interface: PushService
Support for dependency injection. Inject an implementation of an IdGenerator collaborating object - this is used when a pushId is null on the push() method.

Specified by:
setPushIdGenerator in interface PushService
Parameters:
pushIdGenerator - an instance of an IdGenerator implementation (must be thread safe)

setPapService

public void setPapService(PapService papService)
Description copied from interface: PushService
Support for dependency injection. Inject an implementation of a papService collaborating object - this is used to send the PAP messages to the PPG.

Specified by:
setPapService in interface PushService
Parameters:
papService - an instance of a papService implementation (must be thread safe)

setPushApplicationService

public void setPushApplicationService(PushApplicationService pushAppService)
Description copied from interface: PushService
Support for dependency injection. Inject an implementation of a PushApplicationService collaborating object - this is used to interface with the business service that manages push applications.

Specified by:
setPushApplicationService in interface PushService
Parameters:
pushAppService - an instance of a PushApplicationService implementation (must be thread safe)

setSubscriptionService

public void setSubscriptionService(SubscriptionService subscriptionService)
Description copied from interface: PushService
Support for dependency injection. Inject an implementation of a SubscriptionService collaborating object - this is used to interface with the business service that manages subscriptions.

Specified by:
setSubscriptionService in interface PushService
Parameters:
subscriptionService - an instance of a SubscriptionService implementation (must be thread safe)

setPushRequestService

public void setPushRequestService(PushRequestService pushRequestService)
Description copied from interface: PushService
Support for dependency injection. Inject an implementation of a PushRequestService collaborating object - this is used to interface with the business service that manages push requests.

Specified by:
setPushRequestService in interface PushService
Parameters:
pushRequestService - an instance of a PushRequestService implementation (must be thread safe)

setPushRequestDetailService

public void setPushRequestDetailService(PushRequestDetailService pushRequestDetailService)
Description copied from interface: PushService
Support for dependency injection. Inject an implementation of a PushRequestDetailService collaborating object - this is used to interface with the business service that manages push request details.

Specified by:
setPushRequestDetailService in interface PushService
Parameters:
pushRequestDetailService - an instance of a PushRequestDetailService implementation (must be thread safe)

setPushCountService

public void setPushCountService(PushCountService pushCountService)
Description copied from interface: PushService
Support for dependency injection. Inject an implementation of a PushCountService collaborating object - this is used to interface with the business service that manages tracking pushes that are complete.

Specified by:
setPushCountService in interface PushService

setPushStatsService

public void setPushStatsService(PushStatsService pushStatsService)
Description copied from interface: PushService
Support for dependency injection. Inject an implementation of a PushStatsService collaborating object - this is used to interface with the business service that manages tracking push statistics.

Specified by:
setPushStatsService in interface PushService

push

public PushResult push(PushParameters pushParameters)
                throws PushSDKException,
                       UnauthorizedException,
                       InvalidPushAppException,
                       InvalidPushRequestException
Sends a push request to a push application using the characteristics in the specified PushParameters.

The PushResult will contain the outcome of the push message.

Implementation notes:

Specified by:
push in interface PushService
Parameters:
pushParameters - defines the attributes of the push message to send
Returns:
the result of the push operation
Throws:
IllegalArgumentException - if any of the information passed in fails validation; or, if the following scenario occurs: 1) the push application being pushed to has a type of PushApplicationType.PUBLIC_PUSH and is storing push requests, 2) the push_all address is used, and 3) the number of active subscribers for the application exceeds PushSDKProperties.getSubscriptionFindMaxResults().
UnauthorizedException - the push did not succeed due to an authorization failure at the PPG
InvalidPushAppException - the push did not succeed since the application being pushed to was invalid
InvalidPushRequestException - the push did not succeed due to an invalid push id (either not a unique id or was unable to generate a new push id)
PushSDKException - if the push could not be sent for various other reasons (e.g. malformed PPG URL, if the PAP XML response returned by the PPG could not be parsed by the SDK, etc.). The exception stack trace will have details of the error.

cancel

public CancelResult cancel(String applicationId,
                           String pushId,
                           List<String> addresses)
                    throws PushSDKException,
                           UnauthorizedException,
                           InvalidPushAppException,
                           InvalidPushRequestException
Description copied from interface: PushService
Sends a cancel request using the attributes specified.

The CancelResult will contain the outcome of the cancel request. See the CancelResult class for more details about what is returned.

Note: Cancelling a message is not guaranteed and is only a best effort. To know if the cancel succeeded, you must issue a status query or if you are using acknowledgements you will be notified asynchronously when the final outcome is known by the PPG.

Note: If the push application is not storing push requests, and if the addresses specified are subscriber IDs, then they will be mapped to client addresses (e.g. PINs) using the currently known mapping. This may result in incorrect results if a subscriber or device swap occurred after the push request was issued.

Specified by:
cancel in interface PushService
pushId - the id of the previously submitted push request to cancel
addresses - optional parameter that contains a list of addresses for which the request should be cancelled
Returns:
the result of the cancel operation
Throws:
PushSDKException - if the cancel could not be sent for various other reasons (e.g. malformed PPG URL, if the PAP XML response returned by the PPG could not be parsed by the SDK, etc.). The exception stack trace will have details of the error.
UnauthorizedException - the cancel did not succeed due to an authorization failure at the PPG
InvalidPushAppException - the cancel did not succeed due to an invalid push application associated with the provided push request
InvalidPushRequestException - the cancel did not succeed due to an invalid pushId provided

cancel

public CancelResult cancel(String applicationId,
                           String pushId,
                           String address)
                    throws PushSDKException,
                           UnauthorizedException,
                           InvalidPushAppException,
                           InvalidPushRequestException
Description copied from interface: PushService
Sends a cancel request using the attributes specified.

The CancelResult will contain the outcome of the cancel request. See the CancelResult class for more details about what is returned.

Note: Cancelling a message is not guaranteed and is only a best effort. To know if the cancel succeeded, you must issue a status query or if you are using acknowledgements you will be notified asynchronously when the final outcome is known by the PPG.

Note: If the push application is not storing push requests, and if the address specified is a subscriber ID, then it will be mapped to a client address (e.g. PIN) using the currently known mapping. This may result in incorrect results if a subscriber or device swap occurred after the push request was issued.

Specified by:
cancel in interface PushService
pushId - the id of the previously submitted push request to cancel
address - optional parameter that contains an address for which the request should be cancelled
Returns:
the result of the cancel operation
Throws:
PushSDKException - if the cancel could not be sent for various other reasons (e.g. malformed PPG URL, if the PAP XML response returned by the PPG could not be parsed by the SDK, etc.). The exception stack trace will have details of the error.
UnauthorizedException - the cancel did not succeed due to an authorization failure at the PPG
InvalidPushAppException - the cancel did not succeed due to an invalid push application associated with the provided push request
InvalidPushRequestException - the cancel did not succeed due to an invalid pushId provided

cancel

public CancelResult cancel(String applicationId,
                           String pushId)
                    throws PushSDKException,
                           UnauthorizedException,
                           InvalidPushAppException,
                           InvalidPushRequestException
Description copied from interface: PushService
Sends a cancel request using the attributes specified. This will attempt to cancel the push for all addresses specified in the original push request (matching the pushId specified).

The CancelResult will contain the outcome of the cancel request. See the CancelResult class for more details about what is returned.

Note: Cancelling a message is not guaranteed and is only a best effort. To know if the cancel succeeded, you must issue a status query or if you are using acknowledgements you will be notified asynchronously when the final outcome is known by the PPG.

Specified by:
cancel in interface PushService
pushId - the id of the previously submitted push request to cancel
Returns:
the result of the cancel operation
Throws:
PushSDKException - if the cancel could not be sent for various other reasons (e.g. malformed PPG URL, if the PAP XML response returned by the PPG could not be parsed by the SDK, etc.). The exception stack trace will have details of the error.
UnauthorizedException - the cancel did not succeed due to an authorization failure at the PPG
InvalidPushAppException - the cancel did not succeed due to an invalid push application associated with the provided push request
InvalidPushRequestException - the cancel did not succeed due to an invalid pushId provided

statusQueryCompleted

public StatusResult statusQueryCompleted(String applicationId,
                                         String pushId)
                                  throws PushSDKException,
                                         UnauthorizedException,
                                         InvalidPushRequestException,
                                         InvalidPushAppException
Description copied from interface: PushService
Queries the status of a push request for addresses to which delivery has completed.

The StatusResult will contain the outcome of the status query request. See the StatusResult class for more details about what is returned.

Specified by:
statusQueryCompleted in interface PushService
Parameters:
applicationId - the unique id of the push application to query
pushId - the id of the push that this request is querying about
Returns:
the response from the status query request
Throws:
PushSDKException - if the status query could not be sent for various other reasons (e.g. malformed PPG URL, if the PAP XML response returned by the PPG could not be parsed by the SDK, etc.). The exception stack trace will have details of the error.
UnauthorizedException - the status query did not succeed due to an authorization failure at the PPG
InvalidPushRequestException - the status query did not succeed due to an invalid pushId provided
InvalidPushAppException - the status query did not succeed due to an invalid push application associated with the provided push request

statusQueryFailed

public StatusResult statusQueryFailed(String applicationId,
                                      String pushId)
                               throws PushSDKException,
                                      UnauthorizedException,
                                      InvalidPushRequestException,
                                      InvalidPushAppException
Description copied from interface: PushService
Queries the status of a push request for addresses to which delivery has failed.

The StatusResult will contain the outcome of the status query request. See the StatusResult class for more details about what is returned.

Specified by:
statusQueryFailed in interface PushService
Parameters:
applicationId - the unique id of the push application to query
pushId - the id of the push that this request is querying about
Returns:
the response from the status query request
Throws:
PushSDKException - if the status query could not be sent for various other reasons (e.g. malformed PPG URL, if the PAP XML response returned by the PPG could not be parsed by the SDK, etc.). The exception stack trace will have details of the error.
UnauthorizedException - the status query did not succeed due to an authorization failure at the PPG
InvalidPushRequestException - the status query did not succeed due to an invalid pushId provided
InvalidPushAppException - the status query did not succeed due to an invalid push application associated with the provided push request

statusQueryPending

public StatusResult statusQueryPending(String applicationId,
                                       String pushId)
                                throws PushSDKException,
                                       UnauthorizedException,
                                       InvalidPushRequestException,
                                       InvalidPushAppException
Description copied from interface: PushService
Queries the status of a push request for addresses to which delivery is pending.

The StatusResult will contain the outcome of the status query request. See the StatusResult class for more details about what is returned.

Specified by:
statusQueryPending in interface PushService
Parameters:
applicationId - the unique id of the push application to query
pushId - the id of the push that this request is querying about
Returns:
the response from the status query request
Throws:
PushSDKException - if the status query could not be sent for various other reasons (e.g. malformed PPG URL, if the PAP XML response returned by the PPG could not be parsed by the SDK, etc.). The exception stack trace will have details of the error.
UnauthorizedException - the status query did not succeed due to an authorization failure at the PPG
InvalidPushRequestException - the status query did not succeed due to an invalid pushId provided
InvalidPushAppException - the status query did not succeed due to an invalid push application associated with the provided push request

statusQueryAll

public StatusResult statusQueryAll(String applicationId,
                                   String pushId,
                                   List<String> addresses)
                            throws PushSDKException,
                                   UnauthorizedException,
                                   InvalidPushRequestException,
                                   InvalidPushAppException
Description copied from interface: PushService
Queries the status of a previously submitted push request.

The StatusResult will contain the outcome of the status query request. See the StatusResult class for more details about what is returned.

Note: If the push application is not storing push requests, and if the addresses specified are subscriber IDs, then they will be mapped to client addresses (e.g. PINs) using the currently known mapping. This may result in incorrect results if a subscriber or device swap occurred after the push request was issued.

Specified by:
statusQueryAll in interface PushService
Parameters:
applicationId - the unique id of the push application to query
pushId - the id of the push that this request is querying about
addresses - the list of the addresses from the original push request that this call is querying about
Returns:
the response from the status query request
Throws:
PushSDKException - if the status query could not be sent for various other reasons (e.g. malformed PPG URL, if the PAP XML response returned by the PPG could not be parsed by the SDK, etc.). The exception stack trace will have details of the error.
UnauthorizedException - the status query did not succeed due to an authorization failure at the PPG
InvalidPushRequestException - the status query did not succeed due to an invalid pushId provided
InvalidPushAppException - the status query did not succeed due to an invalid push application associated with the provided push request

statusQueryAll

public StatusResult statusQueryAll(String applicationId,
                                   String pushId,
                                   String address)
                            throws PushSDKException,
                                   UnauthorizedException,
                                   InvalidPushRequestException,
                                   InvalidPushAppException
Description copied from interface: PushService
Queries the status of a previously submitted push request.

The StatusResult will contain the outcome of the status query request. See the StatusResult class for more details about what is returned.

Note: If the push application is not storing push requests, and if the address specified is a subscriber ID, then it will be mapped to a client address (e.g. PIN) using the currently known mapping. This may result in incorrect results if a subscriber or device swap occurred after the push request was issued.

Specified by:
statusQueryAll in interface PushService
Parameters:
applicationId - the unique id of the push application to query
pushId - the id of the push that this request is querying about
address - the address from the original push request that this call is querying about
Returns:
the response from the status query request
Throws:
PushSDKException - if the status query could not be sent for various other reasons (e.g. malformed PPG URL, if the PAP XML response returned by the PPG could not be parsed by the SDK, etc.). The exception stack trace will have details of the error.
UnauthorizedException - the status query did not succeed due to an authorization failure at the PPG
InvalidPushRequestException - the status query did not succeed due to an invalid pushId provided
InvalidPushAppException - the status query did not succeed due to an invalid push application associated with the provided push request

statusQueryAll

public StatusResult statusQueryAll(String applicationId,
                                   String pushId)
                            throws PushSDKException,
                                   UnauthorizedException,
                                   InvalidPushRequestException,
                                   InvalidPushAppException
Description copied from interface: PushService
Queries the status of a previously submitted push request for all addresses.

The StatusResult will contain the outcome of the status query request. See the StatusResult class for more details about what is returned.

Specified by:
statusQueryAll in interface PushService
Parameters:
applicationId - the unique id of the push application to query
pushId - the id of the push that this request is querying about
Returns:
the response from the status query request
Throws:
PushSDKException - if the status query could not be sent for various other reasons (e.g. malformed PPG URL, if the PAP XML response returned by the PPG could not be parsed by the SDK, etc.). The exception stack trace will have details of the error.
UnauthorizedException - the status query did not succeed due to an authorization failure at the PPG
InvalidPushRequestException - the status query did not succeed due to an invalid pushId provided
InvalidPushAppException - the status query did not succeed due to an invalid push application associated with the provided push request

validateAppForPush

protected PushApplication validateAppForPush(String applicationId)
                                      throws InvalidPushAppException,
                                             PushSDKException
Validates that a push application being pushed to exists, is active, and has not expired.

Parameters:
applicationId - the id of the push application to validate
Returns:
the validated push application
Throws:
InvalidPushAppException - if the push application fails validation
PushSDKException - if any other errors occurring during the validation


Copyright © 2011 Research In Motion. All Rights Reserved.