1 /*******************************************************************************
2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 * ============LICENSE_END=========================================================
19 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
21 *******************************************************************************/
22 package org.onap.dmaap.dmf.mr.beans;
24 import java.text.SimpleDateFormat;
25 import java.util.Date;
27 import javax.servlet.http.HttpServletRequest;
28 import javax.servlet.http.HttpServletResponse;
29 import javax.servlet.http.HttpSession;
31 import org.onap.dmaap.dmf.mr.utils.ConfigurationReader;
34 * DMaaPContext provide and maintain all the configurations , Http request/response
35 * Session and consumer Request Time
36 * @author nilanjana.maity
39 public class DMaaPContext {
41 private ConfigurationReader configReader;
42 private HttpServletRequest request;
43 private HttpServletResponse response;
44 private HttpSession session;
45 private String consumerRequestTime;
48 public synchronized static long getBatchID() {
50 final long metricsSendTime = System.currentTimeMillis();
51 final Date d = new Date(metricsSendTime);
52 final String text = new SimpleDateFormat("ddMMyyyyHHmmss").format(d);
53 long dt= Long.valueOf(text)+i;
57 catch(NumberFormatException ex){
62 public HttpServletRequest getRequest() {
66 public void setRequest(HttpServletRequest request) {
67 this.request = request;
70 public HttpServletResponse getResponse() {
74 public void setResponse(HttpServletResponse response) {
75 this.response = response;
78 public HttpSession getSession() {
79 this.session = request.getSession();
83 public void setSession(HttpSession session) {
84 this.session = session;
87 public ConfigurationReader getConfigReader() {
91 public void setConfigReader(ConfigurationReader configReader) {
92 this.configReader = configReader;
95 public String getConsumerRequestTime() {
96 return consumerRequestTime;
99 public void setConsumerRequestTime(String consumerRequestTime) {
100 this.consumerRequestTime = consumerRequestTime;