public void setNode(String name) { if (hasNode(name)) { return; } Node node = new Node(name); addNode(node); }
private Node createPropertySetNode(String varName, String value) { Node propSetNode = new Node(/*XMLNS + SOAP.DELIM + */PROPERTYSET); propSetNode.setNameSpace(XMLNS, Subscription.XMLNS); Node propNode = new Node(/*XMLNS + SOAP.DELIM + */PROPERTY); propSetNode.addNode(propNode); // Thanks for Giordano Sassaroli <sassarol@cefriel.it> (05/22/03) //Node varNameNode = new Node(XMLNS + SOAP.DELIM + varName); Node varNameNode = new Node(varName); varNameNode.setValue(value); propNode.addNode(varNameNode); return propSetNode; }
/** * Add a Service to device without checking for duplicate or syntax error * * @param s * Add Service s to the Device */ public void addService(Service s) { Node serviceListNode = getDeviceNode().getNode(ServiceList.ELEM_NAME); if (serviceListNode == null) { serviceListNode = new Node(ServiceList.ELEM_NAME); getDeviceNode().addNode(serviceListNode); } serviceListNode.addNode(s.getServiceNode()); }
public void setNode(String name, String value) { Node node = getNode(name); if (node == null) { node = new Node(name); addNode(node); } node.setValue(value); }
public void addAction(Action a){ Iterator<Argument> i = a.getArgumentList().iterator(); while (i.hasNext()) { Argument arg = i.next(); arg.setService(this); } Node scdpNode = getSCPDNode(); Node actionListNode = scdpNode.getNode(ActionList.ELEM_NAME); if (actionListNode == null){ actionListNode = new Node(ActionList.ELEM_NAME); scdpNode.addNode(actionListNode); } actionListNode.addNode(a.getActionNode()); }
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()); } }
public Service(){ this(new Node(ELEM_NAME)); Node sp = new Node(SPEC_VERSION); Node M =new Node(MAJOR); M.setValue(MAJOR_VALUE); sp.addNode(M); Node m =new Node(MINOR); m.setValue(MINOR_VALUE); sp.addNode(m); //Node scpd = new Node(SCPD_ROOTNODE,SCPD_ROOTNODE_NS); wrong! Node scpd = new Node(SCPD_ROOTNODE); scpd.addAttribute("xmlns",SCPD_ROOTNODE_NS); scpd.addNode(sp); getServiceData().setSCPDNode(scpd); }
public final static Node createEnvelopeBodyNode() { // <Envelope> Node envNode = new Node(SOAP.XMLNS + SOAP.DELIM + SOAP.ENVELOPE); envNode.setAttribute("xmlns" + SOAP.DELIM + SOAP.XMLNS, SOAP.XMLNS_URL); envNode.setAttribute(SOAP.XMLNS + SOAP.DELIM + "encodingStyle", SOAP.ENCSTYLE_URL); // <Body> Node bodyNode = new Node(SOAP.XMLNS + SOAP.DELIM + SOAP.BODY); envNode.addNode(bodyNode); return envNode; }
public void setFaultResponse(int errCode, String errDescr) { setStatusCode(HTTPStatus.INTERNAL_SERVER_ERROR); Node bodyNode = getBodyNode(); Node faultNode = createFaultResponseNode(errCode, errDescr); bodyNode.addNode(faultNode); Node envNode = getEnvelopeNode(); setContent(envNode); }
public void setResponse(Action action) { setStatusCode(HTTPStatus.OK); Node bodyNode = getBodyNode(); Node resNode = createResponseNode(action); bodyNode.addNode(resNode); Node envNode = getEnvelopeNode(); setContent(envNode); }
public boolean addIcon(Icon icon) { Node deviceNode = getDeviceNode(); if (deviceNode == null) return false; Node iconListNode = deviceNode.getNode(IconList.ELEM_NAME); if (iconListNode == null) { iconListNode = new Node(IconList.ELEM_NAME); deviceNode.addNode(iconListNode); } Node iconNode = new Node(Icon.ELEM_NAME); if (icon.getIconNode() != null) { iconNode.set(icon.getIconNode()); } iconListNode.addNode(iconNode); if (icon.hasURL() && icon.hasBytes()) { iconBytesMap.put(icon.getURL(), icon.getBytes()); } return true; }
private Node createResponseNode(String var) { Node queryResNode = new Node(); queryResNode.setName(Control.NS, Control.QUERY_STATE_VARIABLE_RESPONSE); queryResNode.setNameSpace(Control.NS, Control.XMLNS); Node returnNode = new Node(); returnNode.setName(Control.RETURN); returnNode.setValue(var); queryResNode.addNode(returnNode); return queryResNode; } }
public void setResponse(StateVariable stateVar) { String var = stateVar.getValue(); setStatusCode(HTTPStatus.OK); Node bodyNode = getBodyNode(); Node resNode = createResponseNode(var); bodyNode.addNode(resNode); Node envNodee = getEnvelopeNode(); setContent(envNodee); }
private Node createContentNode(StateVariable stateVar) { Node queryVarNode = new Node(); queryVarNode.setName(Control.NS, Control.QUERY_STATE_VARIABLE); queryVarNode.setNameSpace(Control.NS, Control.XMLNS); Node varNode = new Node(); varNode.setName(Control.NS, Control.VAR_NAME); varNode.setValue(stateVar.getName()); queryVarNode.addNode(varNode); return queryVarNode; }
/** * This method ovverride the value of the AllowedValueRange Node<br> * of this object. <br> * <br> * Note: This method should be used to create a dynamic<br> * Device withtout writing any XML that describe the device<br>. * <br> * Note2: The enforce the constraint of the SCPD rule the<br> * AllowedValueList and AllowedValueRange are mutal exclusive<br> * the last set will be the only present<br> * * @param avr The new AllowedValueRange */ public void setAllowedValueRange(AllowedValueRange avr){ //TODO Some test done not stable getStateVariableNode().removeNode(AllowedValueList.ELEM_NAME); getStateVariableNode().removeNode(AllowedValueRange.ELEM_NAME); getStateVariableNode().addNode(avr.getAllowedValueRangeNode()); }
public void setRequest(StateVariable stateVar) { Service service = stateVar.getService(); String ctrlURL = service.getControlURL(); setRequestHost(service); setEnvelopeNode(SOAP.createEnvelopeBodyNode()); Node envNode = getEnvelopeNode(); Node bodyNode = getBodyNode(); Node qeuryNode = createContentNode(stateVar); bodyNode.addNode(qeuryNode); setContent(envNode); setSOAPAction(Control.QUERY_SOAPACTION); }
public void setRequest(Action action, ArgumentList argList) { Service service = action.getService(); setRequestHost(service); setEnvelopeNode(SOAP.createEnvelopeBodyNode()); Node envNode = getEnvelopeNode(); Node bodyNode = getBodyNode(); Node argNode = createContentNode(service, action, argList); bodyNode.addNode(argNode); setContent(envNode); String serviceType = service.getServiceType(); String actionName = action.getName(); String soapAction = "\"" + serviceType + "#" + actionName + "\""; setSOAPAction(soapAction); }
private Node createContentNode(Service service, Action action, ArgumentList argList) { String actionName = action.getName(); String serviceType = service.getServiceType(); Node actionNode = new Node(); actionNode.setName(Control.NS, actionName); actionNode.setNameSpace(Control.NS, serviceType); int argListCnt = argList.size(); for (int n=0; n<argListCnt; n++) { Argument arg = argList.getArgument(n); Node argNode = new Node(); argNode.setName(arg.getName()); argNode.setValue(arg.getValue()); actionNode.addNode(argNode); } return actionNode; }
private Node createResponseNode(Action action) { String actionName = action.getName(); Node actionNameResNode = new Node(SOAP.METHODNS + SOAP.DELIM + actionName + SOAP.RESPONSE); Service service = action.getService(); if (service != null) { actionNameResNode.setAttribute( "xmlns:" + SOAP.METHODNS, service.getServiceType()); } ArgumentList argList = action.getArgumentList(); int nArgs = argList.size(); for (int n=0; n<nArgs; n++) { Argument arg = argList.getArgument(n); if (arg.isOutDirection() == false) continue; Node argNode = new Node(); argNode.setName(arg.getName()); argNode.setValue(arg.getValue()); actionNameResNode.addNode(argNode); } return actionNameResNode; }
public boolean set(Node otherNode) { if (otherNode == null) return false; setName(otherNode.getName()); setValue(otherNode.getValue()); removeAllAttributes(); int nOtherAttributes = otherNode.getNAttributes(); for (int n=0; n<nOtherAttributes; n++) { Attribute otherAttr = otherNode.getAttribute(n); Attribute thisAttr = new Attribute(otherAttr); addAttribute(thisAttr); } removeAllNodes(); int nOtherChildNodes = otherNode.getNNodes(); for (int n=0; n<nOtherChildNodes; n++) { Node otherChildNode = otherNode.getNode(n); Node thisChildNode = new Node(); thisChildNode.set(otherChildNode); addNode(thisChildNode); } return true; }