示例#1
0
  /**
   * sets up a gmpls connection through the gmpls web service.
   *
   * @param gmplsConnection connection to be established
   * @return true if connection could be established
   * @throws InvalidRequestFaultException request was not valid
   * @throws SoapFault should not happen
   */
  public static int setUpConnection(final GmplsConnection gmplsConnection) throws SoapFault {
    AJaxbSerializer jserGmpls =
        org.opennaas.extensions.gmpls.serviceinterface.databinding.utils.JaxbSerializer
            .getInstance();
    try {
      gmplsConnection.setStatus(StatusType.SETUP_IN_PROGRESS);
      DbManager.updateStatus(gmplsConnection, "Trying to setup the Connection");
    } catch (UnexpectedFaultException e1) {
      e1.printStackTrace();
    }
    final CreatePathResponse response =
        (CreatePathResponse)
            jserGmpls.elementToObject(
                ContextListener.getGmplsWS()
                    .createPath(jserGmpls.objectToElement(gmplsConnection.getCreatePathRequest())));
    CreatePathResponseType resp = response.getCreatePathResponse();
    gmplsConnection.setPathId(resp.getPathIdentifier().getPathIdentifier());
    gmplsConnection.setStatus(StatusType.ACTIVE);

    DbManager.updatePathId(gmplsConnection);
    DbManager.updateStatus(gmplsConnection, "PathId is " + gmplsConnection.getPathId());
    Notifications.subscribe(gmplsConnection.getPathId());
    return gmplsConnection.getPathId();
  }