public boolean postControlAction() { // Thanks for Giordano Sassaroli <*****@*****.**> (08/30/03) ArgumentList actionArgList = getArgumentList(); ArgumentList actionInputArgList = getInputArgumentList(); ActionRequest ctrlReq = new ActionRequest(); ctrlReq.setRequest(this, actionInputArgList); if (Debug.isOn() == true) ctrlReq.print(); ActionResponse ctrlRes = ctrlReq.post(); if (Debug.isOn() == true) ctrlRes.print(); setControlResponse(ctrlRes); // Thanks for Dimas <*****@*****.**> and Stefano Lenzi // <*****@*****.**> (07/09/04) int statCode = ctrlRes.getStatusCode(); setStatus(statCode); if (ctrlRes.isSuccessful() == false) return false; ArgumentList outArgList = ctrlRes.getResponse(); try { actionArgList.setResArgs(outArgList); } catch (IllegalArgumentException ex) { setStatus( UPnPStatus.INVALID_ARGS, "Action succesfully delivered but invalid arguments returned."); return false; } return true; }
private void clearOutputAgumentValues() { ArgumentList allArgList = getArgumentList(); int allArgCnt = allArgList.size(); for (int n = 0; n < allArgCnt; n++) { Argument arg = allArgList.getArgument(n); if (arg.isOutDirection() == false) continue; arg.setValue(""); } }
/** @deprecated */ public void set(ArgumentList inArgList) { int nInArgs = inArgList.size(); for (int n = 0; n < nInArgs; n++) { Argument inArg = inArgList.getArgument(n); String inArgName = inArg.getName(); Argument arg = getArgument(inArgName); if (arg == null) continue; arg.setValue(inArg.getValue()); } }
void updateArgumentList(TreeNode parentNode, Action action) { ArgumentList argList = action.getArgumentList(); int nArguments = argList.size(); for (int n = 0; n < nArguments; n++) { Argument arg = argList.getArgument(n); String argName = arg.getName() + "(" + arg.getDirection() + ")"; TreeNode argNode = new TreeNode(argName); argNode.setUserData(arg); parentNode.add(argNode); } }
public Argument getArgument(String name) { ArgumentList argList = getArgumentList(); int nArgs = argList.size(); for (int n = 0; n < nArgs; n++) { Argument arg = argList.getArgument(n); String argName = arg.getName(); if (argName == null) continue; if (name.equals(argName) == true) return arg; } return null; }
public ArgumentList getOutputArgumentList() { ArgumentList allArgList = getArgumentList(); int allArgCnt = allArgList.size(); ArgumentList argList = new ArgumentList(); for (int n = 0; n < allArgCnt; n++) { Argument arg = allArgList.getArgument(n); if (arg.isOutDirection() == false) continue; argList.add(arg); } return argList; }
public void print() { Debug.message("Action : " + getName()); ArgumentList argList = getArgumentList(); int nArgs = argList.size(); for (int n = 0; n < nArgs; n++) { Argument arg = argList.getArgument(n); String name = arg.getName(); String value = arg.getValue(); String dir = arg.getDirection(); Debug.message(" [" + n + "] = " + dir + ", " + name + ", " + value); } }
public ArgumentList getArgumentList() { ArgumentList argumentList = new ArgumentList(); Node argumentListNode = getActionNode().getNode(ArgumentList.ELEM_NAME); if (argumentListNode == null) return argumentList; int nodeCnt = argumentListNode.getNNodes(); for (int n = 0; n < nodeCnt; n++) { Node node = argumentListNode.getNode(n); if (Argument.isArgumentNode(node) == false) continue; Argument argument = new Argument(getServiceNode(), node); argumentList.add(argument); } return argumentList; }
/** * Set all the Argument which are Output Argoument to the given value in the argument list * * @param outArgList */ public void setResArgs(ArgumentList outArgList) { int nArgs = size(); for (int n = 0; n < nArgs; n++) { Argument arg = getArgument(n); if (arg.isOutDirection()) { String argName = arg.getName(); Argument outArg = outArgList.getArgument(argName); if (outArg == null) throw new IllegalArgumentException("Argument \"" + argName + "\" missing."); arg.setValue(outArg.getValue()); } } }
public void setArgumentList(ArgumentList al) { Node argumentListNode = getActionNode().getNode(ArgumentList.ELEM_NAME); if (argumentListNode == null) { argumentListNode = new Node(ArgumentList.ELEM_NAME); getActionNode().addNode(argumentListNode); } else { argumentListNode.removeAllNodes(); } Iterator<Argument> i = al.iterator(); while (i.hasNext()) { Argument a = i.next(); a.setService(getService()); argumentListNode.addNode(a.getArgumentNode()); } }