aboutsummaryrefslogtreecommitdiffstats
path: root/common-be
diff options
context:
space:
mode:
Diffstat (limited to 'common-be')
-rw-r--r--common-be/pom.xml17
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/config/NonManoArtifactType.java43
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/config/NonManoConfiguration.java42
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/config/NonManoConfigurationManager.java68
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/config/NonManoFolderType.java35
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/config/exception/LoadConfigurationException.java31
-rw-r--r--common-be/src/main/resources/config/nonManoConfig.yaml22
-rw-r--r--common-be/src/test/java/org/openecomp/sdc/be/config/NonManoConfigurationManagerTest.java50
8 files changed, 308 insertions, 0 deletions
diff --git a/common-be/pom.xml b/common-be/pom.xml
index 025e3a9ec0..564f200bcc 100644
--- a/common-be/pom.xml
+++ b/common-be/pom.xml
@@ -55,6 +55,18 @@
</dependency>
<dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest</artifactId>
+ <version>${hamcrest.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest-library</artifactId>
+ <version>${hamcrest.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
@@ -72,6 +84,11 @@
<version>${tosca.datatype.version}</version>
</dependency>
<dependency>
+ <groupId>org.onap.sdc.sdc-tosca</groupId>
+ <artifactId>sdc-tosca</artifactId>
+ <version>${sdc-tosca-parser.version}</version>
+ </dependency>
+ <dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/config/NonManoArtifactType.java b/common-be/src/main/java/org/openecomp/sdc/be/config/NonManoArtifactType.java
new file mode 100644
index 0000000000..35917f88a7
--- /dev/null
+++ b/common-be/src/main/java/org/openecomp/sdc/be/config/NonManoArtifactType.java
@@ -0,0 +1,43 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.be.config;
+
+/**
+ * Stores non mano artifact types.
+ */
+public enum NonManoArtifactType {
+ ONAP_VES_EVENTS("onap_ves_events"),
+ ONAP_PM_DICTIONARY("onap_pm_dictionary"),
+ ONAP_YANG_MODULES("onap_yang_modules"),
+ ONAP_ANSIBLE_PLAYBOOKS("onap_ansible_playbooks"),
+ ONAP_SCRIPTS("onap_scripts"),
+ ONAP_OTHERS("onap_others"),
+ ONAP_SW_INFORMATION("onap_pnf_sw_information");
+
+ private final String type;
+
+ NonManoArtifactType(final String type) {
+ this.type = type;
+ }
+
+ public String getType() {
+ return type;
+ }
+}
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/config/NonManoConfiguration.java b/common-be/src/main/java/org/openecomp/sdc/be/config/NonManoConfiguration.java
new file mode 100644
index 0000000000..9471fed0fe
--- /dev/null
+++ b/common-be/src/main/java/org/openecomp/sdc/be/config/NonManoConfiguration.java
@@ -0,0 +1,42 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.be.config;
+
+import java.util.Map;
+
+import lombok.Data;
+
+/**
+ * Represents the non-mano configuration yaml.
+ */
+@Data
+public class NonManoConfiguration {
+ private Map<String, NonManoFolderType> nonManoKeyFolderMapping;
+
+ /**
+ * Gets the non mano folder type based on the non mano artifact type.
+ * @param nonManoArtifactType the artifact type
+ * @return
+ * The NonManoType for the artifact type
+ */
+ public NonManoFolderType getNonManoType(final NonManoArtifactType nonManoArtifactType) {
+ return nonManoKeyFolderMapping.get(nonManoArtifactType.getType());
+ }
+}
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/config/NonManoConfigurationManager.java b/common-be/src/main/java/org/openecomp/sdc/be/config/NonManoConfigurationManager.java
new file mode 100644
index 0000000000..028f16ab6e
--- /dev/null
+++ b/common-be/src/main/java/org/openecomp/sdc/be/config/NonManoConfigurationManager.java
@@ -0,0 +1,68 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.be.config;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
+import org.apache.commons.io.IOUtils;
+import org.onap.sdc.tosca.parser.utils.YamlToObjectConverter;
+import org.openecomp.sdc.be.config.exception.LoadConfigurationException;
+
+/**
+ * Singleton that loads and stores the Non Mano configuration
+ */
+public class NonManoConfigurationManager {
+ private static NonManoConfigurationManager nonManoConfigurationManager = null;
+ private NonManoConfiguration nonManoConfiguration;
+
+ private NonManoConfigurationManager() {
+ loadConfiguration();
+ }
+
+ /**
+ * Loads the configuration yaml from the resources.
+ */
+ private void loadConfiguration() {
+ final InputStream configYamlAsStream = getClass().getClassLoader().getResourceAsStream("config/nonManoConfig.yaml");
+ if (configYamlAsStream == null) {
+ throw new LoadConfigurationException("Expected non-mano configuration file 'config/nonManoConfig.yaml' not found in resources");
+ }
+ final String data;
+ try {
+ data = IOUtils.toString(configYamlAsStream, StandardCharsets.UTF_8);
+ } catch (final IOException e) {
+ throw new LoadConfigurationException("Could not parse non-mano configuration file 'config/nonManoConfig.yaml' to string", e);
+ }
+ nonManoConfiguration = new YamlToObjectConverter().convertFromString(data, NonManoConfiguration.class);
+ }
+
+ public static NonManoConfigurationManager getInstance() {
+ if (nonManoConfigurationManager == null) {
+ nonManoConfigurationManager = new NonManoConfigurationManager();
+ }
+
+ return nonManoConfigurationManager;
+ }
+
+ public NonManoConfiguration getNonManoConfiguration() {
+ return nonManoConfiguration;
+ }
+}
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/config/NonManoFolderType.java b/common-be/src/main/java/org/openecomp/sdc/be/config/NonManoFolderType.java
new file mode 100644
index 0000000000..4d815e3f57
--- /dev/null
+++ b/common-be/src/main/java/org/openecomp/sdc/be/config/NonManoFolderType.java
@@ -0,0 +1,35 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.openecomp.sdc.be.config;
+
+import lombok.Data;
+
+@Data
+public class NonManoFolderType {
+ private String location;
+ private String type;
+
+ /**
+ * Gets the expected folder path
+ * @return
+ */
+ public String getPath() {
+ return String.format("Artifacts/%s/%s", type, location);
+ }
+}
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/config/exception/LoadConfigurationException.java b/common-be/src/main/java/org/openecomp/sdc/be/config/exception/LoadConfigurationException.java
new file mode 100644
index 0000000000..53432a3490
--- /dev/null
+++ b/common-be/src/main/java/org/openecomp/sdc/be/config/exception/LoadConfigurationException.java
@@ -0,0 +1,31 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.be.config.exception;
+
+public class LoadConfigurationException extends RuntimeException {
+
+ public LoadConfigurationException(final String s) {
+ super(s);
+ }
+
+ public LoadConfigurationException(final String s, final Throwable throwable) {
+ super(s, throwable);
+ }
+}
diff --git a/common-be/src/main/resources/config/nonManoConfig.yaml b/common-be/src/main/resources/config/nonManoConfig.yaml
new file mode 100644
index 0000000000..4ace330392
--- /dev/null
+++ b/common-be/src/main/resources/config/nonManoConfig.yaml
@@ -0,0 +1,22 @@
+nonManoKeyFolderMapping:
+ onap_ves_events:
+ location: VES_EVENTS
+ type: Deployment
+ onap_pm_dictionary:
+ location: PM_DICTIONARY
+ type: Deployment
+ onap_yang_modules:
+ location: YANG_MODULE
+ type: Deployment
+ onap_ansible_playbooks:
+ location: ANSIBLE_PLAYBOOK
+ type: Deployment
+ onap_scripts:
+ location: SCRIPTS
+ type: Deployment
+ onap_others:
+ location: OTHER
+ type: Informational
+ onap_pnf_sw_information:
+ location: PNF_SW_INFORMATION
+ type: Informational \ No newline at end of file
diff --git a/common-be/src/test/java/org/openecomp/sdc/be/config/NonManoConfigurationManagerTest.java b/common-be/src/test/java/org/openecomp/sdc/be/config/NonManoConfigurationManagerTest.java
new file mode 100644
index 0000000000..bbe8623ed8
--- /dev/null
+++ b/common-be/src/test/java/org/openecomp/sdc/be/config/NonManoConfigurationManagerTest.java
@@ -0,0 +1,50 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.be.config;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.hamcrest.Matchers.anEmptyMap;
+import static org.junit.Assert.assertThat;
+
+import org.junit.Test;
+
+public class NonManoConfigurationManagerTest {
+
+ @Test
+ public void getInstance() {
+ final NonManoConfigurationManager instance = NonManoConfigurationManager.getInstance();
+ assertThat("Singleton instance should never be null", instance, is(notNullValue()));
+ }
+
+ @Test
+ public void getNonManoConfiguration() {
+ final NonManoConfiguration nonManoConfiguration = NonManoConfigurationManager.getInstance()
+ .getNonManoConfiguration();
+ assertThat("NonManoConfiguration instance should never be null", nonManoConfiguration, is(notNullValue()));
+ assertThat("NonManoConfiguration FolderMapping configuration should no be empty",
+ nonManoConfiguration.getNonManoKeyFolderMapping(), is(not(anEmptyMap())));
+
+ for (final NonManoArtifactType value : NonManoArtifactType.values()) {
+ assertThat(String.format("Expected %s value should not be null", value), nonManoConfiguration.getNonManoType(value), is(notNullValue()));
+ }
+ }
+} \ No newline at end of file