public void hydrateSpecVersion(MutableDevice descriptor, Node specVersionNode) throws DescriptorBindingException { NodeList specVersionChildren = specVersionNode.getChildNodes(); for (int i = 0; i < specVersionChildren.getLength(); i++) { Node specVersionChild = specVersionChildren.item(i); if (specVersionChild.getNodeType() != Node.ELEMENT_NODE) continue; if (ELEMENT.major.equals(specVersionChild)) { String version = XMLUtil.getTextContent(specVersionChild).trim(); if (!version.equals("1")) { log.warning("Unsupported UDA major version, ignoring: " + version); version = "1"; } descriptor.udaVersion.major = Integer.valueOf(version); } else if (ELEMENT.minor.equals(specVersionChild)) { String version = XMLUtil.getTextContent(specVersionChild).trim(); if (!version.equals("0")) { log.warning("Unsupported UDA minor version, ignoring: " + version); version = "0"; } descriptor.udaVersion.minor = Integer.valueOf(version); } } }
public void hydrateActionArgument(MutableActionArgument actionArgument, Node actionArgumentNode) { NodeList argumentNodeChildren = actionArgumentNode.getChildNodes(); for (int i = 0; i < argumentNodeChildren.getLength(); i++) { Node argumentNodeChild = argumentNodeChildren.item(i); if (argumentNodeChild.getNodeType() != Node.ELEMENT_NODE) continue; if (ELEMENT.name.equals(argumentNodeChild)) { actionArgument.name = XMLUtil.getTextContent(argumentNodeChild); } else if (ELEMENT.direction.equals(argumentNodeChild)) { String directionString = XMLUtil.getTextContent(argumentNodeChild); try { actionArgument.direction = ActionArgument.Direction.valueOf(directionString.toUpperCase(Locale.ROOT)); } catch (IllegalArgumentException ex) { // TODO: UPNP VIOLATION: Pelco SpectraIV-IP uses illegal value INOUT log.warning("UPnP specification violation: Invalid action argument direction, assuming 'IN': " + directionString); actionArgument.direction = ActionArgument.Direction.IN; } } else if (ELEMENT.relatedStateVariable.equals(argumentNodeChild)) { actionArgument.relatedStateVariable = XMLUtil.getTextContent(argumentNodeChild); } else if (ELEMENT.retval.equals(argumentNodeChild)) { actionArgument.retval = true; } } }
public void hydrateAction(MutableAction action, Node actionNode) { NodeList actionNodeChildren = actionNode.getChildNodes(); for (int i = 0; i < actionNodeChildren.getLength(); i++) { Node actionNodeChild = actionNodeChildren.item(i); if (actionNodeChild.getNodeType() != Node.ELEMENT_NODE) continue; if (ELEMENT.name.equals(actionNodeChild)) { action.name = XMLUtil.getTextContent(actionNodeChild); } else if (ELEMENT.argumentList.equals(actionNodeChild)) { NodeList argumentChildren = actionNodeChild.getChildNodes(); for (int j = 0; j < argumentChildren.getLength(); j++) { Node argumentChild = argumentChildren.item(j); if (argumentChild.getNodeType() != Node.ELEMENT_NODE) continue; MutableActionArgument actionArgument = new MutableActionArgument(); hydrateActionArgument(actionArgument, argumentChild); action.arguments.add(actionArgument); } } } }
icon.width = (Integer.valueOf(XMLUtil.getTextContent(iconChild))); } else if (ELEMENT.height.equals(iconChild)) { icon.height = (Integer.valueOf(XMLUtil.getTextContent(iconChild))); } else if (ELEMENT.depth.equals(iconChild)) { String depth = XMLUtil.getTextContent(iconChild); try { icon.depth = (Integer.valueOf(depth)); icon.uri = parseURI(XMLUtil.getTextContent(iconChild)); } else if (ELEMENT.mimetype.equals(iconChild)) { try { icon.mimeType = XMLUtil.getTextContent(iconChild); MimeType.valueOf(icon.mimeType); } catch(IllegalArgumentException ex) {
protected void readProperties(Element propertysetElement, IncomingEventRequestMessage message) { NodeList propertysetElementChildren = propertysetElement.getChildNodes(); StateVariable[] stateVariables = message.getService().getStateVariables(); for (int i = 0; i < propertysetElementChildren.getLength(); i++) { Node propertysetChild = propertysetElementChildren.item(i); if (propertysetChild.getNodeType() != Node.ELEMENT_NODE) continue; if (getUnprefixedNodeName(propertysetChild).equals("property")) { NodeList propertyChildren = propertysetChild.getChildNodes(); for (int j = 0; j < propertyChildren.getLength(); j++) { Node propertyChild = propertyChildren.item(j); if (propertyChild.getNodeType() != Node.ELEMENT_NODE) continue; String stateVariableName = getUnprefixedNodeName(propertyChild); for (StateVariable stateVariable : stateVariables) { if (stateVariable.getName().equals(stateVariableName)) { log.fine("Reading state variable value: " + stateVariableName); String value = XMLUtil.getTextContent(propertyChild); message.getStateVariableValues().add( new StateVariableValue(stateVariable, value) ); break; } } } } } }
stateVariable.name = XMLUtil.getTextContent(stateVariableChild); } else if (ELEMENT.dataType.equals(stateVariableChild)) { String dtName = XMLUtil.getTextContent(stateVariableChild); Datatype.Builtin builtin = Datatype.Builtin.getByDescriptorName(dtName); stateVariable.dataType = builtin != null ? builtin.getDatatype() : new CustomDatatype(dtName); } else if (ELEMENT.defaultValue.equals(stateVariableChild)) { stateVariable.defaultValue = XMLUtil.getTextContent(stateVariableChild); } else if (ELEMENT.allowedValueList.equals(stateVariableChild)) { allowedValues.add(XMLUtil.getTextContent(allowedValueListChild)); range.minimum = Long.valueOf(XMLUtil.getTextContent(allowedValueRangeChild)); } catch (Exception ex) { range.maximum = Long.valueOf(XMLUtil.getTextContent(allowedValueRangeChild)); } catch (Exception ex) { range.step = Long.valueOf(XMLUtil.getTextContent(allowedValueRangeChild)); } catch (Exception ex) {
errorCode = XMLUtil.getTextContent(errorChild); errorDescription = XMLUtil.getTextContent(errorChild);
service.serviceType = (ServiceType.valueOf(XMLUtil.getTextContent(serviceChild))); } else if (ELEMENT.serviceId.equals(serviceChild)) { service.serviceId = (ServiceId.valueOf(XMLUtil.getTextContent(serviceChild))); } else if (ELEMENT.SCPDURL.equals(serviceChild)) { service.descriptorURI = parseURI(XMLUtil.getTextContent(serviceChild)); } else if (ELEMENT.controlURL.equals(serviceChild)) { service.controlURI = parseURI(XMLUtil.getTextContent(serviceChild)); } else if (ELEMENT.eventSubURL.equals(serviceChild)) { service.eventSubscriptionURI = parseURI(XMLUtil.getTextContent(serviceChild));
descriptor.deviceType = XMLUtil.getTextContent(deviceNodeChild); } else if (ELEMENT.friendlyName.equals(deviceNodeChild)) { descriptor.friendlyName = XMLUtil.getTextContent(deviceNodeChild); } else if (ELEMENT.manufacturer.equals(deviceNodeChild)) { descriptor.manufacturer = XMLUtil.getTextContent(deviceNodeChild); } else if (ELEMENT.manufacturerURL.equals(deviceNodeChild)) { descriptor.manufacturerURI = parseURI(XMLUtil.getTextContent(deviceNodeChild)); } else if (ELEMENT.modelDescription.equals(deviceNodeChild)) { descriptor.modelDescription = XMLUtil.getTextContent(deviceNodeChild); } else if (ELEMENT.modelName.equals(deviceNodeChild)) { descriptor.modelName = XMLUtil.getTextContent(deviceNodeChild); } else if (ELEMENT.modelNumber.equals(deviceNodeChild)) { descriptor.modelNumber = XMLUtil.getTextContent(deviceNodeChild); } else if (ELEMENT.modelURL.equals(deviceNodeChild)) { descriptor.modelURI = parseURI(XMLUtil.getTextContent(deviceNodeChild)); } else if (ELEMENT.presentationURL.equals(deviceNodeChild)) { descriptor.presentationURI = parseURI(XMLUtil.getTextContent(deviceNodeChild)); } else if (ELEMENT.UPC.equals(deviceNodeChild)) { descriptor.upc = XMLUtil.getTextContent(deviceNodeChild); } else if (ELEMENT.serialNumber.equals(deviceNodeChild)) { descriptor.serialNumber = XMLUtil.getTextContent(deviceNodeChild); } else if (ELEMENT.UDN.equals(deviceNodeChild)) { descriptor.udn = UDN.valueOf(XMLUtil.getTextContent(deviceNodeChild)); } else if (ELEMENT.iconList.equals(deviceNodeChild)) { hydrateIconList(descriptor, deviceNodeChild); } else if (ELEMENT.X_DLNADOC.equals(deviceNodeChild) && Descriptor.Device.DLNA_PREFIX.equals(deviceNodeChild.getPrefix())) { String txt = XMLUtil.getTextContent(deviceNodeChild);
} else if (ELEMENT.URLBase.equals(rootChild)) { try { String urlString = XMLUtil.getTextContent(rootChild); if (urlString != null && urlString.length() > 0) {
/** * The UPnP spec says that action arguments must be in the order as declared * by the service. This method however is lenient, the action argument nodes * in the XML can be in any order, as long as they are all there everything * is OK. */ protected ActionArgumentValue[] readArgumentValues(NodeList nodeList, ActionArgument[] args) throws ActionException { List<Node> nodes = getMatchingNodes(nodeList, args); ActionArgumentValue[] values = new ActionArgumentValue[args.length]; for (int i = 0; i < args.length; i++) { ActionArgument arg = args[i]; Node node = findActionArgumentNode(nodes, arg); if(node == null) { throw new ActionException( ErrorCode.ARGUMENT_VALUE_INVALID, "Could not find argument '" + arg.getName() + "' node"); } log.fine("Reading action argument: " + arg.getName()); String value = XMLUtil.getTextContent(node); values[i] = createValue(arg, value); } return values; }
public void hydrateSpecVersion(MutableDevice descriptor, Node specVersionNode) throws DescriptorBindingException { NodeList specVersionChildren = specVersionNode.getChildNodes(); for (int i = 0; i < specVersionChildren.getLength(); i++) { Node specVersionChild = specVersionChildren.item(i); if (specVersionChild.getNodeType() != Node.ELEMENT_NODE) continue; if (ELEMENT.major.equals(specVersionChild)) { String version = XMLUtil.getTextContent(specVersionChild).trim(); if (!version.equals("1")) { log.warning("Unsupported UDA major version, ignoring: " + version); version = "1"; } descriptor.udaVersion.major = Integer.valueOf(version); } else if (ELEMENT.minor.equals(specVersionChild)) { String version = XMLUtil.getTextContent(specVersionChild).trim(); if (!version.equals("0")) { log.warning("Unsupported UDA minor version, ignoring: " + version); version = "0"; } descriptor.udaVersion.minor = Integer.valueOf(version); } } }
public void hydrateActionArgument(MutableActionArgument actionArgument, Node actionArgumentNode) { NodeList argumentNodeChildren = actionArgumentNode.getChildNodes(); for (int i = 0; i < argumentNodeChildren.getLength(); i++) { Node argumentNodeChild = argumentNodeChildren.item(i); if (argumentNodeChild.getNodeType() != Node.ELEMENT_NODE) continue; if (ELEMENT.name.equals(argumentNodeChild)) { actionArgument.name = XMLUtil.getTextContent(argumentNodeChild); } else if (ELEMENT.direction.equals(argumentNodeChild)) { String directionString = XMLUtil.getTextContent(argumentNodeChild); try { actionArgument.direction = ActionArgument.Direction.valueOf(directionString.toUpperCase(Locale.ENGLISH)); } catch (IllegalArgumentException ex) { // TODO: UPNP VIOLATION: Pelco SpectraIV-IP uses illegal value INOUT log.warning("UPnP specification violation: Invalid action argument direction, assuming 'IN': " + directionString); actionArgument.direction = ActionArgument.Direction.IN; } } else if (ELEMENT.relatedStateVariable.equals(argumentNodeChild)) { actionArgument.relatedStateVariable = XMLUtil.getTextContent(argumentNodeChild); } else if (ELEMENT.retval.equals(argumentNodeChild)) { actionArgument.retval = true; } } }
public void hydrateAction(MutableAction action, Node actionNode) { NodeList actionNodeChildren = actionNode.getChildNodes(); for (int i = 0; i < actionNodeChildren.getLength(); i++) { Node actionNodeChild = actionNodeChildren.item(i); if (actionNodeChild.getNodeType() != Node.ELEMENT_NODE) continue; if (ELEMENT.name.equals(actionNodeChild)) { action.name = XMLUtil.getTextContent(actionNodeChild); } else if (ELEMENT.argumentList.equals(actionNodeChild)) { NodeList argumentChildren = actionNodeChild.getChildNodes(); for (int j = 0; j < argumentChildren.getLength(); j++) { Node argumentChild = argumentChildren.item(j); if (argumentChild.getNodeType() != Node.ELEMENT_NODE) continue; MutableActionArgument actionArgument = new MutableActionArgument(); hydrateActionArgument(actionArgument, argumentChild); action.arguments.add(actionArgument); } } } }
icon.width = (Integer.valueOf(XMLUtil.getTextContent(iconChild))); } else if (ELEMENT.height.equals(iconChild)) { icon.height = (Integer.valueOf(XMLUtil.getTextContent(iconChild))); } else if (ELEMENT.depth.equals(iconChild)) { String depth = XMLUtil.getTextContent(iconChild); try { icon.depth = (Integer.valueOf(depth)); icon.uri = parseURI(XMLUtil.getTextContent(iconChild)); } else if (ELEMENT.mimetype.equals(iconChild)) { icon.mimeType = XMLUtil.getTextContent(iconChild);
public void hydrateServiceList(MutableDevice descriptor, Node serviceListNode) throws DescriptorBindingException { NodeList serviceListNodeChildren = serviceListNode.getChildNodes(); for (int i = 0; i < serviceListNodeChildren.getLength(); i++) { Node serviceListNodeChild = serviceListNodeChildren.item(i); if (serviceListNodeChild.getNodeType() != Node.ELEMENT_NODE) continue; if (ELEMENT.service.equals(serviceListNodeChild)) { MutableService service = new MutableService(); NodeList serviceChildren = serviceListNodeChild.getChildNodes(); for (int x = 0; x < serviceChildren.getLength(); x++) { Node serviceChild = serviceChildren.item(x); if (serviceChild.getNodeType() != Node.ELEMENT_NODE) continue; if (ELEMENT.serviceType.equals(serviceChild)) { service.serviceType = (ServiceType.valueOf(XMLUtil.getTextContent(serviceChild))); } else if (ELEMENT.serviceId.equals(serviceChild)) { service.serviceId = (ServiceId.valueOf(XMLUtil.getTextContent(serviceChild))); } else if (ELEMENT.SCPDURL.equals(serviceChild)) { service.descriptorURI = parseURI(XMLUtil.getTextContent(serviceChild)); } else if (ELEMENT.controlURL.equals(serviceChild)) { service.controlURI = parseURI(XMLUtil.getTextContent(serviceChild)); } else if (ELEMENT.eventSubURL.equals(serviceChild)) { service.eventSubscriptionURI = parseURI(XMLUtil.getTextContent(serviceChild)); } } descriptor.services.add(service); } } }
protected void readProperties(Element propertysetElement, IncomingEventRequestMessage message) { NodeList propertysetElementChildren = propertysetElement.getChildNodes(); StateVariable[] stateVariables = message.getService().getStateVariables(); for (int i = 0; i < propertysetElementChildren.getLength(); i++) { Node propertysetChild = propertysetElementChildren.item(i); if (propertysetChild.getNodeType() != Node.ELEMENT_NODE) continue; if (getUnprefixedNodeName(propertysetChild).equals("property")) { NodeList propertyChildren = propertysetChild.getChildNodes(); for (int j = 0; j < propertyChildren.getLength(); j++) { Node propertyChild = propertyChildren.item(j); if (propertyChild.getNodeType() != Node.ELEMENT_NODE) continue; String stateVariableName = getUnprefixedNodeName(propertyChild); for (StateVariable stateVariable : stateVariables) { if (stateVariable.getName().equals(stateVariableName)) { log.fine("Reading state variable value: " + stateVariableName); String value = XMLUtil.getTextContent(propertyChild); message.getStateVariableValues().add( new StateVariableValue(stateVariable, value) ); break; } } } } } }
descriptor.deviceType = XMLUtil.getTextContent(deviceNodeChild); } else if (ELEMENT.friendlyName.equals(deviceNodeChild)) { descriptor.friendlyName = XMLUtil.getTextContent(deviceNodeChild); } else if (ELEMENT.manufacturer.equals(deviceNodeChild)) { descriptor.manufacturer = XMLUtil.getTextContent(deviceNodeChild); } else if (ELEMENT.manufacturerURL.equals(deviceNodeChild)) { descriptor.manufacturerURI = parseURI(XMLUtil.getTextContent(deviceNodeChild)); } else if (ELEMENT.modelDescription.equals(deviceNodeChild)) { descriptor.modelDescription = XMLUtil.getTextContent(deviceNodeChild); } else if (ELEMENT.modelName.equals(deviceNodeChild)) { descriptor.modelName = XMLUtil.getTextContent(deviceNodeChild); } else if (ELEMENT.modelNumber.equals(deviceNodeChild)) { descriptor.modelNumber = XMLUtil.getTextContent(deviceNodeChild); } else if (ELEMENT.modelURL.equals(deviceNodeChild)) { descriptor.modelURI = parseURI(XMLUtil.getTextContent(deviceNodeChild)); } else if (ELEMENT.presentationURL.equals(deviceNodeChild)) { descriptor.presentationURI = parseURI(XMLUtil.getTextContent(deviceNodeChild)); } else if (ELEMENT.UPC.equals(deviceNodeChild)) { descriptor.upc = XMLUtil.getTextContent(deviceNodeChild); } else if (ELEMENT.serialNumber.equals(deviceNodeChild)) { descriptor.serialNumber = XMLUtil.getTextContent(deviceNodeChild); } else if (ELEMENT.UDN.equals(deviceNodeChild)) { descriptor.udn = UDN.valueOf(XMLUtil.getTextContent(deviceNodeChild)); } else if (ELEMENT.iconList.equals(deviceNodeChild)) { hydrateIconList(descriptor, deviceNodeChild); } else if (ELEMENT.X_DLNADOC.equals(deviceNodeChild) && Descriptor.Device.DLNA_PREFIX.equals(deviceNodeChild.getPrefix())) { String txt = XMLUtil.getTextContent(deviceNodeChild);
} else if (ELEMENT.URLBase.equals(rootChild)) { try { String urlString = XMLUtil.getTextContent(rootChild); if (urlString != null && urlString.length() > 0) {
/** * The UPnP spec says that action arguments must be in the order as declared * by the service. This method however is lenient, the action argument nodes * in the XML can be in any order, as long as they are all there everything * is OK. */ protected ActionArgumentValue[] readArgumentValues(NodeList nodeList, ActionArgument[] args) throws ActionException { List<Node> nodes = getMatchingNodes(nodeList, args); ActionArgumentValue[] values = new ActionArgumentValue[args.length]; for (int i = 0; i < args.length; i++) { ActionArgument arg = args[i]; Node node = findActionArgumentNode(nodes, arg); if(node == null) { throw new ActionException( ErrorCode.ARGUMENT_VALUE_INVALID, "Could not find argument '" + arg.getName() + "' node"); } log.fine("Reading action argument: " + arg.getName()); String value = XMLUtil.getTextContent(node); values[i] = createValue(arg, value); } return values; }