update the package name
[dmaap/messagerouter/msgrtr.git] / src / main / java / org / onap / dmaap / dmf / mr / beans / LogDetails.java
1 /**
2  * 
3  */
4 /*******************************************************************************
5  *  ============LICENSE_START=======================================================
6  *  org.onap.dmaap
7  *  ================================================================================
8  *  Copyright © 2017 AT&T Intellectual Property. All rights reserved.
9  *  ================================================================================
10  *  Licensed under the Apache License, Version 2.0 (the "License");
11  *  you may not use this file except in compliance with the License.
12  *  You may obtain a copy of the License at
13  *        http://www.apache.org/licenses/LICENSE-2.0
14 *  
15  *  Unless required by applicable law or agreed to in writing, software
16  *  distributed under the License is distributed on an "AS IS" BASIS,
17  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  *  See the License for the specific language governing permissions and
19  *  limitations under the License.
20  *  ============LICENSE_END=========================================================
21  *  
22  *  ECOMP is a trademark and service mark of AT&T Intellectual Property.
23  *  
24  *******************************************************************************/
25 package org.onap.dmaap.dmf.mr.beans;
26
27 import java.util.Date;
28
29 import org.onap.dmaap.dmf.mr.constants.CambriaConstants;
30 import org.onap.dmaap.dmf.mr.utils.Utils;
31
32 /**
33  * @author muzainulhaque.qazi
34  *
35  */
36
37 public class LogDetails {
38         
39         private String publisherId;
40         private String topicId;
41         private String subscriberGroupId;
42         private String subscriberId;
43         private String publisherIp;
44         private String messageBatchId;
45         private String messageSequence;
46         private String messageTimestamp;
47         private String consumeTimestamp;
48         private String transactionIdTs; 
49         private String serverIp;
50         
51         private long messageLengthInBytes; 
52         private long totalMessageCount;
53         
54         private boolean transactionEnabled;
55         /**
56          * This is for transaction enabled logging details
57          *
58          */
59         public LogDetails() {
60                 super();
61         }
62
63         public String getTransactionId() {
64                 StringBuilder transactionId = new StringBuilder();
65                 transactionId.append(transactionIdTs);
66                 transactionId.append(CambriaConstants.TRANSACTION_ID_SEPARATOR);
67                 transactionId.append(publisherIp);
68                 transactionId.append(CambriaConstants.TRANSACTION_ID_SEPARATOR);
69                 transactionId.append(messageBatchId);
70                 transactionId.append(CambriaConstants.TRANSACTION_ID_SEPARATOR);
71                 transactionId.append(messageSequence);
72
73                 return transactionId.toString();
74         }
75
76         public String getPublisherId() {
77                 return publisherId;
78         }
79
80         public void setPublisherId(String publisherId) {
81                 this.publisherId = publisherId;
82         }
83
84         public String getTopicId() {
85                 return topicId;
86         }
87
88         public void setTopicId(String topicId) {
89                 this.topicId = topicId;
90         }
91
92         public String getSubscriberGroupId() {
93                 return subscriberGroupId;
94         }
95
96         public void setSubscriberGroupId(String subscriberGroupId) {
97                 this.subscriberGroupId = subscriberGroupId;
98         }
99
100         public String getSubscriberId() {
101                 return subscriberId;
102         }
103
104         public void setSubscriberId(String subscriberId) {
105                 this.subscriberId = subscriberId;
106         }
107
108         public String getPublisherIp() {
109                 return publisherIp;
110         }
111
112         public void setPublisherIp(String publisherIp) {
113                 this.publisherIp = publisherIp;
114         }
115
116         public String getMessageBatchId() {
117                 return messageBatchId;
118         }
119
120         public void setMessageBatchId(Long messageBatchId) {
121                 this.messageBatchId = Utils.getFromattedBatchSequenceId(messageBatchId);
122         }
123
124         public String getMessageSequence() {
125                 return messageSequence;
126         }
127
128         public void setMessageSequence(String messageSequence) {
129                 this.messageSequence = messageSequence;
130         }
131
132         public String getMessageTimestamp() {
133                 return messageTimestamp;
134         }
135
136         public void setMessageTimestamp(String messageTimestamp) {
137                 this.messageTimestamp = messageTimestamp;
138         }
139
140         public String getPublishTimestamp() {
141                 return Utils.getFormattedDate(new Date());
142         }
143
144         public String getConsumeTimestamp() {
145                 return consumeTimestamp;
146         }
147
148         public void setConsumeTimestamp(String consumeTimestamp) {
149                 this.consumeTimestamp = consumeTimestamp;
150         }
151
152         public long getMessageLengthInBytes() {
153                 return messageLengthInBytes;
154         }
155
156         public void setMessageLengthInBytes(long messageLengthInBytes) {
157                 this.messageLengthInBytes = messageLengthInBytes;
158         }
159
160         public long getTotalMessageCount() {
161                 return totalMessageCount;
162         }
163
164         public void setTotalMessageCount(long totalMessageCount) {
165                 this.totalMessageCount = totalMessageCount;
166         }
167
168         public boolean isTransactionEnabled() {
169                 return transactionEnabled;
170         }
171
172         public void setTransactionEnabled(boolean transactionEnabled) {
173                 this.transactionEnabled = transactionEnabled;
174         }
175
176         public String getTransactionIdTs() {
177                 return transactionIdTs;
178         }
179
180         public void setTransactionIdTs(String transactionIdTs) {
181                 this.transactionIdTs = transactionIdTs;
182         }
183
184         public String getPublisherLogDetails() {
185                 
186                         StringBuilder buffer = new StringBuilder();
187                         buffer.append("[publisherId=" + publisherId);
188                         buffer.append(", topicId=" + topicId);
189                         buffer.append(", messageTimestamp=" + messageTimestamp);
190                         buffer.append(", publisherIp=" + publisherIp);
191                         buffer.append(", messageBatchId=" + messageBatchId);
192                         buffer.append(", messageSequence=" + messageSequence );
193                         buffer.append(", messageLengthInBytes=" + messageLengthInBytes);
194                         buffer.append(", transactionEnabled=" + transactionEnabled);
195                         buffer.append(", transactionId=" + getTransactionId());
196                         buffer.append(", publishTimestamp=" + getPublishTimestamp());           
197                         buffer.append(", serverIp=" + getServerIp()+"]");
198                 return buffer.toString();
199                 
200         }
201
202         public String getServerIp() {
203                 return serverIp;
204         }
205
206         public void setServerIp(String serverIp) {
207                 this.serverIp = serverIp;
208         }
209
210         public void setMessageBatchId(String messageBatchId) {
211                 this.messageBatchId = messageBatchId;
212         }
213         
214 }