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.components.impl;
25 import fj.data.Either;
26 import io.vavr.Function3;
27 import java.util.Optional;
28 import java.util.function.BiFunction;
29 import java.util.function.BooleanSupplier;
30 import org.apache.commons.collections.CollectionUtils;
31 import org.apache.commons.lang3.StringUtils;
32 import org.apache.commons.lang3.tuple.ImmutablePair;
33 import org.openecomp.sdc.be.catalog.enums.ChangeTypeEnum;
34 import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentException;
35 import org.openecomp.sdc.be.components.impl.exceptions.ByResponseFormatComponentException;
36 import org.openecomp.sdc.be.components.impl.exceptions.ComponentException;
37 import org.openecomp.sdc.be.components.impl.generic.GenericTypeBusinessLogic;
38 import org.openecomp.sdc.be.components.validation.component.ComponentContactIdValidator;
39 import org.openecomp.sdc.be.components.validation.component.ComponentDescriptionValidator;
40 import org.openecomp.sdc.be.components.validation.component.ComponentIconValidator;
41 import org.openecomp.sdc.be.components.validation.component.ComponentNameValidator;
42 import org.openecomp.sdc.be.components.validation.component.ComponentProjectCodeValidator;
43 import org.openecomp.sdc.be.components.validation.component.ComponentTagsValidator;
44 import org.openecomp.sdc.be.components.validation.component.ComponentValidator;
45 import org.openecomp.sdc.be.config.BeEcompErrorManager;
46 import org.openecomp.sdc.be.config.ConfigurationManager;
47 import org.openecomp.sdc.be.dao.api.ActionStatus;
48 import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
49 import org.openecomp.sdc.be.dao.utils.MapUtil;
50 import org.openecomp.sdc.be.datamodel.api.HighestFilterEnum;
51 import org.openecomp.sdc.be.datatypes.components.ServiceMetadataDataDefinition;
52 import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
53 import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
54 import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
55 import org.openecomp.sdc.be.datatypes.enums.FilterKeyEnum;
56 import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
57 import org.openecomp.sdc.be.datatypes.enums.OriginTypeEnum;
58 import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
59 import org.openecomp.sdc.be.facade.operations.CatalogOperation;
60 import org.openecomp.sdc.be.impl.ComponentsUtils;
61 import org.openecomp.sdc.be.model.ArtifactDefinition;
62 import org.openecomp.sdc.be.model.CapReqDef;
63 import org.openecomp.sdc.be.model.Component;
64 import org.openecomp.sdc.be.model.ComponentInstance;
65 import org.openecomp.sdc.be.model.ComponentInstanceInput;
66 import org.openecomp.sdc.be.model.ComponentInstanceProperty;
67 import org.openecomp.sdc.be.model.ComponentParametersView;
68 import org.openecomp.sdc.be.model.DataTypeDefinition;
69 import org.openecomp.sdc.be.model.GroupDefinition;
70 import org.openecomp.sdc.be.model.IComponentInstanceConnectedElement;
71 import org.openecomp.sdc.be.model.InputDefinition;
72 import org.openecomp.sdc.be.model.LifecycleStateEnum;
73 import org.openecomp.sdc.be.model.Operation;
74 import org.openecomp.sdc.be.model.PropertyDefinition;
75 import org.openecomp.sdc.be.model.Resource;
76 import org.openecomp.sdc.be.model.User;
77 import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ArtifactsOperations;
78 import org.openecomp.sdc.be.model.jsonjanusgraph.operations.InterfaceOperation;
79 import org.openecomp.sdc.be.model.operations.api.IElementOperation;
80 import org.openecomp.sdc.be.model.operations.api.IGroupInstanceOperation;
81 import org.openecomp.sdc.be.model.operations.api.IGroupOperation;
82 import org.openecomp.sdc.be.model.operations.api.IGroupTypeOperation;
83 import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
84 import org.openecomp.sdc.be.model.operations.impl.InterfaceLifecycleOperation;
85 import org.openecomp.sdc.be.model.tosca.ToscaPropertyType;
86 import org.openecomp.sdc.be.resources.data.ComponentMetadataData;
87 import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum;
88 import org.openecomp.sdc.be.resources.data.auditing.model.ResourceCommonInfo;
89 import org.openecomp.sdc.be.resources.data.auditing.model.ResourceVersionInfo;
90 import org.openecomp.sdc.be.ui.model.UiComponentDataTransfer;
91 import org.openecomp.sdc.be.user.Role;
92 import org.openecomp.sdc.be.utils.CommonBeUtils;
93 import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum;
94 import org.openecomp.sdc.common.api.ArtifactTypeEnum;
95 import org.openecomp.sdc.common.log.wrappers.Logger;
96 import org.openecomp.sdc.common.util.ValidationUtils;
97 import org.openecomp.sdc.exception.ResponseFormat;
98 import org.springframework.beans.factory.annotation.Autowired;
100 import java.util.ArrayList;
101 import java.util.HashMap;
102 import java.util.List;
103 import java.util.Map;
104 import java.util.Map.Entry;
105 import java.util.stream.Collectors;
107 public abstract class ComponentBusinessLogic extends BaseBusinessLogic {
109 protected ArtifactsBusinessLogic artifactsBusinessLogic;
111 protected final GroupBusinessLogic groupBusinessLogic;
113 protected GenericTypeBusinessLogic genericTypeBusinessLogic;
115 protected ComponentDescriptionValidator componentDescriptionValidator;
116 protected ComponentProjectCodeValidator componentProjectCodeValidator;
118 protected CatalogOperation catalogOperations;
119 protected ComponentIconValidator componentIconValidator;
121 protected ComponentValidator componentValidator;
122 protected ComponentTagsValidator componentTagsValidator;
123 protected ComponentNameValidator componentNameValidator;
124 protected ComponentContactIdValidator componentContactIdValidator;
126 public ComponentBusinessLogic(IElementOperation elementDao,
127 IGroupOperation groupOperation,
128 IGroupInstanceOperation groupInstanceOperation,
129 IGroupTypeOperation groupTypeOperation,
130 GroupBusinessLogic groupBusinessLogic,
131 InterfaceOperation interfaceOperation,
132 InterfaceLifecycleOperation interfaceLifecycleTypeOperation,
133 ArtifactsBusinessLogic artifactsBusinessLogic,
134 ArtifactsOperations artifactToscaOperation,
135 ComponentContactIdValidator componentContactIdValidator,
136 ComponentNameValidator componentNameValidator,
137 ComponentTagsValidator componentTagsValidator,
138 ComponentValidator componentValidator,
139 ComponentIconValidator componentIconValidator,
140 ComponentProjectCodeValidator componentProjectCodeValidator,
141 ComponentDescriptionValidator componentDescriptionValidator){
143 super(elementDao, groupOperation, groupInstanceOperation, groupTypeOperation,
144 interfaceOperation, interfaceLifecycleTypeOperation, artifactToscaOperation);
145 this.artifactsBusinessLogic = artifactsBusinessLogic;
146 this.groupBusinessLogic = groupBusinessLogic;
147 this.componentContactIdValidator = componentContactIdValidator;
148 this.componentNameValidator = componentNameValidator;
149 this.componentTagsValidator = componentTagsValidator;
150 this.componentValidator = componentValidator;
151 this.componentIconValidator = componentIconValidator;
152 this.componentProjectCodeValidator = componentProjectCodeValidator;
153 this.componentDescriptionValidator = componentDescriptionValidator;
156 public void setComponentDescriptionValidator(ComponentDescriptionValidator componentDescriptionValidator) {
157 this.componentDescriptionValidator = componentDescriptionValidator;
160 public void setComponentProjectCodeValidator(ComponentProjectCodeValidator componentProjectCodeValidator) {
161 this.componentProjectCodeValidator = componentProjectCodeValidator;
164 public void setComponentIconValidator(ComponentIconValidator componentIconValidator) {
165 this.componentIconValidator = componentIconValidator;
168 public void setComponentContactIdValidator(ComponentContactIdValidator componentContactIdValidator) {
169 this.componentContactIdValidator = componentContactIdValidator;
172 public void setComponentTagsValidator(ComponentTagsValidator componentTagsValidator) {
173 this.componentTagsValidator = componentTagsValidator;
176 public void setComponentNameValidator(ComponentNameValidator componentNameValidator) {
177 this.componentNameValidator = componentNameValidator;
182 public void setGenericTypeBusinessLogic(GenericTypeBusinessLogic genericTypeBusinessLogic) {
183 this.genericTypeBusinessLogic = genericTypeBusinessLogic;
186 private static final Logger log = Logger.getLogger(ComponentBusinessLogic.class.getName());
188 private static final String TAG_FIELD_LABEL = "tag";
190 public abstract Either<List<String>, ResponseFormat> deleteMarkedComponents();
192 public abstract ComponentInstanceBusinessLogic getComponentInstanceBL();
194 public abstract Either<List<ComponentInstance>, ResponseFormat> getComponentInstancesFilteredByPropertiesAndInputs(String componentId, String userId);
199 * @param dataParamsToReturn
202 public abstract Either<UiComponentDataTransfer, ResponseFormat> getUiComponentDataTransferByComponentId(String componentId, List<String> dataParamsToReturn);
204 User validateUser(User user, String ecompErrorContext, Component component, AuditingActionEnum auditAction, boolean inTransaction) {
206 ResponseFormat responseFormat;
208 validateUserNotEmpty(user, ecompErrorContext);
209 validatedUser = validateUserExists(user);
210 } catch(ByActionStatusComponentException e){
211 if(e.getActionStatus() == ActionStatus.MISSING_INFORMATION){
212 user.setUserId("UNKNOWN");
214 responseFormat = componentsUtils.getResponseFormat(e.getActionStatus(), e.getParams());
215 componentsUtils.auditComponentAdmin(responseFormat, user, component, auditAction, component.getComponentType());
217 } catch(ByResponseFormatComponentException e){
218 responseFormat = e.getResponseFormat();
219 componentsUtils.auditComponentAdmin(responseFormat, user, component, auditAction, component.getComponentType());
222 return validatedUser;
225 protected void validateUserRole(User user, Component component, List<Role> roles, AuditingActionEnum auditAction, String comment) {
226 if (roles != null && roles.isEmpty()) {
227 roles.add(Role.ADMIN);
228 roles.add(Role.DESIGNER);
231 validateUserRole(user, roles);
232 }catch (ByActionStatusComponentException e) {
233 ResponseFormat responseFormat = componentsUtils.getResponseFormat(e.getActionStatus(), e.getParams());
234 handleComponentException(component, comment, responseFormat, user, auditAction);
236 }catch (ByResponseFormatComponentException e) {
237 ResponseFormat responseFormat = e.getResponseFormat();
238 handleComponentException(component, comment, responseFormat, user, auditAction);
243 private void handleComponentException(Component component, String comment, ResponseFormat responseFormat,
244 User user, AuditingActionEnum auditAction){
245 String commentStr = null;
246 String distrStatus = null;
247 ComponentTypeEnum componentType = component.getComponentType();
248 if (componentType == ComponentTypeEnum.SERVICE) {
249 distrStatus = ((ServiceMetadataDataDefinition) component.getComponentMetadataDefinition().getMetadataDataDefinition()).getDistributionStatus();
250 commentStr = comment;
252 componentsUtils.auditComponent(responseFormat, user, component, auditAction, new ResourceCommonInfo(componentType.getValue()),
253 ResourceVersionInfo.newBuilder().distributionStatus(distrStatus).build(),
254 ResourceVersionInfo.newBuilder().distributionStatus(distrStatus).build(),
255 commentStr, null, null);
258 public Either<Boolean, ResponseFormat> validateConformanceLevel(String componentUuid, ComponentTypeEnum componentTypeEnum, String userId) {
259 log.trace("validate conformance level");
261 if (componentTypeEnum != ComponentTypeEnum.SERVICE) {
262 log.error("conformance level validation for non service component, id {}", componentUuid);
263 ResponseFormat errorResponse = componentsUtils.getResponseFormat(ActionStatus.INVALID_CONTENT);
264 return Either.right(errorResponse);
267 validateUserExists(userId);
269 Either<ComponentMetadataData, StorageOperationStatus> eitherComponent = toscaOperationFacade.getLatestComponentMetadataByUuid(componentUuid, JsonParseFlagEnum.ParseMetadata, null);
270 if (eitherComponent.isRight()) {
271 log.error("can't validate conformance level, component not found, uuid {}", componentUuid);
272 BeEcompErrorManager.getInstance().logBeComponentMissingError("validateConformanceLevel", componentTypeEnum.getValue(), componentUuid);
274 StorageOperationStatus status = eitherComponent.right().value();
275 ActionStatus actionStatus = componentsUtils.convertFromStorageResponse(status, componentTypeEnum);
276 ResponseFormat responseFormat = componentsUtils.getResponseFormat(actionStatus);
277 return Either.right(responseFormat);
280 String componentConformanceLevel = eitherComponent.left().value().getMetadataDataDefinition().getConformanceLevel();
281 if (StringUtils.isBlank(componentConformanceLevel)) {
282 log.error("component conformance level property is null or empty, uuid {}", componentUuid);
283 ResponseFormat errorResponse = componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR);
284 return Either.right(errorResponse);
287 String configConformanceLevel = ConfigurationManager.getConfigurationManager().getConfiguration().getMinToscaConformanceLevel();
288 Boolean result = true;
289 if (CommonBeUtils.conformanceLevelCompare(componentConformanceLevel, configConformanceLevel) < 0) {
290 log.error("invalid asset conformance level, uuid {}, asset conformanceLevel {}, config conformanceLevel {}", componentUuid, componentConformanceLevel, configConformanceLevel);
293 log.trace("conformance level validation finished");
295 return Either.left(result);
298 protected void validateIcon(User user, Component component, AuditingActionEnum actionEnum) {
299 log.debug("validate Icon");
300 ComponentTypeEnum type = component.getComponentType();
301 String icon = component.getIcon();
302 if (!ValidationUtils.validateStringNotEmpty(icon)) {
303 log.info("icon is missing.");
304 ResponseFormat errorResponse = componentsUtils.getResponseFormat(ActionStatus.COMPONENT_MISSING_ICON, type.getValue());
305 componentsUtils.auditComponentAdmin(errorResponse, user, component, actionEnum, type);
306 throw new ComponentException(ActionStatus.COMPONENT_MISSING_ICON, type.getValue());
309 validateIcon(icon, type);
310 } catch(ComponentException e){
311 ResponseFormat responseFormat = e.getResponseFormat() != null ? e.getResponseFormat()
312 : componentsUtils.getResponseFormat(e.getActionStatus(), e.getParams());
313 componentsUtils.auditComponentAdmin(responseFormat, user, component, actionEnum, type);
318 private void validateIcon(String icon, ComponentTypeEnum type) {
320 if (!ValidationUtils.validateIconLength(icon)) {
321 log.debug("icon exceeds max length");
322 throw new ComponentException(ActionStatus.COMPONENT_ICON_EXCEEDS_LIMIT, type.getValue(), "" + ValidationUtils.ICON_MAX_LENGTH);
325 if (!ValidationUtils.validateIcon(icon)) {
326 log.info("icon is invalid.");
327 throw new ComponentException(ActionStatus.COMPONENT_INVALID_ICON, type.getValue());
332 protected void checkComponentFieldsForOverrideAttempt(Component component) {
333 if (component.getLifecycleState() != null) {
334 log.info("LifecycleState cannot be defined by user. This field will be overridden by the application");
336 if (component.getVersion() != null) {
337 log.info("Version cannot be defined by user. This field will be overridden by the application");
339 if (component.getCreatorUserId() != null || component.getCreatorFullName() != null) {
340 log.info("Creator cannot be defined by user. This field will be overridden by the application");
342 if (component.getLastUpdaterUserId() != null || component.getLastUpdaterFullName() != null) {
343 log.info("Last Updater cannot be defined by user. This field will be overridden by the application");
345 if (component.getCreationDate() != null) {
346 log.info("Creation Date cannot be defined by user. This field will be overridden by the application");
348 if (component.isHighestVersion() != null) {
349 log.info("Is Highest Version cannot be defined by user. This field will be overridden by the application");
351 if (component.getUUID() != null) {
352 log.info("UUID cannot be defined by user. This field will be overridden by the application");
354 if (component.getLastUpdateDate() != null) {
355 log.info("Last Update Date cannot be defined by user. This field will be overridden by the application");
357 if (component.getUniqueId() != null) {
358 log.info("uid cannot be defined by user. This field will be overridden by the application.");
359 component.setUniqueId(null);
361 if (component.getInvariantUUID() != null) {
362 log.info("Invariant UUID cannot be defined by user. This field will be overridden by the application.");
366 protected void validateComponentFieldsBeforeCreate(User user, Component component, AuditingActionEnum actionEnum) {
367 // validate component name uniqueness
368 log.debug("validate component name ");
369 componentNameValidator.validateAndCorrectField(user, component, actionEnum);
370 // validate description
371 log.debug("validate description");
372 componentDescriptionValidator.validateAndCorrectField(user, component, actionEnum);
374 log.debug("validate tags");
375 componentTagsValidator.validateAndCorrectField(user, component, actionEnum);
376 // validate contact info
377 log.debug("validate contact info");
378 componentContactIdValidator.validateAndCorrectField(user, component, actionEnum);
380 log.debug("validate icon");
381 validateIcon(user, component, actionEnum);
384 public CapReqDef getRequirementsAndCapabilities(String componentId, ComponentTypeEnum componentTypeEnum, String userId) {
386 validateUserExists(userId);
387 ComponentParametersView filter = new ComponentParametersView(true);
388 filter.setIgnoreCapabilities(false);
389 filter.setIgnoreRequirements(false);
390 filter.setIgnoreComponentInstances(false);
393 Component component = validateComponentExists(componentId, componentTypeEnum, filter);
394 return new CapReqDef(component.getRequirements(), component.getCapabilities());
395 }catch (ComponentException e){
396 BeEcompErrorManager.getInstance().logBeComponentMissingError("getRequirementsAndCapabilities", componentTypeEnum.getValue(), componentId);
397 throwComponentException(e.getResponseFormat());
402 public Either<List<Component>, ResponseFormat> getLatestVersionNotAbstractComponents(boolean isAbstractAbstract, ComponentTypeEnum componentTypeEnum, String internalComponentType, List<String> componentUids,
405 validateUserExists(userId);
406 List<Component> result = new ArrayList<>();
407 List<String> componentsUidToFetch = new ArrayList<>();
408 componentsUidToFetch.addAll(componentUids);
409 if (!componentsUidToFetch.isEmpty()) {
410 log.debug("Number of Components to fetch from graph is {}", componentsUidToFetch.size());
411 Either<List<Component>, StorageOperationStatus> nonCheckoutCompResponse = toscaOperationFacade.getLatestVersionNotAbstractComponents(isAbstractAbstract, componentTypeEnum, internalComponentType, componentsUidToFetch);
413 if (nonCheckoutCompResponse.isLeft()) {
414 log.debug("Retrived Resource successfully.");
415 result.addAll(nonCheckoutCompResponse.left().value());
417 return Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(nonCheckoutCompResponse.right().value())));
420 return Either.left(result);
423 janusGraphDao.commit();
427 private Boolean isHighest(HighestFilterEnum highestFilter) {
428 Boolean isHighest = null;
429 switch (highestFilter) {
435 case NON_HIGHEST_ONLY:
444 public Either<List<Component>, ResponseFormat> getLatestVersionNotAbstractComponentsMetadata(boolean isAbstractAbstract, HighestFilterEnum highestFilter, ComponentTypeEnum componentTypeEnum, String internalComponentType, String userId) {
445 ResponseFormat responseFormat = null;
448 validateUserExists(userId);
449 Boolean isHighest = isHighest(highestFilter);
450 Either<List<Component>, StorageOperationStatus> nonCheckoutCompResponse = toscaOperationFacade.getLatestVersionNotAbstractMetadataOnly(isAbstractAbstract, componentTypeEnum, internalComponentType);
452 if (nonCheckoutCompResponse.isLeft()) {
453 log.debug("Retrieved Resource successfully.");
454 return Either.left(nonCheckoutCompResponse.left().value());
456 responseFormat = componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(nonCheckoutCompResponse.right().value()));
458 janusGraphDao.commit();
460 return Either.right(responseFormat);
463 public void setDeploymentArtifactsPlaceHolder(Component component, User user) {
467 @SuppressWarnings("unchecked")
468 public void setToscaArtifactsPlaceHolders(Component component, User user) {
469 Map<String, ArtifactDefinition> artifactMap = component.getToscaArtifacts();
470 if (artifactMap == null) {
471 artifactMap = new HashMap<>();
473 String componentUniqueId = component.getUniqueId();
474 String componentSystemName = component.getSystemName();
475 String componentType = component.getComponentType().getValue().toLowerCase();
476 Map<String, Object> toscaArtifacts = ConfigurationManager.getConfigurationManager().getConfiguration().getToscaArtifacts();
478 if (toscaArtifacts != null) {
479 for (Entry<String, Object> artifactInfoMap : toscaArtifacts.entrySet()) {
480 Map<String, Object> artifactInfo = (Map<String, Object>) artifactInfoMap.getValue();
481 ArtifactDefinition artifactDefinition = artifactsBusinessLogic.createArtifactPlaceHolderInfo(componentUniqueId, artifactInfoMap.getKey(), artifactInfo, user, ArtifactGroupTypeEnum.TOSCA);
482 artifactDefinition.setArtifactName(ValidationUtils.normalizeFileName(componentType + "-" + componentSystemName + artifactInfo.get("artifactName")));
483 artifactMap.put(artifactDefinition.getArtifactLabel(), artifactDefinition);
486 component.setToscaArtifacts(artifactMap);
489 public Either<ArtifactDefinition, Operation> populateToscaArtifacts(Component component, User user, boolean isInCertificationRequest, boolean inTransaction, boolean shouldLock) {
490 return populateToscaArtifacts(component, user, isInCertificationRequest, inTransaction, shouldLock, true, true);
493 public Either<ArtifactDefinition, Operation> populateToscaArtifacts(Component component, User user, boolean isInCertificationRequest, boolean inTransaction, boolean shouldLock, boolean retrieveResource) {
494 return populateToscaArtifacts(component, user, isInCertificationRequest, inTransaction, shouldLock, true, retrieveResource);
497 private Either<ArtifactDefinition, Operation> populateToscaArtifacts(Component component, User user, boolean isInCertificationRequest, boolean inTransaction, boolean shouldLock, boolean fetchTemplatesFromDB, boolean retrieveResource) {
498 if (retrieveResource) {
499 Either<Component, StorageOperationStatus> toscaElement = toscaOperationFacade.getToscaFullElement(component.getUniqueId());
500 if ( toscaElement.isRight() ){
501 throw new ByActionStatusComponentException(componentsUtils.convertFromStorageResponse(toscaElement.right().value(), component.getComponentType()));
503 component = toscaElement.left().value();
506 Either<ArtifactDefinition, Operation> generateToscaRes =
507 saveToscaArtifactAndPopulateToscaArtifactsWithResult(component, componentsUtils,
508 ArtifactTypeEnum.TOSCA_TEMPLATE,
509 (comp, toscaArtifact) ->
510 saveToscaArtifactPayload(toscaArtifact, comp, user, isInCertificationRequest, shouldLock,
511 inTransaction, fetchTemplatesFromDB));
513 if (!isAbstractResource(component)) {
514 generateToscaRes = saveToscaArtifactAndPopulateToscaArtifactsWithResult(component, componentsUtils,
515 ArtifactTypeEnum.TOSCA_CSAR,
516 (comp, toscaArtifactArg) -> saveToscaArtifactPayload(toscaArtifactArg, comp, user,
517 isInCertificationRequest, shouldLock, inTransaction, true));
519 return generateToscaRes;
522 private static Either<ArtifactDefinition, Operation> saveToscaArtifactAndPopulateToscaArtifactsWithResult(
524 final ComponentsUtils componentsUtils,
525 final ArtifactTypeEnum artifactEnum,
526 final BiFunction<Component, ArtifactDefinition, Either<ArtifactDefinition, Operation>> saveToscaArtifactPayloadFunction) {
528 ArtifactDefinition artifactDefinition = getToscaArtifactByTypeOrThrowException(component, artifactEnum,
531 Either<ArtifactDefinition, Operation> result =
532 saveToscaArtifactPayloadFunction.apply(component, artifactDefinition);
534 if (result.isLeft()) {
535 ArtifactDefinition def = result.left().value();
536 component.getToscaArtifacts().put(def.getArtifactLabel(), def);
542 private static Optional<ArtifactDefinition> getToscaArtifactByType(
543 final Map<String, ArtifactDefinition> toscaArtifacts,
544 final ArtifactTypeEnum typeEnum) {
545 return toscaArtifacts.values().stream()
546 .filter(p -> p.getArtifactType().equals(typeEnum.getType()))
550 private static ArtifactDefinition getToscaArtifactByTypeOrThrowException(
551 final Component component,
552 final ArtifactTypeEnum typeEnum,
553 final ComponentsUtils componentsUtils) {
555 return Optional.ofNullable(component.getToscaArtifacts())
556 .flatMap(toscaArtifacts -> getToscaArtifactByType(toscaArtifacts, typeEnum))
558 log.debug("Impossible to find a ToscaArtifact with type '{}' for {}", typeEnum.getType(), component);
559 return new ByResponseFormatComponentException(
560 componentsUtils.getResponseFormat(ActionStatus.ARTIFACT_NOT_FOUND, typeEnum.name()));
564 private boolean isAbstractResource(Component component) {
565 return component.getComponentType() == ComponentTypeEnum.RESOURCE && ((Resource)component).isAbstract();
568 private Either<ArtifactDefinition, Operation> saveToscaArtifactPayload(ArtifactDefinition artifactDefinition, org.openecomp.sdc.be.model.Component component, User user, boolean isInCertificationRequest, boolean shouldLock,
569 boolean inTransaction, boolean fetchTemplatesFromDB) {
570 return artifactsBusinessLogic.generateAndSaveToscaArtifact(artifactDefinition, component, user, isInCertificationRequest, shouldLock, inTransaction, fetchTemplatesFromDB);
573 public ImmutablePair<String, byte[]> getToscaModelByComponentUuid(ComponentTypeEnum componentType, String uuid, ResourceCommonInfo resourceCommonInfo) {
575 Either<List<Component>, StorageOperationStatus> latestVersionEither = toscaOperationFacade.getComponentListByUuid(uuid, null);
577 if (latestVersionEither.isRight()) {
578 throw new ByActionStatusComponentException(componentsUtils.convertFromStorageResponse(latestVersionEither.right().value(), componentType));
581 List<Component> components = latestVersionEither.left().value();
583 Component component = components.stream().filter(Component::isHighestVersion).findFirst().orElse(null);
584 if(component == null){
585 component = components.stream().filter(c -> c.getLifecycleState() == LifecycleStateEnum.CERTIFIED).findFirst().orElse(null);
588 if(component == null){
589 throw new ByResponseFormatComponentException(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(StorageOperationStatus.NOT_FOUND, componentType)));
591 resourceCommonInfo.setResourceName(component.getName());
592 // TODO remove after migration - handle artifact not found(no
594 if (null == component.getToscaArtifacts() || component.getToscaArtifacts().isEmpty()) {
595 throw new ByResponseFormatComponentException(componentsUtils.getResponseFormat(ActionStatus.ARTIFACT_NOT_FOUND, ArtifactTypeEnum.TOSCA_CSAR.name()));
597 ArtifactDefinition csarArtifact = component.getToscaArtifacts().values().stream()
598 .filter(p -> p.getArtifactType().equals(ArtifactTypeEnum.TOSCA_CSAR.getType()))
600 return artifactsBusinessLogic.handleDownloadToscaModelRequest(component, csarArtifact);
603 protected StorageOperationStatus markComponentToDelete(Component component) {
605 ComponentTypeEnum componentType = component.getComponentType();
606 String uniqueId = component.getUniqueId();
607 if (Boolean.TRUE.equals(component.getIsDeleted())) {
608 log.info("component {} already marked as deleted. id= {}, type={}", component.getName(), uniqueId, componentType);
609 return StorageOperationStatus.NOT_FOUND;
612 StorageOperationStatus markResourceToDelete = toscaOperationFacade.markComponentToDelete(component);
613 if (StorageOperationStatus.OK != markResourceToDelete) {
614 log.debug("failed to mark component {} of type {} for delete. error = {}", uniqueId, componentType, markResourceToDelete);
615 return markResourceToDelete;
617 log.debug("Component {} of type {} was marked as deleted", uniqueId, componentType);
618 updateCatalog(component, ChangeTypeEnum.DELETE);
619 return StorageOperationStatus.OK;
623 public Either<Boolean, ResponseFormat> validateAndUpdateDescription(User user, Component currentComponent, Component updatedComponent, AuditingActionEnum auditingAction) {
624 String descriptionUpdated = updatedComponent.getDescription();
625 String descriptionCurrent = currentComponent.getDescription();
626 if (descriptionUpdated != null && !descriptionCurrent.equals(descriptionUpdated)) {
627 componentDescriptionValidator.validateAndCorrectField(user, updatedComponent, auditingAction);
628 currentComponent.setDescription(updatedComponent.getDescription());
630 return Either.left(true);
633 public Either<Boolean, ResponseFormat> validateAndUpdateProjectCode(User user, Component currentComponent, Component updatedComponent) {
634 String projectCodeUpdated = updatedComponent.getProjectCode();
635 String projectCodeCurrent = currentComponent.getProjectCode();
636 if (projectCodeUpdated != null && !projectCodeCurrent.equals(projectCodeUpdated)) {
638 componentProjectCodeValidator.validateAndCorrectField(user, updatedComponent, null);
639 } catch (ComponentException exp) {
640 ResponseFormat errorRespons = exp.getResponseFormat();
641 return Either.right(errorRespons);
643 currentComponent.setProjectCode(updatedComponent.getProjectCode());
645 return Either.left(true);
648 public Either<Boolean, ResponseFormat> validateAndUpdateIcon(User user, Component currentComponent, Component updatedComponent, boolean hasBeenCertified) {
649 String iconUpdated = updatedComponent.getIcon();
650 String iconCurrent = currentComponent.getIcon();
651 if (iconUpdated != null && !iconCurrent.equals(iconUpdated)) {
652 if (!hasBeenCertified) {
653 componentIconValidator.validateAndCorrectField(user, updatedComponent, null);
654 currentComponent.setIcon(updatedComponent.getIcon());
656 log.info("icon {} cannot be updated once the component has been certified once.", iconUpdated);
657 ResponseFormat errorResponse = componentsUtils.getResponseFormat(ActionStatus.COMPONENT_PARAMETER_CANNOT_BE_CHANGED, "Icon", currentComponent.getComponentType().name().toLowerCase());
658 return Either.right(errorResponse);
661 return Either.left(true);
664 protected Either<List<String>, ResponseFormat> deleteMarkedComponents(ComponentTypeEnum componentType) {
666 log.trace("start deleteMarkedComponents");
667 Either<List<String>, StorageOperationStatus> deleteMarkedElements = toscaOperationFacade.deleteMarkedElements(componentType);
670 if ( deleteMarkedElements.isRight()){
671 janusGraphDao.rollback();
672 ResponseFormat responseFormat = componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(deleteMarkedElements.right().value(), componentType));
673 return Either.right(responseFormat);
675 log.trace("end deleteMarkedComponents");
676 janusGraphDao.commit();
677 return Either.left(deleteMarkedElements.left().value());
680 public Either<List<ArtifactDefinition>, StorageOperationStatus> getComponentArtifactsForDelete(String parentId, NodeTypeEnum parentType) {
681 List<ArtifactDefinition> artifacts = new ArrayList<>();
682 Either<Map<String, ArtifactDefinition>, StorageOperationStatus> artifactsResponse = artifactToscaOperation.getArtifacts(parentId);
683 if (artifactsResponse.isRight()) {
684 if (artifactsResponse.right().value() != StorageOperationStatus.NOT_FOUND) {
685 log.debug("failed to retrieve artifacts for {} {}", parentType, parentId);
686 return Either.right(artifactsResponse.right().value());
689 artifacts.addAll(artifactsResponse.left().value().values());
691 return Either.left(artifacts);
698 * @param dataParamsToReturn - ui list of params to return
702 public Either<UiComponentDataTransfer, ResponseFormat> getComponentDataFilteredByParams(String componentId, User user, List<String> dataParamsToReturn) {
705 validateUserExists(user);
708 UiComponentDataTransfer result = new UiComponentDataTransfer();
710 if(dataParamsToReturn == null || dataParamsToReturn.isEmpty()) {
714 Either<UiComponentDataTransfer, ResponseFormat> uiDataTransferEither = getUiComponentDataTransferByComponentId(componentId, dataParamsToReturn);
715 if(uiDataTransferEither.isRight()){
716 return Either.right(uiDataTransferEither.right().value());
718 result = uiDataTransferEither.left().value();
721 return Either.left(result);
724 protected <T extends Component> void generateAndAddInputsFromGenericTypeProperties(T component, Resource genericType) {
725 List<InputDefinition> genericAndComponentInputs = new ArrayList<>();
726 List<InputDefinition> genericInputs = genericTypeBusinessLogic.generateInputsFromGenericTypeProperties(genericType);
727 genericAndComponentInputs.addAll(genericInputs);
728 if (null != component.getInputs()){
729 List<InputDefinition> nonGenericInputsFromComponent = getAllNonGenericInputsFromComponent(genericInputs, component.getInputs());
730 genericAndComponentInputs.addAll(nonGenericInputsFromComponent);
732 component.setInputs(genericAndComponentInputs);
735 private List<InputDefinition> getAllNonGenericInputsFromComponent(List<InputDefinition> genericInputs, List<InputDefinition> componentInputs) {
736 if (genericInputs == null) {
737 return componentInputs;
740 Map<String, InputDefinition> inputByNameMap = MapUtil.toMap(genericInputs, InputDefinition::getName);
741 List<InputDefinition> componentNonGenericInputs = new ArrayList<>();
742 componentInputs.stream().forEach(input -> {
743 if (!inputByNameMap.containsKey(input.getName())) {
744 componentNonGenericInputs.add(input);
747 return componentNonGenericInputs;
750 protected <T extends Component> Resource fetchAndSetDerivedFromGenericType(T component){
751 Either<Resource, ResponseFormat> genericTypeEither = this.genericTypeBusinessLogic.fetchDerivedFromGenericType(component);
752 if(genericTypeEither.isRight()){
753 log.debug("Failed to fetch latest generic type for component {} of type", component.getName(), component.assetType());
754 throw new ByActionStatusComponentException(ActionStatus.GENERIC_TYPE_NOT_FOUND, component.assetType());
756 Resource genericTypeResource = genericTypeEither.left().value();
757 component.setDerivedFromGenericInfo(genericTypeResource);
758 return genericTypeResource;
761 public Either<Map<String, List<IComponentInstanceConnectedElement>>, ResponseFormat> getFilteredComponentInstanceProperties(String componentId, Map<FilterKeyEnum, List<String>> filters, String userId) {
762 Either<Map<String, List<IComponentInstanceConnectedElement>>, ResponseFormat> response = null;
763 Either<Component, StorageOperationStatus> getResourceRes = null;
765 if(!filters.containsKey(FilterKeyEnum.NAME_FRAGMENT) && StringUtils.isEmpty(filters.get(FilterKeyEnum.NAME_FRAGMENT).get(0))){
766 response = Either.right(componentsUtils.getResponseFormat(ActionStatus.INVALID_CONTENT));
768 if (userId != null && response == null) {
769 validateUserExists(userId);
771 if(response == null){
772 getResourceRes = toscaOperationFacade.getToscaElement(componentId);
773 if(getResourceRes.isRight()){
774 response = Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(getResourceRes.right().value())));
777 if(response == null){
778 response = getFilteredComponentInstancesProperties(getResourceRes.left().value(), filters);
780 } catch(Exception e){
781 log.debug("The exception {} occured during filtered instance properties fetching. the containing component is {}. ", e, componentId);
782 response = Either.right(componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR));
784 if (response != null && response.isLeft()){
785 toscaOperationFacade.commit();
787 toscaOperationFacade.rollback();
793 private Either<Map<String, List<IComponentInstanceConnectedElement>>, ResponseFormat> getFilteredComponentInstancesProperties(Component component, Map<FilterKeyEnum, List<String>> filters) {
795 Map<String, List<IComponentInstanceConnectedElement>> filteredProperties = new HashMap<>();
796 Either<Map<String, List<IComponentInstanceConnectedElement>>, ResponseFormat> result = Either.left(filteredProperties);
797 List<ComponentInstance> filteredInstances = getFilteredInstances(component, filters.get(FilterKeyEnum.RESOURCE_TYPE));
798 String propertyNameFragment= filters.get(FilterKeyEnum.NAME_FRAGMENT).get(0);
799 boolean searchByFragment = propertyNameFragment.length() > 3 ;
800 if(CollectionUtils.isNotEmpty(filteredInstances)){
801 for(ComponentInstance instance : filteredInstances){
802 if(component.getComponentInstancesProperties()!=null &&component.getComponentInstancesProperties().containsKey(instance.getUniqueId())){
803 List<IComponentInstanceConnectedElement> currProperties = getFilteredComponentInstanceProperties(component.getComponentInstancesProperties().get(instance.getUniqueId()), propertyNameFragment, searchByFragment);
804 setFilteredProperties(filteredProperties, instance, currProperties);
806 if(component.getComponentInstancesInputs()!=null && component.getComponentInstancesInputs().containsKey(instance.getUniqueId())){
807 List<IComponentInstanceConnectedElement> currInputs = getFilteredComponentInstanceInputs(component.getComponentInstancesInputs().get(instance.getUniqueId()), propertyNameFragment, searchByFragment);
808 if(CollectionUtils.isNotEmpty(currInputs)){
809 checkFilteredProperties(filteredProperties, instance, currInputs);
817 private void setFilteredProperties(Map<String, List<IComponentInstanceConnectedElement>> filteredProperties, ComponentInstance instance, List<IComponentInstanceConnectedElement> currProperties) {
818 if(CollectionUtils.isNotEmpty(currProperties)){
819 filteredProperties.put(instance.getUniqueId(), currProperties);
823 private void checkFilteredProperties(Map<String, List<IComponentInstanceConnectedElement>> filteredProperties, ComponentInstance instance, List<IComponentInstanceConnectedElement> currInputs) {
824 if(filteredProperties.get(instance.getUniqueId())!=null){
825 filteredProperties.get(instance.getUniqueId()).addAll(currInputs);
827 filteredProperties.put(instance.getUniqueId(), currInputs);
831 private List<IComponentInstanceConnectedElement> getFilteredComponentInstanceInputs(List<ComponentInstanceInput> inputs, String propertyNameFragment, boolean searchByFragment) {
832 return inputs.stream().filter(i -> isMatchingInput(i, propertyNameFragment, searchByFragment)).collect(Collectors.toList());
835 private List<IComponentInstanceConnectedElement> getFilteredComponentInstanceProperties(List<ComponentInstanceProperty> instanceProperties, String propertyNameFragment, boolean searchByFragment) {
836 return instanceProperties.stream().filter(p -> isMatchingProperty(p, propertyNameFragment, searchByFragment)).collect(Collectors.toList());
839 private boolean isMatchingInput(ComponentInstanceInput input, String propertyNameFragment, boolean searchByFragment) {
840 boolean isMatching = false;
841 if(searchByFragment && input.getName().toLowerCase().contains(propertyNameFragment)){
844 if(!searchByFragment && input.getName().equalsIgnoreCase(propertyNameFragment)){
850 private boolean isMatchingProperty(ComponentInstanceProperty property, String propertyNameFragment, boolean searchByFragment) {
851 boolean isMatching = false;
852 if(searchByFragment && property.getName().toLowerCase().contains(propertyNameFragment)){
855 if(!searchByFragment && property.getName().equalsIgnoreCase(propertyNameFragment)){
858 if (!isMatching && !ToscaPropertyType.isPrimitiveType(property.getType())){
859 isMatching = isMatchingComplexPropertyByRecursively(property, propertyNameFragment, searchByFragment);
864 private boolean isMatchingComplexPropertyByRecursively(PropertyDataDefinition property, String propertyNameFragment, boolean searchByFragment) {
866 List<PropertyDefinition> dataTypeProperties;
867 DataTypeDefinition currentProperty;
868 if(searchByFragment && property.getName().toLowerCase().contains(propertyNameFragment.toLowerCase())){
871 if(!searchByFragment && property.getName().equalsIgnoreCase(propertyNameFragment)){
875 propertyType = isEmptyInnerType(property) ? property.getType() : property.getSchema().getProperty().getType();
877 if(ToscaPropertyType.isScalarType(propertyType)){
880 Either<DataTypeDefinition, StorageOperationStatus> getDataTypeByNameRes = propertyOperation.getDataTypeByName(propertyType);
881 if(getDataTypeByNameRes.isRight()){
884 currentProperty = getDataTypeByNameRes.left().value();
885 dataTypeProperties = currentProperty.getProperties();
887 boolean dataPropertiesNotNull = CollectionUtils.isNotEmpty(dataTypeProperties);
888 BooleanSupplier dataMatchesComplexProperty = () -> isMatchingComplexProperty(propertyNameFragment,
889 searchByFragment, dataTypeProperties);
890 BooleanSupplier parentPropertiesNotNull = () -> CollectionUtils
891 .isNotEmpty(currentProperty.getDerivedFrom().getProperties());
892 BooleanSupplier parentDataMatchesComplexProperty = () -> isMatchingComplexProperty(propertyNameFragment,
893 searchByFragment, currentProperty.getDerivedFrom().getProperties());
895 return ((dataPropertiesNotNull && dataMatchesComplexProperty.getAsBoolean())
896 || (parentPropertiesNotNull.getAsBoolean() && parentDataMatchesComplexProperty.getAsBoolean()));
899 private boolean isMatchingComplexProperty(String propertyNameFragment, boolean searchByFragment, List<PropertyDefinition> dataTypeProperties) {
900 for(PropertyDefinition prop : dataTypeProperties){
901 if(isMatchingComplexPropertyByRecursively(prop, propertyNameFragment, searchByFragment)){
908 private boolean isEmptyInnerType(PropertyDataDefinition property) {
909 return property == null|| property.getSchema() == null || property.getSchema().getProperty() == null || property.getSchema().getProperty().getType() == null;
912 public Either<Boolean, ResponseFormat> shouldUpgradeToLatestGeneric(Component clonedComponent) {
914 if(!clonedComponent.deriveFromGeneric())
915 return Either.left(false);
916 Boolean shouldUpgrade = false;
917 String currentGenericType = clonedComponent.getDerivedFromGenericType();
918 String currentGenericVersion = clonedComponent.getDerivedFromGenericVersion();
919 Resource genericTypeResource = fetchAndSetDerivedFromGenericType(clonedComponent);
920 if(null == currentGenericType || !currentGenericType.equals(genericTypeResource.getToscaResourceName()) || !currentGenericVersion.equals(genericTypeResource.getVersion())){
921 shouldUpgrade = upgradeToLatestGeneric(clonedComponent, genericTypeResource);
923 reverntUpdateOfGenericVersion(clonedComponent, currentGenericType, currentGenericVersion);
926 return Either.left(shouldUpgrade);
929 private void reverntUpdateOfGenericVersion(Component clonedComponent, String currentGenericType, String currentGenericVersion) {
930 clonedComponent.setDerivedFromGenericType(currentGenericType);
931 clonedComponent.setDerivedFromGenericVersion(currentGenericVersion);
934 private <T extends ToscaDataDefinition> Either<Map<String, T>, String> validateNoConflictingProperties(List<T> currentList, List<T> upgradedList) {
935 Map<String, T> currentMap = ToscaDataDefinition.listToMapByName(currentList);
936 Map<String, T> upgradedMap = ToscaDataDefinition.listToMapByName(upgradedList);
937 return ToscaDataDefinition.mergeDataMaps(upgradedMap, currentMap, true);
940 private boolean shouldUpgradeNodeType(Component componentToCheckOut, Resource latestGeneric){
942 List<PropertyDefinition> genericTypeProps = latestGeneric.getProperties();
943 Either<Map<String, PropertyDefinition>, String> validPropertiesMerge = validateNoConflictingProperties(genericTypeProps, ((Resource)componentToCheckOut).getProperties());
944 if (validPropertiesMerge.isRight()) {
945 log.debug("property {} cannot be overriden, check out performed without upgrading to latest generic", validPropertiesMerge.right().value());
948 List<AttributeDataDefinition> genericTypeAttributes = latestGeneric.getAttributes();
949 final Either<Map<String, AttributeDataDefinition>, String> validAttributesMerge = validateNoConflictingProperties(
950 genericTypeAttributes, ((Resource) componentToCheckOut).getAttributes());
951 if (validAttributesMerge.isRight()) {
952 log.debug("attribute {} cannot be overriden, check out performed without upgrading to latest generic", validAttributesMerge.right().value());
958 private boolean upgradeToLatestGeneric(Component componentToCheckOut, Resource latestGeneric) {
960 if (!componentToCheckOut.shouldGenerateInputs()) {
961 //node type - validate properties and attributes
962 return shouldUpgradeNodeType(componentToCheckOut, latestGeneric);
964 List<PropertyDefinition> genericTypeProps = latestGeneric.getProperties();
965 List<InputDefinition> genericTypeInputs = null == genericTypeProps? null : genericTypeBusinessLogic.convertGenericTypePropertiesToInputsDefintion(genericTypeProps, latestGeneric.getUniqueId());
966 List<InputDefinition> currentList = new ArrayList<>();
967 // nullify existing ownerId from existing list and merge into updated list
968 if (null != componentToCheckOut.getInputs()) {
969 for(InputDefinition input : componentToCheckOut.getInputs()) {
970 InputDefinition copy = new InputDefinition(input);
971 copy.setOwnerId(null);
972 currentList.add(copy);
975 if (null == genericTypeInputs) {
976 componentToCheckOut.setInputs(currentList);
980 Either<Map<String, InputDefinition>, String> eitherMerged = validateNoConflictingProperties(genericTypeInputs, currentList);
981 if (eitherMerged.isRight()) {
982 log.debug("input {} cannot be overriden, check out performed without upgrading to latest generic", eitherMerged.right().value());
985 componentToCheckOut.setInputs(new ArrayList<>(eitherMerged.left().value().values()));
990 private List<ComponentInstance> getFilteredInstances(Component component, List<String> resourceTypes) {
991 List<ComponentInstance> filteredInstances = null;
992 if(CollectionUtils.isEmpty(resourceTypes)){
993 filteredInstances = component.getComponentInstances();
995 else if(CollectionUtils.isNotEmpty(component.getComponentInstances())){
996 filteredInstances = component.getComponentInstances()
997 .stream().filter(i -> isMatchingType(i.getOriginType(), resourceTypes)).collect(Collectors.toList());
999 if(filteredInstances == null){
1000 filteredInstances = new ArrayList<>();
1002 return filteredInstances;
1005 private boolean isMatchingType(OriginTypeEnum originType, List<String> resourceTypes) {
1006 boolean isMatchingType = false;
1007 for(String resourceType : resourceTypes){
1008 if(originType == OriginTypeEnum.findByValue(resourceType.toUpperCase())){
1009 isMatchingType = true;
1013 return isMatchingType;
1016 public Either<Component, ActionStatus> shouldUpgradeToLatestDerived(Component clonedComponent) {
1017 //general implementation. Must be error for service, VF . In ResourceBuisnessLogic exist override
1018 return Either.right(ActionStatus.GENERAL_ERROR);
1021 protected Either<Component, ResponseFormat> updateCatalog(Component component, ChangeTypeEnum changeStatus){
1022 log.debug("update Catalog start with Component Type {} And Componet Name {} with change status {}", component.getComponentType().name(), component.getName(), changeStatus.name());
1023 ActionStatus status = catalogOperations.updateCatalog(changeStatus,component);
1024 if(status != ActionStatus.OK){
1025 return Either.right( componentsUtils.getResponseFormat(status));
1028 return Either.left(component);
1031 public CatalogOperation getCatalogOperations() {
1032 return catalogOperations;
1036 public void setCatalogOperations(CatalogOperation catalogOperations) {
1037 this.catalogOperations = catalogOperations;
1040 public List<GroupDefinition> throwComponentException(ResponseFormat responseFormat) {
1041 throw new ByResponseFormatComponentException(responseFormat);