public class NotificationFramework
extends java.lang.Object
implements java.io.Serializable
Modifier and Type | Field and Description |
---|---|
private static boolean |
API_ACTIVE
The value of the "Notification.Framework.Active" key.
|
private static java.lang.String |
API_DOMAIN
The value of the "Notification.Framework.Domain" key.
|
private static boolean |
API_LOGINBLOCK
The value of the "Notification.Framework.LoginBlockSite" key.
|
private static java.lang.String |
API_LOGINID
The value of the "Notification.Framework.LogonId" key.
|
private static java.lang.String |
API_LOGINPWD
The value of the "Notification.Framework.LogonPwd" key.
|
private static int |
API_LOGINRETRIES
The value of the "Notification.Framework.LogonRetries" key.
|
private static java.lang.String |
API_SERVERURL
The value of the "Notification.Framework.URL" key.
|
private static java.lang.String |
API_TOKEN
The current notification framework login authorization token.
|
private static int |
cvLoginRetries
The current number of consecutive failed login retry attempts.
|
private static javax.net.ssl.TrustManager[] |
cvTrustManager
A trust manager that allows self-signed certificates to be accepted.
|
private static long |
serialVersionUID
The class' serialization version id.
|
Constructor and Description |
---|
NotificationFramework() |
Modifier and Type | Method and Description |
---|---|
static int |
callFramework(java.lang.String api,
org.json.JSONObject data,
java.lang.String errtext,
java.util.ArrayList<java.lang.String> results)
Performs a call to the notification framework for a given API.
|
static java.lang.String |
getDomain()
Returns the configured notification framework domain.
|
static java.lang.String |
getServerURL()
Returns the configured notification framework server URL.
|
static boolean |
isActive()
Answers if the notification framework is active.
|
static boolean |
isLoggedIn()
Answers if a successful login has occurred with the notification framework
(i.e.
|
static boolean |
isSiteBlocked()
Answers if access to the site should be blocked due to an inability to
login to the notification framework.
|
protected static void |
logCallError(java.lang.Exception e,
java.lang.String errmsg,
int response)
Logs an error to the MAIN log for notification call failures.
|
static boolean |
login()
Performs login with the notification framework and sets the API_TOKEN
value to the token returned from the framework.
|
static void |
resumeProcessing()
Instructs this class to resume processing of notification requests.
|
protected static boolean |
retryUnauthorized(java.lang.String api,
java.lang.String token)
Answers if a notification framework API call should be retried due to an
unauthorized response from the framework (HTTP_UNAUTHORIZED).
|
protected static void |
setDefaultSSLContext()
Sets the default SSL context for URL SSL connections so that self-signed
certificates will be accepted.
|
private static final long serialVersionUID
private static boolean API_ACTIVE
private static java.lang.String API_DOMAIN
private static boolean API_LOGINBLOCK
private static java.lang.String API_LOGINID
private static java.lang.String API_LOGINPWD
private static int API_LOGINRETRIES
private static java.lang.String API_TOKEN
private static java.lang.String API_SERVERURL
private static int cvLoginRetries
private static javax.net.ssl.TrustManager[] cvTrustManager
public static final boolean isActive()
true
if the framework is active,
otherwise false
.public static final boolean isLoggedIn()
true
if a successful login has occurred,
otherwise false
.public static final boolean isSiteBlocked()
true
if site access should be blocked,
otherwise false
.public static final java.lang.String getDomain()
public static final java.lang.String getServerURL()
public static final boolean login()
true
if the processing was successful,
otherwise false
.public static final int callFramework(java.lang.String api, org.json.JSONObject data, java.lang.String errtext, java.util.ArrayList<java.lang.String> results)
api
- (String) The name of the API to call.data
- (JSONObject) The data to be sent to the API.errtext
- (String) Any additional text to add to logged error
messages.results
- (ArrayList) An empty array list of type String. Any
result codes or other info returned by the API are placed here.protected static final void logCallError(java.lang.Exception e, java.lang.String errmsg, int response)
e
- (Exception) An exception to log or null
if there
is no exception.errmsg
- (String) Any additional error message text to include
in the logged error.response
- (int) The response code for the call.public static final void resumeProcessing()
protected static final boolean retryUnauthorized(java.lang.String api, java.lang.String token)
api
- (String) The api being called when the unauthorized
response occurred.token
- (String) The authorization token that was used when
the unauthorized response occurred.true
if a retry should be attempted,
otherwise false
.protected static void setDefaultSSLContext() throws java.lang.Exception
java.lang.Exception
- - if an error occurs while setting the context.