952c0672ccafa272c3ff8224fe47c2757d0c199a
[sdc.git] /
1 package org.openecomp.sdc.be.model.operations.migration;
2
3 import org.apache.commons.lang3.StringUtils;
4 import org.openecomp.sdc.be.model.Component;
5 import org.openecomp.sdc.be.model.ComponentInstance;
6 import org.slf4j.Logger;
7 import org.slf4j.LoggerFactory;
8
9 import java.util.HashSet;
10 import java.util.List;
11 import java.util.Set;
12 import java.util.stream.Collectors;
13
14 /**
15  * to be moved with all operations to the migration project
16  */
17 @Deprecated
18 public class MigrationErrorInformer {
19
20     private static Logger log = LoggerFactory.getLogger(MigrationErrorInformer.class);
21     private static Set<String> malformedVFs = new HashSet<>();
22
23     public static void addMalformedVF(String vfId) {
24         malformedVFs.add(vfId);
25     }
26
27     public static void logIfServiceUsingMalformedVfs(Component service) {
28         List<ComponentInstance> componentInstances = service.getComponentInstances();
29         if (componentInstances != null && !componentInstances.isEmpty() && !malformedVFs.isEmpty()) {
30             Set<String> serviceInstances = componentInstances.stream().map(ComponentInstance::getComponentUid).collect(Collectors.toSet());
31             serviceInstances.retainAll(malformedVFs);
32             if (!serviceInstances.isEmpty()) {
33                 log.error(String.format("Service %s is using malformed VFs: %s", service.getUniqueId(), StringUtils.join(serviceInstances, ',')));
34             }
35         }
36     }
37
38
39 }