use of org.cybergarage.xml.Parser in project i2p.i2p by i2p.
the class ControlPoint method addDevice.
private synchronized void addDevice(SSDPPacket ssdpPacket) {
if (ssdpPacket.isRootDevice() == false)
return;
String usn = ssdpPacket.getUSN();
String udn = USN.getUDN(usn);
Device dev = getDevice(udn);
if (dev != null) {
dev.setSSDPPacket(ssdpPacket);
return;
}
String location = ssdpPacket.getLocation();
try {
URL locationUrl = new URL(location);
Parser parser = UPnP.getXMLParser();
Node rootNode = parser.parse(locationUrl);
Device rootDev = getDevice(rootNode);
if (rootDev == null)
return;
rootDev.setSSDPPacket(ssdpPacket);
Debug.warning("Add root device", new Exception("received on " + ssdpPacket.getLocalAddress()));
addDevice(rootNode);
// Thanks for Oliver Newell (2004/10/16)
// After node is added, invoke the AddDeviceListener to notify high-level
// control point application that a new device has been added. (The
// control point application must implement the DeviceChangeListener interface
// to receive the notifications)
performAddDeviceListener(rootDev);
} catch (MalformedURLException me) {
Debug.warning(ssdpPacket.toString());
Debug.warning(me);
} catch (ParserException pe) {
Debug.warning(ssdpPacket.toString());
Debug.warning(pe);
}
}
use of org.cybergarage.xml.Parser in project i2p.i2p by i2p.
the class Device method loadDescription.
public boolean loadDescription(File file) throws InvalidDescriptionException {
try {
Parser parser = UPnP.getXMLParser();
rootNode = parser.parse(file);
if (rootNode == null)
throw new InvalidDescriptionException(Description.NOROOT_EXCEPTION, file);
deviceNode = rootNode.getNode(Device.ELEM_NAME);
if (deviceNode == null)
throw new InvalidDescriptionException(Description.NOROOTDEVICE_EXCEPTION, file);
} catch (ParserException e) {
throw new InvalidDescriptionException(e);
}
if (initializeLoadedDescription() == false)
return false;
setDescriptionFile(file);
return true;
}
use of org.cybergarage.xml.Parser in project i2p.i2p by i2p.
the class Device method loadDescription.
/**
* @since 1.8.0
*/
public boolean loadDescription(InputStream input) throws InvalidDescriptionException {
try {
Parser parser = UPnP.getXMLParser();
rootNode = parser.parse(input);
if (rootNode == null)
throw new InvalidDescriptionException(Description.NOROOT_EXCEPTION);
deviceNode = rootNode.getNode(Device.ELEM_NAME);
if (deviceNode == null)
throw new InvalidDescriptionException(Description.NOROOTDEVICE_EXCEPTION);
} catch (ParserException e) {
throw new InvalidDescriptionException(e);
}
if (initializeLoadedDescription() == false)
return false;
setDescriptionFile(null);
return true;
}
use of org.cybergarage.xml.Parser in project i2p.i2p by i2p.
the class Service method loadSCPD.
/**
* @since 1.8.0
*/
public boolean loadSCPD(InputStream input) throws ParserException {
Parser parser = UPnP.getXMLParser();
Node scpdNode = parser.parse(input);
if (scpdNode == null)
return false;
ServiceData data = getServiceData();
data.setSCPDNode(scpdNode);
return true;
}
use of org.cybergarage.xml.Parser in project i2p.i2p by i2p.
the class SOAPRequest method postMessage.
// //////////////////////////////////////////////
// post
// //////////////////////////////////////////////
public SOAPResponse postMessage(String host, int port) {
HTTPResponse httpRes = post(host, port);
SOAPResponse soapRes = new SOAPResponse(httpRes);
byte[] content = soapRes.getContent();
if (content.length <= 0)
return soapRes;
try {
ByteArrayInputStream byteIn = new ByteArrayInputStream(content);
Parser xmlParser = SOAP.getXMLParser();
Node rootNode = xmlParser.parse(byteIn);
soapRes.setEnvelopeNode(rootNode);
} catch (Exception e) {
Debug.warning(e);
}
return soapRes;
}
Aggregations