com.alarmpoint.servicemanager
Class ServiceManagerScriptObject

java.lang.Object
  extended by com.alarmpoint.servicemanager.ServiceManagerScriptObject

public class ServiceManagerScriptObject
extends java.lang.Object

Interfaces with the Service Manager SOAP web service in order to query, create and update records.

Author:
bneate

Constructor Summary
ServiceManagerScriptObject()
          Construct a uninitialised object.
ServiceManagerScriptObject(java.lang.String url, java.lang.String user, java.lang.String password)
          Construct a new ServiceManagerScriptObject with the specified url and user/password combination
 
Method Summary
 void closeIncident(java.lang.String incidentId, org.dom4j.Element instance)
          Close the Service Manager incident identified by the incidentID with the specified instance
 void closeIncident(java.lang.String incidentId, java.util.Map<java.lang.String,java.lang.Object> fields)
          Close the Service Manager incident identified by the incidentID with the specified fields and values
 void closeIncident(java.lang.String incidentId, java.lang.String resolution, java.lang.String fixType)
          Close the Service Manager incident identified by the incidentID with a resolution
 java.lang.String createIncident(org.dom4j.Element instance)
          Create a new Service Manager incident with the specified instance
 java.lang.String createIncident(java.util.Map<java.lang.String,java.lang.Object> fields)
          Create a new Service Manager incident with the specified fields and values
 java.util.Map<java.lang.String,java.util.Collection<java.lang.String>> getGroupedList(java.lang.String operation, java.lang.String queryString, java.lang.String valueElement, java.lang.String groupElement)
          Retrive a list of strings from Service Manager and group them based on a field on that object
 java.util.SortedSet<java.lang.String> getSortedList(java.lang.String operation, java.lang.String queryString, java.lang.String elementName)
          Retrive a list of strings from Service Manager
 java.util.Collection<java.util.Map<java.lang.String,java.lang.String>> getValueMap(java.lang.String operation, java.lang.String queryString)
          Retrive a list of all fields and values from Service Manager for a specified object
 void initializeClient(java.lang.String url, java.lang.String user, java.lang.String password)
          Initialize this class with the specified url and user/password combination
 java.util.SortedSet<java.lang.String> queryCategoryList()
          Retrieve the list of active categories from Service Manager
 java.util.List<ServiceManagerIncident> queryIncident(ServiceManagerQuery query)
          Retrieve a list of incidents from Service Manager
 java.util.List<ServiceManagerIncident> queryIncident(java.lang.String queryString)
          Retrieve a list of incidents from Service Manager
 java.util.SortedSet<java.lang.String> queryProblemTypeList()
          Retrieve the list of active problem types from Service Manager
 java.util.SortedSet<java.lang.String> queryProductTypeList()
          Retrieve the list of active product types from Service Manager
 java.util.SortedSet<java.lang.String> querySubcategoryList()
          Retrieve the list of active subcategories from Service Manager
 void resolveIncident(java.lang.String incidentId, org.dom4j.Element instance)
          Resolve the Service Manager incident identified by the incidentID with the specified instance
 void resolveIncident(java.lang.String incidentId, java.lang.String resolution, java.lang.String fixType, java.lang.String message, java.lang.String closureCode)
          Resolve the Service Manager incident identified by the incidentID with the specified fields and values
 org.dom4j.Node sendReceive(java.lang.String action, org.dom4j.Element payload)
          Send a SOAP request to the Service Manager server and return the contents ot the returned SOAP body
 void updateIncident(java.lang.String incidentId, org.dom4j.Element instance)
          Update the Service Manager incident identified by the incidentID with the specified instance
 void updateIncident(java.lang.String incidentId, java.util.Map<java.lang.String,java.lang.Object> fields)
          Update the Service Manager incident identified by the incidentID with the specified fields and values
 void updateIncident(java.lang.String incidentId, java.lang.String message)
          Update the Service Manager incident identified by the incidentID with a journal update
 void updateIncident(java.lang.String incidentId, java.lang.String message, java.lang.String status)
          Update the Service Manager incident identified by the incidentID with a journal update and status
 void updateIncident(java.lang.String incidentId, java.lang.String message, java.lang.String status, java.lang.String assignee)
          Update the Service Manager incident identified by the incidentID with a journal update, status and assignee
 java.lang.String validateCredentials(java.lang.String operation)
          Given a List Operation this method will return null if the intialized credentials are valid and a string detailing the error otherwise
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServiceManagerScriptObject

public ServiceManagerScriptObject()
Construct a uninitialised object. Make sure to run the initializeClient method before you use it


ServiceManagerScriptObject

public ServiceManagerScriptObject(java.lang.String url,
                                  java.lang.String user,
                                  java.lang.String password)
Construct a new ServiceManagerScriptObject with the specified url and user/password combination

Parameters:
url - The url of the Service Manager web services
user - The username to use for the Service Manager web services
password - The password to use for the Service Manager web services
Method Detail

initializeClient

public void initializeClient(java.lang.String url,
                             java.lang.String user,
                             java.lang.String password)
Initialize this class with the specified url and user/password combination

Parameters:
url - the url of the Service Manager web services
user - the user for the Service Manager web services
password - the password for the Service Manager web services

createIncident

public java.lang.String createIncident(java.util.Map<java.lang.String,java.lang.Object> fields)
                                throws ServiceManagerException
Create a new Service Manager incident with the specified fields and values
 Note: This method assumes that a extaccess record exists with the following values:
   Name: probsummary
   Object Name: Incident
   Data Policy:
     number field must have the IncidentID API Caption and Exclude false
 

Parameters:
fields - The Map used to construct the instance XML element
Throws:
ServiceManagerException - if a error occurs with a message detailing that error

createIncident

public java.lang.String createIncident(org.dom4j.Element instance)
                                throws ServiceManagerException
Create a new Service Manager incident with the specified instance
 Note: This method assumes that a extaccess record exists with the following values:
   Name: probsummary
   Object Name: Incident
   Data Policy:
     number field must have the IncidentID API Caption and Exclude false
 

Parameters:
instance - the XML instance element for the create request
Throws:
ServiceManagerException - if a error occurs with a message detailing that error

updateIncident

public void updateIncident(java.lang.String incidentId,
                           java.lang.String message)
                    throws ServiceManagerException
Update the Service Manager incident identified by the incidentID with a journal update
 Note: This method assumes that a extaccess record exists with the following values:
   Name: probsummary
   Object Name: Incident
   Data Policy:
     number field must have the IncidentID API Caption and Exclude false
     update.action field must have the JournalUpdates API Caption and Exclude false
 

Parameters:
incidentId - incident id identifying the incident to update
message - The message to be added to the JournalUpdates
Throws:
ServiceManagerException - if the update was not successful

updateIncident

public void updateIncident(java.lang.String incidentId,
                           java.lang.String message,
                           java.lang.String status)
                    throws ServiceManagerException
Update the Service Manager incident identified by the incidentID with a journal update and status
 Note: This method assumes that a extaccess record exists with the following values:
   Name: probsummary
   Object Name: Incident
   Data Policy:
     number field must have the IncidentID API Caption and Exclude false
     update.action field must have the JournalUpdates API Caption and Exclude false
     problem.status field must have the IMTicketStatus API Caption and Exclude false
 

Parameters:
incidentId - incident id identifying the incident to update
message - The message to be added to the JournalUpdates
status - The status to update the incident with
Throws:
ServiceManagerException - if the update was not successful

updateIncident

public void updateIncident(java.lang.String incidentId,
                           java.lang.String message,
                           java.lang.String status,
                           java.lang.String assignee)
                    throws ServiceManagerException
Update the Service Manager incident identified by the incidentID with a journal update, status and assignee
 Note: This method assumes that a extaccess record exists with the following values:
   Name: probsummary
   Object Name: Incident
   Data Policy:
     number field must have the IncidentID API Caption and Exclude false
     update.action field must have the JournalUpdates API Caption and Exclude false
     problem.status field must have the IMTicketStatus API Caption and Exclude false
     assignee.name field must have the AssigneeName API Caption and Exclude false
 

Parameters:
incidentId - incident id identifying the incident to update
message - The message to be added to the JournalUpdates
status - The status to update the incident with
assignee - The assignee to update the incident with
Throws:
ServiceManagerException - if the update was not successful

updateIncident

public void updateIncident(java.lang.String incidentId,
                           java.util.Map<java.lang.String,java.lang.Object> fields)
                    throws ServiceManagerException
Update the Service Manager incident identified by the incidentID with the specified fields and values
 Note: This method assumes that a extaccess record exists with the following values:
   Name: probsummary
   Object Name: Incident
   Data Policy:
     number field must have the IncidentID API Caption and Exclude false
 

Parameters:
incidentId - incident id identifying the incident to update
fields - The Map used to construct the instance XML element
Throws:
ServiceManagerException - if a error occurs with a message detailing that error

updateIncident

public void updateIncident(java.lang.String incidentId,
                           org.dom4j.Element instance)
                    throws ServiceManagerException
Update the Service Manager incident identified by the incidentID with the specified instance
 Note: This method assumes that a extaccess record exists with the following values:
   Name: probsummary
   Object Name: Incident
   Data Policy:
     number field must have the IncidentID API Caption and Exclude false
 

Parameters:
incidentId - incident id identifying the incident to update
instance - the XML instance element for the update request
Throws:
ServiceManagerException - if a error occurs with a message detailing that error

resolveIncident

public void resolveIncident(java.lang.String incidentId,
                            java.lang.String resolution,
                            java.lang.String fixType,
                            java.lang.String message,
                            java.lang.String closureCode)
                     throws ServiceManagerException
Resolve the Service Manager incident identified by the incidentID with the specified fields and values
 Note: This method assumes that a extaccess record exists with the following values:
   Name: probsummary
   Object Name: Incident
   Data Policy:
     number field must have the IncidentID API Caption and Exclude false
 

Parameters:
incidentId - incident id identifying the incident to resolve
resolution - String containing the text detailing the resolution code
fixType - type of fix being applied
message - additional information
closureCode - String containing the code that will be displayed in SM indicating the closure reason.
Throws:
ServiceManagerException - if a error occurs with a message detailing that error

resolveIncident

public void resolveIncident(java.lang.String incidentId,
                            org.dom4j.Element instance)
                     throws ServiceManagerException
Resolve the Service Manager incident identified by the incidentID with the specified instance
 Note: This method assumes that a extaccess record exists with the following values:
   Name: probsummary
   Object Name: Incident
   Data Policy:
     number field must have the IncidentID API Caption and Exclude false
 

Parameters:
incidentId - incident id identifying the incident to resolve
instance - the XML instance element for the resolve request
Throws:
ServiceManagerException - if a error occurs with a message detailing that error

closeIncident

public void closeIncident(java.lang.String incidentId,
                          java.lang.String resolution,
                          java.lang.String fixType)
                   throws ServiceManagerException
Close the Service Manager incident identified by the incidentID with a resolution
 Note: This method assumes that a extaccess record exists with the following values:
   Name: probsummary
   Object Name: Incident
   Data Policy:
     number field must have the IncidentID API Caption and Exclude false
     resolution field must have the Resolution API Caption and Exclude false
 

Parameters:
incidentId - incident id identifying the incident to close
resolution - The message to be added to the Resolution
fixType - Temporary or Permanent
Throws:
ServiceManagerException - if the update was not successful

closeIncident

public void closeIncident(java.lang.String incidentId,
                          java.util.Map<java.lang.String,java.lang.Object> fields)
                   throws ServiceManagerException
Close the Service Manager incident identified by the incidentID with the specified fields and values
 Note: This method assumes that a extaccess record exists with the following values:
   Name: probsummary
   Object Name: Incident
   Data Policy:
     number field must have the IncidentID API Caption and Exclude false
 

Parameters:
incidentId - incident id identifying the incident to close
fields - The Map used to construct the instance XML element
Throws:
ServiceManagerException - if a error occurs with a message detailing that error

closeIncident

public void closeIncident(java.lang.String incidentId,
                          org.dom4j.Element instance)
                   throws ServiceManagerException
Close the Service Manager incident identified by the incidentID with the specified instance
 Note: This method assumes that a extaccess record exists with the following values:
   Name: probsummary
   Object Name: Incident
   Data Policy:
     number field must have the IncidentID API Caption and Exclude false
 

Parameters:
incidentId - incident id identifying the incident to close
instance - the XML instance element for the close request
Throws:
ServiceManagerException - if a error occurs with a message detailing that error

queryIncident

public java.util.List<ServiceManagerIncident> queryIncident(ServiceManagerQuery query)
                                                     throws ServiceManagerException
Retrieve a list of incidents from Service Manager
 Note: This method assumes that a extaccess record exists with the following values:
   Name: probsummary
   Object Name: Incident
 

Parameters:
query - A ServiceManagerQuery object used to construct the Service Manager query
Returns:
A list of ServiceManagerIncident objects representing the incidents retrieved from Service Manager
Throws:
ServiceManagerException - if a error occurs with a message detailing that error

queryIncident

public java.util.List<ServiceManagerIncident> queryIncident(java.lang.String queryString)
                                                     throws ServiceManagerException
Retrieve a list of incidents from Service Manager
 Note: This method assumes that a extaccess record exists with the following values:
   Name: probsummary
   Object Name: Incident
 

Parameters:
queryString - The search query passed to Service Manager
Returns:
A list of ServiceManagerIncident objects representing the incidents retrieved from Service Manager
Throws:
ServiceManagerException - if a error occurs with a message detailing that error

queryCategoryList

public java.util.SortedSet<java.lang.String> queryCategoryList()
Retrieve the list of active categories from Service Manager
 Note: This method assumes that a extaccess record exists with the following values:
   Name: category
   Object Name: Category
   Data Policy:
     name field must have the name API Caption and Exclude false
 

Returns:
A SortedSet of Service Manager categories if the request succeeded or a empty list otherwise

querySubcategoryList

public java.util.SortedSet<java.lang.String> querySubcategoryList()
Retrieve the list of active subcategories from Service Manager
 Note: This method assumes that a extaccess record exists with the following values:
   Name: subcategory
   Object Name: Subcategory
   Data Policy:
     subcategory field must have the subcategory API Caption and Exclude false
 

Returns:
A SortedSet of Service Manager subcategories if the request succeeded or a empty list otherwise

queryProblemTypeList

public java.util.SortedSet<java.lang.String> queryProblemTypeList()
Retrieve the list of active problem types from Service Manager
 Note: This method assumes that a extaccess record exists with the following values:
   Name: problemtype
   Object Name: ProblemType
   Data Policy:
     problem.type field must have the problem.type API Caption and Exclude false
 

Returns:
A SortedSet of Service Manager problem types if the request succeeded or a empty list otherwise

queryProductTypeList

public java.util.SortedSet<java.lang.String> queryProductTypeList()
Retrieve the list of active product types from Service Manager
 Note: This method assumes that a extaccess record exists with the following values:
   Name: producttype
   Object Name: ProductType
   Data Policy:
     product.type field must have the product.type API Caption and Exclude false
 

Returns:
A SortedSet of Service Manager product types if the request succeeded or a empty list otherwise

getSortedList

public java.util.SortedSet<java.lang.String> getSortedList(java.lang.String operation,
                                                           java.lang.String queryString,
                                                           java.lang.String elementName)
                                                    throws ServiceManagerException
Retrive a list of strings from Service Manager

Parameters:
operation - The name of the root element of the request ("RetrieveCategoryListRequest" for example)
queryString - The query used to select the values
elementName - the API Caption of the field to return the values for
Returns:
A list of strings retrieved from Service Manager
Throws:
ServiceManagerException - if a error occurs with a message detailing that error

getValueMap

public java.util.Collection<java.util.Map<java.lang.String,java.lang.String>> getValueMap(java.lang.String operation,
                                                                                          java.lang.String queryString)
                                                                                   throws ServiceManagerException
Retrive a list of all fields and values from Service Manager for a specified object

Parameters:
operation - The name of the root element of the request ("RetrieveCategoryListRequest" for example)
queryString - The query used to select the values
Returns:
A list of maps where the key is the field name and the value is the field value
Throws:
ServiceManagerException - if a error occurs with a message detailing that error

getGroupedList

public java.util.Map<java.lang.String,java.util.Collection<java.lang.String>> getGroupedList(java.lang.String operation,
                                                                                             java.lang.String queryString,
                                                                                             java.lang.String valueElement,
                                                                                             java.lang.String groupElement)
                                                                                      throws ServiceManagerException
Retrive a list of strings from Service Manager and group them based on a field on that object

Parameters:
operation - The name of the root element of the request ("RetrieveCategoryListRequest" for example)
queryString - The query used to select the values
valueElement - the API Caption of the field to return the values for
groupElement - the API Caption of the field to group the returned values by
Returns:
A map of strings to a list of strings where the key is the value of the groupElement and the value is list of valueElements associated with the groupElement
Throws:
ServiceManagerException - if a error occurs with a message detailing that error

validateCredentials

public java.lang.String validateCredentials(java.lang.String operation)
                                     throws ServiceManagerException
Given a List Operation this method will return null if the intialized credentials are valid and a string detailing the error otherwise

Parameters:
operation - The name of the root element of the request ("RetrieveCategoryListRequest" for example)
Returns:
null if the validation was successful and a string detailing the error otherwise
Throws:
ServiceManagerException - if a error occurs with a message detailing that error

sendReceive

public org.dom4j.Node sendReceive(java.lang.String action,
                                  org.dom4j.Element payload)
                           throws ServiceManagerException
Send a SOAP request to the Service Manager server and return the contents ot the returned SOAP body

Parameters:
action - The SOAP Action to perform in Service Manager. The possible values are defined on the extaccess table
payload - A dom4j Element that will be the payload of the SOAP request
Returns:
A dom4j Node containing the contents of the returned SOAP body element
Throws:
ServiceManagerException - if a error occurs with a message detailing that error