@UpnpAction(
      out = {
        @UpnpOutputArgument(
            name = "Result",
            stateVariable = "A_ARG_TYPE_Result",
            getterName = "getResult"),
        @UpnpOutputArgument(
            name = "NumberReturned",
            stateVariable = "A_ARG_TYPE_Count",
            getterName = "getCount"),
        @UpnpOutputArgument(
            name = "TotalMatches",
            stateVariable = "A_ARG_TYPE_Count",
            getterName = "getTotalMatches"),
        @UpnpOutputArgument(
            name = "UpdateID",
            stateVariable = "A_ARG_TYPE_UpdateID",
            getterName = "getContainerUpdateID")
      })
  public BrowseResult browse(
      @UpnpInputArgument(name = "ObjectID", aliases = "ContainerID") String objectId,
      @UpnpInputArgument(name = "BrowseFlag") String browseFlag,
      @UpnpInputArgument(name = "Filter") String filter,
      @UpnpInputArgument(name = "StartingIndex", stateVariable = "A_ARG_TYPE_Index")
          UnsignedIntegerFourBytes firstResult,
      @UpnpInputArgument(name = "RequestedCount", stateVariable = "A_ARG_TYPE_Count")
          UnsignedIntegerFourBytes maxResults,
      @UpnpInputArgument(name = "SortCriteria") String orderBy)
      throws ContentDirectoryException {

    SortCriterion[] orderByCriteria;
    try {
      orderByCriteria = SortCriterion.valueOf(orderBy);
    } catch (Exception ex) {
      throw new ContentDirectoryException(
          ContentDirectoryErrorCode.UNSUPPORTED_SORT_CRITERIA, ex.toString());
    }

    try {
      return browse(
          objectId,
          BrowseFlag.valueOrNullOf(browseFlag),
          filter,
          firstResult.getValue(),
          maxResults.getValue(),
          orderByCriteria);
    } catch (ContentDirectoryException ex) {
      throw ex;
    } catch (Exception ex) {
      throw new ContentDirectoryException(ErrorCode.ACTION_FAILED, ex.toString());
    }
  }
Ejemplo n.º 2
0
  /** @param maxResults Can be <code>null</code>, then {@link #getDefaultMaxResults()} is used. */
  public Browse(
      Service service,
      String objectID,
      BrowseFlag flag,
      String filter,
      long firstResult,
      Long maxResults,
      SortCriterion... orderBy) {

    super(new ActionInvocation(service.getAction("Browse")));

    log.fine("Creating browse action for object ID: " + objectID);

    getActionInvocation().setInput("ObjectID", objectID);
    getActionInvocation().setInput("BrowseFlag", flag.toString());
    getActionInvocation().setInput("Filter", filter);
    getActionInvocation().setInput("StartingIndex", new UnsignedIntegerFourBytes(firstResult));
    getActionInvocation()
        .setInput(
            "RequestedCount",
            new UnsignedIntegerFourBytes(maxResults == null ? getDefaultMaxResults() : maxResults));
    getActionInvocation().setInput("SortCriteria", SortCriterion.toString(orderBy));
  }