public interface ServiceAPI
NOTE: By convention, implementors of this interface must be thread-safe.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
NAME
This is the name of the global variable in each Integration Service's script that is assigned an instance of this
interface.
|
Modifier and Type | Method and Description |
---|---|
APXMLMessage |
createAPXML()
Creates an new APXML message that the caller can populate.
|
IntegrationServiceRequest |
createIntegrationServiceRequest()
Creates an object that can be used to make an Integration Service Request to either a local (i.e., hosted on the
same Integration Agent), or external Integration Service.
|
java.lang.String |
decrypt(java.lang.String encryptedString)
This method will decrypt the provided string.
|
GlobalService |
getConfiguration()
Expose the service definition of this Integration Service.
|
org.apache.log4j.Logger |
getLogger()
Gets a logger that will write to the APIA log file in the same log4j category and format as the Integration
Service.
|
void |
sendAPXML(APXMLMessage apxml)
Adds the specified APXML message to the end of the Integration Service's outbound queue.
|
void |
sendAPXML(APXMLMessage apxml,
java.lang.String domain,
java.lang.String serviceName)
Adds the specified APXML message to the end of the specified service's inbound queue.
|
static final java.lang.String NAME
org.apache.log4j.Logger getLogger()
For example, if the Integration Service is (default,sample), the logger will write to the category com.alarmpoint.integrationagents.services.default.sample).
GlobalService getConfiguration()
GlobalService
APXMLMessage createAPXML()
void sendAPXML(APXMLMessage apxml) throws java.lang.Exception
apxml
- - the outbound APXML message; must be non-nulljava.lang.Exception
- if the message cannot be queuedvoid sendAPXML(APXMLMessage apxml, java.lang.String domain, java.lang.String serviceName) throws java.lang.Exception
Below is a sample usage of this method to send an APXML to the local ping|ping service.
var apxml = ServiceAPI.createAPXML(); apxml.setMethod("add"); apxml.setSubclass("event"); apxml.setToken("recipients","bsmith"); apxml.setToken("situation","Redirected ping from sample."); apxml.setToken("device","localhost"); apxml.setToken("incident_id","Redirected-localhost-ping-test"); ServiceAPI.sendAPXML(apxml, "ping", "ping");
apxml
- - the inbound APXML message; must be non-nulldomain
- - the domain of the targeted serviceserviceName
- - the service name to queue the messagejava.lang.Exception
- if the message cannot be queuedIntegrationServiceRequest createIntegrationServiceRequest()
java.lang.String decrypt(java.lang.String encryptedString) throws SymmetricCipherException
Below is a sample usage of this method to decrypt the "password" token passed in the apxml
function handleRequest(apxml) { var encryptedPassword = apxml.getValue("password"); var decryptedPassword = ServiceAPI.decrypt(encryptedPassword); // Log the decryptedPassword ServiceAPI.getLogger().debug("Decrypted Password is: " + decryptedPassword); }
encryptedString
- - a string that has been encrypted. The encryptedString must not be null.SymmetricCipherException
- if the encryptedString cannot be decrypted