test_class.declarator: logger = LoggerFactory.getLogger(SxmpServletProcessorTest.class)
test_class.modifier: private static final
test_class.original_string: private static final Logger logger = LoggerFactory.getLogger(SxmpServletProcessorTest.class);
test_class.type: Logger
test_class.var_name: logger
test_class.declarator: thrown= ExpectedException.none()
test_class.modifier: @Rule
      public
test_class.original_string: @Rule
      public ExpectedException thrown= ExpectedException.none();
test_class.type: ExpectedException
test_class.var_name: thrown
test_class.file: ch-sxmp/src/test/java/com/cloudhopper/sxmp/servlet/SxmpServletProcessorTest.java
test_class.identifier: SxmpServletProcessorTest
test_case.body: @Test
      public void doProcessBadAPIVersion() throws Exception {
          SxmpServletProcessor processor = new SxmpServletProcessor();
  
          try {
              processor.doProcess(null, null, null, "/any/path/to/servlet/2.0", "POST", "text/xml");
          } catch (HttpStatusCodeException e) {
              // correct behavior
              Assert.assertEquals(HttpStatus.SC_BAD_REQUEST, e.getStatusCode());
              Assert.assertThat(e.getMessage(), CoreMatchers.containsString("Unsupported API version"));
          }
      }
test_case.class_method_signature: SxmpServletProcessorTest.doProcessBadAPIVersion()
test_case.full_signature: @Test public void doProcessBadAPIVersion()
test_case.identifier: doProcessBadAPIVersion
test_case.invocations: doProcess assertEquals getStatusCode assertThat getMessage containsString
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void doProcessBadAPIVersion()
focal_class.declarator: logger = LoggerFactory.getLogger(SxmpServletProcessor.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger logger = LoggerFactory.getLogger(SxmpServletProcessor.class);
focal_class.type: Logger
focal_class.var_name: logger
focal_class.declarator: fatal = MarkerFactory.getMarker("FATAL")
focal_class.modifier: private static final
focal_class.original_string: private static final Marker fatal = MarkerFactory.getMarker("FATAL");
focal_class.type: Marker
focal_class.var_name: fatal
focal_class.file: ch-sxmp/src/main/java/com/cloudhopper/sxmp/servlet/SxmpServletProcessor.java
focal_class.identifier: SxmpServletProcessor
focal_class.class_method_signature: SxmpServletProcessor.SxmpServletProcessor()
focal_class.full_signature: public  SxmpServletProcessor()
focal_class.identifier: SxmpServletProcessor
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.signature:  SxmpServletProcessor()
focal_class.class_method_signature: SxmpServletProcessor.process(SxmpProcessor processor, HttpServletRequest request, HttpServletResponse response)
focal_class.full_signature: public void process(SxmpProcessor processor, HttpServletRequest request, HttpServletResponse response)
focal_class.identifier: process
focal_class.modifiers: public
focal_class.parameters: (SxmpProcessor processor, HttpServletRequest request, HttpServletResponse response)
focal_class.return: void
focal_class.signature: void process(SxmpProcessor processor, HttpServletRequest request, HttpServletResponse response)
focal_class.class_method_signature: SxmpServletProcessor.doProcess(SxmpProcessor processor, InputStream in, PrintWriter out, String uri, String method, String contentType)
focal_class.full_signature: public static void doProcess(SxmpProcessor processor, InputStream in, PrintWriter out, String uri, String method, String contentType)
focal_class.identifier: doProcess
focal_class.modifiers: public static
focal_class.parameters: (SxmpProcessor processor, InputStream in, PrintWriter out, String uri, String method, String contentType)
focal_class.return: void
focal_class.signature: void doProcess(SxmpProcessor processor, InputStream in, PrintWriter out, String uri, String method, String contentType)
focal_method.body: public static void doProcess(SxmpProcessor processor, InputStream in, PrintWriter out, String uri, String method, String contentType) throws IOException, HttpStatusCodeException {
          // validate the user went to the correct URL
          // E.g. /api/sxmp/1.0
          // find the next position of last / (to extract version)
          int posOfVersion = uri.lastIndexOf('/');
          if (posOfVersion < 0 || posOfVersion+1 >= uri.length()) {
              throw new HttpStatusCodeException(HttpServletResponse.SC_NOT_FOUND, "Bad URL used, could not extract version or no data for version");
          }
  
          String version = uri.substring(posOfVersion+1);
          //logger.debug("Parsed API Version: " + version);
  
          // check if the version is supported
          if (!version.equals(SxmpParser.VERSION_1_0) && !version.equals(SxmpParser.VERSION_1_1)) {
              throw new HttpStatusCodeException(HttpServletResponse.SC_BAD_REQUEST, "Unsupported API version in URL");
          }
  
          // validate the user did a POST
          if (!method.equalsIgnoreCase("POST")) {
              throw new HttpStatusCodeException(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "Only HTTP POST methods are acceptable");
          }
  
          // validate the user posted "text/xml"
          //logger.debug("Request contentType: " + contentType);
          if (contentType == null || !contentType.toLowerCase().startsWith("text/xml")) {
              throw new HttpStatusCodeException(HttpServletResponse.SC_BAD_REQUEST, "Unsupported Content-Type HTTP Header - Must Be text/xml");
          }
  
          // create a new session tied to this processor
          SxmpSession session = new SxmpSession(processor, version);
  
          Response response = null;
          try {
              // process request, get response
              response = session.process(in);
          } catch (Exception e) {
              // any exception thrown in process() should generate a non-200 HTTP status code
              // the exception also would have already been logged in the SxmpSession, so we
              // won't print it here and duplicate it -- any error during processing
              // would actually have returned an ErrorResponse
              throw new HttpStatusCodeException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());
          }
  
          // at this point, we should have a response
          if (response == null) {
              logger.error(fatal, "The response from SxmpSession.process() was null -- should be impossible");
              throw new HttpStatusCodeException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Response was empty");
          }
  
          try {
              // if we get here, write a response
              SxmpWriter.write(out, response);
          } catch (SxmpErrorException e) {
              logger.error("Error while writing response", e);
              throw new HttpStatusCodeException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Unable to cleanly write response to OutputStream");
          }
      }
focal_method.class_method_signature: SxmpServletProcessor.doProcess(SxmpProcessor processor, InputStream in, PrintWriter out, String uri, String method, String contentType)
focal_method.full_signature: public static void doProcess(SxmpProcessor processor, InputStream in, PrintWriter out, String uri, String method, String contentType)
focal_method.identifier: doProcess
focal_method.invocations: lastIndexOf length substring equals equals equalsIgnoreCase startsWith toLowerCase process getMessage error write error
focal_method.modifiers: public static
focal_method.parameters: (SxmpProcessor processor, InputStream in, PrintWriter out, String uri, String method, String contentType)
focal_method.return: void
focal_method.signature: void doProcess(SxmpProcessor processor, InputStream in, PrintWriter out, String uri, String method, String contentType)