# Collector

The Collector resource encapsulates a single instance of a digit collecting resource. This resource defines the source MediaStream for the collecting operation, the state of the collection process, and a digit mask used during digit detection.

## XML Definition

<collector identifier="<identifier>" appid="<appid>"
href=http://server/dialogicwebservice/mediacontrol/collectors/<identifier>
streamidentifier="<stream identifier>"
conferenceidentifier="<conference identifier>"
digits="<digits>" cpa="<cpa>" cpa_mask="<cpa_mask>" />
</collector>

## Collector Properties

Name | Description | Type | Input / Output | Optional / Mandatory
identifier | Unique identifier assigned to the specific instance of the resource. This identifier is used by the web service client when performing actions on the resource. | String | Output | N/A
appid | Unique application id included in the original HTTP POST creation process that is utilized by the web service such that clients only have access to resources that they created. | String | Output | N/A
href | An HTTP reference to the specific resource. | String | Output | N/A
streamidentifier | Unique identifier of the MediaStream that is being used for digit detection. | String | Input / Output | Mandatory if the conference identifier is not being set
conferenceidentifier | Unique identifier of the Conference that is being used for digit detection. | String | Input / Output | Mandatory if the stream identifier is not being set
digits | Changes the reporting of DTMF digit events. Under normal usage, standard is the preferred option. Values: both, standard, long, no Default: standard | String | Input / Output | Optional
cpa | Enables or disables reporting of Call Progress events described in the cpa_mask. Values: yes, no. Default: no | String | Input / Output | Optional
cpa_mask | A list of cpa events to be reported: interrupt, ring, busy, dial, CNG, CED, 400, PVD, PAMD] | String | Input / Output | Mandatory if cpa is yes.

##
Interaction Diagram

### Collector Creation

The following diagram illustrates the Collector creation process.

### Collector Deletion

The following diagram illustrates the Collector deletion process.

## Java Sample Code

public void CreateCollector(String destIdentifier, IdentifierType type) {
logger.info("Collector:: CreateCollector - Entered.");
//Create a HttpURLConnection with the correct server
//Send request to create collector and retrieve response
String response = "";
String identifierText = "streamidentifier";
if (type == IdentifierType.CONFERENCE) {
identifierText = "conferenceidentifier";
}
String requestBody = "<collector " +
identifierText +
"=\"" +
destIdentifier +
"\" " +
">" +
"</collector>";
HttpURLConnection connection = utils.SendHTTPRequest("http://" + MainSipServlet.WMSHost + ":81/DialogicWebService/mediacontrol/collectors",
"POST",
requestBody);
if (connection != null) {
response = utils.GetHTTPStringResponse(connection);
}
//Retrieve response codes
int responseCode = 0;
try {
responseCode = connection.getResponseCode();
} catch (IOException ex) {
Logger.getLogger(Collector.class.getName()).log(Level.SEVERE, null, ex);
}
String responseMessage = "";
try {
responseMessage = connection.getResponseMessage();
} catch (IOException ex) {
Logger.getLogger(Collector.class.getName()).log(Level.SEVERE, null, ex);
}
String responseLocation = connection.getHeaderField("location");
//close the connection
connection.disconnect();
//log results
logger.info("Collector:: CreateCollector - Http response code =" + responseCode);
logger.info("Collector:: CreateCollector - Http response message =" + responseMessage);
logger.info("Collector:: CreateCollector - Http response location =" + responseLocation);
if (responseCode == 201) {
collectorRef = responseLocation;
int index = collectorRef.lastIndexOf("/collectors", collectorRef.length());
resourceId = collectorRef.substring(index+12);
logger.info("Collector:: CreateCollector - Resource Id = " + resourceId);
eventMonitor.AddCollector(this);
}
logger.info("Collector:: CreateCollector - Exited.");
}