diff options
Diffstat (limited to 'catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing')
24 files changed, 1915 insertions, 2643 deletions
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/AuditRecordFactory.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/AuditRecordFactory.java deleted file mode 100644 index bae33384e4..0000000000 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/AuditRecordFactory.java +++ /dev/null @@ -1,93 +0,0 @@ -/*- - * ============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 java.util.Map; - -import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum; - -public final class AuditRecordFactory { - public static AuditingGenericEvent createAuditRecord(Map<AuditingFieldsKeysEnum, Object> auditingFields) { - if (auditingFields == null) { - return null; - } - AuditingActionEnum actionEnum = AuditingActionEnum - .getActionByName((String) auditingFields.get(AuditingFieldsKeysEnum.AUDIT_ACTION)); - if (actionEnum == null) { - return null; - } - String tableName = actionEnum.getAuditingEsType(); - AuditingGenericEvent event = null; - switch (tableName) { - case AuditingTypesConstants.USER_ADMIN_EVENT_TYPE: - event = new UserAdminEvent(auditingFields); - break; - case AuditingTypesConstants.AUTH_EVENT_TYPE: - event = new AuthEvent(auditingFields); - break; - case AuditingTypesConstants.CATEGORY_EVENT_TYPE: - event = new CategoryEvent(auditingFields); - break; - case AuditingTypesConstants.RESOURCE_ADMIN_EVENT_TYPE: - event = new ResourceAdminEvent(auditingFields); - break; - case AuditingTypesConstants.USER_ACCESS_EVENT_TYPE: - event = new UserAccessEvent(auditingFields); - break; - case AuditingTypesConstants.DISTRIBUTION_STATUS_EVENT_TYPE: - event = new DistributionStatusEvent(auditingFields); - break; - case AuditingTypesConstants.DISTRIBUTION_DOWNLOAD_EVENT_TYPE: - event = new DistributionDownloadEvent(auditingFields); - break; - case AuditingTypesConstants.DISTRIBUTION_ENGINE_EVENT_TYPE: - event = new DistributionEngineEvent(auditingFields); - break; - case AuditingTypesConstants.DISTRIBUTION_NOTIFICATION_EVENT_TYPE: - event = new DistributionNotificationEvent(auditingFields); - break; - case AuditingTypesConstants.DISTRIBUTION_DEPLOY_EVENT_TYPE: - event = new DistributionDeployEvent(auditingFields); - break; - case AuditingTypesConstants.DISTRIBUTION_GET_UEB_CLUSTER_EVENT_TYPE: - event = new AuditingGetUebClusterEvent(auditingFields); - break; - case AuditingTypesConstants.CONSUMER_EVENT_TYPE: - event = new ConsumerEvent(auditingFields); - break; - case AuditingTypesConstants.GET_USERS_LIST_EVENT_TYPE: - event = new GetUsersListEvent(auditingFields); - break; - case AuditingTypesConstants.GET_CATEGORY_HIERARCHY_EVENT_TYPE: - event = new GetCategoryHierarchyEvent(auditingFields); - break; - case AuditingTypesConstants.EXTERNAL_API_EVENT_TYPE: - event = new ExternalApiEvent(auditingFields); - break; - case AuditingTypesConstants.ECOMP_OPERATIONAL_ENV_EVENT_TYPE: - event = new EcompOperationalEnvironmentEvent(auditingFields); - break; - } - - return event; - } - -} diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/AuditingActionEnum.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/AuditingActionEnum.java index 0c1352f4ec..da5eab8747 100644 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/AuditingActionEnum.java +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/AuditingActionEnum.java @@ -20,120 +20,127 @@ package org.openecomp.sdc.be.resources.data.auditing; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.openecomp.sdc.common.log.wrappers.Logger; //TODO rename to AuditAction public enum AuditingActionEnum { - // User admininstration - ADD_USER("AddUser", AuditingTypesConstants.USER_ADMIN_EVENT_TYPE), - UPDATE_USER("UpdateUser", AuditingTypesConstants.USER_ADMIN_EVENT_TYPE), - DELETE_USER("DeleteUser", AuditingTypesConstants.USER_ADMIN_EVENT_TYPE), - USER_ACCESS("Access", AuditingTypesConstants.USER_ACCESS_EVENT_TYPE), - GET_USERS_LIST("GetUsersList", AuditingTypesConstants.GET_USERS_LIST_EVENT_TYPE), - - // Resource/service administration - CREATE_RESOURCE("Create", AuditingTypesConstants.RESOURCE_ADMIN_EVENT_TYPE), - IMPORT_RESOURCE("ResourceImport", AuditingTypesConstants.RESOURCE_ADMIN_EVENT_TYPE), - CHECKOUT_RESOURCE("Checkout", AuditingTypesConstants.RESOURCE_ADMIN_EVENT_TYPE), - UNDO_CHECKOUT_RESOURCE("UndoCheckout", AuditingTypesConstants.RESOURCE_ADMIN_EVENT_TYPE), - CHECKIN_RESOURCE("Checkin", AuditingTypesConstants.RESOURCE_ADMIN_EVENT_TYPE), - CERTIFICATION_REQUEST_RESOURCE("CertificationRequest", AuditingTypesConstants.RESOURCE_ADMIN_EVENT_TYPE), - START_CERTIFICATION_RESOURCE("CertificationStart", AuditingTypesConstants.RESOURCE_ADMIN_EVENT_TYPE), - FAIL_CERTIFICATION_RESOURCE("CertificationFailure", AuditingTypesConstants.RESOURCE_ADMIN_EVENT_TYPE), - CANCEL_CERTIFICATION_RESOURCE("CertificationCancel", AuditingTypesConstants.RESOURCE_ADMIN_EVENT_TYPE), - CERTIFICATION_SUCCESS_RESOURCE("CertificationSuccess", AuditingTypesConstants.RESOURCE_ADMIN_EVENT_TYPE), - UPDATE_RESOURCE_METADATA("UpdateResourceMetadata", AuditingTypesConstants.RESOURCE_ADMIN_EVENT_TYPE), - UPDATE_SERVICE_METADATA("UpdateServiceMetadata", AuditingTypesConstants.RESOURCE_ADMIN_EVENT_TYPE), - ARTIFACT_UPLOAD("ArtifactUpload", AuditingTypesConstants.RESOURCE_ADMIN_EVENT_TYPE), - //External API - ARTIFACT_UPLOAD_BY_API("ArtifactUploadByAPI", AuditingTypesConstants.EXTERNAL_API_EVENT_TYPE), - ARTIFACT_UPDATE_BY_API("ArtifactUpdateByAPI", AuditingTypesConstants.EXTERNAL_API_EVENT_TYPE), - ARTIFACT_DELETE_BY_API("ArtifactDeleteByAPI", AuditingTypesConstants.EXTERNAL_API_EVENT_TYPE), - DOWNLOAD_ARTIFACT("DownloadArtifact",AuditingTypesConstants.EXTERNAL_API_EVENT_TYPE), - CREATE_RESOURCE_BY_API("CreateResourceByAPI", AuditingTypesConstants.EXTERNAL_API_EVENT_TYPE), - CHANGE_LIFECYCLE_BY_API("ChangeLifecycleByAPI", AuditingTypesConstants.EXTERNAL_API_EVENT_TYPE), - ACTIVATE_SERVICE_BY_API("ActivateServiceByAPI", AuditingTypesConstants.EXTERNAL_API_EVENT_TYPE), - - - ARTIFACT_PAYLOAD_UPDATE("ArtifactPayloadUpdate", AuditingTypesConstants.RESOURCE_ADMIN_EVENT_TYPE), - ARTIFACT_METADATA_UPDATE("ArtifactMetadataUpdate", AuditingTypesConstants.RESOURCE_ADMIN_EVENT_TYPE), - ARTIFACT_DELETE("ArtifactDelete", AuditingTypesConstants.RESOURCE_ADMIN_EVENT_TYPE), - ARTIFACT_DOWNLOAD("ArtifactDownload", AuditingTypesConstants.RESOURCE_ADMIN_EVENT_TYPE), - - - // Distribution - DISTRIBUTION_ARTIFACT_DOWNLOAD("DArtifactDownload", AuditingTypesConstants.DISTRIBUTION_DOWNLOAD_EVENT_TYPE), - DISTRIBUTION_STATE_CHANGE_REQUEST("DRequest", AuditingTypesConstants.RESOURCE_ADMIN_EVENT_TYPE), - DISTRIBUTION_STATE_CHANGE_APPROV("DApprove", AuditingTypesConstants.RESOURCE_ADMIN_EVENT_TYPE), - DISTRIBUTION_STATE_CHANGE_REJECT("DReject", AuditingTypesConstants.RESOURCE_ADMIN_EVENT_TYPE), - CREATE_DISTRIBUTION_TOPIC("CreateDistributionTopic", AuditingTypesConstants.DISTRIBUTION_ENGINE_EVENT_TYPE), - ADD_KEY_TO_TOPIC_ACL("AddKeyToTopicACL", AuditingTypesConstants.DISTRIBUTION_ENGINE_EVENT_TYPE), - REMOVE_KEY_FROM_TOPIC_ACL("RemoveKeyFromTopicACL", AuditingTypesConstants.DISTRIBUTION_ENGINE_EVENT_TYPE), - DISTRIBUTION_REGISTER("DRegister", AuditingTypesConstants.DISTRIBUTION_ENGINE_EVENT_TYPE), - DISTRIBUTION_UN_REGISTER("DUnRegister", AuditingTypesConstants.DISTRIBUTION_ENGINE_EVENT_TYPE), - DISTRIBUTION_NOTIFY("DNotify", AuditingTypesConstants.DISTRIBUTION_NOTIFICATION_EVENT_TYPE), - DISTRIBUTION_STATUS("DStatus", AuditingTypesConstants.DISTRIBUTION_STATUS_EVENT_TYPE), - DISTRIBUTION_DEPLOY("DResult",AuditingTypesConstants.DISTRIBUTION_DEPLOY_EVENT_TYPE), - GET_UEB_CLUSTER("GetUebCluster", AuditingTypesConstants.DISTRIBUTION_GET_UEB_CLUSTER_EVENT_TYPE), - GET_VALID_ARTIFACT_TYPES("GetValidArtifactTypes", AuditingTypesConstants.DISTRIBUTION_GET_VALID_ARTIFACT_TYPES_EVENT_TYPE), - - //Environment + // User admininstration + ADD_USER("AddUser", AuditingTypesConstants.USER_ADMIN_EVENT_TYPE), + UPDATE_USER("UpdateUser", AuditingTypesConstants.USER_ADMIN_EVENT_TYPE), + DELETE_USER("DeleteUser", AuditingTypesConstants.USER_ADMIN_EVENT_TYPE), + USER_ACCESS("Access", AuditingTypesConstants.USER_ACCESS_EVENT_TYPE), + GET_USERS_LIST("GetUsersList", AuditingTypesConstants.GET_USERS_LIST_EVENT_TYPE), + + // Resource/service administration + CREATE_RESOURCE("Create", AuditingTypesConstants.RESOURCE_ADMIN_EVENT_TYPE), + IMPORT_RESOURCE("ResourceImport", AuditingTypesConstants.RESOURCE_ADMIN_EVENT_TYPE), + CHECKOUT_RESOURCE("Checkout", AuditingTypesConstants.RESOURCE_ADMIN_EVENT_TYPE), + UNDO_CHECKOUT_RESOURCE("UndoCheckout", AuditingTypesConstants.RESOURCE_ADMIN_EVENT_TYPE), + CHECKIN_RESOURCE("Checkin", AuditingTypesConstants.RESOURCE_ADMIN_EVENT_TYPE), + CERTIFICATION_REQUEST_RESOURCE("CertificationRequest", AuditingTypesConstants.RESOURCE_ADMIN_EVENT_TYPE), + START_CERTIFICATION_RESOURCE("CertificationStart", AuditingTypesConstants.RESOURCE_ADMIN_EVENT_TYPE), + FAIL_CERTIFICATION_RESOURCE("CertificationFailure", AuditingTypesConstants.RESOURCE_ADMIN_EVENT_TYPE), + CANCEL_CERTIFICATION_RESOURCE("CertificationCancel", AuditingTypesConstants.RESOURCE_ADMIN_EVENT_TYPE), + CERTIFICATION_SUCCESS_RESOURCE("CertificationSuccess", AuditingTypesConstants.RESOURCE_ADMIN_EVENT_TYPE), + CREATE_SERVICE("CreateService", AuditingTypesConstants.RESOURCE_ADMIN_EVENT_TYPE), + UPDATE_RESOURCE_METADATA("UpdateResourceMetadata", AuditingTypesConstants.RESOURCE_ADMIN_EVENT_TYPE), + UPDATE_SERVICE_METADATA("UpdateServiceMetadata", AuditingTypesConstants.RESOURCE_ADMIN_EVENT_TYPE), + ARTIFACT_UPLOAD("ArtifactUpload", AuditingTypesConstants.RESOURCE_ADMIN_EVENT_TYPE), + //External API + ARTIFACT_UPLOAD_BY_API("ArtifactUploadByAPI", AuditingTypesConstants.EXTERNAL_API_EVENT_TYPE), + ARTIFACT_UPDATE_BY_API("ArtifactUpdateByAPI", AuditingTypesConstants.EXTERNAL_API_EVENT_TYPE), + ARTIFACT_DELETE_BY_API("ArtifactDeleteByAPI", AuditingTypesConstants.EXTERNAL_API_EVENT_TYPE), + DOWNLOAD_ARTIFACT("DownloadArtifact",AuditingTypesConstants.EXTERNAL_API_EVENT_TYPE), + CREATE_RESOURCE_BY_API("CreateResourceByAPI", AuditingTypesConstants.EXTERNAL_API_EVENT_TYPE), + CHANGE_LIFECYCLE_BY_API("ChangeLifecycleByAPI", AuditingTypesConstants.EXTERNAL_API_EVENT_TYPE), + ACTIVATE_SERVICE_BY_API("ActivateServiceByAPI", AuditingTypesConstants.EXTERNAL_API_EVENT_TYPE), + + ARTIFACT_PAYLOAD_UPDATE("ArtifactPayloadUpdate", AuditingTypesConstants.RESOURCE_ADMIN_EVENT_TYPE), + ARTIFACT_METADATA_UPDATE("ArtifactMetadataUpdate", AuditingTypesConstants.RESOURCE_ADMIN_EVENT_TYPE), + ARTIFACT_DELETE("ArtifactDelete", AuditingTypesConstants.RESOURCE_ADMIN_EVENT_TYPE), + ARTIFACT_DOWNLOAD("ArtifactDownload", AuditingTypesConstants.RESOURCE_ADMIN_EVENT_TYPE), + + //Automated upgrade + UPDATE_SERVICE_REFERENCE("UpdateServiceReference", AuditingTypesConstants.RESOURCE_ADMIN_EVENT_TYPE), + VF_UPGRADE_SERVICES("VfUpgradeServices", AuditingTypesConstants.RESOURCE_ADMIN_EVENT_TYPE), + + //Archive/Restore Components + ARCHIVE_COMPONENT("ArchiveComponent", AuditingTypesConstants.RESOURCE_ADMIN_EVENT_TYPE), + RESTORE_COMPONENT("RestoreComponent", AuditingTypesConstants.RESOURCE_ADMIN_EVENT_TYPE), + + // Distribution + DISTRIBUTION_ARTIFACT_DOWNLOAD("DArtifactDownload", AuditingTypesConstants.DISTRIBUTION_DOWNLOAD_EVENT_TYPE), + DISTRIBUTION_STATE_CHANGE_REQUEST("DRequest", AuditingTypesConstants.RESOURCE_ADMIN_EVENT_TYPE), + DISTRIBUTION_STATE_CHANGE_APPROV("DApprove", AuditingTypesConstants.RESOURCE_ADMIN_EVENT_TYPE), + DISTRIBUTION_STATE_CHANGE_REJECT("DReject", AuditingTypesConstants.RESOURCE_ADMIN_EVENT_TYPE), + CREATE_DISTRIBUTION_TOPIC("CreateDistributionTopic", AuditingTypesConstants.DISTRIBUTION_ENGINE_EVENT_TYPE), + ADD_KEY_TO_TOPIC_ACL("AddKeyToTopicACL", AuditingTypesConstants.DISTRIBUTION_ENGINE_EVENT_TYPE), + REMOVE_KEY_FROM_TOPIC_ACL("RemoveKeyFromTopicACL", AuditingTypesConstants.DISTRIBUTION_ENGINE_EVENT_TYPE), + DISTRIBUTION_REGISTER("DRegister", AuditingTypesConstants.DISTRIBUTION_ENGINE_EVENT_TYPE), + DISTRIBUTION_UN_REGISTER("DUnRegister", AuditingTypesConstants.DISTRIBUTION_ENGINE_EVENT_TYPE), + DISTRIBUTION_NOTIFY("DNotify", AuditingTypesConstants.DISTRIBUTION_NOTIFICATION_EVENT_TYPE), + DISTRIBUTION_STATUS("DStatus", AuditingTypesConstants.DISTRIBUTION_STATUS_EVENT_TYPE), + DISTRIBUTION_DEPLOY("DResult",AuditingTypesConstants.DISTRIBUTION_DEPLOY_EVENT_TYPE), + GET_UEB_CLUSTER("GetUebCluster", AuditingTypesConstants.DISTRIBUTION_GET_UEB_CLUSTER_EVENT_TYPE), + GET_VALID_ARTIFACT_TYPES("GetValidArtifactTypes", AuditingTypesConstants.DISTRIBUTION_GET_VALID_ARTIFACT_TYPES_EVENT_TYPE), + + //Environment CREATE_ENVIRONMENT("CreateEnvironment", AuditingTypesConstants.ECOMP_OPERATIONAL_ENV_EVENT_TYPE), UPDATE_ENVIRONMENT("UpdateEnvironment", AuditingTypesConstants.ECOMP_OPERATIONAL_ENV_EVENT_TYPE), DELETE_ENVIRONMENT("DeleteEnvironment", AuditingTypesConstants.ECOMP_OPERATIONAL_ENV_EVENT_TYPE), UNKNOWN_ENVIRONMENT_NOTIFICATION("UnknownEnvironmentNotification", AuditingTypesConstants.ECOMP_OPERATIONAL_ENV_EVENT_TYPE), UNSUPPORTED_ENVIRONMENT_TYPE("UnsupportedEnvironmentType", AuditingTypesConstants.ECOMP_OPERATIONAL_ENV_EVENT_TYPE), - // .... - AUTH_REQUEST("HttpAuthentication", AuditingTypesConstants.AUTH_EVENT_TYPE), - ADD_ECOMP_USER_CREDENTIALS("AddECOMPUserCredentials", AuditingTypesConstants.CONSUMER_EVENT_TYPE), - GET_ECOMP_USER_CREDENTIALS("GetECOMPUserCredentials", AuditingTypesConstants.CONSUMER_EVENT_TYPE), - DELETE_ECOMP_USER_CREDENTIALS("DeleteECOMPUserCredentials", AuditingTypesConstants.CONSUMER_EVENT_TYPE), - UPDATE_ECOMP_USER_CREDENTIALS("UpdateECOMPUserCredentials", AuditingTypesConstants.CONSUMER_EVENT_TYPE), - // Category - ADD_CATEGORY("AddCategory", AuditingTypesConstants.CATEGORY_EVENT_TYPE), - ADD_SUB_CATEGORY("AddSubCategory", AuditingTypesConstants.CATEGORY_EVENT_TYPE), - ADD_GROUPING("AddGrouping", AuditingTypesConstants.CATEGORY_EVENT_TYPE), - GET_CATEGORY_HIERARCHY("GetCategoryHierarchy", AuditingTypesConstants.GET_CATEGORY_HIERARCHY_EVENT_TYPE), - - // Assets - - GET_ASSET_LIST("GetAssetList", AuditingTypesConstants.EXTERNAL_API_EVENT_TYPE), - GET_FILTERED_ASSET_LIST("GetFilteredAssetList", AuditingTypesConstants.EXTERNAL_API_EVENT_TYPE), - GET_ASSET_METADATA("GetAssetMetadata", AuditingTypesConstants.EXTERNAL_API_EVENT_TYPE), - GET_TOSCA_MODEL("GetToscaModel", AuditingTypesConstants.EXTERNAL_API_EVENT_TYPE); + + AUTH_REQUEST("HttpAuthentication", AuditingTypesConstants.AUTH_EVENT_TYPE), + ADD_ECOMP_USER_CREDENTIALS("AddECOMPUserCredentials", AuditingTypesConstants.CONSUMER_EVENT_TYPE), + GET_ECOMP_USER_CREDENTIALS("GetECOMPUserCredentials", AuditingTypesConstants.CONSUMER_EVENT_TYPE), + DELETE_ECOMP_USER_CREDENTIALS("DeleteECOMPUserCredentials", AuditingTypesConstants.CONSUMER_EVENT_TYPE), + UPDATE_ECOMP_USER_CREDENTIALS("UpdateECOMPUserCredentials", AuditingTypesConstants.CONSUMER_EVENT_TYPE), + + // Category + ADD_CATEGORY("AddCategory", AuditingTypesConstants.CATEGORY_EVENT_TYPE), + ADD_SUB_CATEGORY("AddSubCategory", AuditingTypesConstants.CATEGORY_EVENT_TYPE), + ADD_GROUPING("AddGrouping", AuditingTypesConstants.CATEGORY_EVENT_TYPE), + GET_CATEGORY_HIERARCHY("GetCategoryHierarchy", AuditingTypesConstants.GET_CATEGORY_HIERARCHY_EVENT_TYPE), + + // Assets + GET_ASSET_LIST("GetAssetList", AuditingTypesConstants.EXTERNAL_API_EVENT_TYPE), + GET_FILTERED_ASSET_LIST("GetFilteredAssetList", AuditingTypesConstants.EXTERNAL_API_EVENT_TYPE), + GET_ASSET_METADATA("GetAssetMetadata", AuditingTypesConstants.EXTERNAL_API_EVENT_TYPE), + GET_TOSCA_MODEL("GetToscaModel", AuditingTypesConstants.EXTERNAL_API_EVENT_TYPE); private final String name; private final String auditingEsType; - private static Logger log = LoggerFactory.getLogger(AuditingActionEnum.class.getName()); - - private AuditingActionEnum(String name, String auditingEsType) { - this.name = name; - this.auditingEsType = auditingEsType; - } - - public String getName() { - return name; - } - - public String getAuditingEsType() { - return auditingEsType; - } - - public static AuditingActionEnum getActionByName(String name) { - AuditingActionEnum res = null; - AuditingActionEnum[] values = values(); - for (AuditingActionEnum value : values) { - if (value.getName().equals(name)) { - res = value; - break; - } - } - if (res == null) { - log.debug("No auditing action is mapped to name {}", name); - } - return res; - } + + private static Logger log = Logger.getLogger(AuditingActionEnum.class.getName()); + + AuditingActionEnum(String name, String auditingEsType) { + this.name = name; + this.auditingEsType = auditingEsType; + } + + public String getName() { + return name; + } + + public String getAuditingEsType() { + return auditingEsType; + } + + public static AuditingActionEnum fromName(String name) { + AuditingActionEnum res = null; + AuditingActionEnum[] values = values(); + for (AuditingActionEnum value : values) { + if (value.getName().equals(name)) { + res = value; + break; + } + } + if (res == null) { + log.debug("No auditing action is mapped to name {}", name); + } + return res; + } } diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/AuditingGenericEvent.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/AuditingGenericEvent.java index 7789e47766..92e5f4bf2f 100644 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/AuditingGenericEvent.java +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/AuditingGenericEvent.java @@ -22,63 +22,72 @@ package org.openecomp.sdc.be.resources.data.auditing; import org.openecomp.sdc.common.datastructure.ESTimeBasedEvent; +import java.util.Date; + public class AuditingGenericEvent extends ESTimeBasedEvent { - protected String requestId; - protected String serviceInstanceId; - protected String action; - protected String status; + protected String requestId; + protected String serviceInstanceId; + protected String action; + protected String status; - protected String desc; + protected String desc; - // protected Map<String, Object> fields = new HashMap<String, Object>(); + public AuditingGenericEvent() { + super(); + } - public AuditingGenericEvent() { - super(); - } + public String getRequestId() { + return requestId; + } - public String getRequestId() { - return requestId; - } + public void setRequestId(String requestId) { + this.requestId = requestId; - public void setRequestId(String requestId) { - this.requestId = requestId; + } - } + public String getServiceInstanceId() { + return serviceInstanceId; + } - public String getServiceInstanceId() { - return serviceInstanceId; - } + public void setServiceInstanceId(String serviceInstanceId) { + this.serviceInstanceId = serviceInstanceId; + } - public void setServiceInstanceId(String serviceInstanceId) { - this.serviceInstanceId = serviceInstanceId; - } + public String getAction() { + return action; + } - public String getAction() { - return action; - } + public void setAction(String action) { + this.action = action; + } - public void setAction(String action) { - this.action = action; - } + public String getStatus() { + return status; + } - public String getStatus() { - return status; - } + public void setStatus(String status) { + this.status = status; + } - public void setStatus(String status) { - this.status = status; - } + public String getDesc() { + return desc; + } - public String getDesc() { - return desc; - } + public void setDesc(String desc) { + this.desc = desc; + } - public void setDesc(String desc) { - this.desc = desc; - } + public void fillFields() { - public void fillFields() { + } - } + protected Date parseDateFromString(final String timestamp) { + try { + return simpleDateFormat.parse(timestamp); + } + catch (Exception e) { + return new Date(); + } + } } diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/AuditingGetUebClusterEvent.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/AuditingGetUebClusterEvent.java index d293bd8cfe..f0b1e63989 100644 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/AuditingGetUebClusterEvent.java +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/AuditingGetUebClusterEvent.java @@ -20,25 +20,21 @@ package org.openecomp.sdc.be.resources.data.auditing; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.Map; -import java.util.TimeZone; -import java.util.UUID; - -import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData; -import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum; - import com.datastax.driver.core.utils.UUIDs; import com.datastax.driver.mapping.annotations.ClusteringColumn; import com.datastax.driver.mapping.annotations.Column; import com.datastax.driver.mapping.annotations.PartitionKey; import com.datastax.driver.mapping.annotations.Table; +import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData; +import org.openecomp.sdc.common.datastructure.AuditingFieldsKey; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.TimeZone; +import java.util.UUID; @Table(keyspace = AuditingTypesConstants.AUDIT_KEYSPACE, name = AuditingTypesConstants.DISTRIBUTION_GET_UEB_CLUSTER_EVENT_TYPE) public class AuditingGetUebClusterEvent extends AuditingGenericEvent { - private static String DISTRIBUTION_GET_UEB_CLUSTER_EVENT_TEMPLATE = "action=\"%s\" " - + " consumerId=\"%s\" statusTime=\"%s\" status=\"%s\" status_desc=\"%s\" "; @PartitionKey protected UUID timebaseduuid; @@ -62,70 +58,38 @@ public class AuditingGetUebClusterEvent extends AuditingGenericEvent { @Column(name = "consumer_id") private String consumerId; + //Required to be public as it is used by Cassandra driver on get operation public AuditingGetUebClusterEvent() { - super(); timestamp1 = new Date(); timebaseduuid = UUIDs.timeBased(); } - public AuditingGetUebClusterEvent(Map<AuditingFieldsKeysEnum, Object> auditingFields) { - this(); - Object value; - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_REQUEST_ID); - if (value != null) { - setRequestId((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_SERVICE_INSTANCE_ID); - if (value != null) { - setServiceInstanceId((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_ACTION); - if (value != null) { - setAction((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_STATUS); - if (value != null) { - setStatus((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_DESC); - if (value != null) { - setDesc((String) value); - } else { - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_STATUS_DESC); - if (value != null) { - setDesc((String) value); - } - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_CONSUMER_ID); - if (value != null) { - setConsumerId((String) value); - } - - } - public AuditingGetUebClusterEvent(String action, CommonAuditData commonAuditData, String consumerId) { this(); this.action = action; this.requestId = commonAuditData.getRequestId(); this.serviceInstanceId = commonAuditData.getServiceInstanceId(); this.status = commonAuditData.getStatus(); - //if no desc, keep distr desc this.desc = commonAuditData.getDescription(); this.consumerId = consumerId; } + public void setTimestamp1(String timestamp) { + this.timestamp1 = parseDateFromString(timestamp); + } + @Override public void fillFields() { - fields.put(AuditingFieldsKeysEnum.AUDIT_REQUEST_ID.getDisplayName(), getRequestId()); + fields.put(AuditingFieldsKey.AUDIT_REQUEST_ID.getDisplayName(), getRequestId()); - fields.put(AuditingFieldsKeysEnum.AUDIT_SERVICE_INSTANCE_ID.getDisplayName(), getServiceInstanceId()); - fields.put(AuditingFieldsKeysEnum.AUDIT_ACTION.getDisplayName(), getAction()); - fields.put(AuditingFieldsKeysEnum.AUDIT_STATUS.getDisplayName(), getStatus()); - fields.put(AuditingFieldsKeysEnum.AUDIT_DESC.getDisplayName(), getDesc()); - fields.put(AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_CONSUMER_ID.getDisplayName(), getConsumerId()); + fields.put(AuditingFieldsKey.AUDIT_SERVICE_INSTANCE_ID.getDisplayName(), getServiceInstanceId()); + fields.put(AuditingFieldsKey.AUDIT_ACTION.getDisplayName(), getAction()); + fields.put(AuditingFieldsKey.AUDIT_STATUS.getDisplayName(), getStatus()); + fields.put(AuditingFieldsKey.AUDIT_DESC.getDisplayName(), getDesc()); + fields.put(AuditingFieldsKey.AUDIT_DISTRIBUTION_CONSUMER_ID.getDisplayName(), getConsumerId()); SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormatPattern); simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); - fields.put(AuditingFieldsKeysEnum.AUDIT_TIMESTAMP.getDisplayName(), simpleDateFormat.format(timestamp1)); + fields.put(AuditingFieldsKey.AUDIT_TIMESTAMP.getDisplayName(), simpleDateFormat.format(timestamp1)); } diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/AuditingTypesConstants.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/AuditingTypesConstants.java index 26cc463725..b7ca47600a 100644 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/AuditingTypesConstants.java +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/AuditingTypesConstants.java @@ -22,31 +22,32 @@ package org.openecomp.sdc.be.resources.data.auditing; public interface AuditingTypesConstants { - String ARTIFACT_KEYSPACE = "sdcartifact"; - String REPO_KEYSPACE = "sdcrepository"; - String AUDIT_KEYSPACE = "sdcaudit"; - String COMPONENT_KEYSPACE = "sdccomponent"; - String TITAN_KEYSPACE = "titan"; + String ARTIFACT_KEYSPACE = "sdcartifact"; + String REPO_KEYSPACE = "sdcrepository"; + String AUDIT_KEYSPACE = "sdcaudit"; + String COMPONENT_KEYSPACE = "sdccomponent"; + String TITAN_KEYSPACE = "titan"; - String USER_ADMIN_EVENT_TYPE = "useradminevent"; - String USER_ACCESS_EVENT_TYPE = "useraccessevent"; - String RESOURCE_ADMIN_EVENT_TYPE = "resourceadminevent"; - String DISTRIBUTION_DOWNLOAD_EVENT_TYPE = "distributiondownloadevent"; + String USER_ADMIN_EVENT_TYPE = "useradminevent"; + String USER_ACCESS_EVENT_TYPE = "useraccessevent"; + String RESOURCE_ADMIN_EVENT_TYPE = "resourceadminevent"; + String DISTRIBUTION_DOWNLOAD_EVENT_TYPE = "distributiondownloadevent"; - String DISTRIBUTION_ENGINE_EVENT_TYPE = "distributionengineevent"; - String DISTRIBUTION_NOTIFICATION_EVENT_TYPE = "distributionnotificationevent"; - String DISTRIBUTION_STATUS_EVENT_TYPE = "distributionstatusevent"; - String DISTRIBUTION_DEPLOY_EVENT_TYPE = "distributiondeployevent"; - String DISTRIBUTION_GET_UEB_CLUSTER_EVENT_TYPE = "auditinggetuebclusterevent"; - String DISTRIBUTION_GET_VALID_ARTIFACT_TYPES_EVENT_TYPE = "auditinggetvalidartifacttypesevent"; + String DISTRIBUTION_ENGINE_EVENT_TYPE = "distributionengineevent"; + String DISTRIBUTION_NOTIFICATION_EVENT_TYPE = "distributionnotificationevent"; + String DISTRIBUTION_STATUS_EVENT_TYPE = "distributionstatusevent"; + String DISTRIBUTION_DEPLOY_EVENT_TYPE = "distributiondeployevent"; + String DISTRIBUTION_GET_UEB_CLUSTER_EVENT_TYPE = "auditinggetuebclusterevent"; + //TODO remove if not in use + String DISTRIBUTION_GET_VALID_ARTIFACT_TYPES_EVENT_TYPE = "auditinggetvalidartifacttypesevent"; - String ECOMP_OPERATIONAL_ENV_EVENT_TYPE = "ecompopenvironmentevent"; - String AUTH_EVENT_TYPE = "authevent"; - String CONSUMER_EVENT_TYPE = "consumerevent"; - String CATEGORY_EVENT_TYPE = "categoryevent"; - String GET_USERS_LIST_EVENT_TYPE = "getuserslistevent"; - String GET_CATEGORY_HIERARCHY_EVENT_TYPE = "getcategoryhierarchyevent"; - String EXTERNAL_API_EVENT_TYPE = "externalapievent"; - String ENVIRONMENT_ENGINE_EVENT_TYPE = "environmentengineevent"; + String ECOMP_OPERATIONAL_ENV_EVENT_TYPE = "ecompopenvironmentevent"; + String AUTH_EVENT_TYPE = "authevent"; + String CONSUMER_EVENT_TYPE = "consumerevent"; + String CATEGORY_EVENT_TYPE = "categoryevent"; + String GET_USERS_LIST_EVENT_TYPE = "getuserslistevent"; + String GET_CATEGORY_HIERARCHY_EVENT_TYPE = "getcategoryhierarchyevent"; + String EXTERNAL_API_EVENT_TYPE = "externalapievent"; + String ENVIRONMENT_ENGINE_EVENT_TYPE = "environmentengineevent"; } diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/AuthEvent.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/AuthEvent.java index a684a009f5..dfa0ed972a 100644 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/AuthEvent.java +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/AuthEvent.java @@ -20,203 +20,164 @@ package org.openecomp.sdc.be.resources.data.auditing; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.Map; -import java.util.TimeZone; -import java.util.UUID; - -import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData; -import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum; - import com.datastax.driver.core.utils.UUIDs; import com.datastax.driver.mapping.annotations.ClusteringColumn; import com.datastax.driver.mapping.annotations.Column; import com.datastax.driver.mapping.annotations.PartitionKey; import com.datastax.driver.mapping.annotations.Table; +import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData; +import org.openecomp.sdc.common.datastructure.AuditingFieldsKey; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.TimeZone; +import java.util.UUID; @Table(keyspace = "sdcaudit", name = AuditingTypesConstants.AUTH_EVENT_TYPE) public class AuthEvent extends AuditingGenericEvent { - private static String AUTH_EVENT_TEMPLATE = "action=\"%s\" timestamp=\"%s\" " - + "URL=\"%s\" USER=\"%s\" AUTH_STATUS=\"%s\" " + "REALM=\"%s\" status=\"%s\" desc=\"%s\""; + @PartitionKey + protected UUID timebaseduuid; + + @ClusteringColumn + protected Date timestamp1; - @PartitionKey - protected UUID timebaseduuid; + @Column + private String url; + @Column + private String user; - @ClusteringColumn - protected Date timestamp1; + @Column(name = "auth_status") + private String authStatus; - @Column - private String url; - @Column - private String user; + @Column + private String realm; + @Column + protected String action; + @Column + protected String status; - @Column(name = "auth_status") - private String authStatus; + @Column(name = "description") + protected String desc; - @Column - private String realm; - @Column - protected String action; - @Column - protected String status; - - @Column(name = "description") - protected String desc; - - @Column(name = "request_id") - protected String requestId; - - public AuthEvent() { - super(); - timestamp1 = new Date(); - timebaseduuid = UUIDs.timeBased(); - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - public String getUser() { - return user; - } - - public void setUser(String user) { - this.user = user; - } - - public String getAuthStatus() { - return authStatus; - } - - public void setAuthStatus(String authStatus) { - this.authStatus = authStatus; - } - - public String getRealm() { - return realm; - } - - public void setRealm(String realm) { - this.realm = realm; - } - - public UUID getTimebaseduuid() { - return timebaseduuid; - } - - public void setTimebaseduuid(UUID timebaseduuid) { - this.timebaseduuid = timebaseduuid; - } - - public Date getTimestamp1() { - return timestamp1; - } - - public void setTimestamp1(Date timestamp1) { - this.timestamp1 = timestamp1; - } - - 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 String getRequestId() { - return requestId; - } - - public void setRequestId(String requestId) { - this.requestId = requestId; - } - - public AuthEvent(Map<AuditingFieldsKeysEnum, Object> auditingFields) { - this(); - Object value; - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_AUTH_URL); - if (value != null) { - setUrl((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_AUTH_USER); - if (value != null) { - setUser((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_AUTH_STATUS); - if (value != null) { - setAuthStatus((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_AUTH_REALM); - if (value != null) { - setRealm((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_ACTION); - if (value != null) { - setAction((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_DESC); - if (value != null) { - setDesc((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_REQUEST_ID); - if (value != null) { - setRequestId((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_STATUS); - if (value != null) { - setStatus((String) value); - } - - } - - public AuthEvent(String action, CommonAuditData commonAuditData, String user, String authUrl, String realm, String authStatus) { - this(); + @Column(name = "request_id") + protected String requestId; + + public AuthEvent(String action, CommonAuditData commonAuditData, String user, String authUrl, String realm, String authStatus) { + this(); this.action = action; this.requestId = commonAuditData.getRequestId(); - this.desc = commonAuditData.getDescription(); - this.status = commonAuditData.getStatus(); - this.authStatus = authStatus; - this.url = authUrl; - this.realm = realm; - this.user = user; - } - - @Override - public void fillFields() { - fields.put(AuditingFieldsKeysEnum.AUDIT_AUTH_URL.getDisplayName(), getUrl()); - - fields.put(AuditingFieldsKeysEnum.AUDIT_AUTH_USER.getDisplayName(), getUser()); - fields.put(AuditingFieldsKeysEnum.AUDIT_AUTH_STATUS.getDisplayName(), getAuthStatus()); - fields.put(AuditingFieldsKeysEnum.AUDIT_AUTH_REALM.getDisplayName(), getRealm()); - fields.put(AuditingFieldsKeysEnum.AUDIT_ACTION.getDisplayName(), getAction()); - fields.put(AuditingFieldsKeysEnum.AUDIT_STATUS.getDisplayName(), getStatus()); - fields.put(AuditingFieldsKeysEnum.AUDIT_REQUEST_ID.getDisplayName(), getRequestId()); - fields.put(AuditingFieldsKeysEnum.AUDIT_DESC.getDisplayName(), getDesc()); - SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormatPattern); - simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); - fields.put(AuditingFieldsKeysEnum.AUDIT_TIMESTAMP.getDisplayName(), simpleDateFormat.format(timestamp1)); - } + this.desc = commonAuditData.getDescription(); + this.status = commonAuditData.getStatus(); + this.authStatus = authStatus; + this.url = authUrl; + this.realm = realm; + this.user = user; + } + + //Required to be public as it is used by Cassandra driver on get operation + public AuthEvent() { + timestamp1 = new Date(); + timebaseduuid = UUIDs.timeBased(); + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getUser() { + return user; + } + + public void setUser(String user) { + this.user = user; + } + + public String getAuthStatus() { + return authStatus; + } + + public void setAuthStatus(String authStatus) { + this.authStatus = authStatus; + } + + public String getRealm() { + return realm; + } + + public void setRealm(String realm) { + this.realm = realm; + } + + public UUID getTimebaseduuid() { + return timebaseduuid; + } + + public void setTimebaseduuid(UUID timebaseduuid) { + this.timebaseduuid = timebaseduuid; + } + + public Date getTimestamp1() { + return timestamp1; + } + + public void setTimestamp1(Date timestamp1) { + this.timestamp1 = timestamp1; + } + + 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 String getRequestId() { + return requestId; + } + + public void setRequestId(String requestId) { + this.requestId = requestId; + } + + public void setTimestamp1(String timestamp) { + this.timestamp1 = parseDateFromString(timestamp); + } + + @Override + public void fillFields() { + fields.put(AuditingFieldsKey.AUDIT_AUTH_URL.getDisplayName(), getUrl()); + + fields.put(AuditingFieldsKey.AUDIT_AUTH_USER.getDisplayName(), getUser()); + fields.put(AuditingFieldsKey.AUDIT_AUTH_STATUS.getDisplayName(), getAuthStatus()); + fields.put(AuditingFieldsKey.AUDIT_AUTH_REALM.getDisplayName(), getRealm()); + fields.put(AuditingFieldsKey.AUDIT_ACTION.getDisplayName(), getAction()); + fields.put(AuditingFieldsKey.AUDIT_STATUS.getDisplayName(), getStatus()); + fields.put(AuditingFieldsKey.AUDIT_REQUEST_ID.getDisplayName(), getRequestId()); + fields.put(AuditingFieldsKey.AUDIT_DESC.getDisplayName(), getDesc()); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormatPattern); + simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); + fields.put(AuditingFieldsKey.AUDIT_TIMESTAMP.getDisplayName(), simpleDateFormat.format(timestamp1)); + } } diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/CategoryEvent.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/CategoryEvent.java index 2e4f6c8fc4..95d31d9216 100644 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/CategoryEvent.java +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/CategoryEvent.java @@ -20,237 +20,194 @@ package org.openecomp.sdc.be.resources.data.auditing; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.Map; -import java.util.TimeZone; -import java.util.UUID; - -import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData; -import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum; - import com.datastax.driver.core.utils.UUIDs; import com.datastax.driver.mapping.annotations.ClusteringColumn; import com.datastax.driver.mapping.annotations.Column; import com.datastax.driver.mapping.annotations.PartitionKey; import com.datastax.driver.mapping.annotations.Table; +import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData; +import org.openecomp.sdc.common.datastructure.AuditingFieldsKey; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.TimeZone; +import java.util.UUID; @Table(keyspace = AuditingTypesConstants.AUDIT_KEYSPACE, name = AuditingTypesConstants.CATEGORY_EVENT_TYPE) public class CategoryEvent extends AuditingGenericEvent { - @PartitionKey - protected UUID timebaseduuid; - - @ClusteringColumn - protected Date timestamp1; - - @Column - String action; - @Column - String status; - @Column(name = "description") - String desc; - - @Column(name = "category_name") - String categoryName; - - @Column(name = "sub_category_name") - String subCategoryName; - - @Column(name = "grouping_name") - String groupingName; - - @Column - String modifier; - - @Column(name = "service_instance_id") - String serviceInstanceId; - - @Column(name = "resource_type") - String resourceType; - - @Column(name = "request_id") - String requestId; - - public CategoryEvent() { - super(); - timestamp1 = new Date(); - timebaseduuid = UUIDs.timeBased(); - } - - public CategoryEvent(Map<AuditingFieldsKeysEnum, Object> auditingFields) { - this(); - Object value; - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_ACTION); - if (value != null) { - setAction((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_STATUS); - if (value != null) { - setStatus((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_DESC); - if (value != null) { - setDesc((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_CATEGORY_NAME); - if (value != null) { - setCategoryName((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_SUB_CATEGORY_NAME); - if (value != null) { - setSubCategoryName((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_GROUPING_NAME); - if (value != null) { - setGroupingName((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_MODIFIER_UID); - if (value != null) { - setModifier((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_REQUEST_ID); - if (value != null) { - setRequestId((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_RESOURCE_TYPE); - if (value != null) { - setResourceType((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_SERVICE_INSTANCE_ID); - if (value != null) { - setServiceInstanceId((String) value); - } - - } - - public CategoryEvent(String action, CommonAuditData commonAuditData, String modifier, String categoryName, String subCategoryName, + + @PartitionKey + protected UUID timebaseduuid; + + @ClusteringColumn + protected Date timestamp1; + + @Column + String action; + @Column + String status; + @Column(name = "description") + String desc; + + @Column(name = "category_name") + String categoryName; + + @Column(name = "sub_category_name") + String subCategoryName; + + @Column(name = "grouping_name") + String groupingName; + + @Column + String modifier; + + @Column(name = "service_instance_id") + String serviceInstanceId; + + @Column(name = "resource_type") + String resourceType; + + @Column(name = "request_id") + String requestId; + + public CategoryEvent(String action, CommonAuditData commonAuditData, String modifier, String categoryName, String subCategoryName, String groupingName, String resourceType) { - this(); - this.action = action; - this.requestId = commonAuditData.getRequestId(); - this.status = commonAuditData.getStatus(); - this.desc = commonAuditData.getDescription(); - this.serviceInstanceId = commonAuditData.getServiceInstanceId(); - this.resourceType = resourceType; - this.modifier = modifier; - this.categoryName = categoryName; - this.subCategoryName = subCategoryName; - this.groupingName = groupingName; - } - - @Override - public void fillFields() { - - fields.put(AuditingFieldsKeysEnum.AUDIT_ACTION.getDisplayName(), getAction()); - fields.put(AuditingFieldsKeysEnum.AUDIT_STATUS.getDisplayName(), getStatus()); - fields.put(AuditingFieldsKeysEnum.AUDIT_DESC.getDisplayName(), getDesc()); - fields.put(AuditingFieldsKeysEnum.AUDIT_CATEGORY_NAME.getDisplayName(), getCategoryName()); - fields.put(AuditingFieldsKeysEnum.AUDIT_SUB_CATEGORY_NAME.getDisplayName(), getSubCategoryName()); - fields.put(AuditingFieldsKeysEnum.AUDIT_GROUPING_NAME.getDisplayName(), getGroupingName()); - fields.put(AuditingFieldsKeysEnum.AUDIT_MODIFIER_UID.getDisplayName(), getModifier()); - fields.put(AuditingFieldsKeysEnum.AUDIT_REQUEST_ID.getDisplayName(), getRequestId()); - fields.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_TYPE.getDisplayName(), getResourceType()); - fields.put(AuditingFieldsKeysEnum.AUDIT_SERVICE_INSTANCE_ID.getDisplayName(), getServiceInstanceId()); - SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormatPattern); - simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); - fields.put(AuditingFieldsKeysEnum.AUDIT_TIMESTAMP.getDisplayName(), simpleDateFormat.format(timestamp1)); - - } - - public UUID getTimebaseduuid() { - return timebaseduuid; - } - - public void setTimebaseduuid(UUID timebaseduuid) { - this.timebaseduuid = timebaseduuid; - } - - 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 String getCategoryName() { - return categoryName; - } - - public void setCategoryName(String categoryName) { - this.categoryName = categoryName; - } - - public String getSubCategoryName() { - return subCategoryName; - } - - public void setSubCategoryName(String subCategoryName) { - this.subCategoryName = subCategoryName; - } - - public String getGroupingName() { - return groupingName; - } - - public void setGroupingName(String groupingName) { - this.groupingName = groupingName; - } - - public Date getTimestamp1() { - return timestamp1; - } - - public void setTimestamp1(Date timestamp1) { - this.timestamp1 = timestamp1; - } - - public String getModifier() { - return modifier; - } - - public void setModifier(String modifier) { - this.modifier = modifier; - } - - public String getServiceInstanceId() { - return serviceInstanceId; - } - - public void setServiceInstanceId(String serviceInstanceId) { - this.serviceInstanceId = serviceInstanceId; - } - - public String getResourceType() { - return resourceType; - } - - public void setResourceType(String resourceType) { - this.resourceType = resourceType; - } - - public String getRequestId() { - return requestId; - } - - public void setRequestId(String requestId) { - this.requestId = requestId; - } + this(); + this.action = action; + this.requestId = commonAuditData.getRequestId(); + this.status = commonAuditData.getStatus(); + this.desc = commonAuditData.getDescription(); + this.serviceInstanceId = commonAuditData.getServiceInstanceId(); + this.resourceType = resourceType; + this.modifier = modifier; + this.categoryName = categoryName; + this.subCategoryName = subCategoryName; + this.groupingName = groupingName; + } + + //Required to be public as it is used by Cassandra driver on get operation + public CategoryEvent() { + timestamp1 = new Date(); + timebaseduuid = UUIDs.timeBased(); + } + + public void setTimestamp1(String timestamp) { + this.timestamp1 = parseDateFromString(timestamp); + } + + @Override + public void fillFields() { + + fields.put(AuditingFieldsKey.AUDIT_ACTION.getDisplayName(), getAction()); + fields.put(AuditingFieldsKey.AUDIT_STATUS.getDisplayName(), getStatus()); + fields.put(AuditingFieldsKey.AUDIT_DESC.getDisplayName(), getDesc()); + fields.put(AuditingFieldsKey.AUDIT_CATEGORY_NAME.getDisplayName(), getCategoryName()); + fields.put(AuditingFieldsKey.AUDIT_SUB_CATEGORY_NAME.getDisplayName(), getSubCategoryName()); + fields.put(AuditingFieldsKey.AUDIT_GROUPING_NAME.getDisplayName(), getGroupingName()); + fields.put(AuditingFieldsKey.AUDIT_MODIFIER_UID.getDisplayName(), getModifier()); + fields.put(AuditingFieldsKey.AUDIT_REQUEST_ID.getDisplayName(), getRequestId()); + fields.put(AuditingFieldsKey.AUDIT_RESOURCE_TYPE.getDisplayName(), getResourceType()); + fields.put(AuditingFieldsKey.AUDIT_SERVICE_INSTANCE_ID.getDisplayName(), getServiceInstanceId()); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormatPattern); + simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); + fields.put(AuditingFieldsKey.AUDIT_TIMESTAMP.getDisplayName(), simpleDateFormat.format(timestamp1)); + + } + + public UUID getTimebaseduuid() { + return timebaseduuid; + } + + public void setTimebaseduuid(UUID timebaseduuid) { + this.timebaseduuid = timebaseduuid; + } + + 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 String getCategoryName() { + return categoryName; + } + + public void setCategoryName(String categoryName) { + this.categoryName = categoryName; + } + + public String getSubCategoryName() { + return subCategoryName; + } + + public void setSubCategoryName(String subCategoryName) { + this.subCategoryName = subCategoryName; + } + + public String getGroupingName() { + return groupingName; + } + + public void setGroupingName(String groupingName) { + this.groupingName = groupingName; + } + + public Date getTimestamp1() { + return timestamp1; + } + + public void setTimestamp1(Date timestamp1) { + this.timestamp1 = timestamp1; + } + + public String getModifier() { + return modifier; + } + + public void setModifier(String modifier) { + this.modifier = modifier; + } + + public String getServiceInstanceId() { + return serviceInstanceId; + } + + public void setServiceInstanceId(String serviceInstanceId) { + this.serviceInstanceId = serviceInstanceId; + } + + public String getResourceType() { + return resourceType; + } + + public void setResourceType(String resourceType) { + this.resourceType = resourceType; + } + + public String getRequestId() { + return requestId; + } + + public void setRequestId(String requestId) { + this.requestId = requestId; + } } diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/ConsumerEvent.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/ConsumerEvent.java index 3fceb8bb50..546b71070d 100644 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/ConsumerEvent.java +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/ConsumerEvent.java @@ -20,25 +20,21 @@ package org.openecomp.sdc.be.resources.data.auditing; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.Map; -import java.util.TimeZone; -import java.util.UUID; - -import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData; -import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum; - import com.datastax.driver.core.utils.UUIDs; import com.datastax.driver.mapping.annotations.ClusteringColumn; import com.datastax.driver.mapping.annotations.Column; import com.datastax.driver.mapping.annotations.PartitionKey; import com.datastax.driver.mapping.annotations.Table; +import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData; +import org.openecomp.sdc.common.datastructure.AuditingFieldsKey; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.TimeZone; +import java.util.UUID; @Table(keyspace = AuditingTypesConstants.AUDIT_KEYSPACE, name = AuditingTypesConstants.CONSUMER_EVENT_TYPE) public class ConsumerEvent extends AuditingGenericEvent { - private static String CONSUMER_EVENT_TEMPLATE = "action=\"%s\" timestamp=\"%s\" " - + "modifier=\"%s\" ecompUser=\"%s\" status=\"%s\" desc=\"%s\""; @PartitionKey protected UUID timebaseduuid; @@ -62,41 +58,6 @@ public class ConsumerEvent extends AuditingGenericEvent { @Column(name = "ecomp_user") private String ecompUser; - public ConsumerEvent() { - super(); - timestamp1 = new Date(); - timebaseduuid = UUIDs.timeBased(); - } - - public ConsumerEvent(Map<AuditingFieldsKeysEnum, Object> auditingFields) { - this(); - Object value; - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_REQUEST_ID); - if (value != null) { - setRequestId((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_ACTION); - if (value != null) { - setAction((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_STATUS); - if (value != null) { - setStatus((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_DESC); - if (value != null) { - setDesc((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_MODIFIER_UID); - if (value != null) { - setModifier((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_ECOMP_USER); - if (value != null) { - setEcompUser((String) value); - } - } - public ConsumerEvent(String action, CommonAuditData commonAuditData, String ecompUser, String modifier) { this(); this.action = action; @@ -107,18 +68,28 @@ public class ConsumerEvent extends AuditingGenericEvent { this.ecompUser = ecompUser; } + //Required to be public as it is used by Cassandra driver on get operation + public ConsumerEvent() { + timestamp1 = new Date(); + timebaseduuid = UUIDs.timeBased(); + } + + public void setTimestamp1(String timestamp) { + this.timestamp1 = parseDateFromString(timestamp); + } + @Override public void fillFields() { - fields.put(AuditingFieldsKeysEnum.AUDIT_REQUEST_ID.getDisplayName(), getRequestId()); + fields.put(AuditingFieldsKey.AUDIT_REQUEST_ID.getDisplayName(), getRequestId()); - fields.put(AuditingFieldsKeysEnum.AUDIT_ACTION.getDisplayName(), getAction()); - fields.put(AuditingFieldsKeysEnum.AUDIT_STATUS.getDisplayName(), getStatus()); - fields.put(AuditingFieldsKeysEnum.AUDIT_DESC.getDisplayName(), getDesc()); - fields.put(AuditingFieldsKeysEnum.AUDIT_MODIFIER_UID.getDisplayName(), getModifier()); - fields.put(AuditingFieldsKeysEnum.AUDIT_ECOMP_USER.getDisplayName(), getEcompUser()); + fields.put(AuditingFieldsKey.AUDIT_ACTION.getDisplayName(), getAction()); + fields.put(AuditingFieldsKey.AUDIT_STATUS.getDisplayName(), getStatus()); + fields.put(AuditingFieldsKey.AUDIT_DESC.getDisplayName(), getDesc()); + fields.put(AuditingFieldsKey.AUDIT_MODIFIER_UID.getDisplayName(), getModifier()); + fields.put(AuditingFieldsKey.AUDIT_ECOMP_USER.getDisplayName(), getEcompUser()); SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormatPattern); simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); - fields.put(AuditingFieldsKeysEnum.AUDIT_TIMESTAMP.getDisplayName(), simpleDateFormat.format(timestamp1)); + fields.put(AuditingFieldsKey.AUDIT_TIMESTAMP.getDisplayName(), simpleDateFormat.format(timestamp1)); } public String getModifier() { diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/DistributionDeployEvent.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/DistributionDeployEvent.java index f3bd870eb0..0423a08fac 100644 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/DistributionDeployEvent.java +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/DistributionDeployEvent.java @@ -20,28 +20,23 @@ package org.openecomp.sdc.be.resources.data.auditing; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.Map; -import java.util.TimeZone; -import java.util.UUID; - -import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData; -import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum; - import com.datastax.driver.core.utils.UUIDs; import com.datastax.driver.mapping.annotations.ClusteringColumn; import com.datastax.driver.mapping.annotations.Column; import com.datastax.driver.mapping.annotations.PartitionKey; import com.datastax.driver.mapping.annotations.Table; +import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData; +import org.openecomp.sdc.be.resources.data.auditing.model.ResourceCommonInfo; +import org.openecomp.sdc.common.datastructure.AuditingFieldsKey; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.TimeZone; +import java.util.UUID; @Table(keyspace = AuditingTypesConstants.AUDIT_KEYSPACE, name = AuditingTypesConstants.DISTRIBUTION_DEPLOY_EVENT_TYPE) public class DistributionDeployEvent extends AuditingGenericEvent { - private static String DISTRIBUTION_DEPLOY_EVENT_TEMPLATE = "action=\"%s\" timestamp=\"%s\" " - + "resourceName=\"%s\" resourceType=\"%s\" currVersion=\"%s\" " - + "modifierName=\"%s\" modifierUid=\"%s\" did=\"%s\" " + "status=\"%s\" desc=\"%s\""; - @PartitionKey protected UUID timebaseduuid; @@ -76,60 +71,13 @@ public class DistributionDeployEvent extends AuditingGenericEvent { @Column private String did; - public DistributionDeployEvent() { - super(); - timestamp1 = new Date(); - timebaseduuid = UUIDs.timeBased(); - } - - public DistributionDeployEvent(Map<AuditingFieldsKeysEnum, Object> auditingFields) { - this(); - Object value; - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_REQUEST_ID); - if (value != null) { - setRequestId((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_SERVICE_INSTANCE_ID); - if (value != null) { - setServiceInstanceId((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_ACTION); - if (value != null) { - setAction((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_STATUS); - if (value != null) { - setStatus((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_DESC); - if (value != null) { - setDesc((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_ID); - if (value != null) { - setDid((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_MODIFIER_UID); - if (value != null) { - setModifier((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_RESOURCE_CURR_VERSION); - if (value != null) { - setCurrVersion((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME); - if (value != null) { - setResourceName((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_RESOURCE_TYPE); - if (value != null) { - setResourceType((String) value); - } + public DistributionDeployEvent() { + timestamp1 = new Date(); + timebaseduuid = UUIDs.timeBased(); } - - public DistributionDeployEvent(String action, CommonAuditData commonAuditData, String did, String modifier, - String currVersion, String resourceName, String resourceType) { + public DistributionDeployEvent(String action, CommonAuditData commonAuditData, ResourceCommonInfo resourceCommonInfo, String did, String modifier, + String currVersion) { this(); this.action = action; this.requestId = commonAuditData.getRequestId(); @@ -139,27 +87,31 @@ public class DistributionDeployEvent extends AuditingGenericEvent { this.did = did; this.modifier = modifier; this.currVersion = currVersion; - this.resourceName = resourceName; - this.resourceType = resourceType; + this.resourceName = resourceCommonInfo.getResourceName(); + this.resourceType = resourceCommonInfo.getResourceType(); + } + + public void setTimestamp1(String timestamp) { + this.timestamp1 = parseDateFromString(timestamp); } @Override - public void fillFields() { - fields.put(AuditingFieldsKeysEnum.AUDIT_REQUEST_ID.getDisplayName(), getRequestId()); - fields.put(AuditingFieldsKeysEnum.AUDIT_SERVICE_INSTANCE_ID.getDisplayName(), getServiceInstanceId()); - fields.put(AuditingFieldsKeysEnum.AUDIT_ACTION.getDisplayName(), getAction()); - fields.put(AuditingFieldsKeysEnum.AUDIT_STATUS.getDisplayName(), getStatus()); - fields.put(AuditingFieldsKeysEnum.AUDIT_DESC.getDisplayName(), getDesc()); - - fields.put(AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_ID.getDisplayName(), getDid()); - fields.put(AuditingFieldsKeysEnum.AUDIT_MODIFIER_UID.getDisplayName(), getModifier()); - fields.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_CURR_VERSION.getDisplayName(), getCurrVersion()); - fields.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME.getDisplayName(), getResourceName()); - fields.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_TYPE.getDisplayName(), getResourceType()); - SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormatPattern); - simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); - fields.put(AuditingFieldsKeysEnum.AUDIT_TIMESTAMP.getDisplayName(), simpleDateFormat.format(timestamp1)); - } + public void fillFields() { + fields.put(AuditingFieldsKey.AUDIT_REQUEST_ID.getDisplayName(), getRequestId()); + fields.put(AuditingFieldsKey.AUDIT_SERVICE_INSTANCE_ID.getDisplayName(), getServiceInstanceId()); + fields.put(AuditingFieldsKey.AUDIT_ACTION.getDisplayName(), getAction()); + fields.put(AuditingFieldsKey.AUDIT_STATUS.getDisplayName(), getStatus()); + fields.put(AuditingFieldsKey.AUDIT_DESC.getDisplayName(), getDesc()); + + fields.put(AuditingFieldsKey.AUDIT_DISTRIBUTION_ID.getDisplayName(), getDid()); + fields.put(AuditingFieldsKey.AUDIT_MODIFIER_UID.getDisplayName(), getModifier()); + fields.put(AuditingFieldsKey.AUDIT_RESOURCE_CURR_VERSION.getDisplayName(), getCurrVersion()); + fields.put(AuditingFieldsKey.AUDIT_RESOURCE_NAME.getDisplayName(), getResourceName()); + fields.put(AuditingFieldsKey.AUDIT_RESOURCE_TYPE.getDisplayName(), getResourceType()); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormatPattern); + simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); + fields.put(AuditingFieldsKey.AUDIT_TIMESTAMP.getDisplayName(), simpleDateFormat.format(timestamp1)); + } public String getResourceName() { return resourceName; @@ -258,11 +210,11 @@ public class DistributionDeployEvent extends AuditingGenericEvent { } @Override - public String toString() { - return "DistributionDeployEvent [timebaseduuid=" + timebaseduuid + ", timestamp1=" + timestamp1 + ", requestId=" - + requestId + ", serviceInstanceId=" + serviceInstanceId + ", action=" + action + ", status=" + status - + ", desc=" + desc + ", resourceName=" + resourceName + ", resourceType=" + resourceType - + ", currVersion=" + currVersion + ", modifier=" + modifier + ", did=" + did + "]"; - } + public String toString() { + return "DistributionDeployEvent [timebaseduuid=" + timebaseduuid + ", timestamp1=" + timestamp1 + ", requestId=" + + requestId + ", serviceInstanceId=" + serviceInstanceId + ", action=" + action + ", status=" + status + + ", desc=" + desc + ", resourceName=" + resourceName + ", resourceType=" + resourceType + + ", currVersion=" + currVersion + ", modifier=" + modifier + ", did=" + did + "]"; + } } diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/DistributionDownloadEvent.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/DistributionDownloadEvent.java index 1a205cbbbe..d3ffd33074 100644 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/DistributionDownloadEvent.java +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/DistributionDownloadEvent.java @@ -20,28 +20,23 @@ package org.openecomp.sdc.be.resources.data.auditing; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.Map; -import java.util.TimeZone; -import java.util.UUID; - -import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData; -import org.openecomp.sdc.be.resources.data.auditing.model.DistributionData; -import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum; - import com.datastax.driver.core.utils.UUIDs; import com.datastax.driver.mapping.annotations.ClusteringColumn; import com.datastax.driver.mapping.annotations.Column; import com.datastax.driver.mapping.annotations.PartitionKey; import com.datastax.driver.mapping.annotations.Table; +import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData; +import org.openecomp.sdc.be.resources.data.auditing.model.DistributionData; +import org.openecomp.sdc.common.datastructure.AuditingFieldsKey; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.TimeZone; +import java.util.UUID; @Table(keyspace = AuditingTypesConstants.AUDIT_KEYSPACE, name = AuditingTypesConstants.DISTRIBUTION_DOWNLOAD_EVENT_TYPE) public class DistributionDownloadEvent extends AuditingGenericEvent { - private static String DISTRIBUTION_DOWNLOAD_EVENT_TEMPLATE = "action=\"%s\" timestamp=\"%s\" " - + "consumerId=\"%s\" resourceUrl=\"%s\" status=\"%s\" desc=\"%s\""; - @PartitionKey protected UUID timebaseduuid; @@ -68,46 +63,12 @@ public class DistributionDownloadEvent extends AuditingGenericEvent { @Column(name = "resource_url") private String resourceUrl; + //Required to be public as it is used by Cassandra driver on get operation public DistributionDownloadEvent() { - super(); - timestamp1 = new Date(); timebaseduuid = UUIDs.timeBased(); } - public DistributionDownloadEvent(Map<AuditingFieldsKeysEnum, Object> auditingFields) { - this(); - Object value; - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_REQUEST_ID); - if (value != null) { - setRequestId((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_SERVICE_INSTANCE_ID); - if (value != null) { - setServiceInstanceId((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_ACTION); - if (value != null) { - setAction((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_STATUS); - if (value != null) { - setStatus((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_DESC); - if (value != null) { - setDesc((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_CONSUMER_ID); - if (value != null) { - setConsumerId((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_RESOURCE_URL); - if (value != null) { - setResourceUrl((String) value); - } - } - public DistributionDownloadEvent(String action, CommonAuditData commonAuditData, DistributionData distributionData) { this(); this.action = action; @@ -119,20 +80,24 @@ public class DistributionDownloadEvent extends AuditingGenericEvent { this.resourceUrl = distributionData.getResourceUrl(); } - @Override - public void fillFields() { - fields.put(AuditingFieldsKeysEnum.AUDIT_REQUEST_ID.getDisplayName(), getRequestId()); - fields.put(AuditingFieldsKeysEnum.AUDIT_SERVICE_INSTANCE_ID.getDisplayName(), getServiceInstanceId()); - fields.put(AuditingFieldsKeysEnum.AUDIT_ACTION.getDisplayName(), getAction()); - fields.put(AuditingFieldsKeysEnum.AUDIT_STATUS.getDisplayName(), getStatus()); - fields.put(AuditingFieldsKeysEnum.AUDIT_DESC.getDisplayName(), getDesc()); + public void setTimestamp1(String timestamp) { + this.timestamp1 = parseDateFromString(timestamp); + } - fields.put(AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_CONSUMER_ID.getDisplayName(), getConsumerId()); - fields.put(AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_RESOURCE_URL.getDisplayName(), getResourceUrl()); - SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormatPattern); - simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); - fields.put(AuditingFieldsKeysEnum.AUDIT_TIMESTAMP.getDisplayName(), simpleDateFormat.format(timestamp1)); - } + @Override + public void fillFields() { + fields.put(AuditingFieldsKey.AUDIT_REQUEST_ID.getDisplayName(), getRequestId()); + fields.put(AuditingFieldsKey.AUDIT_SERVICE_INSTANCE_ID.getDisplayName(), getServiceInstanceId()); + fields.put(AuditingFieldsKey.AUDIT_ACTION.getDisplayName(), getAction()); + fields.put(AuditingFieldsKey.AUDIT_STATUS.getDisplayName(), getStatus()); + fields.put(AuditingFieldsKey.AUDIT_DESC.getDisplayName(), getDesc()); + + fields.put(AuditingFieldsKey.AUDIT_DISTRIBUTION_CONSUMER_ID.getDisplayName(), getConsumerId()); + fields.put(AuditingFieldsKey.AUDIT_DISTRIBUTION_RESOURCE_URL.getDisplayName(), getResourceUrl()); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormatPattern); + simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); + fields.put(AuditingFieldsKey.AUDIT_TIMESTAMP.getDisplayName(), simpleDateFormat.format(timestamp1)); + } public String getConsumerId() { return consumerId; @@ -202,15 +167,16 @@ public class DistributionDownloadEvent extends AuditingGenericEvent { return desc; } + @Override public void setDesc(String desc) { this.desc = desc; } @Override - public String toString() { - return "DistributionDownloadEvent [timebaseduuid=" + timebaseduuid + ", timestamp1=" + timestamp1 - + ", requestId=" + requestId + ", serviceInstanceId=" + serviceInstanceId + ", action=" + action - + ", status=" + status + ", desc=" + desc + ", consumerId=" + consumerId + ", resourceUrl=" + resourceUrl + "]"; - } + public String toString() { + return "DistributionDownloadEvent [timebaseduuid=" + timebaseduuid + ", timestamp1=" + timestamp1 + + ", requestId=" + requestId + ", serviceInstanceId=" + serviceInstanceId + ", action=" + action + + ", status=" + status + ", desc=" + desc + ", consumerId=" + consumerId + ", resourceUrl=" + resourceUrl + "]"; + } } diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/DistributionEngineEvent.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/DistributionEngineEvent.java index 46bff73eb0..b7513ff468 100644 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/DistributionEngineEvent.java +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/DistributionEngineEvent.java @@ -20,27 +20,23 @@ package org.openecomp.sdc.be.resources.data.auditing; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.Map; -import java.util.TimeZone; -import java.util.UUID; - -import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData; -import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum; - import com.datastax.driver.core.utils.UUIDs; import com.datastax.driver.mapping.annotations.ClusteringColumn; import com.datastax.driver.mapping.annotations.Column; import com.datastax.driver.mapping.annotations.PartitionKey; import com.datastax.driver.mapping.annotations.Table; +import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData; +import org.openecomp.sdc.be.resources.data.auditing.model.DistributionTopicData; +import org.openecomp.sdc.common.datastructure.AuditingFieldsKey; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.TimeZone; +import java.util.UUID; @Table(keyspace = AuditingTypesConstants.AUDIT_KEYSPACE, name = AuditingTypesConstants.DISTRIBUTION_ENGINE_EVENT_TYPE) public class DistributionEngineEvent extends AuditingGenericEvent { - private static String DISTRIBUTION_ENGINE_EVENT_TEMPLATE = "action=\"%s\" timestamp=\"%s\" " - + "environmentName=\"%s\" topicName=\"%s\" role=\"%s\" apiKey=\"%s\" " + "status=\"%s\" "; - @PartitionKey protected UUID timebaseduuid; @@ -79,68 +75,14 @@ public class DistributionEngineEvent extends AuditingGenericEvent { @Column(name = "api_key") private String apiKey; + //Required to be public as it is used by Cassandra driver on get operation public DistributionEngineEvent() { - super(); timestamp1 = new Date(); timebaseduuid = UUIDs.timeBased(); } - public DistributionEngineEvent(Map<AuditingFieldsKeysEnum, Object> auditingFields) { - this(); - Object value; - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_REQUEST_ID); - if (value != null) { - setRequestId((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_SERVICE_INSTANCE_ID); - if (value != null) { - setServiceInstanceId((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_ACTION); - if (value != null) { - setAction((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_STATUS); - if (value != null) { - setStatus((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_DESC); - if (value != null) { - setDesc((String) value); - } else { - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_STATUS_DESC); - if (value != null) { - setDesc((String) value); - } - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_CONSUMER_ID); - if (value != null) { - setConsumerId((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_STATUS_TOPIC_NAME); - if (value != null) { - setDstatusTopic((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_NOTIFICATION_TOPIC_NAME); - if (value != null) { - setDnotifTopic((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_API_KEY); - if (value != null) { - setApiKey((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_ENVRIONMENT_NAME); - if (value != null) { - setEnvironmentName((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_ROLE); - if (value != null) { - setRole((String) value); - } - } - - public DistributionEngineEvent(String action, CommonAuditData commonAuditData, String consumerId, String distStatusTopic, String distNotifTopic, - String apiKey, String envName, String role) { + public DistributionEngineEvent(String action, CommonAuditData commonAuditData, String consumerId, DistributionTopicData distributionTopicData, + String apiKey, String envName, String role) { this(); this.action = action; this.requestId = commonAuditData.getRequestId(); @@ -149,33 +91,37 @@ public class DistributionEngineEvent extends AuditingGenericEvent { //if no desc, keep distr desc this.desc = commonAuditData.getDescription(); this.consumerId = consumerId; - this.dstatusTopic = distStatusTopic; - this.dnotifTopic = distNotifTopic; + this.dstatusTopic = distributionTopicData.getStatusTopic(); + this.dnotifTopic = distributionTopicData.getNotificationTopic(); this.apiKey = apiKey; this.environmentName = envName; this.role = role; } + public void setTimestamp1(String timestamp) { + this.timestamp1 = parseDateFromString(timestamp); + } + @Override public void fillFields() { - fields.put(AuditingFieldsKeysEnum.AUDIT_REQUEST_ID.getDisplayName(), getRequestId()); - - fields.put(AuditingFieldsKeysEnum.AUDIT_SERVICE_INSTANCE_ID.getDisplayName(), getServiceInstanceId()); - fields.put(AuditingFieldsKeysEnum.AUDIT_ACTION.getDisplayName(), getAction()); - fields.put(AuditingFieldsKeysEnum.AUDIT_STATUS.getDisplayName(), getStatus()); - fields.put(AuditingFieldsKeysEnum.AUDIT_DESC.getDisplayName(), getDesc()); - - fields.put(AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_CONSUMER_ID.getDisplayName(), getConsumerId()); - fields.put(AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_API_KEY.getDisplayName(), getApiKey()); - fields.put(AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_ENVRIONMENT_NAME.getDisplayName(), getEnvironmentName()); - fields.put(AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_ROLE.getDisplayName(), getRole()); - fields.put(AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_STATUS_TOPIC_NAME.getDisplayName(), getDstatusTopic()); - fields.put(AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_NOTIFICATION_TOPIC_NAME.getDisplayName(), - getDnotifTopic()); - SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormatPattern); - simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); - fields.put(AuditingFieldsKeysEnum.AUDIT_TIMESTAMP.getDisplayName(), simpleDateFormat.format(timestamp1)); - } + fields.put(AuditingFieldsKey.AUDIT_REQUEST_ID.getDisplayName(), getRequestId()); + + fields.put(AuditingFieldsKey.AUDIT_SERVICE_INSTANCE_ID.getDisplayName(), getServiceInstanceId()); + fields.put(AuditingFieldsKey.AUDIT_ACTION.getDisplayName(), getAction()); + fields.put(AuditingFieldsKey.AUDIT_STATUS.getDisplayName(), getStatus()); + fields.put(AuditingFieldsKey.AUDIT_DESC.getDisplayName(), getDesc()); + + fields.put(AuditingFieldsKey.AUDIT_DISTRIBUTION_CONSUMER_ID.getDisplayName(), getConsumerId()); + fields.put(AuditingFieldsKey.AUDIT_DISTRIBUTION_API_KEY.getDisplayName(), getApiKey()); + fields.put(AuditingFieldsKey.AUDIT_DISTRIBUTION_ENVRIONMENT_NAME.getDisplayName(), getEnvironmentName()); + fields.put(AuditingFieldsKey.AUDIT_DISTRIBUTION_ROLE.getDisplayName(), getRole()); + fields.put(AuditingFieldsKey.AUDIT_DISTRIBUTION_STATUS_TOPIC_NAME.getDisplayName(), getDstatusTopic()); + fields.put(AuditingFieldsKey.AUDIT_DISTRIBUTION_NOTIFICATION_TOPIC_NAME.getDisplayName(), + getDnotifTopic()); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormatPattern); + simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); + fields.put(AuditingFieldsKey.AUDIT_TIMESTAMP.getDisplayName(), simpleDateFormat.format(timestamp1)); + } public String getDstatusTopic() { return dstatusTopic; diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/DistributionNotificationEvent.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/DistributionNotificationEvent.java index 4b783fbc33..12b8c0c453 100644 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/DistributionNotificationEvent.java +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/DistributionNotificationEvent.java @@ -20,340 +20,274 @@ package org.openecomp.sdc.be.resources.data.auditing; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.Map; -import java.util.TimeZone; -import java.util.UUID; - -import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData; -import org.openecomp.sdc.be.resources.data.auditing.model.OperationalEnvAuditData; -import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum; - import com.datastax.driver.core.utils.UUIDs; import com.datastax.driver.mapping.annotations.ClusteringColumn; import com.datastax.driver.mapping.annotations.Column; import com.datastax.driver.mapping.annotations.PartitionKey; import com.datastax.driver.mapping.annotations.Table; +import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData; +import org.openecomp.sdc.be.resources.data.auditing.model.OperationalEnvAuditData; +import org.openecomp.sdc.be.resources.data.auditing.model.ResourceCommonInfo; +import org.openecomp.sdc.be.resources.data.auditing.model.ResourceVersionInfo; +import org.openecomp.sdc.common.datastructure.AuditingFieldsKey; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.TimeZone; +import java.util.UUID; @Table(keyspace = AuditingTypesConstants.AUDIT_KEYSPACE, name = AuditingTypesConstants.DISTRIBUTION_NOTIFICATION_EVENT_TYPE) public class DistributionNotificationEvent extends AuditingGenericEvent { - private static String DISTRIBUTION_NOTIFICATION_EVENT_TEMPLATE = "action=\"%s\" timestamp=\"%s\" " - + "resourceName=\"%s\" resourceType=\"%s\" currVersion=\"%s\" " + "modifierName=\"%s\" modifierUid=\"%s\" " - + "currState=\"%s\" distributionId=\"%s\" " + "topicName=\"%s\" status=\"%s\" description=\"%s\""; - - @PartitionKey - protected UUID timebaseduuid; - - @ClusteringColumn - protected Date timestamp1; - - @Column(name = "request_id") - protected String requestId; - - @Column(name = "service_instance_id") - protected String serviceInstanceId; - @Column - protected String action; - @Column - protected String status; - - @Column(name = "description") - protected String desc; - - @Column(name = "resource_name") - private String resourceName; - - @Column(name = "resource_type") - private String resourceType; - - @Column(name = "curr_version") - private String currVersion; - - @Column - private String modifier; - - @Column(name = "curr_state") - private String currState; - - @Column(name = "topic_name") - private String topicName; - - @Column - private String did; - - @Column(name = "env_id") - private String envId; - - @Column(name = "vnf_workload_context") - private String vnfWorkloadContext; - - @Column(name = "tenant") - private String tenant; - - public DistributionNotificationEvent() { - super(); - timestamp1 = new Date(); - timebaseduuid = UUIDs.timeBased(); - } - - public DistributionNotificationEvent(Map<AuditingFieldsKeysEnum, Object> auditingFields) { - this(); - Object value; - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_REQUEST_ID); - if (value != null) { - setRequestId((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_SERVICE_INSTANCE_ID); - if (value != null) { - setServiceInstanceId((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_ACTION); - if (value != null) { - setAction((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_STATUS); - if (value != null) { - setStatus((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_DESC); - if (value != null) { - setDesc((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_ID); - if (value != null) { - setDid((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_MODIFIER_UID); - if (value != null) { - setModifier((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_RESOURCE_CURR_STATE); - if (value != null) { - setCurrState((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_RESOURCE_CURR_VERSION); - if (value != null) { - setCurrVersion((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME); - if (value != null) { - setResourceName((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_RESOURCE_TYPE); - if (value != null) { - setResourceType((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_TOPIC_NAME); - if (value != null) { - setTopicName((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_ENVIRONMENT_ID); - if (value != null) { - setEnvId((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_VNF_WORKLOAD_CONTEXT); - if (value != null) { - setVnfWorkloadContext((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_TENANT); - if (value != null) { - setTenant((String) value); - } - - } - - public DistributionNotificationEvent(String action, CommonAuditData commonAuditData, String did, String modifier, String resourceCurrState, - String resourceCurrVersion, String resourceName, String resourceType, String topicName, + @PartitionKey + protected UUID timebaseduuid; + + @ClusteringColumn + protected Date timestamp1; + + @Column(name = "request_id") + protected String requestId; + + @Column(name = "service_instance_id") + protected String serviceInstanceId; + @Column + protected String action; + @Column + protected String status; + + @Column(name = "description") + protected String desc; + + @Column(name = "resource_name") + private String resourceName; + + @Column(name = "resource_type") + private String resourceType; + + @Column(name = "curr_version") + private String currVersion; + + @Column + private String modifier; + + @Column(name = "curr_state") + private String currState; + + @Column(name = "topic_name") + private String topicName; + + @Column + private String did; + + @Column(name = "env_id") + private String envId; + + @Column(name = "vnf_workload_context") + private String vnfWorkloadContext; + + @Column(name = "tenant") + private String tenant; + + public DistributionNotificationEvent() { + timestamp1 = new Date(); + timebaseduuid = UUIDs.timeBased(); + } + + public DistributionNotificationEvent(String action, CommonAuditData commonAuditData, ResourceCommonInfo resourceCommonInfo, + ResourceVersionInfo resourceVersionInfo, + String did, String modifier, String topicName, OperationalEnvAuditData opEnvFields) { - this(); + this(); + this.action = action; + this.requestId = commonAuditData.getRequestId(); + this.serviceInstanceId = commonAuditData.getServiceInstanceId(); + this.status = commonAuditData.getStatus(); + this.desc = commonAuditData.getDescription(); + this.did = did; + this.modifier = modifier; + this.currState = resourceVersionInfo.getState(); + this.currVersion = resourceVersionInfo.getVersion(); + this.resourceName = resourceCommonInfo.getResourceName(); + this.resourceType = resourceCommonInfo.getResourceType(); + this.topicName = topicName; + this.envId = opEnvFields.getEnvId(); + this.vnfWorkloadContext = opEnvFields.getVnfWorkloadContext(); + this.tenant = opEnvFields.getTenant(); + + } + + public void setTimestamp1(String timestamp) { + this.timestamp1 = parseDateFromString(timestamp); + } + + @Override + public void fillFields() { + fields.put(AuditingFieldsKey.AUDIT_REQUEST_ID.getDisplayName(), getRequestId()); + + fields.put(AuditingFieldsKey.AUDIT_SERVICE_INSTANCE_ID.getDisplayName(), getServiceInstanceId()); + fields.put(AuditingFieldsKey.AUDIT_ACTION.getDisplayName(), getAction()); + fields.put(AuditingFieldsKey.AUDIT_STATUS.getDisplayName(), getStatus()); + fields.put(AuditingFieldsKey.AUDIT_DESC.getDisplayName(), getDesc()); + fields.put(AuditingFieldsKey.AUDIT_DISTRIBUTION_ENVIRONMENT_ID.getDisplayName(), getEnvId()); + fields.put(AuditingFieldsKey.AUDIT_DISTRIBUTION_VNF_WORKLOAD_CONTEXT.getDisplayName(), getVnfWorkloadContext()); + fields.put(AuditingFieldsKey.AUDIT_DISTRIBUTION_TENANT.getDisplayName(), getTenant()); + + fields.put(AuditingFieldsKey.AUDIT_DISTRIBUTION_ID.getDisplayName(), getDid()); + fields.put(AuditingFieldsKey.AUDIT_MODIFIER_UID.getDisplayName(), getModifier()); + fields.put(AuditingFieldsKey.AUDIT_RESOURCE_CURR_STATE.getDisplayName(), getCurrState()); + fields.put(AuditingFieldsKey.AUDIT_RESOURCE_CURR_VERSION.getDisplayName(), getCurrVersion()); + fields.put(AuditingFieldsKey.AUDIT_RESOURCE_NAME.getDisplayName(), getResourceName()); + fields.put(AuditingFieldsKey.AUDIT_RESOURCE_TYPE.getDisplayName(), getResourceType()); + fields.put(AuditingFieldsKey.AUDIT_DISTRIBUTION_TOPIC_NAME.getDisplayName(), getTopicName()); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormatPattern); + simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); + fields.put(AuditingFieldsKey.AUDIT_TIMESTAMP.getDisplayName(), simpleDateFormat.format(timestamp1)); + } + + public String getResourceName() { + return resourceName; + } + + public void setResourceName(String resourceName) { + this.resourceName = resourceName; + } + + public String getResourceType() { + return resourceType; + } + + public void setResourceType(String resourceType) { + this.resourceType = resourceType; + } + + public String getCurrVersion() { + return currVersion; + } + + public void setCurrVersion(String currVersion) { + this.currVersion = currVersion; + } + + public String getCurrState() { + return currState; + } + + public void setCurrState(String currState) { + this.currState = currState; + } + + public String getTopicName() { + return topicName; + } + + public void setTopicName(String topicName) { + this.topicName = topicName; + } + + public UUID getTimebaseduuid() { + return timebaseduuid; + } + + public void setTimebaseduuid(UUID timebaseduuid) { + this.timebaseduuid = timebaseduuid; + } + + public Date getTimestamp1() { + return timestamp1; + } + + public void setTimestamp1(Date timestamp1) { + this.timestamp1 = timestamp1; + } + + 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; - this.requestId = commonAuditData.getRequestId(); - this.serviceInstanceId = commonAuditData.getServiceInstanceId(); - this.status = commonAuditData.getStatus(); - this.desc = commonAuditData.getDescription(); - this.did = did; - this.modifier = modifier; - this.currState = resourceCurrState; - this.currVersion = resourceCurrVersion; - this.resourceName = resourceName; - this.resourceType = resourceType; - this.topicName = topicName; - this.envId = opEnvFields.getEnvId(); - this.vnfWorkloadContext = opEnvFields.getVnfWorkloadContext(); - this.tenant = opEnvFields.getTenant(); - - } - - @Override - public void fillFields() { - fields.put(AuditingFieldsKeysEnum.AUDIT_REQUEST_ID.getDisplayName(), getRequestId()); - - fields.put(AuditingFieldsKeysEnum.AUDIT_SERVICE_INSTANCE_ID.getDisplayName(), getServiceInstanceId()); - fields.put(AuditingFieldsKeysEnum.AUDIT_ACTION.getDisplayName(), getAction()); - fields.put(AuditingFieldsKeysEnum.AUDIT_STATUS.getDisplayName(), getStatus()); - fields.put(AuditingFieldsKeysEnum.AUDIT_DESC.getDisplayName(), getDesc()); - fields.put(AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_ENVIRONMENT_ID.getDisplayName(), getEnvId()); - fields.put(AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_VNF_WORKLOAD_CONTEXT.getDisplayName(), getVnfWorkloadContext()); - fields.put(AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_TENANT.getDisplayName(), getTenant()); - - fields.put(AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_ID.getDisplayName(), getDid()); - fields.put(AuditingFieldsKeysEnum.AUDIT_MODIFIER_UID.getDisplayName(), getModifier()); - fields.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_CURR_STATE.getDisplayName(), getCurrState()); - fields.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_CURR_VERSION.getDisplayName(), getCurrVersion()); - fields.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME.getDisplayName(), getResourceName()); - fields.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_TYPE.getDisplayName(), getResourceType()); - fields.put(AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_TOPIC_NAME.getDisplayName(), getTopicName()); - SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormatPattern); - simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); - fields.put(AuditingFieldsKeysEnum.AUDIT_TIMESTAMP.getDisplayName(), simpleDateFormat.format(timestamp1)); - } - - public String getResourceName() { - return resourceName; - } - - public void setResourceName(String resourceName) { - this.resourceName = resourceName; - } - - public String getResourceType() { - return resourceType; - } - - public void setResourceType(String resourceType) { - this.resourceType = resourceType; - } - - public String getCurrVersion() { - return currVersion; - } - - public void setCurrVersion(String currVersion) { - this.currVersion = currVersion; - } - - public String getCurrState() { - return currState; - } - - public void setCurrState(String currState) { - this.currState = currState; - } - - public String getTopicName() { - return topicName; - } - - public void setTopicName(String topicName) { - this.topicName = topicName; - } - - public UUID getTimebaseduuid() { - return timebaseduuid; - } - - public void setTimebaseduuid(UUID timebaseduuid) { - this.timebaseduuid = timebaseduuid; - } - - public Date getTimestamp1() { - return timestamp1; - } - - public void setTimestamp1(Date timestamp1) { - this.timestamp1 = timestamp1; - } - - 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 String getModifier() { - return modifier; - } - - public void setModifier(String modifier) { - this.modifier = modifier; - } - - public String getDid() { - return did; - } - - public void setDid(String did) { - this.did = did; - } - - public String getVnfWorkloadContext() { - return vnfWorkloadContext; - } - - public void setVnfWorkloadContext(String vnfWorkloadContext) { - this.vnfWorkloadContext = vnfWorkloadContext; - } - - public String getEnvId() { - return envId; - } - - public void setEnvId(String envId) { - this.envId = envId; - } - - public String getTenant() { - return tenant; - } - - public void setTenant(String tenant) { - this.tenant = tenant; - } - - @Override - public String toString() { - return "DistributionNotificationEvent [timebaseduuid=" + timebaseduuid + ", timestamp1=" + timestamp1 - + ", requestId=" + requestId + ", serviceInstanceId=" + serviceInstanceId + ", action=" + action - + ", status=" + status + ", desc=" + desc + ", resourceName=" + resourceName + ", resourceType=" - + resourceType + ", currVersion=" + currVersion + ", modifier=" + modifier + ", currState=" + currState - + ", topicName=" + topicName + ", did=" + did + } + + 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 String getModifier() { + return modifier; + } + + public void setModifier(String modifier) { + this.modifier = modifier; + } + + public String getDid() { + return did; + } + + public void setDid(String did) { + this.did = did; + } + + public String getVnfWorkloadContext() { + return vnfWorkloadContext; + } + + public void setVnfWorkloadContext(String vnfWorkloadContext) { + this.vnfWorkloadContext = vnfWorkloadContext; + } + + public String getEnvId() { + return envId; + } + + public void setEnvId(String envId) { + this.envId = envId; + } + + public String getTenant() { + return tenant; + } + + public void setTenant(String tenant) { + this.tenant = tenant; + } + + @Override + public String toString() { + return "DistributionNotificationEvent [timebaseduuid=" + timebaseduuid + ", timestamp1=" + timestamp1 + + ", requestId=" + requestId + ", serviceInstanceId=" + serviceInstanceId + ", action=" + action + + ", status=" + status + ", desc=" + desc + ", resourceName=" + resourceName + ", resourceType=" + + resourceType + ", currVersion=" + currVersion + ", modifier=" + modifier + ", currState=" + currState + + ", topicName=" + topicName + ", did=" + did + ", envId=" + envId + ", vnfWorkloadContext=" + vnfWorkloadContext + ", tenant=" + tenant + "]"; - } + } } diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/DistributionStatusEvent.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/DistributionStatusEvent.java index dd429c4e21..369fd555ca 100644 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/DistributionStatusEvent.java +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/DistributionStatusEvent.java @@ -20,251 +20,206 @@ package org.openecomp.sdc.be.resources.data.auditing; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.Map; -import java.util.TimeZone; -import java.util.UUID; - -import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData; -import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum; - import com.datastax.driver.core.utils.UUIDs; import com.datastax.driver.mapping.annotations.ClusteringColumn; import com.datastax.driver.mapping.annotations.Column; import com.datastax.driver.mapping.annotations.PartitionKey; import com.datastax.driver.mapping.annotations.Table; +import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData; +import org.openecomp.sdc.be.resources.data.auditing.model.DistributionData; +import org.openecomp.sdc.common.datastructure.AuditingFieldsKey; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.TimeZone; +import java.util.UUID; @Table(keyspace = AuditingTypesConstants.AUDIT_KEYSPACE, name = AuditingTypesConstants.DISTRIBUTION_STATUS_EVENT_TYPE) public class DistributionStatusEvent extends AuditingGenericEvent { - private static String DISTRIBUTION_STATUS_NOTIFICATION_EVENT_TEMPLATE = "action=\"%s\" timestamp=\"%s\" " - + "did=\"%s\" consumerId=\"%s\" topicName=\"%s\" resoureURL=\"%s\" statusTime=\"%s\" status=\"%s\" "; - - @PartitionKey - protected UUID timebaseduuid; - - @ClusteringColumn - protected Date timestamp1; - - @Column(name = "request_id") - protected String requestId; - - @Column(name = "service_instance_id") - protected String serviceInstanceId; - - @Column - protected String action; - @Column - protected String status; - - @Column(name = "description") - protected String desc; - - @Column - private String did; - - @Column(name = "consumer_id") - private String consumerId; - - @Column(name = "topic_name") - private String topicName; - - @Column(name = "resoure_url") - private String resoureURL; - - @Column(name = "status_time") - private String statusTime; - - public DistributionStatusEvent() { - super(); - timestamp1 = new Date(); - timebaseduuid = UUIDs.timeBased(); - - } - - public DistributionStatusEvent(Map<AuditingFieldsKeysEnum, Object> auditingFields) { - this(); - Object value; - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_REQUEST_ID); - if (value != null) { - setRequestId((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_SERVICE_INSTANCE_ID); - if (value != null) { - setServiceInstanceId((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_ACTION); - if (value != null) { - setAction((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_STATUS); - if (value != null) { - setStatus((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_DESC); - if (value != null) { - setDesc((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_ID); - if (value != null) { - setDid((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_CONSUMER_ID); - if (value != null) { - setConsumerId((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_TOPIC_NAME); - if (value != null) { - setTopicName((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_RESOURCE_URL); - if (value != null) { - setResoureURL((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_STATUS_TIME); - if (value != null) { - setStatusTime((String) value); - } - } - - public DistributionStatusEvent(String action, CommonAuditData commonAuditData, String did, String consumerId, String topicName, - String resourceURL, String statusTime) { - this(); - this.action = action; - this.requestId = commonAuditData.getRequestId(); - this.serviceInstanceId = commonAuditData.getServiceInstanceId(); - this.status = commonAuditData.getStatus(); - this.desc = commonAuditData.getDescription(); - this.did = did; - this.consumerId = consumerId; - this.topicName = topicName; - this.resoureURL = resourceURL; - this.statusTime = statusTime; - } - - @Override - public void fillFields() { - fields.put(AuditingFieldsKeysEnum.AUDIT_REQUEST_ID.getDisplayName(), getRequestId()); - - fields.put(AuditingFieldsKeysEnum.AUDIT_SERVICE_INSTANCE_ID.getDisplayName(), getServiceInstanceId()); - fields.put(AuditingFieldsKeysEnum.AUDIT_ACTION.getDisplayName(), getAction()); - fields.put(AuditingFieldsKeysEnum.AUDIT_STATUS.getDisplayName(), getStatus()); - fields.put(AuditingFieldsKeysEnum.AUDIT_DESC.getDisplayName(), getDesc()); - fields.put(AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_CONSUMER_ID.getDisplayName(), getConsumerId()); - - fields.put(AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_ID.getDisplayName(), getDid()); - fields.put(AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_STATUS_TIME.getDisplayName(), getStatusTime()); - fields.put(AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_TOPIC_NAME.getDisplayName(), getTopicName()); - fields.put(AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_RESOURCE_URL.getDisplayName(), getResoureURL()); - SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormatPattern); - simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); - fields.put(AuditingFieldsKeysEnum.AUDIT_TIMESTAMP.getDisplayName(), simpleDateFormat.format(timestamp1)); - - } - - public String getDid() { - return did; - } - - public void setDid(String did) { - this.did = did; - } - - public String getConsumerId() { - return consumerId; - } - - public void setConsumerId(String consumerId) { - this.consumerId = consumerId; - } - - public String getTopicName() { - return topicName; - } - - public void setTopicName(String topicName) { - this.topicName = topicName; - } - - public String getResoureURL() { - return resoureURL; - } - - public void setResoureURL(String resoureURL) { - this.resoureURL = resoureURL; - } - - 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 UUID getTimebaseduuid() { - return timebaseduuid; - } - - public void setTimebaseduuid(UUID timebaseduuid) { - this.timebaseduuid = timebaseduuid; - } - - public Date getTimestamp1() { - return timestamp1; - } - - public void setTimestamp1(Date timestamp) { - this.timestamp1 = timestamp; - } - - public String getStatusTime() { - return statusTime; - } - - public void setStatusTime(String statusTime) { - this.statusTime = statusTime; - } - - @Override - public String toString() { - return "DistributionStatusEvent [timebaseduuid=" + timebaseduuid + ", timestamp1=" + timestamp1 + ", requestId=" - + requestId + ", serviceInstanceId=" + serviceInstanceId + ", action=" + action + ", status=" + status - + ", desc=" + desc + ", did=" + did + ", consumerId=" + consumerId + ", topicName=" + topicName - + ", resoureURL=" + resoureURL + ", statusTime=" + statusTime + "]"; - } + @PartitionKey + protected UUID timebaseduuid; + + @ClusteringColumn + protected Date timestamp1; + + @Column(name = "request_id") + protected String requestId; + + @Column(name = "service_instance_id") + protected String serviceInstanceId; + + @Column + protected String action; + @Column + protected String status; + + @Column(name = "description") + protected String desc; + + @Column + private String did; + + @Column(name = "consumer_id") + private String consumerId; + + @Column(name = "topic_name") + private String topicName; + + @Column(name = "resoure_url") + private String resoureURL; + + @Column(name = "status_time") + private String statusTime; + + //Required to be public as it is used by Cassandra driver on get operation + public DistributionStatusEvent() { + timestamp1 = new Date(); + timebaseduuid = UUIDs.timeBased(); + + } + + public DistributionStatusEvent(String action, CommonAuditData commonAuditData, DistributionData distributionData, + String did, String topicName, String statusTime) { + this(); + this.action = action; + this.requestId = commonAuditData.getRequestId(); + this.serviceInstanceId = commonAuditData.getServiceInstanceId(); + this.status = commonAuditData.getStatus(); + this.desc = commonAuditData.getDescription(); + this.did = did; + this.consumerId = distributionData.getConsumerId(); + this.topicName = topicName; + this.resoureURL = distributionData.getResourceUrl(); + this.statusTime = statusTime; + } + + public void setTimestamp1(String timestamp) { + this.timestamp1 = parseDateFromString(timestamp); + } + + @Override + public void fillFields() { + fields.put(AuditingFieldsKey.AUDIT_REQUEST_ID.getDisplayName(), getRequestId()); + + fields.put(AuditingFieldsKey.AUDIT_SERVICE_INSTANCE_ID.getDisplayName(), getServiceInstanceId()); + fields.put(AuditingFieldsKey.AUDIT_ACTION.getDisplayName(), getAction()); + fields.put(AuditingFieldsKey.AUDIT_STATUS.getDisplayName(), getStatus()); + fields.put(AuditingFieldsKey.AUDIT_DESC.getDisplayName(), getDesc()); + fields.put(AuditingFieldsKey.AUDIT_DISTRIBUTION_CONSUMER_ID.getDisplayName(), getConsumerId()); + + fields.put(AuditingFieldsKey.AUDIT_DISTRIBUTION_ID.getDisplayName(), getDid()); + fields.put(AuditingFieldsKey.AUDIT_DISTRIBUTION_STATUS_TIME.getDisplayName(), getStatusTime()); + fields.put(AuditingFieldsKey.AUDIT_DISTRIBUTION_TOPIC_NAME.getDisplayName(), getTopicName()); + fields.put(AuditingFieldsKey.AUDIT_DISTRIBUTION_RESOURCE_URL.getDisplayName(), getResoureURL()); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormatPattern); + simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); + fields.put(AuditingFieldsKey.AUDIT_TIMESTAMP.getDisplayName(), simpleDateFormat.format(timestamp1)); + + } + + public String getDid() { + return did; + } + + public void setDid(String did) { + this.did = did; + } + + public String getConsumerId() { + return consumerId; + } + + public void setConsumerId(String consumerId) { + this.consumerId = consumerId; + } + + public String getTopicName() { + return topicName; + } + + public void setTopicName(String topicName) { + this.topicName = topicName; + } + + public String getResoureURL() { + return resoureURL; + } + + public void setResoureURL(String resoureURL) { + this.resoureURL = resoureURL; + } + + 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 UUID getTimebaseduuid() { + return timebaseduuid; + } + + public void setTimebaseduuid(UUID timebaseduuid) { + this.timebaseduuid = timebaseduuid; + } + + public Date getTimestamp1() { + return timestamp1; + } + + public void setTimestamp1(Date timestamp) { + this.timestamp1 = timestamp; + } + + public String getStatusTime() { + return statusTime; + } + + public void setStatusTime(String statusTime) { + this.statusTime = statusTime; + } + + @Override + public String toString() { + return "DistributionStatusEvent [timebaseduuid=" + timebaseduuid + ", timestamp1=" + timestamp1 + ", requestId=" + + requestId + ", serviceInstanceId=" + serviceInstanceId + ", action=" + action + ", status=" + status + + ", desc=" + desc + ", did=" + did + ", consumerId=" + consumerId + ", topicName=" + topicName + + ", resoureURL=" + resoureURL + ", statusTime=" + statusTime + "]"; + } } diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/EcompOperationalEnvironmentEvent.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/EcompOperationalEnvironmentEvent.java index 854a7aca48..d78f0e0e5b 100644 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/EcompOperationalEnvironmentEvent.java +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/EcompOperationalEnvironmentEvent.java @@ -1,16 +1,16 @@ package org.openecomp.sdc.be.resources.data.auditing; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.Map; -import java.util.TimeZone; - -import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum; - import com.datastax.driver.mapping.annotations.ClusteringColumn; import com.datastax.driver.mapping.annotations.Column; import com.datastax.driver.mapping.annotations.PartitionKey; import com.datastax.driver.mapping.annotations.Table; +import org.openecomp.sdc.common.datastructure.AuditingFieldsKey; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.TimeZone; + +//import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum; @Table(keyspace = AuditingTypesConstants.AUDIT_KEYSPACE, name = AuditingTypesConstants.ECOMP_OPERATIONAL_ENV_EVENT_TYPE) public class EcompOperationalEnvironmentEvent extends AuditingGenericEvent { @@ -37,41 +37,11 @@ public class EcompOperationalEnvironmentEvent extends AuditingGenericEvent { protected String tenantContext; + //Required to be public as it is used by Cassandra driver on get operation public EcompOperationalEnvironmentEvent() { - super(); timestamp1 = new Date(); } - public EcompOperationalEnvironmentEvent(Map<AuditingFieldsKeysEnum, Object> auditingFields) { - this(); - Object value; - - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_ACTION); - if (value != null) { - setAction((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_OPERATIONAL_ENVIRONMENT_ID); - if (value != null) { - setOperationalEnvironmentId((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_OPERATIONAL_ENVIRONMENT_NAME); - if (value != null) { - setOperationalEnvironmentName((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_OPERATIONAL_ENVIRONMENT_TYPE); - if (value != null) { - setOperational_environment_type((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_OPERATIONAL_ENVIRONMENT_ACTION); - if (value != null) { - setOperationalEnvironmentAction((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_TENANT_CONTEXT); - if (value != null) { - setTenantContext((String) value); - } - } - public EcompOperationalEnvironmentEvent(String action, String operationalEnvironmentId, String operationalEnvironmentName, String operationalEnvironmentType, String operationalEnvironmentAction, String tenantContext) { this(); @@ -143,15 +113,15 @@ public class EcompOperationalEnvironmentEvent extends AuditingGenericEvent { @Override public void fillFields() { - fields.put(AuditingFieldsKeysEnum.AUDIT_ACTION.getDisplayName(), getAction()); - fields.put(AuditingFieldsKeysEnum.AUDIT_OPERATIONAL_ENVIRONMENT_ID.getDisplayName(), getOperationalEnvironmentId()); - fields.put(AuditingFieldsKeysEnum.AUDIT_OPERATIONAL_ENVIRONMENT_NAME.getDisplayName(), getOperationalEnvironmentName()); - fields.put(AuditingFieldsKeysEnum.AUDIT_OPERATIONAL_ENVIRONMENT_TYPE.getDisplayName(), getOperationalEnvironmentType()); - fields.put(AuditingFieldsKeysEnum.AUDIT_OPERATIONAL_ENVIRONMENT_ACTION.getDisplayName(), getOperationalEnvironmentAction()); - fields.put(AuditingFieldsKeysEnum.AUDIT_TENANT_CONTEXT.getDisplayName(), getTenantContext()); + fields.put(AuditingFieldsKey.AUDIT_ACTION.getDisplayName(), getAction()); + fields.put(AuditingFieldsKey.AUDIT_OPERATIONAL_ENVIRONMENT_ID.getDisplayName(), getOperationalEnvironmentId()); + fields.put(AuditingFieldsKey.AUDIT_OPERATIONAL_ENVIRONMENT_NAME.getDisplayName(), getOperationalEnvironmentName()); + fields.put(AuditingFieldsKey.AUDIT_OPERATIONAL_ENVIRONMENT_TYPE.getDisplayName(), getOperationalEnvironmentType()); + fields.put(AuditingFieldsKey.AUDIT_OPERATIONAL_ENVIRONMENT_ACTION.getDisplayName(), getOperationalEnvironmentAction()); + fields.put(AuditingFieldsKey.AUDIT_TENANT_CONTEXT.getDisplayName(), getTenantContext()); SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormatPattern); simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); - fields.put(AuditingFieldsKeysEnum.AUDIT_TIMESTAMP.getDisplayName(), simpleDateFormat.format(timestamp1)); + fields.put(AuditingFieldsKey.AUDIT_TIMESTAMP.getDisplayName(), simpleDateFormat.format(timestamp1)); } @Override diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/ExternalApiEvent.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/ExternalApiEvent.java index 6f4abb1480..d04a7dfa56 100644 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/ExternalApiEvent.java +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/ExternalApiEvent.java @@ -20,21 +20,21 @@ package org.openecomp.sdc.be.resources.data.auditing; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.Map; -import java.util.TimeZone; -import java.util.UUID; - -import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData; -import org.openecomp.sdc.be.resources.data.auditing.model.ResourceAuditData; -import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum; - import com.datastax.driver.core.utils.UUIDs; import com.datastax.driver.mapping.annotations.ClusteringColumn; import com.datastax.driver.mapping.annotations.Column; import com.datastax.driver.mapping.annotations.PartitionKey; import com.datastax.driver.mapping.annotations.Table; +import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData; +import org.openecomp.sdc.be.resources.data.auditing.model.DistributionData; +import org.openecomp.sdc.be.resources.data.auditing.model.ResourceCommonInfo; +import org.openecomp.sdc.be.resources.data.auditing.model.ResourceVersionInfo; +import org.openecomp.sdc.common.datastructure.AuditingFieldsKey; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.TimeZone; +import java.util.UUID; /** * This class Represents the Audit for External API @@ -98,103 +98,24 @@ public class ExternalApiEvent extends AuditingGenericEvent { @Column(name = "artifact_data") private String artifactData; + //Required to be public as it is used by Cassandra driver on get operation public ExternalApiEvent() { - super(); timestamp1 = new Date(); timebaseduuid = UUIDs.timeBased(); } - public ExternalApiEvent(Map<AuditingFieldsKeysEnum, Object> auditingFields) { - this(); - Object value; - - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_ACTION); - if (value != null) { - setAction((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_STATUS); - if (value != null) { - setStatus((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_DESC); - if (value != null) { - setDesc((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_CONSUMER_ID); - if (value != null) { - setConsumerId((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_RESOURCE_URL); - if (value != null) { - setResourceURL((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME); - if (value != null) { - setResourceName((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_RESOURCE_TYPE); - if (value != null) { - setResourceType((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_SERVICE_INSTANCE_ID); - if (value != null) { - setServiceInstanceId((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_INVARIANT_UUID); - if (value != null) { - setInvariantUuid((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_MODIFIER_UID); - if (value != null) { - setModifier((String) value); - } - - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_RESOURCE_PREV_VERSION); - if (value != null) { - setPrevVersion((String) value); - } - - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_RESOURCE_CURR_VERSION); - if (value != null) { - setCurrVersion((String) value); - } - - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_RESOURCE_PREV_STATE); - if (value != null) { - setPrevState((String) value); - } - - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_RESOURCE_CURR_STATE); - if (value != null) { - setCurrState((String) value); - } - - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_PREV_ARTIFACT_UUID); - if (value != null) { - setPrevArtifactUuid((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_CURR_ARTIFACT_UUID); - if (value != null) { - setCurrArtifactUuid((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_ARTIFACT_DATA); - if (value != null) { - setArtifactData((String) value); - } - } - - public ExternalApiEvent(String action, CommonAuditData commonAuditData, String resourceType, String resourceName, - String distConsumerId, String distResourceUrl, ResourceAuditData prevParams, ResourceAuditData currParams, + public ExternalApiEvent(String action, CommonAuditData commonAuditData, ResourceCommonInfo resourceCommonInfo, + DistributionData distributionData, ResourceVersionInfo prevParams, ResourceVersionInfo currParams, String modifier, String invariantUuid, String artifactData) { this(); this.action = action; this.status = commonAuditData.getStatus(); this.desc = commonAuditData.getDescription(); this.requestId = commonAuditData.getRequestId(); - this.consumerId = distConsumerId; - this.resourceURL = distResourceUrl; - this.resourceName = resourceName; - this.resourceType = resourceType; + this.consumerId = distributionData.getConsumerId(); + this.resourceURL = distributionData.getResourceUrl(); + this.resourceName = resourceCommonInfo.getResourceName(); + this.resourceType = resourceCommonInfo.getResourceType(); this.serviceInstanceId = commonAuditData.getServiceInstanceId(); this.invariantUuid = invariantUuid; this.modifier = modifier; @@ -209,28 +130,28 @@ public class ExternalApiEvent extends AuditingGenericEvent { @Override public void fillFields() { - fields.put(AuditingFieldsKeysEnum.AUDIT_SERVICE_INSTANCE_ID.getDisplayName(), getServiceInstanceId()); - fields.put(AuditingFieldsKeysEnum.AUDIT_INVARIANT_UUID.getDisplayName(), getInvariantUuid()); - fields.put(AuditingFieldsKeysEnum.AUDIT_ACTION.getDisplayName(), getAction()); - fields.put(AuditingFieldsKeysEnum.AUDIT_STATUS.getDisplayName(), getStatus()); - fields.put(AuditingFieldsKeysEnum.AUDIT_DESC.getDisplayName(), getDesc()); + fields.put(AuditingFieldsKey.AUDIT_SERVICE_INSTANCE_ID.getDisplayName(), getServiceInstanceId()); + fields.put(AuditingFieldsKey.AUDIT_INVARIANT_UUID.getDisplayName(), getInvariantUuid()); + fields.put(AuditingFieldsKey.AUDIT_ACTION.getDisplayName(), getAction()); + fields.put(AuditingFieldsKey.AUDIT_STATUS.getDisplayName(), getStatus()); + fields.put(AuditingFieldsKey.AUDIT_DESC.getDisplayName(), getDesc()); SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormatPattern); simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); - fields.put(AuditingFieldsKeysEnum.AUDIT_TIMESTAMP.getDisplayName(), simpleDateFormat.format(timestamp1)); - fields.put(AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_CONSUMER_ID.getDisplayName(), getConsumerId()); - fields.put(AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_RESOURCE_URL.getDisplayName(), getResourceURL()); - fields.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME.getDisplayName(), getResourceName()); - fields.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_TYPE.getDisplayName(), getResourceType()); - fields.put(AuditingFieldsKeysEnum.AUDIT_MODIFIER_UID.getDisplayName(), getModifier()); - - fields.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_PREV_VERSION.getDisplayName(), getPrevVersion()); - fields.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_CURR_VERSION.getDisplayName(), getCurrVersion()); - fields.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_PREV_STATE.getDisplayName(), getPrevState()); - fields.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_CURR_STATE.getDisplayName(), getCurrState()); - - fields.put(AuditingFieldsKeysEnum.AUDIT_PREV_ARTIFACT_UUID.getDisplayName(), getPrevArtifactUuid()); - fields.put(AuditingFieldsKeysEnum.AUDIT_CURR_ARTIFACT_UUID.getDisplayName(), getCurrArtifactUuid()); - fields.put(AuditingFieldsKeysEnum.AUDIT_ARTIFACT_DATA.getDisplayName(), getArtifactData()); + fields.put(AuditingFieldsKey.AUDIT_TIMESTAMP.getDisplayName(), simpleDateFormat.format(timestamp1)); + fields.put(AuditingFieldsKey.AUDIT_DISTRIBUTION_CONSUMER_ID.getDisplayName(), getConsumerId()); + fields.put(AuditingFieldsKey.AUDIT_DISTRIBUTION_RESOURCE_URL.getDisplayName(), getResourceURL()); + fields.put(AuditingFieldsKey.AUDIT_RESOURCE_NAME.getDisplayName(), getResourceName()); + fields.put(AuditingFieldsKey.AUDIT_RESOURCE_TYPE.getDisplayName(), getResourceType()); + fields.put(AuditingFieldsKey.AUDIT_MODIFIER_UID.getDisplayName(), getModifier()); + + fields.put(AuditingFieldsKey.AUDIT_RESOURCE_PREV_VERSION.getDisplayName(), getPrevVersion()); + fields.put(AuditingFieldsKey.AUDIT_RESOURCE_CURR_VERSION.getDisplayName(), getCurrVersion()); + fields.put(AuditingFieldsKey.AUDIT_RESOURCE_PREV_STATE.getDisplayName(), getPrevState()); + fields.put(AuditingFieldsKey.AUDIT_RESOURCE_CURR_STATE.getDisplayName(), getCurrState()); + + fields.put(AuditingFieldsKey.AUDIT_PREV_ARTIFACT_UUID.getDisplayName(), getPrevArtifactUuid()); + fields.put(AuditingFieldsKey.AUDIT_CURR_ARTIFACT_UUID.getDisplayName(), getCurrArtifactUuid()); + fields.put(AuditingFieldsKey.AUDIT_ARTIFACT_DATA.getDisplayName(), getArtifactData()); } public UUID getTimebaseduuid() { diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/GetCategoryHierarchyEvent.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/GetCategoryHierarchyEvent.java index 09f45c6934..8037a090ba 100644 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/GetCategoryHierarchyEvent.java +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/GetCategoryHierarchyEvent.java @@ -20,20 +20,18 @@ package org.openecomp.sdc.be.resources.data.auditing; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.Map; -import java.util.TimeZone; -import java.util.UUID; - -import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData; -import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum; - import com.datastax.driver.core.utils.UUIDs; import com.datastax.driver.mapping.annotations.ClusteringColumn; import com.datastax.driver.mapping.annotations.Column; import com.datastax.driver.mapping.annotations.PartitionKey; import com.datastax.driver.mapping.annotations.Table; +import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData; +import org.openecomp.sdc.common.datastructure.AuditingFieldsKey; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.TimeZone; +import java.util.UUID; @Table(keyspace = AuditingTypesConstants.AUDIT_KEYSPACE, name = AuditingTypesConstants.GET_CATEGORY_HIERARCHY_EVENT_TYPE) public class GetCategoryHierarchyEvent extends AuditingGenericEvent { @@ -60,41 +58,12 @@ public class GetCategoryHierarchyEvent extends AuditingGenericEvent { @Column private String details; + //Required to be public as it is used by Cassandra driver on get operation public GetCategoryHierarchyEvent() { - super(); timestamp1 = new Date(); timebaseduuid = UUIDs.timeBased(); } - public GetCategoryHierarchyEvent(Map<AuditingFieldsKeysEnum, Object> auditingFields) { - this(); - Object value; - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_REQUEST_ID); - if (value != null) { - setRequestId((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_ACTION); - if (value != null) { - setAction((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_STATUS); - if (value != null) { - setStatus((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_DESC); - if (value != null) { - setDesc((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_MODIFIER_UID); - if (value != null) { - setModifier((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_DETAILS); - if (value != null) { - setDetails((String) value); - } - } - public GetCategoryHierarchyEvent(String action, CommonAuditData commonAuditData, String modifier, String details) { this(); this.action = action; @@ -105,18 +74,22 @@ public class GetCategoryHierarchyEvent extends AuditingGenericEvent { this.details = details; } - @Override + public void setTimestamp1(String timestamp) { + this.timestamp1 = parseDateFromString(timestamp); + } + + @Override public void fillFields() { - fields.put(AuditingFieldsKeysEnum.AUDIT_REQUEST_ID.getDisplayName(), getRequestId()); + fields.put(AuditingFieldsKey.AUDIT_REQUEST_ID.getDisplayName(), getRequestId()); - fields.put(AuditingFieldsKeysEnum.AUDIT_SERVICE_INSTANCE_ID.getDisplayName(), getServiceInstanceId()); - fields.put(AuditingFieldsKeysEnum.AUDIT_ACTION.getDisplayName(), getAction()); - fields.put(AuditingFieldsKeysEnum.AUDIT_STATUS.getDisplayName(), getStatus()); - fields.put(AuditingFieldsKeysEnum.AUDIT_DESC.getDisplayName(), getDesc()); - fields.put(AuditingFieldsKeysEnum.AUDIT_DETAILS.getDisplayName(), getDetails()); + fields.put(AuditingFieldsKey.AUDIT_SERVICE_INSTANCE_ID.getDisplayName(), getServiceInstanceId()); + fields.put(AuditingFieldsKey.AUDIT_ACTION.getDisplayName(), getAction()); + fields.put(AuditingFieldsKey.AUDIT_STATUS.getDisplayName(), getStatus()); + fields.put(AuditingFieldsKey.AUDIT_DESC.getDisplayName(), getDesc()); + fields.put(AuditingFieldsKey.AUDIT_DETAILS.getDisplayName(), getDetails()); SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormatPattern); simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); - fields.put(AuditingFieldsKeysEnum.AUDIT_TIMESTAMP.getDisplayName(), simpleDateFormat.format(timestamp1)); + fields.put(AuditingFieldsKey.AUDIT_TIMESTAMP.getDisplayName(), simpleDateFormat.format(timestamp1)); } public UUID getTimebaseduuid() { diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/GetUsersListEvent.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/GetUsersListEvent.java index ef5abcf9fe..441cbc42f0 100644 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/GetUsersListEvent.java +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/GetUsersListEvent.java @@ -20,20 +20,18 @@ package org.openecomp.sdc.be.resources.data.auditing; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.Map; -import java.util.TimeZone; -import java.util.UUID; - -import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData; -import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum; - import com.datastax.driver.core.utils.UUIDs; import com.datastax.driver.mapping.annotations.ClusteringColumn; import com.datastax.driver.mapping.annotations.Column; import com.datastax.driver.mapping.annotations.PartitionKey; import com.datastax.driver.mapping.annotations.Table; +import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData; +import org.openecomp.sdc.common.datastructure.AuditingFieldsKey; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.TimeZone; +import java.util.UUID; @Table(keyspace = AuditingTypesConstants.AUDIT_KEYSPACE, name = AuditingTypesConstants.GET_USERS_LIST_EVENT_TYPE) public class GetUsersListEvent extends AuditingGenericEvent { @@ -59,46 +57,12 @@ public class GetUsersListEvent extends AuditingGenericEvent { @Column private String details; + //Required to be public as it is used by Cassandra driver on get operation public GetUsersListEvent() { - super(); timestamp1 = new Date(); timebaseduuid = UUIDs.timeBased(); } - public GetUsersListEvent(Map<AuditingFieldsKeysEnum, Object> auditingFields) { - this(); - Object value; - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_REQUEST_ID); - if (value != null) { - setRequestId((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_ACTION); - if (value != null) { - setAction((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_STATUS); - if (value != null) { - setStatus((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_DESC); - if (value != null) { - setDesc((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_MODIFIER_UID); - if (value != null) { - setModifier((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_USER_DETAILS); - if (value != null) { - setDetails((String) value); - } else { - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_DETAILS); - if (value != null) { - setDetails((String) value); - } - } - } - public GetUsersListEvent(String action, CommonAuditData commonAuditData, String modifier, String userDetails) { this(); this.action = action; @@ -109,19 +73,22 @@ public class GetUsersListEvent extends AuditingGenericEvent { this.details = userDetails; } + public void setTimestamp1(String timestamp) { + this.timestamp1 = parseDateFromString(timestamp); + } @Override public void fillFields() { - fields.put(AuditingFieldsKeysEnum.AUDIT_REQUEST_ID.getDisplayName(), getRequestId()); + fields.put(AuditingFieldsKey.AUDIT_REQUEST_ID.getDisplayName(), getRequestId()); - fields.put(AuditingFieldsKeysEnum.AUDIT_ACTION.getDisplayName(), getAction()); - fields.put(AuditingFieldsKeysEnum.AUDIT_STATUS.getDisplayName(), getStatus()); - fields.put(AuditingFieldsKeysEnum.AUDIT_DESC.getDisplayName(), getDesc()); - fields.put(AuditingFieldsKeysEnum.AUDIT_USER_DETAILS.getDisplayName(), getDetails()); - fields.put(AuditingFieldsKeysEnum.AUDIT_MODIFIER_UID.getDisplayName(), getModifier()); + fields.put(AuditingFieldsKey.AUDIT_ACTION.getDisplayName(), getAction()); + fields.put(AuditingFieldsKey.AUDIT_STATUS.getDisplayName(), getStatus()); + fields.put(AuditingFieldsKey.AUDIT_DESC.getDisplayName(), getDesc()); + fields.put(AuditingFieldsKey.AUDIT_USER_DETAILS.getDisplayName(), getDetails()); + fields.put(AuditingFieldsKey.AUDIT_MODIFIER_UID.getDisplayName(), getModifier()); SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormatPattern); simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); - fields.put(AuditingFieldsKeysEnum.AUDIT_TIMESTAMP.getDisplayName(), simpleDateFormat.format(timestamp1)); + fields.put(AuditingFieldsKey.AUDIT_TIMESTAMP.getDisplayName(), simpleDateFormat.format(timestamp1)); } public UUID getTimebaseduuid() { diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/ResourceAdminEvent.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/ResourceAdminEvent.java index f07cb213a0..82e1fca9ca 100644 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/ResourceAdminEvent.java +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/ResourceAdminEvent.java @@ -20,447 +20,351 @@ package org.openecomp.sdc.be.resources.data.auditing; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.Map; -import java.util.TimeZone; -import java.util.UUID; - -import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData; -import org.openecomp.sdc.be.resources.data.auditing.model.ResourceAuditData; -import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum; - import com.datastax.driver.core.utils.UUIDs; import com.datastax.driver.mapping.annotations.ClusteringColumn; import com.datastax.driver.mapping.annotations.Column; import com.datastax.driver.mapping.annotations.PartitionKey; import com.datastax.driver.mapping.annotations.Table; +import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData; +import org.openecomp.sdc.be.resources.data.auditing.model.ResourceCommonInfo; +import org.openecomp.sdc.be.resources.data.auditing.model.ResourceVersionInfo; +import org.openecomp.sdc.common.datastructure.AuditingFieldsKey; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.TimeZone; +import java.util.UUID; @Table(keyspace = AuditingTypesConstants.AUDIT_KEYSPACE, name = AuditingTypesConstants.RESOURCE_ADMIN_EVENT_TYPE) public class ResourceAdminEvent extends AuditingGenericEvent { - private static String RESOURCE_ADMIN_EVENT_TEMPLATE = "action=\"%s\" timestamp=\"%s\" " - + "resourceName=\"%s\" resourceType=\"%s\" prevVersion=\"%s\" currVersion=\"%s\" " - + "modifierName=\"%s\" modifierUid=\"%s\" " + "prevState=\"%s\" currState=\"%s\" " - + "checkinComment=\"%s\" prevArtifactUuid=\"%s\" currArtifactUuid=\"%s\" " + "artifactData=\"%s\" " - + "status=\"%s\" desc=\"%s\""; + @PartitionKey + protected UUID timebaseduuid; + + @ClusteringColumn + protected Date timestamp1; + + @Column + protected String action; - @PartitionKey - protected UUID timebaseduuid; + @Column(name = "resource_type") + protected String resourceType; - @ClusteringColumn - protected Date timestamp1; - - @Column - protected String action; - - @Column(name = "resource_type") - protected String resourceType; - - @Column(name = "prev_version") - protected String prevVersion; - - @Column(name = "prev_state") - protected String prevState; - - @Column(name = "curr_state") - protected String currState; - - @Column(name = "resource_name") - private String resourceName; - - @Column(name = "curr_version") - private String currVersion; - - @Column(name = "request_id") - protected String requestId; - - @Column(name = "service_instance_id") - protected String serviceInstanceId; - - @Column - protected String status; - - @Column(name = "description") - protected String desc; - - @Column - protected String modifier; - - @Column(name = "prev_artifact_UUID") - protected String prevArtifactUUID; - - @Column(name = "curr_artifact_UUID") - protected String currArtifactUUID; - - @Column(name = "artifact_data") - protected String artifactData; - - @Column - protected String did; - - @Column(name = "dprev_status") - protected String dprevStatus; - - @Column(name = "dcurr_status") - protected String dcurrStatus; - - @Column(name = "tosca_node_type") - protected String toscaNodeType; - - @Column - protected String comment; - - @Column(name = "invariant_UUID") - protected String invariantUUID; - - public ResourceAdminEvent() { - super(); - timestamp1 = new Date(); - timebaseduuid = UUIDs.timeBased(); - } - - public ResourceAdminEvent(String action, CommonAuditData commonAuditData, ResourceAuditData prevParams, ResourceAuditData currParams, String resourceType, - String resourceName, String invariantUuid, String modifier, String artifactData, String comment, String did, String toscaNodeType) { - this(); - this.action = action; - this.requestId = commonAuditData.getRequestId(); - this.desc = commonAuditData.getDescription(); - this.status = commonAuditData.getStatus(); - this.serviceInstanceId = commonAuditData.getServiceInstanceId(); - this.currState = currParams.getState(); - this.currVersion = currParams.getVersion(); - this.currArtifactUUID = currParams.getArtifactUuid(); - this.prevState = prevParams.getState(); - this.prevVersion = prevParams.getVersion(); - this.prevArtifactUUID = prevParams.getArtifactUuid(); - this.resourceName = resourceName; - this.resourceType = resourceType; - this.comment = comment; - this.dcurrStatus = currParams.getDistributionStatus(); - this.dprevStatus = prevParams.getDistributionStatus(); - this.artifactData = artifactData; - this.modifier = modifier; - this.invariantUUID = invariantUuid; - this.did = did; - this.toscaNodeType = toscaNodeType; - } - - public ResourceAdminEvent(Map<AuditingFieldsKeysEnum, Object> auditingFields) { - this(); - Object value; - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_REQUEST_ID); - if (value != null) { - setRequestId((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_SERVICE_INSTANCE_ID); - if (value != null) { - setServiceInstanceId((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_RESOURCE_TYPE); - if (value != null) { - setResourceType((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_RESOURCE_PREV_VERSION); - if (value != null) { - setPrevVersion((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_RESOURCE_PREV_STATE); - if (value != null) { - setPrevState((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME); - if (value != null) { - setResourceName((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_RESOURCE_CURR_VERSION); - if (value != null) { - setCurrVersion((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_RESOURCE_CURR_STATE); - if (value != null) { - setCurrState((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_STATUS); - if (value != null) { - setStatus((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_DESC); - if (value != null) { - setDesc((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_ACTION); - if (value != null) { - setAction((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_MODIFIER_UID); - if (value != null) { - setModifier((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_PREV_ARTIFACT_UUID); - if (value != null) { - setPrevArtifactUUID((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_CURR_ARTIFACT_UUID); - if (value != null) { - setCurrArtifactUUID((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_ARTIFACT_DATA); - if (value != null) { - setArtifactData((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_RESOURCE_COMMENT); - if (value != null) { - setComment((String) value); - } - - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_RESOURCE_DCURR_STATUS); - if (value != null) { - setDcurrStatus((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_RESOURCE_DPREV_STATUS); - if (value != null) { - setDprevStatus((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_ID); - if (value != null) { - setDid((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_RESOURCE_TOSCA_NODE_TYPE); - if (value != null) { - setToscaNodeType((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_INVARIANT_UUID); - if (value != null) { - setInvariantUUID((String) value); - } - - } - - - @Override - public void fillFields() { - fields.put(AuditingFieldsKeysEnum.AUDIT_REQUEST_ID.getDisplayName(), getRequestId()); - - fields.put(AuditingFieldsKeysEnum.AUDIT_SERVICE_INSTANCE_ID.getDisplayName(), getServiceInstanceId()); - fields.put(AuditingFieldsKeysEnum.AUDIT_ACTION.getDisplayName(), getAction()); - fields.put(AuditingFieldsKeysEnum.AUDIT_STATUS.getDisplayName(), getStatus()); - fields.put(AuditingFieldsKeysEnum.AUDIT_DESC.getDisplayName(), getDesc()); - fields.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_TYPE.getDisplayName(), getResourceType()); - fields.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_PREV_VERSION.getDisplayName(), getPrevVersion()); - fields.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_PREV_STATE.getDisplayName(), getPrevState()); - fields.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME.getDisplayName(), getResourceName()); - fields.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_CURR_VERSION.getDisplayName(), getCurrVersion()); - fields.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_CURR_STATE.getDisplayName(), getCurrState()); - fields.put(AuditingFieldsKeysEnum.AUDIT_MODIFIER_UID.getDisplayName(), getModifier()); - fields.put(AuditingFieldsKeysEnum.AUDIT_PREV_ARTIFACT_UUID.getDisplayName(), getPrevArtifactUUID()); - fields.put(AuditingFieldsKeysEnum.AUDIT_CURR_ARTIFACT_UUID.getDisplayName(), getCurrArtifactUUID()); - fields.put(AuditingFieldsKeysEnum.AUDIT_ARTIFACT_DATA.getDisplayName(), getArtifactData()); - fields.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_COMMENT.getDisplayName(), getComment()); - fields.put(AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_ID.getDisplayName(), getDid()); - fields.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_DCURR_STATUS.getDisplayName(), getDcurrStatus()); - fields.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_DPREV_STATUS.getDisplayName(), getDprevStatus()); - fields.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_TOSCA_NODE_TYPE.getDisplayName(), getToscaNodeType()); - fields.put(AuditingFieldsKeysEnum.AUDIT_INVARIANT_UUID.getDisplayName(), getInvariantUUID()); - - SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormatPattern); - simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); - fields.put(AuditingFieldsKeysEnum.AUDIT_TIMESTAMP.getDisplayName(), simpleDateFormat.format(timestamp1)); - } - - public String getResourceName() { - return resourceName; - } - - public void setResourceName(String resourceName) { - this.resourceName = resourceName; - } - - public String getResourceType() { - return resourceType; - } - - public void setResourceType(String resourceType) { - this.resourceType = resourceType; - } - - public String getPrevVersion() { - return prevVersion; - } - - public void setPrevVersion(String prevVersion) { - this.prevVersion = prevVersion; - } - - public String getCurrVersion() { - return currVersion; - } - - public void setCurrVersion(String currVersion) { - this.currVersion = currVersion; - } - - public String getPrevState() { - return prevState; - } - - public void setPrevState(String prevState) { - this.prevState = prevState; - } - - public String getCurrState() { - return currState; - } - - public void setCurrState(String currState) { - this.currState = currState; - } - - public UUID getTimebaseduuid() { - return timebaseduuid; - } - - public void setTimebaseduuid(UUID timebaseduuid) { - this.timebaseduuid = timebaseduuid; - } - - public Date getTimestamp1() { - return timestamp1; - } - - public void setTimestamp1(Date timestamp1) { - this.timestamp1 = timestamp1; - } - - public String getAction() { - return action; - } - - public void setAction(String action) { - this.action = action; - } - - 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 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 String getModifier() { - return modifier; - } - - public void setModifier(String modifier) { - this.modifier = modifier; - } - - public String getPrevArtifactUUID() { - return prevArtifactUUID; - } - - public void setPrevArtifactUUID(String prevArtifactUUID) { - this.prevArtifactUUID = prevArtifactUUID; - } - - public String getCurrArtifactUUID() { - return currArtifactUUID; - } - - public void setCurrArtifactUUID(String currArtifactUUID) { - this.currArtifactUUID = currArtifactUUID; - } - - public String getArtifactData() { - return artifactData; - } - - public void setArtifactData(String artifactData) { - this.artifactData = artifactData; - } - - public String getDid() { - return did; - } - - public void setDid(String did) { - this.did = did; - } - - public String getDprevStatus() { - return dprevStatus; - } - - public void setDprevStatus(String dprevStatus) { - this.dprevStatus = dprevStatus; - } - - public String getDcurrStatus() { - return dcurrStatus; - } - - public void setDcurrStatus(String dcurrStatus) { - this.dcurrStatus = dcurrStatus; - } - - public String getToscaNodeType() { - return toscaNodeType; - } - - public void setToscaNodeType(String toscaNodeType) { - this.toscaNodeType = toscaNodeType; - } - - public String getComment() { - return comment; - } - - public void setComment(String comment) { - this.comment = comment; - } - - public String getInvariantUUID() { - return invariantUUID; - } - - public void setInvariantUUID(String invariantUUID) { - this.invariantUUID = invariantUUID; - } - - @Override - public String toString() { - return "ResourceAdminEvent [timebaseduuid=" + timebaseduuid + ", timestamp1=" + timestamp1 + ", action=" - + action + ", resourceType=" + resourceType + ", prevVersion=" + prevVersion + ", prevState=" - + prevState + ", currState=" + currState + ", resourceName=" + resourceName + ", currVersion=" - + currVersion + ", requestId=" + requestId + ", serviceInstanceId=" + serviceInstanceId + ", status=" - + status + ", desc=" + desc + ", modifier=" + modifier + ", prevArtifactUUID=" + prevArtifactUUID - + ", currArtifactUUID=" + currArtifactUUID + ", artifactData=" + artifactData + ", invariantUUID=" - + invariantUUID + "]"; - } + @Column(name = "prev_version") + protected String prevVersion; + + @Column(name = "prev_state") + protected String prevState; + + @Column(name = "curr_state") + protected String currState; + + @Column(name = "resource_name") + private String resourceName; + + @Column(name = "curr_version") + private String currVersion; + + @Column(name = "request_id") + protected String requestId; + + @Column(name = "service_instance_id") + protected String serviceInstanceId; + + @Column + protected String status; + + @Column(name = "description") + protected String desc; + + @Column + protected String modifier; + + @Column(name = "prev_artifact_UUID") + protected String prevArtifactUUID; + + @Column(name = "curr_artifact_UUID") + protected String currArtifactUUID; + + @Column(name = "artifact_data") + protected String artifactData; + + @Column + protected String did; + + @Column(name = "dprev_status") + protected String dprevStatus; + + @Column(name = "dcurr_status") + protected String dcurrStatus; + + @Column(name = "tosca_node_type") + protected String toscaNodeType; + + @Column + protected String comment; + + @Column(name = "invariant_UUID") + protected String invariantUUID; + + public ResourceAdminEvent() { + timestamp1 = new Date(); + timebaseduuid = UUIDs.timeBased(); + } + + public ResourceAdminEvent(String action, CommonAuditData commonAuditData, ResourceCommonInfo resourceCommonInfo, ResourceVersionInfo prevParams, ResourceVersionInfo currParams, + String invariantUuid, String modifier, String artifactData, String comment, String did, String toscaNodeType) { + this(); + this.action = action; + this.requestId = commonAuditData.getRequestId(); + this.desc = commonAuditData.getDescription(); + this.status = commonAuditData.getStatus(); + this.serviceInstanceId = commonAuditData.getServiceInstanceId(); + this.currState = currParams.getState(); + this.currVersion = currParams.getVersion(); + this.currArtifactUUID = currParams.getArtifactUuid(); + this.prevState = prevParams.getState(); + this.prevVersion = prevParams.getVersion(); + this.prevArtifactUUID = prevParams.getArtifactUuid(); + this.resourceName = resourceCommonInfo.getResourceName(); + this.resourceType = resourceCommonInfo.getResourceType(); + this.comment = comment; + this.dcurrStatus = currParams.getDistributionStatus(); + this.dprevStatus = prevParams.getDistributionStatus(); + this.artifactData = artifactData; + this.modifier = modifier; + this.invariantUUID = invariantUuid; + this.did = did; + this.toscaNodeType = toscaNodeType; + } + + public void setTimestamp1(String timestamp) { + this.timestamp1 = parseDateFromString(timestamp); + } + + @Override + public void fillFields() { + fields.put(AuditingFieldsKey.AUDIT_REQUEST_ID.getDisplayName(), getRequestId()); + + fields.put(AuditingFieldsKey.AUDIT_SERVICE_INSTANCE_ID.getDisplayName(), getServiceInstanceId()); + fields.put(AuditingFieldsKey.AUDIT_ACTION.getDisplayName(), getAction()); + fields.put(AuditingFieldsKey.AUDIT_STATUS.getDisplayName(), getStatus()); + fields.put(AuditingFieldsKey.AUDIT_DESC.getDisplayName(), getDesc()); + fields.put(AuditingFieldsKey.AUDIT_RESOURCE_TYPE.getDisplayName(), getResourceType()); + fields.put(AuditingFieldsKey.AUDIT_RESOURCE_PREV_VERSION.getDisplayName(), getPrevVersion()); + fields.put(AuditingFieldsKey.AUDIT_RESOURCE_PREV_STATE.getDisplayName(), getPrevState()); + fields.put(AuditingFieldsKey.AUDIT_RESOURCE_NAME.getDisplayName(), getResourceName()); + fields.put(AuditingFieldsKey.AUDIT_RESOURCE_CURR_VERSION.getDisplayName(), getCurrVersion()); + fields.put(AuditingFieldsKey.AUDIT_RESOURCE_CURR_STATE.getDisplayName(), getCurrState()); + fields.put(AuditingFieldsKey.AUDIT_MODIFIER_UID.getDisplayName(), getModifier()); + fields.put(AuditingFieldsKey.AUDIT_PREV_ARTIFACT_UUID.getDisplayName(), getPrevArtifactUUID()); + fields.put(AuditingFieldsKey.AUDIT_CURR_ARTIFACT_UUID.getDisplayName(), getCurrArtifactUUID()); + fields.put(AuditingFieldsKey.AUDIT_ARTIFACT_DATA.getDisplayName(), getArtifactData()); + fields.put(AuditingFieldsKey.AUDIT_RESOURCE_COMMENT.getDisplayName(), getComment()); + fields.put(AuditingFieldsKey.AUDIT_DISTRIBUTION_ID.getDisplayName(), getDid()); + fields.put(AuditingFieldsKey.AUDIT_RESOURCE_DCURR_STATUS.getDisplayName(), getDcurrStatus()); + fields.put(AuditingFieldsKey.AUDIT_RESOURCE_DPREV_STATUS.getDisplayName(), getDprevStatus()); + fields.put(AuditingFieldsKey.AUDIT_RESOURCE_TOSCA_NODE_TYPE.getDisplayName(), getToscaNodeType()); + fields.put(AuditingFieldsKey.AUDIT_INVARIANT_UUID.getDisplayName(), getInvariantUUID()); + + SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormatPattern); + simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); + fields.put(AuditingFieldsKey.AUDIT_TIMESTAMP.getDisplayName(), simpleDateFormat.format(timestamp1)); + } + + public String getResourceName() { + return resourceName; + } + + public void setResourceName(String resourceName) { + this.resourceName = resourceName; + } + + public String getResourceType() { + return resourceType; + } + + public void setResourceType(String resourceType) { + this.resourceType = resourceType; + } + + public String getPrevVersion() { + return prevVersion; + } + + public void setPrevVersion(String prevVersion) { + this.prevVersion = prevVersion; + } + + public String getCurrVersion() { + return currVersion; + } + + public void setCurrVersion(String currVersion) { + this.currVersion = currVersion; + } + + public String getPrevState() { + return prevState; + } + + public void setPrevState(String prevState) { + this.prevState = prevState; + } + + public String getCurrState() { + return currState; + } + + public void setCurrState(String currState) { + this.currState = currState; + } + + public UUID getTimebaseduuid() { + return timebaseduuid; + } + + public void setTimebaseduuid(UUID timebaseduuid) { + this.timebaseduuid = timebaseduuid; + } + + public Date getTimestamp1() { + return timestamp1; + } + + public void setTimestamp1(Date timestamp1) { + this.timestamp1 = timestamp1; + } + + public String getAction() { + return action; + } + + public void setAction(String action) { + this.action = action; + } + + 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 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 String getModifier() { + return modifier; + } + + public void setModifier(String modifier) { + this.modifier = modifier; + } + + public String getPrevArtifactUUID() { + return prevArtifactUUID; + } + + public void setPrevArtifactUUID(String prevArtifactUUID) { + this.prevArtifactUUID = prevArtifactUUID; + } + + public String getCurrArtifactUUID() { + return currArtifactUUID; + } + + public void setCurrArtifactUUID(String currArtifactUUID) { + this.currArtifactUUID = currArtifactUUID; + } + + public String getArtifactData() { + return artifactData; + } + + public void setArtifactData(String artifactData) { + this.artifactData = artifactData; + } + + public String getDid() { + return did; + } + + public void setDid(String did) { + this.did = did; + } + + public String getDprevStatus() { + return dprevStatus; + } + + public void setDprevStatus(String dprevStatus) { + this.dprevStatus = dprevStatus; + } + + public String getDcurrStatus() { + return dcurrStatus; + } + + public void setDcurrStatus(String dcurrStatus) { + this.dcurrStatus = dcurrStatus; + } + + public String getToscaNodeType() { + return toscaNodeType; + } + + public void setToscaNodeType(String toscaNodeType) { + this.toscaNodeType = toscaNodeType; + } + + public String getComment() { + return comment; + } + + public void setComment(String comment) { + this.comment = comment; + } + + public String getInvariantUUID() { + return invariantUUID; + } + + public void setInvariantUUID(String invariantUUID) { + this.invariantUUID = invariantUUID; + } + + @Override + public String toString() { + return "ResourceAdminEvent [timebaseduuid=" + timebaseduuid + ", timestamp1=" + timestamp1 + ", action=" + + action + ", resourceType=" + resourceType + ", prevVersion=" + prevVersion + ", prevState=" + + prevState + ", currState=" + currState + ", resourceName=" + resourceName + ", currVersion=" + + currVersion + ", requestId=" + requestId + ", serviceInstanceId=" + serviceInstanceId + ", status=" + + status + ", desc=" + desc + ", modifier=" + modifier + ", prevArtifactUUID=" + prevArtifactUUID + + ", currArtifactUUID=" + currArtifactUUID + ", artifactData=" + artifactData + ", invariantUUID=" + + invariantUUID + "]"; + } } diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/UserAccessEvent.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/UserAccessEvent.java index 7ead342827..74c85f6ea9 100644 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/UserAccessEvent.java +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/UserAccessEvent.java @@ -20,180 +20,149 @@ package org.openecomp.sdc.be.resources.data.auditing; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.Map; -import java.util.TimeZone; -import java.util.UUID; - -import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData; -import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum; - import com.datastax.driver.core.utils.UUIDs; import com.datastax.driver.mapping.annotations.ClusteringColumn; import com.datastax.driver.mapping.annotations.Column; import com.datastax.driver.mapping.annotations.PartitionKey; import com.datastax.driver.mapping.annotations.Table; +import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData; +import org.openecomp.sdc.common.datastructure.AuditingFieldsKey; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.TimeZone; +import java.util.UUID; @Table(keyspace = AuditingTypesConstants.AUDIT_KEYSPACE, name = AuditingTypesConstants.USER_ACCESS_EVENT_TYPE) public class UserAccessEvent extends AuditingGenericEvent { - private static String USER_ACCESS_EVENT_TEMPLATE = "action=\"%s\" timestamp=\"%s\" " - + "userUid=\"%s\" userName=\"%s\" status=\"%s\" desc=\"%s\""; - - @PartitionKey - protected UUID timebaseduuid; - - @ClusteringColumn - protected Date timestamp1; - - @Column(name = "REQUEST_ID") - protected String requestId; - - @Column(name = "USER") - private String userUid; - - @Column - private String status; - - @Column(name = "DESCRIPTION") - private String desc; - - @Column - private String action; - - @Column(name = "service_instance_id") - private String serviceInstanceId; - - public UserAccessEvent() { - super(); - timestamp1 = new Date(); - timebaseduuid = UUIDs.timeBased(); - } - - public UserAccessEvent(Map<AuditingFieldsKeysEnum, Object> auditingFields) { - this(); - Object value; - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_REQUEST_ID); - if (value != null) { - setRequestId((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_USER_UID); - if (value != null) { - setUserUid((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_STATUS); - if (value != null) { - setStatus((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_DESC); - if (value != null) { - setDesc((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_ACTION); - if (value != null) { - setAction((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_SERVICE_INSTANCE_ID); - if (value != null) { - setServiceInstanceId((String) value); - } - - } - - public UserAccessEvent(String action, CommonAuditData commonAuditData, String user) { - this(); - this.action = action; - this.requestId = commonAuditData.getRequestId(); - this.userUid = user; - this.status = commonAuditData.getStatus(); - this.desc = commonAuditData.getDescription(); - this.serviceInstanceId = commonAuditData.getServiceInstanceId(); - } - - - @Override - public void fillFields() { - fields.put(AuditingFieldsKeysEnum.AUDIT_REQUEST_ID.getDisplayName(), getRequestId()); - - fields.put(AuditingFieldsKeysEnum.AUDIT_SERVICE_INSTANCE_ID.getDisplayName(), getServiceInstanceId()); - fields.put(AuditingFieldsKeysEnum.AUDIT_ACTION.getDisplayName(), getAction()); - fields.put(AuditingFieldsKeysEnum.AUDIT_STATUS.getDisplayName(), getStatus()); - fields.put(AuditingFieldsKeysEnum.AUDIT_DESC.getDisplayName(), getDesc()); - fields.put(AuditingFieldsKeysEnum.AUDIT_USER_UID.getDisplayName(), getUserUid()); - SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormatPattern); - simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); - fields.put(AuditingFieldsKeysEnum.AUDIT_TIMESTAMP.getDisplayName(), simpleDateFormat.format(timestamp1)); - } - - public String getUserUid() { - return userUid; - } - - public void setUserUid(String userUid) { - this.userUid = userUid; - } - - public UUID getTimebaseduuid() { - return timebaseduuid; - } - - public void setTimebaseduuid(UUID timebaseduuid) { - this.timebaseduuid = timebaseduuid; - } - - public String getRequestId() { - return requestId; - } - - public void setRequestId(String requestId) { - this.requestId = requestId; - } - - @Override - public String getServiceInstanceId() { return serviceInstanceId; } - - @Override - public void setServiceInstanceId(String serviceInstanceId) { - this.serviceInstanceId = serviceInstanceId; - } - - 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 String getAction() { - return action; - } - - public void setAction(String action) { - this.action = action; - } - - public Date getTimestamp1() { - return timestamp1; - } - - public void setTimestamp1(Date timestamp) { - this.timestamp1 = timestamp; - } - - @Override - public String toString() { - return "UserAccessEvent [timebaseduuid=" + timebaseduuid + ", timestamp1=" + timestamp1 + ", requestId=" - + requestId + ", userUid=" + userUid + ", status=" + status + ", desc=" + desc + ", action=" + action - + ", serviceInstanceId=" + serviceInstanceId + "]"; - } + + @PartitionKey + protected UUID timebaseduuid; + + @ClusteringColumn + protected Date timestamp1; + + @Column(name = "REQUEST_ID") + protected String requestId; + + @Column(name = "USER") + private String userUid; + + @Column + private String status; + + @Column(name = "DESCRIPTION") + private String desc; + + @Column + private String action; + + @Column(name = "service_instance_id") + private String serviceInstanceId; + + //Required to be public as it is used by Cassandra driver on get operation + public UserAccessEvent() { + timestamp1 = new Date(); + timebaseduuid = UUIDs.timeBased(); + } + + public UserAccessEvent(String action, CommonAuditData commonAuditData, String user) { + this(); + this.action = action; + this.requestId = commonAuditData.getRequestId(); + this.userUid = user; + this.status = commonAuditData.getStatus(); + this.desc = commonAuditData.getDescription(); + this.serviceInstanceId = commonAuditData.getServiceInstanceId(); + } + + public void setTimestamp1(String timestamp) { + this.timestamp1 = parseDateFromString(timestamp); + } + + @Override + public void fillFields() { + fields.put(AuditingFieldsKey.AUDIT_REQUEST_ID.getDisplayName(), getRequestId()); + + fields.put(AuditingFieldsKey.AUDIT_SERVICE_INSTANCE_ID.getDisplayName(), getServiceInstanceId()); + fields.put(AuditingFieldsKey.AUDIT_ACTION.getDisplayName(), getAction()); + fields.put(AuditingFieldsKey.AUDIT_STATUS.getDisplayName(), getStatus()); + fields.put(AuditingFieldsKey.AUDIT_DESC.getDisplayName(), getDesc()); + fields.put(AuditingFieldsKey.AUDIT_USER_UID.getDisplayName(), getUserUid()); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormatPattern); + simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); + fields.put(AuditingFieldsKey.AUDIT_TIMESTAMP.getDisplayName(), simpleDateFormat.format(timestamp1)); + } + + public String getUserUid() { + return userUid; + } + + public void setUserUid(String userUid) { + this.userUid = userUid; + } + + public UUID getTimebaseduuid() { + return timebaseduuid; + } + + public void setTimebaseduuid(UUID timebaseduuid) { + this.timebaseduuid = timebaseduuid; + } + + public String getRequestId() { + return requestId; + } + + public void setRequestId(String requestId) { + this.requestId = requestId; + } + + @Override + public String getServiceInstanceId() { return serviceInstanceId; } + + @Override + public void setServiceInstanceId(String serviceInstanceId) { + this.serviceInstanceId = serviceInstanceId; + } + + 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 String getAction() { + return action; + } + + public void setAction(String action) { + this.action = action; + } + + public Date getTimestamp1() { + return timestamp1; + } + + public void setTimestamp1(Date timestamp) { + this.timestamp1 = timestamp; + } + + @Override + public String toString() { + return "UserAccessEvent [timebaseduuid=" + timebaseduuid + ", timestamp1=" + timestamp1 + ", requestId=" + + requestId + ", userUid=" + userUid + ", status=" + status + ", desc=" + desc + ", action=" + action + + ", serviceInstanceId=" + serviceInstanceId + "]"; + } } diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/UserAdminEvent.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/UserAdminEvent.java index eb0d8db6f3..db5155f382 100644 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/UserAdminEvent.java +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/UserAdminEvent.java @@ -20,217 +20,175 @@ package org.openecomp.sdc.be.resources.data.auditing; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.Map; -import java.util.TimeZone; -import java.util.UUID; - -import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData; -import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum; - import com.datastax.driver.core.utils.UUIDs; import com.datastax.driver.mapping.annotations.ClusteringColumn; import com.datastax.driver.mapping.annotations.Column; import com.datastax.driver.mapping.annotations.PartitionKey; import com.datastax.driver.mapping.annotations.Table; +import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData; +import org.openecomp.sdc.common.datastructure.AuditingFieldsKey; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.TimeZone; +import java.util.UUID; @Table(keyspace = AuditingTypesConstants.AUDIT_KEYSPACE, name = AuditingTypesConstants.USER_ADMIN_EVENT_TYPE) public class UserAdminEvent extends AuditingGenericEvent { - private static String USER_ADMIN_EVENT_TEMPLATE = "action=\"%s\" timestamp=\"%s\" modifierName=\"%s\" modifierUid=\"%s\" " - + "userUid=\"%s\" userName=\"%s\" userEmail=\"%s\" userRole=\"%s\" " - + "userBeforeUid=\"%s\" userBeforeName=\"%s\" userBeforeEmail=\"%s\" userBeforeRole=\"%s\" " - + "userAfterUid=\"%s\" userAfterName=\"%s\" userAfterEmail=\"%s\" userAfterRole=\"%s\" " - + "status=\"%s\" desc=\"%s\""; - - @PartitionKey - protected UUID timebaseduuid; - - @ClusteringColumn - protected Date timestamp1; - - @Column(name = "REQUEST_ID") - protected String requestId; - - @Column(name = "SERVICE_INSTANCE_ID") - protected String serviceInstanceId; - - @Column(name = "ACTION") - protected String action; - @Column - protected String status; - - @Column(name = "description") - protected String desc; - - @Column - private String modifier; - - @Column(name = "user_before") - private String userBefore; - - @Column(name = "user_after") - private String userAfter; - - public UserAdminEvent() { - super(); - timestamp1 = new Date(); - timebaseduuid = UUIDs.timeBased(); - } - - public UserAdminEvent(Map<AuditingFieldsKeysEnum, Object> auditingFields) { - this(); - Object value; - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_REQUEST_ID); - if (value != null) { - setRequestId((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_STATUS); - if (value != null) { - setStatus((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_MODIFIER_UID); - if (value != null) { - setModifier((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_ACTION); - if (value != null) { - setAction((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_SERVICE_INSTANCE_ID); - if (value != null) { - setServiceInstanceId((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_DESC); - if (value != null) { - setDesc((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_USER_BEFORE); - if (value != null) { - setUserBefore((String) value); - } - value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_USER_AFTER); - if (value != null) { - setUserAfter((String) value); - } - - } - - public UserAdminEvent(String action, CommonAuditData commonAuditData, String modifier, String userBefore, String userAfter) { - this(); - this.action = action; - this.requestId = commonAuditData.getRequestId(); - this.status = commonAuditData.getStatus(); - this.modifier = modifier; - this.serviceInstanceId = commonAuditData.getServiceInstanceId(); - this.desc = commonAuditData.getDescription(); - this.userBefore = userBefore; - this.userAfter = userAfter; - } - - @Override - public void fillFields() { - fields.put(AuditingFieldsKeysEnum.AUDIT_REQUEST_ID.getDisplayName(), getRequestId()); - - fields.put(AuditingFieldsKeysEnum.AUDIT_SERVICE_INSTANCE_ID.getDisplayName(), getServiceInstanceId()); - fields.put(AuditingFieldsKeysEnum.AUDIT_ACTION.getDisplayName(), getAction()); - fields.put(AuditingFieldsKeysEnum.AUDIT_STATUS.getDisplayName(), getStatus()); - fields.put(AuditingFieldsKeysEnum.AUDIT_DESC.getDisplayName(), getDesc()); - fields.put(AuditingFieldsKeysEnum.AUDIT_USER_BEFORE.getDisplayName(), getUserBefore()); - fields.put(AuditingFieldsKeysEnum.AUDIT_USER_AFTER.getDisplayName(), getUserAfter()); - fields.put(AuditingFieldsKeysEnum.AUDIT_MODIFIER_UID.getDisplayName(), getModifier()); - SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormatPattern); - simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); - fields.put(AuditingFieldsKeysEnum.AUDIT_TIMESTAMP.getDisplayName(), simpleDateFormat.format(timestamp1)); - } - - public String getModifier() { - return modifier; - } - - public void setModifier(String modifier) { - this.modifier = modifier; - } - - public String getUserBefore() { - return userBefore; - } - - public void setUserBefore(String userBeforeName) { - this.userBefore = userBeforeName; - } - - public String getUserAfter() { - return userAfter; - } - - public void setUserAfter(String userAfterName) { - this.userAfter = userAfterName; - } - - 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 UUID getTimebaseduuid() { - return timebaseduuid; - } - - public void setTimebaseduuid(UUID timebaseduuid) { - this.timebaseduuid = timebaseduuid; - } - - public Date getTimestamp1() { - return timestamp1; - } - - public void setTimestamp1(Date timestamp) { - this.timestamp1 = timestamp; - } - - @Override - public String toString() { - return "UserAdminEvent [timebaseduuid=" + timebaseduuid + ", timestamp1=" + timestamp1 + ", requestId=" - + requestId + ", serviceInstanceId=" + serviceInstanceId + ", action=" + action + ", status=" + status - + ", desc=" + desc + ", modifierUid=" + modifier + ", userBefore=" + userBefore + ", userAfter=" - + userAfter + "]"; - } + @PartitionKey + protected UUID timebaseduuid; + + @ClusteringColumn + protected Date timestamp1; + + @Column(name = "REQUEST_ID") + protected String requestId; + + @Column(name = "SERVICE_INSTANCE_ID") + protected String serviceInstanceId; + + @Column(name = "ACTION") + protected String action; + @Column + protected String status; + + @Column(name = "description") + protected String desc; + + @Column + private String modifier; + + @Column(name = "user_before") + private String userBefore; + + @Column(name = "user_after") + private String userAfter; + + //Required to be public as it is used by Cassandra driver on get operation + public UserAdminEvent() { + timestamp1 = new Date(); + timebaseduuid = UUIDs.timeBased(); + } + + public UserAdminEvent(String action, CommonAuditData commonAuditData, String modifier, String userBefore, String userAfter) { + this(); + this.action = action; + this.requestId = commonAuditData.getRequestId(); + this.status = commonAuditData.getStatus(); + this.modifier = modifier; + this.serviceInstanceId = commonAuditData.getServiceInstanceId(); + this.desc = commonAuditData.getDescription(); + this.userBefore = userBefore; + this.userAfter = userAfter; + } + + public void setTimestamp1(String timestamp) { + this.timestamp1 = parseDateFromString(timestamp); + } + + @Override + public void fillFields() { + fields.put(AuditingFieldsKey.AUDIT_REQUEST_ID.getDisplayName(), getRequestId()); + + fields.put(AuditingFieldsKey.AUDIT_SERVICE_INSTANCE_ID.getDisplayName(), getServiceInstanceId()); + fields.put(AuditingFieldsKey.AUDIT_ACTION.getDisplayName(), getAction()); + fields.put(AuditingFieldsKey.AUDIT_STATUS.getDisplayName(), getStatus()); + fields.put(AuditingFieldsKey.AUDIT_DESC.getDisplayName(), getDesc()); + fields.put(AuditingFieldsKey.AUDIT_USER_BEFORE.getDisplayName(), getUserBefore()); + fields.put(AuditingFieldsKey.AUDIT_USER_AFTER.getDisplayName(), getUserAfter()); + fields.put(AuditingFieldsKey.AUDIT_MODIFIER_UID.getDisplayName(), getModifier()); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormatPattern); + simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); + fields.put(AuditingFieldsKey.AUDIT_TIMESTAMP.getDisplayName(), simpleDateFormat.format(timestamp1)); + } + + public String getModifier() { + return modifier; + } + + public void setModifier(String modifier) { + this.modifier = modifier; + } + + public String getUserBefore() { + return userBefore; + } + + public void setUserBefore(String userBeforeName) { + this.userBefore = userBeforeName; + } + + public String getUserAfter() { + return userAfter; + } + + public void setUserAfter(String userAfterName) { + this.userAfter = userAfterName; + } + + 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 UUID getTimebaseduuid() { + return timebaseduuid; + } + + public void setTimebaseduuid(UUID timebaseduuid) { + this.timebaseduuid = timebaseduuid; + } + + public Date getTimestamp1() { + return timestamp1; + } + + public void setTimestamp1(Date timestamp) { + this.timestamp1 = timestamp; + } + + @Override + public String toString() { + return "UserAdminEvent [timebaseduuid=" + timebaseduuid + ", timestamp1=" + timestamp1 + ", requestId=" + + requestId + ", serviceInstanceId=" + serviceInstanceId + ", action=" + action + ", status=" + status + + ", desc=" + desc + ", modifierUid=" + modifier + ", userBefore=" + userBefore + ", userAfter=" + + userAfter + "]"; + } } diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/model/CommonAuditData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/model/CommonAuditData.java index ae5a02ee75..34e2bdd479 100644 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/model/CommonAuditData.java +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/model/CommonAuditData.java @@ -18,6 +18,10 @@ public class CommonAuditData { return description; } + public void setRequestId(String requestId) { + this.requestId = requestId; + } + public String getRequestId() { return requestId; } diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/model/DistributionTopicData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/model/DistributionTopicData.java new file mode 100644 index 0000000000..378acd6f4b --- /dev/null +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/model/DistributionTopicData.java @@ -0,0 +1,45 @@ +package org.openecomp.sdc.be.resources.data.auditing.model; + +public class DistributionTopicData { + private String statusTopic; + private String notificationTopic; + + private DistributionTopicData() { + } + + public String getStatusTopic() { + return statusTopic; + } + + public String getNotificationTopic() { + return notificationTopic; + } + + public static Builder newBuilder() { + return new Builder(); + } + + public static class Builder { + + private final DistributionTopicData instance; + + public Builder() { + instance = new DistributionTopicData(); + } + + public Builder statusTopic(String statusTopic) { + this.instance.statusTopic = statusTopic; + return this; + } + + public Builder notificationTopic(String notificationTopic) { + this.instance.notificationTopic = notificationTopic; + return this; + } + + public DistributionTopicData build() { + return instance; + } + + } +} diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/model/ResourceCommonInfo.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/model/ResourceCommonInfo.java new file mode 100644 index 0000000000..eb9357de14 --- /dev/null +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/model/ResourceCommonInfo.java @@ -0,0 +1,31 @@ +package org.openecomp.sdc.be.resources.data.auditing.model; + +public class ResourceCommonInfo { + + private String resourceName; + private String resourceType; + + public ResourceCommonInfo(){} + + public ResourceCommonInfo(String resourceName, String resourceType) { + this.resourceName = resourceName; + this.resourceType = resourceType; + } + + public ResourceCommonInfo(String resourceType) { + this.resourceType = resourceType; + } + + public String getResourceName() { + return resourceName; + } + + public String getResourceType() { + return resourceType; + } + + public void setResourceName(String resourceName) { + this.resourceName = resourceName; + } + +} diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/model/ResourceAuditData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/model/ResourceVersionInfo.java index d66050a5f9..7e29fec2e5 100644 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/model/ResourceAuditData.java +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/model/ResourceVersionInfo.java @@ -1,12 +1,12 @@ package org.openecomp.sdc.be.resources.data.auditing.model; -public class ResourceAuditData { +public class ResourceVersionInfo { private String artifactUuid; private String state; private String version; private String distributionStatus; - private ResourceAuditData() { + private ResourceVersionInfo() { //for builder } @@ -27,10 +27,10 @@ public class ResourceAuditData { public static class Builder { - private final ResourceAuditData instance; + private final ResourceVersionInfo instance; private Builder() { - instance = new ResourceAuditData(); + instance = new ResourceVersionInfo(); } public Builder artifactUuid(String artifactUuid) { @@ -53,7 +53,7 @@ public class ResourceAuditData { return this; } - public ResourceAuditData build() { + public ResourceVersionInfo build() { return instance; } } |