public Datatype getDatatype() { return getAction().getService().getDatatype(this); }
public OutgoingActionResponseMessage(UpnpResponse.Status status, Action action) { super(new UpnpResponse(status)); if (action != null) { if (action instanceof QueryStateVariableAction) { this.actionNamespace = Constants.NS_UPNP_CONTROL_10; } else { this.actionNamespace = action.getService().getServiceType().toString(); } } addHeaders(); }
protected Object[] createInputArgumentValues(ActionInvocation<LocalService> actionInvocation, Method method) throws ActionException { LocalService service = actionInvocation.getAction().getService();
getClass(), "name", "Action without name of: " + getService() )); } else if (!ModelUtil.isValidUDAName(getName())) { log.warning("UPnP specification violation of: " + getService().getDevice()); log.warning("Invalid action name: " + this); if (getService().getStateVariable(actionArgument.getRelatedStateVariableName()) == null) { errors.add(new ValidationError( getClass(), log.warning("UPnP specification violation of :" + getService().getDevice()); log.warning("Input argument can not have <retval/>"); } else { if (retValueArgument != null) { log.warning("UPnP specification violation of: " + getService().getDevice()); log.warning("Only one argument of action '" + getName() + "' can be <retval/>"); ActionArgument a = getArguments()[j]; if (a.getDirection() == ActionArgument.Direction.OUT) { log.warning("UPnP specification violation of: " + getService().getDevice()); log.warning("Argument '" + retValueArgument.getName() + "' of action '" + getName() + "' is <retval/> but not the first OUT argument");
final LocalService service = actionInvocation.getAction().getService();
)); } else if (!ModelUtil.isValidUDAName(getName())) { log.warning("UPnP specification violation of: " + getAction().getService().getDevice()); log.warning("Invalid argument name: " + this); } else if (getName().length() > 32) { log.warning("UPnP specification violation of: " + getAction().getService().getDevice()); log.warning("Argument name should be less than 32 characters: " + this);
/** * 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)"); } }
@Override protected void execute(ActionInvocation<LocalService> actionInvocation, Object serviceImpl) throws Exception { // Querying a state variable doesn't mean an actual "action" method on this instance gets invoked if (actionInvocation.getAction() instanceof QueryStateVariableAction) { if (!actionInvocation.getAction().getService().isSupportsQueryStateVariables()) { actionInvocation.setFailure( new ActionException(ErrorCode.INVALID_ACTION, "This service does not support querying state variables") ); } else { executeQueryStateVariable(actionInvocation, serviceImpl); } } else { throw new IllegalStateException( "This class can only execute QueryStateVariableAction's, not: " + actionInvocation.getAction() ); } }
protected IncomingActionResponseMessage invokeRemote(OutgoingActionRequestMessage requestMessage) throws RouterException { Device device = actionInvocation.getAction().getService().getDevice();
protected void executeQueryStateVariable(ActionInvocation<LocalService> actionInvocation, Object serviceImpl) throws Exception { LocalService service = actionInvocation.getAction().getService(); String stateVariableName = actionInvocation.getInput("varName").toString(); StateVariable stateVariable = service.getStateVariable(stateVariableName); if (stateVariable == null) { throw new ActionException( ErrorCode.ARGUMENT_VALUE_INVALID, "No state variable found: " + stateVariableName ); } StateVariableAccessor accessor; if ((accessor = service.getAccessor(stateVariable.getName())) == null) { throw new ActionException( ErrorCode.ARGUMENT_VALUE_INVALID, "No accessor for state variable, can't read state: " + stateVariableName ); } try { setOutputArgumentValue( actionInvocation, actionInvocation.getAction().getOutputArgument("return"), accessor.read(stateVariable, serviceImpl).toString() ); } catch (Exception ex) { throw new ActionException(ErrorCode.ACTION_FAILED, ex.getMessage()); } }
soapActionHeader = new SoapActionHeader( new SoapActionType( action.getService().getServiceType(), action.getName()
case INT: case STRING: if (argument.getAction().getService().getStateVariable( argument.getRelatedStateVariableName() ).getTypeDetails().getAllowedValues() != null) {
public void run() { Service service = actionInvocation.getAction().getService();
public Datatype getDatatype() { return getAction().getService().getDatatype(this); }
public OutgoingActionResponseMessage(UpnpResponse.Status status, Action action) { super(new UpnpResponse(status)); if (action != null) { if (action instanceof QueryStateVariableAction) { this.actionNamespace = Constants.NS_UPNP_CONTROL_10; } else { this.actionNamespace = action.getService().getServiceType().toString(); } } addHeaders(); }
)); } else if (!ModelUtil.isValidUDAName(getName())) { log.warning("UPnP specification violation of: " + getAction().getService().getDevice()); log.warning("Invalid argument name: " + this); } else if (getName().length() > 32) { log.warning("UPnP specification violation of: " + getAction().getService().getDevice()); log.warning("Argument name should be less than 32 characters: " + this);
/** * 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)"); } }
@Override protected void execute(ActionInvocation<LocalService> actionInvocation, Object serviceImpl) throws Exception { // Querying a state variable doesn't mean an actual "action" method on this instance gets invoked if (actionInvocation.getAction() instanceof QueryStateVariableAction) { if (!actionInvocation.getAction().getService().isSupportsQueryStateVariables()) { actionInvocation.setFailure( new ActionException(ErrorCode.INVALID_ACTION, "This service does not support querying state variables") ); } else { executeQueryStateVariable(actionInvocation, serviceImpl); } } else { throw new IllegalStateException( "This class can only execute QueryStateVariableAction's, not: " + actionInvocation.getAction() ); } }
protected void executeQueryStateVariable(ActionInvocation<LocalService> actionInvocation, Object serviceImpl) throws Exception { LocalService service = actionInvocation.getAction().getService(); String stateVariableName = actionInvocation.getInput("varName").toString(); StateVariable stateVariable = service.getStateVariable(stateVariableName); if (stateVariable == null) { throw new ActionException( ErrorCode.ARGUMENT_VALUE_INVALID, "No state variable found: " + stateVariableName ); } StateVariableAccessor accessor; if ((accessor = service.getAccessor(stateVariable.getName())) == null) { throw new ActionException( ErrorCode.ARGUMENT_VALUE_INVALID, "No accessor for state variable, can't read state: " + stateVariableName ); } try { setOutputArgumentValue( actionInvocation, actionInvocation.getAction().getOutputArgument("return"), accessor.read(stateVariable, serviceImpl).toString() ); } catch (Exception ex) { throw new ActionException(ErrorCode.ACTION_FAILED, ex.getMessage()); } }
soapActionHeader = new SoapActionHeader( new SoapActionType( action.getService().getServiceType(), action.getName()