Author Topic: CancelRecord with Platform SDK for 8.1  (Read 2876 times)

Offline Calomar

  • Newbie
  • *
  • Posts: 1
  • Karma: 0
CancelRecord with Platform SDK for 8.1
« on: September 24, 2014, 07:42:38 AM »
Hello, We are trying to cancel a record from java third party application, but it doesn’t work. The record is ready after the execution and we can’t see in the ocs log any event with the cancellation

Can you send us a code example?

  public static boolean cancelRecord(long tsid, String clientName, Integer appId, String callingList, String campaign, String phone) {

      boolean result = false;

      if (LOG.isDebugEnabled()) {
          LOG.debug(tsid + " Cancelling record: ");
          LOG.debug(tsid + " clientName: " + clientName);
          LOG.debug(tsid + " appId: " + appId);
          LOG.debug(tsid + " callingList: " + callingList);
          LOG.debug(tsid + " campaign: " + campaign);
          LOG.debug(tsid + "  phone: " + phone);
      }

      try {
          URI uri = new URI("tcp://" + PropertiesConf.getHostOCSGen() + ":" + PropertiesConf.getPortOCSGen());
          // ExternalServiceProtocol protocol = new
          // ExternalServiceProtocol(new Endpoint(uri));
          TServerProtocol protocol = new TServerProtocol(new Endpoint("es1_des_SIPServer_8.1.101.38", "ES1AIOODES02", 3000));

          LOG.debug(tsid + " Abriendo protocolo..." + uri);

          protocol.setClientName(clientName);

          protocol.open();

          LOG.debug(tsid + " Protocolo abierto");

          OutboundDesktopFactory factory = new OutboundDesktopFactory();
          RequestRecordCancel requestRecordCancel = new RequestRecordCancel();

          requestRecordCancel.setApplicationId(appId);
          requestRecordCancel.setCallingList(callingList);
          requestRecordCancel.setCampaignName(campaign);
          requestRecordCancel.setPhone(phone);

          CommonProperties userEvent = CommonProperties.create();
          userEvent.setUserData(factory.marshal(requestRecordCancel));

          RequestDistributeUserEvent request = RequestDistributeUserEvent.create();
          request.setUserEvent(userEvent);

          try {

            protocol.send(request);

            Thread.sleep(2000);
            protocol.close();
            LOG.debug(tsid + " Protocolo cerrado");
            result = true;
          } catch (ProtocolException e) {
            LOG.error(tsid + " " + WSResponse.CONNECTION_LOST + " - " + e.getMessage(), e);
          } catch (IllegalStateException ex) {
            LOG.error(tsid + " " + WSResponse.CONNECTION_LOST + " - " + ex.getMessage(), ex);
          } finally {
            if (!protocol.getState().equals(com.genesyslab.platform.commons.protocol.ChannelState.Closed)) {
                protocol.close();
            }
          }
      } catch (Exception e) {
          LOG.error(tsid + " " + WSResponse.CONNECTION_LOST + " - " + e.getMessage(), e);
      }

      return result;
    }


Regards.

Offline Fra

  • Hero Member
  • *****
  • Posts: 856
  • Karma: -3
Re: CancelRecord with Platform SDK for 8.1
« Reply #1 on: September 24, 2014, 08:23:52 AM »
In order for OCS to process requests from a third-party application, it's necessary to set up a connection between them: have you done that in CME in either OCS or the third-party application?

Also, remember to include both the OriginAppDBID and the TargetAppDBID as attributes of the request.

Fra