This commit is contained in:
Andrea Manzi 2013-03-14 11:12:49 +00:00
parent 79f7a79df7
commit 8dc99d7083
1 changed files with 12 additions and 7 deletions

View File

@ -22,7 +22,7 @@ import org.slf4j.LoggerFactory;
/** /**
* *
* @author andrea * @author Andrea Manzi(CERN)
* *
*/ */
public class HttpResolver extends HttpServlet { public class HttpResolver extends HttpServlet {
@ -45,17 +45,18 @@ public class HttpResolver extends HttpServlet {
String uri = request.getParameter("smp-uri"); String uri = request.getParameter("smp-uri");
if (uri == null || uri.equals("")) {
logger.debug("URI not found");
response.sendError(404);
return;
}
uri = uri.replace(" ","+");//the char + is removed when the servlet is doing unescaping of the query paramenters, we just put it back uri = uri.replace(" ","+");//the char + is removed when the servlet is doing unescaping of the query paramenters, we just put it back
logger.debug("URI = "+ uri); logger.debug("URI = "+ uri);
try { try {
if (uri == null || uri.equals("")) {
// the document has not id - not found
response.sendError(404);
return;
}
OutputStream out = response.getOutputStream(); OutputStream out = response.getOutputStream();
@ -77,7 +78,9 @@ public class HttpResolver extends HttpServlet {
in = uc.getInputStream(); in = uc.getInputStream();
} }
catch(Exception e){ catch(Exception e){
e.printStackTrace(); response.sendError(404);
logger.error("Exception:", e);
return;
} }
@ -90,6 +93,8 @@ public class HttpResolver extends HttpServlet {
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
logger.error("Exception:", e); logger.error("Exception:", e);
response.sendError(404);
return;
} }
} }