Commit 488bc953 authored by Mathijs den Burger's avatar Mathijs den Burger

CMS-10585 Refactor not-found case into separate helper method

parent 7d09a08c
......@@ -364,15 +364,13 @@ public class ResourceServlet extends HttpServlet {
final URL resource = getResourceURL(resourcePath, queryParams);
if (resource == null) {
log.debug("Resource not found: {}", resourcePath);
response.sendError(HttpServletResponse.SC_NOT_FOUND);
notFound(response, resourcePath);
return;
}
final URLConnection conn = resource.openConnection();
if (conn == null) {
log.debug("Resource not found: {}", resourcePath);
response.sendError(HttpServletResponse.SC_NOT_FOUND);
notFound(response, resourcePath);
return;
}
......@@ -387,8 +385,7 @@ public class ResourceServlet extends HttpServlet {
final HttpURLConnection httpConn = (HttpURLConnection) conn;
try {
if (httpConn.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND) {
log.debug("Resource not found: {}", resourcePath);
response.sendError(HttpServletResponse.SC_NOT_FOUND);
notFound(response, resourcePath);
return;
}
} catch (ConnectException e) {
......@@ -420,6 +417,11 @@ public class ResourceServlet extends HttpServlet {
}
}
private void notFound(final HttpServletResponse response, final String resourcePath) throws IOException {
log.debug("Resource not found: {}", resourcePath);
response.sendError(HttpServletResponse.SC_NOT_FOUND);
}
private Set<Pattern> initPatterns(final String paramName, Set<Pattern> defaultPatterns) {
final String param = getInitParameter(paramName, null);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment