/*- * ============LICENSE_START======================================================= * SDC * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============LICENSE_END========================================================= */ package org.openecomp.sdc.be.resources.data.auditing; import com.datastax.driver.mapping.annotations.Transient; import java.text.SimpleDateFormat; import java.util.Date; import java.util.HashMap; import java.util.Map; import java.util.TimeZone; import org.openecomp.sdc.common.datastructure.AuditingFieldsKey; public class AuditingGenericEvent { protected static String dateFormatPattern = "yyyy-MM-dd HH:mm:ss.SSS z"; @Transient protected SimpleDateFormat simpleDateFormat; @Transient protected String requestId; @Transient protected String serviceInstanceId; @Transient protected String action; @Transient protected String status; @Transient protected String timestamp; @Transient protected String desc; @Transient protected Map fields = new HashMap<>(); public AuditingGenericEvent() { super(); simpleDateFormat = new SimpleDateFormat(dateFormatPattern); simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); this.timestamp = simpleDateFormat.format(new Date()); fields.put(AuditingFieldsKey.AUDIT_TIMESTAMP.getDisplayName(), this.timestamp); } public String getRequestId() { return requestId; } public void setRequestId(String requestId) { this.requestId = requestId; } public String getServiceInstanceId() { return serviceInstanceId; } public void setServiceInstanceId(String serviceInstanceId) { this.serviceInstanceId = serviceInstanceId; } public String getAction() { return action; } public void setAction(String action) { this.action = action; } public String getStatus() { return status; } public void setStatus(String status) { this.status = status; } public String getDesc() { return desc; } public void setDesc(String desc) { this.desc = desc; } public void fillFields() { } protected Date parseDateFromString(final String timestamp) { try { return simpleDateFormat.parse(timestamp); } catch (Exception e) { return new Date(); } } public String getTimestamp() { return timestamp; } public void setTimestamp(String timestamp) { this.timestamp = timestamp; } public Map getFields() { return fields; } public void setFields(Map fields) { this.fields = fields; } }