2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2020 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=========================================================
21 package org.openecomp.sdc.be.facade.operations;
23 import org.openecomp.sdc.be.catalog.api.IComponentMessage;
24 import org.openecomp.sdc.be.catalog.api.IStatus;
25 import org.openecomp.sdc.be.catalog.enums.ChangeTypeEnum;
26 import org.openecomp.sdc.be.catalog.impl.ComponentMessage;
27 import org.openecomp.sdc.be.catalog.impl.DmaapProducer;
28 import org.openecomp.sdc.be.dao.api.ActionStatus;
29 import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
30 import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
31 import org.openecomp.sdc.be.model.CatalogUpdateTimestamp;
32 import org.openecomp.sdc.be.model.Component;
33 import org.openecomp.sdc.be.model.Resource;
34 import org.openecomp.sdc.common.log.wrappers.Logger;
36 import java.util.Arrays;
37 import java.util.List;
40 @org.springframework.stereotype.Component
41 public class CatalogOperation {
43 private static final Logger log = Logger.getLogger(CatalogOperation.class);
45 private static final List<ResourceTypeEnum> EXCLUDE_TYPES = Arrays.asList(ResourceTypeEnum.VFCMT, ResourceTypeEnum.Configuration);
47 private final DmaapProducer msProducer;
49 public CatalogOperation(DmaapProducer msProducer){
50 this.msProducer = msProducer;
53 public ActionStatus updateCatalog(ChangeTypeEnum changeTypeEnum, Component component){
54 ActionStatus result = ActionStatus.OK;
56 if(isNeedToUpdateCatalog(component)){
57 IComponentMessage message = new ComponentMessage(component, changeTypeEnum, CatalogUpdateTimestamp.buildDummyCatalogUpdateTimestamp());
58 IStatus status = msProducer.pushMessage(message);
59 result = FacadeOperationUtils.convertStatusToActionStatus(status);
63 log.debug("updateCatalog - failed to updateCatalog and send notification {}", e.getMessage());
64 return ActionStatus.OK;
69 private boolean isNeedToUpdateCatalog(Component component) {
70 boolean isUpdateCatalog = true;
71 if(component.getComponentType() == ComponentTypeEnum.RESOURCE){
72 return ((Resource)component).isAbstract() || EXCLUDE_TYPES.contains(((Resource)component).getResourceType())? false : true;
75 return isUpdateCatalog;
79 public DmaapProducer getMsProducer() {