diff options
author | andre.schmid <andre.schmid@est.tech> | 2019-10-08 18:27:36 +0100 |
---|---|---|
committer | Ofir Sonsino <ofir.sonsino@intl.att.com> | 2019-11-20 17:23:14 +0000 |
commit | 13af621442b4c74d9e63ede8e42dbae48aaa64c9 (patch) | |
tree | 93b192acc70f6b9eed7fba41402bf33bf9970442 /common-be/src/main/java/org/openecomp | |
parent | 86655742cf36bdc056837f5b74bc32c58201a600 (diff) |
Onboard PNF software version
Change-Id: Id9e32e01f6c2f4c39c8ff10816d982cbb3063bf7
Issue-ID: SDC-2589
Signed-off-by: andre.schmid <andre.schmid@est.tech>
Diffstat (limited to 'common-be/src/main/java/org/openecomp')
5 files changed, 219 insertions, 0 deletions
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); + } +} |