Wiki

« Back to GatherDigitsTortu...

GatherDigitsTortureChamber-Java

Requirements#

The development machine where you are creating this application should have the following installed.

1. Install JDK 1.5. Version we have used is 1.5.0_15.

2. Eclipse editor. Version we have used is 3.3.2.

3. Install the CUAE Developer Tools to get the etch framework and cuae-tool.

Create the Application Project#

1. Open a Command Prompt.

2. The cuae requires at a minimum the name of the application project, the implementation language (java or csharp), build format (ant or maven2), and the module name to get started. If the language and or the module name are omitted the tool will prompt you for them. Lets use the cuae tool to create a new application.

 C:\> cd Wxp
 C:\Wxp> cuae create GatherDigitsTortureChamber_Java

3. The cuae tool will ask for the type of project that you are creating. Answer application.

Project type? [application or plugin] application

4. The cuae tool will ask for the programming that we will be using for this application. Answer Java.

Programming language? [java or csharp] java

5. The cuae tool will ask for the build format that we will be using for this application. Answer Ant.

Build format? [ant or maven2] ant

6. The cuae tool will ask for the namespace that we will be using for this application. Just press Enter.

 Project namespace? [default: gatherdigitstorturechamber_java]

7. The cuae tool will ask for the application triggering event. For our application, we will be chosing the IncomingCall. Enter 4.

Available application triggering event:
   0: Skip this step
   1: cisco.uc.cuae.legacy.JTapi.JTapiIncomingCall
   2: cisco.uc.cuae.legacy.JTapi.JTapiCallInitiated
   3: cisco.uc.cuae.legacy.JTapi.JTapiCallEstablished
   4: cisco.uc.cuae.legacy.CallControl.IncomingCall
   5: cisco.uc.cuae.legacy.Http.GotRequest
   6: cisco.uc.cuae.legacy.Presence.SubscriptionTerminated
   7: cisco.uc.cuae.legacy.Presence.Notify
   8: cisco.uc.cuae.legacy.TimerFacility.TimerFire
Triggering event? [0-8] 4

8. Now the cuae tool will create the all the necessary files for this application.

 Generating:
    * application named "GatherDigitsTortureChamber_Java"
    * with namespace "gatherdigitstorturechamber_java"
    * with language "java"
    * with trigger event "cisco.uc.cuae.legacy.CallControl.IncomingCall"
    * in location C:\Wxp\
 Created project "GatherDigitsTortureChamber_Java" in directory "C:\Wxp\GatherDigitsTortureChamber_Java\"

9. Now goto C:\Wxp\GatherDigitsTortureChamber_Java folder. Open the file GatherDigitsTortureChamber_Java.etch in a notepad and add the following line "mixin cisco.uc.cuae.legacy.MediaControl" and save the file. We are adding the MediaControl mixin because the application will be playing some prompts. To play these prompts the media engine will be using TTS.

 // CUAE Application Etch Service Definition
 //
 // This service defines your application and the CUAE services that you
 // use in your application.

 // The service module namespace, this will be translated to the
 // namespace of the generated source code.
 module gatherdigitstorturechamber_java

 // The name of your service.
 service GatherDigitsTortureChamber_Java
 {
     // By default, you must always use the EtchBridge service. Do not
     // remove this mixin, otherwise your application won't work.
     mixin cisco.uc.cuae.EtchBridge

     // You may add any additional service mixins that you require. For
     // example, if you'd like to make and receive phone calls, add the
     // following line:
     //     mixin cisco.uc.cuae.legacy.CallControl
         mixin cisco.uc.cuae.legacy.CallControl
	mixin cisco.uc.cuae.legacy.MediaControl

}

10. From the cmd shell goto application directory, run "ant" command to generate source files.

11. Now open Eclipse. Click on File->New->Project

12. Now select "Java Project from Existing Ant BuildFile". Click Next

13. Now Click on the Browse button and select C:\Wxp\GatherDigitsTortureChamber_Java\build.xml. Click on Open.

14. Now Click on "Finish" button to create the Java Project.

15. Basically the above steps generated all the files that are required for the development. Refresh the folder structure in Eclipse by Selecting the project and clicking F5.

16. Modify the String URI in MainGatherDigitsTortureChamber_JavaClient to match the IP address and port of the Cisco Unified Application Server.

URI settings vary slightly between 2.5(1) Beta 1 and more recent versions of 2.5(1), as follows:

2.5(1) and 2.5(1) Beta 2, Beta 3, Beta 4 & later releases#

// TODO Change to correct URI
String uri = "tls://appserver_ipaddress:9000?TlsConnection.authReqd=false&filter=KeepAlive
 &KeepAlive.Count=5&Packetizer.maxPktSize=102400&TcpTransport.reconnectDelay=4000";

Note:

In Beta 2, the Etch Bridge was updated to use Transport Layer Security for encryption by default. For your applications to work, you must specify TLS as the protocol in the URI and set the authReqd parameter to false. In the example above, the Keep Alive filter and MaxPacketSize and Reconnect Delay parameters have also been set.

2.5(1) Beta 1#


// TODO Change to correct URI
		String uri = "tcp://appserver_ipaddress:9000?&TcpConnection.reconnect_delay=4000";

In addition to setting the correct IP address and port for the Cisco Unfied Application Server, the Reconnect Delay parameter should be set on all connection URIs.

17. Also write the below code where the comment "TODO Insert Your Code Here" exists. Provide the administrator credential to access the system

// TODO Insert Your Code Here
// Register application with correct name and partition. Administrator credential required to register.

String key = server.registerApplication("GatherDigitsTortureChamber_Java", "Default", "<username>", "<password>");
System.out.println("GatherDigitsTortureChamber_Java registered with key = " + key);
System.out.println( "Hit any key to exit." );
System.in.read();

18. Now open ImplGatherDigitsTortureChamber_JavaClient.java. Write in the following methods.


// TODO insert methods here to provide implementations of GatherDigitsTortureChamber_JavaClient
// messages from the server.

@Override
public void incomingCall(String sessionId, IncomingCallOptions options)
{
	//Answer call
	AnswerCallResult acResult = server.answerCall(sessionId, options.callId, options.displayName, null);
	if (acResult.returnValue != CuaeResult.SUCCESS)
	{
		System.out.println("AnswerCall failed");
		server.removeCuaeSession(sessionId);
		return;
	}

	//Play the prompt in non-blocking fashion, pass in AnswerCallResult as state info
	String sPrompt1 = "Enter 6 digits within 6 seconds or enter the pound sign to complete this call.";
	PlayResult prResult = server.beginPlay(sessionId, sPrompt1, acResult.connectionId, null, null, null);
	if (prResult.returnValue != CuaeResult.SUCCESS)
	{
		System.out.println("beginPlay failed");
		server.removeCuaeSession(sessionId);
	}
}

@Override
public void onPlayComplete(String sessionId, PlayResult results, Object state)
{

	//Set the values for the GatherDigitsOptions.
	//Basically setting up the options for the various Termination Conditions
	GatherDigitsOptions gdOptions = new GatherDigitsOptions();

	gdOptions.setTermCondDigitPattern("#");
	gdOptions.setTermCondMaxDigits(6l);
	gdOptions.setTermCondMaxTime(6000l);

	GatherDigitsResult gdResult = server.beginGatherDigits(sessionId, results.connectionId, gdOptions, state);

	if (gdResult.returnValue != CuaeResult.SUCCESS)
	{
		System.out.println("GatherDigits failed");
		server.removeCuaeSession(sessionId);
	}
}

@Override
public void onGatherDigitsComplete(String sessionId, GatherDigitsResult results, Object state)
{
	//Play back the digits that the user has entered
	String sPrompt1 = "You have entered " + results.digits;
	PlayResult prResult = server.beginPlay(sessionId, sPrompt1, results.connectionId, null, null, null);
	if (prResult.returnValue != CuaeResult.SUCCESS)
		System.out.println("beginPlay failed");

	server.removeCuaeSession(sessionId);
}

@Override
public void startTx(String sessionId,StartTxOptions options)
{
}

@Override
public void startRx(String sessionId,StartRxOptions options)
{
}

@Override
public void stopTx(String sessionId,StopTxOptions options)
{
}

@Override
public void remoteHangup(String sessionId,RemoteHangupOptions options)
{
}

@Override
public void gotDigits(String sessionId, GotDigitsOptions options)
{
}

Build the Application.#

1. Locate build.xml (left side application tree in IDE) R-Click on the build.xml->Run As->Ant build. You will get the following output.

Buildfile: C:\Wxp\GatherDigitsTortureChamber_Java\build.xml
compileetch:
     [exec] May 16, 2008 5:55:44 PM org.apache.velocity.runtime.log.JdkLogChute log
     [exec] INFO: FileResourceLoader : adding path '.'
     [exec] *** warning: cannot document parameter configs of logWrite
     [exec] May 16, 2008 5:55:45 PM org.apache.velocity.runtime.log.JdkLogChute log
     [exec] INFO: FileResourceLoader : adding path '.'
     [exec] *** warning: cannot document parameter configs of logWrite
copyfile:
copyfile:
   [delete] Deleting: C:\Wxp\GatherDigitsTortureChamber_Java\etch-generated\etch-src\gatherdigitstorturechamber_java\ImplGatherDigitsTortureChamber_JavaClient.java
   [delete] Deleting: C:\Wxp\GatherDigitsTortureChamber_Java\etch-generated\etch-src\gatherdigitstorturechamber_java\MainGatherDigitsTortureChamber_JavaClient.java
init:
     [copy] Copying 3 files to C:\Wxp\GatherDigitsTortureChamber_Java\bin
build:
     [echo] GatherDigitsTortureChamber_Java: C:\Wxp\GatherDigitsTortureChamber_Java\build.xml
    [javac] Compiling 62 source files to C:\Wxp\GatherDigitsTortureChamber_Java\bin
      [jar] Building jar: C:\Wxp\GatherDigitsTortureChamber_Java\dist\GatherDigitsTortureChamber_Java.jar
BUILD SUCCESSFUL
Total time: 9 seconds

2. Now goto the command prompt

 C:\> cd Wxp\GatherDigitsTortureChamber_Java
 C:\Wxp\GatherDigitsTortureChamber_Java>cuae package
 Created package 



file "C:\Wxp\GatherDigitsTortureChamber_Java\bin\GatherDigitsTortureChamber_Java.mca"

3. Installing The Test Application

  • To install the test application on a CUAE server, execute the cuae install command from a DOS command shell in test application parent directory of the test application. The cuae install command varies slightly between 2.5(1) Beta 1 and Beta 2.

2.5(1) Beta 2#

You are prompted to enter an IP address, username, and password (to view the help, run the cuae install -h command). When prompted, enter Y or N to save management settings. This will save the answers to the above three questions in the properties file and remember them the next time you go to install.

Note:

You are also prompted for the communications protocol (TCP or TLS). Select the protocol that is set on the Management Service. TLS is the default supported protocol. If you want to use TCP, follow the instructions in Management Service Transport Layer Security (TLS) to change the default URI of the Management Service before running these commands.

C:\Wxp\GatherDigitsTortureChamber_Java>cuae package
Created package file
"C:\Wxp\GatherDigitsTortureChamber_Java\bin\GatherDigitsTortureChamber_Java.mca"

C:\Wxp\GatherDigitsTortureChamber_Java>cuae install
Enter the hostname or IP address of the management service (for example: localhost, 1.1.1.1): localhost
Protocol: tls
Generated mgmt-service uri: tls://localhost:9001?TlsConnection.authReqd=false
Enter management service login username:
Entermanagement service login password: ********
Save the amanagement settings with the project? [yes or no] no
Application : C:\Wxp\GatherDigitsTortureChamber_Java\bin\GatherDigitsTortureChamber_Java.mca
Uploading :  ===========================> 100%
Application has been installed successfully

2.5(1) Beta 1#

You are prompted to enter an IP address, username, and password (to view the help, run the cuae install -h command). When prompted, enter Y or N to save management settings. This will save the answers to the above three questions in the properties file and remember them the next time you go to install.

C:\Wxp\GatherDigitsTortureChamber_Java>cuae package
Created package file
"C:\Wxp\GatherDigitsTortureChamber_Java\bin\GatherDigitsTortureChamber_Java.mca"

C:\Wxp\GatherDigitsTortureChamber_Java>cuae install
Enter management service uri or host/IP <for example: localhost, tcp://1.1.1.1.:4001>:
Enter management service login username:
Entermanagement service login password: ********
Save the amanagement settings with the project? [YyNn] n
Application : C:\Wxp\GatherDigitsTortureChamber_Java\bin\GatherDigitsTortureChamber_Java.mca
Uploading :  ===========================> 100%
Application ahas been installed successfully

Run the Application.#

1. TO run the application, goto the eclipse editor and R-Click on MainGatherDigitsTortureChamber_JavaClient.java and Select "Run As" -> "Java Application".

At this point the application will remain registered and running until either you stop your application or the application loses connectivity to the Unified Application server.

Place an incomming call to cuae to trigger the application.

0 Attachments
1389 Views
Average (0 Votes)
The average rating is 0.0 stars out of 5.
Comments
No comments yet. Be the first.