public class ManifestCreatorNamingConventionImpl implements ManifestCreator {
protected static final Logger logger =
LoggerFactory.getLogger(ManifestCreatorNamingConventionImpl.class);
+
+ private static final String CLOUD_SPECIFIC_FIXED_KEY_WORD = "cloudtech";
+ private static final String[][] CLOUD_SPECIFIC_KEY_WORDS = {{"k8s", "azure", "aws"}, /* cloud specific technology */
+ {"charts", "day0", "configtemplate"} /*cloud specific sub type*/};
+
@Override
public Optional<ManifestContent> createManifest(
VspDetails vspDetails, FilesDataStructure filesDataStructure) {
return Pattern.matches(Constants.BASE_HEAT_REGEX, fileName) && !isVolFile(fileName);
}
+ protected boolean isCloudSpecificArtifact(String artifact) {
+ if (artifact.contains(CLOUD_SPECIFIC_FIXED_KEY_WORD)) {
+ for (int i = 0; i < CLOUD_SPECIFIC_KEY_WORDS.length; i++) {
+ if (Arrays.stream(CLOUD_SPECIFIC_KEY_WORDS[i]).noneMatch(str -> artifact.contains(str))) {
+ return false;
+ }
+ }
+ return true;
+ } else {
+ return false;
+ }
+ }
private void addArtifactsToManifestFileDataList(
FilesDataStructure filesDataStructure, List<FileData> fileDataList) {
.union(filesDataStructure.getArtifacts(), filesDataStructure.getUnassigned());
if (CollectionUtils.isNotEmpty(forArtifacts)) {
for (String artifact : forArtifacts) {
- fileDataList.add(createBaseFileData(FileData.Type.OTHER, artifact));
+ if (isCloudSpecificArtifact(artifact)) {
+ fileDataList.add(createBaseFileData(FileData.Type.CLOUD_TECHNOLOGY_SPECIFIC_ARTIFACT, artifact));
+ } else {
+ fileDataList.add(createBaseFileData(FileData.Type.OTHER, artifact));
+ }
}
}
}
--- /dev/null
+package org.openecomp.sdc.vendorsoftwareproduct.services.impl.filedatastructuremodule;
+
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public class ManifestCreatorNamingConventionImplTest extends ManifestCreatorNamingConventionImpl {
+
+ private static final String ARTIFACT_1 = "cloudtech_k8s_charts.zip";
+ private static final String ARTIFACT_2 = "cloudtech_azure_day0.zip";
+ private static final String ARTIFACT_3 = "cloudtech_aws_configtemplate.zip";
+ private static final String ARTIFACT_4 = "k8s_charts.zip";
+ private static final String ARTIFACT_5 = "cloudtech_openstack_configtemplate.zip";
+
+ @Test
+ public void testIsCloudSpecificArtifact() {
+ assertTrue(isCloudSpecificArtifact(ARTIFACT_1));
+ assertTrue(isCloudSpecificArtifact(ARTIFACT_2));
+ assertTrue(isCloudSpecificArtifact(ARTIFACT_3));
+ assertFalse(isCloudSpecificArtifact(ARTIFACT_4));
+ assertFalse(isCloudSpecificArtifact(ARTIFACT_5));
+ }
+}