@Test public void pathServiceGroupRegexTest() throws JAXBException, PublisherException { HttpServletRequest request = mock(HttpServletRequest.class); when(request.getRequestURI()).thenReturn(PARTICIPANT_PARAM); HttpServletResponse response = mock(HttpServletResponse.class); publisherServlet.doGet(request, response); verify(publisherService).serviceGroup((OutputStream)isNull(), (String)isNull(), any(URI.class), any(ParticipantIdentifier.class)); }
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) { try { String path = ModelUtils.urldecode(req.getRequestURI()); Matcher matcher = PATH_SERVICE_METADATA.matcher(path); if (matcher.matches()) { handleMetadataProvider(req, resp, matcher.group(1), matcher.group(2)); return; } matcher = PATH_SERVICE_GROUP.matcher(path); if (matcher.matches()) { handleServiceGroup(req, resp, matcher.group(1)); return; } resp.setStatus(HttpServletResponse.SC_NOT_FOUND); } catch (PeppolParsingException e) { resp.setStatus(HttpServletResponse.SC_BAD_REQUEST); } catch (NotFoundException e) { resp.setStatus(HttpServletResponse.SC_NOT_FOUND); } catch (JAXBException | IOException | NullPointerException | PublisherException e) { log.error(e.getMessage(), e); resp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } }
PublisherServlet extends HttpServlet { @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) { try { String path = ModelUtils.urldecode(req.getRequestURI()); Matcher matcher = PATH_SERVICE_METADATA.matcher(path); if (matcher.matches()) { handleMetadataProvider(req, resp, matcher.group(1), matcher.group(2)); return; } matcher = PATH_SERVICE_GROUP.matcher(path); if (matcher.matches()) { handleServiceGroup(req, resp, matcher.group(1)); return; } resp.setStatus(HttpServletResponse.SC_NOT_FOUND); } catch (PeppolParsingException e) { resp.setStatus(HttpServletResponse.SC_BAD_REQUEST); } catch (NotFoundException e) { resp.setStatus(HttpServletResponse.SC_NOT_FOUND); } catch (JAXBException | IOException | NullPointerException | PublisherException e) { log.error(e.getMessage(), e); resp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } } }
PublisherServlet extends HttpServlet { @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) { try { String path = ModelUtils.urldecode(req.getRequestURI()); Matcher matcher = PATH_SERVICE_METADATA.matcher(path); if (matcher.matches()) { handleMetadataProvider(req, resp, matcher.group(1), matcher.group(2)); return; } matcher = PATH_SERVICE_GROUP.matcher(path); if (matcher.matches()) { handleServiceGroup(req, resp, matcher.group(1)); return; } resp.setStatus(HttpServletResponse.SC_NOT_FOUND); } catch (PeppolParsingException e) { resp.setStatus(HttpServletResponse.SC_BAD_REQUEST); } catch (NotFoundException e) { resp.setStatus(HttpServletResponse.SC_NOT_FOUND); } catch (JAXBException | IOException | NullPointerException | PublisherException e) { log.error(e.getMessage(), e); resp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } } PublisherServlet(PublisherService publisherService); }
PublisherServlet extends HttpServlet { @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) { try { String path = ModelUtils.urldecode(req.getRequestURI()); Matcher matcher = PATH_SERVICE_METADATA.matcher(path); if (matcher.matches()) { handleMetadataProvider(req, resp, matcher.group(1), matcher.group(2)); return; } matcher = PATH_SERVICE_GROUP.matcher(path); if (matcher.matches()) { handleServiceGroup(req, resp, matcher.group(1)); return; } resp.setStatus(HttpServletResponse.SC_NOT_FOUND); } catch (PeppolParsingException e) { resp.setStatus(HttpServletResponse.SC_BAD_REQUEST); } catch (NotFoundException e) { resp.setStatus(HttpServletResponse.SC_NOT_FOUND); } catch (JAXBException | IOException | NullPointerException | PublisherException e) { log.error(e.getMessage(), e); resp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } } PublisherServlet(PublisherService publisherService); void handleServiceGroup(HttpServletRequest req, HttpServletResponse resp, String participantParam); void handleMetadataProvider(HttpServletRequest req, HttpServletResponse resp,
                                       String participantParam, String documentTypeParam); }
PublisherServlet extends HttpServlet { @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) { try { String path = ModelUtils.urldecode(req.getRequestURI()); Matcher matcher = PATH_SERVICE_METADATA.matcher(path); if (matcher.matches()) { handleMetadataProvider(req, resp, matcher.group(1), matcher.group(2)); return; } matcher = PATH_SERVICE_GROUP.matcher(path); if (matcher.matches()) { handleServiceGroup(req, resp, matcher.group(1)); return; } resp.setStatus(HttpServletResponse.SC_NOT_FOUND); } catch (PeppolParsingException e) { resp.setStatus(HttpServletResponse.SC_BAD_REQUEST); } catch (NotFoundException e) { resp.setStatus(HttpServletResponse.SC_NOT_FOUND); } catch (JAXBException | IOException | NullPointerException | PublisherException e) { log.error(e.getMessage(), e); resp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } } PublisherServlet(PublisherService publisherService); void handleServiceGroup(HttpServletRequest req, HttpServletResponse resp, String participantParam); void handleMetadataProvider(HttpServletRequest req, HttpServletResponse resp,
                                       String participantParam, String documentTypeParam);  }