-/*******************************************************************************\r
- * ============LICENSE_START=======================================================\r
- * org.onap.dmaap\r
- * ================================================================================\r
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * ================================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============LICENSE_END=========================================================\r
- *\r
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * \r
- *******************************************************************************/\r
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * org.onap.dmaap
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+*
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ *
+ *******************************************************************************/
package com.att.nsa.dmaap.util;\r
\r
import java.util.Map;\r
import org.json.JSONException;\r
import org.json.JSONObject;\r
import org.springframework.stereotype.Component;\r
-import com.att.nsa.cambria.CambriaApiException;\r
-import com.att.nsa.cambria.exception.DMaaPResponseCode;\r
-import com.att.nsa.cambria.exception.ErrorResponse;\r
+import com.att.dmf.mr.CambriaApiException;\r
+import com.att.dmf.mr.exception.DMaaPResponseCode;\r
+import com.att.dmf.mr.exception.ErrorResponse;\r
import ajsc.beans.interceptors.AjscInterceptor;\r
\r
/**\r
\r
\r
private String defLength;\r
+ //private Logger log = Logger.getLogger(ContentLengthInterceptor.class.toString());\r
private static final EELFLogger log = EELFManager.getInstance().getLogger(ContentLengthInterceptor.class);\r
\r
\r
// checking for no encoding, chunked and requestLength greater then\r
// default length\r
if (null != transferEncoding && !(transferEncoding.contains("chunked"))\r
- && (getDefLength() !=null && requestLength > Integer.parseInt(getDefLength()))) {\r
+ && (requestLength > Integer.parseInt(getDefLength()))) {\r
jsonObj = new JSONObject().append("defaultlength", getDefLength())\r
.append("requestlength", requestLength);\r
log.error("message length is greater than default");\r
throw new CambriaApiException(jsonObj);\r
} \r
- else if (null == transferEncoding && (getDefLength() !=null && requestLength > Integer.parseInt(getDefLength()))) \r
+ else if (null == transferEncoding && (requestLength > Integer.parseInt(getDefLength()))) \r
{\r
jsonObj = new JSONObject().append("defaultlength", getDefLength()).append(\r
"requestlength", requestLength);\r
} catch (CambriaApiException | NumberFormatException | JSONException e) {\r
\r
log.info("Exception obj--"+e);\r
- log.error("message size is greater then default"+e.getMessage());\r
+ log.error("message size is greater then default"+e.getMessage());
+ String messg=e.toString();
+ if(jsonObj!=null){
+ messg=jsonObj.toString();
+ }\r
ErrorResponse errRes = new ErrorResponse(HttpStatus.SC_REQUEST_TOO_LONG,\r
DMaaPResponseCode.MSG_SIZE_EXCEEDS_MSG_LIMIT.getResponseCode(), System.getProperty("msg_size_exceeds")\r
- + e.toString());\r
+ + messg);\r
log.info(errRes.toString());\r
\r
\r
map.put(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,"test");\r
- httpservletresponse.setStatus(HttpStatus.SC_REQUEST_TOO_LONG);\r
- httpservletresponse.getOutputStream().write(errRes.toString().getBytes());\r
+ httpservletresponse.setStatus(HttpStatus.SC_REQUEST_TOO_LONG);
+ if(httpservletresponse.getOutputStream()!=null){\r
+ httpservletresponse.getOutputStream().write(errRes.toString().getBytes());
+ }\r
return false;\r
}\r
\r