aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-dao/src/main/java
diff options
context:
space:
mode:
authorMichael Lando <ml636r@att.com>2018-03-04 14:53:33 +0200
committerMichael Lando <ml636r@att.com>2018-03-07 13:19:05 +0000
commita5445100050e49e83f73424198d73cd72d672a4d (patch)
treecacf4df817df31be23e4e790d1dda857bdae061e /catalog-dao/src/main/java
parent51157f92c21976cba4914c378aaa3cba49826931 (diff)
Sync Integ to Master
Change-Id: I71e3acc26fa612127756ac04073a522b9cc6cd74 Issue-ID: SDC-977 Signed-off-by: Gitelman, Tal (tg851x) <tg851x@intl.att.com>
Diffstat (limited to 'catalog-dao/src/main/java')
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/ActionStatus.java142
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/AuditCassandraDao.java26
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/CassandraClient.java37
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/OperationalEnvironmentDao.java89
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/OperationalEnvironmentsAccessor.java14
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/SdcSchemaUtils.java20
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/Table.java43
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribBaseEventTableDesc.java76
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribDeployEventTableDesc.java47
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribDownloadEventTableDesc.java38
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribEngineEventTableDesc.java51
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribNotifEventTableDesc.java45
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribStatusEventTableDesc.java41
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/EcompOperationalEnvironmentEventTableDesc.java76
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/OperationalEnvironmentsTableDescription.java79
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/config/DAOSpringConfig.java34
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/config/TitanSpringConfig.java35
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/es/ElasticSearchClient.java32
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/graph/datatype/GraphNode.java9
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/AuditingDao.java18
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/ESCatalogDAO.java7
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/GraphVertex.java9
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/TitanDao.java1816
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/types/EdgeLabelEnum.java7
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/types/VertexTypeEnum.java22
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/utils/JsonParserUtils.java116
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/GraphEdgeLabels.java2
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/rest/HttpRestClient.java390
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/rest/RestConfigurationInfo.java110
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/titan/TitanGenericDao.java44
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/titan/TitanGraphClient.java2
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/titan/TitanUtils.java27
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/utils/MapUtil.java10
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/AdditionalInfoParameterData.java11
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ArtifactData.java13
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/CapabilityData.java12
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/CapabilityInstData.java12
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/CategoryData.java8
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ComponentMetadataData.java13
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ConsumerData.java8
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/GraphNodeLock.java8
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/GroupData.java8
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/HeatParameterData.java10
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/HeatParameterValueData.java8
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/InputValueData.java9
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/InputsData.java13
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/OperationData.java8
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/OperationalEnvironmentEntry.java137
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/PolicyTypeData.java137
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/PropertyData.java13
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/PropertyValueData.java12
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/TagData.java8
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/UniqueIdData.java6
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/UserData.java10
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/UserFunctionalMenuData.java8
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/AuditRecordFactory.java11
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/AuditingActionEnum.java11
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/AuditingGetUebClusterEvent.java319
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/AuditingTypesConstants.java2
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/AuthEvent.java20
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/CategoryEvent.java23
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/ConsumerEvent.java304
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/DistributionDeployEvent.java236
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/DistributionDownloadEvent.java184
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/DistributionEngineEvent.java450
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/DistributionNotificationEvent.java82
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/DistributionStatusEvent.java25
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/EcompOperationalEnvironmentEvent.java164
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/ExternalApiEvent.java691
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/GetCategoryHierarchyEvent.java300
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/GetUsersListEvent.java309
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/ResourceAdminEvent.java36
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/UserAccessEvent.java27
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/UserAdminEvent.java21
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/model/CommonAuditData.java75
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/model/DistributionData.java20
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/model/OperationalEnvAuditData.java26
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/model/ResourceAuditData.java60
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/category/CategoryData.java13
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/category/GroupingData.java8
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/category/SubCategoryData.java13
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/impl/ResourceUploader.java4
82 files changed, 3957 insertions, 3463 deletions
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/ActionStatus.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/ActionStatus.java
index 3b440df653..c2bff0a935 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/ActionStatus.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/ActionStatus.java
@@ -7,9 +7,9 @@
* 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.
@@ -21,74 +21,90 @@
package org.openecomp.sdc.be.dao.api;
public enum ActionStatus {
- OK, CREATED, NO_CONTENT, GENERAL_ERROR, NOT_ALLOWED, MISSING_INFORMATION, RESTRICTED_OPERATION, RESTRICTED_ACCESS, INVALID_CONTENT,
- // User related
- USER_ALREADY_EXIST, USER_INACTIVE, USER_NOT_FOUND, USER_HAS_ACTIVE_ELEMENTS, INVALID_EMAIL_ADDRESS, INVALID_ROLE, DELETE_USER_ADMIN_CONFLICT, UPDATE_USER_ADMIN_CONFLICT, CANNOT_DELETE_USER_WITH_ACTIVE_ELEMENTS, CANNOT_UPDATE_USER_WITH_ACTIVE_ELEMENTS, INVALID_USER_ID,
- // CapabilityType related
- CAPABILITY_TYPE_ALREADY_EXIST, MISSING_CAPABILITY_TYPE, REQ_CAP_NOT_SATISFIED_BEFORE_CERTIFICATION, IMPORT_DUPLICATE_REQ_CAP_NAME, IMPORT_REQ_CAP_NAME_EXISTS_IN_DERIVED,
- CAPABILITY_OF_INSTANCE_NOT_FOUND_ON_CONTAINER, REQUIREMENT_OF_INSTANCE_NOT_FOUND_ON_CONTAINER, RELATION_NOT_FOUND,
- // Resource related
- RESOURCE_NOT_FOUND, MISSING_DERIVED_FROM_TEMPLATE, PARENT_RESOURCE_NOT_FOUND, PARENT_RESOURCE_DOES_NOT_EXTEND, INVALID_DEFAULT_VALUE, INVALID_COMPLEX_DEFAULT_VALUE, MULTIPLE_PARENT_RESOURCE_FOUND, INVALID_RESOURCE_PAYLOAD, INVALID_TOSCA_FILE_EXTENSION, INVALID_YAML_FILE, INVALID_TOSCA_TEMPLATE, NOT_RESOURCE_TOSCA_TEMPLATE, NOT_SINGLE_RESOURCE, INVALID_RESOURCE_NAMESPACE, RESOURCE_ALREADY_EXISTS, INVALID_RESOURCE_CHECKSUM, RESOURCE_CANNOT_CONTAIN_RESOURCE_INSTANCES, NO_ASSETS_FOUND, GENERIC_TYPE_NOT_FOUND,INVALID_RESOURCE_TYPE, TOSCA_PARSE_ERROR,
- // Service related
- SERVICE_TYPE_EXCEEDS_LIMIT, INVALID_SERVICE_TYPE, SERVICE_ROLE_EXCEEDS_LIMIT, INVALID_SERVICE_ROLE,
- // Component name related
- COMPONENT_NAME_ALREADY_EXIST, COMPONENT_NAME_EXCEEDS_LIMIT, MISSING_COMPONENT_NAME, INVALID_COMPONENT_NAME,
- // Component description related
- COMPONENT_INVALID_DESCRIPTION, COMPONENT_MISSING_DESCRIPTION, COMPONENT_DESCRIPTION_EXCEEDS_LIMIT,
- // Component icon related
- COMPONENT_MISSING_ICON, COMPONENT_INVALID_ICON, COMPONENT_ICON_EXCEEDS_LIMIT,
- // Tag related
- COMPONENT_MISSING_TAGS, COMPONENT_TAGS_EXCEED_LIMIT, COMPONENT_SINGLE_TAG_EXCEED_LIMIT, INVALID_FIELD_FORMAT, COMPONENT_INVALID_TAGS_NO_COMP_NAME,
- // contactId related
- COMPONENT_MISSING_CONTACT, COMPONENT_INVALID_CONTACT,
- // Vendor related
- VENDOR_NAME_EXCEEDS_LIMIT, VENDOR_RELEASE_EXCEEDS_LIMIT, INVALID_VENDOR_NAME, INVALID_VENDOR_RELEASE, MISSING_VENDOR_NAME, MISSING_VENDOR_RELEASE, RESOURCE_VENDOR_MODEL_NUMBER_EXCEEDS_LIMIT, INVALID_RESOURCE_VENDOR_MODEL_NUMBER,
- // Category related
- COMPONENT_MISSING_CATEGORY, COMPONENT_INVALID_CATEGORY, COMPONENT_ELEMENT_INVALID_NAME_FORMAT, COMPONENT_ELEMENT_INVALID_NAME_LENGTH, COMPONENT_CATEGORY_ALREADY_EXISTS, COMPONENT_CATEGORY_NOT_FOUND, COMPONENT_SUB_CATEGORY_NOT_FOUND_FOR_CATEGORY, COMPONENT_SUB_CATEGORY_EXISTS_FOR_CATEGORY, COMPONENT_GROUPING_EXISTS_FOR_SUB_CATEGORY,
- // Service API URL
- INVALID_SERVICE_API_URL,
- // Property related
- PROPERTY_ALREADY_EXIST, PROPERTY_NAME_ALREADY_EXISTS, PROPERTY_NOT_FOUND, INVALID_PROPERTY, INVALID_PROPERTY_TYPE, INVALID_PROPERTY_INNER_TYPE,
- // Attribute related
- ATTRIBUTE_ALREADY_EXIST, ATTRIBUTE_NOT_FOUND,
- // State related
- COMPONENT_IN_CHECKOUT_STATE, ILLEGAL_COMPONENT_STATE, COMPONENT_IN_CERT_IN_PROGRESS_STATE, COMPONENT_SENT_FOR_CERTIFICATION, COMPONENT_VERSION_ALREADY_EXIST, COMPONENT_ALREADY_CHECKED_IN, COMPONENT_CHECKOUT_BY_ANOTHER_USER, COMPONENT_IN_USE, COMPONENT_HAS_NEWER_VERSION, COMPONENT_ALREADY_CERTIFIED, COMPONENT_NOT_READY_FOR_CERTIFICATION, COMPONENT_ARTIFACT_NOT_FOUND, COMPONENT_INSTANCE_NOT_FOUND, COMPONENT_INSTANCE_NOT_FOUND_ON_CONTAINER, SERVICE_NOT_FOUND, SERVICE_CATEGORY_CANNOT_BE_CHANGED, SERVICE_NAME_CANNOT_BE_CHANGED, SERVICE_ICON_CANNOT_BE_CHANGED, COMPONENT_TOO_MUCH_CATEGORIES, SERVICE_CANNOT_CONTAIN_SUBCATEGORY, RESOURCE_CATEGORY_CANNOT_BE_CHANGED, RESOURCE_NAME_CANNOT_BE_CHANGED, RESOURCE_ICON_CANNOT_BE_CHANGED, RESOURCE_VENDOR_NAME_CANNOT_BE_CHANGED, RESOURCE_TOO_MUCH_SUBCATEGORIES, SERVICE_ICON_EXCEEDS_LIMIT, RESOURCE_INSTANCE_NOT_FOUND, RESOURCE_INSTANCE_BAD_REQUEST, RESOURCE_INSTANCE_MATCH_NOT_FOUND, RESOURCE_INSTANCE_ALREADY_EXIST, RESOURCE_INSTANCE_RELATION_NOT_FOUND, COMPONENT_MISSING_SUBCATEGORY, COMPONENT_INVALID_SUBCATEGORY, ARTIFACT_TYPE_NOT_SUPPORTED, MISSING_ARTIFACT_TYPE, ARTIFACT_LOGICAL_NAME_CANNOT_BE_CHANGED, ARTIFACT_EXIST, ARTIFACT_NOT_FOUND, ARTIFACT_INVALID_MD5, MISSING_ARTIFACT_NAME, MISSING_PROJECT_CODE, INVALID_PROJECT_CODE, COMPONENT_MISSING_MANDATORY_ARTIFACTS, LIFECYCLE_TYPE_ALREADY_EXIST, SERVICE_NOT_AVAILABLE_FOR_DISTRIBUTION, MISSING_LIFECYCLE_TYPE,RESOURCE_VFCMT_LIFECYCLE_STATE_NOT_VALID,
- // Distribution
- MISSING_USER_ID, MISSING_X_ECOMP_INSTANCE_ID, MISSING_PUBLIC_KEY, MISSING_ENV_NAME, DISTRIBUTION_ENV_DOES_NOT_EXIST, MISSING_BODY, ECOMP_RESEND_WITH_BASIC_AUTHENTICATION_CREDENTIALS, ECOMP_COMPONENT_NOT_AUTHORIZED, METHOD_NOT_ALLOWED_TO_DOWNLOAD_ARTIFACT, REGISTRATION_FAILED, DISTRIBUTION_ENVIRONMENT_NOT_AVAILABLE, DISTRIBUTION_ENVIRONMENT_NOT_FOUND, DISTRIBUTION_ENVIRONMENT_INVALID, DISTRIBUTION_ARTIFACT_NOT_FOUND, DISTRIBUTION_REQUESTED_NOT_FOUND, DISTRIBUTION_REQUESTED_FAILED, DISTRIBUTION_NOT_FOUND, ADDITIONAL_INFORMATION_ALREADY_EXISTS, COMPONENT_VERSION_NOT_FOUND, ADDITIONAL_INFORMATION_MAX_NUMBER_REACHED, ADDITIONAL_INFORMATION_EMPTY_STRING_NOT_ALLOWED, ADDITIONAL_INFORMATION_EXCEEDS_LIMIT, ADDITIONAL_INFORMATION_KEY_NOT_ALLOWED_CHARACTERS, ADDITIONAL_INFORMATION_VALUE_NOT_ALLOWED_CHARACTERS, ADDITIONAL_INFORMATION_NOT_FOUND, ASDC_VERSION_NOT_FOUND, MISSING_DATA, EXCEEDS_LIMIT, UNSUPPORTED_ERROR, ARTIFACT_INVALID_TIMEOUT, SERVICE_IS_VNF_CANNOT_BE_CHANGED, RESOURCE_INSTANCE_NOT_FOUND_ON_SERVICE, WRONG_ARTIFACT_FILE_EXTENSION, INVALID_YAML, INVALID_XML, INVALID_JSON, INVALID_DEPLOYMENT_ARTIFACT_HEAT, INVALID_HEAT_PARAMETER_TYPE, INVALID_HEAT_PARAMETER_VALUE, DEPLOYMENT_ARTIFACT_OF_TYPE_ALREADY_EXISTS, DEPLOYMENT_ARTIFACT_NAME_ALREADY_EXISTS, MISSING_HEAT, MISMATCH_HEAT_VS_HEAT_ENV, CORRUPTED_FORMAT, MISMATCH_BETWEEN_ARTIFACT_TYPE_AND_COMPONENT_TYPE, INVALID_PARAMS_IN_HEAT_ENV_FILE,
- // auth
- AUTH_FAILED_INVALIDE_HEADER, AUTH_FAILED, AUTH_REQUIRED, CONSUMER_ALREADY_EXISTS, INVALID_LENGTH, ECOMP_USER_NOT_FOUND, INVALID_CONTENT_PARAM, INVALID_FILTER_KEY, SERVICE_DEPLOYMENT_ARTIFACT_NOT_FOUND, VALIDATED_RESOURCE_NOT_FOUND, FOUND_ALREADY_VALIDATED_RESOURCE, FOUND_LIST_VALIDATED_RESOURCES,
+ OK, ACCEPTED, CREATED, NO_CONTENT, GENERAL_ERROR, NOT_ALLOWED, MISSING_INFORMATION, RESTRICTED_OPERATION, RESTRICTED_ACCESS, INVALID_CONTENT,
+ // User related
+ USER_ALREADY_EXIST, USER_INACTIVE, USER_NOT_FOUND, USER_HAS_ACTIVE_ELEMENTS, INVALID_EMAIL_ADDRESS, INVALID_ROLE, DELETE_USER_ADMIN_CONFLICT, UPDATE_USER_ADMIN_CONFLICT, CANNOT_DELETE_USER_WITH_ACTIVE_ELEMENTS, CANNOT_UPDATE_USER_WITH_ACTIVE_ELEMENTS, INVALID_USER_ID,
+ // CapabilityType related
+ CAPABILITY_TYPE_ALREADY_EXIST, MISSING_CAPABILITY_TYPE, REQ_CAP_NOT_SATISFIED_BEFORE_CERTIFICATION, IMPORT_DUPLICATE_REQ_CAP_NAME, IMPORT_REQ_CAP_NAME_EXISTS_IN_DERIVED,
+ CAPABILITY_OF_INSTANCE_NOT_FOUND_ON_CONTAINER, REQUIREMENT_OF_INSTANCE_NOT_FOUND_ON_CONTAINER, RELATION_NOT_FOUND,
+ // Resource related
+ RESOURCE_NOT_FOUND, MISSING_DERIVED_FROM_TEMPLATE, PARENT_RESOURCE_NOT_FOUND, PARENT_RESOURCE_DOES_NOT_EXTEND, INVALID_DEFAULT_VALUE, INVALID_COMPLEX_DEFAULT_VALUE, MULTIPLE_PARENT_RESOURCE_FOUND, INVALID_RESOURCE_PAYLOAD, INVALID_TOSCA_FILE_EXTENSION, INVALID_YAML_FILE, INVALID_TOSCA_TEMPLATE, NOT_RESOURCE_TOSCA_TEMPLATE, NOT_SINGLE_RESOURCE, INVALID_RESOURCE_NAMESPACE, RESOURCE_ALREADY_EXISTS, INVALID_RESOURCE_CHECKSUM, RESOURCE_CANNOT_CONTAIN_RESOURCE_INSTANCES, NO_ASSETS_FOUND, GENERIC_TYPE_NOT_FOUND, INVALID_RESOURCE_TYPE, TOSCA_PARSE_ERROR,
+ // Service related
+ SERVICE_TYPE_EXCEEDS_LIMIT, INVALID_SERVICE_TYPE, SERVICE_ROLE_EXCEEDS_LIMIT, INVALID_SERVICE_ROLE,
+ // Component name related
+ COMPONENT_NAME_ALREADY_EXIST, COMPONENT_NAME_EXCEEDS_LIMIT, MISSING_COMPONENT_NAME, INVALID_COMPONENT_NAME,
+ // Component description related
+ COMPONENT_INVALID_DESCRIPTION, COMPONENT_MISSING_DESCRIPTION, COMPONENT_DESCRIPTION_EXCEEDS_LIMIT,
+ // Component icon related
+ COMPONENT_MISSING_ICON, COMPONENT_INVALID_ICON, COMPONENT_ICON_EXCEEDS_LIMIT,
+ // Tag related
+ COMPONENT_MISSING_TAGS, COMPONENT_TAGS_EXCEED_LIMIT, COMPONENT_SINGLE_TAG_EXCEED_LIMIT, INVALID_FIELD_FORMAT, COMPONENT_INVALID_TAGS_NO_COMP_NAME,
+ // contactId related
+ COMPONENT_MISSING_CONTACT, COMPONENT_INVALID_CONTACT,
+ // Vendor related
+ VENDOR_NAME_EXCEEDS_LIMIT, VENDOR_RELEASE_EXCEEDS_LIMIT, INVALID_VENDOR_NAME, INVALID_VENDOR_RELEASE, MISSING_VENDOR_NAME, MISSING_VENDOR_RELEASE, RESOURCE_VENDOR_MODEL_NUMBER_EXCEEDS_LIMIT, INVALID_RESOURCE_VENDOR_MODEL_NUMBER,
+ // Category related
+ COMPONENT_MISSING_CATEGORY, COMPONENT_INVALID_CATEGORY, COMPONENT_ELEMENT_INVALID_NAME_FORMAT, COMPONENT_ELEMENT_INVALID_NAME_LENGTH, COMPONENT_CATEGORY_ALREADY_EXISTS, COMPONENT_CATEGORY_NOT_FOUND, COMPONENT_SUB_CATEGORY_NOT_FOUND_FOR_CATEGORY, COMPONENT_SUB_CATEGORY_EXISTS_FOR_CATEGORY, COMPONENT_GROUPING_EXISTS_FOR_SUB_CATEGORY,
+ // Service API URL
+ INVALID_SERVICE_API_URL,
+ // Property related
+ PROPERTY_ALREADY_EXIST, PROPERTY_NAME_ALREADY_EXISTS, PROPERTY_NOT_FOUND, INVALID_PROPERTY, INVALID_PROPERTY_TYPE, INVALID_PROPERTY_INNER_TYPE,
+ // Attribute related
+ ATTRIBUTE_ALREADY_EXIST, ATTRIBUTE_NOT_FOUND,
+ // State related
+ INVALID_SERVICE_STATE, COMPONENT_IN_CHECKOUT_STATE, ILLEGAL_COMPONENT_STATE, COMPONENT_IN_CERT_IN_PROGRESS_STATE, COMPONENT_SENT_FOR_CERTIFICATION, COMPONENT_VERSION_ALREADY_EXIST, COMPONENT_ALREADY_CHECKED_IN, COMPONENT_CHECKOUT_BY_ANOTHER_USER, COMPONENT_IN_USE, COMPONENT_HAS_NEWER_VERSION, COMPONENT_ALREADY_CERTIFIED, COMPONENT_NOT_READY_FOR_CERTIFICATION, COMPONENT_ARTIFACT_NOT_FOUND, COMPONENT_INSTANCE_NOT_FOUND, COMPONENT_INSTANCE_NOT_FOUND_ON_CONTAINER, SERVICE_NOT_FOUND, SERVICE_CATEGORY_CANNOT_BE_CHANGED, SERVICE_NAME_CANNOT_BE_CHANGED, SERVICE_ICON_CANNOT_BE_CHANGED, COMPONENT_TOO_MUCH_CATEGORIES, SERVICE_CANNOT_CONTAIN_SUBCATEGORY, RESOURCE_CATEGORY_CANNOT_BE_CHANGED, RESOURCE_NAME_CANNOT_BE_CHANGED, RESOURCE_ICON_CANNOT_BE_CHANGED, RESOURCE_VENDOR_NAME_CANNOT_BE_CHANGED, RESOURCE_TOO_MUCH_SUBCATEGORIES, SERVICE_ICON_EXCEEDS_LIMIT, RESOURCE_INSTANCE_NOT_FOUND, RESOURCE_INSTANCE_BAD_REQUEST, RESOURCE_INSTANCE_MATCH_NOT_FOUND, RESOURCE_INSTANCE_ALREADY_EXIST, RESOURCE_INSTANCE_RELATION_NOT_FOUND, COMPONENT_MISSING_SUBCATEGORY, COMPONENT_INVALID_SUBCATEGORY, ARTIFACT_TYPE_NOT_SUPPORTED, MISSING_ARTIFACT_TYPE, ARTIFACT_LOGICAL_NAME_CANNOT_BE_CHANGED, ARTIFACT_EXIST, ARTIFACT_NOT_FOUND, ARTIFACT_INVALID_MD5, MISSING_ARTIFACT_NAME, MISSING_PROJECT_CODE, INVALID_PROJECT_CODE, COMPONENT_MISSING_MANDATORY_ARTIFACTS, LIFECYCLE_TYPE_ALREADY_EXIST, SERVICE_NOT_AVAILABLE_FOR_DISTRIBUTION, MISSING_LIFECYCLE_TYPE, RESOURCE_VFCMT_LIFECYCLE_STATE_NOT_VALID,
+ // Distribution
+ BAD_REQUEST_MISSING_RESOURCE, MISSING_USER_ID, MISSING_X_ECOMP_INSTANCE_ID, MISSING_PUBLIC_KEY, MISSING_ENV_NAME, DISTRIBUTION_ENV_DOES_NOT_EXIST, MISSING_BODY, ECOMP_RESEND_WITH_BASIC_AUTHENTICATION_CREDENTIALS, ECOMP_COMPONENT_NOT_AUTHORIZED, METHOD_NOT_ALLOWED_TO_DOWNLOAD_ARTIFACT, REGISTRATION_FAILED, DISTRIBUTION_ENVIRONMENT_NOT_AVAILABLE, DISTRIBUTION_ENVIRONMENT_NOT_FOUND, DISTRIBUTION_ENVIRONMENT_INVALID, DISTRIBUTION_ARTIFACT_NOT_FOUND, DISTRIBUTION_REQUESTED_NOT_FOUND, DISTRIBUTION_REQUESTED_FAILED, DISTRIBUTION_NOT_FOUND, ADDITIONAL_INFORMATION_ALREADY_EXISTS, COMPONENT_VERSION_NOT_FOUND, ADDITIONAL_INFORMATION_MAX_NUMBER_REACHED, ADDITIONAL_INFORMATION_EMPTY_STRING_NOT_ALLOWED, ADDITIONAL_INFORMATION_EXCEEDS_LIMIT, ADDITIONAL_INFORMATION_KEY_NOT_ALLOWED_CHARACTERS, ADDITIONAL_INFORMATION_VALUE_NOT_ALLOWED_CHARACTERS, ADDITIONAL_INFORMATION_NOT_FOUND, ASDC_VERSION_NOT_FOUND, MISSING_DATA, EXCEEDS_LIMIT, UNSUPPORTED_ERROR, ARTIFACT_INVALID_TIMEOUT, SERVICE_IS_VNF_CANNOT_BE_CHANGED, RESOURCE_INSTANCE_NOT_FOUND_ON_SERVICE, WRONG_ARTIFACT_FILE_EXTENSION, INVALID_YAML, INVALID_XML, INVALID_JSON, INVALID_DEPLOYMENT_ARTIFACT_HEAT, INVALID_HEAT_PARAMETER_TYPE, INVALID_HEAT_PARAMETER_VALUE, DEPLOYMENT_ARTIFACT_OF_TYPE_ALREADY_EXISTS, DEPLOYMENT_ARTIFACT_NAME_ALREADY_EXISTS, MISSING_HEAT, MISMATCH_HEAT_VS_HEAT_ENV, CORRUPTED_FORMAT, MISMATCH_BETWEEN_ARTIFACT_TYPE_AND_COMPONENT_TYPE, INVALID_PARAMS_IN_HEAT_ENV_FILE, API_RESOURCE_NOT_FOUND,
+ //UEB
+ UNKNOWN_HOST, AUTHENTICATION_ERROR, CONNNECTION_ERROR, OBJECT_NOT_FOUND, INVALID_RESPONSE_FROM_PROXY,
+ // auth
+ AUTH_FAILED_INVALIDE_HEADER, AUTH_FAILED, AUTH_REQUIRED, CONSUMER_ALREADY_EXISTS, INVALID_LENGTH, ECOMP_USER_NOT_FOUND, INVALID_CONTENT_PARAM, INVALID_FILTER_KEY, SERVICE_DEPLOYMENT_ARTIFACT_NOT_FOUND, VALIDATED_RESOURCE_NOT_FOUND, FOUND_ALREADY_VALIDATED_RESOURCE, FOUND_LIST_VALIDATED_RESOURCES,
- // product
- PRODUCT_NOT_FOUND, INVALID_GROUP_ASSOCIATION, EMPTY_PRODUCT_CONTACTS_LIST, INVALID_PRODUCT_CONTACT, MISSING_ONE_OF_COMPONENT_NAMES, COMPONENT_PARAMETER_CANNOT_BE_CHANGED,
+ // product
+ PRODUCT_NOT_FOUND, INVALID_GROUP_ASSOCIATION, EMPTY_PRODUCT_CONTACTS_LIST, INVALID_PRODUCT_CONTACT, MISSING_ONE_OF_COMPONENT_NAMES, COMPONENT_PARAMETER_CANNOT_BE_CHANGED,
- // occurrences
- EMPTY_OCCURRENCES_LIST, INVALID_OCCURRENCES, NOT_TOPOLOGY_TOSCA_TEMPLATE, INVALID_NODE_TEMPLATE,
+ // occurrences
+ EMPTY_OCCURRENCES_LIST, INVALID_OCCURRENCES, NOT_TOPOLOGY_TOSCA_TEMPLATE, INVALID_NODE_TEMPLATE,
- // Data type related
- DATA_TYPE_ALREADY_EXIST, DATA_TYPE_NOR_PROPERTIES_NEITHER_DERIVED_FROM, DATA_TYPE_PROPERTIES_CANNOT_BE_EMPTY, DATA_TYPE_DERIVED_IS_MISSING, DATA_TYPE_PROPERTY_ALREADY_DEFINED_IN_ANCESTOR, DATA_TYPE_DUPLICATE_PROPERTY, DATA_TYPE_PROEPRTY_CANNOT_HAVE_SAME_TYPE_OF_DATA_TYPE, DATA_TYPE_CANNOT_HAVE_PROPERTIES, DATA_TYPE_CANNOT_BE_EMPTY, DATA_TYPE_CANNOT_BE_UPDATED_BAD_REQUEST,
+ // Data type related
+ DATA_TYPE_ALREADY_EXIST, DATA_TYPE_NOR_PROPERTIES_NEITHER_DERIVED_FROM, DATA_TYPE_PROPERTIES_CANNOT_BE_EMPTY, DATA_TYPE_DERIVED_IS_MISSING, DATA_TYPE_PROPERTY_ALREADY_DEFINED_IN_ANCESTOR, DATA_TYPE_DUPLICATE_PROPERTY, DATA_TYPE_PROEPRTY_CANNOT_HAVE_SAME_TYPE_OF_DATA_TYPE, DATA_TYPE_CANNOT_HAVE_PROPERTIES, DATA_TYPE_CANNOT_BE_EMPTY, DATA_TYPE_CANNOT_BE_UPDATED_BAD_REQUEST,
- // Policy Type related
- TARGETS_EMPTY, TARGETS_NON_VALID, POLICY_TYPE_ALREADY_EXIST,
+ // Policy Type related
+ TARGETS_EMPTY, TARGETS_NON_VALID, POLICY_TYPE_ALREADY_EXIST,
- // Group Type related
- GROUP_MEMBER_EMPTY, GROUP_TYPE_ALREADY_EXIST,
+ // Group Type related
+ GROUP_MEMBER_EMPTY, GROUP_TYPE_ALREADY_EXIST, GROUP_TYPE_ILLEGAL_PER_COMPONENT,
- // CSAR
- MISSING_CSAR_UUID, CSAR_INVALID, CSAR_INVALID_FORMAT, CSAR_NOT_FOUND, YAML_NOT_FOUND_IN_CSAR, VSP_ALREADY_EXISTS, RESOURCE_LINKED_TO_DIFFERENT_VSP, RESOURCE_FROM_CSAR_NOT_FOUND, AAI_ARTIFACT_GENERATION_FAILED, ASSET_NOT_FOUND_DURING_CSAR_CREATION, ARTIFACT_PAYLOAD_NOT_FOUND_DURING_CSAR_CREATION, TOSCA_SCHEMA_FILES_NOT_FOUND, ARTIFACT_NAME_INVALID,
+ // CSAR
+ MISSING_CSAR_UUID, CSAR_INVALID, CSAR_INVALID_FORMAT, CSAR_NOT_FOUND, YAML_NOT_FOUND_IN_CSAR, VSP_ALREADY_EXISTS, RESOURCE_LINKED_TO_DIFFERENT_VSP, RESOURCE_FROM_CSAR_NOT_FOUND, AAI_ARTIFACT_GENERATION_FAILED, ASSET_NOT_FOUND_DURING_CSAR_CREATION, ARTIFACT_PAYLOAD_NOT_FOUND_DURING_CSAR_CREATION, TOSCA_SCHEMA_FILES_NOT_FOUND, ARTIFACT_NAME_INVALID,
- // Group
- GROUP_HAS_CYCLIC_DEPENDENCY, GROUP_ALREADY_EXIST, GROUP_TYPE_IS_INVALID, GROUP_MISSING_GROUP_TYPE, GROUP_INVALID_COMPONENT_INSTANCE, GROUP_INVALID_TOSCA_NAME_OF_COMPONENT_INSTANCE, GROUP_IS_MISSING, GROUP_ARTIFACT_ALREADY_ASSOCIATED, GROUP_ARTIFACT_ALREADY_DISSOCIATED, GROUP_PROPERTY_NOT_FOUND, INVALID_VF_MODULE_NAME, INVALID_VF_MODULE_NAME_MODIFICATION, INVALID_VF_MODULE_TYPE,
-
- // Group instance
- GROUP_INSTANCE_NOT_FOUND_ON_COMPONENT_INSTANCE, INVALID_GROUP_MIN_MAX_INSTANCES_PROPERTY_VALUE, INVALID_GROUP_INITIAL_COUNT_PROPERTY_VALUE, INVALID_GROUP_PROPERTY_VALUE_LOWER_HIGHER,
-
- ARTIFACT_NOT_FOUND_IN_CSAR, ARTIFACT_ALRADY_EXIST_IN_DIFFERENT_TYPE_IN_CSAR, FAILED_RETRIVE_ARTIFACTS_TYPES, ARTIFACT_ALRADY_EXIST_IN_MASTER_IN_CSAR, ARTIFACT_NOT_VALID_IN_MASTER, ARTIFACT_NOT_VALID_ENV,
+ // Group
+ GROUP_HAS_CYCLIC_DEPENDENCY, GROUP_ALREADY_EXIST, GROUP_TYPE_IS_INVALID, GROUP_MISSING_GROUP_TYPE, GROUP_INVALID_COMPONENT_INSTANCE, GROUP_INVALID_TOSCA_NAME_OF_COMPONENT_INSTANCE, GROUP_IS_MISSING, GROUP_ARTIFACT_ALREADY_ASSOCIATED, GROUP_ARTIFACT_ALREADY_DISSOCIATED, GROUP_PROPERTY_NOT_FOUND, INVALID_VF_MODULE_NAME, INVALID_VF_MODULE_NAME_MODIFICATION, INVALID_VF_MODULE_TYPE,
- // cache
- CONVERT_COMPONENT_ERROR, COMPONENT_NOT_FOUND,
+ // Group instance
+ GROUP_INSTANCE_NOT_FOUND_ON_COMPONENT_INSTANCE, INVALID_GROUP_MIN_MAX_INSTANCES_PROPERTY_VALUE, INVALID_GROUP_INITIAL_COUNT_PROPERTY_VALUE, INVALID_GROUP_PROPERTY_VALUE_LOWER_HIGHER,
- // Inputs
- INPUT_IS_NOT_CHILD_OF_COMPONENT,
- CFVC_LOOP_DETECTED,
- ;
+ ARTIFACT_NOT_FOUND_IN_CSAR, ARTIFACT_ALRADY_EXIST_IN_DIFFERENT_TYPE_IN_CSAR, FAILED_RETRIVE_ARTIFACTS_TYPES, ARTIFACT_ALRADY_EXIST_IN_MASTER_IN_CSAR, ARTIFACT_NOT_VALID_IN_MASTER, ARTIFACT_NOT_VALID_ENV,
+
+ // cache
+ CONVERT_COMPONENT_ERROR, COMPONENT_NOT_FOUND,
+
+ // Inputs
+ INPUT_IS_NOT_CHILD_OF_COMPONENT,
+ CFVC_LOOP_DETECTED,
+ //Forwarding Path related
+ FORWARDING_PATH_NAME_MAXIMUM_LENGTH, FORWARDING_PATH_NAME_ALREADY_IN_USE, FORWARDING_PATH_NAME_EMPTY,
+ FORWARDING_PATH_PROTOCOL_MAXIMUM_LENGTH, FORWARDING_PATH_DESTINATION_PORT_MAXIMUM_LENGTH,
+ MISSING_OLD_COMPONENT_INSTANCE, MISSING_NEW_COMPONENT_INSTANCE,
+ //policies
+ RESOURCE_CANNOT_CONTAIN_POLICIES,
+ POLICY_NOT_FOUND_ON_CONTAINER,
+ INVALID_POLICY_NAME,
+ POLICY_NAME_ALREADY_EXIST, EXCLUDED_POLICY_TYPE,
+
+ //External References Statuses
+ EXT_REF_ALREADY_EXIST,
+ EXT_REF_NOT_FOUND,
+
+ POLICY_TARGET_DOES_NOT_EXIST, POLICY_TARGET_TYPE_DOES_NOT_EXIST;
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/AuditCassandraDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/AuditCassandraDao.java
index 73b55b909c..681d20cde3 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/AuditCassandraDao.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/AuditCassandraDao.java
@@ -106,10 +106,7 @@ public class AuditCassandraDao extends CassandraDao {
});
return Either.left(remainingElements);
} catch (Exception e) {
- BeEcompErrorManager.getInstance().processEcompError(EcompErrorName.BeDaoSystemError,
- "Get DistributionStatuses List");
BeEcompErrorManager.getInstance().logBeDaoSystemError("Get DistributionStatuses List");
-
logger.debug("failed to get distribution statuses for ", e);
return Either.right(ActionStatus.GENERAL_ERROR);
}
@@ -133,10 +130,7 @@ public class AuditCassandraDao extends CassandraDao {
return Either.left(remainingElements);
} catch (Exception e) {
- BeEcompErrorManager.getInstance().processEcompError(EcompErrorName.BeDaoSystemError,
- "Get DistributionStatuses List");
BeEcompErrorManager.getInstance().logBeDaoSystemError("get Distribution Deploy By Status");
-
logger.debug("failed to get distribution deploy by status for ", e);
return Either.right(ActionStatus.GENERAL_ERROR);
}
@@ -158,10 +152,7 @@ public class AuditCassandraDao extends CassandraDao {
});
return Either.left(remainingElements);
} catch (Exception e) {
- BeEcompErrorManager.getInstance().processEcompError(EcompErrorName.BeDaoSystemError,
- "Get DistributionStatuses List");
BeEcompErrorManager.getInstance().logBeDaoSystemError("get Distribution request");
-
logger.debug("failed to get distribution request for ", e);
return Either.right(ActionStatus.GENERAL_ERROR);
}
@@ -184,10 +175,7 @@ public class AuditCassandraDao extends CassandraDao {
return Either.left(remainingElements);
} catch (Exception e) {
- BeEcompErrorManager.getInstance().processEcompError(EcompErrorName.BeDaoSystemError,
- "Get DistributionStatuses List");
BeEcompErrorManager.getInstance().logBeDaoSystemError("get Distribution notify");
-
logger.debug("failed to get distribution notify for ", e);
return Either.right(ActionStatus.GENERAL_ERROR);
}
@@ -209,10 +197,7 @@ public class AuditCassandraDao extends CassandraDao {
});
return Either.left(remainingElements);
} catch (Exception e) {
- BeEcompErrorManager.getInstance().processEcompError(EcompErrorName.BeDaoSystemError,
- "Get DistributionStatuses List");
BeEcompErrorManager.getInstance().logBeDaoSystemError("get Distribution notify");
-
logger.debug("failed to get distribution notify for ", e);
return Either.right(ActionStatus.GENERAL_ERROR);
}
@@ -241,8 +226,6 @@ public class AuditCassandraDao extends CassandraDao {
}
} catch (Exception e) {
- BeEcompErrorManager.getInstance().processEcompError(EcompErrorName.BeDaoSystemError,
- "Get Service DistributionStatuses List");
BeEcompErrorManager.getInstance().logBeDaoSystemError("Get Service DistributionStatuses List");
logger.debug("failed to get distribution statuses for action {}",
AuditingActionEnum.DISTRIBUTION_STATE_CHANGE_REQUEST.getName(), e);
@@ -259,8 +242,6 @@ public class AuditCassandraDao extends CassandraDao {
});
}
} catch (Exception e) {
- BeEcompErrorManager.getInstance().processEcompError(EcompErrorName.BeDaoSystemError,
- "Get Service DistributionStatuses List");
BeEcompErrorManager.getInstance().logBeDaoSystemError("Get Service DistributionStatuses List");
logger.debug("failed to get distribution statuses for action {}",
AuditingActionEnum.DISTRIBUTION_DEPLOY.getName(), e);
@@ -277,8 +258,6 @@ public class AuditCassandraDao extends CassandraDao {
});
}
} catch (Exception e) {
- BeEcompErrorManager.getInstance().processEcompError(EcompErrorName.BeDaoSystemError,
- "Get Service DistributionStatuses List");
BeEcompErrorManager.getInstance().logBeDaoSystemError("Get Service DistributionStatuses List");
logger.debug("failed to get distribution statuses for action {}",
AuditingActionEnum.DISTRIBUTION_NOTIFY.getName(), e);
@@ -307,10 +286,7 @@ public class AuditCassandraDao extends CassandraDao {
});
return Either.left(remainingElements);
} catch (Exception e) {
- BeEcompErrorManager.getInstance().processEcompError(EcompErrorName.BeDaoSystemError,
- "get Audit By ServiceId And PrevVersion");
BeEcompErrorManager.getInstance().logBeDaoSystemError("get Audit By ServiceId And PrevVersion");
-
logger.debug("failed to getAuditByServiceIdAndPrevVersion ", e);
return Either.right(ActionStatus.GENERAL_ERROR);
}
@@ -335,8 +311,6 @@ public class AuditCassandraDao extends CassandraDao {
});
return Either.left(remainingElements);
} catch (Exception e) {
- BeEcompErrorManager.getInstance().processEcompError(EcompErrorName.BeDaoSystemError,
- "get Audit By ServiceId And CurrVersion");
BeEcompErrorManager.getInstance().logBeDaoSystemError("get Audit By ServiceId And CurrVersion");
logger.debug("failed to getAuditByServiceIdAndPrevVersion ", e);
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/CassandraClient.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/CassandraClient.java
index eff094a3a0..10b9b0578c 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/CassandraClient.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/CassandraClient.java
@@ -24,9 +24,8 @@ import java.util.List;
import javax.annotation.PreDestroy;
-import com.datastax.driver.core.SocketOptions;
+import com.datastax.driver.core.policies.*;
import org.apache.commons.lang3.tuple.ImmutablePair;
-import org.openecomp.sdc.be.config.Configuration;
import org.openecomp.sdc.be.config.ConfigurationManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -34,11 +33,6 @@ import org.springframework.stereotype.Component;
import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.Session;
-import com.datastax.driver.core.policies.ConstantReconnectionPolicy;
-import com.datastax.driver.core.policies.DCAwareRoundRobinPolicy;
-import com.datastax.driver.core.policies.DefaultRetryPolicy;
-import com.datastax.driver.core.policies.LoadBalancingPolicy;
-import com.datastax.driver.core.policies.TokenAwarePolicy;
import com.datastax.driver.mapping.Mapper;
import com.datastax.driver.mapping.MappingManager;
@@ -50,27 +44,23 @@ public class CassandraClient {
private Cluster cluster;
private boolean isConnected;
- private Configuration.CassandrConfig configuration;
public CassandraClient() {
super();
isConnected = false;
List<String> cassandraHosts = null;
try {
-
- this.configuration = ConfigurationManager.getConfigurationManager().getConfiguration().getCassandraConfig();
- cassandraHosts = configuration.getCassandraHosts();
- Long reconnectTimeout = configuration.getReconnectTimeout();
-
+ cassandraHosts = ConfigurationManager.getConfigurationManager().getConfiguration().getCassandraConfig()
+ .getCassandraHosts();
+ Long reconnectTimeout = ConfigurationManager.getConfigurationManager().getConfiguration()
+ .getCassandraConfig().getReconnectTimeout();
logger.debug("creating cluster to hosts:{} with reconnect timeout:{}", cassandraHosts, reconnectTimeout);
Cluster.Builder clusterBuilder = Cluster.builder()
.withReconnectionPolicy(new ConstantReconnectionPolicy(reconnectTimeout))
.withRetryPolicy(DefaultRetryPolicy.INSTANCE);
-
cassandraHosts.forEach(host -> clusterBuilder.addContactPoint(host));
- setSocketOptions(clusterBuilder);
enableAuthentication(clusterBuilder);
enableSsl(clusterBuilder);
setLocalDc(clusterBuilder);
@@ -84,26 +74,11 @@ public class CassandraClient {
logger.info("** CassandraClient created");
}
- private void setSocketOptions(Cluster.Builder clusterBuilder) {
- SocketOptions socketOptions =new SocketOptions();
- Integer socketConnectTimeout = this.configuration.getSocketConnectTimeout();
- if( socketConnectTimeout!=null ){
- logger.info("SocketConnectTimeout was provided, setting Cassandra client to use SocketConnectTimeout: {} .",socketConnectTimeout);
- socketOptions.setConnectTimeoutMillis(socketConnectTimeout);
- }
- Integer socketReadTimeout = this.configuration.getSocketReadTimeout();
- if( socketReadTimeout != null ){
- logger.info("SocketReadTimeout was provided, setting Cassandra client to use SocketReadTimeout: {} .",socketReadTimeout);
- socketOptions.setReadTimeoutMillis(socketReadTimeout);
- }
- clusterBuilder.withSocketOptions(socketOptions);
- }
-
private void setLocalDc(Cluster.Builder clusterBuilder) {
String localDataCenter = ConfigurationManager.getConfigurationManager().getConfiguration().getCassandraConfig()
.getLocalDataCenter();
if (localDataCenter != null) {
- logger.info("localDatacenter was provided, setting Cassandra client to use datacenter: {} as local.",
+ logger.info("localDatacenter was provided, setting Cassndra clint to use datacenter: {} as local.",
localDataCenter);
LoadBalancingPolicy tokenAwarePolicy = new TokenAwarePolicy(
DCAwareRoundRobinPolicy.builder().withLocalDc(localDataCenter).build());
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/OperationalEnvironmentDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/OperationalEnvironmentDao.java
new file mode 100644
index 0000000000..a803f0b165
--- /dev/null
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/OperationalEnvironmentDao.java
@@ -0,0 +1,89 @@
+package org.openecomp.sdc.be.dao.cassandra;
+
+import java.util.List;
+
+import javax.annotation.PostConstruct;
+
+import org.apache.commons.lang3.tuple.ImmutablePair;
+import org.openecomp.sdc.be.datatypes.enums.EnvironmentStatusEnum;
+import org.openecomp.sdc.be.resources.data.OperationalEnvironmentEntry;
+import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+
+import com.datastax.driver.core.Session;
+import com.datastax.driver.mapping.MappingManager;
+import com.datastax.driver.mapping.Result;
+
+import fj.data.Either;
+
+@Component("operational-environment-dao")
+public class OperationalEnvironmentDao extends CassandraDao {
+
+ private static Logger logger = LoggerFactory.getLogger(OperationalEnvironmentDao.class.getName());
+ private OperationalEnvironmentsAccessor operationalEnvironmentsAccessor;
+
+ public OperationalEnvironmentDao() {
+ super();
+ }
+
+ @PostConstruct
+ public void init() {
+ String keyspace = AuditingTypesConstants.REPO_KEYSPACE;
+ if (client.isConnected()) {
+ Either<ImmutablePair<Session, MappingManager>, CassandraOperationStatus> result = client.connect(keyspace);
+ if (result.isLeft()) {
+ session = result.left().value().left;
+ manager = result.left().value().right;
+ operationalEnvironmentsAccessor = manager.createAccessor(OperationalEnvironmentsAccessor.class);
+ logger.info("** OperationalEnvironmentDao created");
+ } else {
+ logger.info("** OperationalEnvironmentDao failed");
+ throw new RuntimeException("OperationalEnvironment keyspace [" + keyspace + "] failed to connect with error : "
+ + result.right().value());
+ }
+ } else {
+ logger.info("** Cassandra client isn't connected");
+ logger.info("** OperationalEnvironmentDao created, but not connected");
+ }
+ }
+ public CassandraOperationStatus save(OperationalEnvironmentEntry operationalEnvironmentEntry) {
+ return client.save(operationalEnvironmentEntry, OperationalEnvironmentEntry.class, manager);
+ }
+
+ public Either<OperationalEnvironmentEntry, CassandraOperationStatus> get(String envId) {
+ return client.getById(envId, OperationalEnvironmentEntry.class, manager);
+ }
+
+ public CassandraOperationStatus delete(String envId) {
+ return client.delete(envId, OperationalEnvironmentEntry.class, manager);
+ }
+
+ public CassandraOperationStatus deleteAll() {
+ logger.info("cleaning all operational environments.");
+ String query = "truncate sdcrepository.operationalenvironment;";
+ try {
+ session.execute(query);
+ } catch (Exception e) {
+ logger.debug("Failed to clean operational environment", e);
+ return CassandraOperationStatus.GENERAL_ERROR;
+ }
+ logger.info("cleaning all operational environment finished succsesfully.");
+ return CassandraOperationStatus.OK;
+ }
+
+ public Either<Boolean, CassandraOperationStatus> isTableEmpty(String tableName) {
+ return super.isTableEmpty(tableName);
+ }
+
+ //accessors
+ public Either<List<OperationalEnvironmentEntry>, CassandraOperationStatus> getByEnvironmentsStatus(EnvironmentStatusEnum status) {
+ Result<OperationalEnvironmentEntry> operationalEnvironments = operationalEnvironmentsAccessor.getByEnvironmentsStatus(status.getName());
+ if (operationalEnvironments == null) {
+ return Either.right(CassandraOperationStatus.NOT_FOUND);
+ }
+ return Either.left(operationalEnvironments.all());
+ }
+
+}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/OperationalEnvironmentsAccessor.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/OperationalEnvironmentsAccessor.java
new file mode 100644
index 0000000000..e72df9b42d
--- /dev/null
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/OperationalEnvironmentsAccessor.java
@@ -0,0 +1,14 @@
+package org.openecomp.sdc.be.dao.cassandra;
+
+import com.datastax.driver.mapping.Result;
+import com.datastax.driver.mapping.annotations.Accessor;
+import com.datastax.driver.mapping.annotations.Param;
+import com.datastax.driver.mapping.annotations.Query;
+import org.openecomp.sdc.be.resources.data.OperationalEnvironmentEntry;
+
+@Accessor
+public interface OperationalEnvironmentsAccessor {
+ @Query("SELECT * FROM sdcrepository.operationalenvironment WHERE status = :envStatus")
+ Result<OperationalEnvironmentEntry> getByEnvironmentsStatus(@Param("envStatus") String envStatus);
+}
+
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/SdcSchemaUtils.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/SdcSchemaUtils.java
index 4de57ded64..56cf32a152 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/SdcSchemaUtils.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/SdcSchemaUtils.java
@@ -20,15 +20,12 @@
package org.openecomp.sdc.be.dao.cassandra.schema;
-import java.util.List;
-
-import com.datastax.driver.core.SocketOptions;
+import com.datastax.driver.core.*;
import org.openecomp.sdc.be.config.ConfigurationManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.datastax.driver.core.Cluster;
-import com.datastax.driver.core.Session;
+import java.util.List;
public class SdcSchemaUtils {
@@ -74,19 +71,6 @@ public class SdcSchemaUtils {
System.setProperty("javax.net.ssl.trustStorePassword", truststorePassword);
clusterBuilder.withSSL();
}
-
- SocketOptions socketOptions =new SocketOptions();
- Integer socketConnectTimeout = ConfigurationManager.getConfigurationManager().getConfiguration().getCassandraConfig().getSocketConnectTimeout();
- if( socketConnectTimeout!=null ){
- log.info("SocketConnectTimeout was provided, setting Cassandra client to use SocketConnectTimeout: {} .",socketConnectTimeout);
- socketOptions.setConnectTimeoutMillis(socketConnectTimeout);
- }
- Integer socketReadTimeout = ConfigurationManager.getConfigurationManager().getConfiguration().getCassandraConfig().getSocketReadTimeout();
- if( socketReadTimeout != null ){
- log.info("SocketReadTimeout was provided, setting Cassandra client to use SocketReadTimeout: {} .",socketReadTimeout);
- socketOptions.setReadTimeoutMillis(socketReadTimeout);
- }
- clusterBuilder.withSocketOptions(socketOptions);
return clusterBuilder.build();
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/Table.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/Table.java
index 5cbe2508b1..96bd68ac79 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/Table.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/Table.java
@@ -30,11 +30,13 @@ import org.openecomp.sdc.be.dao.cassandra.schema.tables.DistribDownloadEventTabl
import org.openecomp.sdc.be.dao.cassandra.schema.tables.DistribEngineEventTableDesc;
import org.openecomp.sdc.be.dao.cassandra.schema.tables.DistribNotifEventTableDesc;
import org.openecomp.sdc.be.dao.cassandra.schema.tables.DistribStatusEventTableDesc;
+import org.openecomp.sdc.be.dao.cassandra.schema.tables.EcompOperationalEnvironmentEventTableDesc;
import org.openecomp.sdc.be.dao.cassandra.schema.tables.ExternalApiEventTableDesc;
import org.openecomp.sdc.be.dao.cassandra.schema.tables.GetCatHierEventTableDesc;
import org.openecomp.sdc.be.dao.cassandra.schema.tables.GetUebClusterEventTableDesc;
import org.openecomp.sdc.be.dao.cassandra.schema.tables.GetUsersListEventTableDesc;
import org.openecomp.sdc.be.dao.cassandra.schema.tables.MigrationTasksTableDescription;
+import org.openecomp.sdc.be.dao.cassandra.schema.tables.OperationalEnvironmentsTableDescription;
import org.openecomp.sdc.be.dao.cassandra.schema.tables.ResAdminEventTableDescription;
import org.openecomp.sdc.be.dao.cassandra.schema.tables.SdcSchemaFilesTableDescription;
import org.openecomp.sdc.be.dao.cassandra.schema.tables.UserAccessEventTableDescription;
@@ -42,25 +44,28 @@ import org.openecomp.sdc.be.dao.cassandra.schema.tables.UserAdminEventTableDescr
public enum Table {
- ARTIFACT(new ArtifactTableDescription()),
- USER_ADMIN_EVENT(new UserAdminEventTableDescription()),
- USER_ACCESS_EVENT(new UserAccessEventTableDescription()),
- RESOURCE_ADMIN_EVENT(new ResAdminEventTableDescription()),
- DISTRIBUTION_DOWNLOAD_EVENT(new DistribDownloadEventTableDesc()),
- DISTRIBUTION_ENGINE_EVENT(new DistribEngineEventTableDesc()),
- DISTRIBUTION_NOTIFICATION_EVENT(new DistribNotifEventTableDesc()),
- DISTRIBUTION_STATUS_EVENT(new DistribStatusEventTableDesc()),
- DISTRIBUTION_DEPLOY_EVENT(new DistribDeployEventTableDesc()),
- DISTRIBUTION_GET_UEB_CLUSTER_EVENT(new GetUebClusterEventTableDesc()),
- AUTH_EVENT(new AuthEventTableDescription()),
- CONSUMER_EVENT(new ConsumerEventTableDefinition()),
- CATEGORY_EVENT(new CategoryEventTableDescription()),
- GET_USERS_LIST_EVENT(new GetUsersListEventTableDesc()),
- GET_CATEGORY_HIERARCHY_EVENT(new GetCatHierEventTableDesc()),
- EXTERNAL_API_EVENT(new ExternalApiEventTableDesc()),
- COMPONENT_CACHE(new ComponentCacheTableDescription()),
- SDC_SCHEMA_FILES(new SdcSchemaFilesTableDescription()),
- SDC_REPO(new MigrationTasksTableDescription());
+ ARTIFACT(new ArtifactTableDescription()),
+ USER_ADMIN_EVENT(new UserAdminEventTableDescription()),
+ USER_ACCESS_EVENT(new UserAccessEventTableDescription()),
+ RESOURCE_ADMIN_EVENT(new ResAdminEventTableDescription()),
+ DISTRIBUTION_DOWNLOAD_EVENT(new DistribDownloadEventTableDesc()),
+ DISTRIBUTION_ENGINE_EVENT(new DistribEngineEventTableDesc()),
+ DISTRIBUTION_NOTIFICATION_EVENT(new DistribNotifEventTableDesc()),
+ DISTRIBUTION_STATUS_EVENT(new DistribStatusEventTableDesc()),
+ DISTRIBUTION_DEPLOY_EVENT(new DistribDeployEventTableDesc()),
+ DISTRIBUTION_GET_UEB_CLUSTER_EVENT(new GetUebClusterEventTableDesc()),
+ AUTH_EVENT(new AuthEventTableDescription()),
+ CONSUMER_EVENT(new ConsumerEventTableDefinition()),
+ CATEGORY_EVENT(new CategoryEventTableDescription()),
+ GET_USERS_LIST_EVENT(new GetUsersListEventTableDesc()),
+ GET_CATEGORY_HIERARCHY_EVENT(new GetCatHierEventTableDesc()),
+ EXTERNAL_API_EVENT(new ExternalApiEventTableDesc()),
+ COMPONENT_CACHE(new ComponentCacheTableDescription()),
+ SDC_SCHEMA_FILES(new SdcSchemaFilesTableDescription()),
+ SDC_REPO(new MigrationTasksTableDescription()),
+ SDC_OPERATIONAL_ENVIRONMENT(new OperationalEnvironmentsTableDescription()),
+ AUDIT_ECOMP_OPERATIONAL_ENVIRONMENT(new EcompOperationalEnvironmentEventTableDesc());
+
ITableDescription tableDescription;
Table(ITableDescription tableDescription) {
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribBaseEventTableDesc.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribBaseEventTableDesc.java
new file mode 100644
index 0000000000..cbd70ca9fe
--- /dev/null
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribBaseEventTableDesc.java
@@ -0,0 +1,76 @@
+package org.openecomp.sdc.be.dao.cassandra.schema.tables;
+
+import com.datastax.driver.core.DataType;
+import org.apache.commons.lang3.tuple.ImmutablePair;
+import org.openecomp.sdc.be.dao.cassandra.schema.ITableDescription;
+import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public abstract class DistribBaseEventTableDesc implements ITableDescription {
+ @Override
+ public List<ImmutablePair<String, DataType>> primaryKeys() {
+ List<ImmutablePair<String, DataType>> keys = new ArrayList<>();
+ keys.add(new ImmutablePair<String, DataType>(TIMEBASED_UUID_FIELD, DataType.timeuuid()));
+ return keys;
+ }
+
+ @Override
+ public List<ImmutablePair<String, DataType>> clusteringKeys() {
+ List<ImmutablePair<String, DataType>> keys = new ArrayList<>();
+ keys.add(new ImmutablePair<String, DataType>(TIMESTAMP_FIELD, DataType.timestamp()));
+ return keys;
+ }
+
+ @Override
+ public String getKeyspace() {
+ return AuditingTypesConstants.AUDIT_KEYSPACE;
+ }
+
+ @Override
+ public Map<String, ImmutablePair<DataType, Boolean>> getColumnDescription() {
+ Map<String, ImmutablePair<DataType, Boolean>> columns = new HashMap<>();
+
+ for (DistFieldsDescription field : DistFieldsDescription.values()) {
+ columns.put(field.getName(), new ImmutablePair<DataType, Boolean>(field.type, field.indexed));
+ }
+ updateColumnDistribDescription(columns);
+ return columns;
+ }
+
+ protected abstract void updateColumnDistribDescription(final Map<String, ImmutablePair<DataType, Boolean>> columns);
+
+
+ enum DistFieldsDescription {
+ ACTION("action", DataType.varchar(), true),
+ STATUS("status", DataType.varchar(), false),
+ DESCRIPTION("description", DataType.varchar(), false),
+ REQUEST_ID("request_id", DataType.varchar(), false),
+ SERVICE_INST_ID("service_instance_id", DataType.varchar(), false);
+
+ private String name;
+ private DataType type;
+ private boolean indexed;
+
+ DistFieldsDescription(String name, DataType type, boolean indexed) {
+ this.name = name;
+ this.type = type;
+ this.indexed = indexed;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public DataType getType() {
+ return type;
+ }
+
+ public boolean isIndexed() {
+ return indexed;
+ }
+ }
+}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribDeployEventTableDesc.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribDeployEventTableDesc.java
index a233110f9e..ceacdeab0e 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribDeployEventTableDesc.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribDeployEventTableDesc.java
@@ -20,61 +20,36 @@
package org.openecomp.sdc.be.dao.cassandra.schema.tables;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.tuple.ImmutablePair;
-import org.openecomp.sdc.be.dao.cassandra.schema.ITableDescription;
import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants;
import com.datastax.driver.core.DataType;
-public class DistribDeployEventTableDesc implements ITableDescription {
+public class DistribDeployEventTableDesc extends DistribBaseEventTableDesc {
- @Override
- public List<ImmutablePair<String, DataType>> primaryKeys() {
- List<ImmutablePair<String, DataType>> keys = new ArrayList<>();
- keys.add(new ImmutablePair<String, DataType>(TIMEBASED_UUID_FIELD, DataType.timeuuid()));
- return keys;
- }
@Override
- public List<ImmutablePair<String, DataType>> clusteringKeys() {
- List<ImmutablePair<String, DataType>> keys = new ArrayList<>();
- keys.add(new ImmutablePair<String, DataType>(TIMESTAMP_FIELD, DataType.timestamp()));
- return keys;
+ public String getTableName() {
+ return AuditingTypesConstants.DISTRIBUTION_DEPLOY_EVENT_TYPE;
}
@Override
- public Map<String, ImmutablePair<DataType, Boolean>> getColumnDescription() {
- Map<String, ImmutablePair<DataType, Boolean>> columns = new HashMap<>();
-
+ protected void updateColumnDistribDescription(Map<String, ImmutablePair<DataType, Boolean>> columns) {
for (DSEFieldsDescription field : DSEFieldsDescription.values()) {
columns.put(field.getName(), new ImmutablePair<DataType, Boolean>(field.type, field.indexed));
}
+ //replace the base indexed flag value with the correct one for a given table:
+ columns.put(DistFieldsDescription.STATUS.getName(),
+ new ImmutablePair<DataType, Boolean>(DistFieldsDescription.STATUS.getType(), true));
+ columns.put(DistFieldsDescription.SERVICE_INST_ID.getName(),
+ new ImmutablePair<DataType, Boolean>(DistFieldsDescription.SERVICE_INST_ID.getType(), true));
- return columns;
- }
-
- @Override
- public String getKeyspace() {
- return AuditingTypesConstants.AUDIT_KEYSPACE;
- }
-
- @Override
- public String getTableName() {
- return AuditingTypesConstants.DISTRIBUTION_DEPLOY_EVENT_TYPE;
- }
+ }
enum DSEFieldsDescription {
- ACTION("action", DataType.varchar(), true),
- STATUS("status", DataType.varchar(), true),
- DESCRIPTION("description", DataType.varchar(), false),
- REQUEST_ID("request_id", DataType.varchar(), false),
- SERVICE_INST_ID("service_instance_id", DataType.varchar(), true),
- MODIFIER("modifier", DataType.varchar(), false),
+ MODIFIER("modifier", DataType.varchar(), false),
CURR_VERSION("curr_version", DataType.varchar(), false),
DID("did", DataType.varchar(), true),
RESOURCE_NAME("resource_name", DataType.varchar(), false),
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribDownloadEventTableDesc.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribDownloadEventTableDesc.java
index 0ac31352f2..61968be9ec 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribDownloadEventTableDesc.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribDownloadEventTableDesc.java
@@ -20,47 +20,20 @@
package org.openecomp.sdc.be.dao.cassandra.schema.tables;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.tuple.ImmutablePair;
-import org.openecomp.sdc.be.dao.cassandra.schema.ITableDescription;
import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants;
import com.datastax.driver.core.DataType;
-public class DistribDownloadEventTableDesc implements ITableDescription {
+public class DistribDownloadEventTableDesc extends DistribBaseEventTableDesc {
@Override
- public List<ImmutablePair<String, DataType>> primaryKeys() {
- List<ImmutablePair<String, DataType>> keys = new ArrayList<>();
- keys.add(new ImmutablePair<String, DataType>(TIMEBASED_UUID_FIELD, DataType.timeuuid()));
- return keys;
- }
-
- @Override
- public List<ImmutablePair<String, DataType>> clusteringKeys() {
- List<ImmutablePair<String, DataType>> keys = new ArrayList<>();
- keys.add(new ImmutablePair<String, DataType>(TIMESTAMP_FIELD, DataType.timestamp()));
- return keys;
- }
-
- @Override
- public Map<String, ImmutablePair<DataType, Boolean>> getColumnDescription() {
- Map<String, ImmutablePair<DataType, Boolean>> columns = new HashMap<>();
-
+ protected void updateColumnDistribDescription(Map<String, ImmutablePair<DataType, Boolean>> columns) {
for (DSEFieldsDescription field : DSEFieldsDescription.values()) {
columns.put(field.getName(), new ImmutablePair<DataType, Boolean>(field.type, field.indexed));
}
-
- return columns;
- }
-
- @Override
- public String getKeyspace() {
- return AuditingTypesConstants.AUDIT_KEYSPACE;
}
@Override
@@ -69,12 +42,7 @@ public class DistribDownloadEventTableDesc implements ITableDescription {
}
enum DSEFieldsDescription {
- REQUEST_ID("request_Id", DataType.varchar(), false),
- SERVICE_INST_ID("service_Instance_Id", DataType.varchar(),false),
- ACTION("action", DataType.varchar(), true),
- STATUS("status", DataType.varchar(), false),
- DESCRIPTION("description", DataType.varchar(), false),
- CONSUMER_ID("consumer_Id", DataType.varchar(), false),
+ CONSUMER_ID("consumer_Id", DataType.varchar(), false),
RESOURCE_URL("resource_URL", DataType.varchar(), false);
private String name;
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribEngineEventTableDesc.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribEngineEventTableDesc.java
index 16d9af084f..5b1aaee04e 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribEngineEventTableDesc.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribEngineEventTableDesc.java
@@ -20,61 +20,34 @@
package org.openecomp.sdc.be.dao.cassandra.schema.tables;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.tuple.ImmutablePair;
-import org.openecomp.sdc.be.dao.cassandra.schema.ITableDescription;
import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants;
import com.datastax.driver.core.DataType;
-public class DistribEngineEventTableDesc implements ITableDescription {
- @Override
- public List<ImmutablePair<String, DataType>> primaryKeys() {
- List<ImmutablePair<String, DataType>> keys = new ArrayList<>();
- keys.add(new ImmutablePair<String, DataType>(TIMEBASED_UUID_FIELD, DataType.timeuuid()));
- return keys;
- }
-
- @Override
- public List<ImmutablePair<String, DataType>> clusteringKeys() {
- List<ImmutablePair<String, DataType>> keys = new ArrayList<>();
- keys.add(new ImmutablePair<String, DataType>(TIMESTAMP_FIELD, DataType.timestamp()));
- return keys;
- }
-
- @Override
- public Map<String, ImmutablePair<DataType, Boolean>> getColumnDescription() {
- Map<String, ImmutablePair<DataType, Boolean>> columns = new HashMap<>();
+public class DistribEngineEventTableDesc extends DistribBaseEventTableDesc {
- for (DEEFieldsDescription field : DEEFieldsDescription.values()) {
- columns.put(field.getName(), new ImmutablePair<DataType, Boolean>(field.type, field.indexed));
- }
-
- return columns;
- }
+ @Override
+ protected void updateColumnDistribDescription(Map<String, ImmutablePair<DataType, Boolean>> columns) {
+ for (DEEFieldsDescription field : DEEFieldsDescription.values()) {
+ columns.put(field.getName(), new ImmutablePair<DataType, Boolean>(field.type, field.indexed));
+ }
+ //replace the base indexed flag value with the correct one for a given table:
+ columns.put(DistFieldsDescription.REQUEST_ID.getName(),
+ new ImmutablePair<DataType, Boolean>(DistFieldsDescription.REQUEST_ID.getType(), true));
+ }
- @Override
- public String getKeyspace() {
- return AuditingTypesConstants.AUDIT_KEYSPACE;
- }
- @Override
+ @Override
public String getTableName() {
return AuditingTypesConstants.DISTRIBUTION_ENGINE_EVENT_TYPE;
}
enum DEEFieldsDescription {
- ACTION("action", DataType.varchar(), true),
- STATUS("status", DataType.varchar(), false),
- DESCRIPTION("description", DataType.varchar(), false),
CONSUMER_ID("consumer_id", DataType.varchar(), false),
- REQUEST_ID("request_id", DataType.varchar(), true),
- SERVICE_INST_ID("service_instance_id", DataType.varchar(), false),
- ROLE("role", DataType.varchar(), false),
+ ROLE("role", DataType.varchar(), false),
D_ENV("d_env", DataType.varchar(), false),
API_KEY("api_key", DataType.varchar(), false),
DSTATUS_TOPIC("dstatus_topic", DataType.varchar(), false),
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribNotifEventTableDesc.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribNotifEventTableDesc.java
index 371b5c4886..7db070f2d5 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribNotifEventTableDesc.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribNotifEventTableDesc.java
@@ -20,46 +20,23 @@
package org.openecomp.sdc.be.dao.cassandra.schema.tables;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.tuple.ImmutablePair;
-import org.openecomp.sdc.be.dao.cassandra.schema.ITableDescription;
import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants;
import com.datastax.driver.core.DataType;
-public class DistribNotifEventTableDesc implements ITableDescription {
- @Override
- public List<ImmutablePair<String, DataType>> primaryKeys() {
- List<ImmutablePair<String, DataType>> keys = new ArrayList<>();
- keys.add(new ImmutablePair<String, DataType>(TIMEBASED_UUID_FIELD, DataType.timeuuid()));
- return keys;
- }
-
- @Override
- public List<ImmutablePair<String, DataType>> clusteringKeys() {
- List<ImmutablePair<String, DataType>> keys = new ArrayList<>();
- keys.add(new ImmutablePair<String, DataType>(TIMESTAMP_FIELD, DataType.timestamp()));
- return keys;
- }
+public class DistribNotifEventTableDesc extends DistribBaseEventTableDesc {
@Override
- public Map<String, ImmutablePair<DataType, Boolean>> getColumnDescription() {
- Map<String, ImmutablePair<DataType, Boolean>> columns = new HashMap<>();
-
+ protected void updateColumnDistribDescription(Map<String, ImmutablePair<DataType, Boolean>> columns) {
for (DNEFieldsDescription field : DNEFieldsDescription.values()) {
columns.put(field.getName(), new ImmutablePair<DataType, Boolean>(field.type, field.indexed));
}
-
- return columns;
- }
-
- @Override
- public String getKeyspace() {
- return AuditingTypesConstants.AUDIT_KEYSPACE;
+ //replace the base indexed flag value with the correct one for a given table:
+ columns.put(DistFieldsDescription.SERVICE_INST_ID.getName(),
+ new ImmutablePair<DataType, Boolean>(DistFieldsDescription.SERVICE_INST_ID.getType(), true));
}
@Override
@@ -68,18 +45,16 @@ public class DistribNotifEventTableDesc implements ITableDescription {
}
enum DNEFieldsDescription {
- ACTION("action", DataType.varchar(), true),
- STATUS("status", DataType.varchar(), false),
- DESCRIPTION("description", DataType.varchar(), false),
- REQUEST_ID("request_id", DataType.varchar(), false),
- SERVICE_INST_ID("service_instance_id", DataType.varchar(), true),
- TOPIC_NAME("topic_name", DataType.varchar(), false),
+ TOPIC_NAME("topic_name", DataType.varchar(), false),
MODIFIER("modifier", DataType.varchar(), false),
CURR_STATE("curr_state", DataType.varchar(), false),
CURR_VERSION("curr_version", DataType.varchar(), false),
DID("did", DataType.varchar(), true),
RESOURCE_NAME("resource_name", DataType.varchar(), false),
- RESOURCE_TYPE("resource_type", DataType.varchar(), false);
+ RESOURCE_TYPE("resource_type", DataType.varchar(), false),
+ ENV_ID("env_id", DataType.varchar(), false),
+ VNF_WORKLOAD_CONTEXT("vnf_workload_context", DataType.varchar(), false),
+ TENANT("tenant", DataType.varchar(), false);
private String name;
private DataType type;
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribStatusEventTableDesc.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribStatusEventTableDesc.java
index fe5bb465c3..bc5dcec41b 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribStatusEventTableDesc.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribStatusEventTableDesc.java
@@ -20,46 +20,20 @@
package org.openecomp.sdc.be.dao.cassandra.schema.tables;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.tuple.ImmutablePair;
-import org.openecomp.sdc.be.dao.cassandra.schema.ITableDescription;
import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants;
import com.datastax.driver.core.DataType;
-public class DistribStatusEventTableDesc implements ITableDescription {
- @Override
- public List<ImmutablePair<String, DataType>> primaryKeys() {
- List<ImmutablePair<String, DataType>> keys = new ArrayList<>();
- keys.add(new ImmutablePair<String, DataType>(TIMEBASED_UUID_FIELD, DataType.timeuuid()));
- return keys;
- }
-
- @Override
- public List<ImmutablePair<String, DataType>> clusteringKeys() {
- List<ImmutablePair<String, DataType>> keys = new ArrayList<>();
- keys.add(new ImmutablePair<String, DataType>(TIMESTAMP_FIELD, DataType.timestamp()));
- return keys;
- }
+public class DistribStatusEventTableDesc extends DistribBaseEventTableDesc{
@Override
- public Map<String, ImmutablePair<DataType, Boolean>> getColumnDescription() {
- Map<String, ImmutablePair<DataType, Boolean>> columns = new HashMap<>();
-
+ protected void updateColumnDistribDescription(Map<String, ImmutablePair<DataType, Boolean>> columns) {
for (DSEFieldsDescription field : DSEFieldsDescription.values()) {
columns.put(field.getName(), new ImmutablePair<DataType, Boolean>(field.type, field.indexed));
}
-
- return columns;
- }
-
- @Override
- public String getKeyspace() {
- return AuditingTypesConstants.AUDIT_KEYSPACE;
}
@Override
@@ -68,15 +42,10 @@ public class DistribStatusEventTableDesc implements ITableDescription {
}
enum DSEFieldsDescription {
- ACTION("action", DataType.varchar(), true),
- STATUS("status", DataType.varchar(), false),
- DESCRIPTION("description", DataType.varchar(), false),
- DID("did", DataType.varchar(), true),
+ DID("did", DataType.varchar(), true),
CONSUMER_ID("consumer_id", DataType.varchar(), false),
- REQUEST_ID("request_id", DataType.varchar(), false),
- RESOURCE_URL("resoure_URL", DataType.varchar(), false),
- SERVICE_INST_ID("service_instance_id", DataType.varchar(), false),
- TOPIC_NAME("topic_name", DataType.varchar(), false),
+ RESOURCE_URL("resoure_URL", DataType.varchar(), false),
+ TOPIC_NAME("topic_name", DataType.varchar(), false),
STATUS_TIME("status_time", DataType.varchar(), false);
private String name;
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/EcompOperationalEnvironmentEventTableDesc.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/EcompOperationalEnvironmentEventTableDesc.java
new file mode 100644
index 0000000000..6c8fcb4991
--- /dev/null
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/EcompOperationalEnvironmentEventTableDesc.java
@@ -0,0 +1,76 @@
+package org.openecomp.sdc.be.dao.cassandra.schema.tables;
+
+import com.datastax.driver.core.DataType;
+import org.apache.commons.lang3.tuple.ImmutablePair;
+import org.openecomp.sdc.be.dao.cassandra.schema.ITableDescription;
+import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants;
+
+import java.util.*;
+
+public class EcompOperationalEnvironmentEventTableDesc implements ITableDescription {
+
+ private static final String OPERATIONAL_ENVIRONMENT_ID = "operational_environment_id";
+
+ @Override
+ public List<ImmutablePair<String, DataType>> primaryKeys() {
+ List<ImmutablePair<String, DataType>> keys = new ArrayList<>();
+ keys.add(new ImmutablePair<String, DataType>(OPERATIONAL_ENVIRONMENT_ID, DataType.varchar()));
+ return keys;
+ }
+
+ @Override
+ public List<ImmutablePair<String, DataType>> clusteringKeys() {
+ List<ImmutablePair<String, DataType>> keys = new ArrayList<>();
+ keys.add(new ImmutablePair<String, DataType>(TIMESTAMP_FIELD, DataType.timestamp()));
+ return keys;
+ }
+
+ @Override
+ public String getKeyspace() {
+ return AuditingTypesConstants.AUDIT_KEYSPACE;
+ }
+
+ @Override
+ public Map<String, ImmutablePair<DataType, Boolean>> getColumnDescription() {
+ Map<String, ImmutablePair<DataType, Boolean>> columns = new HashMap<>();
+
+ Arrays.stream(EcompOpEnvFieldsDescription.values())
+ .forEach(column -> columns.put(column.getName(), ImmutablePair.of(column.getType(), column.isIndexed())));
+ return columns;
+ }
+
+ @Override
+ public String getTableName() {
+ return AuditingTypesConstants.ECOMP_OPERATIONAL_ENV_EVENT_TYPE;
+ }
+
+ enum EcompOpEnvFieldsDescription {
+ ACTION("action", DataType.varchar(), false),
+ OPERATIONAL_ENVIRONMENT_NAME("operational_environment_name", DataType.varchar(), false),
+ OPERATIONAL_ENVIRONMENT_TYPE("operational_environment_type", DataType.varchar(), false),
+ OPERATIONAL_ENVIRONMENT_ACTION("operational_environment_action", DataType.varchar(), false),
+ TENANT_CONTEXT("tenant_context", DataType.varchar(), false);
+
+ private String name;
+ private DataType type;
+ private boolean indexed;
+
+ EcompOpEnvFieldsDescription(String name, DataType type, boolean indexed) {
+ this.name = name;
+ this.type = type;
+ this.indexed = indexed;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public DataType getType() {
+ return type;
+ }
+
+ public boolean isIndexed() {
+ return indexed;
+ }
+ }
+}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/OperationalEnvironmentsTableDescription.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/OperationalEnvironmentsTableDescription.java
new file mode 100644
index 0000000000..f14e50b8aa
--- /dev/null
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/OperationalEnvironmentsTableDescription.java
@@ -0,0 +1,79 @@
+package org.openecomp.sdc.be.dao.cassandra.schema.tables;
+
+import com.datastax.driver.core.DataType;
+import org.apache.commons.lang3.tuple.ImmutablePair;
+import org.openecomp.sdc.be.dao.cassandra.schema.ITableDescription;
+import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants;
+
+import java.util.*;
+
+
+public class OperationalEnvironmentsTableDescription implements ITableDescription {
+
+ private static final String OPERATIONAL_ENVIRONMENT_TABLE = "operationalEnvironment";
+ private static final String ENVIRONMENT_ID = "environment_id";
+
+ @Override
+ public List<ImmutablePair<String, DataType>> primaryKeys() {
+ List<ImmutablePair<String, DataType>> keys = new ArrayList<>();
+ keys.add(new ImmutablePair<String, DataType>( ENVIRONMENT_ID, DataType.varchar()));
+ return keys;
+ }
+
+ @Override
+ public List<ImmutablePair<String, DataType>> clusteringKeys() {
+ return new LinkedList<>();
+ }
+
+ @Override
+ public Map<String, ImmutablePair<DataType, Boolean>> getColumnDescription() {
+ Map<String, ImmutablePair<DataType, Boolean>> columns = new HashMap<>();
+ Arrays.stream(SdcOperationalEnvironmentFieldsDescription.values())
+ .forEach(column -> columns.put(column.getFieldName(), ImmutablePair.of(column.getFieldType(), column.isIndexed())));
+ return columns;
+ }
+
+ @Override
+ public String getKeyspace() {
+ return AuditingTypesConstants.REPO_KEYSPACE;
+ }
+
+ @Override
+ public String getTableName() {
+ return OPERATIONAL_ENVIRONMENT_TABLE;
+ }
+
+ enum SdcOperationalEnvironmentFieldsDescription {
+ //there is also PK field "environmentID"
+ TENANT("tenant", DataType.varchar(), false),
+ IS_PRODUCTION("is_production", DataType.cboolean(), false),
+ ECOMP_WORKLOAD_CONTEXT("ecomp_workload_context", DataType.varchar(), false),
+ DMAAP_UEB_ADDRESS("dmaap_ueb_address", DataType.set(DataType.varchar()), false),
+ UEB_API_KEY("ueb_api_key",DataType.varchar(), false),
+ UEB_SECRET_KEY("ueb_secret_key",DataType.varchar(), false),
+ STATUS("status",DataType.varchar() ,true),
+ LAST_MODIFIED("last_modified",DataType.timestamp() ,false);
+
+ private String fieldName;
+ private boolean isIndexed;
+ private DataType fieldType;
+
+ SdcOperationalEnvironmentFieldsDescription(String fieldName, DataType dataType, boolean indexed ) {
+ this.fieldName = fieldName;
+ this.fieldType = dataType;
+ this.isIndexed = indexed;
+ }
+
+ public String getFieldName() {
+ return fieldName;
+ }
+
+ public boolean isIndexed() {
+ return isIndexed;
+ }
+
+ public DataType getFieldType() {
+ return fieldType;
+ }
+ }
+}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/config/DAOSpringConfig.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/config/DAOSpringConfig.java
index c5f066bb4b..99979bac0c 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/config/DAOSpringConfig.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/config/DAOSpringConfig.java
@@ -20,34 +20,22 @@
package org.openecomp.sdc.be.dao.config;
-import org.openecomp.sdc.be.dao.DAOTitanStrategy;
-import org.openecomp.sdc.be.dao.TitanClientStrategy;
-import org.openecomp.sdc.be.dao.titan.TitanGenericDao;
-import org.openecomp.sdc.be.dao.titan.TitanGraphClient;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.Primary;
+import org.springframework.context.annotation.Import;
@Configuration
+@Import({TitanSpringConfig.class})
+@ComponentScan({
+ "org.openecomp.sdc.be.dao.cassandra",
+ "org.openecomp.sdc.be.dao.neo4j",
+ "org.openecomp.sdc.be.dao.es",
+ "org.openecomp.sdc.be.dao.impl",
+ "org.openecomp.sdc.be.resources.impl"
+ })
public class DAOSpringConfig {
- @Bean(name = "titan-generic-dao")
- @Primary
- public TitanGenericDao titanGenericDao(@Qualifier("titan-client") TitanGraphClient titanGraphClient) {
- return new TitanGenericDao(titanGraphClient);
- }
-
- @Bean(name = "titan-client", initMethod = "createGraph")
- @Primary
- public TitanGraphClient titanGraphClient(@Qualifier("dao-client-strategy") TitanClientStrategy titanClientStrategy) {
- return new TitanGraphClient(titanClientStrategy);
- }
-
- @Bean(name = "dao-client-strategy")
- public TitanClientStrategy titanClientStrategy() {
- return new DAOTitanStrategy();
- }
+
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/config/TitanSpringConfig.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/config/TitanSpringConfig.java
new file mode 100644
index 0000000000..111c63e53c
--- /dev/null
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/config/TitanSpringConfig.java
@@ -0,0 +1,35 @@
+package org.openecomp.sdc.be.dao.config;
+
+import org.openecomp.sdc.be.dao.DAOTitanStrategy;
+import org.openecomp.sdc.be.dao.TitanClientStrategy;
+import org.openecomp.sdc.be.dao.titan.TitanGenericDao;
+import org.openecomp.sdc.be.dao.titan.TitanGraphClient;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Primary;
+
+@Configuration
+@ComponentScan({
+ "org.openecomp.sdc.be.dao.jsongraph",
+})
+public class TitanSpringConfig {
+
+ @Bean(name = "titan-generic-dao")
+ @Primary
+ public TitanGenericDao titanGenericDao(@Qualifier("titan-client") TitanGraphClient titanGraphClient) {
+ return new TitanGenericDao(titanGraphClient);
+ }
+
+ @Bean(name = "titan-client", initMethod = "createGraph")
+ @Primary
+ public TitanGraphClient titanGraphClient(@Qualifier("dao-client-strategy") TitanClientStrategy titanClientStrategy) {
+ return new TitanGraphClient(titanClientStrategy);
+ }
+
+ @Bean(name = "dao-client-strategy")
+ public TitanClientStrategy titanClientStrategy() {
+ return new DAOTitanStrategy();
+ }
+}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/es/ElasticSearchClient.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/es/ElasticSearchClient.java
index 4bc1afc80e..c5d7d68b55 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/es/ElasticSearchClient.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/es/ElasticSearchClient.java
@@ -33,14 +33,10 @@ import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.apache.commons.lang.SystemUtils;
-import org.elasticsearch.action.admin.cluster.health.ClusterHealthAction;
-import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequestBuilder;
-import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
-import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.node.Node;
import org.elasticsearch.node.NodeBuilder;
import org.elasticsearch.shield.ShieldPlugin;
@@ -174,34 +170,6 @@ public class ElasticSearchClient {
return serverPort;
}
- /**
- * Wait for green status for the given indices.
- *
- * @param indices
- * The indices to wait for.
- * @return A {@link ClusterHealthResponse} that contains the cluster health
- * after waiting maximum 5 minutes for green status.
- */
- public ClusterHealthResponse waitForGreenStatus(String... indices) {
- ClusterHealthAction healthAction = ClusterHealthAction.INSTANCE;
-
- ClusterHealthRequestBuilder builder = healthAction.newRequestBuilder(this.client.admin().cluster());
- builder.setIndices(indices);
- builder.setWaitForGreenStatus();
- builder.setTimeout(TimeValue.timeValueSeconds(30));
- ClusterHealthResponse response = builder.execute().actionGet();
- log.debug("getStatus : {}", response.getStatus());
- log.debug("getActivePrimaryShards : {}", response.getActivePrimaryShards());
- log.debug("getActiveShards : {}", response.getActiveShards());
- log.debug("getInitializingShards : {}", response.getInitializingShards());
- log.debug("getNumberOfDataNodes : {}", response.getNumberOfDataNodes());
- log.debug("getNumberOfNodes : {}", response.getNumberOfNodes());
- log.debug("getRelocatingShards : {}", response.getRelocatingShards());
- log.debug("getUnassignedShards : {}", response.getUnassignedShards());
- log.debug("getAllValidationFailures : {}", response.getAllValidationFailures());
- return response;
- }
-
@Value("#{elasticsearchConfig['cluster.name']}")
public void setClusterName(final String clusterName) {
this.clusterName = clusterName;
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/graph/datatype/GraphNode.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/graph/datatype/GraphNode.java
index 5da11cb738..968381d662 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/graph/datatype/GraphNode.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/graph/datatype/GraphNode.java
@@ -20,14 +20,13 @@
package org.openecomp.sdc.be.dao.graph.datatype;
-import java.util.List;
-import java.util.Map;
-
+import com.google.gson.Gson;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import com.google.gson.Gson;
+import java.util.List;
+import java.util.Map;
public abstract class GraphNode extends GraphElement {
@@ -67,7 +66,7 @@ public abstract class GraphNode extends GraphElement {
return GraphPropertiesDictionary.UNIQUE_ID.getProperty();
}
- public abstract Object getUniqueId();
+ public abstract String getUniqueId();
@Override
public String toString() {
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/AuditingDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/AuditingDao.java
index 2cf479ec64..dfa2b3ac4a 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/AuditingDao.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/AuditingDao.java
@@ -92,6 +92,13 @@ public class AuditingDao extends ESTimeBasedDao {
return write(type, auditingGenericEvent);
}
+ public ActionStatus addRecord(AuditingGenericEvent auditEvent, String type) {
+
+ log.debug("Auditing: Persisting object of type {}, fields: {}", type, auditEvent.getAction());
+// auditEvent.fillFields();
+ return write(type, auditEvent);
+ }
+
public Either<List<ESTimeBasedEvent>, ActionStatus> getListOfDistributionStatuses(String did) {
QueryBuilder componentNameMatch = QueryBuilders.matchQuery(DISTRIBUTION_ID_FIELD, did);
@@ -104,10 +111,7 @@ public class AuditingDao extends ESTimeBasedDao {
remainingElements = customFindEvent(AuditingTypesConstants.DISTRIBUTION_STATUS_EVENT_TYPE,
remainingElementQueryBuilder, null);
} catch (Exception e) {
- BeEcompErrorManager.getInstance().processEcompError(EcompErrorName.BeDaoSystemError,
- "Get DistributionStatuses List");
BeEcompErrorManager.getInstance().logBeDaoSystemError("Get DistributionStatuses List");
-
log.debug("failed to get distribution statuses for ", e);
return Either.right(ActionStatus.GENERAL_ERROR);
}
@@ -134,8 +138,6 @@ public class AuditingDao extends ESTimeBasedDao {
remainingElements = customFindEvent(AuditingTypesConstants.RESOURCE_ADMIN_EVENT_TYPE,
remainingElementQueryBuilder, null);
} catch (Exception e) {
- BeEcompErrorManager.getInstance().processEcompError(EcompErrorName.BeDaoSystemError,
- "Get Service DistributionStatuses List");
BeEcompErrorManager.getInstance().logBeDaoSystemError("Get Service DistributionStatuses List");
log.debug("failed to get distribution statuses for action {}",
AuditingActionEnum.DISTRIBUTION_STATE_CHANGE_REQUEST.getName(), e);
@@ -153,8 +155,6 @@ public class AuditingDao extends ESTimeBasedDao {
dResultElements = customFindEvent(AuditingTypesConstants.DISTRIBUTION_DEPLOY_EVENT_TYPE,
remainingElementQueryBuilder, null);
} catch (Exception e) {
- BeEcompErrorManager.getInstance().processEcompError(EcompErrorName.BeDaoSystemError,
- "Get Service DistributionStatuses List");
BeEcompErrorManager.getInstance().logBeDaoSystemError("Get Service DistributionStatuses List");
log.debug("failed to get distribution statuses for action {}",
AuditingActionEnum.DISTRIBUTION_DEPLOY.getName(), e);
@@ -172,8 +172,6 @@ public class AuditingDao extends ESTimeBasedDao {
dNotifyElements = customFindEvent(AuditingTypesConstants.DISTRIBUTION_NOTIFICATION_EVENT_TYPE,
remainingElementQueryBuilder, null);
} catch (Exception e) {
- BeEcompErrorManager.getInstance().processEcompError(EcompErrorName.BeDaoSystemError,
- "Get Service DistributionStatuses List");
BeEcompErrorManager.getInstance().logBeDaoSystemError("Get Service DistributionStatuses List");
log.debug("failed to get distribution statuses for action {}",
AuditingActionEnum.DISTRIBUTION_NOTIFY.getName(), e);
@@ -229,8 +227,6 @@ public class AuditingDao extends ESTimeBasedDao {
remainingElements = customFindEvent(clazz.getSimpleName().toLowerCase(), remainingElementQueryBuilder,
null);
} catch (Exception e) {
- BeEcompErrorManager.getInstance().processEcompError(EcompErrorName.BeDaoSystemError,
- "Get DistributionStatuses List");
BeEcompErrorManager.getInstance().logBeDaoSystemError("Get DistributionStatuses List");
log.debug("failed to get distribution statuses for action {}", actionType, e);
return Either.right(ActionStatus.GENERAL_ERROR);
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/ESCatalogDAO.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/ESCatalogDAO.java
index 0efff500d0..6a2600a3b2 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/ESCatalogDAO.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/ESCatalogDAO.java
@@ -29,7 +29,7 @@ import java.util.concurrent.TimeUnit;
import javax.annotation.PostConstruct;
import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest;
-import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus;
+import org.elasticsearch.cluster.health.ClusterHealthStatus;
import org.elasticsearch.common.unit.TimeValue;
import org.openecomp.sdc.be.config.BeEcompErrorManager;
import org.openecomp.sdc.be.config.ConfigurationManager;
@@ -111,11 +111,8 @@ public class ESCatalogDAO extends ESGenericSearchDAO implements ICatalogDAO {
private void logAlarm() {
if (lastHealthState == HealthCheckStatus.UP) {
- BeEcompErrorManager.getInstance().processEcompError(EcompErrorName.BeHealthCheckRecovery,
- ES_HEALTH_CHECK_STR);
BeEcompErrorManager.getInstance().logBeHealthCheckElasticSearchRecovery(ES_HEALTH_CHECK_STR);
} else {
- BeEcompErrorManager.getInstance().processEcompError(EcompErrorName.BeHealthCheckError, ES_HEALTH_CHECK_STR);
BeEcompErrorManager.getInstance().logBeHealthCheckElasticSearchError(ES_HEALTH_CHECK_STR);
}
}
@@ -148,8 +145,6 @@ public class ESCatalogDAO extends ESGenericSearchDAO implements ICatalogDAO {
resData = findById(getTypeFromClass(ESArtifactData.class), id, ESArtifactData.class);
} catch (Exception e) {
resData = null;
- BeEcompErrorManager.getInstance().processEcompError(EcompErrorName.BeDaoSystemError,
- "Get Artifact from database");
BeEcompErrorManager.getInstance().logBeDaoSystemError("Get Artifact from database");
log.debug("ESCatalogDAO:getArtifact failed with exception ", e);
return Either.right(ResourceUploadStatus.ERROR);
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/GraphVertex.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/GraphVertex.java
index d38e9c03df..c55902a62b 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/GraphVertex.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/GraphVertex.java
@@ -20,10 +20,7 @@
package org.openecomp.sdc.be.dao.jsongraph;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-
+import com.thinkaurelius.titan.core.TitanVertex;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang.StringUtils;
import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
@@ -32,7 +29,9 @@ import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
-import com.thinkaurelius.titan.core.TitanVertex;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
public class GraphVertex {
private String uniqueId;
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/TitanDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/TitanDao.java
index 387b413dd5..27303613ea 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/TitanDao.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/TitanDao.java
@@ -64,860 +64,964 @@ import fj.data.Either;
@Component("titan-dao")
public class TitanDao {
- TitanGraphClient titanClient;
-
- private static Logger logger = LoggerFactory.getLogger(TitanDao.class.getName());
-
- public TitanDao(@Qualifier("titan-client") TitanGraphClient titanClient) {
- this.titanClient = titanClient;
- logger.info("** TitanDao created");
- }
-
- public TitanOperationStatus commit() {
- logger.debug("doing commit.");
- return titanClient.commit();
- }
-
- public TitanOperationStatus rollback() {
- return titanClient.rollback();
- }
-
- public Either<TitanGraph, TitanOperationStatus> getGraph() {
- return titanClient.getGraph();
- }
-
- /**
- *
- * @param graphVertex
- * @return
- */
- public Either<GraphVertex, TitanOperationStatus> createVertex(GraphVertex graphVertex) {
- logger.trace("try to create vertex for ID [{}]", graphVertex.getUniqueId());
- Either<TitanGraph, TitanOperationStatus> graph = titanClient.getGraph();
- if (graph.isLeft()) {
- try {
- TitanGraph tGraph = graph.left().value();
-
- TitanVertex vertex = tGraph.addVertex();
-
- setVertexProperties(vertex, graphVertex);
-
- graphVertex.setVertex(vertex);
-
- return Either.left(graphVertex);
-
- } catch (Exception e) {
- logger.debug("Failed to create Node for ID [{}]", graphVertex.getUniqueId(), e);
- return Either.right(TitanGraphClient.handleTitanException(e));
- }
- } else {
- logger.debug("Failed to create vertex for ID [{}] {}", graphVertex.getUniqueId(), graph.right().value());
- return Either.right(graph.right().value());
- }
- }
-
- /**
- *
- * @param name
- * @param value
- * @param label
- * @return
- */
- public Either<GraphVertex, TitanOperationStatus> getVertexByPropertyAndLabel(GraphPropertyEnum name, Object value, VertexTypeEnum label) {
- return getVertexByPropertyAndLabel(name, value, label, JsonParseFlagEnum.ParseAll);
- }
-
- /**
- *
- * @param name
- * @param value
- * @param label
- * @param parseFlag
- * @return
- */
- public Either<GraphVertex, TitanOperationStatus> getVertexByPropertyAndLabel(GraphPropertyEnum name, Object value, VertexTypeEnum label, JsonParseFlagEnum parseFlag) {
-
- Either<TitanGraph, TitanOperationStatus> graph = titanClient.getGraph();
- if (graph.isLeft()) {
- try {
- TitanGraph tGraph = graph.left().value();
-
- @SuppressWarnings("unchecked")
- Iterable<TitanVertex> vertecies = tGraph.query().has(name.getProperty(), value).has(GraphPropertyEnum.LABEL.getProperty(), label.getName()).vertices();
-
- java.util.Iterator<TitanVertex> iterator = vertecies.iterator();
- if (iterator.hasNext()) {
- TitanVertex vertex = iterator.next();
- GraphVertex graphVertex = createAndFill(vertex, parseFlag);
-
- return Either.left(graphVertex);
- }
- if (logger.isDebugEnabled()) {
- logger.debug("No vertex in graph for key = {} and value = {} label = {}" + name, value, label);
- }
- return Either.right(TitanOperationStatus.NOT_FOUND);
- } catch (Exception e) {
- if (logger.isDebugEnabled()) {
- logger.debug("Failed to get vertex in graph for key ={} and value = {} label = {}", name, value, label);
- }
- return Either.right(TitanGraphClient.handleTitanException(e));
- }
-
- } else {
- if (logger.isDebugEnabled()) {
- logger.debug("No vertex in graph for key ={} and value = {} label = {} error :{}", name, value, label, graph.right().value());
- }
- return Either.right(graph.right().value());
- }
- }
-
- /**
- *
- * @param id
- * @return
- */
- public Either<GraphVertex, TitanOperationStatus> getVertexById(String id) {
- return getVertexById(id, JsonParseFlagEnum.ParseAll);
- }
-
- /**
- *
- * @param id
- * @param parseFlag
- * @return
- */
- public Either<GraphVertex, TitanOperationStatus> getVertexById(String id, JsonParseFlagEnum parseFlag) {
-
- Either<TitanGraph, TitanOperationStatus> graph = titanClient.getGraph();
- if (id == null) {
- if (logger.isDebugEnabled()) {
- logger.debug("No vertex in graph for id = {} ", id);
- }
- return Either.right(TitanOperationStatus.NOT_FOUND);
- }
- if (graph.isLeft()) {
- try {
- TitanGraph tGraph = graph.left().value();
-
- @SuppressWarnings("unchecked")
- Iterable<TitanVertex> vertecies = tGraph.query().has(GraphPropertyEnum.UNIQUE_ID.getProperty(), id).vertices();
-
- java.util.Iterator<TitanVertex> iterator = vertecies.iterator();
- if (iterator.hasNext()) {
- TitanVertex vertex = iterator.next();
- GraphVertex graphVertex = createAndFill(vertex, parseFlag);
- return Either.left(graphVertex);
- } else {
- if (logger.isDebugEnabled()) {
- logger.debug("No vertex in graph for id = {}", id);
- }
- return Either.right(TitanOperationStatus.NOT_FOUND);
- }
- } catch (Exception e) {
- if (logger.isDebugEnabled()) {
- logger.debug("Failed to get vertex in graph for id {} ", id);
- }
- return Either.right(TitanGraphClient.handleTitanException(e));
- }
- } else {
- if (logger.isDebugEnabled()) {
- logger.debug("No vertex in graph for id {} error : {}", id, graph.right().value());
- }
- return Either.right(graph.right().value());
- }
- }
-
- private void setVertexProperties(TitanVertex vertex, GraphVertex graphVertex) throws IOException {
-
- if (graphVertex.getMetadataProperties() != null) {
- for (Map.Entry<GraphPropertyEnum, Object> entry : graphVertex.getMetadataProperties().entrySet()) {
- if (entry.getValue() != null) {
- vertex.property(entry.getKey().getProperty(), entry.getValue());
- }
- }
- }
- vertex.property(GraphPropertyEnum.LABEL.getProperty(), graphVertex.getLabel().getName());
-
- Map<String, ? extends ToscaDataDefinition> json = graphVertex.getJson();
- if (json != null) {
- String jsonStr = JsonParserUtils.jsonToString(json);
- vertex.property(GraphPropertyEnum.JSON.getProperty(), jsonStr);
-
- }
- Map<String, Object> jsonMetadata = graphVertex.getMetadataJson();
- if (jsonMetadata != null) {
- String jsonMetadataStr = JsonParserUtils.jsonToString(jsonMetadata);
- vertex.property(GraphPropertyEnum.METADATA.getProperty(), jsonMetadataStr);
- }
- }
-
- public void setVertexProperties(Vertex vertex, Map<String, Object> properties) throws IOException {
- for (Map.Entry<String, Object> entry : properties.entrySet()) {
- if (entry.getValue() != null) {
- vertex.property(entry.getKey(), entry.getValue());
- }
- }
- }
-
- private GraphVertex createAndFill(TitanVertex vertex, JsonParseFlagEnum parseFlag) {
- GraphVertex graphVertex = new GraphVertex();
- graphVertex.setVertex(vertex);
- parseVertexProperties(graphVertex, parseFlag);
- return graphVertex;
- }
-
- public void parseVertexProperties(GraphVertex graphVertex, JsonParseFlagEnum parseFlag ) {
- TitanVertex vertex = graphVertex.getVertex();
- Map<GraphPropertyEnum, Object> properties = getVertexProperties(vertex);
- VertexTypeEnum label = VertexTypeEnum.getByName((String) (properties.get(GraphPropertyEnum.LABEL)));
- for (Map.Entry<GraphPropertyEnum, Object> entry : properties.entrySet()) {
- GraphPropertyEnum key = entry.getKey();
- switch (key) {
- case UNIQUE_ID:
- graphVertex.setUniqueId((String) entry.getValue());
- break;
- case LABEL:
- graphVertex.setLabel(VertexTypeEnum.getByName((String) entry.getValue()));
- break;
- case COMPONENT_TYPE:
- String type = (String) entry.getValue();
- if (type != null) {
- graphVertex.setType(ComponentTypeEnum.valueOf(type));
- }
- break;
- case JSON:
- if (parseFlag == JsonParseFlagEnum.ParseAll || parseFlag == JsonParseFlagEnum.ParseJson) {
- String json = (String) entry.getValue();
- Map<String, ? extends ToscaDataDefinition> jsonObj = JsonParserUtils.parseToJson(json, label.getClassOfJson());
- graphVertex.setJson(jsonObj);
- }
- break;
- case METADATA:
- if (parseFlag == JsonParseFlagEnum.ParseAll || parseFlag == JsonParseFlagEnum.ParseMetadata) {
- String json = (String) entry.getValue();
- Map<String, Object> metadatObj = JsonParserUtils.parseToJson(json);
- graphVertex.setMetadataJson(metadatObj);
- }
- break;
- default:
- graphVertex.addMetadataProperty(key, entry.getValue());
- break;
- }
- }
- }
-
- public TitanOperationStatus createEdge(GraphVertex from, GraphVertex to, EdgeLabelEnum label, Map<EdgePropertyEnum, Object> properties) {
- return createEdge(from.getVertex(), to.getVertex(), label, properties);
- }
-
- public TitanOperationStatus createEdge(Vertex from, Vertex to, EdgeLabelEnum label, Map<EdgePropertyEnum, Object> properties) {
- if (logger.isTraceEnabled()) {
- logger.trace("Try to connect {} with {} label {} properties {}", from.property(GraphPropertyEnum.UNIQUE_ID.getProperty()), to.property(GraphPropertyEnum.UNIQUE_ID.getProperty()), label, properties);
- }
- if (from == null || to == null) {
- logger.trace("No Titan vertex for id from {} or id to {}", from.property(GraphPropertyEnum.UNIQUE_ID.getProperty()), to.property(GraphPropertyEnum.UNIQUE_ID.getProperty()));
- return TitanOperationStatus.NOT_FOUND;
- }
- Edge edge = from.addEdge(label.name(), to);
- setEdgeProperties(edge, properties);
- return TitanOperationStatus.OK;
- }
-
- public Map<GraphPropertyEnum, Object> getVertexProperties(Element element) {
-
- Map<GraphPropertyEnum, Object> result = new HashMap<GraphPropertyEnum, Object>();
-
- if (element != null && element.keys() != null && element.keys().size() > 0) {
- Map<String, Property> propertyMap = ElementHelper.propertyMap(element, element.keys().toArray(new String[element.keys().size()]));
-
- for (Entry<String, Property> entry : propertyMap.entrySet()) {
- String key = entry.getKey();
- Object value = entry.getValue().value();
-
- GraphPropertyEnum valueOf = GraphPropertyEnum.getByProperty(key);
- if (valueOf != null) {
- result.put(valueOf, value);
- }
- }
- }
- return result;
- }
-
- public Map<EdgePropertyEnum, Object> getEdgeProperties(Element element) {
-
- Map<EdgePropertyEnum, Object> result = new HashMap<EdgePropertyEnum, Object>();
-
- if (element != null && element.keys() != null && element.keys().size() > 0) {
- Map<String, Property> propertyMap = ElementHelper.propertyMap(element, element.keys().toArray(new String[element.keys().size()]));
-
- for (Entry<String, Property> entry : propertyMap.entrySet()) {
- String key = entry.getKey();
- Object value = entry.getValue().value();
-
- EdgePropertyEnum valueOf = EdgePropertyEnum.getByProperty(key);
- if (valueOf != null) {
- result.put(valueOf, value);
- }
- }
- }
- return result;
- }
-
- public void setEdgeProperties(Element element, Map<EdgePropertyEnum, Object> properties) {
-
- if (properties != null && !properties.isEmpty()) {
-
- Object[] propertyKeyValues = new Object[properties.size() * 2];
- int i = 0;
- for (Entry<EdgePropertyEnum, Object> entry : properties.entrySet()) {
- propertyKeyValues[i++] = entry.getKey().getProperty();
- propertyKeyValues[i++] = entry.getValue();
- }
-
- ElementHelper.attachProperties(element, propertyKeyValues);
-
- }
-
- }
-
- public Either<List<GraphVertex>, TitanOperationStatus> getByCriteria(VertexTypeEnum type, Map<GraphPropertyEnum, Object> props) {
- return getByCriteria(type, props, JsonParseFlagEnum.ParseAll);
- }
-
- public Either<List<GraphVertex>, TitanOperationStatus> getByCriteria(VertexTypeEnum type, Map<GraphPropertyEnum, Object> props, JsonParseFlagEnum parseFlag) {
- Either<TitanGraph, TitanOperationStatus> graph = titanClient.getGraph();
- if (graph.isLeft()) {
- try {
- TitanGraph tGraph = graph.left().value();
-
- TitanGraphQuery<? extends TitanGraphQuery> query = tGraph.query();
- if (type != null) {
- query = query.has(GraphPropertyEnum.LABEL.getProperty(), type.getName());
- }
-
- if (props != null && !props.isEmpty()) {
- for (Map.Entry<GraphPropertyEnum, Object> entry : props.entrySet()) {
- query = query.has(entry.getKey().getProperty(), entry.getValue());
- }
- }
- Iterable<TitanVertex> vertices = query.vertices();
- if (vertices == null) {
- return Either.right(TitanOperationStatus.NOT_FOUND);
- }
-
- Iterator<TitanVertex> iterator = vertices.iterator();
- List<GraphVertex> result = new ArrayList<GraphVertex>();
-
- while (iterator.hasNext()) {
- TitanVertex vertex = iterator.next();
-
- Map<GraphPropertyEnum, Object> newProp = getVertexProperties(vertex);
- GraphVertex graphVertex = createAndFill(vertex, parseFlag);
-
- result.add(graphVertex);
- }
- if (logger.isDebugEnabled()) {
- logger.debug("Number of fetced nodes in graph for criteria : from type = {} and properties = {} is {}", type, props, result.size());
- }
- if (result.size() == 0) {
- return Either.right(TitanOperationStatus.NOT_FOUND);
- }
-
- return Either.left(result);
- } catch (Exception e) {
- if (logger.isDebugEnabled()) {
- logger.debug("Failed get by criteria for type = {} and properties = {}", type, props, e);
- }
- return Either.right(TitanGraphClient.handleTitanException(e));
- }
-
- } else {
- if (logger.isDebugEnabled()) {
- logger.debug("Failed get by criteria for type ={} and properties = {} error : {}", type, props, graph.right().value());
- }
- return Either.right(graph.right().value());
- }
- }
- public Either<List<GraphVertex>, TitanOperationStatus> getByCriteria(VertexTypeEnum type, Map<GraphPropertyEnum, Object> props, Map<GraphPropertyEnum, Object> hasNotProps, JsonParseFlagEnum parseFlag) {
- Either<TitanGraph, TitanOperationStatus> graph = titanClient.getGraph();
- if (graph.isLeft()) {
- try {
- TitanGraph tGraph = graph.left().value();
-
- TitanGraphQuery<? extends TitanGraphQuery> query = tGraph.query();
- if (type != null) {
- query = query.has(GraphPropertyEnum.LABEL.getProperty(), type.getName());
- }
-
- if (props != null && !props.isEmpty()) {
- for (Map.Entry<GraphPropertyEnum, Object> entry : props.entrySet()) {
- query = query.has(entry.getKey().getProperty(), entry.getValue());
- }
- }
- if (hasNotProps != null && !hasNotProps.isEmpty()) {
- for (Map.Entry<GraphPropertyEnum, Object> entry : hasNotProps.entrySet()) {
- if(entry.getValue() instanceof List){
- buildMultipleNegateQueryFromList(entry, query);
- }else{
- query = query.hasNot(entry.getKey().getProperty(), entry.getValue());
- }
- }
- }
- Iterable<TitanVertex> vertices = query.vertices();
- if (vertices == null) {
- return Either.right(TitanOperationStatus.NOT_FOUND);
- }
-
- Iterator<TitanVertex> iterator = vertices.iterator();
- List<GraphVertex> result = new ArrayList<GraphVertex>();
-
- while (iterator.hasNext()) {
- TitanVertex vertex = iterator.next();
-
- Map<GraphPropertyEnum, Object> newProp = getVertexProperties(vertex);
- GraphVertex graphVertex = createAndFill(vertex, parseFlag);
-
- result.add(graphVertex);
- }
- if (logger.isDebugEnabled()) {
- logger.debug("Number of fetced nodes in graph for criteria : from type = {} and properties = {} is {}", type, props, result.size());
- }
- if (result.size() == 0) {
- return Either.right(TitanOperationStatus.NOT_FOUND);
- }
-
- return Either.left(result);
- } catch (Exception e) {
- if (logger.isDebugEnabled()) {
- logger.debug("Failed get by criteria for type = {} and properties = {}", type, props, e);
- }
- return Either.right(TitanGraphClient.handleTitanException(e));
- }
-
- } else {
- if (logger.isDebugEnabled()) {
- logger.debug("Failed get by criteria for type ={} and properties = {} error : {}", type, props, graph.right().value());
- }
- return Either.right(graph.right().value());
- }
- }
-
-
-
- private void buildMultipleNegateQueryFromList(Map.Entry<GraphPropertyEnum, Object> entry, TitanGraphQuery query){
- List<Object> negateList = (List<Object>) entry.getValue();
- for (Object listItem : negateList) {
- query.hasNot(entry.getKey().getProperty(), listItem);
- }
- }
-
-
- /**
- *
- * @param parentVertex
- * @param edgeLabel
- * @param parseFlag
- * @return
- */
- public Either<GraphVertex, TitanOperationStatus> getChildVertex(GraphVertex parentVertex, EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag) {
- Either<List<GraphVertex>, TitanOperationStatus> childrenVertecies = getChildrenVertecies(parentVertex, edgeLabel, parseFlag);
- if (childrenVertecies.isRight()) {
- return Either.right(childrenVertecies.right().value());
- }
- return Either.left(childrenVertecies.left().value().get(0));
- }
-
- public Either<GraphVertex, TitanOperationStatus> getParentVertex(GraphVertex parentVertex, EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag) {
- Either<List<GraphVertex>, TitanOperationStatus> childrenVertecies = getParentVertecies(parentVertex, edgeLabel, parseFlag);
- if (childrenVertecies.isRight()) {
- return Either.right(childrenVertecies.right().value());
- }
- return Either.left(childrenVertecies.left().value().get(0));
- }
-
- /**
- *
- * @param parentVertex
- * @param edgeLabel
- * @param parseFlag
- * @return
- */
- public Either<List<GraphVertex>, TitanOperationStatus> getChildrenVertecies(GraphVertex parentVertex, EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag) {
- return getAdjacentVerticies(parentVertex, edgeLabel, parseFlag, Direction.OUT);
- }
-
- public Either<List<GraphVertex>, TitanOperationStatus> getParentVertecies(GraphVertex parentVertex, EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag) {
- return getAdjacentVerticies(parentVertex, edgeLabel, parseFlag, Direction.IN);
- }
-
- private Either<List<GraphVertex>, TitanOperationStatus> getAdjacentVerticies(GraphVertex parentVertex, EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag, Direction direction) {
- List<GraphVertex> list = new ArrayList<GraphVertex>();
-
- try {
- Either<TitanGraph, TitanOperationStatus> graphRes = titanClient.getGraph();
- if (graphRes.isRight()) {
- logger.error("Failed to retrieve graph. status is {}", graphRes);
- return Either.right(graphRes.right().value());
- }
- Iterator<Edge> edgesCreatorIterator = parentVertex.getVertex().edges(direction, edgeLabel.name());
- if (edgesCreatorIterator != null) {
- while (edgesCreatorIterator.hasNext()) {
- Edge edge = edgesCreatorIterator.next();
- TitanVertex vertex;
- if (direction == Direction.IN) {
- vertex = (TitanVertex) edge.outVertex();
- } else {
- vertex = (TitanVertex) edge.inVertex();
- }
- GraphVertex graphVertex = createAndFill(vertex, parseFlag);
-
- list.add(graphVertex);
- }
- }
- if (true == list.isEmpty()) {
- return Either.right(TitanOperationStatus.NOT_FOUND);
- }
- } catch (Exception e) {
- logger.error("Failed to perform graph operation ", e);
- Either.right(TitanGraphClient.handleTitanException(e));
- }
-
- return Either.left(list);
- }
-
- /**
- * Searches Edge by received label and criteria
- *
- * @param vertex
- * @param label
- * @param properties
- * @return found edge or TitanOperationStatus
- */
- public Either<Edge, TitanOperationStatus> getBelongingEdgeByCriteria(GraphVertex vertex, EdgeLabelEnum label, Map<GraphPropertyEnum, Object> properties) {
-
- Either<Edge, TitanOperationStatus> result = null;
- Edge matchingEdge = null;
- String notFoundMsg = "No edges in graph for criteria";
- try {
- TitanVertexQuery<?> query = vertex.getVertex().query().labels(label.name());
-
- if (properties != null && !properties.isEmpty()) {
- for (Map.Entry<GraphPropertyEnum, Object> entry : properties.entrySet()) {
- query = query.has(entry.getKey().getProperty(), entry.getValue());
- }
- }
-
- Iterable<TitanEdge> edges = query.edges();
- if (edges == null) {
- CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, notFoundMsg);
- result = Either.right(TitanOperationStatus.NOT_FOUND);
- } else {
- Iterator<TitanEdge> eIter = edges.iterator();
- if (eIter.hasNext()) {
- matchingEdge = eIter.next();
- } else {
- CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, notFoundMsg);
- result = Either.right(TitanOperationStatus.NOT_FOUND);
- }
- }
- if (result == null) {
- result = Either.left(matchingEdge);
- }
- } catch (Exception e) {
- CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Exception occured during getting edge by criteria for component with id {}. {}", vertex.getUniqueId(), e);
- return Either.right(TitanGraphClient.handleTitanException(e));
- }
- return result;
- }
-
- /**
- * Deletes Edge by received label and criteria
- *
- * @param vertex
- * @param label
- * @param properties
- * @return
- */
- public Either<Edge, TitanOperationStatus> deleteBelongingEdgeByCriteria(GraphVertex vertex, EdgeLabelEnum label, Map<GraphPropertyEnum, Object> properties) {
- Either<Edge, TitanOperationStatus> result = null;
- try {
- result = getBelongingEdgeByCriteria(vertex, label, properties);
- if (result.isLeft()) {
- Edge edge = result.left().value();
- CommonUtility.addRecordToLog(logger, LogLevelEnum.TRACE, "Going to delete an edge with the label {} belonging to the vertex {} ", label.name(), vertex.getUniqueId());
- edge.remove();
- result = Either.left(edge);
- } else {
- CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to find an edge with the label {} belonging to the vertex {} ", label.name(), vertex.getUniqueId());
- }
- } catch (Exception e) {
- CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Exception occured during deleting an edge by criteria for the component with id {}. {}", vertex.getUniqueId(), e);
- return Either.right(TitanGraphClient.handleTitanException(e));
- }
- return result;
- }
-
- @SuppressWarnings("unchecked")
- /**
- * Deletes an edge between vertices fromVertex and toVertex according to received label
- *
- * @param fromVertex
- * @param toVertex
- * @param label
- * @return
- */
- public Either<Edge, TitanOperationStatus> deleteEdge(GraphVertex fromVertex, GraphVertex toVertex, EdgeLabelEnum label) {
- Either<Edge, TitanOperationStatus> result = null;
- try {
- Iterable<TitanEdge> edges = fromVertex.getVertex().query().labels(label.name()).edges();
- Iterator<TitanEdge> eIter = edges.iterator();
- while (eIter.hasNext()) {
- Edge edge = eIter.next();
- String currVertexUniqueId = edge.inVertex().value(GraphPropertyEnum.UNIQUE_ID.getProperty());
- if (currVertexUniqueId != null && currVertexUniqueId.equals(toVertex.getUniqueId())) {
- CommonUtility.addRecordToLog(logger, LogLevelEnum.TRACE, "Going to delete an edge with the label {} between vertices {} and {}. ", label.name(), fromVertex.getUniqueId(), toVertex.getUniqueId());
- edge.remove();
- result = Either.left(edge);
- break;
- }
- }
- if (result == null) {
- CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to delete an edge with the label {} between vertices {} and {}. ", label.name(), fromVertex.getUniqueId(), toVertex.getUniqueId());
- result = Either.right(TitanOperationStatus.NOT_FOUND);
- }
- } catch (Exception e) {
- CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Exception occured during deleting an edge with the label {} between vertices {} and {}. {}", label.name(), fromVertex.getUniqueId(), toVertex.getUniqueId(), e);
- return Either.right(TitanGraphClient.handleTitanException(e));
- }
- return result;
- }
-
- public TitanOperationStatus deleteEdgeByDirection(GraphVertex fromVertex, Direction direction, EdgeLabelEnum label) {
- try {
- Iterator<Edge> edges = fromVertex.getVertex().edges(direction, label.name());
-
- while (edges.hasNext()) {
- Edge edge = edges.next();
- edge.remove();
- }
- } catch (Exception e) {
- logger.debug("Failed to remove from vertex {} edges {} by direction {} ", fromVertex.getUniqueId(), label, direction, e);
- return TitanGraphClient.handleTitanException(e);
- }
- return TitanOperationStatus.OK;
- }
-
- /**
- * Updates vertex properties. Note that graphVertex argument should contain updated data
- *
- * @param graphVertex
- * @return
- */
- public Either<GraphVertex, TitanOperationStatus> updateVertex(GraphVertex graphVertex) {
- CommonUtility.addRecordToLog(logger, LogLevelEnum.TRACE, "Going to update metadata of vertex with uniqueId {}. ", graphVertex.getUniqueId());
- try {
- graphVertex.updateMetadataJsonWithCurrentMetadataProperties();
- setVertexProperties(graphVertex.getVertex(), graphVertex);
-
- } catch (Exception e) {
- CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to update metadata of vertex with uniqueId {}. ", graphVertex.getUniqueId(), e);
- return Either.right(TitanGraphClient.handleTitanException(e));
- }
- return Either.left(graphVertex);
- }
-
- /**
- * Fetches vertices by uniqueId according to received parse flag
- *
- * @param verticesToGet
- * @return
- */
- public Either<Map<String, GraphVertex>, TitanOperationStatus> getVerticesByUniqueIdAndParseFlag(Map<String, ImmutablePair<GraphPropertyEnum, JsonParseFlagEnum>> verticesToGet) {
-
- Either<Map<String, GraphVertex>, TitanOperationStatus> result = null;
- Map<String, GraphVertex> vertices = new HashMap<>();
- TitanOperationStatus titatStatus;
- Either<GraphVertex, TitanOperationStatus> getVertexRes = null;
- for (Map.Entry<String, ImmutablePair<GraphPropertyEnum, JsonParseFlagEnum>> entry : verticesToGet.entrySet()) {
- if (entry.getValue().getKey() == GraphPropertyEnum.UNIQUE_ID) {
- getVertexRes = getVertexById(entry.getKey(), entry.getValue().getValue());
- } else if (entry.getValue().getKey() == GraphPropertyEnum.USERID) {
- getVertexRes = getVertexByPropertyAndLabel(entry.getValue().getKey(), entry.getKey(), VertexTypeEnum.USER, entry.getValue().getValue());
- }
- if (getVertexRes == null) {
- titatStatus = TitanOperationStatus.ILLEGAL_ARGUMENT;
- CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Invalid vertex type label {} has been received. ", entry.getValue().getKey(), titatStatus);
- result = Either.right(titatStatus);
- }
- if (getVertexRes.isRight()) {
- titatStatus = getVertexRes.right().value();
- CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to get vertex by id {} . Status is {}. ", entry.getKey(), titatStatus);
- result = Either.right(titatStatus);
- break;
- } else {
- vertices.put(entry.getKey(), getVertexRes.left().value());
- }
- }
- if (result == null) {
- result = Either.left(vertices);
- }
- return result;
- }
-
- /**
- * Creates edge between "from" and "to" vertices with specified label and properties extracted from received edge
- *
- * @param from
- * @param to
- * @param label
- * @param edgeToCopy
- * @return
- */
- public TitanOperationStatus createEdge(Vertex from, Vertex to, EdgeLabelEnum label, Edge edgeToCopy) {
- return createEdge(from, to, label, getEdgeProperties(edgeToCopy));
- }
-
- public TitanOperationStatus replaceEdgeLabel(Vertex fromVertex, Vertex toVertex, Edge prevEdge, EdgeLabelEnum prevLabel, EdgeLabelEnum newLabel) {
-
- CommonUtility.addRecordToLog(logger, LogLevelEnum.TRACE, "Going to replace edge with label {} to {} between vertices {} and {}", prevLabel, newLabel, fromVertex.property(GraphPropertyEnum.UNIQUE_ID.getProperty()),
- toVertex.property(GraphPropertyEnum.UNIQUE_ID.getProperty()));
- TitanOperationStatus result = createEdge(fromVertex, toVertex, newLabel, prevEdge);
- if (result == TitanOperationStatus.OK) {
- prevEdge.remove();
- }
- return result;
- }
-
- /**
- * Replaces previous label of edge with new label
- *
- * @param fromVertex
- * @param toVertex
- * @param prevLabel
- * @param newLabel
- * @return
- */
- public TitanOperationStatus replaceEdgeLabel(Vertex fromVertex, Vertex toVertex, EdgeLabelEnum prevLabel, EdgeLabelEnum newLabel) {
-
- TitanOperationStatus result = null;
- Iterator<Edge> prevEdgeIter = toVertex.edges(Direction.IN, prevLabel.name());
- if (prevEdgeIter == null || !prevEdgeIter.hasNext()) {
- CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to replace edge with label {} to {} between vertices {} and {}", prevLabel, newLabel, fromVertex.property(GraphPropertyEnum.UNIQUE_ID.getProperty()),
- toVertex.property(GraphPropertyEnum.UNIQUE_ID.getProperty()));
- result = TitanOperationStatus.NOT_FOUND;
- }
- if (result == null) {
- result = replaceEdgeLabel(fromVertex, toVertex, prevEdgeIter.next(), prevLabel, newLabel);
- }
- return result;
- }
-
- /**
- * Updates metadata properties of vertex on graph. Json metadata property of the vertex will be updated with received properties too.
- *
- *
- * @param vertex
- * @param properties
- * @return
- */
- public TitanOperationStatus updateVertexMetadataPropertiesWithJson(Vertex vertex, Map<GraphPropertyEnum, Object> properties) {
- try {
- if (!MapUtils.isEmpty(properties)) {
- String jsonMetadataStr = (String) vertex.property(GraphPropertyEnum.METADATA.getProperty()).value();
- Map<String, Object> jsonMetadataMap = JsonParserUtils.parseToJson(jsonMetadataStr);
- for (Map.Entry<GraphPropertyEnum, Object> property : properties.entrySet()) {
- vertex.property(property.getKey().getProperty(), property.getValue());
- jsonMetadataMap.put(property.getKey().getProperty(), property.getValue());
- }
- vertex.property(GraphPropertyEnum.METADATA.getProperty(), JsonParserUtils.jsonToString(jsonMetadataMap));
- }
- } catch (Exception e) {
- CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Exception occured during update vertex metadata properties with json{}. {}", vertex.property(GraphPropertyEnum.UNIQUE_ID.getProperty()), e.getMessage());
- return TitanGraphClient.handleTitanException(e);
- }
- return TitanOperationStatus.OK;
- }
-
- public TitanOperationStatus disassociateAndDeleteLast(GraphVertex vertex, Direction direction, EdgeLabelEnum label) {
- try {
- Iterator<Edge> edges = vertex.getVertex().edges(direction, label.name());
-
- while (edges.hasNext()) {
- Edge edge = edges.next();
- Vertex secondVertex;
- Direction reverseDirection;
- if (direction == Direction.IN) {
- secondVertex = edge.outVertex();
- reverseDirection = Direction.OUT;
- } else {
- secondVertex = edge.inVertex();
- reverseDirection = Direction.IN;
- }
- edge.remove();
- CommonUtility.addRecordToLog(logger, LogLevelEnum.TRACE, "Edge {} with direction {} was removed from {}", label.name(), direction, vertex.getVertex());
-
- Iterator<Edge> restOfEdges = secondVertex.edges(reverseDirection, label.name());
- if (restOfEdges.hasNext() == false) {
- secondVertex.remove();
- CommonUtility.addRecordToLog(logger, LogLevelEnum.TRACE, "This was last edge . Vertex {} was removed ", vertex.getUniqueId());
- }
- }
- } catch (Exception e) {
- CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Exception occured during deleting an edge with the label {} direction {} from vertex {}. {}", label.name(), direction, vertex.getUniqueId(), e);
- return TitanGraphClient.handleTitanException(e);
- }
- return TitanOperationStatus.OK;
- }
-
- public Object getProperty(TitanVertex vertex, String key) {
- PropertyKey propertyKey = titanClient.getGraph().left().value().getPropertyKey(key);
- Object value = vertex.valueOrNull(propertyKey);
- return value;
- }
-
- public Object getProperty(Edge edge, EdgePropertyEnum key) {
- Object value = null;
- try {
- Property<Object> property = edge.property(key.getProperty());
- if (property != null) {
- return property.orElse(null);
- }
- } catch (Exception e) {
-
- }
- return value;
- }
- /**
- *
- * @param vertexA
- * @param vertexB
- * @param label
- * @param direction
- * @return
- */
- public TitanOperationStatus moveEdge(GraphVertex vertexA, GraphVertex vertexB, EdgeLabelEnum label, Direction direction) {
- TitanOperationStatus result = deleteEdgeByDirection(vertexA, direction, label);
- if ( result != TitanOperationStatus.OK ){
- logger.error("Failed to diassociate {} from element {}. error {} ", label, vertexA.getUniqueId(), result);
- return result;
- }
- TitanOperationStatus createRelation;
- if (direction == Direction.IN ){
- createRelation = createEdge(vertexB, vertexA, label, null);
- }else{
- createRelation = createEdge(vertexA, vertexB, label, null);
- }
- if (createRelation != TitanOperationStatus.OK) {
- return createRelation;
- }
- return TitanOperationStatus.OK;
- }
-
- public Either<Edge, TitanOperationStatus> getBelongingEdgeByCriteria(String parentId, EdgeLabelEnum label, Map<GraphPropertyEnum, Object> properties) {
- Either<GraphVertex, TitanOperationStatus> getVertexRes = getVertexById(parentId, JsonParseFlagEnum.NoParse);
- if(getVertexRes.isRight()){
- return Either.right(getVertexRes.right().value());
- }
- return getBelongingEdgeByCriteria(getVertexRes.left().value(), label, properties);
- }
+ TitanGraphClient titanClient;
+
+ private static Logger logger = LoggerFactory.getLogger(TitanDao.class.getName());
+
+ public TitanDao(@Qualifier("titan-client") TitanGraphClient titanClient) {
+ this.titanClient = titanClient;
+ logger.info("** TitanDao created");
+ }
+
+ public TitanOperationStatus commit() {
+ logger.debug("doing commit.");
+ return titanClient.commit();
+ }
+
+ public TitanOperationStatus rollback() {
+ return titanClient.rollback();
+ }
+
+ public Either<TitanGraph, TitanOperationStatus> getGraph() {
+ return titanClient.getGraph();
+ }
+
+ /**
+ *
+ * @param graphVertex
+ * @return
+ */
+ public Either<GraphVertex, TitanOperationStatus> createVertex(GraphVertex graphVertex) {
+ logger.trace("try to create vertex for ID [{}]", graphVertex.getUniqueId());
+ Either<TitanGraph, TitanOperationStatus> graph = titanClient.getGraph();
+ if (graph.isLeft()) {
+ try {
+ TitanGraph tGraph = graph.left().value();
+
+ TitanVertex vertex = tGraph.addVertex();
+
+ setVertexProperties(vertex, graphVertex);
+
+ graphVertex.setVertex(vertex);
+
+ return Either.left(graphVertex);
+
+ } catch (Exception e) {
+ logger.debug("Failed to create Node for ID [{}]", graphVertex.getUniqueId(), e);
+ return Either.right(TitanGraphClient.handleTitanException(e));
+ }
+ } else {
+ logger.debug("Failed to create vertex for ID [{}] {}", graphVertex.getUniqueId(), graph.right().value());
+ return Either.right(graph.right().value());
+ }
+ }
+
+ /**
+ *
+ * @param name
+ * @param value
+ * @param label
+ * @return
+ */
+ public Either<GraphVertex, TitanOperationStatus> getVertexByPropertyAndLabel(GraphPropertyEnum name, Object value, VertexTypeEnum label) {
+ return getVertexByPropertyAndLabel(name, value, label, JsonParseFlagEnum.ParseAll);
+ }
+
+ public Either<GraphVertex, TitanOperationStatus> getVertexByLabel(VertexTypeEnum label) {
+ return titanClient.getGraph().left().map(graph -> graph.query().has(GraphPropertyEnum.LABEL.getProperty(), label.getName()).vertices()).left().bind(titanVertices -> getFirstFoundVertex(JsonParseFlagEnum.NoParse, titanVertices));
+ }
+
+ private Either<GraphVertex, TitanOperationStatus> getFirstFoundVertex(JsonParseFlagEnum parseFlag, Iterable<TitanVertex> vertices) {
+ Iterator<TitanVertex> iterator = vertices.iterator();
+ if (iterator.hasNext()) {
+ TitanVertex vertex = iterator.next();
+ GraphVertex graphVertex = createAndFill(vertex, parseFlag);
+
+ return Either.left(graphVertex);
+ }
+ return Either.right(TitanOperationStatus.NOT_FOUND);
+ }
+
+ /**
+ *
+ * @param name
+ * @param value
+ * @param label
+ * @param parseFlag
+ * @return
+ */
+ public Either<GraphVertex, TitanOperationStatus> getVertexByPropertyAndLabel(GraphPropertyEnum name, Object value, VertexTypeEnum label, JsonParseFlagEnum parseFlag) {
+
+ Either<TitanGraph, TitanOperationStatus> graph = titanClient.getGraph();
+ if (graph.isLeft()) {
+ try {
+ TitanGraph tGraph = graph.left().value();
+
+ @SuppressWarnings("unchecked")
+ Iterable<TitanVertex> vertecies = tGraph.query().has(name.getProperty(), value).has(GraphPropertyEnum.LABEL.getProperty(), label.getName()).vertices();
+
+ java.util.Iterator<TitanVertex> iterator = vertecies.iterator();
+ if (iterator.hasNext()) {
+ TitanVertex vertex = iterator.next();
+ GraphVertex graphVertex = createAndFill(vertex, parseFlag);
+
+ return Either.left(graphVertex);
+ }
+ if (logger.isDebugEnabled()) {
+ logger.debug("No vertex in graph for key = {} and value = {} label = {}" + name, value, label);
+ }
+ return Either.right(TitanOperationStatus.NOT_FOUND);
+ } catch (Exception e) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Failed to get vertex in graph for key ={} and value = {} label = {}", name, value, label);
+ }
+ return Either.right(TitanGraphClient.handleTitanException(e));
+ }
+
+ } else {
+ if (logger.isDebugEnabled()) {
+ logger.debug("No vertex in graph for key ={} and value = {} label = {} error :{}", name, value, label, graph.right().value());
+ }
+ return Either.right(graph.right().value());
+ }
+ }
+
+ /**
+ *
+ * @param id
+ * @return
+ */
+ public Either<GraphVertex, TitanOperationStatus> getVertexById(String id) {
+ return getVertexById(id, JsonParseFlagEnum.ParseAll);
+ }
+
+ /**
+ *
+ * @param id
+ * @param parseFlag
+ * @return
+ */
+ public Either<GraphVertex, TitanOperationStatus> getVertexById(String id, JsonParseFlagEnum parseFlag) {
+
+ Either<TitanGraph, TitanOperationStatus> graph = titanClient.getGraph();
+ if (id == null) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("No vertex in graph for id = {} ", id);
+ }
+ return Either.right(TitanOperationStatus.NOT_FOUND);
+ }
+ if (graph.isLeft()) {
+ try {
+ TitanGraph tGraph = graph.left().value();
+
+ @SuppressWarnings("unchecked")
+ Iterable<TitanVertex> vertecies = tGraph.query().has(GraphPropertyEnum.UNIQUE_ID.getProperty(), id).vertices();
+
+ java.util.Iterator<TitanVertex> iterator = vertecies.iterator();
+ if (iterator.hasNext()) {
+ TitanVertex vertex = iterator.next();
+ GraphVertex graphVertex = createAndFill(vertex, parseFlag);
+ return Either.left(graphVertex);
+ } else {
+ if (logger.isDebugEnabled()) {
+ logger.debug("No vertex in graph for id = {}", id);
+ }
+ return Either.right(TitanOperationStatus.NOT_FOUND);
+ }
+ } catch (Exception e) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Failed to get vertex in graph for id {} ", id);
+ }
+ return Either.right(TitanGraphClient.handleTitanException(e));
+ }
+ } else {
+ if (logger.isDebugEnabled()) {
+ logger.debug("No vertex in graph for id {} error : {}", id, graph.right().value());
+ }
+ return Either.right(graph.right().value());
+ }
+ }
+
+ private void setVertexProperties(TitanVertex vertex, GraphVertex graphVertex) throws IOException {
+
+ if (graphVertex.getMetadataProperties() != null) {
+ for (Map.Entry<GraphPropertyEnum, Object> entry : graphVertex.getMetadataProperties().entrySet()) {
+ if (entry.getValue() != null) {
+ vertex.property(entry.getKey().getProperty(), entry.getValue());
+ }
+ }
+ }
+ vertex.property(GraphPropertyEnum.LABEL.getProperty(), graphVertex.getLabel().getName());
+
+ Map<String, ? extends ToscaDataDefinition> json = graphVertex.getJson();
+ if (json != null) {
+ String jsonStr = JsonParserUtils.toJson(json);
+ vertex.property(GraphPropertyEnum.JSON.getProperty(), jsonStr);
+
+ }
+ Map<String, Object> jsonMetadata = graphVertex.getMetadataJson();
+ if (jsonMetadata != null) {
+ String jsonMetadataStr = JsonParserUtils.toJson(jsonMetadata);
+ vertex.property(GraphPropertyEnum.METADATA.getProperty(), jsonMetadataStr);
+ }
+ }
+
+ public void setVertexProperties(Vertex vertex, Map<String, Object> properties) throws IOException {
+ for (Map.Entry<String, Object> entry : properties.entrySet()) {
+ if (entry.getValue() != null) {
+ vertex.property(entry.getKey(), entry.getValue());
+ }
+ }
+ }
+
+ private GraphVertex createAndFill(TitanVertex vertex, JsonParseFlagEnum parseFlag) {
+ GraphVertex graphVertex = new GraphVertex();
+ graphVertex.setVertex(vertex);
+ parseVertexProperties(graphVertex, parseFlag);
+ return graphVertex;
+ }
+
+ public void parseVertexProperties(GraphVertex graphVertex, JsonParseFlagEnum parseFlag) {
+ TitanVertex vertex = graphVertex.getVertex();
+ Map<GraphPropertyEnum, Object> properties = getVertexProperties(vertex);
+ VertexTypeEnum label = VertexTypeEnum.getByName((String) (properties.get(GraphPropertyEnum.LABEL)));
+ for (Map.Entry<GraphPropertyEnum, Object> entry : properties.entrySet()) {
+ GraphPropertyEnum key = entry.getKey();
+ switch (key) {
+ case UNIQUE_ID:
+ graphVertex.setUniqueId((String) entry.getValue());
+ break;
+ case LABEL:
+ graphVertex.setLabel(VertexTypeEnum.getByName((String) entry.getValue()));
+ break;
+ case COMPONENT_TYPE:
+ String type = (String) entry.getValue();
+ if (type != null) {
+ graphVertex.setType(ComponentTypeEnum.valueOf(type));
+ }
+ break;
+ case JSON:
+ if (parseFlag == JsonParseFlagEnum.ParseAll || parseFlag == JsonParseFlagEnum.ParseJson) {
+ String json = (String) entry.getValue();
+ Map<String, ? extends ToscaDataDefinition> jsonObj = JsonParserUtils.toMap(json, label.getClassOfJson());
+ graphVertex.setJson(jsonObj);
+ }
+ break;
+ case METADATA:
+ if (parseFlag == JsonParseFlagEnum.ParseAll || parseFlag == JsonParseFlagEnum.ParseMetadata) {
+ String json = (String) entry.getValue();
+ Map<String, Object> metadatObj = JsonParserUtils.toMap(json);
+ graphVertex.setMetadataJson(metadatObj);
+ }
+ break;
+ default:
+ graphVertex.addMetadataProperty(key, entry.getValue());
+ break;
+ }
+ }
+ }
+
+ public TitanOperationStatus createEdge(GraphVertex from, GraphVertex to, EdgeLabelEnum label, Map<EdgePropertyEnum, Object> properties) {
+ return createEdge(from.getVertex(), to.getVertex(), label, properties);
+ }
+
+ public TitanOperationStatus createEdge(Vertex from, Vertex to, EdgeLabelEnum label, Map<EdgePropertyEnum, Object> properties) {
+ if (logger.isTraceEnabled()) {
+ logger.trace("Try to connect {} with {} label {} properties {}", from.property(GraphPropertyEnum.UNIQUE_ID.getProperty()), to.property(GraphPropertyEnum.UNIQUE_ID.getProperty()), label, properties);
+ }
+ if (from == null || to == null) {
+ logger.trace("No Titan vertex for id from {} or id to {}", from.property(GraphPropertyEnum.UNIQUE_ID.getProperty()), to.property(GraphPropertyEnum.UNIQUE_ID.getProperty()));
+ return TitanOperationStatus.NOT_FOUND;
+ }
+ Edge edge = from.addEdge(label.name(), to);
+ setEdgeProperties(edge, properties);
+ return TitanOperationStatus.OK;
+ }
+
+ public Map<GraphPropertyEnum, Object> getVertexProperties(Element element) {
+
+ Map<GraphPropertyEnum, Object> result = new HashMap<GraphPropertyEnum, Object>();
+
+ if (element != null && element.keys() != null && element.keys().size() > 0) {
+ Map<String, Property> propertyMap = ElementHelper.propertyMap(element, element.keys().toArray(new String[element.keys().size()]));
+
+ for (Entry<String, Property> entry : propertyMap.entrySet()) {
+ String key = entry.getKey();
+ Object value = entry.getValue().value();
+
+ GraphPropertyEnum valueOf = GraphPropertyEnum.getByProperty(key);
+ if (valueOf != null) {
+ result.put(valueOf, value);
+ }
+ }
+ }
+ return result;
+ }
+
+ public Map<EdgePropertyEnum, Object> getEdgeProperties(Element element) {
+
+ Map<EdgePropertyEnum, Object> result = new HashMap<EdgePropertyEnum, Object>();
+
+ if (element != null && element.keys() != null && element.keys().size() > 0) {
+ Map<String, Property> propertyMap = ElementHelper.propertyMap(element, element.keys().toArray(new String[element.keys().size()]));
+
+ for (Entry<String, Property> entry : propertyMap.entrySet()) {
+ String key = entry.getKey();
+ Object value = entry.getValue().value();
+
+ EdgePropertyEnum valueOf = EdgePropertyEnum.getByProperty(key);
+ if (valueOf != null) {
+ result.put(valueOf, value);
+ }
+ }
+ }
+ return result;
+ }
+
+ public void setEdgeProperties(Element element, Map<EdgePropertyEnum, Object> properties) {
+
+ if (properties != null && !properties.isEmpty()) {
+
+ Object[] propertyKeyValues = new Object[properties.size() * 2];
+ int i = 0;
+ for (Entry<EdgePropertyEnum, Object> entry : properties.entrySet()) {
+ propertyKeyValues[i++] = entry.getKey().getProperty();
+ propertyKeyValues[i++] = entry.getValue();
+ }
+
+ ElementHelper.attachProperties(element, propertyKeyValues);
+
+ }
+
+ }
+
+ public Either<List<GraphVertex>, TitanOperationStatus> getByCriteria(VertexTypeEnum type, Map<GraphPropertyEnum, Object> props) {
+ return getByCriteria(type, props, JsonParseFlagEnum.ParseAll);
+ }
+
+ public Either<List<GraphVertex>, TitanOperationStatus> getByCriteria(VertexTypeEnum type, Map<GraphPropertyEnum, Object> props, JsonParseFlagEnum parseFlag) {
+ Either<TitanGraph, TitanOperationStatus> graph = titanClient.getGraph();
+ if (graph.isLeft()) {
+ try {
+ TitanGraph tGraph = graph.left().value();
+
+ TitanGraphQuery<? extends TitanGraphQuery> query = tGraph.query();
+ if (type != null) {
+ query = query.has(GraphPropertyEnum.LABEL.getProperty(), type.getName());
+ }
+
+ if (props != null && !props.isEmpty()) {
+ for (Map.Entry<GraphPropertyEnum, Object> entry : props.entrySet()) {
+ query = query.has(entry.getKey().getProperty(), entry.getValue());
+ }
+ }
+ Iterable<TitanVertex> vertices = query.vertices();
+ if (vertices == null) {
+ return Either.right(TitanOperationStatus.NOT_FOUND);
+ }
+
+ Iterator<TitanVertex> iterator = vertices.iterator();
+ List<GraphVertex> result = new ArrayList<GraphVertex>();
+
+ while (iterator.hasNext()) {
+ TitanVertex vertex = iterator.next();
+
+ Map<GraphPropertyEnum, Object> newProp = getVertexProperties(vertex);
+ GraphVertex graphVertex = createAndFill(vertex, parseFlag);
+
+ result.add(graphVertex);
+ }
+ if (logger.isDebugEnabled()) {
+ logger.debug("Number of fetced nodes in graph for criteria : from type = {} and properties = {} is {}", type, props, result.size());
+ }
+ if (result.size() == 0) {
+ return Either.right(TitanOperationStatus.NOT_FOUND);
+ }
+
+ return Either.left(result);
+ } catch (Exception e) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Failed get by criteria for type = {} and properties = {}", type, props, e);
+ }
+ return Either.right(TitanGraphClient.handleTitanException(e));
+ }
+
+ } else {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Failed get by criteria for type ={} and properties = {} error : {}", type, props, graph.right().value());
+ }
+ return Either.right(graph.right().value());
+ }
+ }
+
+ public Either<List<GraphVertex>, TitanOperationStatus> getByCriteria(VertexTypeEnum type, Map<GraphPropertyEnum, Object> props, Map<GraphPropertyEnum, Object> hasNotProps, JsonParseFlagEnum parseFlag) {
+ Either<TitanGraph, TitanOperationStatus> graph = titanClient.getGraph();
+ if (graph.isLeft()) {
+ try {
+ TitanGraph tGraph = graph.left().value();
+
+ TitanGraphQuery<? extends TitanGraphQuery> query = tGraph.query();
+ if (type != null) {
+ query = query.has(GraphPropertyEnum.LABEL.getProperty(), type.getName());
+ }
+
+ if (props != null && !props.isEmpty()) {
+ for (Map.Entry<GraphPropertyEnum, Object> entry : props.entrySet()) {
+ query = query.has(entry.getKey().getProperty(), entry.getValue());
+ }
+ }
+ if (hasNotProps != null && !hasNotProps.isEmpty()) {
+ for (Map.Entry<GraphPropertyEnum, Object> entry : hasNotProps.entrySet()) {
+ if (entry.getValue() instanceof List) {
+ buildMultipleNegateQueryFromList(entry, query);
+ } else {
+ query = query.hasNot(entry.getKey().getProperty(), entry.getValue());
+ }
+ }
+ }
+ Iterable<TitanVertex> vertices = query.vertices();
+ if (vertices == null) {
+ return Either.right(TitanOperationStatus.NOT_FOUND);
+ }
+
+ Iterator<TitanVertex> iterator = vertices.iterator();
+ List<GraphVertex> result = new ArrayList<GraphVertex>();
+
+ while (iterator.hasNext()) {
+ TitanVertex vertex = iterator.next();
+
+ Map<GraphPropertyEnum, Object> newProp = getVertexProperties(vertex);
+ GraphVertex graphVertex = createAndFill(vertex, parseFlag);
+
+ result.add(graphVertex);
+ }
+ if (logger.isDebugEnabled()) {
+ logger.debug("Number of fetced nodes in graph for criteria : from type = {} and properties = {} is {}", type, props, result.size());
+ }
+ if (result.size() == 0) {
+ return Either.right(TitanOperationStatus.NOT_FOUND);
+ }
+
+ return Either.left(result);
+ } catch (Exception e) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Failed get by criteria for type = {} and properties = {}", type, props, e);
+ }
+ return Either.right(TitanGraphClient.handleTitanException(e));
+ }
+
+ } else {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Failed get by criteria for type ={} and properties = {} error : {}", type, props, graph.right().value());
+ }
+ return Either.right(graph.right().value());
+ }
+ }
+
+ public Either<Iterator<Vertex>, TitanOperationStatus> getCatalogVerticies() {
+ Either<TitanGraph, TitanOperationStatus> graph = titanClient.getGraph();
+ if (graph.isLeft()) {
+ try {
+ TitanGraph tGraph = graph.left().value();
+
+ Iterable<TitanVertex> vCatalogIter = tGraph.query().has(GraphPropertyEnum.LABEL.getProperty(), VertexTypeEnum.CATALOG_ROOT.getName()).vertices();
+ if (vCatalogIter == null) {
+ logger.debug("Failed to fetch catalog vertex");
+ return Either.right(TitanOperationStatus.GENERAL_ERROR);
+ }
+ TitanVertex catalogV = vCatalogIter.iterator().next();
+ if (catalogV == null) {
+ logger.debug("Failed to fetch catalog vertex");
+ return Either.right(TitanOperationStatus.GENERAL_ERROR);
+ }
+ Iterator<Vertex> vertices = catalogV.vertices(Direction.OUT, EdgeLabelEnum.CATALOG_ELEMENT.name());
+
+ return Either.left(vertices);
+ } catch (Exception e) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Failed get by criteria: ", e);
+ }
+ return Either.right(TitanGraphClient.handleTitanException(e));
+ }
+
+ } else {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Failed get by criteria : ", graph.right().value());
+ }
+ return Either.right(graph.right().value());
+ }
+ }
+
+ private void buildMultipleNegateQueryFromList(Map.Entry<GraphPropertyEnum, Object> entry, TitanGraphQuery query) {
+ List<Object> negateList = (List<Object>) entry.getValue();
+ for (Object listItem : negateList) {
+ query.hasNot(entry.getKey().getProperty(), listItem);
+ }
+ }
+
+ /**
+ *
+ * @param parentVertex
+ * @param edgeLabel
+ * @param parseFlag
+ * @return
+ */
+ public Either<GraphVertex, TitanOperationStatus> getChildVertex(GraphVertex parentVertex, EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag) {
+ Either<List<GraphVertex>, TitanOperationStatus> childrenVertecies = getChildrenVertecies(parentVertex, edgeLabel, parseFlag);
+ if (childrenVertecies.isRight()) {
+ return Either.right(childrenVertecies.right().value());
+ }
+ return Either.left(childrenVertecies.left().value().get(0));
+ }
+
+ /**
+ *
+ * @param parentVertex
+ * @param edgeLabel
+ * @param parseFlag
+ * @return
+ */
+ public Either<Vertex, TitanOperationStatus> getChildVertex(Vertex parentVertex, EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag) {
+ Either<List<Vertex>, TitanOperationStatus> childrenVertecies = getChildrenVertecies(parentVertex, edgeLabel, parseFlag);
+ if (childrenVertecies.isRight()) {
+ return Either.right(childrenVertecies.right().value());
+ }
+ return Either.left(childrenVertecies.left().value().get(0));
+ }
+
+ public Either<GraphVertex, TitanOperationStatus> getParentVertex(GraphVertex parentVertex, EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag) {
+ Either<List<GraphVertex>, TitanOperationStatus> childrenVertecies = getParentVertecies(parentVertex, edgeLabel, parseFlag);
+ if (childrenVertecies.isRight()) {
+ return Either.right(childrenVertecies.right().value());
+ }
+ return Either.left(childrenVertecies.left().value().get(0));
+ }
+
+ public Either<Vertex, TitanOperationStatus> getParentVertex(Vertex parentVertex, EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag) {
+ Either<List<Vertex>, TitanOperationStatus> childrenVertecies = getParentVertecies(parentVertex, edgeLabel, parseFlag);
+ if (childrenVertecies.isRight()) {
+ return Either.right(childrenVertecies.right().value());
+ }
+ return Either.left(childrenVertecies.left().value().get(0));
+ }
+
+ /**
+ *
+ * @param parentVertex
+ * @param edgeLabel
+ * @param parseFlag
+ * @return
+ */
+ public Either<List<GraphVertex>, TitanOperationStatus> getChildrenVertecies(GraphVertex parentVertex, EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag) {
+ return getAdjacentVerticies(parentVertex, edgeLabel, parseFlag, Direction.OUT);
+ }
+
+ public Either<List<GraphVertex>, TitanOperationStatus> getParentVertecies(GraphVertex parentVertex, EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag) {
+ return getAdjacentVerticies(parentVertex, edgeLabel, parseFlag, Direction.IN);
+ }
+
+ public Either<List<Vertex>, TitanOperationStatus> getParentVertecies(Vertex parentVertex, EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag) {
+ return getAdjacentVerticies(parentVertex, edgeLabel, parseFlag, Direction.IN);
+ }
+
+ private Either<List<Vertex>, TitanOperationStatus> getAdjacentVerticies(Vertex parentVertex, EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag, Direction direction) {
+ List<Vertex> list = new ArrayList<>();
+ try {
+ Either<TitanGraph, TitanOperationStatus> graphRes = titanClient.getGraph();
+ if (graphRes.isRight()) {
+ logger.error("Failed to retrieve graph. status is {}", graphRes);
+ return Either.right(graphRes.right().value());
+ }
+ Iterator<Edge> edgesCreatorIterator = parentVertex.edges(direction, edgeLabel.name());
+ if (edgesCreatorIterator != null) {
+ while (edgesCreatorIterator.hasNext()) {
+ Edge edge = edgesCreatorIterator.next();
+ TitanVertex vertex;
+ if (direction == Direction.IN) {
+ vertex = (TitanVertex) edge.outVertex();
+ } else {
+ vertex = (TitanVertex) edge.inVertex();
+ }
+ // GraphVertex graphVertex = createAndFill(vertex, parseFlag);
+
+ list.add(vertex);
+ }
+ }
+ if (true == list.isEmpty()) {
+ return Either.right(TitanOperationStatus.NOT_FOUND);
+ }
+ } catch (Exception e) {
+ logger.error("Failed to perform graph operation ", e);
+ Either.right(TitanGraphClient.handleTitanException(e));
+ }
+
+ return Either.left(list);
+ }
+
+ /**
+ *
+ * @param parentVertex
+ * @param edgeLabel
+ * @param parseFlag
+ * @return
+ */
+ public Either<List<Vertex>, TitanOperationStatus> getChildrenVertecies(Vertex parentVertex, EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag) {
+ return getAdjacentVerticies(parentVertex, edgeLabel, parseFlag, Direction.OUT);
+ }
+
+ private Either<List<GraphVertex>, TitanOperationStatus> getAdjacentVerticies(GraphVertex parentVertex, EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag, Direction direction) {
+ List<GraphVertex> list = new ArrayList<GraphVertex>();
+
+ Either<List<Vertex>, TitanOperationStatus> adjacentVerticies = getAdjacentVerticies(parentVertex.getVertex(), edgeLabel, parseFlag, direction);
+ if (adjacentVerticies.isRight()) {
+ return Either.right(adjacentVerticies.right().value());
+ }
+ adjacentVerticies.left().value().stream().forEach(vertex -> {
+ list.add(createAndFill((TitanVertex) vertex, parseFlag));
+ });
+
+ return Either.left(list);
+ }
+
+ /**
+ * Searches Edge by received label and criteria
+ *
+ * @param vertex
+ * @param label
+ * @param properties
+ * @return found edge or TitanOperationStatus
+ */
+ public Either<Edge, TitanOperationStatus> getBelongingEdgeByCriteria(GraphVertex vertex, EdgeLabelEnum label, Map<GraphPropertyEnum, Object> properties) {
+
+ Either<Edge, TitanOperationStatus> result = null;
+ Edge matchingEdge = null;
+ String notFoundMsg = "No edges in graph for criteria";
+ try {
+ TitanVertexQuery<?> query = vertex.getVertex().query().labels(label.name());
+
+ if (properties != null && !properties.isEmpty()) {
+ for (Map.Entry<GraphPropertyEnum, Object> entry : properties.entrySet()) {
+ query = query.has(entry.getKey().getProperty(), entry.getValue());
+ }
+ }
+
+ Iterable<TitanEdge> edges = query.edges();
+ if (edges == null) {
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, notFoundMsg);
+ result = Either.right(TitanOperationStatus.NOT_FOUND);
+ } else {
+ Iterator<TitanEdge> eIter = edges.iterator();
+ if (eIter.hasNext()) {
+ matchingEdge = eIter.next();
+ } else {
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, notFoundMsg);
+ result = Either.right(TitanOperationStatus.NOT_FOUND);
+ }
+ }
+ if (result == null) {
+ result = Either.left(matchingEdge);
+ }
+ } catch (Exception e) {
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Exception occured during getting edge by criteria for component with id {}. {}", vertex.getUniqueId(), e);
+ return Either.right(TitanGraphClient.handleTitanException(e));
+ }
+ return result;
+ }
+
+ /**
+ * Deletes Edge by received label and criteria
+ *
+ * @param vertex
+ * @param label
+ * @param properties
+ * @return
+ */
+ public Either<Edge, TitanOperationStatus> deleteBelongingEdgeByCriteria(GraphVertex vertex, EdgeLabelEnum label, Map<GraphPropertyEnum, Object> properties) {
+ Either<Edge, TitanOperationStatus> result = null;
+ try {
+ result = getBelongingEdgeByCriteria(vertex, label, properties);
+ if (result.isLeft()) {
+ Edge edge = result.left().value();
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.TRACE, "Going to delete an edge with the label {} belonging to the vertex {} ", label.name(), vertex.getUniqueId());
+ edge.remove();
+ result = Either.left(edge);
+ } else {
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to find an edge with the label {} belonging to the vertex {} ", label.name(), vertex.getUniqueId());
+ }
+ } catch (Exception e) {
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Exception occured during deleting an edge by criteria for the component with id {}. {}", vertex.getUniqueId(), e);
+ return Either.right(TitanGraphClient.handleTitanException(e));
+ }
+ return result;
+ }
+
+ @SuppressWarnings("unchecked")
+ /**
+ * Deletes an edge between vertices fromVertex and toVertex according to received label
+ *
+ * @param fromVertex
+ * @param toVertex
+ * @param label
+ * @return
+ */
+
+ public Either<Edge, TitanOperationStatus> deleteEdge(GraphVertex fromVertex, GraphVertex toVertex, EdgeLabelEnum label) {
+ return deleteEdge(fromVertex.getVertex(), toVertex.getVertex(), label, fromVertex.getUniqueId(), toVertex.getUniqueId());
+ }
+
+ public Either<Edge, TitanOperationStatus> deleteEdge(TitanVertex fromVertex, TitanVertex toVertex, EdgeLabelEnum label, String uniqueIdFrom, String uniqueIdTo) {
+ Either<Edge, TitanOperationStatus> result = null;
+ try {
+ Iterable<TitanEdge> edges = fromVertex.query().labels(label.name()).edges();
+ Iterator<TitanEdge> eIter = edges.iterator();
+ while (eIter.hasNext()) {
+ Edge edge = eIter.next();
+ String currVertexUniqueId = edge.inVertex().value(GraphPropertyEnum.UNIQUE_ID.getProperty());
+ if (currVertexUniqueId != null && currVertexUniqueId.equals(uniqueIdTo)) {
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.TRACE, "Going to delete an edge with the label {} between vertices {} and {}. ", label.name(), uniqueIdFrom, uniqueIdTo);
+ edge.remove();
+ result = Either.left(edge);
+ break;
+ }
+ }
+ if (result == null) {
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to delete an edge with the label {} between vertices {} and {}. ", label.name(), uniqueIdFrom, uniqueIdTo);
+ result = Either.right(TitanOperationStatus.NOT_FOUND);
+ }
+ } catch (Exception e) {
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Exception occured during deleting an edge with the label {} between vertices {} and {}. {}", label.name(), uniqueIdFrom, uniqueIdTo, e);
+ return Either.right(TitanGraphClient.handleTitanException(e));
+ }
+ return result;
+ }
+
+ public TitanOperationStatus deleteEdgeByDirection(GraphVertex fromVertex, Direction direction, EdgeLabelEnum label) {
+ try {
+ Iterator<Edge> edges = fromVertex.getVertex().edges(direction, label.name());
+
+ while (edges.hasNext()) {
+ Edge edge = edges.next();
+ edge.remove();
+ }
+ } catch (Exception e) {
+ logger.debug("Failed to remove from vertex {} edges {} by direction {} ", fromVertex.getUniqueId(), label, direction, e);
+ return TitanGraphClient.handleTitanException(e);
+ }
+ return TitanOperationStatus.OK;
+ }
+
+ /**
+ * Updates vertex properties. Note that graphVertex argument should contain updated data
+ *
+ * @param graphVertex
+ * @return
+ */
+ public Either<GraphVertex, TitanOperationStatus> updateVertex(GraphVertex graphVertex) {
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.TRACE, "Going to update metadata of vertex with uniqueId {}. ", graphVertex.getUniqueId());
+ try {
+ graphVertex.updateMetadataJsonWithCurrentMetadataProperties();
+ setVertexProperties(graphVertex.getVertex(), graphVertex);
+
+ } catch (Exception e) {
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to update metadata of vertex with uniqueId {}. ", graphVertex.getUniqueId(), e);
+ return Either.right(TitanGraphClient.handleTitanException(e));
+ }
+ return Either.left(graphVertex);
+ }
+
+ /**
+ * Fetches vertices by uniqueId according to received parse flag
+ *
+ * @param verticesToGet
+ * @return
+ */
+ public Either<Map<String, GraphVertex>, TitanOperationStatus> getVerticesByUniqueIdAndParseFlag(Map<String, ImmutablePair<GraphPropertyEnum, JsonParseFlagEnum>> verticesToGet) {
+
+ Either<Map<String, GraphVertex>, TitanOperationStatus> result = null;
+ Map<String, GraphVertex> vertices = new HashMap<>();
+ TitanOperationStatus titatStatus;
+ Either<GraphVertex, TitanOperationStatus> getVertexRes = null;
+ for (Map.Entry<String, ImmutablePair<GraphPropertyEnum, JsonParseFlagEnum>> entry : verticesToGet.entrySet()) {
+ if (entry.getValue().getKey() == GraphPropertyEnum.UNIQUE_ID) {
+ getVertexRes = getVertexById(entry.getKey(), entry.getValue().getValue());
+ } else if (entry.getValue().getKey() == GraphPropertyEnum.USERID) {
+ getVertexRes = getVertexByPropertyAndLabel(entry.getValue().getKey(), entry.getKey(), VertexTypeEnum.USER, entry.getValue().getValue());
+ }
+ if (getVertexRes == null) {
+ titatStatus = TitanOperationStatus.ILLEGAL_ARGUMENT;
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Invalid vertex type label {} has been received. ", entry.getValue().getKey(), titatStatus);
+ result = Either.right(titatStatus);
+ }
+ if (getVertexRes.isRight()) {
+ titatStatus = getVertexRes.right().value();
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to get vertex by id {} . Status is {}. ", entry.getKey(), titatStatus);
+ result = Either.right(titatStatus);
+ break;
+ } else {
+ vertices.put(entry.getKey(), getVertexRes.left().value());
+ }
+ }
+ if (result == null) {
+ result = Either.left(vertices);
+ }
+ return result;
+ }
+
+ /**
+ * Creates edge between "from" and "to" vertices with specified label and properties extracted from received edge
+ *
+ * @param from
+ * @param to
+ * @param label
+ * @param edgeToCopy
+ * @return
+ */
+ public TitanOperationStatus createEdge(Vertex from, Vertex to, EdgeLabelEnum label, Edge edgeToCopy) {
+ return createEdge(from, to, label, getEdgeProperties(edgeToCopy));
+ }
+
+ public TitanOperationStatus replaceEdgeLabel(Vertex fromVertex, Vertex toVertex, Edge prevEdge, EdgeLabelEnum prevLabel, EdgeLabelEnum newLabel) {
+
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.TRACE, "Going to replace edge with label {} to {} between vertices {} and {}", prevLabel, newLabel, fromVertex.property(GraphPropertyEnum.UNIQUE_ID.getProperty()),
+ toVertex.property(GraphPropertyEnum.UNIQUE_ID.getProperty()));
+ TitanOperationStatus result = createEdge(fromVertex, toVertex, newLabel, prevEdge);
+ if (result == TitanOperationStatus.OK) {
+ prevEdge.remove();
+ }
+ return result;
+ }
+
+ /**
+ * Replaces previous label of edge with new label
+ *
+ * @param fromVertex
+ * @param toVertex
+ * @param prevLabel
+ * @param newLabel
+ * @return
+ */
+ public TitanOperationStatus replaceEdgeLabel(Vertex fromVertex, Vertex toVertex, EdgeLabelEnum prevLabel, EdgeLabelEnum newLabel) {
+
+ TitanOperationStatus result = null;
+ Iterator<Edge> prevEdgeIter = toVertex.edges(Direction.IN, prevLabel.name());
+ if (prevEdgeIter == null || !prevEdgeIter.hasNext()) {
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to replace edge with label {} to {} between vertices {} and {}", prevLabel, newLabel, fromVertex.property(GraphPropertyEnum.UNIQUE_ID.getProperty()),
+ toVertex.property(GraphPropertyEnum.UNIQUE_ID.getProperty()));
+ result = TitanOperationStatus.NOT_FOUND;
+ }
+ if (result == null) {
+ result = replaceEdgeLabel(fromVertex, toVertex, prevEdgeIter.next(), prevLabel, newLabel);
+ }
+ return result;
+ }
+
+ /**
+ * Updates metadata properties of vertex on graph. Json metadata property of the vertex will be updated with received properties too.
+ *
+ *
+ * @param vertex
+ * @param properties
+ * @return
+ */
+ public TitanOperationStatus updateVertexMetadataPropertiesWithJson(Vertex vertex, Map<GraphPropertyEnum, Object> properties) {
+ try {
+ if (!MapUtils.isEmpty(properties)) {
+ String jsonMetadataStr = (String) vertex.property(GraphPropertyEnum.METADATA.getProperty()).value();
+ Map<String, Object> jsonMetadataMap = JsonParserUtils.toMap(jsonMetadataStr);
+ for (Map.Entry<GraphPropertyEnum, Object> property : properties.entrySet()) {
+ vertex.property(property.getKey().getProperty(), property.getValue());
+ jsonMetadataMap.put(property.getKey().getProperty(), property.getValue());
+ }
+ vertex.property(GraphPropertyEnum.METADATA.getProperty(), JsonParserUtils.toJson(jsonMetadataMap));
+ }
+ } catch (Exception e) {
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Exception occurred during update vertex metadata properties with json{}. {}", vertex.property(GraphPropertyEnum.UNIQUE_ID.getProperty()), e.getMessage());
+ return TitanGraphClient.handleTitanException(e);
+ }
+ return TitanOperationStatus.OK;
+ }
+
+ public TitanOperationStatus disassociateAndDeleteLast(GraphVertex vertex, Direction direction, EdgeLabelEnum label) {
+ try {
+ Iterator<Edge> edges = vertex.getVertex().edges(direction, label.name());
+
+ while (edges.hasNext()) {
+ Edge edge = edges.next();
+ Vertex secondVertex;
+ Direction reverseDirection;
+ if (direction == Direction.IN) {
+ secondVertex = edge.outVertex();
+ reverseDirection = Direction.OUT;
+ } else {
+ secondVertex = edge.inVertex();
+ reverseDirection = Direction.IN;
+ }
+ edge.remove();
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.TRACE, "Edge {} with direction {} was removed from {}", label.name(), direction, vertex.getVertex());
+
+ Iterator<Edge> restOfEdges = secondVertex.edges(reverseDirection, label.name());
+ if (restOfEdges.hasNext() == false) {
+ secondVertex.remove();
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.TRACE, "This was last edge . Vertex {} was removed ", vertex.getUniqueId());
+ }
+ }
+ } catch (Exception e) {
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Exception occured during deleting an edge with the label {} direction {} from vertex {}. {}", label.name(), direction, vertex.getUniqueId(), e);
+ return TitanGraphClient.handleTitanException(e);
+ }
+ return TitanOperationStatus.OK;
+ }
+
+ public Object getProperty(TitanVertex vertex, String key) {
+ PropertyKey propertyKey = titanClient.getGraph().left().value().getPropertyKey(key);
+ Object value = vertex.valueOrNull(propertyKey);
+ return value;
+ }
+
+ public Object getProperty(Edge edge, EdgePropertyEnum key) {
+ Object value = null;
+ try {
+ Property<Object> property = edge.property(key.getProperty());
+ if (property != null) {
+ return property.orElse(null);
+ }
+ } catch (Exception e) {
+
+ }
+ return value;
+ }
+
+ /**
+ *
+ * @param vertexA
+ * @param vertexB
+ * @param label
+ * @param direction
+ * @return
+ */
+ public TitanOperationStatus moveEdge(GraphVertex vertexA, GraphVertex vertexB, EdgeLabelEnum label, Direction direction) {
+ TitanOperationStatus result = deleteEdgeByDirection(vertexA, direction, label);
+ if (result != TitanOperationStatus.OK) {
+ logger.error("Failed to diassociate {} from element {}. error {} ", label, vertexA.getUniqueId(), result);
+ return result;
+ }
+ TitanOperationStatus createRelation;
+ if (direction == Direction.IN) {
+ createRelation = createEdge(vertexB, vertexA, label, null);
+ } else {
+ createRelation = createEdge(vertexA, vertexB, label, null);
+ }
+ if (createRelation != TitanOperationStatus.OK) {
+ return createRelation;
+ }
+ return TitanOperationStatus.OK;
+ }
+
+ public Either<Edge, TitanOperationStatus> getBelongingEdgeByCriteria(String parentId, EdgeLabelEnum label, Map<GraphPropertyEnum, Object> properties) {
+ Either<GraphVertex, TitanOperationStatus> getVertexRes = getVertexById(parentId, JsonParseFlagEnum.NoParse);
+ if (getVertexRes.isRight()) {
+ return Either.right(getVertexRes.right().value());
+ }
+ return getBelongingEdgeByCriteria(getVertexRes.left().value(), label, properties);
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/types/EdgeLabelEnum.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/types/EdgeLabelEnum.java
index 3018915066..eda2805087 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/types/EdgeLabelEnum.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/types/EdgeLabelEnum.java
@@ -48,12 +48,17 @@ public enum EdgeLabelEnum {
INST_ATTRIBUTES,
INST_GROUPS,
SERVICE_API_ARTIFACTS,
+ FORWARDING_PATH,
CALCULATED_CAPABILITIES,
FULLFILLED_CAPABILITIES,
CALCULATED_REQUIREMENTS,
FULLFILLED_REQUIREMENTS,
LAST_DISTRIBUTION_STATE_MODIFIER,
- CALCULATED_CAP_PROPERTIES;
+ CALCULATED_CAP_PROPERTIES,
+ POLICIES,
+ EXTERNAL_REFS,
+ CATALOG_ELEMENT;
+
/**
* Returns EdgeLabelEnum according received name
* @param name
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/types/VertexTypeEnum.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/types/VertexTypeEnum.java
index 08652ba171..1bc9df5f4a 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/types/VertexTypeEnum.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/types/VertexTypeEnum.java
@@ -20,20 +20,7 @@
package org.openecomp.sdc.be.dao.jsongraph.types;
-import org.openecomp.sdc.be.datatypes.elements.AdditionalInfoParameterDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.CompositionDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.GroupDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.InterfaceDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.ListCapabilityDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.ListRequirementDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.MapArtifactDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.MapCapabiltyProperty;
-import org.openecomp.sdc.be.datatypes.elements.MapGroupsDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.MapListCapabiltyDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.MapListRequirementDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.MapPropertiesDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.*;
public enum VertexTypeEnum {
@@ -66,8 +53,11 @@ public enum VertexTypeEnum {
FULLFILLED_CAPABILITIES ("fullfilledCapabilities", MapListCapabiltyDataDefinition.class),
CALCULATED_REQUIREMENTS ("calculatedRequirements", MapListRequirementDataDefinition.class),
FULLFILLED_REQUIREMENTS ("fullfilledRequirements", MapListRequirementDataDefinition.class),
- CALCULATED_CAP_PROPERTIES ("calculatedCapProperties", MapCapabiltyProperty.class)
-;
+ CALCULATED_CAP_PROPERTIES ("calculatedCapProperties", MapCapabiltyProperty.class),
+ FORWARDING_PATH ("path", ForwardingPathDataDefinition.class),
+ POLICIES ("policies", PolicyDataDefinition.class),
+ EXTERNAL_REF ("componentInstanceExtRefs", MapComponentInstanceExternalRefs.class),
+ CATALOG_ROOT ("catalogRoot", null);
private String name;
private Class classOfJson;
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/utils/JsonParserUtils.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/utils/JsonParserUtils.java
index da3d6530e4..b2530e8e8a 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/utils/JsonParserUtils.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/utils/JsonParserUtils.java
@@ -7,9 +7,9 @@
* 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.
@@ -20,67 +20,73 @@
package org.openecomp.sdc.be.dao.jsongraph.utils;
-import java.io.IOException;
-import java.util.Map;
-
-import org.codehaus.jackson.JsonGenerationException;
-import org.codehaus.jackson.map.DeserializationConfig;
-import org.codehaus.jackson.map.JsonMappingException;
-import org.codehaus.jackson.map.ObjectMapper;
-import org.codehaus.jackson.map.SerializationConfig.Feature;
-import org.codehaus.jackson.map.annotate.JsonSerialize;
-import org.codehaus.jackson.type.JavaType;
-import org.codehaus.jackson.type.TypeReference;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.JavaType;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
+import com.google.common.base.Strings;
import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.io.IOException;
+import java.util.Map;
+
public class JsonParserUtils {
- private static ObjectMapper mapper = new ObjectMapper();
- private static Logger logger = LoggerFactory.getLogger(JsonParserUtils.class.getName());
+ private static final Logger log = LoggerFactory.getLogger(JsonParserUtils.class.getName());
+ private static final ObjectMapper mapper = buildObjectMapper();
+
+ private JsonParserUtils() {
+ // No instances allowed
+ }
+
+ private static ObjectMapper buildObjectMapper() {
+ return new ObjectMapper()
+ .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
+ .disable(SerializationFeature.FAIL_ON_EMPTY_BEANS)
+ .setSerializationInclusion(JsonInclude.Include.NON_NULL);
+ }
-
- public static <T> String jsonToString(T elementToRepresent) throws IOException, JsonGenerationException, JsonMappingException {
+ public static <T> String toJson(T object) throws IOException {
+ return mapper.writer()
+ .writeValueAsString(object);
+ }
-
- mapper.configure(Feature.FAIL_ON_EMPTY_BEANS, false);
- mapper.setSerializationInclusion(JsonSerialize.Inclusion.NON_NULL);
- return mapper.writeValueAsString(elementToRepresent);
- }
+ public static Map<String, Object> toMap(String json) {
+ if (Strings.isNullOrEmpty(json)) {
+ return null;
+ }
- public static Map<String, Object> parseToJson(String json) {
- Map<String, Object> object = null;
- if (json == null || json.isEmpty()) {
- return null;
- }
- mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
- mapper.configure(Feature.FAIL_ON_EMPTY_BEANS, false);
- mapper.setSerializationInclusion(JsonSerialize.Inclusion.NON_NULL);
- TypeReference<Map<String, Object>> typeRef = new TypeReference<Map<String, Object>>() {
- };
+ Map<String, Object> object = null;
+ try {
+ TypeReference<Map<String, Object>> typeRef = new TypeReference<Map<String, Object>>() {
+ };
+ object = mapper.readerFor(typeRef)
+ .readValue(json);
+ }
+ catch (Exception e) {
+ log.debug("Failed to parse json {}", json, e);
+ }
+ return object;
+ }
- try {
- object = mapper.readValue(json, typeRef);
- } catch (Exception e) {
- logger.debug("Failed to parse json {}", json, e);
- }
- return object;
- }
- public static <T extends ToscaDataDefinition> Map<String, T> parseToJson(String json, Class <T> clazz) {
- Map<String, T> object = null;
- if (json == null || json.isEmpty()) {
- return null;
- }
- mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
- mapper.configure(Feature.FAIL_ON_EMPTY_BEANS, false);
- mapper.setSerializationInclusion(JsonSerialize.Inclusion.NON_NULL);
- JavaType type = mapper.getTypeFactory().constructMapType(Map.class, String.class, clazz);
+ public static <T extends ToscaDataDefinition> Map<String, T> toMap(String json, Class<T> clazz) {
+ if (Strings.isNullOrEmpty(json)) {
+ return null;
+ }
- try {
- object = mapper.readValue(json, type);
- } catch (Exception e) {
- logger.debug("Failed to parse json {}", json, e);
- }
- return object;
- }
+ Map<String, T> object = null;
+ try {
+ JavaType type = mapper.getTypeFactory()
+ .constructMapType(Map.class, String.class, clazz);
+ object = mapper.readerFor(type)
+ .readValue(json);
+ }
+ catch (Exception e) {
+ log.debug("Failed to parse json {}", json, e);
+ }
+ return object;
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/GraphEdgeLabels.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/GraphEdgeLabels.java
index 1b5222c0a0..790e92ec55 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/GraphEdgeLabels.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/GraphEdgeLabels.java
@@ -37,7 +37,7 @@ public enum GraphEdgeLabels {
CALCULATED_REQUIREMENT("CALCULATED_REQUIREMENT"), CALCULATED_CAPABILITY("CALCULATED_CAPABILITY"), RELATIONSHIP_ORIGIN("RELATIONSHIP_ORIGIN"), CAPABILITY_ORIGIN("CAPABILITY_ORIGIN"),
CALCULATED_REQUIREMENT_FULLFILLED("CALCULATED_REQUIREMENT_FULLFILLED"), CALCULATED_CAPABILITY_FULLFILLED("CALCULATED_CAPABILITY_FULLFILLED"),
// Group
- GROUP("GROUP"), GROUP_ARTIFACT_REF("GROUP_ARTIFACT_REF"), GROUP_MEMBER("GROUP_MEMBER"), INPUT("EDGE_INPUT"), GET_INPUT("GET_INPUT"), GROUP_INST("GROUP_INST");
+ GROUP("GROUP"), GROUP_ARTIFACT_REF("GROUP_ARTIFACT_REF"), GROUP_MEMBER("GROUP_MEMBER"), INPUT("EDGE_INPUT"), GET_INPUT("GET_INPUT"), GROUP_INST("GROUP_INST"), GROUP_TYPE_CAPABILITY_TYPE("GROUP_TYPE_CAPABILITY_TYPE");
private String property;
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/rest/HttpRestClient.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/rest/HttpRestClient.java
deleted file mode 100644
index 563129937e..0000000000
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/rest/HttpRestClient.java
+++ /dev/null
@@ -1,390 +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.dao.rest;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Map.Entry;
-import java.util.Properties;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.http.HttpEntity;
-import org.apache.http.client.config.RequestConfig;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.client.methods.HttpPut;
-import org.apache.http.client.methods.HttpRequestBase;
-import org.apache.http.entity.ContentType;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
-import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
-import org.apache.http.util.EntityUtils;
-import org.openecomp.sdc.be.config.BeEcompErrorManager;
-import org.openecomp.sdc.be.config.BeEcompErrorManager.ErrorSeverity;
-import org.openecomp.sdc.common.rest.api.RestResponse;
-import org.openecomp.sdc.common.rest.api.RestResponseAsByteArray;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class HttpRestClient {
-
- public final static int DEFAULT_CONNECTION_POOL_SIZE = 10;
-
- public final static int DEFAULT_READ_TIMEOUT_IN_SEC = 30;
-
- public final static int DEFAULT_CONNECT_TIMEOUT = 30;
-
- public final static int DEFAULT_SOCKET_TIMEOUT = 30;
-
- private CloseableHttpClient httpClient = null;
-
- private PoolingHttpClientConnectionManager cm = null;
-
- private static Logger logger = LoggerFactory.getLogger(HttpRestClient.class.getName());
-
- private RestResponse errorRestResponse = new RestResponse("internal server error", null, 500);
- private RestResponseAsByteArray errorRestResponseAsByteArray = new RestResponseAsByteArray(
- "internal server error".getBytes(), null, 500);
-
- boolean isInitialized = false;
-
- // public static void main(String[] argv) {
- // try {
- // RestClientService restClientService =
- // RestClientServiceFactory.createHttpRestClientService(new
- // RestConfigurationInfo());
- //
- // String uriCreateCell =
- // "http://172.20.37.245:9082/topology/management/cell/update";
- // String jsonStr = " { \"cellName\" : \"mycell118\" }";
- // String jsonUpdateStr =
- // " { \"cellName\" : \"mycell118\", \"hostName\" : \"myhost333\" }";
- //
- //
- // // jsonStr = " <note>dfd</note>";
- //
- // Properties headers = new Properties();
- // headers.put("Content-type", "application/json");
- // headers.put("Accept", "*/*");
- //
- // // RestResponse restResponse = restClientService.doPOST(uriCreateCell,
- // headers, jsonStr);
- //
- // RestResponse restResponse = restClientService.doPUT(uriCreateCell,
- // headers, jsonUpdateStr);
- //
- // System.out.println(restResponse);
- //
- //
- // } catch (RestClientServiceExeption e) {
- // e.printStackTrace();
- // }
- //
- // }
-
- public HttpRestClient() {
- super();
- isInitialized = init(new RestConfigurationInfo());
- }
-
- public HttpRestClient(RestConfigurationInfo restConfigurationInfo) {
- super();
- isInitialized = init(restConfigurationInfo);
- }
-
- public boolean init(RestConfigurationInfo restConfigurationInfo) {
-
- logger.debug("create HttpRestClient: restConfigurationInfo= {}", restConfigurationInfo);
- boolean result = false;
- createHttpClient(restConfigurationInfo);
- result = true;
-
- logger.debug("Finish creating HttpRestClient. Result is {}", result);
- return result;
- }
-
- public void destroy() {
-
- try {
- httpClient.close();
- logger.debug("Http client closed");
- } catch (Exception e) {
- logger.trace("Failed to close http client", e);
- }
-
- }
-
- private void createHttpClient(RestConfigurationInfo restConfigurationInfo) {
- // throws KeyManagementException, NoSuchAlgorithmException {
-
- PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager();
-
- int connPoolSize = getConnectionPoolSize(restConfigurationInfo);
- connManager.setMaxTotal(connPoolSize);
- connManager.setDefaultMaxPerRoute(10);
- connManager.setValidateAfterInactivity(15000);
-
- // Create common default configuration
- int socketTimeout = getTimeout(restConfigurationInfo.getSocketTimeoutInSec(), DEFAULT_SOCKET_TIMEOUT);
-
- int connectTimeoutInSec = getTimeout(restConfigurationInfo.getConnectTimeoutInSec(), DEFAULT_CONNECT_TIMEOUT);
-
- int readTimeOut = getTimeout(restConfigurationInfo.getReadTimeoutInSec(), DEFAULT_READ_TIMEOUT_IN_SEC);
-
- RequestConfig clientConfig = RequestConfig.custom().setConnectTimeout(connectTimeoutInSec)
- .setSocketTimeout(socketTimeout).setConnectionRequestTimeout(readTimeOut).build();
-
- this.cm = connManager;
-
- this.httpClient = HttpClients.custom().setDefaultRequestConfig(clientConfig).setConnectionManager(connManager)
- .build();
-
- }
-
- private int getConnectionPoolSize(RestConfigurationInfo restConfigurationInfo) {
- Integer connPoolSizeObj = restConfigurationInfo.getConnectionPoolSize();
- int connPoolSize = DEFAULT_CONNECTION_POOL_SIZE;
- if (connPoolSizeObj != null) {
- connPoolSize = connPoolSizeObj.intValue();
- if (connPoolSize <= 0) {
- connPoolSize = DEFAULT_CONNECTION_POOL_SIZE;
- }
- }
- return connPoolSize;
- }
-
- private int getTimeout(Integer value, Integer defaultValue) {
-
- int defaultTimeout = defaultValue != null ? defaultValue.intValue() * 1000 : 0;
-
- int timeout = defaultTimeout;
-
- if (value != null) {
- timeout = defaultValue.intValue() * 1000;
- if (timeout <= 0) {
- timeout = defaultTimeout;
- }
- }
-
- return timeout;
- }
-
- /**
- * Executes RS-GET to perform FIND.
- *
- * @param headerParameterKey
- * String
- * @param headerParameterValue
- * String
- * @return String
- */
- public RestResponse doGET(String uri, Properties headers) {
-
- logger.debug("Before executing uri {}. headers = {}", uri, headers);
-
- HttpGet httpGet = new HttpGet(uri);
-
- RestResponse response = execute(httpGet, headers);
-
- return response;
- }
-
- public RestResponse doPUT(String uri, Properties headers, String body) {
-
- logger.debug("Before executing uri {}. headers = {}.body = {}", uri, headers, body);
-
- HttpPut httpPut = new HttpPut(uri);
- StringEntity data = new StringEntity(body, ContentType.APPLICATION_JSON);
- httpPut.setEntity(data);
- RestResponse response = execute(httpPut, headers);
-
- return response;
- }
-
- public RestResponse doPOST(String uri, Properties headers, String body) {
-
- logger.debug("Before executing uri {}. headers = {}.body = {}", uri, headers, body);
-
- HttpPost httpPost = new HttpPost(uri);
- StringEntity data = new StringEntity(body, ContentType.APPLICATION_JSON);
- httpPost.setEntity(data);
- RestResponse response = execute(httpPost, headers);
-
- return response;
- }
-
- public RestResponseAsByteArray doGetAsByteArray(String uri, Properties headers) {
-
- logger.debug("Before executing uri {}. headers = {}", uri, headers);
-
- HttpGet httpGet = new HttpGet(uri);
-
- RestResponseAsByteArray response = executeAndReturnByteArray(httpGet, headers);
-
- return response;
- }
-
- private void addHeadersToRequest(HttpRequestBase httpRequestBase, Properties headers) {
-
- if (headers != null) {
- for (Entry<Object, Object> entry : headers.entrySet()) {
- httpRequestBase.addHeader(entry.getKey().toString(), entry.getValue().toString());
- }
- }
-
- }
-
- private RestResponse execute(HttpRequestBase httpRequestBase, Properties headers) {
-
- RestResponse restResponse = null;
-
- CloseableHttpResponse httpResponse = null;
-
- try {
-
- addHeadersToRequest(httpRequestBase, headers);
-
- httpResponse = this.httpClient.execute(httpRequestBase);
-
- restResponse = buildRestResponseFromResult(httpResponse);
-
- logger.debug("After executing uri {}. response = {}", httpRequestBase.getURI().toString(), restResponse);
-
- } catch (Exception exception) {
- httpRequestBase.abort();
-
- String description = "Failed executing http request " + httpRequestBase.getURI().toString() + "("
- + httpRequestBase.getMethod() + ")";
- BeEcompErrorManager.getInstance().logInternalFlowError("ExecuteRestRequest", description,
- ErrorSeverity.ERROR);
- restResponse = errorRestResponse;
- } finally {
- // ensure the connection gets released to the manager
- releaseResource(httpResponse);
- }
-
- return restResponse;
- }
-
- private RestResponse buildRestResponseFromResult(CloseableHttpResponse httpResponse) throws IOException {
-
- int statusCode = httpResponse.getStatusLine().getStatusCode();
- String statusDesc = httpResponse.getStatusLine().getReasonPhrase();
-
- HttpEntity entity = httpResponse.getEntity();
- String response = null;
- if (entity != null) {
- response = EntityUtils.toString(entity);
- }
-
- RestResponse restResponse = new RestResponse(response, statusDesc, statusCode);
-
- return restResponse;
- }
-
- private RestResponseAsByteArray buildRestResponseByteArrayFromResult(CloseableHttpResponse httpResponse)
- throws IOException {
-
- int statusCode = httpResponse.getStatusLine().getStatusCode();
- String statusDesc = httpResponse.getStatusLine().getReasonPhrase();
-
- HttpEntity entity = httpResponse.getEntity();
-
- byte[] response = null;
- if (entity != null) {
- InputStream content = entity.getContent();
- if (content != null) {
- response = IOUtils.toByteArray(content);
- }
- }
-
- RestResponseAsByteArray restResponse = new RestResponseAsByteArray(response, statusDesc, statusCode);
-
- return restResponse;
- }
-
- private RestResponseAsByteArray executeAndReturnByteArray(HttpRequestBase httpRequestBase, Properties headers) {
-
- RestResponseAsByteArray restResponse = null;
-
- CloseableHttpResponse httpResponse = null;
-
- try {
-
- addHeadersToRequest(httpRequestBase, headers);
-
- httpResponse = this.httpClient.execute(httpRequestBase);
-
- restResponse = buildRestResponseByteArrayFromResult(httpResponse);
-
- if (restResponse != null) {
- logger.debug("After executing uri {}. Response: {}", httpRequestBase.getURI().toString(), restResponse.toPrettyString());
- }
-
- } catch (Exception exception) {
- httpRequestBase.abort();
- String description = "Failed executing http request " + httpRequestBase.getURI().toString() + "("
- + httpRequestBase.getMethod() + ")";
- BeEcompErrorManager.getInstance().logInternalFlowError("ExecuteRestRequest", description,
- ErrorSeverity.ERROR);
- logger.debug(description, exception);
- restResponse = errorRestResponseAsByteArray;
- } finally {
- // ensure the connection gets released to the manager
- releaseResource(httpResponse);
- }
-
- return restResponse;
- }
-
- /**
- * This method print the JSON response from the REST Server
- *
- * @param response
- * the JSON response from the REST server
- * @param method
- * name of method
- */
- private void logResponse(String response, String method) {
- logger.trace("{} response = {}", method, response);
- }
-
- private void releaseResource(CloseableHttpResponse response) {
- if (response != null) {
- try {
- HttpEntity entity = response.getEntity();
- if (entity != null) {
- EntityUtils.consume(entity);
- }
- response.close();
- } catch (Exception e) {
- logger.error("failed to close connection exception", e);
- }
- }
- }
-
- public boolean isInitialized() {
- return isInitialized;
- }
-
-}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/rest/RestConfigurationInfo.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/rest/RestConfigurationInfo.java
deleted file mode 100644
index 1e45ba6ae3..0000000000
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/rest/RestConfigurationInfo.java
+++ /dev/null
@@ -1,110 +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.dao.rest;
-
-public class RestConfigurationInfo {
-
- private Integer readTimeoutInSec = null;
-
- private Boolean ignoreCertificate = null;
-
- private Integer connectionPoolSize = null;
-
- private Integer connectTimeoutInSec = null;
-
- private Integer socketTimeoutInSec = null;
-
- /**
- * @return the readTimeoutInSec
- */
- public Integer getReadTimeoutInSec() {
- return readTimeoutInSec;
- }
-
- /**
- * @param readTimeoutInSec
- * the readTimeoutInSec to set
- */
- public void setReadTimeoutInSec(Integer readTimeoutInSec) {
- this.readTimeoutInSec = readTimeoutInSec;
- }
-
- /**
- * @return the ignoreCertificate
- */
- public Boolean getIgnoreCertificate() {
- return ignoreCertificate;
- }
-
- /**
- * @param ignoreCertificate
- * the ignoreCertificate to set
- */
- public void setIgnoreCertificate(Boolean ignoreCertificate) {
- this.ignoreCertificate = ignoreCertificate;
- }
-
- /**
- * @return the connectionPoolSize
- */
- public Integer getConnectionPoolSize() {
- return connectionPoolSize;
- }
-
- /**
- * @param connectionPoolSize
- * the connectionPoolSize to set
- */
- public void setConnectionPoolSize(Integer connectionPoolSize) {
- this.connectionPoolSize = connectionPoolSize;
- }
-
- /**
- * @return the connectTimeoutInSec
- */
- public Integer getConnectTimeoutInSec() {
- return connectTimeoutInSec;
- }
-
- /**
- * @param connectTimeoutInSec
- * the connectTimeoutInSec to set
- */
- public void setConnectTimeoutInSec(Integer connectTimeoutInSec) {
- this.connectTimeoutInSec = connectTimeoutInSec;
- }
-
- public Integer getSocketTimeoutInSec() {
- return socketTimeoutInSec;
- }
-
- public void setSocketTimeoutInSec(Integer socketTimeoutInSec) {
- this.socketTimeoutInSec = socketTimeoutInSec;
- }
-
- @Override
- public String toString() {
- return "RestConfigurationInfo [readTimeoutInSec=" + readTimeoutInSec + ", ignoreCertificate="
- + ignoreCertificate + ", connectionPoolSize=" + connectionPoolSize + ", connectTimeoutInSec="
- + connectTimeoutInSec + ", socketTimeoutInSec=" + socketTimeoutInSec + "]";
- }
-
-}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/titan/TitanGenericDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/titan/TitanGenericDao.java
index 8bd190f932..1db807fa0e 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/titan/TitanGenericDao.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/titan/TitanGenericDao.java
@@ -20,15 +20,14 @@
package org.openecomp.sdc.be.dao.titan;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.stream.Collectors;
-import java.util.stream.StreamSupport;
-
+import com.thinkaurelius.titan.core.PropertyKey;
+import com.thinkaurelius.titan.core.TitanEdge;
+import com.thinkaurelius.titan.core.TitanGraph;
+import com.thinkaurelius.titan.core.TitanGraphQuery;
+import com.thinkaurelius.titan.core.TitanVertex;
+import com.thinkaurelius.titan.core.TitanVertexQuery;
+import com.thinkaurelius.titan.graphdb.query.TitanPredicate;
+import fj.data.Either;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.ImmutableTriple;
import org.apache.tinkerpop.gremlin.structure.Direction;
@@ -52,15 +51,14 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
-import com.thinkaurelius.titan.core.PropertyKey;
-import com.thinkaurelius.titan.core.TitanEdge;
-import com.thinkaurelius.titan.core.TitanGraph;
-import com.thinkaurelius.titan.core.TitanGraphQuery;
-import com.thinkaurelius.titan.core.TitanVertex;
-import com.thinkaurelius.titan.core.TitanVertexQuery;
-import com.thinkaurelius.titan.graphdb.query.TitanPredicate;
-
-import fj.data.Either;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.stream.Collectors;
+import java.util.stream.StreamSupport;
@Component("titan-generic-dao")
public class TitanGenericDao {
@@ -908,7 +906,7 @@ public class TitanGenericDao {
return true;
}
- public <T extends GraphNode> Either<List<T>, TitanOperationStatus> getByCriteriaWithPradicat(NodeTypeEnum type, Map<String, Entry<TitanPredicate, Object>> props, Class<T> clazz) {
+ public <T extends GraphNode> Either<List<T>, TitanOperationStatus> getByCriteriaWithPredicate(NodeTypeEnum type, Map<String, Entry<TitanPredicate, Object>> props, Class<T> clazz) {
Either<TitanGraph, TitanOperationStatus> graph = titanClient.getGraph();
if (graph.isLeft()) {
try {
@@ -1111,6 +1109,14 @@ public class TitanGenericDao {
}
+ public Either<Boolean, TitanOperationStatus> isRelationExist(GraphNode from, GraphNode to, GraphEdgeLabels edgeLabel) {
+ return getEdgeByNodes(from, to, edgeLabel)
+ .left()
+ .map(edge -> true)
+ .right()
+ .bind(err -> err == TitanOperationStatus.NOT_FOUND ? Either.left(false): Either.right(err));
+ }
+
public Either<GraphRelation, TitanOperationStatus> deleteRelation(GraphNode from, GraphNode to, GraphEdgeLabels label) {
logger.debug("try to delete relation from [{}] to [{}]", from.getKeyValueId(), to.getKeyValueId());
return deleteEdge(label.getProperty(), from.getKeyValueId(), to.getKeyValueId(), from.getLabel(), to.getLabel());
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/titan/TitanGraphClient.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/titan/TitanGraphClient.java
index edcf70f093..7d151f1a3e 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/titan/TitanGraphClient.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/titan/TitanGraphClient.java
@@ -392,10 +392,8 @@ public class TitanGraphClient {
private void logAlarm() {
if (lastHealthState == true) {
- BeEcompErrorManager.getInstance().processEcompError(EcompErrorName.BeHealthCheckRecovery, TITAN_HEALTH_CHECK_STR);
BeEcompErrorManager.getInstance().logBeHealthCheckTitanRecovery(TITAN_HEALTH_CHECK_STR);
} else {
- BeEcompErrorManager.getInstance().processEcompError(EcompErrorName.BeHealthCheckError, TITAN_HEALTH_CHECK_STR);
BeEcompErrorManager.getInstance().logBeHealthCheckTitanError(TITAN_HEALTH_CHECK_STR);
}
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/titan/TitanUtils.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/titan/TitanUtils.java
new file mode 100644
index 0000000000..163ef807fb
--- /dev/null
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/titan/TitanUtils.java
@@ -0,0 +1,27 @@
+package org.openecomp.sdc.be.dao.titan;
+
+import com.thinkaurelius.titan.graphdb.query.TitanPredicate;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import static com.thinkaurelius.titan.core.attribute.Contain.NOT_IN;
+import static java.util.Collections.emptyMap;
+import static org.apache.commons.collections.CollectionUtils.isEmpty;
+
+public class TitanUtils {
+
+ private TitanUtils() {
+ }
+
+ public static <T> Map<String, Entry<TitanPredicate, Object>> buildNotInPredicate(String propKey, Collection<T> notInCollection) {
+ if (isEmpty(notInCollection)) {
+ return emptyMap();
+ }
+ Map<String, Entry<TitanPredicate, Object>> predicateCriteria = new HashMap<>();
+ predicateCriteria.put(propKey, new HashMap.SimpleEntry<>(NOT_IN, notInCollection));
+ return predicateCriteria;
+ }
+}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/utils/MapUtil.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/utils/MapUtil.java
index e8b2e0c9ad..991fb0b29f 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/utils/MapUtil.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/utils/MapUtil.java
@@ -20,15 +20,13 @@
package org.openecomp.sdc.be.dao.utils;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
+import java.util.*;
import java.util.function.Function;
+import java.util.stream.Collector;
import java.util.stream.Collectors;
+import static java.util.stream.Collectors.groupingBy;
+
/**
* Utility class to ease map manipulation.
*/
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/AdditionalInfoParameterData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/AdditionalInfoParameterData.java
index a5a6e6df76..8c3742e474 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/AdditionalInfoParameterData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/AdditionalInfoParameterData.java
@@ -20,16 +20,15 @@
package org.openecomp.sdc.be.resources.data;
-import java.lang.reflect.Type;
-import java.util.HashMap;
-import java.util.Map;
-
+import com.google.gson.reflect.TypeToken;
import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
import org.openecomp.sdc.be.datatypes.elements.AdditionalInfoParameterDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import com.google.gson.reflect.TypeToken;
+import java.lang.reflect.Type;
+import java.util.HashMap;
+import java.util.Map;
public class AdditionalInfoParameterData extends GraphNode {
@@ -118,7 +117,7 @@ public class AdditionalInfoParameterData extends GraphNode {
}
@Override
- public Object getUniqueId() {
+ public String getUniqueId() {
return additionalInfoParameterDataDefinition.getUniqueId();
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ArtifactData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ArtifactData.java
index 84d9663e59..7114413f41 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ArtifactData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ArtifactData.java
@@ -20,18 +20,17 @@
package org.openecomp.sdc.be.resources.data;
-import java.lang.reflect.Type;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
+import com.google.gson.reflect.TypeToken;
import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum;
-import com.google.gson.reflect.TypeToken;
+import java.lang.reflect.Type;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
public class ArtifactData extends GraphNode {
@@ -104,7 +103,7 @@ public class ArtifactData extends GraphNode {
}
@Override
- public Object getUniqueId() {
+ public String getUniqueId() {
return artifactDataDefinition.getUniqueId();
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/CapabilityData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/CapabilityData.java
index 9f04c56be2..d2b1336ce1 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/CapabilityData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/CapabilityData.java
@@ -20,17 +20,16 @@
package org.openecomp.sdc.be.resources.data;
-import java.lang.reflect.Type;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
+import com.google.gson.reflect.TypeToken;
import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
import org.openecomp.sdc.be.datatypes.elements.CapabilityDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import com.google.gson.reflect.TypeToken;
+import java.lang.reflect.Type;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
public class CapabilityData extends GraphNode {
@@ -76,6 +75,7 @@ public class CapabilityData extends GraphNode {
private String minOccurrences = CapabilityDataDefinition.MIN_OCCURRENCES;
private String maxOccurrences = CapabilityDataDefinition.MAX_OCCURRENCES;
+ @Override
public String getUniqueId() {
return uniqueId;
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/CapabilityInstData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/CapabilityInstData.java
index 0b5da1217d..1e456d3490 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/CapabilityInstData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/CapabilityInstData.java
@@ -20,16 +20,15 @@
package org.openecomp.sdc.be.resources.data;
-import java.lang.reflect.Type;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
+import com.google.gson.reflect.TypeToken;
import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import com.google.gson.reflect.TypeToken;
+import java.lang.reflect.Type;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
public class CapabilityInstData extends GraphNode {
@@ -65,6 +64,7 @@ public class CapabilityInstData extends GraphNode {
private Long modificationTime;
+ @Override
public String getUniqueId() {
return uniqueId;
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/CategoryData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/CategoryData.java
index 4cfde8b0fa..7a2e0b5141 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/CategoryData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/CategoryData.java
@@ -20,13 +20,13 @@
package org.openecomp.sdc.be.resources.data;
-import java.util.HashMap;
-import java.util.Map;
-
import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
+import java.util.HashMap;
+import java.util.Map;
+
public abstract class CategoryData extends GraphNode {
private String name;
@@ -107,7 +107,7 @@ public abstract class CategoryData extends GraphNode {
}
@Override
- public Object getUniqueId() {
+ public String getUniqueId() {
return uniqueId;
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ComponentMetadataData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ComponentMetadataData.java
index fb58e9abff..52dd34be1b 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ComponentMetadataData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ComponentMetadataData.java
@@ -20,17 +20,16 @@
package org.openecomp.sdc.be.resources.data;
-import java.lang.reflect.Type;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
+import com.google.gson.reflect.TypeToken;
import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
import org.openecomp.sdc.be.datatypes.components.ComponentMetadataDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import com.google.gson.reflect.TypeToken;
+import java.lang.reflect.Type;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
public abstract class ComponentMetadataData extends GraphNode {
@@ -108,7 +107,7 @@ public abstract class ComponentMetadataData extends GraphNode {
}
@Override
- public Object getUniqueId() {
+ public String getUniqueId() {
return metadataDataDefinition.getUniqueId();
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ConsumerData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ConsumerData.java
index 3fb085f3d2..88c9c7097a 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ConsumerData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ConsumerData.java
@@ -20,14 +20,14 @@
package org.openecomp.sdc.be.resources.data;
-import java.util.HashMap;
-import java.util.Map;
-
import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
import org.openecomp.sdc.be.datatypes.elements.ConsumerDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
+import java.util.HashMap;
+import java.util.Map;
+
public class ConsumerData extends GraphNode {
private ConsumerDataDefinition consumerDataDefinition;
@@ -67,7 +67,7 @@ public class ConsumerData extends GraphNode {
}
@Override
- public Object getUniqueId() {
+ public String getUniqueId() {
return consumerDataDefinition.getConsumerName();
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/GraphNodeLock.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/GraphNodeLock.java
index 200521c054..68b362b293 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/GraphNodeLock.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/GraphNodeLock.java
@@ -20,13 +20,13 @@
package org.openecomp.sdc.be.resources.data;
-import java.util.HashMap;
-import java.util.Map;
-
import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
+import java.util.HashMap;
+import java.util.Map;
+
public class GraphNodeLock extends GraphNode {
private String uniqueId;
@@ -50,7 +50,7 @@ public class GraphNodeLock extends GraphNode {
}
@Override
- public Object getUniqueId() {
+ public String getUniqueId() {
return uniqueId;
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/GroupData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/GroupData.java
index e354e95b27..93f03e415a 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/GroupData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/GroupData.java
@@ -20,14 +20,14 @@
package org.openecomp.sdc.be.resources.data;
-import java.util.HashMap;
-import java.util.Map;
-
import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
import org.openecomp.sdc.be.datatypes.elements.GroupDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
+import java.util.HashMap;
+import java.util.Map;
+
public class GroupData extends GraphNode {
GroupDataDefinition groupDataDefinition;
@@ -63,7 +63,7 @@ public class GroupData extends GraphNode {
}
@Override
- public Object getUniqueId() {
+ public String getUniqueId() {
return groupDataDefinition.getUniqueId();
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/HeatParameterData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/HeatParameterData.java
index 7115a45bf3..c9dbc67b94 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/HeatParameterData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/HeatParameterData.java
@@ -20,16 +20,16 @@
package org.openecomp.sdc.be.resources.data;
-import java.math.BigDecimal;
-import java.util.HashMap;
-import java.util.Map;
-
import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
import org.openecomp.sdc.be.dao.utils.Constants;
import org.openecomp.sdc.be.datatypes.elements.HeatParameterDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
+import java.math.BigDecimal;
+import java.util.HashMap;
+import java.util.Map;
+
public class HeatParameterData extends GraphNode {
private HeatParameterDataDefinition heatDataDefinition;
@@ -134,7 +134,7 @@ public class HeatParameterData extends GraphNode {
}
@Override
- public Object getUniqueId() {
+ public String getUniqueId() {
return heatDataDefinition.getUniqueId();
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/HeatParameterValueData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/HeatParameterValueData.java
index ecabe22b80..a7f52a0bf3 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/HeatParameterValueData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/HeatParameterValueData.java
@@ -20,14 +20,14 @@
package org.openecomp.sdc.be.resources.data;
-import java.util.HashMap;
-import java.util.Map;
-
import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
import org.openecomp.sdc.be.dao.utils.Constants;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
+import java.util.HashMap;
+import java.util.Map;
+
public class HeatParameterValueData extends GraphNode {
public HeatParameterValueData() {
@@ -52,7 +52,7 @@ public class HeatParameterValueData extends GraphNode {
private String value;
@Override
- public Object getUniqueId() {
+ public String getUniqueId() {
return uniqueId;
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/InputValueData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/InputValueData.java
index 1ed3ef1135..be45c855a4 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/InputValueData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/InputValueData.java
@@ -20,15 +20,15 @@
package org.openecomp.sdc.be.resources.data;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Objects;
-
import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
import org.openecomp.sdc.be.dao.utils.Constants;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+
public class InputValueData extends GraphNode {
private String uniqueId;
@@ -68,6 +68,7 @@ public class InputValueData extends GraphNode {
}
+ @Override
public String getUniqueId() {
return uniqueId;
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/InputsData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/InputsData.java
index 3bb71d5bed..2152619d00 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/InputsData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/InputsData.java
@@ -20,11 +20,7 @@
package org.openecomp.sdc.be.resources.data;
-import java.lang.reflect.Type;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
+import com.google.gson.reflect.TypeToken;
import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
import org.openecomp.sdc.be.dao.utils.Constants;
@@ -32,7 +28,10 @@ import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.SchemaDefinition;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import com.google.gson.reflect.TypeToken;
+import java.lang.reflect.Type;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
public class InputsData extends GraphNode {
@@ -129,7 +128,7 @@ public class InputsData extends GraphNode {
}
@Override
- public Object getUniqueId() {
+ public String getUniqueId() {
return propertyDataDefinition.getUniqueId();
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/OperationData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/OperationData.java
index d87cfe8853..cf05ad0eb9 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/OperationData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/OperationData.java
@@ -20,14 +20,14 @@
package org.openecomp.sdc.be.resources.data;
-import java.util.HashMap;
-import java.util.Map;
-
import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
import org.openecomp.sdc.be.datatypes.elements.OperationDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
+import java.util.HashMap;
+import java.util.Map;
+
public class OperationData extends GraphNode {
OperationDataDefinition operationDataDefinition;
@@ -69,7 +69,7 @@ public class OperationData extends GraphNode {
}
@Override
- public Object getUniqueId() {
+ public String getUniqueId() {
return operationDataDefinition.getUniqueId();
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/OperationalEnvironmentEntry.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/OperationalEnvironmentEntry.java
new file mode 100644
index 0000000000..5b3c282bd7
--- /dev/null
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/OperationalEnvironmentEntry.java
@@ -0,0 +1,137 @@
+package org.openecomp.sdc.be.resources.data;
+
+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.datatypes.enums.EnvironmentStatusEnum;
+
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Set;
+
+@Table(keyspace = "sdcrepository", name = "operationalEnvironment")
+public class OperationalEnvironmentEntry {
+
+ @PartitionKey(0)
+ @Column(name = "environment_id")
+ private String environmentId;
+
+ @Column(name = "tenant")
+ private String tenant;
+
+ @Column(name = "is_production")
+ private Boolean isProduction;
+
+ @Column(name = "ecomp_workload_context")
+ private String ecompWorkloadContext;
+
+ @Column(name = "dmaap_ueb_address")
+ private Set<String> dmaapUebAddress;
+
+ @Column(name = "ueb_api_key")
+ private String uebApikey;
+
+ @Column(name = "ueb_secret_key")
+ private String uebSecretKey;
+
+ @Column(name = "status")
+ private String status;
+
+ public Date getLastModified() {
+ return lastModified;
+ }
+
+ public void setLastModified(Date lastModified) {
+ this.lastModified = lastModified;
+ }
+
+ @Column(name = "last_modified")
+ private Date lastModified;
+
+
+ public String getEnvironmentId() {
+ return environmentId;
+ }
+
+ //must be unique, add any validation if neccessary
+ public void setEnvironmentId(String environmentId) {
+ this.environmentId = environmentId;
+ }
+
+ public String getTenant() {
+ return tenant;
+ }
+
+ public void setTenant(String tenant) {
+ this.tenant = tenant;
+ }
+
+ public Boolean getIsProduction() {
+ return isProduction;
+ }
+
+ public void setIsProduction(Boolean production) {
+ isProduction = production;
+ }
+
+ public String getEcompWorkloadContext() {
+ return ecompWorkloadContext;
+ }
+
+ public void setEcompWorkloadContext(String ecompWorkloadContext) {
+ this.ecompWorkloadContext = ecompWorkloadContext;
+ }
+
+ public String getStatus() {
+ return status;
+ }
+
+ public void setStatus(String status) {
+ //log if status doesn't exists in EnvironmentStatusEnum
+ this.status = status;
+ }
+
+ public void setStatus(EnvironmentStatusEnum status) {
+ this.status = status.getName();
+ }
+
+ public Set<String> getDmaapUebAddress() {
+ return dmaapUebAddress;
+ }
+
+ public void setDmaapUebAddress(Set<String> dmaapUebAddress) {
+ this.dmaapUebAddress = dmaapUebAddress;
+ }
+
+ public void addDmaapUebAddress(String address) {
+ if ( this.dmaapUebAddress == null )
+ this.dmaapUebAddress = new HashSet<>();
+ dmaapUebAddress.add(address);
+ }
+
+ public String getUebApikey() {
+ return uebApikey;
+ }
+
+ public void setUebApikey(String uebApikey) {
+ this.uebApikey = uebApikey;
+ }
+
+ public String getUebSecretKey() {
+ return uebSecretKey;
+ }
+
+ public void setUebSecretKey(String uebSecretKey) {
+ this.uebSecretKey = uebSecretKey;
+ }
+
+ @Override
+ public String toString() {
+ return "OperationalEnvironmentEntry [environmentId=" + environmentId + ", tenant=" + tenant + ", isProduction="
+ + isProduction + ", ecompWorkloadContext=" + ecompWorkloadContext + ", dmaapUebAddress="
+ + dmaapUebAddress + ", uebApikey=" + uebApikey + ", status=" + status
+ + ", lastModified=" + lastModified + "]";
+ }
+
+
+}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/PolicyTypeData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/PolicyTypeData.java
index 62f2ad5e12..8f2293aff7 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/PolicyTypeData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/PolicyTypeData.java
@@ -7,9 +7,9 @@
* 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.
@@ -20,111 +20,106 @@
package org.openecomp.sdc.be.resources.data;
-import java.lang.reflect.Type;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
+import com.google.gson.reflect.TypeToken;
import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
import org.openecomp.sdc.be.datatypes.elements.PolicyTypeDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import com.google.gson.reflect.TypeToken;
+import java.lang.reflect.Type;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
public class PolicyTypeData extends GraphNode {
- private PolicyTypeDataDefinition policyTypeDataDefinition;
- private static final Type mapType = new TypeToken<HashMap<String, String>>() {
- }.getType();
- private static final Type listType = new TypeToken<List<String>>() {
- }.getType();
-
- public PolicyTypeData() {
- super(NodeTypeEnum.PolicyType);
- policyTypeDataDefinition = new PolicyTypeDataDefinition();
- }
+ private PolicyTypeDataDefinition policyTypeDataDefinition;
+ private static final Type mapType = new TypeToken<HashMap<String, String>>() {
+ }.getType();
+ private static final Type listType = new TypeToken<List<String>>() {
+ }.getType();
- public PolicyTypeData(PolicyTypeDataDefinition policyTypeDataDefinition) {
- super(NodeTypeEnum.PolicyType);
- this.policyTypeDataDefinition = policyTypeDataDefinition;
- }
+ public PolicyTypeData() {
+ super(NodeTypeEnum.PolicyType);
+ policyTypeDataDefinition = new PolicyTypeDataDefinition();
+ }
- public PolicyTypeData(Map<String, Object> properties) {
+ public PolicyTypeData(PolicyTypeDataDefinition policyTypeDataDefinition) {
+ super(NodeTypeEnum.PolicyType);
+ this.policyTypeDataDefinition = policyTypeDataDefinition;
+ }
- this();
+ public PolicyTypeData(Map<String, Object> properties) {
- policyTypeDataDefinition
- .setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
+ this();
- HashMap<String, String> metatdata = getGson()
- .fromJson((String) properties.get(GraphPropertiesDictionary.METADATA.getProperty()), mapType);
- policyTypeDataDefinition.setMetadata(metatdata);
+ policyTypeDataDefinition
+ .setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
- List<String> members = getGson()
- .fromJson((String) properties.get(GraphPropertiesDictionary.TARGETS.getProperty()), listType);
- policyTypeDataDefinition.setTargets(members);
+ HashMap<String, String> metatdata = getGson()
+ .fromJson((String) properties.get(GraphPropertiesDictionary.METADATA.getProperty()), mapType);
+ policyTypeDataDefinition.setMetadata(metatdata);
- policyTypeDataDefinition.setType((String) properties.get(GraphPropertiesDictionary.TYPE.getProperty()));
+ List<String> members = getGson()
+ .fromJson((String) properties.get(GraphPropertiesDictionary.TARGETS.getProperty()), listType);
+ policyTypeDataDefinition.setTargets(members);
+ policyTypeDataDefinition.setType((String) properties.get(GraphPropertiesDictionary.TYPE.getProperty()));
- policyTypeDataDefinition
- .setDescription((String) properties.get(GraphPropertiesDictionary.DESCRIPTION.getProperty()));
+ policyTypeDataDefinition
+ .setDescription((String) properties.get(GraphPropertiesDictionary.DESCRIPTION.getProperty()));
- policyTypeDataDefinition.setHighestVersion(
- (boolean) properties.get(GraphPropertiesDictionary.IS_HIGHEST_VERSION.getProperty()));
+ policyTypeDataDefinition.setHighestVersion(
+ (boolean) properties.get(GraphPropertiesDictionary.IS_HIGHEST_VERSION.getProperty()));
- policyTypeDataDefinition.setVersion((String) properties.get(GraphPropertiesDictionary.VERSION.getProperty()));
+ policyTypeDataDefinition.setVersion((String) properties.get(GraphPropertiesDictionary.VERSION.getProperty()));
- policyTypeDataDefinition
- .setCreationTime((Long) properties.get(GraphPropertiesDictionary.CREATION_DATE.getProperty()));
+ policyTypeDataDefinition
+ .setCreationTime((Long) properties.get(GraphPropertiesDictionary.CREATION_DATE.getProperty()));
- policyTypeDataDefinition
- .setModificationTime((Long) properties.get(GraphPropertiesDictionary.LAST_UPDATE_DATE.getProperty()));
+ policyTypeDataDefinition
+ .setModificationTime((Long) properties.get(GraphPropertiesDictionary.LAST_UPDATE_DATE.getProperty()));
- }
+ }
- @Override
- public Map<String, Object> toGraphMap() {
+ @Override
+ public Map<String, Object> toGraphMap() {
- Map<String, Object> map = new HashMap<String, Object>();
+ Map<String, Object> map = new HashMap<String, Object>();
- addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, policyTypeDataDefinition.getUniqueId());
+ addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, policyTypeDataDefinition.getUniqueId());
- addIfExists(map, GraphPropertiesDictionary.TYPE, policyTypeDataDefinition.getType());
+ addIfExists(map, GraphPropertiesDictionary.TYPE, policyTypeDataDefinition.getType());
- addIfExists(map, GraphPropertiesDictionary.VERSION, policyTypeDataDefinition.getVersion());
+ addIfExists(map, GraphPropertiesDictionary.VERSION, policyTypeDataDefinition.getVersion());
- addIfExists(map, GraphPropertiesDictionary.IS_HIGHEST_VERSION, policyTypeDataDefinition.isHighestVersion());
+ addIfExists(map, GraphPropertiesDictionary.IS_HIGHEST_VERSION, policyTypeDataDefinition.isHighestVersion());
- addIfExists(map, GraphPropertiesDictionary.DESCRIPTION, policyTypeDataDefinition.getDescription());
+ addIfExists(map, GraphPropertiesDictionary.DESCRIPTION, policyTypeDataDefinition.getDescription());
- addIfExists(map, GraphPropertiesDictionary.METADATA, policyTypeDataDefinition.getMetadata());
+ addIfExists(map, GraphPropertiesDictionary.METADATA, policyTypeDataDefinition.getMetadata());
- addIfExists(map, GraphPropertiesDictionary.TARGETS, policyTypeDataDefinition.getTargets());
+ addIfExists(map, GraphPropertiesDictionary.TARGETS, policyTypeDataDefinition.getTargets());
- addIfExists(map, GraphPropertiesDictionary.CREATION_DATE, policyTypeDataDefinition.getCreationTime());
+ addIfExists(map, GraphPropertiesDictionary.CREATION_DATE, policyTypeDataDefinition.getCreationTime());
- addIfExists(map, GraphPropertiesDictionary.LAST_UPDATE_DATE, policyTypeDataDefinition.getModificationTime());
+ addIfExists(map, GraphPropertiesDictionary.LAST_UPDATE_DATE, policyTypeDataDefinition.getModificationTime());
- return map;
- }
+ return map;
+ }
- @Override
- public String toString() {
- return "PolicyTypeData [policyTypeDataDefinition=" + policyTypeDataDefinition + "]";
- }
+ @Override
+ public String toString() {
+ return "PolicyTypeData [policyTypeDataDefinition=" + policyTypeDataDefinition + "]";
+ }
- @Override
- public String getUniqueId() {
- return this.policyTypeDataDefinition.getUniqueId();
- }
+ @Override
+ public String getUniqueId() {
+ return this.policyTypeDataDefinition.getUniqueId();
+ }
- public PolicyTypeDataDefinition getPolicyTypeDataDefinition() {
- return policyTypeDataDefinition;
- }
+ public PolicyTypeDataDefinition getPolicyTypeDataDefinition() {
+ return policyTypeDataDefinition;
+ }
- public void setPolicyTypeDataDefinition(PolicyTypeDataDefinition policyTypeDataDefinition) {
- this.policyTypeDataDefinition = policyTypeDataDefinition;
- }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/PropertyData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/PropertyData.java
index a72ec9465b..403e27db1a 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/PropertyData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/PropertyData.java
@@ -20,11 +20,7 @@
package org.openecomp.sdc.be.resources.data;
-import java.lang.reflect.Type;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
+import com.google.gson.reflect.TypeToken;
import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
import org.openecomp.sdc.be.dao.utils.Constants;
@@ -32,7 +28,10 @@ import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.SchemaDefinition;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import com.google.gson.reflect.TypeToken;
+import java.lang.reflect.Type;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
public class PropertyData extends GraphNode {
@@ -129,7 +128,7 @@ public class PropertyData extends GraphNode {
}
@Override
- public Object getUniqueId() {
+ public String getUniqueId() {
return propertyDataDefinition.getUniqueId();
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/PropertyValueData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/PropertyValueData.java
index 7577e57a7e..80044e288d 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/PropertyValueData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/PropertyValueData.java
@@ -20,18 +20,17 @@
package org.openecomp.sdc.be.resources.data;
-import java.lang.reflect.Type;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
+import com.google.gson.reflect.TypeToken;
import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
import org.openecomp.sdc.be.dao.utils.Constants;
import org.openecomp.sdc.be.datatypes.elements.PropertyRule;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import com.google.gson.reflect.TypeToken;
+import java.lang.reflect.Type;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
public class PropertyValueData extends GraphNode {
@@ -77,6 +76,7 @@ public class PropertyValueData extends GraphNode {
private List<PropertyRule> rules;
+ @Override
public String getUniqueId() {
return uniqueId;
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/TagData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/TagData.java
index de2412d7ed..92b8323e0d 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/TagData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/TagData.java
@@ -20,13 +20,13 @@
package org.openecomp.sdc.be.resources.data;
-import java.util.HashMap;
-import java.util.Map;
-
import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
+import java.util.HashMap;
+import java.util.Map;
+
public class TagData extends GraphNode {
private String name;
@@ -105,7 +105,7 @@ public class TagData extends GraphNode {
}
@Override
- public Object getUniqueId() {
+ public String getUniqueId() {
return name;
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/UniqueIdData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/UniqueIdData.java
index 30f9a66d79..fd3b8659a1 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/UniqueIdData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/UniqueIdData.java
@@ -20,11 +20,11 @@
package org.openecomp.sdc.be.resources.data;
-import java.util.Map;
-
import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
+import java.util.Map;
+
public class UniqueIdData extends GraphNode {
private String uniqueId;
@@ -35,7 +35,7 @@ public class UniqueIdData extends GraphNode {
}
@Override
- public Object getUniqueId() {
+ public String getUniqueId() {
return uniqueId;
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/UserData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/UserData.java
index 78974c4a77..dc4522fef9 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/UserData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/UserData.java
@@ -20,15 +20,15 @@
package org.openecomp.sdc.be.resources.data;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
-
import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
import org.openecomp.sdc.be.dao.utils.DaoUtils;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
public class UserData extends GraphNode {
private String firstName;
@@ -213,7 +213,7 @@ public class UserData extends GraphNode {
}
@Override
- public Object getUniqueId() {
+ public String getUniqueId() {
return userId;
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/UserFunctionalMenuData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/UserFunctionalMenuData.java
index 2a31f4bb68..263cc89bba 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/UserFunctionalMenuData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/UserFunctionalMenuData.java
@@ -20,14 +20,14 @@
package org.openecomp.sdc.be.resources.data;
-import java.util.HashMap;
-import java.util.Map;
-
import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
import org.openecomp.sdc.be.dao.utils.DaoUtils;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
+import java.util.HashMap;
+import java.util.Map;
+
public class UserFunctionalMenuData extends GraphNode {
private String uniqueId;
@@ -88,7 +88,7 @@ public class UserFunctionalMenuData extends GraphNode {
}
@Override
- public Object getUniqueId() {
+ public String getUniqueId() {
return uniqueId;
}
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
index 9e9836049f..09d37ac03d 100644
--- 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
@@ -20,12 +20,12 @@
package org.openecomp.sdc.be.resources.data.auditing;
-import java.util.EnumMap;
+import java.util.Map;
import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum;
public final class AuditRecordFactory {
- public static AuditingGenericEvent createAuditRecord(EnumMap<AuditingFieldsKeysEnum, Object> auditingFields) {
+ public static AuditingGenericEvent createAuditRecord(Map<AuditingFieldsKeysEnum, Object> auditingFields) {
AuditingActionEnum actionEnum = AuditingActionEnum
.getActionByName((String) auditingFields.get(AuditingFieldsKeysEnum.AUDIT_ACTION));
String tableName = actionEnum.getAuditingEsType();
@@ -76,9 +76,12 @@ public final class AuditRecordFactory {
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;
- }
+ 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 cfc37f19e2..e810925fcd 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
@@ -23,6 +23,7 @@ package org.openecomp.sdc.be.resources.data.auditing;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+//TODO rename to AuditAction
public enum AuditingActionEnum {
// User admininstration
@@ -53,6 +54,7 @@ public enum AuditingActionEnum {
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),
@@ -76,7 +78,14 @@ public enum AuditingActionEnum {
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),
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 bd8c032390..b5b99bf709 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
@@ -21,11 +21,9 @@
package org.openecomp.sdc.be.resources.data.auditing;
import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.EnumMap;
-import java.util.TimeZone;
-import java.util.UUID;
+import java.util.*;
+import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData;
import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum;
import com.datastax.driver.core.utils.UUIDs;
@@ -36,156 +34,167 @@ import com.datastax.driver.mapping.annotations.Table;
@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;
-
- @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 = "consumer_id")
- private String consumerId;
-
- public AuditingGetUebClusterEvent() {
- super();
- timestamp1 = new Date();
- timebaseduuid = UUIDs.timeBased();
- }
-
- public AuditingGetUebClusterEvent(EnumMap<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);
- }
-
- }
-
- @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());
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormatPattern);
- simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
- fields.put(AuditingFieldsKeysEnum.AUDIT_TIMESTAMP.getDisplayName(), simpleDateFormat.format(timestamp1));
-
- }
-
- public String getConsumerId() {
- return consumerId;
- }
-
- public void setConsumerId(String consumerId) {
- this.consumerId = consumerId;
- }
-
- 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;
- }
-
- @Override
- public String toString() {
- return "AuditingGetUebClusterEvent [timebaseduuid=" + timebaseduuid + ", timestamp1=" + timestamp1
- + ", requestId=" + requestId + ", serviceInstanceId=" + serviceInstanceId + ", action=" + action
- + ", status=" + status + ", desc=" + desc + ", consumerId=" + consumerId + "]";
- }
+ private static String DISTRIBUTION_GET_UEB_CLUSTER_EVENT_TEMPLATE = "action=\"%s\" "
+ + " consumerId=\"%s\" statusTime=\"%s\" status=\"%s\" status_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
+ protected String action;
+ @Column
+ protected String status;
+
+ @Column(name = "description")
+ protected String desc;
+
+ @Column(name = "consumer_id")
+ private String consumerId;
+
+ 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;
+ }
+
+ @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());
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormatPattern);
+ simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
+ fields.put(AuditingFieldsKeysEnum.AUDIT_TIMESTAMP.getDisplayName(), simpleDateFormat.format(timestamp1));
+
+ }
+
+ public String getConsumerId() {
+ return consumerId;
+ }
+
+ public void setConsumerId(String consumerId) {
+ this.consumerId = consumerId;
+ }
+
+ 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;
+ }
+
+ @Override
+ public String toString() {
+ return "AuditingGetUebClusterEvent [timebaseduuid=" + timebaseduuid + ", timestamp1=" + timestamp1
+ + ", requestId=" + requestId + ", serviceInstanceId=" + serviceInstanceId + ", action=" + action
+ + ", status=" + status + ", desc=" + desc + ", consumerId=" + consumerId + "]";
+ }
}
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 9f25932b37..26cc463725 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
@@ -40,11 +40,13 @@ public interface AuditingTypesConstants {
String DISTRIBUTION_GET_UEB_CLUSTER_EVENT_TYPE = "auditinggetuebclusterevent";
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";
}
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 5c8cded0db..8e8a42310e 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
@@ -21,11 +21,9 @@
package org.openecomp.sdc.be.resources.data.auditing;
import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.EnumMap;
-import java.util.TimeZone;
-import java.util.UUID;
+import java.util.*;
+import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData;
import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum;
import com.datastax.driver.core.utils.UUIDs;
@@ -153,7 +151,7 @@ public class AuthEvent extends AuditingGenericEvent {
this.requestId = requestId;
}
- public AuthEvent(EnumMap<AuditingFieldsKeysEnum, Object> auditingFields) {
+ public AuthEvent(Map<AuditingFieldsKeysEnum, Object> auditingFields) {
this();
Object value;
value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_AUTH_URL);
@@ -191,6 +189,18 @@ public class AuthEvent extends AuditingGenericEvent {
}
+ 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());
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 a970c84847..f85f67aa86 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
@@ -21,11 +21,9 @@
package org.openecomp.sdc.be.resources.data.auditing;
import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.EnumMap;
-import java.util.TimeZone;
-import java.util.UUID;
+import java.util.*;
+import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData;
import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum;
import com.datastax.driver.core.utils.UUIDs;
@@ -76,7 +74,7 @@ public class CategoryEvent extends AuditingGenericEvent {
timebaseduuid = UUIDs.timeBased();
}
- public CategoryEvent(EnumMap<AuditingFieldsKeysEnum, Object> auditingFields) {
+ public CategoryEvent(Map<AuditingFieldsKeysEnum, Object> auditingFields) {
this();
Object value;
value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_ACTION);
@@ -122,6 +120,21 @@ public class CategoryEvent extends AuditingGenericEvent {
}
+ 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() {
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 6c5bc3140d..81d27cae53 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
@@ -21,11 +21,9 @@
package org.openecomp.sdc.be.resources.data.auditing;
import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.EnumMap;
-import java.util.TimeZone;
-import java.util.UUID;
+import java.util.*;
+import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData;
import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum;
import com.datastax.driver.core.utils.UUIDs;
@@ -36,149 +34,159 @@ import com.datastax.driver.mapping.annotations.Table;
@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;
-
- @ClusteringColumn
- protected Date timestamp1;
-
- @Column(name = "request_id")
- protected String requestId;
- @Column
- protected String action;
- @Column
- protected String status;
-
- @Column(name = "description")
- protected String desc;
-
- @Column
- private String modifier;
-
- @Column(name = "ecomp_user")
- private String ecompUser;
-
- public ConsumerEvent() {
- super();
- timestamp1 = new Date();
- timebaseduuid = UUIDs.timeBased();
- }
-
- public ConsumerEvent(EnumMap<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);
- }
- }
-
- @Override
- public void fillFields() {
- fields.put(AuditingFieldsKeysEnum.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());
- 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 getEcompUser() {
- return ecompUser;
- }
-
- public void setEcompUser(String ecompUser) {
- this.ecompUser = ecompUser;
- }
-
- 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 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;
- }
-
- @Override
- public String toString() {
- return "ConsumerEvent [timebaseduuid=" + timebaseduuid + ", timestamp1=" + timestamp1 + ", requestId="
- + requestId + ", action=" + action + ", status=" + status + ", desc=" + desc + ", modifier=" + modifier
- + ", ecompUser=" + ecompUser + "]";
- }
+ private static String CONSUMER_EVENT_TEMPLATE = "action=\"%s\" timestamp=\"%s\" "
+ + "modifier=\"%s\" ecompUser=\"%s\" status=\"%s\" desc=\"%s\"";
+
+ @PartitionKey
+ protected UUID timebaseduuid;
+
+ @ClusteringColumn
+ protected Date timestamp1;
+
+ @Column(name = "request_id")
+ protected String requestId;
+ @Column
+ protected String action;
+ @Column
+ protected String status;
+
+ @Column(name = "description")
+ protected String desc;
+
+ @Column
+ private String modifier;
+
+ @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;
+ this.requestId = commonAuditData.getRequestId();
+ this.status = commonAuditData.getStatus();
+ this.desc = commonAuditData.getDescription();
+ this.modifier = modifier;
+ this.ecompUser = ecompUser;
+ }
+
+ @Override
+ public void fillFields() {
+ fields.put(AuditingFieldsKeysEnum.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());
+ 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 getEcompUser() {
+ return ecompUser;
+ }
+
+ public void setEcompUser(String ecompUser) {
+ this.ecompUser = ecompUser;
+ }
+
+ 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 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;
+ }
+
+ @Override
+ public String toString() {
+ return "ConsumerEvent [timebaseduuid=" + timebaseduuid + ", timestamp1=" + timestamp1 + ", requestId="
+ + requestId + ", action=" + action + ", status=" + status + ", desc=" + desc + ", modifier=" + modifier
+ + ", ecompUser=" + ecompUser + "]";
+ }
}
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 6ee320575c..045263d645 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
@@ -21,11 +21,9 @@
package org.openecomp.sdc.be.resources.data.auditing;
import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.EnumMap;
-import java.util.TimeZone;
-import java.util.UUID;
+import java.util.*;
+import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData;
import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum;
import com.datastax.driver.core.utils.UUIDs;
@@ -37,51 +35,51 @@ import com.datastax.driver.mapping.annotations.Table;
@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\"";
+ 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;
+ @PartitionKey
+ protected UUID timebaseduuid;
- @ClusteringColumn
- protected Date timestamp1;
+ @ClusteringColumn
+ protected Date timestamp1;
- @Column(name = "request_id")
- protected String requestId;
+ @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 = "service_instance_id")
+ protected String serviceInstanceId;
+ @Column
+ protected String action;
+ @Column
+ protected String status;
- @Column(name = "description")
- protected String desc;
+ @Column(name = "description")
+ protected String desc;
- @Column(name = "resource_name")
- private String resourceName;
+ @Column(name = "resource_name")
+ private String resourceName;
- @Column(name = "resource_type")
- private String resourceType;
+ @Column(name = "resource_type")
+ private String resourceType;
- @Column(name = "curr_version")
- private String currVersion;
+ @Column(name = "curr_version")
+ private String currVersion;
- @Column
- private String modifier;
+ @Column
+ private String modifier;
- @Column
- private String did;
+ @Column
+ private String did;
- public DistributionDeployEvent() {
+ public DistributionDeployEvent() {
super();
timestamp1 = new Date();
timebaseduuid = UUIDs.timeBased();
}
- public DistributionDeployEvent(EnumMap<AuditingFieldsKeysEnum, Object> auditingFields) {
+ public DistributionDeployEvent(Map<AuditingFieldsKeysEnum, Object> auditingFields) {
this();
Object value;
value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_REQUEST_ID);
@@ -124,19 +122,33 @@ public class DistributionDeployEvent extends AuditingGenericEvent {
if (value != null) {
setResourceType((String) value);
}
-
- }
-
- @Override
+ }
+
+
+ public DistributionDeployEvent(String action, CommonAuditData commonAuditData, String did, String modifier,
+ String currVersion, String resourceName, String resourceType) {
+ 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.currVersion = currVersion;
+ this.resourceName = resourceName;
+ this.resourceType = resourceType;
+ }
+
+ @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_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());
@@ -146,103 +158,103 @@ public class DistributionDeployEvent extends AuditingGenericEvent {
fields.put(AuditingFieldsKeysEnum.AUDIT_TIMESTAMP.getDisplayName(), simpleDateFormat.format(timestamp1));
}
- public String getResourceName() {
- return resourceName;
- }
+ public String getResourceName() {
+ return resourceName;
+ }
- public void setResourceName(String resourceName) {
- this.resourceName = resourceName;
- }
+ public void setResourceName(String resourceName) {
+ this.resourceName = resourceName;
+ }
- public String getResourceType() {
- return resourceType;
- }
+ public String getResourceType() {
+ return resourceType;
+ }
- public void setResourceType(String resourceType) {
- this.resourceType = resourceType;
- }
+ public void setResourceType(String resourceType) {
+ this.resourceType = resourceType;
+ }
- public String getCurrVersion() {
- return currVersion;
- }
+ public String getCurrVersion() {
+ return currVersion;
+ }
- public void setCurrVersion(String currVersion) {
- this.currVersion = currVersion;
- }
+ public void setCurrVersion(String currVersion) {
+ this.currVersion = currVersion;
+ }
- public UUID getTimebaseduuid() {
- return timebaseduuid;
- }
+ public UUID getTimebaseduuid() {
+ return timebaseduuid;
+ }
- public void setTimebaseduuid(UUID timebaseduuid) {
- this.timebaseduuid = timebaseduuid;
- }
+ public void setTimebaseduuid(UUID timebaseduuid) {
+ this.timebaseduuid = timebaseduuid;
+ }
- public Date getTimestamp1() {
- return timestamp1;
- }
+ public Date getTimestamp1() {
+ return timestamp1;
+ }
- public void setTimestamp1(Date timestamp1) {
- this.timestamp1 = timestamp1;
- }
+ public void setTimestamp1(Date timestamp1) {
+ this.timestamp1 = timestamp1;
+ }
- 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 String getModifier() {
- return modifier;
- }
+ public String getModifier() {
+ return modifier;
+ }
- public void setModifier(String modifier) {
- this.modifier = modifier;
- }
+ public void setModifier(String modifier) {
+ this.modifier = modifier;
+ }
- public String getDid() {
- return did;
- }
+ public String getDid() {
+ return did;
+ }
- public void setDid(String did) {
- this.did = did;
- }
+ public void setDid(String did) {
+ this.did = did;
+ }
- @Override
+ @Override
public String toString() {
return "DistributionDeployEvent [timebaseduuid=" + timebaseduuid + ", timestamp1=" + timestamp1 + ", requestId="
+ requestId + ", serviceInstanceId=" + serviceInstanceId + ", action=" + action + ", status=" + status
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 4b9fc0318f..474b713b9e 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
@@ -21,11 +21,10 @@
package org.openecomp.sdc.be.resources.data.auditing;
import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.EnumMap;
-import java.util.TimeZone;
-import java.util.UUID;
+import java.util.*;
+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;
@@ -37,43 +36,43 @@ import com.datastax.driver.mapping.annotations.Table;
@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\"";
+ private static String DISTRIBUTION_DOWNLOAD_EVENT_TEMPLATE = "action=\"%s\" timestamp=\"%s\" "
+ + "consumerId=\"%s\" resourceUrl=\"%s\" status=\"%s\" desc=\"%s\"";
- @PartitionKey
- protected UUID timebaseduuid;
+ @PartitionKey
+ protected UUID timebaseduuid;
- @ClusteringColumn
- protected Date timestamp1;
+ @ClusteringColumn
+ protected Date timestamp1;
- @Column(name = "request_id")
- protected String requestId;
+ @Column(name = "request_id")
+ protected String requestId;
- @Column(name = "service_instance_id")
- protected String serviceInstanceId;
+ @Column(name = "service_instance_id")
+ protected String serviceInstanceId;
- @Column
- protected String action;
- @Column
- protected String status;
+ @Column
+ protected String action;
+ @Column
+ protected String status;
- @Column(name = "description")
- protected String desc;
+ @Column(name = "description")
+ protected String desc;
- @Column(name = "consumer_id")
- private String consumerId;
+ @Column(name = "consumer_id")
+ private String consumerId;
- @Column(name = "resource_url")
- private String resourceUrl;
+ @Column(name = "resource_url")
+ private String resourceUrl;
- public DistributionDownloadEvent() {
+ public DistributionDownloadEvent() {
super();
- timestamp1 = new Date();
- timebaseduuid = UUIDs.timeBased();
- }
+ timestamp1 = new Date();
+ timebaseduuid = UUIDs.timeBased();
+ }
- public DistributionDownloadEvent(EnumMap<AuditingFieldsKeysEnum, Object> auditingFields) {
+ public DistributionDownloadEvent(Map<AuditingFieldsKeysEnum, Object> auditingFields) {
this();
Object value;
value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_REQUEST_ID);
@@ -104,17 +103,27 @@ public class DistributionDownloadEvent extends AuditingGenericEvent {
if (value != null) {
setResourceUrl((String) value);
}
-
}
+ public DistributionDownloadEvent(String action, CommonAuditData commonAuditData, DistributionData distributionData) {
+ this();
+ this.action = action;
+ this.requestId = commonAuditData.getRequestId();
+ this.serviceInstanceId = commonAuditData.getServiceInstanceId();
+ this.status = commonAuditData.getStatus();
+ this.desc = commonAuditData.getDescription();
+ this.consumerId = distributionData.getConsumerId();
+ 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());
+
fields.put(AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_CONSUMER_ID.getDisplayName(), getConsumerId());
fields.put(AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_RESOURCE_URL.getDisplayName(), getResourceUrl());
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormatPattern);
@@ -122,84 +131,83 @@ public class DistributionDownloadEvent extends AuditingGenericEvent {
fields.put(AuditingFieldsKeysEnum.AUDIT_TIMESTAMP.getDisplayName(), simpleDateFormat.format(timestamp1));
}
- public String getConsumerId() {
- return consumerId;
- }
+ public String getConsumerId() {
+ return consumerId;
+ }
- public void setConsumerId(String consumerId) {
- this.consumerId = consumerId;
- }
+ public void setConsumerId(String consumerId) {
+ this.consumerId = consumerId;
+ }
- public String getResourceUrl() {
- return resourceUrl;
- }
+ public String getResourceUrl() {
+ return resourceUrl;
+ }
- public void setResourceUrl(String resourceUrl) {
- this.resourceUrl = resourceUrl;
- }
+ public void setResourceUrl(String resourceUrl) {
+ this.resourceUrl = resourceUrl;
+ }
- public UUID getTimebaseduuid() {
- return timebaseduuid;
- }
+ public UUID getTimebaseduuid() {
+ return timebaseduuid;
+ }
- public void setTimebaseduuid(UUID timebaseduuid) {
- this.timebaseduuid = timebaseduuid;
- }
+ public void setTimebaseduuid(UUID timebaseduuid) {
+ this.timebaseduuid = timebaseduuid;
+ }
- public Date getTimestamp1() {
- return timestamp1;
- }
+ public Date getTimestamp1() {
+ return timestamp1;
+ }
- public void setTimestamp1(Date timestamp1) {
- this.timestamp1 = timestamp1;
- }
+ public void setTimestamp1(Date timestamp1) {
+ this.timestamp1 = timestamp1;
+ }
- 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;
+ }
- @Override
+ @Override
public String toString() {
return "DistributionDownloadEvent [timebaseduuid=" + timebaseduuid + ", timestamp1=" + timestamp1
+ ", requestId=" + requestId + ", serviceInstanceId=" + serviceInstanceId + ", action=" + action
- + ", status=" + status + ", desc=" + desc + ", consumerId=" + consumerId + ", resourceUrl="
- + resourceUrl + "]";
+ + ", 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 b125e7a712..70b2d4e7b1 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
@@ -21,11 +21,9 @@
package org.openecomp.sdc.be.resources.data.auditing;
import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.EnumMap;
-import java.util.TimeZone;
-import java.util.UUID;
+import java.util.*;
+import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData;
import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum;
import com.datastax.driver.core.utils.UUIDs;
@@ -37,115 +35,133 @@ import com.datastax.driver.mapping.annotations.Table;
@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;
-
- @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 = "consumer_id")
- private String consumerId;
-
- @Column(name = "DSTATUS_TOPIC")
- private String dstatusTopic;
-
- @Column(name = "DNOTIF_TOPIC")
- private String dnotifTopic;
-
- @Column(name = "d_env")
- private String environmentName;
-
- @Column
- private String role;
-
- @Column(name = "api_key")
- private String apiKey;
-
- public DistributionEngineEvent() {
- super();
- timestamp1 = new Date();
- timebaseduuid = UUIDs.timeBased();
- }
-
- public DistributionEngineEvent(EnumMap<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);
- }
- }
-
- @Override
- public void fillFields() {
- fields.put(AuditingFieldsKeysEnum.AUDIT_REQUEST_ID.getDisplayName(), getRequestId());
+ 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;
+
+ @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 = "consumer_id")
+ private String consumerId;
+
+ @Column(name = "DSTATUS_TOPIC")
+ private String dstatusTopic;
+
+ @Column(name = "DNOTIF_TOPIC")
+ private String dnotifTopic;
+
+ @Column(name = "d_env")
+ private String environmentName;
+
+ @Column
+ private String role;
+
+ @Column(name = "api_key")
+ private String apiKey;
+
+ 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) {
+ 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;
+ this.dstatusTopic = distStatusTopic;
+ this.dnotifTopic = distNotifTopic;
+ this.apiKey = apiKey;
+ this.environmentName = envName;
+ this.role = role;
+ }
+
+ @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());
@@ -158,116 +174,116 @@ public class DistributionEngineEvent extends AuditingGenericEvent {
fields.put(AuditingFieldsKeysEnum.AUDIT_TIMESTAMP.getDisplayName(), simpleDateFormat.format(timestamp1));
}
- public String getDstatusTopic() {
- return dstatusTopic;
- }
+ public String getDstatusTopic() {
+ return dstatusTopic;
+ }
- public void setDstatusTopic(String dstatusTopic) {
- this.dstatusTopic = dstatusTopic;
- }
+ public void setDstatusTopic(String dstatusTopic) {
+ this.dstatusTopic = dstatusTopic;
+ }
- public String getDnotifTopic() {
- return dnotifTopic;
- }
-
- public void setDnotifTopic(String dnotifTopic) {
- this.dnotifTopic = dnotifTopic;
- }
-
- public String getEnvironmentName() {
- return environmentName;
- }
-
- public void setEnvironmentName(String environmentName) {
- this.environmentName = environmentName;
- }
-
- public String getRole() {
- return role;
- }
-
- public void setRole(String role) {
- this.role = role;
- }
-
- public String getApiKey() {
- return apiKey;
- }
-
- public void setApiKey(String apiKey) {
- this.apiKey = apiKey;
- }
-
- 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 getConsumerId() {
- return consumerId;
- }
-
- public void setConsumerId(String consumerId) {
- this.consumerId = consumerId;
- }
-
- @Override
- public String toString() {
- return "DistributionEngineEvent [timebaseduuid=" + timebaseduuid + ", timestamp1=" + timestamp1 + ", requestId="
- + requestId + ", serviceInstanceId=" + serviceInstanceId + ", action=" + action + ", status=" + status
- + ", desc=" + desc + ", consumerId=" + consumerId + ", dstatusTopic=" + dstatusTopic + ", dnotifTopic="
- + dnotifTopic + ", environmentName=" + environmentName + ", role=" + role + ", apiKey=" + apiKey + "]";
- }
+ public String getDnotifTopic() {
+ return dnotifTopic;
+ }
+
+ public void setDnotifTopic(String dnotifTopic) {
+ this.dnotifTopic = dnotifTopic;
+ }
+
+ public String getEnvironmentName() {
+ return environmentName;
+ }
+
+ public void setEnvironmentName(String environmentName) {
+ this.environmentName = environmentName;
+ }
+
+ public String getRole() {
+ return role;
+ }
+
+ public void setRole(String role) {
+ this.role = role;
+ }
+
+ public String getApiKey() {
+ return apiKey;
+ }
+
+ public void setApiKey(String apiKey) {
+ this.apiKey = apiKey;
+ }
+
+ 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 getConsumerId() {
+ return consumerId;
+ }
+
+ public void setConsumerId(String consumerId) {
+ this.consumerId = consumerId;
+ }
+
+ @Override
+ public String toString() {
+ return "DistributionEngineEvent [timebaseduuid=" + timebaseduuid + ", timestamp1=" + timestamp1 + ", requestId="
+ + requestId + ", serviceInstanceId=" + serviceInstanceId + ", action=" + action + ", status=" + status
+ + ", desc=" + desc + ", consumerId=" + consumerId + ", dstatusTopic=" + dstatusTopic + ", dnotifTopic="
+ + dnotifTopic + ", environmentName=" + environmentName + ", role=" + role + ", apiKey=" + apiKey + "]";
+ }
}
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 6420f08fb5..db48364f0f 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
@@ -21,11 +21,10 @@
package org.openecomp.sdc.be.resources.data.auditing;
import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.EnumMap;
-import java.util.TimeZone;
-import java.util.UUID;
+import java.util.*;
+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;
@@ -81,13 +80,22 @@ public class DistributionNotificationEvent extends AuditingGenericEvent {
@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(EnumMap<AuditingFieldsKeysEnum, Object> auditingFields) {
+ public DistributionNotificationEvent(Map<AuditingFieldsKeysEnum, Object> auditingFields) {
this();
Object value;
value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_REQUEST_ID);
@@ -138,6 +146,40 @@ public class DistributionNotificationEvent extends AuditingGenericEvent {
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,
+ OperationalEnvAuditData opEnvFields) {
+ 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 = 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();
}
@@ -149,6 +191,9 @@ public class DistributionNotificationEvent extends AuditingGenericEvent {
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());
@@ -274,13 +319,38 @@ public class DistributionNotificationEvent extends AuditingGenericEvent {
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 + "]";
+ + ", 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 6565b824ac..c05631ec74 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
@@ -21,11 +21,9 @@
package org.openecomp.sdc.be.resources.data.auditing;
import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.EnumMap;
-import java.util.TimeZone;
-import java.util.UUID;
+import java.util.*;
+import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData;
import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum;
import com.datastax.driver.core.utils.UUIDs;
@@ -82,7 +80,7 @@ public class DistributionStatusEvent extends AuditingGenericEvent {
}
- public DistributionStatusEvent(EnumMap<AuditingFieldsKeysEnum, Object> auditingFields) {
+ public DistributionStatusEvent(Map<AuditingFieldsKeysEnum, Object> auditingFields) {
this();
Object value;
value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_REQUEST_ID);
@@ -125,6 +123,21 @@ public class DistributionStatusEvent extends AuditingGenericEvent {
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
@@ -243,7 +256,7 @@ public class DistributionStatusEvent extends AuditingGenericEvent {
this.statusTime = statusTime;
}
- @Override
+ @Override
public String toString() {
return "DistributionStatusEvent [timebaseduuid=" + timebaseduuid + ", timestamp1=" + timestamp1 + ", requestId="
+ requestId + ", serviceInstanceId=" + serviceInstanceId + ", action=" + action + ", status=" + status
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
new file mode 100644
index 0000000000..0ead1ff989
--- /dev/null
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/EcompOperationalEnvironmentEvent.java
@@ -0,0 +1,164 @@
+package org.openecomp.sdc.be.resources.data.auditing;
+
+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.AuditingFieldsKeysEnum;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Map;
+import java.util.TimeZone;
+
+@Table(keyspace = AuditingTypesConstants.AUDIT_KEYSPACE, name = AuditingTypesConstants.ECOMP_OPERATIONAL_ENV_EVENT_TYPE)
+public class EcompOperationalEnvironmentEvent extends AuditingGenericEvent {
+
+ @PartitionKey
+ protected String operationalEnvironmentId;
+
+ @ClusteringColumn
+ protected Date timestamp1;
+
+ @Column
+ protected String action;
+
+ @Column(name = "operational_environment_action")
+ protected String operationalEnvironmentAction;
+
+ @Column(name = "operational_environment_name")
+ protected String operationalEnvironmentName;
+
+ @Column(name = "operational_environment_type")
+ protected String operationalEnvironmentType;
+
+ @Column(name = "tenant_context")
+ protected String tenantContext;
+
+
+ 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();
+ this.action = action;
+ this.operationalEnvironmentId = operationalEnvironmentId;
+ this.operationalEnvironmentType = operationalEnvironmentType;
+ this.operationalEnvironmentName = operationalEnvironmentName;
+ this.operationalEnvironmentAction = operationalEnvironmentAction;
+ this.tenantContext = tenantContext;
+ }
+
+ public String getOperationalEnvironmentId() {
+ return operationalEnvironmentId;
+ }
+
+ public void setOperationalEnvironmentId(String operationalEnvironmentId) {
+ this.operationalEnvironmentId = operationalEnvironmentId;
+ }
+
+ public String getOperationalEnvironmentAction() {
+ return operationalEnvironmentAction;
+ }
+
+ public void setOperationalEnvironmentAction(String operationalEnvironmentAction) {
+ this.operationalEnvironmentAction = operationalEnvironmentAction;
+ }
+
+ public String getOperationalEnvironmentName() {
+ return operationalEnvironmentName;
+ }
+
+ public void setOperationalEnvironmentName(String operationalEnvironmentName) {
+ this.operationalEnvironmentName = operationalEnvironmentName;
+ }
+
+ public String getOperationalEnvironmentType() {
+ return operationalEnvironmentType;
+ }
+
+ public void setOperational_environment_type(String operationalEnvironmentType) {
+ this.operationalEnvironmentType = operationalEnvironmentType;
+ }
+
+ public String getTenantContext() {
+ return tenantContext;
+ }
+
+ public void setTenantContext(String tenantContext) {
+ this.tenantContext = tenantContext;
+ }
+
+ public Date getTimestamp1() {
+ return timestamp1;
+ }
+
+ public void setTimestamp1(Date timestamp) {
+ this.timestamp1 = timestamp;
+ }
+
+ @Override
+ public String getAction() {
+ return action;
+ }
+
+ @Override
+ public void setAction(String action) {
+ this.action = action;
+ }
+
+ @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());
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormatPattern);
+ simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
+ fields.put(AuditingFieldsKeysEnum.AUDIT_TIMESTAMP.getDisplayName(), simpleDateFormat.format(timestamp1));
+ }
+
+ @Override
+ public String toString() {
+ return "EcompOperationalEnvironmentEvent [timestamp1=" + timestamp1 + ", action = " + action
+ + ", operational_environment_id=" + operationalEnvironmentId + ", operational_environment_name=" + operationalEnvironmentName
+ + ", operational_environment_type=" + operationalEnvironmentType + ", operational_environment_action=" + operationalEnvironmentAction
+ + ", tenant_context=" + tenantContext + "]";
+ }
+
+}
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 f32acc81c4..ed546301fc 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
@@ -21,11 +21,10 @@
package org.openecomp.sdc.be.resources.data.auditing;
import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.EnumMap;
-import java.util.TimeZone;
-import java.util.UUID;
+import java.util.*;
+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;
@@ -40,334 +39,358 @@ import com.datastax.driver.mapping.annotations.Table;
*/
@Table(keyspace = AuditingTypesConstants.AUDIT_KEYSPACE, name = AuditingTypesConstants.EXTERNAL_API_EVENT_TYPE)
public class ExternalApiEvent extends AuditingGenericEvent {
- @PartitionKey
- protected UUID timebaseduuid;
-
- @ClusteringColumn()
- protected Date timestamp1;
-
- @Column
- protected String action;
- @Column
- protected String status;
-
- @Column(name = "description")
- protected String desc;
-
- @Column(name = "consumer_id")
- private String consumerId;
-
- @Column(name = "resource_url")
- private String resourceURL;
-
- @Column(name = "resource_name")
- private String resourceName;
-
- @Column(name = "resource_type")
- private String resourceType;
-
- @Column(name = "service_instance_id")
- protected String serviceInstanceId;
-
- @Column(name = "invariant_uuid")
- protected String invariantUuid;
-
- @Column(name = "modifier")
- private String modifier;
-
- @Column(name = "prev_version")
- protected String prevVersion;
-
- @Column(name = "curr_version")
- private String currVersion;
-
- @Column(name = "prev_state")
- protected String prevState;
-
- @Column(name = "curr_state")
- protected String currState;
-
- @Column(name = "prev_artifact_uuid")
- private String prevArtifactUuid;
-
- @Column(name = "curr_artifact_uuid")
- private String currArtifactUuid;
-
- @Column(name = "artifact_data")
- private String artifactData;
-
- public ExternalApiEvent() {
- super();
- timestamp1 = new Date();
- timebaseduuid = UUIDs.timeBased();
- }
-
- public ExternalApiEvent(EnumMap<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);
- }
- }
-
- @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());
- 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());
- }
-
- 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 getConsumerId() {
- return consumerId;
- }
-
- public void setConsumerId(String consumerId) {
- this.consumerId = consumerId;
- }
-
- public String getResourceURL() {
- return resourceURL;
- }
-
- public void setResourceURL(String resourceURL) {
- this.resourceURL = resourceURL;
- }
-
- 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 getServiceInstanceId() {
- return serviceInstanceId;
- }
-
- public void setServiceInstanceId(String serviceInstanceId) {
- this.serviceInstanceId = serviceInstanceId;
- }
-
- public String getInvariantUuid() {
- return invariantUuid;
- }
-
- public void setInvariantUuid(String invariantUuid) {
- this.invariantUuid = invariantUuid;
- }
-
- 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;
- }
-
- @Override
- public String toString() {
- return "ExternalApiEvent [timebaseduuid=" + timebaseduuid + ", timestamp1=" + timestamp1 + ", action=" + action
- + ", status=" + status + ", desc=" + desc + ", consumerId=" + consumerId + ", resourceURL="
- + resourceURL + ", resourceName=" + resourceName + ", resourceType=" + resourceType
- + ", serviceInstanceId=" + serviceInstanceId + ", invariantUuid=" + invariantUuid + ", modifier=" + modifier
- + ", prevVersion=" + prevVersion+ ", currVersion=" + currVersion
- + ", prevState=" + prevState + ", currState=" + currState
- + ", prevArtifactUuid="
- + prevArtifactUuid + ", currArtifactUuid=" + currArtifactUuid + ", artifactData=" + artifactData + "]";
- }
-
- 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;
- }
+ @PartitionKey
+ protected UUID timebaseduuid;
+
+ @ClusteringColumn()
+ protected Date timestamp1;
+
+ @Column
+ protected String action;
+ @Column
+ protected String status;
+
+ @Column(name = "description")
+ protected String desc;
+
+ @Column(name = "consumer_id")
+ private String consumerId;
+
+ @Column(name = "resource_url")
+ private String resourceURL;
+
+ @Column(name = "resource_name")
+ private String resourceName;
+
+ @Column(name = "resource_type")
+ private String resourceType;
+
+ @Column(name = "service_instance_id")
+ protected String serviceInstanceId;
+
+ @Column(name = "invariant_uuid")
+ protected String invariantUuid;
+
+ @Column(name = "modifier")
+ private String modifier;
+
+ @Column(name = "prev_version")
+ protected String prevVersion;
+
+ @Column(name = "curr_version")
+ private String currVersion;
+
+ @Column(name = "prev_state")
+ protected String prevState;
+
+ @Column(name = "curr_state")
+ protected String currState;
+
+ @Column(name = "prev_artifact_uuid")
+ private String prevArtifactUuid;
+
+ @Column(name = "curr_artifact_uuid")
+ private String currArtifactUuid;
+
+ @Column(name = "artifact_data")
+ private String artifactData;
+
+ 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,
+ 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.serviceInstanceId = commonAuditData.getServiceInstanceId();
+ this.invariantUuid = invariantUuid;
+ this.modifier = modifier;
+ this.prevVersion = prevParams.getVersion();
+ this.prevState = prevParams.getState();
+ this.prevArtifactUuid = prevParams.getArtifactUuid();
+ this.currVersion = currParams.getVersion();
+ this.currState = currParams.getState();
+ this.currArtifactUuid = currParams.getArtifactUuid();
+ this.artifactData = artifactData;
+ }
+
+ @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());
+ 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());
+ }
+
+ 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 getConsumerId() {
+ return consumerId;
+ }
+
+ public void setConsumerId(String consumerId) {
+ this.consumerId = consumerId;
+ }
+
+ public String getResourceURL() {
+ return resourceURL;
+ }
+
+ public void setResourceURL(String resourceURL) {
+ this.resourceURL = resourceURL;
+ }
+
+ 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 getServiceInstanceId() {
+ return serviceInstanceId;
+ }
+
+ public void setServiceInstanceId(String serviceInstanceId) {
+ this.serviceInstanceId = serviceInstanceId;
+ }
+
+ public String getInvariantUuid() {
+ return invariantUuid;
+ }
+
+ public void setInvariantUuid(String invariantUuid) {
+ this.invariantUuid = invariantUuid;
+ }
+
+ 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;
+ }
+
+ @Override
+ public String toString() {
+ return "ExternalApiEvent [timebaseduuid=" + timebaseduuid + ", timestamp1=" + timestamp1 + ", action=" + action
+ + ", status=" + status + ", desc=" + desc + ", consumerId=" + consumerId + ", resourceURL="
+ + resourceURL + ", resourceName=" + resourceName + ", resourceType=" + resourceType
+ + ", serviceInstanceId=" + serviceInstanceId + ", invariantUuid=" + invariantUuid + ", modifier=" + modifier
+ + ", prevVersion=" + prevVersion+ ", currVersion=" + currVersion
+ + ", prevState=" + prevState + ", currState=" + currState
+ + ", prevArtifactUuid="
+ + prevArtifactUuid + ", currArtifactUuid=" + currArtifactUuid + ", artifactData=" + artifactData + "]";
+ }
+
+ 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;
+ }
}
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 0b86651b8a..f80db7ef6e 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
@@ -21,11 +21,9 @@
package org.openecomp.sdc.be.resources.data.auditing;
import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.EnumMap;
-import java.util.TimeZone;
-import java.util.UUID;
+import java.util.*;
+import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData;
import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum;
import com.datastax.driver.core.utils.UUIDs;
@@ -36,147 +34,157 @@ import com.datastax.driver.mapping.annotations.Table;
@Table(keyspace = AuditingTypesConstants.AUDIT_KEYSPACE, name = AuditingTypesConstants.GET_CATEGORY_HIERARCHY_EVENT_TYPE)
public class GetCategoryHierarchyEvent extends AuditingGenericEvent {
- @PartitionKey
- protected UUID timebaseduuid;
-
- @ClusteringColumn()
- // @Column(name="timestamp")
- protected Date timestamp1;
-
- @Column(name = "request_id")
- protected String requestId;
- @Column
- protected String action;
- @Column
- protected String status;
-
- @Column(name = "description")
- protected String desc;
-
- @Column
- private String modifier;
-
- @Column
- private String details;
-
- public GetCategoryHierarchyEvent() {
- super();
- timestamp1 = new Date();
- timebaseduuid = UUIDs.timeBased();
- }
-
- public GetCategoryHierarchyEvent(EnumMap<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);
- }
- }
-
- @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_DETAILS.getDisplayName(), getDetails());
- 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 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 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 getDetails() {
- return details;
- }
-
- public void setDetails(String details) {
- this.details = details;
- }
-
- @Override
- public String toString() {
- return "GetCategoryHierarchyEvent [timebaseduuid=" + timebaseduuid + ", timestamp1=" + timestamp1
- + ", requestId=" + requestId + ", action=" + action + ", status=" + status + ", desc=" + desc
- + ", modifier=" + modifier + ", details=" + details + "]";
- }
+ @PartitionKey
+ protected UUID timebaseduuid;
+
+ @ClusteringColumn()
+ // @Column(name="timestamp")
+ protected Date timestamp1;
+
+ @Column(name = "request_id")
+ protected String requestId;
+ @Column
+ protected String action;
+ @Column
+ protected String status;
+
+ @Column(name = "description")
+ protected String desc;
+
+ @Column
+ private String modifier;
+
+ @Column
+ private String details;
+
+ 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;
+ this.requestId = commonAuditData.getRequestId();
+ this.desc = commonAuditData.getDescription();
+ this.status = commonAuditData.getStatus();
+ this.modifier = modifier;
+ this.details = details;
+ }
+
+ @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_DETAILS.getDisplayName(), getDetails());
+ 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 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 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 getDetails() {
+ return details;
+ }
+
+ public void setDetails(String details) {
+ this.details = details;
+ }
+
+ @Override
+ public String toString() {
+ return "GetCategoryHierarchyEvent [timebaseduuid=" + timebaseduuid + ", timestamp1=" + timestamp1
+ + ", requestId=" + requestId + ", action=" + action + ", status=" + status + ", desc=" + desc
+ + ", modifier=" + modifier + ", details=" + details + "]";
+ }
}
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 728a0430b0..41f7f05079 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
@@ -21,11 +21,9 @@
package org.openecomp.sdc.be.resources.data.auditing;
import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.EnumMap;
-import java.util.TimeZone;
-import java.util.UUID;
+import java.util.*;
+import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData;
import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum;
import com.datastax.driver.core.utils.UUIDs;
@@ -36,151 +34,162 @@ import com.datastax.driver.mapping.annotations.Table;
@Table(keyspace = AuditingTypesConstants.AUDIT_KEYSPACE, name = AuditingTypesConstants.GET_USERS_LIST_EVENT_TYPE)
public class GetUsersListEvent extends AuditingGenericEvent {
- @PartitionKey
- protected UUID timebaseduuid;
-
- @ClusteringColumn
- protected Date timestamp1;
-
- @Column(name = "request_id")
- protected String requestId;
- @Column
- protected String action;
- @Column
- protected String status;
-
- @Column(name = "description")
- protected String desc;
-
- @Column
- private String modifier;
-
- @Column
- private String details;
-
- public GetUsersListEvent() {
- super();
- timestamp1 = new Date();
- timebaseduuid = UUIDs.timeBased();
- }
-
- public GetUsersListEvent(EnumMap<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);
- }
- }
- }
-
- @Override
- public void fillFields() {
- fields.put(AuditingFieldsKeysEnum.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());
- 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 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 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 getDetails() {
- return details;
- }
-
- public void setDetails(String details) {
- this.details = details;
- }
-
- @Override
- public String toString() {
- return "GetUsersListEvent [timebaseduuid=" + timebaseduuid + ", timestamp1=" + timestamp1 + ", requestId="
- + requestId + ", action=" + action + ", status=" + status + ", desc=" + desc + ", modifier=" + modifier
- + ", details=" + details + "]";
- }
+ @PartitionKey
+ protected UUID timebaseduuid;
+
+ @ClusteringColumn
+ protected Date timestamp1;
+
+ @Column(name = "request_id")
+ protected String requestId;
+ @Column
+ protected String action;
+ @Column
+ protected String status;
+
+ @Column(name = "description")
+ protected String desc;
+
+ @Column
+ private String modifier;
+
+ @Column
+ private String details;
+
+ 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;
+ this.requestId = commonAuditData.getRequestId();
+ this.status = commonAuditData.getStatus();
+ this.desc = commonAuditData.getDescription();
+ this.modifier = modifier;
+ this.details = userDetails;
+ }
+
+
+ @Override
+ public void fillFields() {
+ fields.put(AuditingFieldsKeysEnum.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());
+ 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 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 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 getDetails() {
+ return details;
+ }
+
+ public void setDetails(String details) {
+ this.details = details;
+ }
+
+ @Override
+ public String toString() {
+ return "GetUsersListEvent [timebaseduuid=" + timebaseduuid + ", timestamp1=" + timestamp1 + ", requestId="
+ + requestId + ", action=" + action + ", status=" + status + ", desc=" + desc + ", modifier=" + modifier
+ + ", details=" + details + "]";
+ }
}
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 21a84751da..214f2187af 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
@@ -21,11 +21,10 @@
package org.openecomp.sdc.be.resources.data.auditing;
import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.EnumMap;
-import java.util.TimeZone;
-import java.util.UUID;
+import java.util.*;
+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;
@@ -118,7 +117,33 @@ public class ResourceAdminEvent extends AuditingGenericEvent {
timebaseduuid = UUIDs.timeBased();
}
- public ResourceAdminEvent(EnumMap<AuditingFieldsKeysEnum, Object> auditingFields) {
+ 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);
@@ -209,6 +234,7 @@ public class ResourceAdminEvent extends AuditingGenericEvent {
}
+
@Override
public void fillFields() {
fields.put(AuditingFieldsKeysEnum.AUDIT_REQUEST_ID.getDisplayName(), getRequestId());
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 a1ae1e2df1..80a370dc62 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
@@ -21,11 +21,9 @@
package org.openecomp.sdc.be.resources.data.auditing;
import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.EnumMap;
-import java.util.TimeZone;
-import java.util.UUID;
+import java.util.*;
+import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData;
import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum;
import com.datastax.driver.core.utils.UUIDs;
@@ -69,7 +67,7 @@ public class UserAccessEvent extends AuditingGenericEvent {
timebaseduuid = UUIDs.timeBased();
}
- public UserAccessEvent(EnumMap<AuditingFieldsKeysEnum, Object> auditingFields) {
+ public UserAccessEvent(Map<AuditingFieldsKeysEnum, Object> auditingFields) {
this();
Object value;
value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_REQUEST_ID);
@@ -99,6 +97,17 @@ public class UserAccessEvent extends AuditingGenericEvent {
}
+ 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());
@@ -137,6 +146,14 @@ public class UserAccessEvent extends AuditingGenericEvent {
this.requestId = requestId;
}
+ @Override
+ public String getServiceInstanceId() { return serviceInstanceId; }
+
+ @Override
+ public void setServiceInstanceId(String serviceInstanceId) {
+ this.serviceInstanceId = serviceInstanceId;
+ }
+
public String getStatus() {
return status;
}
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 72d7d2ff6d..1ab3ae783b 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
@@ -21,11 +21,9 @@
package org.openecomp.sdc.be.resources.data.auditing;
import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.EnumMap;
-import java.util.TimeZone;
-import java.util.UUID;
+import java.util.*;
+import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData;
import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum;
import com.datastax.driver.core.utils.UUIDs;
@@ -76,10 +74,9 @@ public class UserAdminEvent extends AuditingGenericEvent {
super();
timestamp1 = new Date();
timebaseduuid = UUIDs.timeBased();
-
}
- public UserAdminEvent(EnumMap<AuditingFieldsKeysEnum, Object> auditingFields) {
+ public UserAdminEvent(Map<AuditingFieldsKeysEnum, Object> auditingFields) {
this();
Object value;
value = auditingFields.get(AuditingFieldsKeysEnum.AUDIT_REQUEST_ID);
@@ -117,6 +114,18 @@ public class UserAdminEvent extends AuditingGenericEvent {
}
+ 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());
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
new file mode 100644
index 0000000000..ae5a02ee75
--- /dev/null
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/model/CommonAuditData.java
@@ -0,0 +1,75 @@
+package org.openecomp.sdc.be.resources.data.auditing.model;
+
+public class CommonAuditData {
+ private String description;
+ private String requestId;
+ private String serviceInstanceId;
+ private String status;
+
+ private CommonAuditData() {
+ //for builder
+ }
+
+ public String getStatus() {
+ return status;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public String getRequestId() {
+ return requestId;
+ }
+
+ public String getServiceInstanceId() {
+ return serviceInstanceId;
+ }
+
+ public void setServiceInstanceId(String serviceInstanceId) {
+ this.serviceInstanceId = serviceInstanceId ;
+ }
+
+ public static Builder newBuilder() {
+ return new Builder();
+ }
+
+ public static class Builder {
+ private final CommonAuditData instance;
+
+ private Builder() {
+ instance = new CommonAuditData();
+ }
+
+ public Builder description(String description) {
+ instance.description = description;
+ return this;
+ }
+
+ public Builder status(int status) {
+ instance.status = String.valueOf(status);
+ return this;
+ }
+
+ public Builder status(String status) {
+ instance.status = status;
+ return this;
+ }
+
+ public Builder requestId(String requestId) {
+ instance.requestId = requestId;
+ return this;
+ }
+
+ public Builder serviceInstanceId(String serviceInstanceId) {
+ instance.serviceInstanceId = serviceInstanceId;
+ return this;
+ }
+
+ public CommonAuditData build() {
+ return instance;
+ }
+
+ }
+
+}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/model/DistributionData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/model/DistributionData.java
new file mode 100644
index 0000000000..fe45050e07
--- /dev/null
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/model/DistributionData.java
@@ -0,0 +1,20 @@
+package org.openecomp.sdc.be.resources.data.auditing.model;
+
+public class DistributionData {
+
+ private final String consumerId;
+ private final String resourceUrl;
+
+ public DistributionData(String consumerId, String resourceUrl) {
+ this.consumerId = consumerId;
+ this.resourceUrl = resourceUrl;
+ }
+
+ public String getConsumerId() {
+ return consumerId;
+ }
+
+ public String getResourceUrl() {
+ return resourceUrl;
+ }
+}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/model/OperationalEnvAuditData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/model/OperationalEnvAuditData.java
new file mode 100644
index 0000000000..968b41c74a
--- /dev/null
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/model/OperationalEnvAuditData.java
@@ -0,0 +1,26 @@
+package org.openecomp.sdc.be.resources.data.auditing.model;
+
+public class OperationalEnvAuditData {
+ private String envId;
+ private String vnfWorkloadContext;
+ private String tenant;
+
+ public String getEnvId() {
+ return envId;
+ }
+
+ public String getVnfWorkloadContext() {
+ return vnfWorkloadContext;
+ }
+
+ public String getTenant() {
+ return tenant;
+ }
+
+ public OperationalEnvAuditData(String envId, String vnfWorkloadContext, String tenant) {
+ this.envId = envId;
+ this.vnfWorkloadContext = vnfWorkloadContext;
+ this.tenant = tenant;
+ }
+
+}
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/ResourceAuditData.java
new file mode 100644
index 0000000000..d66050a5f9
--- /dev/null
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/model/ResourceAuditData.java
@@ -0,0 +1,60 @@
+package org.openecomp.sdc.be.resources.data.auditing.model;
+
+public class ResourceAuditData {
+ private String artifactUuid;
+ private String state;
+ private String version;
+ private String distributionStatus;
+
+ private ResourceAuditData() {
+ //for builder
+ }
+
+ public static Builder newBuilder() {
+ return new Builder();
+ }
+
+ public String getArtifactUuid() {
+ return artifactUuid;
+ }
+ public String getState() {
+ return state;
+ }
+ public String getVersion() {
+ return version;
+ }
+ public String getDistributionStatus() { return distributionStatus; }
+
+
+ public static class Builder {
+ private final ResourceAuditData instance;
+
+ private Builder() {
+ instance = new ResourceAuditData();
+ }
+
+ public Builder artifactUuid(String artifactUuid) {
+ instance.artifactUuid = artifactUuid;
+ return this;
+ }
+
+ public Builder state(String state) {
+ instance.state = state;
+ return this;
+ }
+
+ public Builder version(String version) {
+ instance.version = version;
+ return this;
+ }
+
+ public Builder distributionStatus(String distributionStatus) {
+ instance.distributionStatus = distributionStatus;
+ return this;
+ }
+
+ public ResourceAuditData build() {
+ return instance;
+ }
+ }
+}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/category/CategoryData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/category/CategoryData.java
index d42eb78ed3..27f5674558 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/category/CategoryData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/category/CategoryData.java
@@ -20,17 +20,16 @@
package org.openecomp.sdc.be.resources.data.category;
-import java.lang.reflect.Type;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
+import com.google.gson.reflect.TypeToken;
import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
import org.openecomp.sdc.be.datatypes.category.CategoryDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import com.google.gson.reflect.TypeToken;
+import java.lang.reflect.Type;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
public class CategoryData extends GraphNode {
private CategoryDataDefinition categoryDataDefinition;
@@ -61,7 +60,7 @@ public class CategoryData extends GraphNode {
}
@Override
- public Object getUniqueId() {
+ public String getUniqueId() {
return categoryDataDefinition.getUniqueId();
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/category/GroupingData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/category/GroupingData.java
index ca40ae986b..ba451cb930 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/category/GroupingData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/category/GroupingData.java
@@ -20,14 +20,14 @@
package org.openecomp.sdc.be.resources.data.category;
-import java.util.HashMap;
-import java.util.Map;
-
import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
import org.openecomp.sdc.be.datatypes.category.GroupingDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
+import java.util.HashMap;
+import java.util.Map;
+
public class GroupingData extends GraphNode {
private GroupingDataDefinition groupingDataDefinition;
@@ -56,7 +56,7 @@ public class GroupingData extends GraphNode {
}
@Override
- public Object getUniqueId() {
+ public String getUniqueId() {
return groupingDataDefinition.getUniqueId();
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/category/SubCategoryData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/category/SubCategoryData.java
index 1112b4514d..5011992c61 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/category/SubCategoryData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/category/SubCategoryData.java
@@ -20,17 +20,16 @@
package org.openecomp.sdc.be.resources.data.category;
-import java.lang.reflect.Type;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
+import com.google.gson.reflect.TypeToken;
import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
import org.openecomp.sdc.be.datatypes.category.SubCategoryDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import com.google.gson.reflect.TypeToken;
+import java.lang.reflect.Type;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
public class SubCategoryData extends GraphNode {
@@ -67,7 +66,7 @@ public class SubCategoryData extends GraphNode {
}
@Override
- public Object getUniqueId() {
+ public String getUniqueId() {
return subCategoryDataDefinition.getUniqueId();
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/impl/ResourceUploader.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/impl/ResourceUploader.java
index a3c5218495..2c659ff527 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/impl/ResourceUploader.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/impl/ResourceUploader.java
@@ -78,8 +78,6 @@ public class ResourceUploader implements IResourceUploader {
public ResourceUploadStatus saveArtifact(ESArtifactData artifactData, boolean isReload) {
ResourceUploadStatus status = ResourceUploadStatus.OK;
if (resourceDAO == null) {
- BeEcompErrorManager.getInstance().processEcompError(EcompErrorName.BeInitializationError,
- "Save Artifact - internal object not initialized");
BeEcompErrorManager.getInstance()
.logBeInitializationError("Save Artifact - internal object not initialized");
log.debug("update artifact failed - resourceDAO is null");
@@ -101,8 +99,6 @@ public class ResourceUploader implements IResourceUploader {
} catch (ResourceDAOException e) {
status = ResourceUploadStatus.ERROR;
- BeEcompErrorManager.getInstance().processEcompError(EcompErrorName.BeDaoSystemError,
- "Save Artifact to database");
BeEcompErrorManager.getInstance().logBeDaoSystemError("Save Artifact to database");
log.debug("ResourceUploadStatus:saveArtifact failed with exception ", e);
}