net.rim.pushsdk.subscription.web
Class SubscriptionRequestParser

java.lang.Object
  extended by net.rim.pushsdk.subscription.web.SubscriptionRequestParser
All Implemented Interfaces:
Serializable

public class SubscriptionRequestParser
extends Object
implements Serializable

Parses the needed parameters out of various subscription-related HTTP requests.

Author:
mdandrea
See Also:
Serialized Form

Field Summary
static String REQUEST_PARAM_ADDRESS
          The subscriber's address (e.g.
static String REQUEST_PARAM_MODEL
          The model number of the subscriber's device HTTP request parameter.
static String REQUEST_PARAM_OS_VERSION
          The OS version of the subscriber's device HTTP request parameter.
static String REQUEST_PARAM_PASSWORD
          The subscriber's password HTTP request parameter.
static String REQUEST_PARAM_PUSH_APP_ID
          The push application id HTTP request parameter.
static String REQUEST_PARAM_TYPE
          The subscriber's type HTTP request parameter.
static String REQUEST_PARAM_USERNAME
          The subscriber's username HTTP request parameter.
 
Constructor Summary
SubscriptionRequestParser()
           
 
Method Summary
 AuthenticationRequest parseAuthenticationRequest(javax.servlet.http.HttpServletRequest request)
          Parses out the HTTP request parameters from an authentication request and constructs an authentication request with the app id, username and password fields set.
 ResumeRequest parseResumeRequest(javax.servlet.http.HttpServletRequest request)
          Parses out the HTTP request parameters from a resume request and constructs a resume request with the app id field set.
 SubscribeRequest parseSubscribeRequest(javax.servlet.http.HttpServletRequest request)
          Parses out the HTTP request parameters from a subscribe request and constructs a subscribe request with the following fields set: app id, address, OS version, model number, and type (the type field can be null if the app id does not correspond to a push application with a type of Public+Enterprise Push).
 SuspendRequest parseSuspendRequest(javax.servlet.http.HttpServletRequest request)
          Parses out the HTTP request parameters from a suspend request and constructs a suspend request with the app id field set.
 UnsubscribeRequest parseUnsubscribeRequest(javax.servlet.http.HttpServletRequest request)
          Parses out the HTTP request parameters from an unsubscribe request and constructs an unsubscribe request with the app id field set.
protected static String trim(String str)
          Trims white space from a String, if the String is not null.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REQUEST_PARAM_PUSH_APP_ID

public static final String REQUEST_PARAM_PUSH_APP_ID
The push application id HTTP request parameter.

See Also:
Constant Field Values

REQUEST_PARAM_ADDRESS

public static final String REQUEST_PARAM_ADDRESS
The subscriber's address (e.g. PIN, email address) HTTP request parameter.

See Also:
Constant Field Values

REQUEST_PARAM_OS_VERSION

public static final String REQUEST_PARAM_OS_VERSION
The OS version of the subscriber's device HTTP request parameter.

See Also:
Constant Field Values

REQUEST_PARAM_MODEL

public static final String REQUEST_PARAM_MODEL
The model number of the subscriber's device HTTP request parameter.

See Also:
Constant Field Values

REQUEST_PARAM_USERNAME

public static final String REQUEST_PARAM_USERNAME
The subscriber's username HTTP request parameter.

See Also:
Constant Field Values

REQUEST_PARAM_PASSWORD

public static final String REQUEST_PARAM_PASSWORD
The subscriber's password HTTP request parameter. Note: This request parameter is optional if a content provider only requires a username to perform authentication.

See Also:
Constant Field Values

REQUEST_PARAM_TYPE

public static final String REQUEST_PARAM_TYPE
The subscriber's type HTTP request parameter.

Since:
1.1
See Also:
Constant Field Values
Constructor Detail

SubscriptionRequestParser

public SubscriptionRequestParser()
Method Detail

parseSubscribeRequest

public SubscribeRequest parseSubscribeRequest(javax.servlet.http.HttpServletRequest request)
Parses out the HTTP request parameters from a subscribe request and constructs a subscribe request with the following fields set: app id, address, OS version, model number, and type (the type field can be null if the app id does not correspond to a push application with a type of Public+Enterprise Push).

Parameters:
request - an HTTP request
Returns:
an initialized subscribe request
Throws:
SubIllegalArgumentException - if the "type" request parameter was invalid (i.e. anything but null or the valid values)

parseUnsubscribeRequest

public UnsubscribeRequest parseUnsubscribeRequest(javax.servlet.http.HttpServletRequest request)
Parses out the HTTP request parameters from an unsubscribe request and constructs an unsubscribe request with the app id field set.

Parameters:
request - an HTTP request
Returns:
an initialized unsubscribe request

parseSuspendRequest

public SuspendRequest parseSuspendRequest(javax.servlet.http.HttpServletRequest request)
Parses out the HTTP request parameters from a suspend request and constructs a suspend request with the app id field set.

Parameters:
request - an HTTP request
Returns:
an initialized suspend request

parseResumeRequest

public ResumeRequest parseResumeRequest(javax.servlet.http.HttpServletRequest request)
Parses out the HTTP request parameters from a resume request and constructs a resume request with the app id field set.

Parameters:
request - an HTTP request
Returns:
an initialized resume request

parseAuthenticationRequest

public AuthenticationRequest parseAuthenticationRequest(javax.servlet.http.HttpServletRequest request)
Parses out the HTTP request parameters from an authentication request and constructs an authentication request with the app id, username and password fields set.

Parameters:
request - an HTTP request
Returns:
an initialized authentication request

trim

protected static String trim(String str)
Trims white space from a String, if the String is not null. Otherwise, returns null.

Parameters:
str - the String to be trimmed
Returns:
a trimmed String, or null if the original String was null


Copyright © 2011 Research In Motion. All Rights Reserved.