Commit 97a918b2 authored by neelesh thakur's avatar neelesh thakur
Browse files

address comments

parent 95bb8962
......@@ -2,6 +2,7 @@ package org.opengroup.osdu.search.provider.azure.security;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import org.opengroup.osdu.azure.logging.CoreLoggerFactory;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.http.HttpStatus;
......@@ -22,6 +23,8 @@ import java.io.IOException;
@Order(Ordered.HIGHEST_PRECEDENCE)
public class RequestRejectedExceptionFilter extends GenericFilterBean {
private static final String LOGGER_NAME = RequestRejectedExceptionFilter.class.getName();
@Override
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
try {
......@@ -29,6 +32,7 @@ public class RequestRejectedExceptionFilter extends GenericFilterBean {
} catch (RequestRejectedException e) {
HttpServletRequest request = (HttpServletRequest) req;
HttpServletResponse response = (HttpServletResponse) res;
CoreLoggerFactory.getInstance().getLogger(LOGGER_NAME).info(String.format("Invalid URL: %s | message: %s", this.getRequestURL(request), e.getMessage()));
this.handleRequestRejectedException(request, response);
}
}
......@@ -45,4 +49,10 @@ public class RequestRejectedExceptionFilter extends GenericFilterBean {
response.setContentType(MediaType.APPLICATION_JSON.toString());
response.getWriter().append(jsonErrorResponse);
}
private String getRequestURL(HttpServletRequest request) {
StringBuilder requestURL = new StringBuilder(request.getRequestURL().toString());
String queryString = request.getQueryString();
return queryString == null ? requestURL.toString() : requestURL.append('?').append(queryString).toString();
}
}
\ No newline at end of file
Supports Markdown
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