2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.openecomp.sdc.be.resources.data.auditing;
24 import org.openecomp.sdc.common.datastructure.AuditingFieldsKey;
25 import com.datastax.driver.mapping.annotations.Transient;
26 import java.text.SimpleDateFormat;
27 import java.util.Date;
28 import java.util.HashMap;
30 import java.util.TimeZone;
32 public class AuditingGenericEvent {
34 protected SimpleDateFormat simpleDateFormat;
35 protected static String dateFormatPattern = "yyyy-MM-dd HH:mm:ss.SSS z";
38 protected String requestId;
40 protected String serviceInstanceId;
42 protected String action;
44 protected String status;
46 protected String timestamp;
48 protected String desc;
50 protected Map<String, Object> fields = new HashMap<>();
53 public AuditingGenericEvent() {
55 simpleDateFormat = new SimpleDateFormat(dateFormatPattern);
56 simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
57 this.timestamp = simpleDateFormat.format(new Date());
58 fields.put(AuditingFieldsKey.AUDIT_TIMESTAMP.getDisplayName(), this.timestamp);
62 public String getRequestId() {
66 public void setRequestId(String requestId) {
67 this.requestId = requestId;
71 public String getServiceInstanceId() {
72 return serviceInstanceId;
75 public void setServiceInstanceId(String serviceInstanceId) {
76 this.serviceInstanceId = serviceInstanceId;
79 public String getAction() {
83 public void setAction(String action) {
87 public String getStatus() {
91 public void setStatus(String status) {
95 public String getDesc() {
99 public void setDesc(String desc) {
103 public void fillFields() {
107 protected Date parseDateFromString(final String timestamp) {
109 return simpleDateFormat.parse(timestamp);
111 catch (Exception e) {
116 public String getTimestamp() {
120 public void setTimestamp(String timestamp) {
121 this.timestamp = timestamp;
124 public Map<String, Object> getFields() {
128 public void setFields(Map<String, Object> fields) {
129 this.fields = fields;