<zusammen-state-store.version>0.2.2</zusammen-state-store.version>
<pmd.version>5.8.1</pmd.version>
<build.tools.version>${project.version}</build.tools.version>
+ <togglz.version>2.4.1.Final</togglz.version>
</properties>
<build>
<param-value>WEB-INF/beans-services.xml</param-value>
</context-param>
+ <context-param>
+ <param-name>org.togglz.core.manager.TogglzConfig</param-name>
+ <param-value>org.openecomp.sdc.common.togglz.TogglzConfiguration</param-value>
+ </context-param>
+
+
<listener>
<listener-class>org.openecomp.server.listeners.OnboardingAppStartupListener</listener-class>
--- /dev/null
+package org.openecomp.sdc.common.togglz;
+
+import org.togglz.core.Feature;
+import org.togglz.core.annotation.Label;
+import org.togglz.core.context.FeatureContext;
+
+public enum ToggleableFeature implements Feature {
+
+ @Label ("Forwarder Capability")
+ FORWARDER_CAPABILITY;
+
+ public boolean isActive() {
+ return FeatureContext.getFeatureManager().isActive(this);
+ }
+}
--- /dev/null
+package org.openecomp.sdc.common.togglz;
+
+import org.togglz.core.Feature;
+import org.togglz.core.manager.TogglzConfig;
+import org.togglz.core.repository.StateRepository;
+import org.togglz.core.repository.file.FileBasedStateRepository;
+import org.togglz.core.user.SimpleFeatureUser;
+import org.togglz.core.user.UserProvider;
+
+import java.io.File;
+
+public class TogglzConfiguration implements TogglzConfig {
+ @Override
+ public Class<? extends Feature> getFeatureClass() {
+ return ToggleableFeature.class;
+ }
+
+ @Override
+ public StateRepository getStateRepository() {
+ return new FileBasedStateRepository(new File("/tmp/features.properties"));
+ }
+
+ @Override
+ public UserProvider getUserProvider() {
+ return () -> new SimpleFeatureUser("admin", true);
+ }
+}
import org.openecomp.core.translator.factory.HeatToToscaTranslatorFactory;
import org.openecomp.core.utilities.file.FileContentHandler;
import org.openecomp.core.utilities.file.FileUtils;
+import org.openecomp.sdc.common.togglz.ToggleableFeature;
import org.openecomp.sdc.tosca.services.YamlUtil;
import org.openecomp.core.validation.util.MessageContainerUtil;
import org.openecomp.sdc.common.errors.CoreException;
protected static Logger logger = (Logger) LoggerFactory.getLogger(HeatToToscaUtil.class);
protected static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
+ private static final String forwarder = "forwarder";
/**
NodeType flatNodeType =
getNodeTypeWithFlatHierarchy(type, serviceTemplate, context);
- String capabilityKey;
- List<String> capabilityMapping;
+
if (flatNodeType.getCapabilities() != null) {
- for (Map.Entry<String, CapabilityDefinition> capabilityNodeEntry : flatNodeType
- .getCapabilities()
- .entrySet()) {
- capabilityKey = capabilityNodeEntry.getKey() + "_" + templateName;
- nodeTypeCapabilitiesDefinition.put(capabilityKey, capabilityNodeEntry.getValue().clone());
- capabilityMapping = new ArrayList<>();
- capabilityMapping.add(templateName);
- capabilityMapping.add(capabilityNodeEntry.getKey());
- capabilitySubstitutionMapping.put(capabilityKey, capabilityMapping);
- }
+ flatNodeType.getCapabilities()
+ .entrySet()
+ .stream()
+ .filter(capabilityNodeEntry -> shouldCapabilityNeedsToBeAdded(capabilityNodeEntry.getKey()))
+ .forEach(capabilityNodeEntry ->
+ addCapabilityToSubMapping(
+ templateName, capabilityNodeEntry, nodeTypeCapabilitiesDefinition, capabilitySubstitutionMapping));
}
mdcDataDebugMessage.debugExitMessage(null, null);
}
+ private static boolean shouldCapabilityNeedsToBeAdded(String capabilityKey) {
+ return !capabilityKey.contains(forwarder) || ToggleableFeature.FORWARDER_CAPABILITY.isActive();
+ }
+
+ private static void addCapabilityToSubMapping(String templateName,
+ Map.Entry<String, CapabilityDefinition> capabilityNodeEntry,
+ Map<String, CapabilityDefinition> nodeTypeCapabilitiesDefinition,
+ Map<String, List<String>> capabilitySubstitutionMapping) {
+ String capabilityKey;
+ List<String> capabilityMapping;
+ capabilityKey = capabilityNodeEntry.getKey() + "_" + templateName;
+ nodeTypeCapabilitiesDefinition.put(capabilityKey, capabilityNodeEntry.getValue().clone());
+ capabilityMapping = new ArrayList<>();
+ capabilityMapping.add(templateName);
+ capabilityMapping.add(capabilityNodeEntry.getKey());
+ capabilitySubstitutionMapping.put(capabilityKey, capabilityMapping);
+ }
+
private static List<Map<String, RequirementDefinition>> getNodeTypeReqs(
String type,
String templateName,
package org.openecomp.sdc.translator.services.heattotosca.impl.resourcetranslation;
import org.apache.commons.collections4.MapUtils;
+import org.junit.AfterClass;
import org.junit.Assert;
+import org.junit.BeforeClass;
import org.openecomp.core.translator.api.HeatToToscaTranslator;
import org.openecomp.core.translator.datatypes.TranslatorOutput;
import org.openecomp.core.translator.factory.HeatToToscaTranslatorFactory;
import org.openecomp.sdc.common.errors.CoreException;
import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.common.errors.ErrorCode;
+import org.openecomp.sdc.common.togglz.ToggleableFeature;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
import org.openecomp.sdc.datatypes.error.ErrorMessage;
import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage;
import org.openecomp.sdc.tosca.services.ToscaFileOutputService;
import org.openecomp.sdc.tosca.services.impl.ToscaFileOutputServiceCsarImpl;
import org.openecomp.sdc.translator.TestUtils;
+import org.togglz.testing.TestFeatureManager;
+import org.togglz.testing.TestFeatureManagerProvider;
import java.io.BufferedInputStream;
import java.io.File;
public static final String IN_POSTFIX = "/in";
public static final String OUT_POSTFIX = "/out";
+ protected static TestFeatureManager manager;
+
+ @BeforeClass
+ public static void enableForwarderFeature(){
+ manager = new TestFeatureManager(ToggleableFeature.class);
+ if (!ToggleableFeature.FORWARDER_CAPABILITY.isActive()) {
+ manager.enable(ToggleableFeature.FORWARDER_CAPABILITY);
+ }
+ }
+
+
+ @AfterClass
+ public static void disableForwarderFeature() {
+ manager.disable(ToggleableFeature.FORWARDER_CAPABILITY);
+ manager = null;
+ TestFeatureManagerProvider.setFeatureManager(null);
+ }
+
protected void testTranslationWithInit(String path) throws IOException {
File translatedZipFile = initTranslatorAndTranslate(path);
testTranslation(path, translatedZipFile);
import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.ConsolidationDataTestUtil.validateVolumeInConsolidationData;
import org.apache.commons.collections4.MapUtils;
+import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Before;
+import org.junit.BeforeClass;
import org.openecomp.core.translator.datatypes.TranslatorOutput;
import org.openecomp.core.utilities.file.FileUtils;
import org.openecomp.core.utilities.json.JsonUtil;
import org.openecomp.sdc.common.errors.CoreException;
import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.common.errors.ErrorCode;
+import org.openecomp.sdc.common.togglz.ToggleableFeature;
import org.openecomp.sdc.common.utils.SdcCommon;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
import org.openecomp.sdc.datatypes.error.ErrorMessage;
import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.TypeComputeConsolidationData;
import org.openecomp.sdc.translator.services.heattotosca.TranslationService;
import org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.ConsolidationDataValidationType;
+import org.togglz.testing.TestFeatureManager;
+import org.togglz.testing.TestFeatureManagerProvider;
import java.io.BufferedInputStream;
import java.io.File;
private final String MANIFEST_NAME = SdcCommon.MANIFEST_NAME;
private String validationFilename = "validationOutput.json";
+ protected static TestFeatureManager manager;
+
+ @BeforeClass
+ public static void enableForwarderFeature(){
+ manager = new TestFeatureManager(ToggleableFeature.class);
+ if (!ToggleableFeature.FORWARDER_CAPABILITY.isActive()) {
+ manager.enable(ToggleableFeature.FORWARDER_CAPABILITY);
+ }
+ }
+
+
+ @AfterClass
+ public static void disableForwarderFeature() {
+ manager.disable(ToggleableFeature.FORWARDER_CAPABILITY);
+ manager = null;
+ TestFeatureManagerProvider.setFeatureManager(null);
+ }
+
@Before
public void setUp() throws IOException {
initTranslatorAndTranslate();
<artifactId>jackson-annotations</artifactId>
<version>${jackson.version}</version>
</dependency>
+
+ <!-- Feature Toggle support libraries-->
+ <dependency>
+ <groupId>org.togglz</groupId>
+ <artifactId>togglz-core</artifactId>
+ <version>${togglz.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.togglz</groupId>
+ <artifactId>togglz-servlet</artifactId>
+ <version>${togglz.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.togglz</groupId>
+ <artifactId>togglz-console</artifactId>
+ <version>${togglz.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.togglz</groupId>
+ <artifactId>togglz-testing</artifactId>
+ <version>${togglz.version}</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>