Skip to content

Commit

Permalink
updated logging of requests
Browse files Browse the repository at this point in the history
  • Loading branch information
anneferger committed Jun 24, 2024
1 parent b894dee commit b7e7f1c
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 16 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>pl.psnc.dl.ege</groupId>
<artifactId>ege-framework</artifactId>
<version>0.5.5</version>
<version>0.5.6</version>
<name>EGE Framework</name>
<properties>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ public class Conversion {
* of possible conversions paths.
*/
public static void doGetHelper(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
LOGGER.debug("REQUEST: " + request.getRequestURL() + " " + request.getContextPath() + " " + request.toString());
try {
RequestResolver rr = new ConversionRequestResolver(request,
Method.GET);
Expand All @@ -102,17 +101,17 @@ public static void doGetHelper(HttpServletRequest request, HttpServletResponse r
}
printConversionPossibilities(response, rr, inpfo);
}

} catch (RequestResolvingException ex) {
} catch (RequestResolvingException ex) {
if (ex.getStatus().equals(
RequestResolvingException.Status.WRONG_METHOD)) {
response.sendError(405, R_WRONG_METHOD);
} else {
throw new ServletException(ex);
}
}
LOGGER.debug("REQUEST: " + request.getRequestURL() + "; " + request.getMethod() + "; " + response.getStatus());

}
}

/*
* Send in response xml data of possible conversions paths.
Expand Down Expand Up @@ -239,13 +238,12 @@ protected static void printConversionPossibilities(HttpServletResponse response,
public static void doPostHelper(
HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
LOGGER.debug("REQUEST: " + request.getRequestURL() + " " + request.getContextPath());
try {
ConversionRequestResolver rr = new ConversionRequestResolver(
request, Method.POST);
List<DataType> pathFrame = (List<DataType>) rr.getData();
performConversion(response, rr, pathFrame);
} catch (RequestResolvingException ex) {
} catch (RequestResolvingException ex) {
if (ex.getStatus().equals(
RequestResolvingException.Status.BAD_REQUEST)) {
response.sendError(HttpServletResponse.SC_BAD_REQUEST);
Expand All @@ -258,6 +256,7 @@ public static void doPostHelper(
} catch (Exception ex) {
throw new ServletException(ex);
}
LOGGER.debug("REQUEST: " + request.getRequestURL() + "; " + request.getMethod() + "; " + response.getStatus());
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,13 @@ public class Customization {
public void doGetHelper(
HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
LOGGER.debug("REQUEST: " + request.getRequestURL() + " " + request.getContextPath() + " " + request.toString());
try {
try {
//resolve request and catch any errors
RequestResolver rr = new CustomizationRequestResolver(request,
Method.GET);
//print available validation options
printAvailableCustomizationSettings(response, rr);
} catch (RequestResolvingException ex) {
} catch (RequestResolvingException ex) {
if (ex.getStatus().equals(
RequestResolvingException.Status.WRONG_METHOD)) {
//TODO : something with "wrong" method message (and others)
Expand All @@ -56,6 +55,7 @@ public void doGetHelper(
throw new ServletException(ex);
}
}
LOGGER.debug("REQUEST: " + request.getRequestURL() + "; " + request.getMethod() + "; " + response.getStatus());
}

/*
Expand Down Expand Up @@ -112,13 +112,12 @@ private void printAvailableCustomizationSettings(HttpServletResponse response,
public void doPostHelper(
HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
LOGGER.debug("REQUEST: " + request.getRequestURL() + " " + request.getContextPath());
try {
try {
RequestResolver rr = new CustomizationRequestResolver(request,
Method.POST);
String[] cs = (String[]) rr.getData();
performCustomization(cs, rr, response);
} catch (RequestResolvingException ex) {
} catch (RequestResolvingException ex) {
if (ex.getStatus().equals(
RequestResolvingException.Status.BAD_REQUEST)) {
response.sendError(HttpServletResponse.SC_BAD_REQUEST);
Expand All @@ -130,6 +129,7 @@ public void doPostHelper(
} catch (Exception ex) {
throw new ServletException(ex);
}
LOGGER.debug("REQUEST: " + request.getRequestURL() + "; " + request.getMethod() + "; " + response.getStatus());
}

/*
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/pl/psnc/dl/ege/webapp/servlethelpers/Info.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ public class Info extends HttpServlet {

public void doGetHelper(HttpServletRequest request, HttpServletResponse response, HttpServlet httpservlet)
throws IOException, ServletException {
LOGGER.debug("REQUEST: " + request.getRequestURL() + " " + request.getContextPath() + " " + request.toString());
servlet = httpservlet;
//String serverInfo = servlet.getServletContext().getServerInfo();
try {
Expand Down Expand Up @@ -96,7 +95,7 @@ public void doGetHelper(HttpServletRequest request, HttpServletResponse response
catch (IOException e) {
e.printStackTrace();
}

LOGGER.debug("REQUEST: " + request.getRequestURL() + "; " + request.getMethod() + "; " + response.getStatus());
}

public synchronized String getVersion(HttpServletRequest request) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ public void doGetHelper(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException
{
LOGGER.debug("REQUEST: " + request.getRequestURL() + " " + request.getContextPath() + " " + request.toString());
try {
//resolve request and catch any errors
RequestResolver rr = new ValidationRequestResolver(request,
Expand All @@ -58,6 +57,8 @@ public void doGetHelper(HttpServletRequest request,
throw new ServletException(ex);
}
}
LOGGER.debug("REQUEST: " + request.getRequestURL() + "; " + request.getMethod() + "; " + response.getStatus());

}


Expand Down

0 comments on commit b7e7f1c

Please sign in to comment.