Catalog alignment
[sdc.git] / catalog-dao / src / main / java / org / openecomp / sdc / be / resources / data / auditing / AuditingGenericEvent.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 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  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.openecomp.sdc.be.resources.data.auditing;
22
23
24 import org.openecomp.sdc.common.datastructure.AuditingFieldsKey;
25
26 import java.text.SimpleDateFormat;
27 import java.util.Date;
28 import java.util.HashMap;
29 import java.util.Map;
30 import java.util.TimeZone;
31
32 public class AuditingGenericEvent {
33     protected SimpleDateFormat simpleDateFormat;
34     protected static String dateFormatPattern = "yyyy-MM-dd HH:mm:ss.SSS z";
35
36     protected String requestId;
37     protected String serviceInstanceId;
38     protected String action;
39     protected String status;
40     protected String timestamp;
41
42     protected String desc;
43     protected Map<String, Object> fields = new HashMap<>();
44
45
46     public AuditingGenericEvent() {
47         super();
48         simpleDateFormat = new SimpleDateFormat(dateFormatPattern);
49         simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
50         this.timestamp = simpleDateFormat.format(new Date());
51         fields.put(AuditingFieldsKey.AUDIT_TIMESTAMP.getDisplayName(), this.timestamp);
52
53     }
54
55     public String getRequestId() {
56         return requestId;
57     }
58
59     public void setRequestId(String requestId) {
60         this.requestId = requestId;
61
62     }
63
64     public String getServiceInstanceId() {
65         return serviceInstanceId;
66     }
67
68     public void setServiceInstanceId(String serviceInstanceId) {
69         this.serviceInstanceId = serviceInstanceId;
70     }
71
72     public String getAction() {
73         return action;
74     }
75
76     public void setAction(String action) {
77         this.action = action;
78     }
79
80     public String getStatus() {
81         return status;
82     }
83
84     public void setStatus(String status) {
85         this.status = status;
86     }
87
88     public String getDesc() {
89         return desc;
90     }
91
92     public void setDesc(String desc) {
93         this.desc = desc;
94     }
95
96     public void fillFields() {
97
98     }
99
100     protected Date parseDateFromString(final String timestamp) {
101         try {
102             return simpleDateFormat.parse(timestamp);
103         }
104         catch (Exception e) {
105             return new Date();
106         }
107     }
108
109     public String getTimestamp() {
110         return timestamp;
111     }
112
113     public void setTimestamp(String timestamp) {
114         this.timestamp = timestamp;
115     }
116
117     public Map<String, Object> getFields() {
118         return fields;
119     }
120
121     public void setFields(Map<String, Object> fields) {
122         this.fields = fields;
123     }
124
125
126 }