diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/org/onap/dmaap/mr/filter/ContentLengthFilter.java | 21 | ||||
-rw-r--r-- | src/main/java/org/onap/dmaap/mr/filter/DefaultLength.java | 6 |
2 files changed, 13 insertions, 14 deletions
diff --git a/src/main/java/org/onap/dmaap/mr/filter/ContentLengthFilter.java b/src/main/java/org/onap/dmaap/mr/filter/ContentLengthFilter.java index a175b16..dbf4246 100644 --- a/src/main/java/org/onap/dmaap/mr/filter/ContentLengthFilter.java +++ b/src/main/java/org/onap/dmaap/mr/filter/ContentLengthFilter.java @@ -74,8 +74,6 @@ public class ContentLengthFilter implements Filter { */ public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { - // TODO Auto-generated method stub - // place your code here log.info("inside servlet do filter content length checking before pub/sub"); HttpServletRequest request = (HttpServletRequest) req; JSONObject jsonObj = null; @@ -105,12 +103,14 @@ public class ContentLengthFilter implements Filter { chain.doFilter(req, res); } } catch (CambriaApiException | NumberFormatException e) { - log.error("message size is greater then default"); - ErrorResponse errRes = new ErrorResponse(HttpStatus.SC_EXPECTATION_FAILED, - DMaaPResponseCode.MSG_SIZE_EXCEEDS_MSG_LIMIT.getResponseCode(), errorMessages.getMsgSizeExceeds() - + jsonObj.toString()); - log.info(errRes.toString()); - + log.error("message size is greater then default", e); + if (jsonObj != null) { + ErrorResponse errRes = new ErrorResponse(HttpStatus.SC_EXPECTATION_FAILED, + DMaaPResponseCode.MSG_SIZE_EXCEEDS_MSG_LIMIT.getResponseCode(), + errorMessages.getMsgSizeExceeds() + + jsonObj.toString()); + log.info(errRes.toString()); + } } } @@ -119,14 +119,13 @@ public class ContentLengthFilter implements Filter { * @see Filter#init(FilterConfig) */ public void init(FilterConfig fConfig) throws ServletException { - // TODO Auto-generated method stub this.filterConfig = fConfig; log.info("Filter Content Length Initialize"); ApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(fConfig .getServletContext()); DefaultLength defLength = (DefaultLength) ctx.getBean("defLength"); - DMaaPErrorMessages errorMessages = (DMaaPErrorMessages) ctx.getBean("DMaaPErrorMessages"); - this.errorMessages = errorMessages; + DMaaPErrorMessages errMessages = (DMaaPErrorMessages) ctx.getBean("DMaaPErrorMessages"); + this.errorMessages = errMessages; this.defaultLength = defLength; } diff --git a/src/main/java/org/onap/dmaap/mr/filter/DefaultLength.java b/src/main/java/org/onap/dmaap/mr/filter/DefaultLength.java index 598ef1b..3425823 100644 --- a/src/main/java/org/onap/dmaap/mr/filter/DefaultLength.java +++ b/src/main/java/org/onap/dmaap/mr/filter/DefaultLength.java @@ -24,14 +24,14 @@ package org.onap.dmaap.mr.filter; public class DefaultLength { - String defaultLength; + String defLength; public String getDefaultLength() { - return defaultLength; + return defLength; } public void setDefaultLength(String defaultLength) { - this.defaultLength = defaultLength; + this.defLength = defaultLength; } } |