Package com.denimgroup.threadfix.exception

Examples of com.denimgroup.threadfix.exception.RestIOException


    @Override
    public String postUrlAsString(String urlString, String data, String username, String password, String contentType) {
        if ((JIRA_BASE_URL + "/rest/api/2/issue").equals(urlString) && hasReporter(data) && reporterRestricted) {
            postErrorResponse = "{\"errorMessages\":[],\"errors\":{\"reporter\":\"Field 'reporter' cannot be set. It is not on the appropriate screen, or unknown.\"}}";
            throw new RestIOException(new Exception(), "Throwing mock 401 error.", 401);
        } else {
            return getResponse(urlString, username, password);
        }
    }
View Full Code Here


    @Override
    public String postUrlAsString(String urlString, String data, String username, String password, String contentType) {
        if ((VERSION_ONE_URL + "/rest/api/2/issue").equals(urlString) && hasReporter(data) && reporterRestricted) {
            postErrorResponse = "{\"errorMessages\":[],\"errors\":{\"reporter\":\"Field 'reporter' cannot be set. It is not on the appropriate screen, or unknown.\"}}";
            throw new RestIOException(new Exception(), "Throwing mock 401 error.", 401);
        } else {
            return getResponse(urlString, username, password);
        }
    }
View Full Code Here

        Map<String, String> nameIdMap;
        try {
            nameIdMap = getNameFieldMap("project/", "key");
        } catch (RestIOException e) {
            if (e.getStatusCode() == 401) {
                throw new RestIOException(e, "Invalid JIRA credentials, server returned 401 Unauthorized.");
            } else {
                throw e;
            }
        }
View Full Code Here

      InputStream stream = httpConnection.getInputStream();

            return stream;
    } catch (IOException e) {
            LOG.info("Encountered IOException, unable to continue");
        throw new RestIOException(e, "Unable to communicate with the server.", getStatusCode(httpConnection));
    }
  }
View Full Code Here

    String test = null;
    try {
      test = IOUtils.toString(responseStream);
    } catch (IOException e) {
      throw new RestIOException(e, "Unable to get response from server.");
    } finally {
      closeInputStream(responseStream);
    }

    return test;
View Full Code Here

            LOG.warn("Error stream from HTTP connection was null");
          } else {
            LOG.warn("Error stream from HTTP connection was not null. Attempting to get response text.");
                        setPostErrorResponse(IOUtils.toString(errorStream));
            LOG.warn("Error text in response was '" + getPostErrorResponse() + "'");
                        throw new RestIOException(e, "Received error from server. Check the logs for more details.",
                                "Unable to get response from server. Error text was: " +
                                getPostErrorResponse(), getStatusCode(httpConnection));
          }
        } catch (IOException e2) {
          LOG.warn("IOException encountered trying to read the reason for the previous IOException: "
                            + e2.getMessage(), e2);
                    throw new RestIOException(e2, "Unable to read response from server.", getStatusCode(httpConnection));
        }
      }
            throw new RestIOException(e, "Unable to read response from server.");
        } finally {
      if (outputWriter != null) {
        try {
          outputWriter.close();
        } catch (IOException e) {
View Full Code Here

   
    String test = null;
    try {
            test = IOUtils.toString(responseStream);
    } catch (IOException e) {
      throw new RestIOException(e, "Unable to parse response from server.");
    } finally {
      closeInputStream(responseStream);
    }
   
    return test;
View Full Code Here

  public static void readSAXInput(DefaultHandler handler, String completionCode, InputStream stream) {
    try {
      readSAXInput(handler, stream);
    } catch (IOException e) {
            STATIC_LOGGER.error("Encountered IOException while trying to read the SAX input.");
            throw new RestIOException(e, "Encountered IOException while trying to read data. Can't continue.");
    } catch (SAXException e) {
      if (!e.getMessage().equals(completionCode)) {
                STATIC_LOGGER.error("Encountered SAXException while trying to read the SAX input.");
                throw new RestIOException(e, "Encountered SAXException while trying to read data. Can't continue.");
            }
    } finally {
      closeInputStream(stream);
    }
  }
View Full Code Here

      ScanUtils.readSAXInput(collector, "Done.", stream);
     
      return getType(collector.tags);
    } catch (IOException | RestIOException e) {
      log.error("Encountered IOException. Rethrowing.");
            throw new RestIOException(e, "Unable to determine scan type.");
    }
  }
View Full Code Here

            return new ObjectMapper().readValue(jsonString, JiraJsonMetadataResponse.class).getProjectOrNull();
        } catch (IOException e) {
            LOG.info("Failed to deserialize JSON.");
            LOG.debug("Failing JSON: " + jsonString, e);

            throw new RestIOException(e, "Unable to parse server response.");
        }
    }
View Full Code Here

TOP

Related Classes of com.denimgroup.threadfix.exception.RestIOException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.