Java Code Examples for org.fourthline.cling.support.contentdirectory.DIDLParser#parse()

The following examples show how to use org.fourthline.cling.support.contentdirectory.DIDLParser#parse() . 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: Browse.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
public void success(ActionInvocation invocation) {
    log.fine("Successful browse action, reading output argument values");

    BrowseResult result = new BrowseResult(
            invocation.getOutput("Result").getValue().toString(),
            (UnsignedIntegerFourBytes) invocation.getOutput("NumberReturned").getValue(),
            (UnsignedIntegerFourBytes) invocation.getOutput("TotalMatches").getValue(),
            (UnsignedIntegerFourBytes) invocation.getOutput("UpdateID").getValue()
    );

    boolean proceed = receivedRaw(invocation, result);

    if (proceed && result.getCountLong() > 0 && result.getResult().length() > 0) {

        try {

            DIDLParser didlParser = new DIDLParser();
            DIDLContent didl = didlParser.parse(result.getResult());
            received(invocation, didl);
            updateStatus(Status.OK);

        } catch (Exception ex) {
            invocation.setFailure(
                    new ActionException(ErrorCode.ACTION_FAILED, "Can't parse DIDL XML response: " + ex, ex)
            );
            failure(invocation, null);
        }

    } else {
        received(invocation, new DIDLContent());
        updateStatus(Status.NO_CONTENT);
    }
}
 
Example 2
Source File: Search.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void success(ActionInvocation actionInvocation) {
    log.fine("Successful search action, reading output argument values");

    SearchResult result = new SearchResult(
            actionInvocation.getOutput("Result").getValue().toString(),
            (UnsignedIntegerFourBytes) actionInvocation.getOutput("NumberReturned").getValue(),
            (UnsignedIntegerFourBytes) actionInvocation.getOutput("TotalMatches").getValue(),
            (UnsignedIntegerFourBytes) actionInvocation.getOutput("UpdateID").getValue());

    boolean proceed = receivedRaw(actionInvocation, result);

    if (proceed && result.getCountLong() > 0 && result.getResult().length() > 0) {
        try {
            DIDLParser didlParser = new DIDLParser();
            DIDLContent didl = didlParser.parse(result.getResult());
            received(actionInvocation, didl);
            updateStatus(Status.OK);
        } catch (Exception ex) {
            actionInvocation.setFailure(
                    new ActionException(ErrorCode.ACTION_FAILED, "Can't parse DIDL XML response: " + ex, ex)
            );
            failure(actionInvocation, null);
        }
    } else {
        received(actionInvocation, new DIDLContent());
        updateStatus(Status.NO_CONTENT);
    }
}
 
Example 3
Source File: Browse.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
public void success(ActionInvocation invocation) {
    log.fine("Successful browse action, reading output argument values");

    BrowseResult result = new BrowseResult(
            invocation.getOutput("Result").getValue().toString(),
            (UnsignedIntegerFourBytes) invocation.getOutput("NumberReturned").getValue(),
            (UnsignedIntegerFourBytes) invocation.getOutput("TotalMatches").getValue(),
            (UnsignedIntegerFourBytes) invocation.getOutput("UpdateID").getValue()
    );

    boolean proceed = receivedRaw(invocation, result);

    if (proceed && result.getCountLong() > 0 && result.getResult().length() > 0) {

        try {

            DIDLParser didlParser = new DIDLParser();
            DIDLContent didl = didlParser.parse(result.getResult());
            received(invocation, didl);
            updateStatus(Status.OK);

        } catch (Exception ex) {
            invocation.setFailure(
                    new ActionException(ErrorCode.ACTION_FAILED, "Can't parse DIDL XML response: " + ex, ex)
            );
            failure(invocation, null);
        }

    } else {
        received(invocation, new DIDLContent());
        updateStatus(Status.NO_CONTENT);
    }
}
 
Example 4
Source File: Search.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void success(ActionInvocation actionInvocation) {
    log.fine("Successful search action, reading output argument values");

    SearchResult result = new SearchResult(
            actionInvocation.getOutput("Result").getValue().toString(),
            (UnsignedIntegerFourBytes) actionInvocation.getOutput("NumberReturned").getValue(),
            (UnsignedIntegerFourBytes) actionInvocation.getOutput("TotalMatches").getValue(),
            (UnsignedIntegerFourBytes) actionInvocation.getOutput("UpdateID").getValue());

    boolean proceed = receivedRaw(actionInvocation, result);

    if (proceed && result.getCountLong() > 0 && result.getResult().length() > 0) {
        try {
            DIDLParser didlParser = new DIDLParser();
            DIDLContent didl = didlParser.parse(result.getResult());
            received(actionInvocation, didl);
            updateStatus(Status.OK);
        } catch (Exception ex) {
            actionInvocation.setFailure(
                    new ActionException(ErrorCode.ACTION_FAILED, "Can't parse DIDL XML response: " + ex, ex)
            );
            failure(actionInvocation, null);
        }
    } else {
        received(actionInvocation, new DIDLContent());
        updateStatus(Status.NO_CONTENT);
    }
}