2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
19 * Modifications copyright (c) 2019 Nokia
20 * ================================================================================
23 package org.openecomp.sdc.be.impl;
25 import com.fasterxml.jackson.databind.DeserializationFeature;
26 import com.fasterxml.jackson.databind.ObjectMapper;
27 import com.fasterxml.jackson.databind.module.SimpleModule;
28 import com.google.gson.Gson;
29 import com.google.gson.GsonBuilder;
30 import com.google.gson.reflect.TypeToken;
32 import fj.data.Either;
33 import java.lang.reflect.Type;
34 import java.util.ArrayList;
35 import java.util.Collections;
36 import java.util.List;
38 import java.util.Optional;
40 import java.util.stream.Collectors;
41 import javax.servlet.http.HttpServletRequest;
42 import org.apache.commons.collections.CollectionUtils;
43 import org.apache.commons.lang3.StringUtils;
44 import org.onap.logging.ref.slf4j.ONAPLogConstants;
45 import org.openecomp.sdc.be.auditing.api.AuditEventFactory;
46 import org.openecomp.sdc.be.auditing.impl.AuditAuthRequestEventFactory;
47 import org.openecomp.sdc.be.auditing.impl.AuditConsumerEventFactory;
48 import org.openecomp.sdc.be.auditing.impl.AuditEcompOpEnvEventFactory;
49 import org.openecomp.sdc.be.auditing.impl.AuditGetUebClusterEventFactory;
50 import org.openecomp.sdc.be.auditing.impl.AuditingManager;
51 import org.openecomp.sdc.be.auditing.impl.category.AuditCategoryEventFactory;
52 import org.openecomp.sdc.be.auditing.impl.category.AuditGetCategoryHierarchyEventFactory;
53 import org.openecomp.sdc.be.auditing.impl.distribution.AuditDistributionDeployEventFactory;
54 import org.openecomp.sdc.be.auditing.impl.distribution.AuditDistributionDownloadEventFactory;
55 import org.openecomp.sdc.be.auditing.impl.distribution.AuditDistributionEngineEventFactoryManager;
56 import org.openecomp.sdc.be.auditing.impl.distribution.AuditDistributionNotificationEventFactory;
57 import org.openecomp.sdc.be.auditing.impl.distribution.AuditDistributionStatusEventFactory;
58 import org.openecomp.sdc.be.auditing.impl.distribution.AuditRegUnregDistributionEngineEventFactory;
59 import org.openecomp.sdc.be.auditing.impl.externalapi.AuditActivateServiceExternalApiEventFactory;
60 import org.openecomp.sdc.be.auditing.impl.externalapi.AuditAssetExternalApiEventFactory;
61 import org.openecomp.sdc.be.auditing.impl.externalapi.AuditAssetListExternalApiEventFactory;
62 import org.openecomp.sdc.be.auditing.impl.externalapi.AuditChangeLifecycleExternalApiEventFactory;
63 import org.openecomp.sdc.be.auditing.impl.externalapi.AuditCreateResourceExternalApiEventFactory;
64 import org.openecomp.sdc.be.auditing.impl.externalapi.AuditCreateServiceExternalApiEventFactory;
65 import org.openecomp.sdc.be.auditing.impl.externalapi.AuditCrudExternalApiArtifactEventFactory;
66 import org.openecomp.sdc.be.auditing.impl.externalapi.AuditDownloadArtifactExternalApiEventFactory;
67 import org.openecomp.sdc.be.auditing.impl.resourceadmin.AuditResourceEventFactoryManager;
68 import org.openecomp.sdc.be.auditing.impl.usersadmin.AuditGetUsersListEventFactory;
69 import org.openecomp.sdc.be.auditing.impl.usersadmin.AuditUserAccessEventFactory;
70 import org.openecomp.sdc.be.auditing.impl.usersadmin.AuditUserAdminEventFactory;
71 import org.openecomp.sdc.be.components.distribution.engine.DmaapConsumer;
72 import org.openecomp.sdc.be.components.impl.ImportUtils;
73 import org.openecomp.sdc.be.components.impl.ImportUtils.ResultStatusEnum;
74 import org.openecomp.sdc.be.components.impl.ResponseFormatManager;
75 import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentException;
76 import org.openecomp.sdc.be.components.impl.exceptions.ByResponseFormatComponentException;
77 import org.openecomp.sdc.be.components.impl.exceptions.ComponentException;
78 import org.openecomp.sdc.be.config.BeEcompErrorManager;
79 import org.openecomp.sdc.be.dao.api.ActionStatus;
80 import org.openecomp.sdc.be.dao.cassandra.CassandraOperationStatus;
81 import org.openecomp.sdc.be.dao.graph.datatype.AdditionalInformationEnum;
82 import org.openecomp.sdc.be.datamodel.utils.ConstraintConvertor;
83 import org.openecomp.sdc.be.datatypes.elements.AdditionalInfoParameterInfo;
84 import org.openecomp.sdc.be.datatypes.elements.RequirementNodeFilterPropertyDataDefinition;
85 import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
86 import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
87 import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
88 import org.openecomp.sdc.be.model.ArtifactDefinition;
89 import org.openecomp.sdc.be.model.CapabilityTypeDefinition;
90 import org.openecomp.sdc.be.model.Component;
91 import org.openecomp.sdc.be.model.ComponentInstance;
92 import org.openecomp.sdc.be.model.ConsumerDefinition;
93 import org.openecomp.sdc.be.model.DataTypeDefinition;
94 import org.openecomp.sdc.be.model.GroupTypeDefinition;
95 import org.openecomp.sdc.be.model.LifecycleStateEnum;
96 import org.openecomp.sdc.be.model.PolicyTypeDefinition;
97 import org.openecomp.sdc.be.model.PropertyConstraint;
98 import org.openecomp.sdc.be.model.RequirementDefinition;
99 import org.openecomp.sdc.be.model.Resource;
100 import org.openecomp.sdc.be.model.User;
101 import org.openecomp.sdc.be.model.operations.StorageException;
102 import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
103 import org.openecomp.sdc.be.model.operations.impl.PropertyOperation.PropertyConstraintDeserialiser;
104 import org.openecomp.sdc.be.model.operations.impl.PropertyOperation.PropertyConstraintJacksonDeserializer;
105 import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum;
106 import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants;
107 import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData;
108 import org.openecomp.sdc.be.resources.data.auditing.model.DistributionData;
109 import org.openecomp.sdc.be.resources.data.auditing.model.DistributionTopicData;
110 import org.openecomp.sdc.be.resources.data.auditing.model.OperationalEnvAuditData;
111 import org.openecomp.sdc.be.resources.data.auditing.model.ResourceCommonInfo;
112 import org.openecomp.sdc.be.resources.data.auditing.model.ResourceVersionInfo;
113 import org.openecomp.sdc.be.tosca.ToscaError;
114 import org.openecomp.sdc.be.ui.model.UIConstraint;
115 import org.openecomp.sdc.be.ui.model.UiLeftPaletteComponent;
116 import org.openecomp.sdc.common.api.Constants;
117 import org.openecomp.sdc.common.log.enums.EcompLoggerErrorCode;
118 import org.openecomp.sdc.common.log.enums.LogLevel;
119 import org.openecomp.sdc.common.log.enums.Severity;
120 import org.openecomp.sdc.common.log.wrappers.Logger;
121 import org.openecomp.sdc.common.log.wrappers.LoggerSdcAudit;
122 import org.openecomp.sdc.common.util.ThreadLocalsHolder;
123 import org.openecomp.sdc.common.util.ValidationUtils;
124 import org.openecomp.sdc.exception.ResponseFormat;
125 import org.slf4j.MarkerFactory;
126 import org.springframework.beans.factory.annotation.Autowired;
128 @org.springframework.stereotype.Component("componentUtils")
129 public class ComponentsUtils {
131 private static final String CONVERT_STORAGE_RESPONSE_TO_ACTION_RESPONSE = "convert storage response {} to action response {}";
132 private static final String INSIDE_AUDITING_FOR_AUDIT_ACTION = "Inside auditing for audit action {}";
133 private static final String AUDIT_BEFORE_SENDING_RESPONSE = "audit before sending response";
134 private static final String CONVERT_JSON_TO_OBJECT = "convertJsonToObject";
135 private static final Logger log = Logger.getLogger(ComponentsUtils.class);
136 private static final String PARTNER_NAME = "UNKNOWN";
137 private final AuditingManager auditingManager;
138 private final ResponseFormatManager responseFormatManager;
139 private static LoggerSdcAudit audit = new LoggerSdcAudit(DmaapConsumer.class);
142 public ComponentsUtils(AuditingManager auditingManager) {
143 this.auditingManager = auditingManager;
144 this.responseFormatManager = ResponseFormatManager.getInstance();
147 public AuditingManager getAuditingManager() {
148 return auditingManager;
151 public <T> Either<T, ResponseFormat> convertJsonToObject(String data, User user, Class<T> clazz, AuditingActionEnum actionEnum) {
153 BeEcompErrorManager.getInstance().logBeInvalidJsonInput(CONVERT_JSON_TO_OBJECT);
154 log.debug("object is null after converting from json");
155 ResponseFormat responseFormat = getInvalidContentErrorAndAudit(user, actionEnum);
156 return Either.right(responseFormat);
159 T obj = parseJsonToObject(data, clazz);
160 return Either.left(obj);
161 } catch (Exception e) {
163 BeEcompErrorManager.getInstance().logBeInvalidJsonInput(CONVERT_JSON_TO_OBJECT);
164 log.debug("failed to convert from json {}", data, e);
165 ResponseFormat responseFormat = getInvalidContentErrorAndAudit(user, actionEnum);
166 return Either.right(responseFormat);
170 public static <T> T parseJsonToObject(String data, Class<T> clazz) {
171 Type constraintType = new TypeToken<PropertyConstraint>() {}.getType();
172 Gson gson = new GsonBuilder().registerTypeAdapter(constraintType, new PropertyConstraintDeserialiser()).create();
173 log.trace("convert json to object. json=\n{}", data);
174 return gson.fromJson(data, clazz);
177 public <T> Either<T, ResponseFormat> convertJsonToObjectUsingObjectMapper(String data, User user, Class<T> clazz, AuditingActionEnum actionEnum, ComponentTypeEnum typeEnum) {
179 ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
180 mapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
181 mapper.configure(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_AS_NULL, true);
184 log.trace("convert json to object. json=\n{}", data);
186 SimpleModule module = new SimpleModule("customDeserializationModule");
187 module.addDeserializer(PropertyConstraint.class, new PropertyConstraintJacksonDeserializer());
188 mapper.registerModule(module);
190 component = mapper.readValue(data, clazz);
191 if (component == null) {
192 BeEcompErrorManager.getInstance().logBeInvalidJsonInput(CONVERT_JSON_TO_OBJECT);
193 log.debug("object is null after converting from json");
194 ResponseFormat responseFormat = getInvalidContentErrorAndAuditComponent(user, actionEnum, typeEnum);
195 return Either.right(responseFormat);
197 } catch (Exception e) {
198 BeEcompErrorManager.getInstance().logBeInvalidJsonInput(CONVERT_JSON_TO_OBJECT);
199 log.debug("failed to convert from json {}", data, e);
200 ResponseFormat responseFormat = getInvalidContentErrorAndAuditComponent(user, actionEnum, typeEnum);
201 return Either.right(responseFormat);
203 return Either.left(component);
206 public ResponseFormat getResponseFormat(ActionStatus actionStatus, String... params) {
207 return responseFormatManager.getResponseFormat(actionStatus, params);
210 public ResponseFormat getResponseFormat(StorageOperationStatus storageStatus, String... params) {
211 return responseFormatManager.getResponseFormat(this.convertFromStorageResponse(storageStatus), params);
214 public <T> Either<List<T>, ResponseFormat> convertToResponseFormatOrNotFoundErrorToEmptyList(StorageOperationStatus storageOperationStatus) {
215 return storageOperationStatus.equals(StorageOperationStatus.NOT_FOUND) ? Either.left(Collections.emptyList()) :
216 Either.right(getResponseFormat(storageOperationStatus));
220 * Returns the response format of resource error with respective variables according to actionStatus. This is needed for cases where actionStatus is anonymously converted from storage operation, and the caller doesn't know what actionStatus he
221 * received. It's caller's Responsibility to fill the resource object passed to this function with needed fields.
223 * Note that RESOURCE_IN_USE case passes hardcoded "resource" string to the error parameter. This means that if Resource object will also be used for Service, this code needs to be refactored and we should tell Resource from Service.
225 * @param actionStatus
229 public ResponseFormat getResponseFormatByResource(ActionStatus actionStatus, Component resource) {
230 if (resource == null) {
231 return getResponseFormat(actionStatus);
233 ResponseFormat responseFormat;
235 switch (actionStatus) {
236 case COMPONENT_VERSION_ALREADY_EXIST:
237 responseFormat = getResponseFormat(ActionStatus.COMPONENT_VERSION_ALREADY_EXIST, ComponentTypeEnum.RESOURCE.getValue(), resource.getVersion());
239 case RESOURCE_NOT_FOUND:
240 responseFormat = getResponseFormat(ActionStatus.RESOURCE_NOT_FOUND, resource.getName());
242 case COMPONENT_NAME_ALREADY_EXIST:
243 responseFormat = getResponseFormat(ActionStatus.COMPONENT_NAME_ALREADY_EXIST, ComponentTypeEnum.RESOURCE.getValue(), resource.getName());
245 case COMPONENT_IN_USE:
246 responseFormat = getResponseFormat(ActionStatus.COMPONENT_IN_USE, ComponentTypeEnum.RESOURCE.name().toLowerCase(), resource.getUniqueId());
249 responseFormat = getResponseFormat(actionStatus);
252 return responseFormat;
255 public ResponseFormat getResponseFormatByResource(ActionStatus actionStatus, String resourceName) {
256 if (resourceName == null) {
257 return getResponseFormat(actionStatus);
260 ResponseFormat responseFormat;
261 if (actionStatus == ActionStatus.RESOURCE_NOT_FOUND) {
262 responseFormat = getResponseFormat(ActionStatus.RESOURCE_NOT_FOUND, resourceName);
265 responseFormat = getResponseFormat(actionStatus);
267 return responseFormat;
270 public ResponseFormat getResponseFormatByCapabilityType(ActionStatus actionStatus, CapabilityTypeDefinition capabilityType) {
271 if (capabilityType == null) {
272 return getResponseFormat(actionStatus);
275 ResponseFormat responseFormat;
276 if (actionStatus == ActionStatus.CAPABILITY_TYPE_ALREADY_EXIST) {
277 responseFormat = getResponseFormat(ActionStatus.CAPABILITY_TYPE_ALREADY_EXIST, capabilityType.getType());
280 responseFormat = getResponseFormat(actionStatus);
282 return responseFormat;
285 public <T> ResponseFormat getResponseFormatByElement(ActionStatus actionStatus, T obj) {
287 return getResponseFormat(actionStatus);
290 ResponseFormat responseFormat = null;
291 if (actionStatus == ActionStatus.MISSING_CAPABILITY_TYPE) {
292 if (obj instanceof List && org.apache.commons.collections.CollectionUtils.isNotEmpty((List) obj)) {
293 List list = (List) obj;
294 if (list.get(0) instanceof RequirementDefinition) {
295 responseFormat = getResponseFormat(ActionStatus.MISSING_CAPABILITY_TYPE, ((RequirementDefinition) list
296 .get(0)).getName()); //Arbitray index, all we need is single object
297 return responseFormat;
300 log.debug("UNKNOWN TYPE : expecting obj as a non empty List<RequirmentsDefinitions>");
303 responseFormat = getResponseFormat(actionStatus);
305 return responseFormat;
309 * Returns the response format of resource error with respective variables according to actionStatus. This is needed for cases where actionStatus is anynomously converted from storage operation, and the caller doesn't know what actionStatus he
310 * received. It's caller's responisibility to fill the passed resource object with needed fields.
312 * @param actionStatus
316 ResponseFormat getResponseFormatByUser(ActionStatus actionStatus, User user) {
318 return getResponseFormat(actionStatus);
320 ResponseFormat requestErrorWrapper;
321 switch (actionStatus) {
322 case INVALID_USER_ID:
323 requestErrorWrapper = getResponseFormat(actionStatus, user.getUserId());
325 case INVALID_EMAIL_ADDRESS:
326 requestErrorWrapper = getResponseFormat(actionStatus, user.getEmail());
329 requestErrorWrapper = getResponseFormat(actionStatus, user.getRole());
332 case USER_ALREADY_EXIST:
334 case USER_HAS_ACTIVE_ELEMENTS:
335 requestErrorWrapper = getResponseFormat(actionStatus, user.getUserId());
338 requestErrorWrapper = getResponseFormat(actionStatus);
341 return requestErrorWrapper;
344 public ResponseFormat getResponseFormatByUserId(ActionStatus actionStatus, String userId) {
345 User user = new User();
346 user.setUserId(userId);
347 return getResponseFormatByUser(actionStatus, user);
350 public ResponseFormat getResponseFormatByDE(ActionStatus actionStatus, String envName) {
351 ResponseFormat responseFormat;
353 switch (actionStatus) {
354 case DISTRIBUTION_ENVIRONMENT_NOT_AVAILABLE:
355 responseFormat = getResponseFormat(ActionStatus.DISTRIBUTION_ENVIRONMENT_NOT_AVAILABLE, envName);
357 case DISTRIBUTION_ENVIRONMENT_NOT_FOUND:
358 responseFormat = getResponseFormat(ActionStatus.DISTRIBUTION_ENVIRONMENT_NOT_FOUND, envName);
361 responseFormat = getResponseFormat(actionStatus);
364 return responseFormat;
367 public ResponseFormat getResponseFormatByArtifactId(ActionStatus actionStatus, String artifactId) {
368 ResponseFormat responseFormat;
370 switch (actionStatus) {
371 case RESOURCE_NOT_FOUND:
372 case ARTIFACT_NOT_FOUND:
373 responseFormat = getResponseFormat(ActionStatus.ARTIFACT_NOT_FOUND, artifactId);
376 responseFormat = getResponseFormat(actionStatus);
379 return responseFormat;
382 public ResponseFormat getInvalidContentErrorAndAudit(User user, AuditingActionEnum actionEnum) {
383 ResponseFormat responseFormat = responseFormatManager.getResponseFormat(ActionStatus.INVALID_CONTENT);
384 log.debug(AUDIT_BEFORE_SENDING_RESPONSE);
385 auditAdminUserAction(actionEnum, user, null, null, responseFormat);
386 return responseFormat;
389 public ResponseFormat getInvalidContentErrorAndAudit(User user, String resourceName, AuditingActionEnum actionEnum) {
390 ResponseFormat responseFormat = responseFormatManager.getResponseFormat(ActionStatus.INVALID_CONTENT);
391 log.debug(AUDIT_BEFORE_SENDING_RESPONSE);
392 auditResource(responseFormat, user, resourceName, actionEnum);
393 return responseFormat;
398 public ResponseFormat getInvalidContentErrorForConsumerAndAudit(User user, ConsumerDefinition consumer, AuditingActionEnum actionEnum) {
399 ResponseFormat responseFormat = responseFormatManager.getResponseFormat(ActionStatus.INVALID_CONTENT);
400 log.debug(AUDIT_BEFORE_SENDING_RESPONSE);
401 auditConsumerCredentialsEvent(actionEnum, consumer, responseFormat, user);
402 return responseFormat;
405 private ResponseFormat getInvalidContentErrorAndAuditComponent(User user, AuditingActionEnum actionEnum, ComponentTypeEnum typeEnum) {
406 ResponseFormat responseFormat = responseFormatManager.getResponseFormat(ActionStatus.INVALID_CONTENT);
407 log.debug(AUDIT_BEFORE_SENDING_RESPONSE);
408 auditComponentAdmin(responseFormat, user, null, actionEnum, typeEnum);
409 return responseFormat;
412 public void auditResource(ResponseFormat responseFormat, User modifier, Resource resource, AuditingActionEnum actionEnum, ResourceVersionInfo prevResFields) {
413 auditResource(responseFormat, modifier, resource, resource.getName(), actionEnum, prevResFields, null, null);
416 public void auditResource(ResponseFormat responseFormat, User modifier, String resourceName, AuditingActionEnum actionEnum) {
417 auditResource(responseFormat, modifier, null, resourceName, actionEnum);
420 public void auditResource(ResponseFormat responseFormat, User modifier, Resource resource, AuditingActionEnum actionEnum) {
421 auditResource(responseFormat, modifier, resource, resource.getName(), actionEnum);
424 public void auditResource(ResponseFormat responseFormat, User modifier, Resource resource, String resourceName, AuditingActionEnum actionEnum) {
425 auditResource(responseFormat, modifier, resource, resourceName, actionEnum, ResourceVersionInfo.newBuilder().build(), null, null);
428 public void auditResource(ResponseFormat responseFormat, User modifier, Resource resource, String resourceName, AuditingActionEnum actionEnum,
429 ResourceVersionInfo prevResFields, String currentArtifactUuid, ArtifactDefinition artifactDefinition) {
430 if (actionEnum != null) {
431 int status = responseFormat.getStatus();
434 String resourceCurrVersion = null;
435 String resourceCurrState = null;
436 String invariantUUID = null;
437 String resourceType = ComponentTypeEnum.RESOURCE.getValue();
438 String toscaNodeType = null;
440 log.trace(INSIDE_AUDITING_FOR_AUDIT_ACTION, actionEnum);
442 String message = getMessageString(responseFormat);
444 String artifactData = buildAuditingArtifactData(artifactDefinition);
446 if (resource != null) {
447 resourceName = resource.getName();
448 resourceCurrVersion = resource.getVersion();
449 if (resource.getLifecycleState() != null) {
450 resourceCurrState = resource.getLifecycleState().name();
452 if (resource.getResourceType() != null) {
453 resourceType = resource.getResourceType().name();
455 invariantUUID = resource.getInvariantUUID();
456 uuid = resource.getUUID();
457 toscaNodeType = resource.getToscaResourceName();
460 AuditEventFactory factory = AuditResourceEventFactoryManager.createResourceEventFactory(
462 CommonAuditData.newBuilder()
464 .description(message)
465 .requestId(ThreadLocalsHolder.getUuid())
466 .serviceInstanceId(uuid)
468 new ResourceCommonInfo(resourceName, resourceType),
470 ResourceVersionInfo.newBuilder()
471 .artifactUuid(currentArtifactUuid)
472 .state(resourceCurrState)
473 .version(resourceCurrVersion)
477 artifactData, null, null, toscaNodeType);
479 getAuditingManager().auditEvent(factory);
483 private String getMessageString(ResponseFormat responseFormat) {
485 if (responseFormat.getMessageId() != null) {
486 message = responseFormat.getMessageId() + ": ";
488 message += responseFormat.getFormattedMessage();
492 public void auditDistributionDownload(ResponseFormat responseFormat, DistributionData distributionData) {
493 log.trace("Inside auditing");
494 int status = responseFormat.getStatus();
496 String message = getMessageString(responseFormat);
498 AuditDistributionDownloadEventFactory factory = new AuditDistributionDownloadEventFactory(
499 CommonAuditData.newBuilder()
501 .description(message)
502 .requestId(ThreadLocalsHolder.getUuid())
505 getAuditingManager().auditEvent(factory);
508 public void auditExternalGetAsset(ResponseFormat responseFormat, AuditingActionEnum actionEnum, DistributionData distributionData,
509 ResourceCommonInfo resourceCommonInfo, String requestId, String serviceInstanceId) {
510 log.trace(INSIDE_AUDITING_FOR_AUDIT_ACTION, actionEnum);
512 AuditEventFactory factory = new AuditAssetExternalApiEventFactory(actionEnum,
513 CommonAuditData.newBuilder()
514 .status(responseFormat.getStatus())
515 .description(getMessageString(responseFormat))
516 .requestId(requestId)
517 .serviceInstanceId(serviceInstanceId)
519 resourceCommonInfo, distributionData);
521 getAuditingManager().auditEvent(factory);
524 public void auditExternalGetAssetList(ResponseFormat responseFormat, AuditingActionEnum actionEnum, DistributionData distributionData, String requestId) {
525 log.trace(INSIDE_AUDITING_FOR_AUDIT_ACTION, actionEnum);
527 AuditEventFactory factory = new AuditAssetListExternalApiEventFactory(actionEnum,
528 CommonAuditData.newBuilder()
529 .status(responseFormat.getStatus())
530 .description(getMessageString(responseFormat))
531 .requestId(requestId)
535 getAuditingManager().auditEvent(factory);
538 public void auditChangeLifecycleAction(ResponseFormat responseFormat, ComponentTypeEnum componentType, String requestId,
539 Component component, Component responseObject, DistributionData distributionData, User modifier) {
541 String invariantUuid = "";
542 String serviceInstanceId = "";
543 ResourceVersionInfo currResourceVersionInfo = null;
544 ResourceVersionInfo prevResourceVersionInfo = null;
545 ResourceCommonInfo resourceCommonInfo = new ResourceCommonInfo(componentType.getValue());
547 if (component != null) {
548 prevResourceVersionInfo = buildResourceVersionInfoFromComponent(component);
549 resourceCommonInfo.setResourceName(component.getName());
552 if (responseObject != null){
553 currResourceVersionInfo = buildResourceVersionInfoFromComponent(responseObject);
554 invariantUuid = responseObject.getInvariantUUID();
555 serviceInstanceId = responseObject.getUUID();
557 else if (component != null){
558 currResourceVersionInfo = buildResourceVersionInfoFromComponent(component);
559 invariantUuid = component.getInvariantUUID();
560 serviceInstanceId = component.getUUID();
563 if (prevResourceVersionInfo == null) {
564 prevResourceVersionInfo = ResourceVersionInfo.newBuilder()
567 if (currResourceVersionInfo == null) {
568 currResourceVersionInfo = ResourceVersionInfo.newBuilder()
571 AuditEventFactory factory = new AuditChangeLifecycleExternalApiEventFactory(
572 CommonAuditData.newBuilder()
573 .serviceInstanceId(serviceInstanceId)
574 .requestId(requestId)
575 .description(getMessageString(responseFormat))
576 .status(responseFormat.getStatus())
578 resourceCommonInfo, distributionData,
579 prevResourceVersionInfo, currResourceVersionInfo,
580 invariantUuid, modifier);
582 getAuditingManager().auditEvent(factory);
585 private ResourceVersionInfo buildResourceVersionInfoFromComponent(Component component) {
586 return ResourceVersionInfo.newBuilder()
587 .version(component.getVersion())
588 .state(component.getLifecycleState().name())
592 public void auditExternalCrudApi(ResponseFormat responseFormat, AuditingActionEnum actionEnum, ResourceCommonInfo resourceCommonInfo, HttpServletRequest request,
593 ArtifactDefinition artifactDefinition, String artifactUuid) {
594 log.trace(INSIDE_AUDITING_FOR_AUDIT_ACTION, actionEnum);
596 ResourceVersionInfo currResourceVersionInfo;
597 User modifier = new User();
598 modifier.setUserId(request.getHeader(Constants.USER_ID_HEADER));
599 String artifactData = "";
600 DistributionData distributionData = new DistributionData(request.getHeader(Constants.X_ECOMP_INSTANCE_ID_HEADER), request.getRequestURI());
601 String requestId = request.getHeader(Constants.X_ECOMP_REQUEST_ID_HEADER);
604 if (artifactDefinition == null) {
605 currResourceVersionInfo = ResourceVersionInfo.newBuilder()
606 .artifactUuid(artifactUuid)
610 currResourceVersionInfo = ResourceVersionInfo.newBuilder()
611 .artifactUuid(artifactDefinition.getArtifactUUID())
612 .version(artifactDefinition.getArtifactVersion())
614 artifactData = buildAuditingArtifactData(artifactDefinition);
615 modifier.setUserId(artifactDefinition.getUserIdLastUpdater());
617 AuditEventFactory factory = new AuditCrudExternalApiArtifactEventFactory(actionEnum,
618 CommonAuditData.newBuilder()
619 .status(responseFormat.getStatus())
620 .description(getMessageString(responseFormat))
621 .requestId(requestId)
623 resourceCommonInfo, distributionData, ResourceVersionInfo.newBuilder().build(), currResourceVersionInfo,
624 null, modifier, artifactData);
626 getAuditingManager().auditEvent(factory);
629 public boolean isExternalApiEvent(AuditingActionEnum auditingActionEnum){
630 return auditingActionEnum != null && auditingActionEnum.getAuditingEsType().equals(AuditingTypesConstants.EXTERNAL_API_EVENT_TYPE);
633 public void auditCreateResourceExternalApi(ResponseFormat responseFormat, ResourceCommonInfo resourceCommonInfo, HttpServletRequest request,
636 String invariantUuid = null;
637 String serviceInstanceId = null;
639 User modifier = new User();
640 modifier.setUserId(request.getHeader(Constants.USER_ID_HEADER));
641 DistributionData distributionData = new DistributionData(request.getHeader(Constants.X_ECOMP_INSTANCE_ID_HEADER), request.getRequestURI());
642 String requestId = request.getHeader(Constants.X_ECOMP_REQUEST_ID_HEADER);
644 ResourceVersionInfo currResourceVersionInfo;
646 if( resource != null ){
647 currResourceVersionInfo = ResourceVersionInfo.newBuilder()
648 .state(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT.name())
649 .version(ImportUtils.Constants.FIRST_NON_CERTIFIED_VERSION)
651 resourceCommonInfo.setResourceName(resource.getName());
652 invariantUuid = resource.getInvariantUUID();
653 serviceInstanceId = resource.getUUID();
656 currResourceVersionInfo = ResourceVersionInfo.newBuilder()
660 AuditEventFactory factory = new AuditCreateResourceExternalApiEventFactory(
661 CommonAuditData.newBuilder()
662 .status(responseFormat.getStatus())
663 .description(getMessageString(responseFormat))
664 .requestId(requestId)
665 .serviceInstanceId(serviceInstanceId)
667 resourceCommonInfo, distributionData,
668 currResourceVersionInfo, invariantUuid, modifier);
670 getAuditingManager().auditEvent(factory);
673 public void auditCreateServiceExternalApi(ResponseFormat responseFormat, HttpServletRequest request, Component service) {
675 String invariantUuid = null;
676 String serviceInstanceId = null;
678 User modifier = new User();
679 modifier.setUserId(request.getHeader(Constants.USER_ID_HEADER));
680 DistributionData distributionData = new DistributionData(request.getHeader(Constants.X_ECOMP_INSTANCE_ID_HEADER), request.getRequestURI());
681 String requestId = request.getHeader(Constants.X_ECOMP_REQUEST_ID_HEADER);
683 if(null != service) {
684 invariantUuid = service.getInvariantUUID();
685 serviceInstanceId = service.getUUID();
688 AuditEventFactory factory = new AuditCreateServiceExternalApiEventFactory(
689 CommonAuditData.newBuilder()
690 .status(responseFormat.getStatus())
691 .description(getMessageString(responseFormat))
692 .requestId(requestId)
693 .serviceInstanceId(serviceInstanceId)
695 new ResourceCommonInfo(ComponentTypeEnum.SERVICE.name()), distributionData, invariantUuid, modifier);
697 getAuditingManager().auditEvent(factory);
701 public void auditExternalActivateService(ResponseFormat responseFormat, DistributionData distributionData, String requestId, String serviceInstanceUuid, User modifier) {
702 AuditEventFactory factory = new AuditActivateServiceExternalApiEventFactory(
703 CommonAuditData.newBuilder()
704 .serviceInstanceId(serviceInstanceUuid)
705 .description(getMessageString(responseFormat))
706 .status(responseFormat.getStatus())
707 .requestId(requestId)
709 new ResourceCommonInfo(ComponentTypeEnum.SERVICE.name()), distributionData, "", modifier);
710 getAuditingManager().auditEvent(factory);
713 public void auditExternalDownloadArtifact(ResponseFormat responseFormat, ResourceCommonInfo resourceCommonInfo,
714 DistributionData distributionData, String requestId, String currArtifactUuid, String userId) {
715 User modifier = new User();
716 modifier.setUserId(userId);
718 AuditEventFactory factory = new AuditDownloadArtifactExternalApiEventFactory(
719 CommonAuditData.newBuilder()
720 .description(getMessageString(responseFormat))
721 .status(responseFormat.getStatus())
722 .requestId(requestId)
724 resourceCommonInfo, distributionData,
725 ResourceVersionInfo.newBuilder()
726 .artifactUuid(currArtifactUuid)
729 getAuditingManager().auditEvent(factory);
732 private String buildAuditingArtifactData(ArtifactDefinition artifactDefinition) {
733 StringBuilder sb = new StringBuilder();
734 if (artifactDefinition != null) {
735 sb.append(artifactDefinition.getArtifactGroupType().getType())
738 .append(artifactDefinition.getArtifactLabel())
741 .append(artifactDefinition.getArtifactType())
743 .append(artifactDefinition.getArtifactName())
745 .append(artifactDefinition.getTimeout())
747 .append(artifactDefinition.getEsId());
750 sb.append(artifactDefinition.getArtifactVersion() != null ? artifactDefinition.getArtifactVersion() : " ");
752 sb.append(artifactDefinition.getArtifactUUID() != null ? artifactDefinition.getArtifactUUID() : " ");
754 return sb.toString();
757 public void auditCategory(ResponseFormat responseFormat, User modifier, String categoryName, String subCategoryName, String groupingName, AuditingActionEnum actionEnum, String componentType) {
758 log.trace(INSIDE_AUDITING_FOR_AUDIT_ACTION, actionEnum);
760 AuditEventFactory factory = new AuditCategoryEventFactory(actionEnum,
761 CommonAuditData.newBuilder()
762 .description(getMessageString(responseFormat))
763 .status(responseFormat.getStatus())
764 .requestId(ThreadLocalsHolder.getUuid())
766 modifier, categoryName, subCategoryName, groupingName, componentType);
768 getAuditingManager().auditEvent(factory);
771 public ActionStatus convertFromStorageResponse(StorageOperationStatus storageResponse) {
773 return convertFromStorageResponse(storageResponse, ComponentTypeEnum.RESOURCE);
776 public ActionStatus convertFromStorageResponse(StorageOperationStatus storageResponse, ComponentTypeEnum type) {
778 ActionStatus responseEnum = ActionStatus.GENERAL_ERROR;
779 if (storageResponse == null) {
782 switch (storageResponse) {
784 responseEnum = ActionStatus.OK;
786 case CONNECTION_FAILURE:
788 responseEnum = ActionStatus.GENERAL_ERROR;
791 responseEnum = ActionStatus.INVALID_CONTENT;
793 case ENTITY_ALREADY_EXISTS:
794 responseEnum = ActionStatus.COMPONENT_NAME_ALREADY_EXIST;
796 case PARENT_RESOURCE_NOT_FOUND:
797 responseEnum = ActionStatus.PARENT_RESOURCE_NOT_FOUND;
799 case MULTIPLE_PARENT_RESOURCE_FOUND:
800 responseEnum = ActionStatus.MULTIPLE_PARENT_RESOURCE_FOUND;
803 if (ComponentTypeEnum.RESOURCE == type) {
804 responseEnum = ActionStatus.RESOURCE_NOT_FOUND;
805 } else if (ComponentTypeEnum.PRODUCT == type) {
806 responseEnum = ActionStatus.PRODUCT_NOT_FOUND;
808 responseEnum = ActionStatus.SERVICE_NOT_FOUND;
811 case FAILED_TO_LOCK_ELEMENT:
812 responseEnum = ActionStatus.COMPONENT_IN_USE;
814 case ARTIFACT_NOT_FOUND:
815 responseEnum = ActionStatus.ARTIFACT_NOT_FOUND;
817 case DISTR_ENVIRONMENT_NOT_AVAILABLE:
818 responseEnum = ActionStatus.DISTRIBUTION_ENVIRONMENT_NOT_AVAILABLE;
820 case DISTR_ENVIRONMENT_NOT_FOUND:
821 responseEnum = ActionStatus.DISTRIBUTION_ENVIRONMENT_NOT_FOUND;
823 case DISTR_ENVIRONMENT_SENT_IS_INVALID:
824 responseEnum = ActionStatus.DISTRIBUTION_ENVIRONMENT_INVALID;
827 responseEnum = ActionStatus.INVALID_CONTENT;
830 responseEnum = ActionStatus.INVALID_CONTENT;
833 responseEnum = ActionStatus.CSAR_NOT_FOUND;
835 case PROPERTY_NAME_ALREADY_EXISTS:
836 responseEnum = ActionStatus.PROPERTY_NAME_ALREADY_EXISTS;
838 case MATCH_NOT_FOUND:
839 responseEnum = ActionStatus.COMPONENT_SUB_CATEGORY_NOT_FOUND_FOR_CATEGORY;
841 case CATEGORY_NOT_FOUND:
842 responseEnum = ActionStatus.COMPONENT_CATEGORY_NOT_FOUND;
844 case INVALID_PROPERTY:
845 responseEnum = ActionStatus.INVALID_PROPERTY;
847 case COMPONENT_IS_ARCHIVED:
848 responseEnum = ActionStatus.COMPONENT_IS_ARCHIVED;
850 case DECLARED_INPUT_USED_BY_OPERATION:
851 responseEnum = ActionStatus.DECLARED_INPUT_USED_BY_OPERATION;
854 responseEnum = ActionStatus.GENERAL_ERROR;
857 log.debug(CONVERT_STORAGE_RESPONSE_TO_ACTION_RESPONSE, storageResponse, responseEnum);
861 public ActionStatus convertFromToscaError(ToscaError toscaError) {
862 ActionStatus responseEnum = ActionStatus.GENERAL_ERROR;
863 if (toscaError == null) {
866 switch (toscaError) {// TODO match errors
867 case NODE_TYPE_CAPABILITY_ERROR:
868 case NOT_SUPPORTED_TOSCA_TYPE:
869 case NODE_TYPE_REQUIREMENT_ERROR:
870 responseEnum = ActionStatus.INVALID_CONTENT;
873 responseEnum = ActionStatus.GENERAL_ERROR;
879 public ActionStatus convertFromStorageResponseForCapabilityType(StorageOperationStatus storageResponse) {
880 ActionStatus responseEnum;
882 switch (storageResponse) {
884 responseEnum = ActionStatus.OK;
886 case CONNECTION_FAILURE:
888 responseEnum = ActionStatus.GENERAL_ERROR;
891 responseEnum = ActionStatus.INVALID_CONTENT;
893 case ENTITY_ALREADY_EXISTS:
894 responseEnum = ActionStatus.CAPABILITY_TYPE_ALREADY_EXIST;
896 case SCHEMA_VIOLATION:
897 responseEnum = ActionStatus.CAPABILITY_TYPE_ALREADY_EXIST;
900 responseEnum = ActionStatus.GENERAL_ERROR;
903 log.debug(CONVERT_STORAGE_RESPONSE_TO_ACTION_RESPONSE, storageResponse, responseEnum);
907 public ActionStatus convertFromStorageResponseForLifecycleType(StorageOperationStatus storageResponse) {
908 ActionStatus responseEnum;
910 switch (storageResponse) {
912 responseEnum = ActionStatus.OK;
914 case CONNECTION_FAILURE:
916 responseEnum = ActionStatus.GENERAL_ERROR;
919 responseEnum = ActionStatus.INVALID_CONTENT;
921 case ENTITY_ALREADY_EXISTS:
922 responseEnum = ActionStatus.LIFECYCLE_TYPE_ALREADY_EXIST;
924 case SCHEMA_VIOLATION:
925 responseEnum = ActionStatus.LIFECYCLE_TYPE_ALREADY_EXIST;
928 responseEnum = ActionStatus.GENERAL_ERROR;
931 log.debug(CONVERT_STORAGE_RESPONSE_TO_ACTION_RESPONSE, storageResponse, responseEnum);
935 public ActionStatus convertFromStorageResponseForResourceInstance(StorageOperationStatus storageResponse, boolean isRelation) {
936 ActionStatus responseEnum;
938 switch (storageResponse) {
940 responseEnum = ActionStatus.OK;
943 responseEnum = ActionStatus.RESOURCE_INSTANCE_BAD_REQUEST;
945 case INVALID_PROPERTY:
946 responseEnum = ActionStatus.INVALID_PROPERTY;
949 responseEnum = ActionStatus.GENERAL_ERROR;
952 responseEnum = ActionStatus.INVALID_CONTENT;
954 case MATCH_NOT_FOUND:
955 responseEnum = ActionStatus.RESOURCE_INSTANCE_MATCH_NOT_FOUND;
957 case SCHEMA_VIOLATION:
958 responseEnum = ActionStatus.RESOURCE_INSTANCE_ALREADY_EXIST;
962 responseEnum = ActionStatus.RESOURCE_INSTANCE_RELATION_NOT_FOUND;
964 responseEnum = ActionStatus.RESOURCE_INSTANCE_NOT_FOUND;
968 responseEnum = ActionStatus.GENERAL_ERROR;
971 log.debug(CONVERT_STORAGE_RESPONSE_TO_ACTION_RESPONSE, storageResponse, responseEnum);
975 public ResponseFormat getResponseFormatForResourceInstance(ActionStatus actionStatus, String serviceName, String resourceInstanceName) {
976 ResponseFormat responseFormat;
978 if (actionStatus == ActionStatus.RESOURCE_INSTANCE_NOT_FOUND) {
979 responseFormat = getResponseFormat(actionStatus, resourceInstanceName);
982 responseFormat = getResponseFormat(actionStatus, serviceName);
984 return responseFormat;
987 public ResponseFormat getResponseFormatForResourceInstanceProperty(ActionStatus actionStatus, String resourceInstanceName) {
988 ResponseFormat responseFormat;
989 if (actionStatus == ActionStatus.RESOURCE_INSTANCE_NOT_FOUND) {
990 responseFormat = getResponseFormat(actionStatus, resourceInstanceName);
993 responseFormat = getResponseFormat(actionStatus);
995 return responseFormat;
998 public ActionStatus convertFromStorageResponseForResourceInstanceProperty(StorageOperationStatus storageResponse) {
999 ActionStatus responseEnum;
1001 switch (storageResponse) {
1003 responseEnum = ActionStatus.OK;
1006 responseEnum = ActionStatus.RESOURCE_INSTANCE_BAD_REQUEST;
1009 responseEnum = ActionStatus.GENERAL_ERROR;
1012 responseEnum = ActionStatus.INVALID_CONTENT;
1014 case MATCH_NOT_FOUND:
1015 responseEnum = ActionStatus.RESOURCE_INSTANCE_MATCH_NOT_FOUND;
1017 case SCHEMA_VIOLATION:
1018 responseEnum = ActionStatus.RESOURCE_INSTANCE_ALREADY_EXIST;
1021 responseEnum = ActionStatus.RESOURCE_INSTANCE_NOT_FOUND;
1024 responseEnum = ActionStatus.GENERAL_ERROR;
1027 log.debug(CONVERT_STORAGE_RESPONSE_TO_ACTION_RESPONSE, storageResponse, responseEnum);
1028 return responseEnum;
1031 public void auditComponent(ResponseFormat responseFormat, User modifier, Component component, AuditingActionEnum actionEnum, ResourceCommonInfo resourceCommonInfo, ResourceVersionInfo prevComponent, String comment) {
1032 auditComponent(responseFormat, modifier, component, actionEnum, resourceCommonInfo, prevComponent, null, comment, null, null);
1035 public void auditComponentAdmin(ResponseFormat responseFormat, User modifier, Component component, AuditingActionEnum actionEnum, ComponentTypeEnum typeEnum) {
1036 auditComponent(responseFormat, modifier, component, actionEnum, new ResourceCommonInfo(typeEnum.getValue()), ResourceVersionInfo.newBuilder().build());
1039 public void auditComponentAdmin(ResponseFormat responseFormat, User modifier, Component component, AuditingActionEnum actionEnum, ComponentTypeEnum typeEnum, String comment) {
1040 auditComponent(responseFormat, modifier, component, actionEnum, new ResourceCommonInfo(typeEnum.getValue()), ResourceVersionInfo.newBuilder().build(), null,
1041 comment, null, null);
1044 public void auditComponentAdmin(ResponseFormat responseFormat, User modifier, Component component, AuditingActionEnum actionEnum, ComponentTypeEnum typeEnum, ResourceVersionInfo prevComponent) {
1045 auditComponent(responseFormat, modifier, component, actionEnum, new ResourceCommonInfo(typeEnum.getValue()), prevComponent);
1048 public void auditComponent(ResponseFormat responseFormat, User modifier, Component component, AuditingActionEnum actionEnum, ResourceCommonInfo resourceCommonInfo, ResourceVersionInfo prevComponent) {
1049 auditComponent(responseFormat, modifier, component, actionEnum, resourceCommonInfo, prevComponent, null, null, null, null);
1052 public void auditComponent(ResponseFormat responseFormat, User modifier, AuditingActionEnum actionEnum, ResourceCommonInfo resourceCommonInfo, String comment) {
1053 auditComponent(responseFormat, modifier, null, actionEnum, resourceCommonInfo, ResourceVersionInfo.newBuilder().build(), null, comment, null, null);
1056 public void auditComponent(ResponseFormat responseFormat, User modifier, Component component, AuditingActionEnum actionEnum, ResourceCommonInfo resourceCommonInfo, ResourceVersionInfo prevComponent, ResourceVersionInfo currComponent) {
1057 auditComponent(responseFormat, modifier, component, actionEnum, resourceCommonInfo, prevComponent, currComponent, null, null, null);
1060 public void auditComponent(ResponseFormat responseFormat, User modifier, Component component, AuditingActionEnum actionEnum, ResourceCommonInfo resourceCommonInfo, ResourceVersionInfo prevComponent, ResourceVersionInfo currComponent,
1061 String comment, ArtifactDefinition artifactDefinition, String did) {
1062 if (actionEnum != null) {
1064 String currState = null;
1065 String invariantUUID = null;
1066 String currArtifactUid = null;
1067 String currVersion = null;
1068 String dcurrStatus = null;
1070 log.trace(INSIDE_AUDITING_FOR_AUDIT_ACTION, actionEnum);
1072 String message = getMessageString(responseFormat);
1073 int status = responseFormat.getStatus();
1074 String artifactData = buildAuditingArtifactData(artifactDefinition);
1076 if (component != null) {
1077 // fields that are filled during creation and might still be empty
1078 if (component.getLifecycleState() != null) {
1079 currState = component.getLifecycleState().name();
1081 uuid = component.getUUID();
1082 invariantUUID = component.getInvariantUUID();
1083 currVersion = component.getVersion();
1084 if (StringUtils.isEmpty(resourceCommonInfo.getResourceName())) {
1085 resourceCommonInfo.setResourceName(component.getComponentMetadataDefinition().getMetadataDataDefinition().getName());
1088 if (currComponent != null) {
1089 currArtifactUid = currComponent.getArtifactUuid();
1090 dcurrStatus = currComponent.getDistributionStatus();
1091 if (currState == null) { //probably it was not set
1092 currState = currComponent.getState();
1094 if (currVersion == null) { //probably it was not set
1095 currVersion = currComponent.getVersion();
1098 AuditEventFactory factory = AuditResourceEventFactoryManager.createResourceEventFactory(
1100 CommonAuditData.newBuilder()
1102 .description(message)
1103 .requestId(ThreadLocalsHolder.getUuid())
1104 .serviceInstanceId(uuid)
1106 resourceCommonInfo, prevComponent,
1107 ResourceVersionInfo.newBuilder()
1108 .artifactUuid(currArtifactUid)
1110 .version(currVersion)
1111 .distributionStatus(dcurrStatus)
1114 modifier, artifactData, comment, did, null);
1116 getAuditingManager().auditEvent(factory);
1120 public void auditDistributionEngine(AuditingActionEnum action, String environmentName, DistributionTopicData distributionTopicData, String status) {
1121 auditDistributionEngine(action, environmentName, distributionTopicData, null, null, status);
1125 public void auditDistributionEngine(AuditingActionEnum action, String environmentName, DistributionTopicData distributionTopicData, String role, String apiKey, String status) {
1126 AuditEventFactory factory = AuditDistributionEngineEventFactoryManager.createDistributionEngineEventFactory(action,
1127 environmentName, distributionTopicData, role, apiKey, status);
1128 getAuditingManager().auditEvent(factory);
1132 public void auditEnvironmentEngine(AuditingActionEnum actionEnum, String environmentID,
1133 String environmentType, String action, String environmentName, String tenantContext) {
1134 AuditEventFactory factory = new AuditEcompOpEnvEventFactory(actionEnum, environmentID, environmentName,
1135 environmentType, action, tenantContext);
1136 audit.startAuditFetchLog(PARTNER_NAME, DmaapConsumer.class.getName());
1137 audit.logEntry(LogLevel.INFO, Severity.OK, null,
1138 MarkerFactory.getMarker(ONAPLogConstants.Markers.ENTRY.getName()), environmentID);
1139 getAuditingManager().auditEvent(factory, audit);
1142 public void auditDistributionNotification(String serviceUUID, String resourceName, String resourceType, String currVersion, User modifier, String environmentName, String currState,
1143 String topicName, String distributionId, String description, String status, String workloadContext, String tenant) {
1145 AuditEventFactory factory = new AuditDistributionNotificationEventFactory(
1146 CommonAuditData.newBuilder()
1147 .serviceInstanceId(serviceUUID)
1149 .description(description)
1150 .requestId(ThreadLocalsHolder.getUuid())
1152 new ResourceCommonInfo(resourceName, resourceType),
1153 ResourceVersionInfo.newBuilder()
1155 .version(currVersion)
1157 distributionId, modifier, topicName,
1158 new OperationalEnvAuditData(environmentName, workloadContext, tenant));
1160 getAuditingManager().auditEvent(factory);
1163 public void auditAuthEvent(String url, String user, String authStatus, String realm) {
1164 AuditEventFactory factory = new AuditAuthRequestEventFactory(
1165 CommonAuditData.newBuilder()
1166 .requestId(ThreadLocalsHolder.getUuid())
1168 user, url, realm, authStatus);
1169 getAuditingManager().auditEvent(factory);
1172 public void auditDistributionStatusNotification(String distributionId, String consumerId, String topicName,
1173 String resourceUrl, String statusTime, String status,
1174 String errorReason, LoggerSdcAudit audit) {
1175 AuditEventFactory factory = new AuditDistributionStatusEventFactory(
1176 CommonAuditData.newBuilder()
1177 .description(errorReason)
1179 .requestId(distributionId)
1181 new DistributionData(consumerId, resourceUrl),
1182 distributionId, topicName, statusTime);
1184 getAuditingManager().auditEvent(factory, audit);
1187 public void auditGetUebCluster(String consumerId, String status, String description) {
1188 AuditEventFactory factory = new AuditGetUebClusterEventFactory(
1189 CommonAuditData.newBuilder()
1190 .description(description)
1192 .requestId(ThreadLocalsHolder.getUuid())
1196 getAuditingManager().auditEvent(factory);
1199 public void auditMissingInstanceIdAsDistributionEngineEvent(AuditingActionEnum actionEnum, String status) {
1200 AuditEventFactory factory = AuditDistributionEngineEventFactoryManager.createDistributionEngineEventFactory(
1202 DistributionTopicData.newBuilder()
1203 .build(), null, null, status);
1204 getAuditingManager().auditEvent(factory);
1208 public void auditRegisterOrUnRegisterEvent(AuditingActionEnum action, String consumerId, String apiPublicKey, String envName, String status, String distributionStatus, String notifTopicName, String statusTopicName) {
1209 String appliedStatus = !StringUtils.isEmpty(status) ? status : distributionStatus;
1211 AuditEventFactory factory = new AuditRegUnregDistributionEngineEventFactory(action,
1212 CommonAuditData.newBuilder()
1213 .requestId(ThreadLocalsHolder.getUuid())
1214 .status(appliedStatus)
1216 DistributionTopicData.newBuilder()
1217 .statusTopic(statusTopicName)
1218 .notificationTopic(notifTopicName)
1220 consumerId, apiPublicKey, envName);
1222 getAuditingManager().auditEvent(factory);
1225 public void auditServiceDistributionDeployed(String serviceName, String serviceVersion, String serviceUUID, String distributionId, String status, String desc, User modifier) {
1227 AuditEventFactory factory = new AuditDistributionDeployEventFactory(
1228 CommonAuditData.newBuilder()
1229 .requestId(ThreadLocalsHolder.getUuid())
1230 .serviceInstanceId(serviceUUID)
1234 new ResourceCommonInfo(serviceName, "Service"),
1239 getAuditingManager().auditEvent(factory);
1243 public void auditConsumerCredentialsEvent(AuditingActionEnum actionEnum, ConsumerDefinition consumer, ResponseFormat responseFormat, User modifier) {
1244 AuditEventFactory factory = new AuditConsumerEventFactory(actionEnum,
1245 CommonAuditData.newBuilder()
1246 .description(getMessageString(responseFormat))
1247 .status(responseFormat.getStatus())
1248 .requestId(ThreadLocalsHolder.getUuid())
1250 modifier, consumer);
1252 getAuditingManager().auditEvent(factory);
1255 public void auditGetUsersList(User user, String details, ResponseFormat responseFormat) {
1257 AuditEventFactory factory = new AuditGetUsersListEventFactory(
1258 CommonAuditData.newBuilder()
1259 .description(getMessageString(responseFormat))
1260 .status(responseFormat.getStatus())
1261 .requestId(ThreadLocalsHolder.getUuid())
1264 getAuditingManager().auditEvent(factory);
1267 public void auditAdminUserActionAndThrowException(AuditingActionEnum actionEnum, User modifier, User userBefore,
1268 User userAfter, ActionStatus status, String... params) {
1269 ResponseFormat responseFormat = getResponseFormat(status, params);
1270 auditAdminUserAction(actionEnum, modifier, userBefore, userAfter, responseFormat);
1271 throw new ByResponseFormatComponentException(responseFormat);
1274 public void auditAdminUserAction(AuditingActionEnum actionEnum, User modifier, User userBefore, User userAfter, ResponseFormat responseFormat) {
1276 AuditEventFactory factory = new AuditUserAdminEventFactory(actionEnum,
1277 CommonAuditData.newBuilder()
1278 .description(getMessageString(responseFormat))
1279 .status(responseFormat.getStatus())
1280 .requestId(ThreadLocalsHolder.getUuid())
1282 modifier, userBefore, userAfter);
1284 getAuditingManager().auditEvent(factory);
1287 public void auditUserAccess(User user, ActionStatus status, String... params) {
1288 auditUserAccess(user, getResponseFormat(status, params));
1291 public void auditUserAccess(User user, ResponseFormat responseFormat) {
1293 AuditEventFactory factory = new AuditUserAccessEventFactory(CommonAuditData.newBuilder()
1294 .description(getMessageString(responseFormat))
1295 .status(responseFormat.getStatus())
1296 .requestId(ThreadLocalsHolder.getUuid())
1300 getAuditingManager().auditEvent(factory);
1303 public void auditGetCategoryHierarchy(User user, String details, ResponseFormat responseFormat) {
1305 AuditEventFactory factory = new AuditGetCategoryHierarchyEventFactory(CommonAuditData.newBuilder()
1306 .description(getMessageString(responseFormat))
1307 .status(responseFormat.getStatus())
1308 .requestId(ThreadLocalsHolder.getUuid())
1312 getAuditingManager().auditEvent(factory);
1315 public ResponseFormat getResponseFormatByComponent(ActionStatus actionStatus, Component component, ComponentTypeEnum type) {
1316 if (component == null) {
1317 return getResponseFormat(actionStatus);
1319 ResponseFormat responseFormat;
1321 switch (actionStatus) {
1322 case COMPONENT_VERSION_ALREADY_EXIST:
1323 responseFormat = getResponseFormat(ActionStatus.COMPONENT_VERSION_ALREADY_EXIST, type.getValue(), component.getVersion());
1325 case RESOURCE_NOT_FOUND:
1326 responseFormat = getResponseFormat(ActionStatus.RESOURCE_NOT_FOUND, component.getComponentMetadataDefinition().getMetadataDataDefinition().getName());
1328 case COMPONENT_NAME_ALREADY_EXIST:
1329 responseFormat = getResponseFormat(ActionStatus.COMPONENT_NAME_ALREADY_EXIST, type.getValue(), component.getComponentMetadataDefinition().getMetadataDataDefinition().getName());
1331 case COMPONENT_IN_USE:
1332 responseFormat = getResponseFormat(ActionStatus.COMPONENT_IN_USE, type.name().toLowerCase(), component.getUniqueId());
1334 case SERVICE_DEPLOYMENT_ARTIFACT_NOT_FOUND:
1335 responseFormat = getResponseFormat(ActionStatus.SERVICE_DEPLOYMENT_ARTIFACT_NOT_FOUND, component.getComponentMetadataDefinition().getMetadataDataDefinition().getName());
1338 responseFormat = getResponseFormat(actionStatus);
1341 return responseFormat;
1344 public boolean validateStringNotEmpty(String value) {
1345 return value != null && !value.trim().isEmpty();
1348 public ActionStatus convertFromStorageResponseForAdditionalInformation(StorageOperationStatus storageResponse) {
1349 ActionStatus responseEnum;
1351 switch (storageResponse) {
1353 responseEnum = ActionStatus.OK;
1355 case ENTITY_ALREADY_EXISTS:
1356 responseEnum = ActionStatus.COMPONENT_NAME_ALREADY_EXIST;
1359 responseEnum = ActionStatus.ADDITIONAL_INFORMATION_NOT_FOUND;
1362 responseEnum = ActionStatus.GENERAL_ERROR;
1365 log.debug(CONVERT_STORAGE_RESPONSE_TO_ACTION_RESPONSE, storageResponse, responseEnum);
1366 return responseEnum;
1369 public ActionStatus convertFromResultStatusEnum(ResultStatusEnum resultStatus, JsonPresentationFields elementType) {
1370 ActionStatus responseEnum = ActionStatus.GENERAL_ERROR;
1371 switch (resultStatus) {
1373 responseEnum = ActionStatus.OK;
1375 case ELEMENT_NOT_FOUND:
1376 if(elementType!= null && elementType == JsonPresentationFields.PROPERTY){
1377 responseEnum = ActionStatus.PROPERTY_NOT_FOUND;
1380 case INVALID_PROPERTY_DEFAULT_VALUE:
1381 case INVALID_PROPERTY_TYPE:
1382 case INVALID_PROPERTY_VALUE:
1383 case INVALID_PROPERTY_NAME:
1384 case MISSING_ENTRY_SCHEMA_TYPE:
1385 responseEnum = ActionStatus.INVALID_PROPERTY;
1388 responseEnum = ActionStatus.GENERAL_ERROR;
1391 return responseEnum;
1394 public ResponseFormat getResponseFormatAdditionalProperty(ActionStatus actionStatus, AdditionalInfoParameterInfo additionalInfoParameterInfo, NodeTypeEnum nodeType, AdditionalInformationEnum labelOrValue) {
1396 if (additionalInfoParameterInfo == null) {
1397 additionalInfoParameterInfo = new AdditionalInfoParameterInfo();
1399 if (labelOrValue == null) {
1400 labelOrValue = AdditionalInformationEnum.None;
1403 switch (actionStatus) {
1404 case COMPONENT_NAME_ALREADY_EXIST:
1405 return getResponseFormat(actionStatus, "Additional parameter", additionalInfoParameterInfo.getKey());
1406 case ADDITIONAL_INFORMATION_EXCEEDS_LIMIT:
1407 return getResponseFormat(actionStatus, labelOrValue.name().toLowerCase(), ValidationUtils.ADDITIONAL_INFORMATION_KEY_MAX_LENGTH.toString());
1408 case ADDITIONAL_INFORMATION_MAX_NUMBER_REACHED:
1409 return getResponseFormat(actionStatus, nodeType.name().toLowerCase());
1410 case ADDITIONAL_INFORMATION_EMPTY_STRING_NOT_ALLOWED:
1411 return getResponseFormat(actionStatus);
1412 case ADDITIONAL_INFORMATION_KEY_NOT_ALLOWED_CHARACTERS:
1413 return getResponseFormat(actionStatus);
1414 case ADDITIONAL_INFORMATION_VALUE_NOT_ALLOWED_CHARACTERS:
1415 return getResponseFormat(actionStatus);
1416 case ADDITIONAL_INFORMATION_NOT_FOUND:
1417 return getResponseFormat(actionStatus);
1419 return getResponseFormat(actionStatus);
1424 public ResponseFormat getResponseFormatAdditionalProperty(ActionStatus actionStatus) {
1425 return getResponseFormatAdditionalProperty(actionStatus, null, null, null);
1428 public ActionStatus convertFromStorageResponseForConsumer(StorageOperationStatus storageResponse) {
1429 ActionStatus responseEnum;
1431 switch (storageResponse) {
1433 responseEnum = ActionStatus.OK;
1435 case CONNECTION_FAILURE:
1437 responseEnum = ActionStatus.GENERAL_ERROR;
1440 responseEnum = ActionStatus.INVALID_CONTENT;
1442 case ENTITY_ALREADY_EXISTS:
1443 responseEnum = ActionStatus.CONSUMER_ALREADY_EXISTS;
1445 case SCHEMA_VIOLATION:
1446 responseEnum = ActionStatus.CONSUMER_ALREADY_EXISTS;
1449 responseEnum = ActionStatus.ECOMP_USER_NOT_FOUND;
1452 responseEnum = ActionStatus.GENERAL_ERROR;
1455 log.debug(CONVERT_STORAGE_RESPONSE_TO_ACTION_RESPONSE, storageResponse, responseEnum);
1456 return responseEnum;
1459 public ActionStatus convertFromStorageResponseForGroupType(StorageOperationStatus storageResponse) {
1460 ActionStatus responseEnum;
1462 switch (storageResponse) {
1464 responseEnum = ActionStatus.OK;
1466 case CONNECTION_FAILURE:
1468 responseEnum = ActionStatus.GENERAL_ERROR;
1471 responseEnum = ActionStatus.INVALID_CONTENT;
1473 case ENTITY_ALREADY_EXISTS:
1474 responseEnum = ActionStatus.GROUP_TYPE_ALREADY_EXIST;
1476 case SCHEMA_VIOLATION:
1477 responseEnum = ActionStatus.GROUP_TYPE_ALREADY_EXIST;
1480 responseEnum = ActionStatus.GENERAL_ERROR;
1483 log.debug(CONVERT_STORAGE_RESPONSE_TO_ACTION_RESPONSE, storageResponse, responseEnum);
1484 return responseEnum;
1487 public ActionStatus convertFromStorageResponseForDataType(StorageOperationStatus storageResponse) {
1488 ActionStatus responseEnum;
1490 switch (storageResponse) {
1492 responseEnum = ActionStatus.OK;
1494 case CONNECTION_FAILURE:
1496 responseEnum = ActionStatus.GENERAL_ERROR;
1499 responseEnum = ActionStatus.INVALID_CONTENT;
1501 case ENTITY_ALREADY_EXISTS:
1502 responseEnum = ActionStatus.DATA_TYPE_ALREADY_EXIST;
1504 case SCHEMA_VIOLATION:
1505 responseEnum = ActionStatus.DATA_TYPE_ALREADY_EXIST;
1507 case CANNOT_UPDATE_EXISTING_ENTITY:
1508 responseEnum = ActionStatus.DATA_TYPE_CANNOT_BE_UPDATED_BAD_REQUEST;
1511 responseEnum = ActionStatus.GENERAL_ERROR;
1514 log.debug(CONVERT_STORAGE_RESPONSE_TO_ACTION_RESPONSE, storageResponse, responseEnum);
1515 return responseEnum;
1518 public ResponseFormat getResponseFormatByGroupType(ActionStatus actionStatus, GroupTypeDefinition groupType) {
1519 if (groupType == null) {
1520 return getResponseFormat(actionStatus);
1522 ResponseFormat responseFormat;
1524 switch (actionStatus) {
1525 case GROUP_MEMBER_EMPTY:
1526 case GROUP_TYPE_ALREADY_EXIST:
1527 responseFormat = getResponseFormat(actionStatus, groupType.getType());
1530 responseFormat = getResponseFormat(actionStatus);
1533 return responseFormat;
1537 public ResponseFormat getResponseFormatByPolicyType(ActionStatus actionStatus, PolicyTypeDefinition policyType) {
1538 if (policyType == null) {
1539 return getResponseFormat(actionStatus);
1542 ResponseFormat responseFormat;
1543 if (actionStatus == ActionStatus.POLICY_TYPE_ALREADY_EXIST) {
1544 responseFormat = getResponseFormat(actionStatus, policyType.getType());
1547 responseFormat = getResponseFormat(actionStatus);
1549 return responseFormat;
1553 public ResponseFormat getResponseFormatByDataType(ActionStatus actionStatus, DataTypeDefinition dataType, List<String> properties) {
1554 if (dataType == null) {
1555 return getResponseFormat(actionStatus);
1557 ResponseFormat responseFormat;
1559 switch (actionStatus) {
1560 case DATA_TYPE_ALREADY_EXIST:
1561 responseFormat = getResponseFormat(actionStatus, dataType.getName());
1563 case DATA_TYPE_NOR_PROPERTIES_NEITHER_DERIVED_FROM:
1564 responseFormat = getResponseFormat(actionStatus, dataType.getName());
1566 case DATA_TYPE_PROPERTIES_CANNOT_BE_EMPTY:
1567 responseFormat = getResponseFormat(actionStatus, dataType.getName());
1569 case DATA_TYPE_PROPERTY_ALREADY_DEFINED_IN_ANCESTOR:
1570 responseFormat = getResponseFormat(actionStatus, dataType.getName(), properties == null ? "" : String.valueOf(properties));
1572 case DATA_TYPE_DERIVED_IS_MISSING:
1573 responseFormat = getResponseFormat(actionStatus, dataType.getDerivedFromName());
1575 case DATA_TYPE_DUPLICATE_PROPERTY:
1576 responseFormat = getResponseFormat(actionStatus, dataType.getName());
1578 case DATA_TYPE_PROEPRTY_CANNOT_HAVE_SAME_TYPE_OF_DATA_TYPE:
1579 responseFormat = getResponseFormat(actionStatus, dataType.getName(), properties == null ? "" : String.valueOf(properties));
1581 case DATA_TYPE_CANNOT_HAVE_PROPERTIES:
1582 responseFormat = getResponseFormat(actionStatus, dataType.getName());
1584 case DATA_TYPE_CANNOT_BE_UPDATED_BAD_REQUEST:
1585 responseFormat = getResponseFormat(actionStatus, dataType.getName());
1589 responseFormat = getResponseFormat(actionStatus);
1592 return responseFormat;
1595 public StorageOperationStatus convertToStorageOperationStatus(CassandraOperationStatus cassandraStatus) {
1596 StorageOperationStatus result;
1597 switch (cassandraStatus) {
1599 result = StorageOperationStatus.OK;
1602 result = StorageOperationStatus.NOT_FOUND;
1604 case CLUSTER_NOT_CONNECTED:
1605 case KEYSPACE_NOT_CONNECTED:
1606 result = StorageOperationStatus.CONNECTION_FAILURE;
1609 result = StorageOperationStatus.GENERAL_ERROR;
1615 public ResponseFormat getResponseFormat(ComponentException exception) {
1616 return exception instanceof ByResponseFormatComponentException ?
1617 getResponseFormat((ByResponseFormatComponentException) exception):
1618 getResponseFormat((ByActionStatusComponentException) exception);
1621 public ResponseFormat getResponseFormat(ByResponseFormatComponentException exception) {
1622 return exception.getResponseFormat();
1625 public ResponseFormat getResponseFormat(ByActionStatusComponentException exception) {
1626 return getResponseFormat(exception.getActionStatus(), exception.getParams());
1629 public ActionStatus convertFromStorageResponseForRelationshipType(
1630 StorageOperationStatus storageResponse) {
1631 ActionStatus responseEnum;
1633 switch (storageResponse) {
1635 responseEnum = ActionStatus.OK;
1637 case CONNECTION_FAILURE:
1639 responseEnum = ActionStatus.GENERAL_ERROR;
1642 responseEnum = ActionStatus.INVALID_CONTENT;
1644 case ENTITY_ALREADY_EXISTS:
1645 responseEnum = ActionStatus.RELATIONSHIP_TYPE_ALREADY_EXIST;
1647 case SCHEMA_VIOLATION:
1648 responseEnum = ActionStatus.RELATIONSHIP_TYPE_ALREADY_EXIST;
1651 responseEnum = ActionStatus.GENERAL_ERROR;
1654 log.debug(CONVERT_STORAGE_RESPONSE_TO_ACTION_RESPONSE, storageResponse, responseEnum);
1655 return responseEnum;
1658 public ResponseFormat getResponseFormat(StorageException exception) {
1659 ActionStatus status = convertFromStorageResponse(exception.getStorageOperationStatus());
1660 return getResponseFormat(status, exception.getParams());
1664 public List<UiLeftPaletteComponent> convertComponentToUiLeftPaletteComponentObject(List<Component> components) {
1665 List<UiLeftPaletteComponent> uiLeftPaletteComponents = new ArrayList<>();
1666 components.forEach(c-> uiLeftPaletteComponents.add(new UiLeftPaletteComponent(c)));
1667 return uiLeftPaletteComponents;
1670 private static Set<String> getNodesFiltersToBeDeleted(final Component component,
1671 final String componentInstanceName) {
1672 return component.getComponentInstances().stream()
1673 .filter(ci -> isNodeFilterUsingChangedCi(ci, componentInstanceName))
1674 .map(ComponentInstance::getName).collect(Collectors.toSet());
1677 public static Set<String> getNodesFiltersToBeDeleted(final Component component,
1678 final ComponentInstance componentInstance) {
1679 return getNodesFiltersToBeDeleted(component, componentInstance.getName());
1682 private static boolean isNodeFilterUsingChangedCi(final ComponentInstance componentInstance,
1683 final String componentInstanceName) {
1684 if (CollectionUtils.isEmpty(componentInstance.getDirectives())) {
1687 if (componentInstance.getNodeFilter() == null || componentInstance.getNodeFilter().getProperties() == null
1688 || componentInstance.getNodeFilter().getProperties().getListToscaDataDefinition() == null) {
1691 return componentInstance.getNodeFilter().getProperties().getListToscaDataDefinition().stream()
1692 .anyMatch(property -> isPropertyConstraintChangedByCi(property, componentInstanceName));
1695 private static boolean isPropertyConstraintChangedByCi(
1696 final RequirementNodeFilterPropertyDataDefinition requirementNodeFilterPropertyDataDefinition,
1697 final String componentInstanceName) {
1698 final List<String> constraints = requirementNodeFilterPropertyDataDefinition.getConstraints();
1699 if (constraints == null) {
1702 return constraints.stream().anyMatch(constraint -> isConstraintChangedByCi(constraint, componentInstanceName));
1705 private static boolean isConstraintChangedByCi(final String constraint,
1706 final String componentInstanceName) {
1707 final UIConstraint uiConstraint = new ConstraintConvertor().convert(constraint);
1708 if (uiConstraint == null || uiConstraint.getSourceType() == null) {
1711 if (!uiConstraint.getSourceType().equals(ConstraintConvertor.PROPERTY_CONSTRAINT)) {
1714 return uiConstraint.getSourceName().equals(componentInstanceName);
1717 public F<StorageOperationStatus, ResponseFormat> toResponseFormat() {
1718 return sos -> getResponseFormat(convertFromStorageResponse(sos));
1722 public Optional<UIConstraint> parseToConstraint(final String componentJson,
1724 final ComponentTypeEnum componentTypeEnum) {
1725 final Either<UIConstraint, ResponseFormat> uiConstraintResponseFormatEither =
1726 convertJsonToObjectUsingObjectMapper(componentJson, user, UIConstraint.class,
1727 AuditingActionEnum.CREATE_RESOURCE, componentTypeEnum);
1728 if (uiConstraintResponseFormatEither.isRight()) {
1729 return Optional.empty();
1731 return Optional.of(uiConstraintResponseFormatEither.left().value());
1734 private Either<List, ResponseFormat> parseToConstraints(final String componentJson,
1736 final ComponentTypeEnum componentTypeEnum) {
1737 return convertJsonToObjectUsingObjectMapper(componentJson, user, List.class, AuditingActionEnum.CREATE_RESOURCE,
1741 public List<UIConstraint> validateAndParseConstraint(final ComponentTypeEnum componentTypeEnum,
1742 final String constraintData,
1743 final User userModifier) {
1745 final String FAILED_TO_PARSE_CONSTRAINT_DATA = "Failed to Parse Constraint Data {}";
1746 final Either<List, ResponseFormat> convertResponse = parseToConstraints(constraintData, userModifier, componentTypeEnum);
1747 if (convertResponse.isRight()) {
1748 log.error(EcompLoggerErrorCode.DATA_ERROR, FAILED_TO_PARSE_CONSTRAINT_DATA, constraintData,
1749 convertResponse.right().value());
1750 return Collections.emptyList();
1752 final List<Map<String, String>> uiConstraintsMaps = (List<Map<String, String>>) convertResponse.left().value();
1753 if (uiConstraintsMaps == null) {
1754 log.error(EcompLoggerErrorCode.DATA_ERROR, FAILED_TO_PARSE_CONSTRAINT_DATA, constraintData);
1755 return Collections.emptyList();
1758 return uiConstraintsMaps.stream().map(dataMap -> new com.fasterxml.jackson.databind.ObjectMapper()
1759 .convertValue(dataMap, UIConstraint.class)).collect(Collectors.toList());