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=========================================================
21 package org.openecomp.sdc.be.model.operations.migration;
23 import org.apache.commons.lang3.StringUtils;
24 import org.openecomp.sdc.be.model.Component;
25 import org.openecomp.sdc.be.model.ComponentInstance;
26 import org.slf4j.Logger;
27 import org.slf4j.LoggerFactory;
29 import java.util.HashSet;
30 import java.util.List;
32 import java.util.stream.Collectors;
35 * to be moved with all operations to the migration project
38 public class MigrationMalformedDataLogger {
40 private static Logger log = LoggerFactory.getLogger(MigrationMalformedDataLogger.class);
41 private static Set<String> malformedVFs = new HashSet<>();
43 public static void reportMalformedVF(String vfId, String errorMsg) {
45 malformedVFs.add(vfId);
48 public static void logMalformedDataMsg(String errorMsg) {
52 public static void logIfServiceUsingMalformedVfs(Component service) {
53 List<ComponentInstance> componentInstances = service.getComponentInstances();
54 if (componentInstances != null && !componentInstances.isEmpty() && !malformedVFs.isEmpty()) {
55 Set<String> serviceInstances = componentInstances.stream().map(ComponentInstance::getComponentUid).collect(Collectors.toSet());
56 serviceInstances.retainAll(malformedVFs);
57 if (!serviceInstances.isEmpty()) {
58 log.error(String.format("Service %s with id %s and version %s is using malformed VFs: %s", service.getName(),
60 service.getUniqueId(),
61 StringUtils.join(serviceInstances, ',')));