@Override public String toString() { return "(" + getClass().getSimpleName() + ", Arguments: " + (getArguments() != null ? getArguments().length : "NO ARGS") + ") " + getName(); }
protected ActionArgument<S> getInputArgument(String name) { ActionArgument<S> argument = getAction().getInputArgument(name); if (argument == null) throw new IllegalArgumentException("Argument not found: " + name); return argument; }
public boolean hasInputArguments() { return getInputArguments() != null && getInputArguments().length > 0; }
public Action<S> deepCopy() { ActionArgument<S>[] actionArgumentsDupe = new ActionArgument[getArguments().length]; for (int i = 0; i < getArguments().length; i++) { ActionArgument arg = getArguments()[i]; actionArgumentsDupe[i] = arg.deepCopy(); } return new Action<>( getName(), actionArgumentsDupe ); }
public ActionArgument<S> getFirstInputArgument() { if (!hasInputArguments()) throw new IllegalStateException("No input arguments: " + this); return getInputArguments()[0]; }
mainPanel.add(invocationToolBar, BorderLayout.NORTH); if (action.hasInputArguments() && action.hasOutputArguments()) { splitPane.setTopComponent(inputArgumentsScrollPane); splitPane.setBottomComponent(outputArgumentsScrollPane); splitPane.setResizeWeight(0.5); mainPanel.add(splitPane, BorderLayout.CENTER); } else if (action.hasInputArguments()) { mainPanel.add(inputArgumentsScrollPane, BorderLayout.CENTER); } else if (action.hasOutputArguments()) { mainPanel.add(outputArgumentsScrollPane, BorderLayout.CENTER); setTitle("Invoking Action: " + action.getName()); setPreferredSize(new Dimension(450, (action.getArguments().length *40) + 120)); pack(); setVisible(true);
private void generateAction(Action action, Document descriptor, Element actionListElement) { Element actionElement = appendNewElement(descriptor, actionListElement, ELEMENT.action); appendNewElementIfNotNull(descriptor, actionElement, ELEMENT.name, action.getName()); if (action.hasArguments()) { Element argumentListElement = appendNewElement(descriptor, actionElement, ELEMENT.argumentList); for (ActionArgument actionArgument : action.getArguments()) { generateActionArgument(actionArgument, descriptor, argumentListElement); } } }
if (getName() == null || getName().length() == 0) { errors.add(new ValidationError( 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); for (ActionArgument actionArgument : getArguments()) { if (getService().getStateVariable(actionArgument.getRelatedStateVariableName()) == null) { errors.add(new ValidationError( getClass(), int retValueArgumentIndex = 0; int i = 0; for (ActionArgument actionArgument : getArguments()) { 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) {
@Override public void onCancel() { view.setCancelEnabled(false); if (actionExecutionFuture != null) { Workbench.Log.ACTION_INVOCATION.info( "Interrupting action execution: " + action.getName() ); actionExecutionFuture.cancel(true); } }
public ActionArgument<S> getFirstOutputArgument() { if (!hasOutputArguments()) throw new IllegalStateException("No output arguments: " + this); return getOutputArguments()[0]; }
public boolean hasOutputArguments() { return getOutputArguments() != null && getOutputArguments().length > 0; }
soapActionHeader = new SoapActionHeader( new SoapActionType( SoapActionType.MAGIC_CONTROL_NS, SoapActionType.MAGIC_CONTROL_TYPE, null, action.getName() soapActionHeader = new SoapActionHeader( new SoapActionType( action.getService().getServiceType(), action.getName()
public Datatype getDatatype() { return getAction().getService().getDatatype(this); }
public Service(ServiceType serviceType, ServiceId serviceId, Action<S>[] actions, StateVariable<S>[] stateVariables) throws ValidationException { this.serviceType = serviceType; this.serviceId = serviceId; if (actions != null) { for (Action action : actions) { this.actions.put(action.getName(), action); action.setService(this); } } if (stateVariables != null) { for (StateVariable stateVariable : stateVariables) { this.stateVariables.put(stateVariable.getName(), stateVariable); stateVariable.setService(this); } } }
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()); } }
protected Object[] createInputArgumentValues(ActionInvocation<LocalService> actionInvocation, Method method) throws ActionException { LocalService service = actionInvocation.getAction().getService(); for (ActionArgument<LocalService> argument : actionInvocation.getAction().getInputArguments()) {
public boolean hasArguments() { return getArguments() != null && getArguments().length > 0; }
public Action build() { return new Action(name, createActionArgumennts()); }
protected ActionArgument<S> getOutputArgument(String name) { ActionArgument<S> argument = getAction().getOutputArgument(name); if (argument == null) throw new IllegalArgumentException("Argument not found: " + name); return argument; }
private void generateAction(Action action, Document descriptor, Element actionListElement) { Element actionElement = appendNewElement(descriptor, actionListElement, ELEMENT.action); appendNewElementIfNotNull(descriptor, actionElement, ELEMENT.name, action.getName()); if (action.hasArguments()) { Element argumentListElement = appendNewElement(descriptor, actionElement, ELEMENT.argumentList); for (ActionArgument actionArgument : action.getArguments()) { generateActionArgument(actionArgument, descriptor, argumentListElement); } } }