cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
450
Views
0
Helpful
2
Replies

CiscoTerminal getDeviceState throws Exception

razaali20
Level 1
Level 1

I am trying to write a simple function to list device states but am getting an exception when I all getDeviceState.

The user that I use has the following only, in both Roles and Groups:

- Standard CTI Allow Control of All Devices

- Standard CTI Enabled

All devices from Available Devices list are moved into Controlled Devices. Available Profiles is empty.

Is there any configuration that needs to be done at the device level, or somewhere else for this to work?

Thanks in advance.

Here is the code:

  JtapiPeer peer = JtapiPeerFactory.getJtapiPeer(null);

  /* connect to the provider */

  String providerString = hostname;

  providerString += ";login=" + login;

  providerString += ";passwd=" + passwd;

  Provider provider = peer.getProvider(providerString);

  CiscoProvider ciscoProvider = (CiscoProvider) provider;

  final Condition inService = new Condition();

  ciscoProvider.addObserver(new ProviderObserver() {

  public void providerChangedEvent (ProvEv [] eventList) {

  if (eventList == null) return;

  for (int i = 0; i < eventList.length; ++i) {

  if (eventList[i] instanceof ProvInServiceEv) {

  inService.set();

  }

  }

  }

  });

  inService.waitTrue();

  Terminal[] terms = ciscoProvider.getTerminals();

  System.out.println ("Found "+ terms.length +"terminals");

  for(int i=0; i< terms.length; i++)

  {

  CiscoTerminal term = (CiscoTerminal)terms[i];

  System.out.println(term);

  try {

  int x = term.getDeviceState();

  System.out.println(x);

  }

  catch (Exception ex) {

  }

  finally {

  }

  Address[] addresses = term.getAddresses();

  System.out.println ("Found "+ addresses.length +"addresses");

  for(int j=0; j< addresses.length; j++)

  {

  CiscoAddress address = (CiscoAddress)addresses[j];

  System.out.println(address);

  }

  }

  provider.shutdown();

2 Replies 2

razaali20
Level 1
Level 1

Forgot to mention the exception:

com.cisco.jtapi.InvalidStateExceptionImpl

You need to add observer on the terminal, wait till the state changes to in-service and then call this API.