public static Document callTurnitinReturnDocument(String apiURL, Map<String,Object> parameters, String secretKey, int timeout, Proxy proxy, boolean isMultipart) throws TransientSubmissionException, SubmissionException { InputStream inputStream = callTurnitinReturnInputStream(apiURL, parameters, secretKey, timeout, proxy, isMultipart); BufferedReader in; in = new BufferedReader(new InputStreamReader(inputStream)); Document document = null; try { DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder parser = documentBuilderFactory.newDocumentBuilder(); document = parser.parse(new org.xml.sax.InputSource(in)); } catch (ParserConfigurationException pce){ log.error("parser configuration error: " + pce.getMessage()); throw new TransientSubmissionException ("Parser configuration error", pce); } catch (Exception t) { throw new TransientSubmissionException ("Cannot parse Turnitin response. Assuming call was unsuccessful", t); } if (log.isDebugEnabled()) { log.debug(" Result from call: " + Xml.writeDocumentToString(document)); } return document; }
public static Map callTurnitinReturnMap(String apiURL, Map<String,Object> parameters, String secretKey, int timeout, Proxy proxy) throws TransientSubmissionException, SubmissionException { XMLTranscoder xmlt = new XMLTranscoder(); try (InputStream inputStream = callTurnitinReturnInputStream(apiURL, parameters, secretKey, timeout, proxy, false)) { Map togo = xmlt.decode(IOUtils.toString(inputStream)); log.debug("Turnitin Result Payload: " + togo); return togo; } catch (Exception t) { // Could be 'java.lang.IllegalArgumentException: xml cannot be null or empty' from IO errors throw new TransientSubmissionException ("Cannot parse Turnitin response. Assuming call was unsuccessful", t); } }
throw new TransientSubmissionException("Error logging in to turnitin: " + message);
} else { if ("218".equals(rcode) || "9999".equals(rcode)) { throw new TransientSubmissionException("Create Class not successful. Message: " + ((CharacterData) (root.getElementsByTagName("rmessage").item(0).getFirstChild())).getData() .trim()
throw new TransientSubmissionException("IOException making turnitin call.", t); throw new TransientSubmissionException("Unable to submit the content data from ContentHosting", t);
+ ". Code: " + rcode); throw new TransientSubmissionException("FirstDate Create Assignment not successful. Message: " + ((CharacterData) (root.getElementsByTagName("rmessage").item(0).getFirstChild())).getData() .trim() + ". Code: " + rcode); throw new TransientSubmissionException("Create Assignment not successful. Message: " + ((CharacterData) (root.getElementsByTagName("rmessage").item(0).getFirstChild())).getData().trim() + ". Code: " + rcode, Integer.valueOf(rcode));