Java Code Examples for org.fourthline.cling.model.types.InvalidValueException#getMessage()

The following examples show how to use org.fourthline.cling.model.types.InvalidValueException#getMessage() . 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: TimeSeekRangeHeader.java    From TVRemoteIME with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void setString(String s) throws InvalidHeaderException {
    if (s.length() != 0) {
        String[] params = s.split(" ");
        if (params.length>0) {
            try {
                TimeSeekRangeType t = new TimeSeekRangeType(NormalPlayTimeRange.valueOf(params[0]));
                if (params.length > 1) {
                    t.setBytesRange(BytesRange.valueOf(params[1]));
                }
                setValue(t);
                return;
            } catch (InvalidValueException invalidValueException) {
                throw new InvalidHeaderException("Invalid TimeSeekRange header value: " + s + "; "+invalidValueException.getMessage());
            }
        }
    }
    throw new InvalidHeaderException("Invalid TimeSeekRange header value: " + s);
}
 
Example 2
Source File: TimeSeekRangeHeader.java    From DroidDLNA with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void setString(String s) throws InvalidHeaderException {
    if (s.length() != 0) {
        String[] params = s.split(" ");
        if (params.length>0) {
            try {
                TimeSeekRangeType t = new TimeSeekRangeType(NormalPlayTimeRange.valueOf(params[0]));
                if (params.length > 1) {
                    t.setBytesRange(BytesRange.valueOf(params[1]));
                }
                setValue(t);
                return;
            } catch (InvalidValueException invalidValueException) {
                throw new InvalidHeaderException("Invalid TimeSeekRange header value: " + s + "; "+invalidValueException.getMessage());
            }
        }
    }
    throw new InvalidHeaderException("Invalid TimeSeekRange header value: " + s);
}
 
Example 3
Source File: ContentRangeHeader.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
public void setString(String s) throws InvalidHeaderException {
    try {
        setValue(BytesRange.valueOf(s,PREFIX));
    } catch (InvalidValueException invalidValueException) {
        throw new InvalidHeaderException("Invalid Range Header: " + invalidValueException.getMessage());
    }
}
 
Example 4
Source File: RangeHeader.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
public void setString(String s) throws InvalidHeaderException {
    try {
        setValue(BytesRange.valueOf(s));
    } catch (InvalidValueException invalidValueException) {
        throw new InvalidHeaderException("Invalid Range Header: " + invalidValueException.getMessage());
    }
}
 
Example 5
Source File: PragmaHeader.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
public void setString(String s) throws InvalidHeaderException {
    try {
        setValue(PragmaType.valueOf(s));
    } catch (InvalidValueException invalidValueException) {
        throw new InvalidHeaderException("Invalid Range Header: " + invalidValueException.getMessage());
    }
}
 
Example 6
Source File: AbstractActionExecutor.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the output argument value on the {@link org.fourthline.cling.model.action.ActionInvocation}, considers string conversion.
 */
protected void setOutputArgumentValue(ActionInvocation<LocalService> actionInvocation, ActionArgument<LocalService> argument, Object result)
        throws ActionException {

    LocalService service = actionInvocation.getAction().getService();

    if (result != null) {
        try {
            if (service.isStringConvertibleType(result)) {
                log.fine("Result of invocation matches convertible type, setting toString() single output argument value");
                actionInvocation.setOutput(new ActionArgumentValue(argument, result.toString()));
            } else {
                log.fine("Result of invocation is Object, setting single output argument value");
                actionInvocation.setOutput(new ActionArgumentValue(argument, result));
            }
        } catch (InvalidValueException ex) {
            throw new ActionException(
                    ErrorCode.ARGUMENT_VALUE_INVALID,
                    "Wrong type or invalid value for '" + argument.getName() + "': " + ex.getMessage(),
                    ex
            );
        }
    } else {

        log.fine("Result of invocation is null, not setting any output argument value(s)");
    }

}
 
Example 7
Source File: SOAPActionProcessorImpl.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates an instance of {@link ActionArgumentValue} and wraps an
 * {@link InvalidValueException} as an {@link ActionException} with the
 * appropriate {@link ErrorCode}.
 */
protected ActionArgumentValue createValue(ActionArgument arg, String value) throws ActionException {
    try {
        return new ActionArgumentValue(arg, value);
    } catch (InvalidValueException ex) {
        throw new ActionException(
                ErrorCode.ARGUMENT_VALUE_INVALID,
                "Wrong type or invalid value for '" + arg.getName() + "': " + ex.getMessage(),
                ex
        );
    }
}
 
Example 8
Source File: ContentRangeHeader.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
public void setString(String s) throws InvalidHeaderException {
    try {
        setValue(BytesRange.valueOf(s,PREFIX));
    } catch (InvalidValueException invalidValueException) {
        throw new InvalidHeaderException("Invalid Range Header: " + invalidValueException.getMessage());
    }
}
 
Example 9
Source File: RangeHeader.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
public void setString(String s) throws InvalidHeaderException {
    try {
        setValue(BytesRange.valueOf(s));
    } catch (InvalidValueException invalidValueException) {
        throw new InvalidHeaderException("Invalid Range Header: " + invalidValueException.getMessage());
    }
}
 
Example 10
Source File: PragmaHeader.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
public void setString(String s) throws InvalidHeaderException {
    try {
        setValue(PragmaType.valueOf(s));
    } catch (InvalidValueException invalidValueException) {
        throw new InvalidHeaderException("Invalid Range Header: " + invalidValueException.getMessage());
    }
}
 
Example 11
Source File: AbstractActionExecutor.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Sets the output argument value on the {@link org.fourthline.cling.model.action.ActionInvocation}, considers string conversion.
 */
protected void setOutputArgumentValue(ActionInvocation<LocalService> actionInvocation, ActionArgument<LocalService> argument, Object result)
        throws ActionException {

    LocalService service = actionInvocation.getAction().getService();

    if (result != null) {
        try {
            if (service.isStringConvertibleType(result)) {
                log.fine("Result of invocation matches convertible type, setting toString() single output argument value");
                actionInvocation.setOutput(new ActionArgumentValue(argument, result.toString()));
            } else {
                log.fine("Result of invocation is Object, setting single output argument value");
                actionInvocation.setOutput(new ActionArgumentValue(argument, result));
            }
        } catch (InvalidValueException ex) {
            throw new ActionException(
                    ErrorCode.ARGUMENT_VALUE_INVALID,
                    "Wrong type or invalid value for '" + argument.getName() + "': " + ex.getMessage(),
                    ex
            );
        }
    } else {

        log.fine("Result of invocation is null, not setting any output argument value(s)");
    }

}
 
Example 12
Source File: SOAPActionProcessorImpl.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates an instance of {@link ActionArgumentValue} and wraps an
 * {@link InvalidValueException} as an {@link ActionException} with the
 * appropriate {@link ErrorCode}.
 */
protected ActionArgumentValue createValue(ActionArgument arg, String value) throws ActionException {
    try {
        return new ActionArgumentValue(arg, value);
    } catch (InvalidValueException ex) {
        throw new ActionException(
                ErrorCode.ARGUMENT_VALUE_INVALID,
                "Wrong type or invalid value for '" + arg.getName() + "': " + ex.getMessage(),
                ex
        );
    }
}
 
Example 13
Source File: AvailableSeekRangeHeader.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void setString(String s) throws InvalidHeaderException {
    if (s.length() != 0) {
        String[] params = s.split(" ");
        if (params.length > 1) {
            try {
                AvailableSeekRangeType.Mode mode = null;
                NormalPlayTimeRange timeRange = null;
                BytesRange byteRange = null;

                //Parse Mode
                try {
                    mode = AvailableSeekRangeType.Mode.valueOf("MODE_" + params[0]);
                } catch (IllegalArgumentException e) {
                    throw new InvalidValueException("Invalid AvailableSeekRange Mode");
                }

                boolean useTime = true;
                //Parse Second Token
                try {
                    timeRange = NormalPlayTimeRange.valueOf(params[1],true);
                } catch (InvalidValueException timeInvalidValueException) {
                    try {
                        byteRange = BytesRange.valueOf(params[1]);
                        useTime = false;
                    } catch (InvalidValueException bytesInvalidValueException) {
                        throw new InvalidValueException("Invalid AvailableSeekRange Range");
                    }
                }
                if (useTime) {
                    if (params.length > 2) {
                        //Parse Third Token
                        byteRange = BytesRange.valueOf(params[2]);
                        setValue(new AvailableSeekRangeType(mode, timeRange, byteRange));
                    }
                    else {
                        setValue(new AvailableSeekRangeType(mode, timeRange));
                    }
                } else {
                    setValue(new AvailableSeekRangeType(mode, byteRange));
                }
                return;
            } catch (InvalidValueException invalidValueException) {
                throw new InvalidHeaderException("Invalid AvailableSeekRange header value: " + s + "; " + invalidValueException.getMessage());
            }
        }
    }
    throw new InvalidHeaderException("Invalid AvailableSeekRange header value: " + s);
}
 
Example 14
Source File: AvailableSeekRangeHeader.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void setString(String s) throws InvalidHeaderException {
    if (s.length() != 0) {
        String[] params = s.split(" ");
        if (params.length > 1) {
            try {
                AvailableSeekRangeType.Mode mode = null;
                NormalPlayTimeRange timeRange = null;
                BytesRange byteRange = null;

                //Parse Mode
                try {
                    mode = AvailableSeekRangeType.Mode.valueOf("MODE_" + params[0]);
                } catch (IllegalArgumentException e) {
                    throw new InvalidValueException("Invalid AvailableSeekRange Mode");
                }

                boolean useTime = true;
                //Parse Second Token
                try {
                    timeRange = NormalPlayTimeRange.valueOf(params[1],true);
                } catch (InvalidValueException timeInvalidValueException) {
                    try {
                        byteRange = BytesRange.valueOf(params[1]);
                        useTime = false;
                    } catch (InvalidValueException bytesInvalidValueException) {
                        throw new InvalidValueException("Invalid AvailableSeekRange Range");
                    }
                }
                if (useTime) {
                    if (params.length > 2) {
                        //Parse Third Token
                        byteRange = BytesRange.valueOf(params[2]);
                        setValue(new AvailableSeekRangeType(mode, timeRange, byteRange));
                    }
                    else {
                        setValue(new AvailableSeekRangeType(mode, timeRange));
                    }
                } else {
                    setValue(new AvailableSeekRangeType(mode, byteRange));
                }
                return;
            } catch (InvalidValueException invalidValueException) {
                throw new InvalidHeaderException("Invalid AvailableSeekRange header value: " + s + "; " + invalidValueException.getMessage());
            }
        }
    }
    throw new InvalidHeaderException("Invalid AvailableSeekRange header value: " + s);
}