org.fourthline.cling.model.message.control.IncomingActionResponseMessage Java Examples

The following examples show how to use org.fourthline.cling.model.message.control.IncomingActionResponseMessage. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SendingAction.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
protected void handleResponse(IncomingActionResponseMessage responseMsg) throws ActionException {

        try {
            log.fine("Received response for outgoing call, reading SOAP response body: " + responseMsg);
            getUpnpService().getConfiguration().getSoapActionProcessor().readBody(responseMsg, actionInvocation);
        } catch (UnsupportedDataException ex) {
            log.fine("Error reading SOAP body: " + ex);
            log.log(Level.FINE, "Exception root cause: ", Exceptions.unwrap(ex));
            throw new ActionException(
                ErrorCode.ACTION_FAILED,
                "Error reading SOAP response message. " + ex.getMessage(),
                false
            );
        }
    }
 
Example #2
Source File: SendingAction.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
protected void handleResponseFailure(IncomingActionResponseMessage responseMsg) throws ActionException {

        try {
            log.fine("Received response with Internal Server Error, reading SOAP failure message");
            getUpnpService().getConfiguration().getSoapActionProcessor().readBody(responseMsg, actionInvocation);
        } catch (UnsupportedDataException ex) {
            log.fine("Error reading SOAP body: " + ex);
            log.log(Level.FINE, "Exception root cause: ", Exceptions.unwrap(ex));
            throw new ActionException(
                ErrorCode.ACTION_FAILED,
                "Error reading SOAP response failure message. " + ex.getMessage(),
                false
            );
        }
    }
 
Example #3
Source File: SendingAction.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
protected void handleResponse(IncomingActionResponseMessage responseMsg) throws ActionException {

        try {
            log.fine("Received response for outgoing call, reading SOAP response body: " + responseMsg);
            getUpnpService().getConfiguration().getSoapActionProcessor().readBody(responseMsg, actionInvocation);
        } catch (UnsupportedDataException ex) {
            log.fine("Error reading SOAP body: " + ex);
            log.log(Level.FINE, "Exception root cause: ", Exceptions.unwrap(ex));
            throw new ActionException(
                ErrorCode.ACTION_FAILED,
                "Error reading SOAP response message. " + ex.getMessage(),
                false
            );
        }
    }
 
Example #4
Source File: SendingAction.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
protected void handleResponseFailure(IncomingActionResponseMessage responseMsg) throws ActionException {

        try {
            log.fine("Received response with Internal Server Error, reading SOAP failure message");
            getUpnpService().getConfiguration().getSoapActionProcessor().readBody(responseMsg, actionInvocation);
        } catch (UnsupportedDataException ex) {
            log.fine("Error reading SOAP body: " + ex);
            log.log(Level.FINE, "Exception root cause: ", Exceptions.unwrap(ex));
            throw new ActionException(
                ErrorCode.ACTION_FAILED,
                "Error reading SOAP response failure message. " + ex.getMessage(),
                false
            );
        }
    }
 
Example #5
Source File: ClingPortMappingExtractor.java    From portmapper with GNU General Public License v3.0 5 votes vote down vote up
private void handleFailureResponse(final IncomingActionResponseMessage incomingActionResponseMessage) {
    if (isNoMoreMappingsException(incomingActionResponseMessage)) {
        moreEntries = false;
        logger.debug("Got no port mapping for entry number {} (status: {}). Stop getting more entries.",
                currentMappingNumber, incomingActionResponseMessage.getOperation().getStatusMessage());
    } else {
        moreEntries = false;
        logger.info(
                "Got error response when fetching port mapping for entry number {}: '{}'. Stop getting more entries.",
                currentMappingNumber, incomingActionResponseMessage);
    }
}
 
Example #6
Source File: SendingAction.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
protected IncomingActionResponseMessage executeSync() throws RouterException {
    return invokeRemote(getInputMessage());
}
 
Example #7
Source File: ActionCallback.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
public void run() {
    Service service = actionInvocation.getAction().getService();

    // Local execution
    if (service instanceof LocalService) {
        LocalService localService = (LocalService)service;

        // Executor validates input inside the execute() call immediately
        localService.getExecutor(actionInvocation.getAction()).execute(actionInvocation);

        if (actionInvocation.getFailure() != null) {
            failure(actionInvocation, null);
        } else {
            success(actionInvocation);
        }

    // Remote execution
    } else if (service instanceof RemoteService){

        if (getControlPoint()  == null) {
            throw new IllegalStateException("Callback must be executed through ControlPoint");
        }

        RemoteService remoteService = (RemoteService)service;

        // Figure out the remote URL where we'd like to send the action request to
        URL controLURL = remoteService.getDevice().normalizeURI(remoteService.getControlURI());

        // Do it
        SendingAction prot = getControlPoint().getProtocolFactory().createSendingAction(actionInvocation, controLURL);
        prot.run();

        IncomingActionResponseMessage response = prot.getOutputMessage();

        if (response == null) {
            failure(actionInvocation, null);
        } else if (response.getOperation().isFailed()) {
            failure(actionInvocation, response.getOperation());
        } else {
            success(actionInvocation);
        }
    }
}
 
Example #8
Source File: SendingAction.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
protected IncomingActionResponseMessage executeSync() throws RouterException {
    return invokeRemote(getInputMessage());
}
 
Example #9
Source File: ActionCallback.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
public void run() {
    Service service = actionInvocation.getAction().getService();

    // Local execution
    if (service instanceof LocalService) {
        LocalService localService = (LocalService)service;

        // Executor validates input inside the execute() call immediately
        localService.getExecutor(actionInvocation.getAction()).execute(actionInvocation);

        if (actionInvocation.getFailure() != null) {
            failure(actionInvocation, null);
        } else {
            success(actionInvocation);
        }

    // Remote execution
    } else if (service instanceof RemoteService){

        if (getControlPoint()  == null) {
            throw new IllegalStateException("Callback must be executed through ControlPoint");
        }

        RemoteService remoteService = (RemoteService)service;

        // Figure out the remote URL where we'd like to send the action request to
        URL controLURL = remoteService.getDevice().normalizeURI(remoteService.getControlURI());

        // Do it
        SendingAction prot = getControlPoint().getProtocolFactory().createSendingAction(actionInvocation, controLURL);
        prot.run();

        IncomingActionResponseMessage response = prot.getOutputMessage();

        if (response == null) {
            failure(actionInvocation, null);
        } else if (response.getOperation().isFailed()) {
            failure(actionInvocation, response.getOperation());
        } else {
            success(actionInvocation);
        }
    }
}
 
Example #10
Source File: ClingOperationFailedException.java    From portmapper with GNU General Public License v3.0 4 votes vote down vote up
public ClingOperationFailedException(final String message, final IncomingActionResponseMessage response) {
    super(message);
    assert response.getOperation().isFailed();
    this.response = response;
}
 
Example #11
Source File: ClingOperationFailedException.java    From portmapper with GNU General Public License v3.0 4 votes vote down vote up
public IncomingActionResponseMessage getResponse() {
    return response;
}
 
Example #12
Source File: ClingPortMappingExtractor.java    From portmapper with GNU General Public License v3.0 3 votes vote down vote up
/**
 * This method checks, if the error code of the given exception means, that no more mappings are available.
 * <p>
 * The following error codes are recognized:
 * <ul>
 * <li>SpecifiedArrayIndexInvalid: 713</li>
 * <li>NoSuchEntryInArray: 714</li>
 * <li>Invalid Args: 402 (e.g. for DD-WRT, TP-LINK TL-R460 firmware 4.7.6 Build 100714 Rel.63134n)</li>
 * <li>Other errors, e.g. "The reference to entity "T" must end with the ';' delimiter" or
 * "Content is not allowed in prolog": 899 (e.g. ActionTec MI424-WR, Thomson TWG850-4U)</li>
 * </ul>
 * See bug reports
 * <ul>
 * <li><a href= "https://sourceforge.net/tracker/index.php?func=detail&aid=1939749&group_id=213879&atid=1027466" >
 * https://sourceforge.net/tracker/index.php?func=detail&aid= 1939749&group_id=213879&atid=1027466</a></li>
 * <li><a href="http://www.sbbi.net/forum/viewtopic.php?p=394">http://www.sbbi .net/forum/viewtopic.php?p=394</a>
 * </li>
 * <li><a href= "http://sourceforge.net/tracker/?func=detail&atid=1027466&aid=3325388&group_id=213879" >http://
 * sourceforge.net/tracker/?func=detail&atid=1027466&aid=3325388& group_id=213879</a></li>
 * <a href= "https://sourceforge.net/tracker2/?func=detail&aid=2540478&group_id=213879&atid=1027466" >https://
 * sourceforge.net/tracker2/?func=detail&aid=2540478&group_id= 213879&atid=1027466</a></li>
 * </ul>
 *
 * @param incomingActionResponseMessage
 *            the exception to check
 * @return <code>true</code>, if the given exception means, that no more port mappings are available, else
 *         <code>false</code>.
 */
private boolean isNoMoreMappingsException(final IncomingActionResponseMessage incomingActionResponseMessage) {
    final int errorCode = incomingActionResponseMessage.getOperation().getStatusCode();
    switch (errorCode) {
    case 713:
    case 714:
    case 402:
    case 899:
        return true;

    default:
        return false;
    }
}