net.rim.pushsdk.pap
Class PapServiceImpl

java.lang.Object
  extended by net.rim.pushsdk.pap.PapServiceImpl
All Implemented Interfaces:
PapService
Direct Known Subclasses:
AcknowledgementPapServiceImpl

public class PapServiceImpl
extends Object
implements PapService

Class implementing the PapService interface that defines push operations to send PAP 2.1/2.0 XML to a Push Proxy Gateway (PPG) and parse the PAP XML responses.

Dependencies that must be injected to properly initialize this object for use:
- httpClient
- pushSDKProperties

Author:
mdicesare

Constructor Summary
PapServiceImpl()
           
 
Method Summary
 CancelResponse cancel(String username, String password, CancelMessageControl cancelMessage)
          Sends a cancel request using the attributes in the cancelMessage.
 void onNotification(ResultNotification resultNotification, Map<String,String[]> notificationParameters)
          Implement this method in order to perform custom actions on result notification.
 PushResponse push(String username, String password, String destination, PushMessageControl pushMessage, Content content)
          Sends a push request with the specified content using the specified attributes.
 ResultNotificationResponseControl receiveNotification(String notificationMessage, Map<String,String[]> requestParameters)
          Called when a result notification message is received from the PPG (e.g.
 void setHttpClient(HttpClient httpClient)
          Support for dependency injection.
 void setPushSDKProperties(PushSDKProperties pushSDKProperties)
          Support for dependency injection.
 StatusQueryResponse statusQuery(String username, String password, StatusQueryMessageControl statusQueryMessage)
          Sends a status query request using the attributes in the statusQueryMessage.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PapServiceImpl

public PapServiceImpl()
Method Detail

setHttpClient

public void setHttpClient(HttpClient httpClient)
Description copied from interface: PapService
Support for dependency injection. This will override the default HttpClient implementation.

Specified by:
setHttpClient in interface PapService
Parameters:
httpClient - the HTTP client

setPushSDKProperties

public void setPushSDKProperties(PushSDKProperties pushSDKProperties)
Description copied from interface: PapService
Support for dependency injection. This will override the default PushSDKProperties implementation.

Specified by:
setPushSDKProperties in interface PapService
Parameters:
pushSDKProperties - the push SDK properties

push

public PushResponse push(String username,
                         String password,
                         String destination,
                         PushMessageControl pushMessage,
                         Content content)
                  throws PushSDKException,
                         BadMessageException,
                         UnauthorizedException
Description copied from interface: PapService
Sends a push request with the specified content using the specified attributes.

Note: If content was specified, then this method will check if a Push-Message-Id header has been specified as part of the top-most Content. If it has not, a Push-Message-ID header will be automatically added with the push id. This may assist in implementing duplicate message detection on the device side and various other use cases.

Specified by:
push in interface PapService
Parameters:
username - the username of the Push Initiator (for a public (BIS) push, this would be the application id; for an enterprise (BES) push, this might be null)
password - the password of the Push Initiator (for a public (BIS) push, this would be the application password; for an enterprise (BES) push, this might be null)
destination - for a public (BIS) push, the application id to push the content to; for an enterprise (BES) push, the application port to push the content to
pushMessage - the push message attributes needed to construct the PAP request
content - the content of the push message
Returns:
the PAP response from the push request
Throws:
PushSDKException - if the message could not be sent for various other reasons (e.g. a malformed PPG URL, if the PAP XML response returned by the PPG could not be parsed by this SDK, etc.)
BadMessageException - if the PPG returned a badmessage-response (i.e. the PPG could not understand/parse the PAP XML sent by the SDK)
UnauthorizedException - the push did not succeed due to authorization failure at the PPG

cancel

public CancelResponse cancel(String username,
                             String password,
                             CancelMessageControl cancelMessage)
                      throws PushSDKException,
                             BadMessageException,
                             UnauthorizedException
Description copied from interface: PapService
Sends a cancel request using the attributes in the cancelMessage.

Specified by:
cancel in interface PapService
Parameters:
username - the username of the Push Initiator (for a public (BIS) push, this would be the application id; for an enterprise (BES) push, this might be null)
password - the password of the Push Initiator (for a public (BIS) push, this would be the application password; for an enterprise (BES) push, this might be null)
cancelMessage - the cancel message attributes needed to construct the PAP request
Returns:
the PAP response from the cancel request
Throws:
PushSDKException - if the cancel could not be sent for various other reasons (e.g. a malformed PPG URL, the PAP XML response returned by the PPG could not be parsed by this SDK, etc.)
BadMessageException - if the PPG returned a badmessage-response (i.e. the PPG could not understand/parse the PAP XML sent by this SDK)
UnauthorizedException - the cancel did not succeed due to authorization failure at the PPG

statusQuery

public StatusQueryResponse statusQuery(String username,
                                       String password,
                                       StatusQueryMessageControl statusQueryMessage)
                                throws PushSDKException,
                                       BadMessageException,
                                       UnauthorizedException
Description copied from interface: PapService
Sends a status query request using the attributes in the statusQueryMessage.

Specified by:
statusQuery in interface PapService
Parameters:
username - the username of the Push Initiator (for a public (BIS) push, this would be the application id; for an enterprise (BES) push, this might be null)
password - the password of the Push Initiator (for a public (BIS) push, this would be the application password; for an enterprise (BES) push, this might be null)
statusQueryMessage - the status query message attributes needed to construct the PAP request
Returns:
the PAP response from the status query request
Throws:
PushSDKException - if the PAP XML response returned by the PPG could not be parsed by this SDK
BadMessageException - if the PPG returned a badmessage-response (i.e. the PPG could not understand/parse the PAP XML sent by this SDK)
UnauthorizedException - the status query did not succeed due to authorization failure at the PPG

onNotification

public void onNotification(ResultNotification resultNotification,
                           Map<String,String[]> notificationParameters)
                    throws PushSDKException
Description copied from interface: PapService
Implement this method in order to perform custom actions on result notification.
The default implementation does nothing.

Specified by:
onNotification in interface PapService
Parameters:
resultNotification - the result notification sent by the PPG
notificationParameters - request parameters from the result notification sent by the PPG
Throws:
PushSDKException - if the result notification cannot be processed

receiveNotification

public ResultNotificationResponseControl receiveNotification(String notificationMessage,
                                                             Map<String,String[]> requestParameters)
Description copied from interface: PapService
Called when a result notification message is received from the PPG (e.g. by a servlet).
The default implementation will unmarshal the result notification and validate its fields, construct the result notification response, and call the onNotification method with the result notification request.

Specified by:
receiveNotification in interface PapService
Parameters:
notificationMessage - PAP result notification XML message as a UTF-8 string
requestParameters - Request parameters from the result notification sent by the PPG
Returns:
result notification response to be sent to the PPG


Copyright © 2011 Research In Motion. All Rights Reserved.