예제 #1
0
  public String getUPnPErrorDescription() {
    Node errorDescNode = getUPnPErrorDescriptionNode();

    if (errorDescNode == null) {
      return "";
    }

    return errorDescNode.getValue();
  }
예제 #2
0
  private Node getUPnPErrorDescriptionNode() {
    Node errorNode = getUPnPErrorNode();

    if (errorNode == null) {
      return null;
    }

    return errorNode.getNodeEndsWith(SOAP.ERROR_DESCRIPTION);
  }
예제 #3
0
  private Node getUPnPErrorCodeNode() {
    Node errorNode = getUPnPErrorNode();

    if (errorNode == null) {
      return null;
    }

    return errorNode.getNodeEndsWith(SOAP.ERROR_CODE);
  }
예제 #4
0
  private Node getUPnPErrorNode() {
    Node detailNode = getFaultDetailNode();

    if (detailNode == null) {
      return null;
    }

    return detailNode.getNodeEndsWith(SOAP.UPNP_ERROR);
  }
예제 #5
0
  ////////////////////////////////////////////////
  // FaultResponse
  ////////////////////////////////////////////////
  public void setFaultResponse(int errCode, String errDescr) {
    setStatusCode(HTTPStatus.INTERNAL_SERVER_ERROR);

    Node bodyNode = getBodyNode();
    Node faultNode = createFaultResponseNode(errCode, errDescr);

    bodyNode.addNode(faultNode);

    Node envNode = getEnvelopeNode();

    setContent(envNode);
  }
예제 #6
0
  public int getUPnPErrorCode() {
    Node errorCodeNode = getUPnPErrorCodeNode();

    if (errorCodeNode == null) {
      return -1;
    }

    String errorCodeStr = errorCodeNode.getValue();

    try {
      return Integer.parseInt(errorCodeStr);
    } catch (Exception e) {
      return -1;
    }
  }
예제 #7
0
  ////////////////////////////////////////////////
  // createFaultResponseNode
  ////////////////////////////////////////////////
  private Node createFaultResponseNode(int errCode, String errDescr) {

    // <s:Fault>
    Node faultNode = new Node(SOAP.XMLNS + SOAP.DELIM + SOAP.FAULT);

    // <faultcode>s:Client</faultcode>
    Node faultCodeNode = new Node(SOAP.FAULT_CODE);

    faultCodeNode.setValue(SOAP.XMLNS + SOAP.DELIM + FAULT_CODE);
    faultNode.addNode(faultCodeNode);

    // <faultstring>UPnPError</faultstring>
    Node faultStringNode = new Node(SOAP.FAULT_STRING);

    faultStringNode.setValue(FAULT_STRING);
    faultNode.addNode(faultStringNode);

    // <detail>
    Node detailNode = new Node(SOAP.DETAIL);

    faultNode.addNode(detailNode);

    // <UPnPError xmlns="urn:schemas-upnp-org:control-1-0">
    Node upnpErrorNode = new Node(FAULT_STRING);

    upnpErrorNode.setAttribute("xmlns", Control.XMLNS);
    detailNode.addNode(upnpErrorNode);

    // <errorCode>error code</errorCode>
    Node errorCodeNode = new Node(SOAP.ERROR_CODE);

    errorCodeNode.setValue(errCode);
    upnpErrorNode.addNode(errorCodeNode);

    // <errorDescription>error string</errorDescription>
    Node errorDesctiprionNode = new Node(SOAP.ERROR_DESCRIPTION);

    errorDesctiprionNode.setValue(errDescr);
    upnpErrorNode.addNode(errorDesctiprionNode);

    return faultNode;
  }