List of usage examples for org.xml.sax InputSource toString
public String toString()
From source file:org.dspace.content.authority.SkylightAPIProtocol.java
protected Choices query(String result, String label, String authority, String args, int start, int limit) throws UnsupportedEncodingException { String encodedArgs = new String(args.getBytes("UTF-8"), "UTF-8"); HttpClient hc = new HttpClient(); String srUrl = url + "/search/" + encodedArgs + ".xml?field=" + label; GetMethod get = new GetMethod(srUrl); log.info("Trying Skylight Query, URL=" + srUrl); try {//from www .j a v a 2 s . c o m int status = hc.executeMethod(get); log.info("Status" + status); if (status == 200) { SAXParserFactory spf = SAXParserFactory.newInstance(); SAXParser sp = spf.newSAXParser(); XMLReader xr = sp.getXMLReader(); SRHandler handler = new SRHandler(result, label, authority); // XXX FIXME: should turn off validation here explicitly, but // it seems to be off by default. xr.setFeature("http://xml.org/sax/features/namespaces", true); xr.setContentHandler(handler); xr.setErrorHandler(handler); InputSource src = new InputSource(get.getResponseBodyAsStream()); log.info("Source from sklightui :: " + src.toString()); xr.parse(src); int confidence; if (handler.total == 0) { confidence = Choices.CF_NOTFOUND; } else if (handler.total == 1) { confidence = Choices.CF_UNCERTAIN; } else { confidence = Choices.CF_AMBIGUOUS; } return new Choices(handler.result, start, handler.total, confidence, false); } } catch (HttpException e) { log.error("Skylight query failed: ", e); return null; } catch (IOException e) { log.error("Skylight query failed: ", e); return null; } catch (ParserConfigurationException e) { log.warn("Failed parsing SHERPA/RoMEO result: ", e); return null; } catch (SAXException e) { log.warn("Failed parsing Skylight result: ", e); return null; } finally { get.releaseConnection(); } return null; }