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 org.onap.dmaap.dmf.mr.utils.ConfigurationReader;
26 import javax.servlet.http.HttpServletRequest;
27 import javax.servlet.http.HttpServletResponse;
28 import javax.servlet.http.HttpSession;
29 import java.text.SimpleDateFormat;
30 import java.util.Date;
33 * DMaaPContext provide and maintain all the configurations , Http request/response
34 * Session and consumer Request Time
35 * @author nilanjana.maity
38 public class DMaaPContext {
40 private ConfigurationReader configReader;
41 private HttpServletRequest request;
42 private HttpServletResponse response;
43 private HttpSession session;
44 private String consumerRequestTime;
47 public synchronized static long getBatchID() {
49 final long metricsSendTime = System.currentTimeMillis();
50 final Date d = new Date(metricsSendTime);
51 final String text = new SimpleDateFormat("ddMMyyyyHHmmss").format(d);
52 long dt= Long.valueOf(text)+i;
56 catch(NumberFormatException ex){
61 public HttpServletRequest getRequest() {
65 public void setRequest(HttpServletRequest request) {
66 this.request = request;
69 public HttpServletResponse getResponse() {
73 public void setResponse(HttpServletResponse response) {
74 this.response = response;
77 public HttpSession getSession() {
78 this.session = request.getSession();
82 public void setSession(HttpSession session) {
83 this.session = session;
86 public ConfigurationReader getConfigReader() {
90 public void setConfigReader(ConfigurationReader configReader) {
91 this.configReader = configReader;
94 public String getConsumerRequestTime() {
95 return consumerRequestTime;
98 public void setConsumerRequestTime(String consumerRequestTime) {
99 this.consumerRequestTime = consumerRequestTime;