diff options
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-vendor-software-product-lib')
198 files changed, 5595 insertions, 7086 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VendorSoftwareProductConstants.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VendorSoftwareProductConstants.java index 220d7f4d15..86c1bd1895 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VendorSoftwareProductConstants.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VendorSoftwareProductConstants.java @@ -17,26 +17,27 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct; public final class VendorSoftwareProductConstants { - public static final String VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE = "VendorSoftwareProduct"; - public static final String VSP_PACKAGE_ZIP = "VSPPackage.zip"; - public static final String CSAR = "CSAR"; - public static final String INFORMATION_ARTIFACT_NAME = "VSP_%s_Information.txt"; - public static final String NAME_PATTERN = "^[a-zA-Z0-9_]*$"; - public final class UniqueValues { - public static final String VENDOR_SOFTWARE_PRODUCT_NAME = "Vendor Software Product name"; - public static final String PROCESS_NAME = "Process name"; - public static final String NETWORK_NAME = "Network name"; - public static final String COMPONENT_NAME = "ComponentData name"; - public static final String NIC_NAME = "NIC name"; - public static final String COMPUTE_NAME = "Compute name"; - public static final String ORCHESTRATION_CANDIDATE_NAME = "Orchestration Candidate name"; - //public static final String COMPONENT_ARTIFACT_NAME = "ComponentArtifact name"; - public static final String DEPLOYMENT_FLAVOR_NAME = "Deployment Flavor name"; - public static final String IMAGE_NAME = "Image name"; - } + public static final String VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE = "VendorSoftwareProduct"; + public static final String VSP_PACKAGE_ZIP = "VSPPackage.zip"; + public static final String CSAR = "CSAR"; + public static final String INFORMATION_ARTIFACT_NAME = "VSP_%s_Information.txt"; + public static final String NAME_PATTERN = "^[a-zA-Z0-9_]*$"; + + public final class UniqueValues { + + public static final String VENDOR_SOFTWARE_PRODUCT_NAME = "Vendor Software Product name"; + public static final String PROCESS_NAME = "Process name"; + public static final String NETWORK_NAME = "Network name"; + public static final String COMPONENT_NAME = "ComponentData name"; + public static final String NIC_NAME = "NIC name"; + public static final String COMPUTE_NAME = "Compute name"; + public static final String ORCHESTRATION_CANDIDATE_NAME = "Orchestration Candidate name"; + //public static final String COMPONENT_ARTIFACT_NAME = "ComponentArtifact name"; + public static final String DEPLOYMENT_FLAVOR_NAME = "Deployment Flavor name"; + public static final String IMAGE_NAME = "Image name"; + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ComponentArtifactDao.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ComponentArtifactDao.java index 88b5964114..55df02e29a 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ComponentArtifactDao.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ComponentArtifactDao.java @@ -7,9 +7,9 @@ * 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. @@ -17,28 +17,24 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao; -import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentMonitoringUploadEntity; -import org.openecomp.sdc.versioning.dao.VersionableDao; - import java.util.Collection; import java.util.Optional; - +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentMonitoringUploadEntity; +import org.openecomp.sdc.versioning.dao.VersionableDao; public interface ComponentArtifactDao extends VersionableDao { - Optional<ComponentMonitoringUploadEntity> getByType(ComponentMonitoringUploadEntity entity); + Optional<ComponentMonitoringUploadEntity> getByType(ComponentMonitoringUploadEntity entity); - void create(ComponentMonitoringUploadEntity entity); + void create(ComponentMonitoringUploadEntity entity); - void delete(ComponentMonitoringUploadEntity entity); + void delete(ComponentMonitoringUploadEntity entity); - Collection<ComponentMonitoringUploadEntity> list(ComponentMonitoringUploadEntity entity); + Collection<ComponentMonitoringUploadEntity> list(ComponentMonitoringUploadEntity entity); - void deleteAll(ComponentMonitoringUploadEntity entity); + void deleteAll(ComponentMonitoringUploadEntity entity); - Collection<ComponentMonitoringUploadEntity> listArtifacts( - ComponentMonitoringUploadEntity entity); + Collection<ComponentMonitoringUploadEntity> listArtifacts(ComponentMonitoringUploadEntity entity); } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ComponentDao.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ComponentDao.java index ef3f2f131d..acc2dbf46d 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ComponentDao.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ComponentDao.java @@ -7,9 +7,9 @@ * 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. @@ -17,26 +17,23 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao; +import java.util.Collection; import org.openecomp.core.dao.BaseDao; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity; import org.openecomp.sdc.versioning.dao.VersionableDao; import org.openecomp.sdc.versioning.dao.types.Version; -import java.util.Collection; - public interface ComponentDao extends VersionableDao, BaseDao<ComponentEntity> { - ComponentEntity getQuestionnaireData(String vspId, Version version, String componentId); + ComponentEntity getQuestionnaireData(String vspId, Version version, String componentId); - void updateQuestionnaireData(String vspId, Version version, String componentId, - String questionnaireData); + void updateQuestionnaireData(String vspId, Version version, String componentId, String questionnaireData); - Collection<ComponentEntity> listQuestionnaires(String vspId, Version version); + Collection<ComponentEntity> listQuestionnaires(String vspId, Version version); - Collection<ComponentEntity> listCompositionAndQuestionnaire(String vspId, Version version); + Collection<ComponentEntity> listCompositionAndQuestionnaire(String vspId, Version version); - void deleteAll(String vspId, Version version); + void deleteAll(String vspId, Version version); } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ComponentDaoFactory.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ComponentDaoFactory.java index e1cf30bfb1..81fc4724eb 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ComponentDaoFactory.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ComponentDaoFactory.java @@ -7,9 +7,9 @@ * 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. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao; import org.openecomp.core.factory.api.AbstractComponentFactory; @@ -25,7 +24,7 @@ import org.openecomp.core.factory.api.AbstractFactory; public abstract class ComponentDaoFactory extends AbstractComponentFactory<ComponentDao> { - public static ComponentDaoFactory getInstance() { - return AbstractFactory.getInstance(ComponentDaoFactory.class); - } + public static ComponentDaoFactory getInstance() { + return AbstractFactory.getInstance(ComponentDaoFactory.class); + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ComponentDependencyModelDao.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ComponentDependencyModelDao.java index a35c8b0000..4d0de55b90 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ComponentDependencyModelDao.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ComponentDependencyModelDao.java @@ -7,9 +7,9 @@ * 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. @@ -17,13 +17,12 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao; import org.openecomp.core.dao.BaseDao; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity; import org.openecomp.sdc.versioning.dao.VersionableDao; -public interface ComponentDependencyModelDao extends VersionableDao, - BaseDao<ComponentDependencyModelEntity> { +public interface ComponentDependencyModelDao extends VersionableDao, BaseDao<ComponentDependencyModelEntity> { + } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ComponentDependencyModelDaoFactory.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ComponentDependencyModelDaoFactory.java index d347426c86..09c5db22b6 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ComponentDependencyModelDaoFactory.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ComponentDependencyModelDaoFactory.java @@ -7,9 +7,9 @@ * 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. @@ -17,17 +17,14 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao; - import org.openecomp.core.factory.api.AbstractComponentFactory; import org.openecomp.core.factory.api.AbstractFactory; -public abstract class ComponentDependencyModelDaoFactory extends - AbstractComponentFactory<ComponentDependencyModelDao> { +public abstract class ComponentDependencyModelDaoFactory extends AbstractComponentFactory<ComponentDependencyModelDao> { - public static ComponentDependencyModelDaoFactory getInstance() { - return AbstractFactory.getInstance(ComponentDependencyModelDaoFactory.class); - } + public static ComponentDependencyModelDaoFactory getInstance() { + return AbstractFactory.getInstance(ComponentDependencyModelDaoFactory.class); + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ComputeDao.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ComputeDao.java index 1ddb0129d2..4f7f5fdde7 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ComputeDao.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ComputeDao.java @@ -7,9 +7,9 @@ * 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. @@ -17,25 +17,21 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao; +import java.util.Collection; import org.openecomp.core.dao.BaseDao; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComputeEntity; import org.openecomp.sdc.versioning.dao.VersionableDao; import org.openecomp.sdc.versioning.dao.types.Version; -import java.util.Collection; - public interface ComputeDao extends VersionableDao, BaseDao<ComputeEntity> { - Collection<ComputeEntity> listByVsp(String vspId, Version version); + Collection<ComputeEntity> listByVsp(String vspId, Version version); + void updateQuestionnaireData(String vspId, Version version, String componentId, String computeId, String questionnaireData); - void updateQuestionnaireData(String vspId, Version version, String componentId, String computeId, - String questionnaireData); - void deleteAll(String vspId, Version version); + void deleteAll(String vspId, Version version); - ComputeEntity getQuestionnaireData(String vspId, Version version, String componentId, - String computeId); + ComputeEntity getQuestionnaireData(String vspId, Version version, String componentId, String computeId); } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ComputeDaoFactory.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ComputeDaoFactory.java index 951ae00c95..78a5cddcf0 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ComputeDaoFactory.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ComputeDaoFactory.java @@ -7,9 +7,9 @@ * 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. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao; import org.openecomp.core.factory.api.AbstractComponentFactory; @@ -25,8 +24,7 @@ import org.openecomp.core.factory.api.AbstractFactory; public abstract class ComputeDaoFactory extends AbstractComponentFactory<ComputeDao> { - - public static ComputeDaoFactory getInstance() { - return AbstractFactory.getInstance(ComputeDaoFactory.class); - } + public static ComputeDaoFactory getInstance() { + return AbstractFactory.getInstance(ComputeDaoFactory.class); + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/DeploymentFlavorDao.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/DeploymentFlavorDao.java index 1a3313ae60..ef96dc98e6 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/DeploymentFlavorDao.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/DeploymentFlavorDao.java @@ -7,9 +7,9 @@ * 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. @@ -17,16 +17,14 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao; - import org.openecomp.core.dao.BaseDao; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity; import org.openecomp.sdc.versioning.dao.VersionableDao; import org.openecomp.sdc.versioning.dao.types.Version; public interface DeploymentFlavorDao extends VersionableDao, BaseDao<DeploymentFlavorEntity> { - void deleteAll(String vspId, Version version); -} + void deleteAll(String vspId, Version version); +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/DeploymentFlavorDaoFactory.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/DeploymentFlavorDaoFactory.java index a94afa2eae..9d70e594b1 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/DeploymentFlavorDaoFactory.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/DeploymentFlavorDaoFactory.java @@ -7,9 +7,9 @@ * 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. @@ -17,14 +17,13 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao; - import org.openecomp.core.factory.api.AbstractComponentFactory; import org.openecomp.core.factory.api.AbstractFactory; public abstract class DeploymentFlavorDaoFactory extends AbstractComponentFactory<DeploymentFlavorDao> { + public static DeploymentFlavorDaoFactory getInstance() { return AbstractFactory.getInstance(DeploymentFlavorDaoFactory.class); } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ImageDao.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ImageDao.java index ab1efd3b66..d707cecae7 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ImageDao.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ImageDao.java @@ -7,9 +7,9 @@ * 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. @@ -17,27 +17,21 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao; - +import java.util.Collection; import org.openecomp.core.dao.BaseDao; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ImageEntity; import org.openecomp.sdc.versioning.dao.VersionableDao; import org.openecomp.sdc.versioning.dao.types.Version; -import java.util.Collection; - public interface ImageDao extends VersionableDao, BaseDao<ImageEntity> { - void updateQuestionnaireData(String vspId, Version version, String componentId, String imageId, - String questionnaireData); - + void updateQuestionnaireData(String vspId, Version version, String componentId, String imageId, String questionnaireData); - void deleteByVspId(String vspId, Version version); + void deleteByVspId(String vspId, Version version); - Collection<ImageEntity> listByVsp(String vspId, Version version); + Collection<ImageEntity> listByVsp(String vspId, Version version); - ImageEntity getQuestionnaireData(String vspId, Version version, String componentId, - String imageId); + ImageEntity getQuestionnaireData(String vspId, Version version, String componentId, String imageId); } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ImageDaoFactory.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ImageDaoFactory.java index e6eda24450..f49169b785 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ImageDaoFactory.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ImageDaoFactory.java @@ -7,9 +7,9 @@ * 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. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao; import org.openecomp.core.factory.api.AbstractComponentFactory; @@ -25,7 +24,7 @@ import org.openecomp.core.factory.api.AbstractFactory; public abstract class ImageDaoFactory extends AbstractComponentFactory<ImageDao> { - public static ImageDaoFactory getInstance() { - return AbstractFactory.getInstance(ImageDaoFactory.class); - } + public static ImageDaoFactory getInstance() { + return AbstractFactory.getInstance(ImageDaoFactory.class); + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/MonitoringUploadDaoFactory.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/MonitoringUploadDaoFactory.java index b70b1a5245..9493295333 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/MonitoringUploadDaoFactory.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/MonitoringUploadDaoFactory.java @@ -7,9 +7,9 @@ * 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. @@ -17,16 +17,14 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao; import org.openecomp.core.factory.api.AbstractComponentFactory; import org.openecomp.core.factory.api.AbstractFactory; -public abstract class MonitoringUploadDaoFactory - extends AbstractComponentFactory<ComponentArtifactDao> { +public abstract class MonitoringUploadDaoFactory extends AbstractComponentFactory<ComponentArtifactDao> { - public static MonitoringUploadDaoFactory getInstance() { - return AbstractFactory.getInstance(MonitoringUploadDaoFactory.class); - } + public static MonitoringUploadDaoFactory getInstance() { + return AbstractFactory.getInstance(MonitoringUploadDaoFactory.class); + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/NetworkDao.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/NetworkDao.java index da57b0a2b4..1736727ed3 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/NetworkDao.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/NetworkDao.java @@ -7,9 +7,9 @@ * 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. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao; import org.openecomp.core.dao.BaseDao; @@ -27,15 +26,5 @@ import org.openecomp.sdc.versioning.dao.types.Version; public interface NetworkDao extends VersionableDao, BaseDao<NetworkEntity> { - - - void deleteAll(String vspId, Version version); - - - - - - - - + void deleteAll(String vspId, Version version); } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/NetworkDaoFactory.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/NetworkDaoFactory.java index 8db3d605e4..547cf037fc 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/NetworkDaoFactory.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/NetworkDaoFactory.java @@ -7,9 +7,9 @@ * 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. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao; import org.openecomp.core.factory.api.AbstractComponentFactory; @@ -25,7 +24,7 @@ import org.openecomp.core.factory.api.AbstractFactory; public abstract class NetworkDaoFactory extends AbstractComponentFactory<NetworkDao> { - public static NetworkDaoFactory getInstance() { - return AbstractFactory.getInstance(NetworkDaoFactory.class); - } + public static NetworkDaoFactory getInstance() { + return AbstractFactory.getInstance(NetworkDaoFactory.class); + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/NicDao.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/NicDao.java index 3205fcdb1f..83f6f3954e 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/NicDao.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/NicDao.java @@ -7,9 +7,9 @@ * 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. @@ -17,27 +17,23 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao; +import java.util.Collection; import org.openecomp.core.dao.BaseDao; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity; import org.openecomp.sdc.versioning.dao.VersionableDao; import org.openecomp.sdc.versioning.dao.types.Version; -import java.util.Collection; - public interface NicDao extends VersionableDao, BaseDao<NicEntity> { - NicEntity getQuestionnaireData(String vspId, Version version, String componentId, - String nicId); + NicEntity getQuestionnaireData(String vspId, Version version, String componentId, String nicId); - void updateQuestionnaireData(String vspId, Version version, String componentId, String nicId, - String questionnaireData); + void updateQuestionnaireData(String vspId, Version version, String componentId, String nicId, String questionnaireData); - Collection<NicEntity> listByVsp(String vspId, Version version); + Collection<NicEntity> listByVsp(String vspId, Version version); - void deleteByComponentId(String vspId, Version version, String componentId); + void deleteByComponentId(String vspId, Version version, String componentId); - void deleteByVspId(String vspId, Version version); + void deleteByVspId(String vspId, Version version); } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/NicDaoFactory.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/NicDaoFactory.java index b61ad6a3ca..24ebc22d12 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/NicDaoFactory.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/NicDaoFactory.java @@ -7,9 +7,9 @@ * 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. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao; import org.openecomp.core.factory.api.AbstractComponentFactory; @@ -25,7 +24,7 @@ import org.openecomp.core.factory.api.AbstractFactory; public abstract class NicDaoFactory extends AbstractComponentFactory<NicDao> { - public static NicDaoFactory getInstance() { - return AbstractFactory.getInstance(NicDaoFactory.class); - } + public static NicDaoFactory getInstance() { + return AbstractFactory.getInstance(NicDaoFactory.class); + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/OrchestrationTemplateCandidateDao.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/OrchestrationTemplateCandidateDao.java index c44ee307b4..8049717cd5 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/OrchestrationTemplateCandidateDao.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/OrchestrationTemplateCandidateDao.java @@ -13,32 +13,28 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.openecomp.sdc.vendorsoftwareproduct.dao; +import java.util.Optional; import org.openecomp.sdc.heat.datatypes.structure.ValidationStructureList; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateCandidateData; import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.FilesDataStructure; import org.openecomp.sdc.versioning.dao.VersionableDao; import org.openecomp.sdc.versioning.dao.types.Version; -import java.util.Optional; - public interface OrchestrationTemplateCandidateDao extends VersionableDao { - Optional<OrchestrationTemplateCandidateData> get(String vspId, Version version); + Optional<OrchestrationTemplateCandidateData> get(String vspId, Version version); - Optional<OrchestrationTemplateCandidateData> getInfo(String vspId, Version version); + Optional<OrchestrationTemplateCandidateData> getInfo(String vspId, Version version); - void delete(String vspId, Version version); + void delete(String vspId, Version version); - void update(String vspId, Version version, OrchestrationTemplateCandidateData candidateData); + void update(String vspId, Version version, OrchestrationTemplateCandidateData candidateData); - void updateStructure(String vspId, Version version, FilesDataStructure fileDataStructure); + void updateStructure(String vspId, Version version, FilesDataStructure fileDataStructure); - Optional<String> getStructure(String vspId, Version version); + Optional<String> getStructure(String vspId, Version version); - void updateValidationData(String vspId, Version version, ValidationStructureList - validationData); + void updateValidationData(String vspId, Version version, ValidationStructureList validationData); } - diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/OrchestrationTemplateCandidateDaoFactory.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/OrchestrationTemplateCandidateDaoFactory.java index 5624da018a..f8c91a9652 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/OrchestrationTemplateCandidateDaoFactory.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/OrchestrationTemplateCandidateDaoFactory.java @@ -7,9 +7,9 @@ * 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. @@ -17,16 +17,14 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao; import org.openecomp.core.factory.api.AbstractComponentFactory; import org.openecomp.core.factory.api.AbstractFactory; -public abstract class OrchestrationTemplateCandidateDaoFactory - extends AbstractComponentFactory<OrchestrationTemplateCandidateDao> { +public abstract class OrchestrationTemplateCandidateDaoFactory extends AbstractComponentFactory<OrchestrationTemplateCandidateDao> { - public static OrchestrationTemplateCandidateDaoFactory getInstance() { - return AbstractFactory.getInstance(OrchestrationTemplateCandidateDaoFactory.class); - } + public static OrchestrationTemplateCandidateDaoFactory getInstance() { + return AbstractFactory.getInstance(OrchestrationTemplateCandidateDaoFactory.class); + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/OrchestrationTemplateDao.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/OrchestrationTemplateDao.java index ddee436331..22eae51af7 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/OrchestrationTemplateDao.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/OrchestrationTemplateDao.java @@ -13,23 +13,20 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.openecomp.sdc.vendorsoftwareproduct.dao; +import java.util.Optional; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateEntity; import org.openecomp.sdc.versioning.dao.VersionableDao; import org.openecomp.sdc.versioning.dao.types.Version; -import java.util.Optional; - public interface OrchestrationTemplateDao extends VersionableDao { - OrchestrationTemplateEntity getInfo(String vspId, Version version); + OrchestrationTemplateEntity getInfo(String vspId, Version version); - OrchestrationTemplateEntity get(String vspId, Version version); + OrchestrationTemplateEntity get(String vspId, Version version); - void update(String vspId, Version version, OrchestrationTemplateEntity uploadData); + void update(String vspId, Version version, OrchestrationTemplateEntity uploadData); - Optional<String> getOrchestrationTemplateStructure(String vspId, Version version); + Optional<String> getOrchestrationTemplateStructure(String vspId, Version version); } - diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/OrchestrationTemplateDaoFactory.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/OrchestrationTemplateDaoFactory.java index be3c849a20..a73355bebe 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/OrchestrationTemplateDaoFactory.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/OrchestrationTemplateDaoFactory.java @@ -7,9 +7,9 @@ * 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. @@ -17,16 +17,14 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao; import org.openecomp.core.factory.api.AbstractComponentFactory; import org.openecomp.core.factory.api.AbstractFactory; -public abstract class OrchestrationTemplateDaoFactory - extends AbstractComponentFactory<OrchestrationTemplateDao> { +public abstract class OrchestrationTemplateDaoFactory extends AbstractComponentFactory<OrchestrationTemplateDao> { - public static OrchestrationTemplateDaoFactory getInstance() { - return AbstractFactory.getInstance(OrchestrationTemplateDaoFactory.class); - } + public static OrchestrationTemplateDaoFactory getInstance() { + return AbstractFactory.getInstance(OrchestrationTemplateDaoFactory.class); + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/PackageInfoDao.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/PackageInfoDao.java index 36fff1e534..a2b1c9c8ae 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/PackageInfoDao.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/PackageInfoDao.java @@ -7,9 +7,9 @@ * 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. @@ -17,14 +17,13 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao; +import java.util.List; import org.openecomp.core.dao.BaseDao; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.PackageInfo; -import java.util.List; - public interface PackageInfoDao extends BaseDao<PackageInfo> { - List<PackageInfo> listByCategory(String category, String subCategory); + + List<PackageInfo> listByCategory(String category, String subCategory); } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/PackageInfoDaoFactory.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/PackageInfoDaoFactory.java index a8e3d6563d..6f617ddd0c 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/PackageInfoDaoFactory.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/PackageInfoDaoFactory.java @@ -7,9 +7,9 @@ * 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. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao; import org.openecomp.core.factory.api.AbstractComponentFactory; @@ -25,7 +24,7 @@ import org.openecomp.core.factory.api.AbstractFactory; public abstract class PackageInfoDaoFactory extends AbstractComponentFactory<PackageInfoDao> { - public static PackageInfoDaoFactory getInstance() { - return AbstractFactory.getInstance(PackageInfoDaoFactory.class); - } + public static PackageInfoDaoFactory getInstance() { + return AbstractFactory.getInstance(PackageInfoDaoFactory.class); + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ProcessDao.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ProcessDao.java index 83eab91ea6..8e1a826d8b 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ProcessDao.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ProcessDao.java @@ -7,9 +7,9 @@ * 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. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao; import org.openecomp.core.dao.BaseDao; @@ -30,13 +29,14 @@ import org.openecomp.sdc.versioning.dao.types.Version; * @since March 23, 2017 */ public interface ProcessDao extends VersionableDao, BaseDao<ProcessEntity> { - void deleteAll(ProcessEntity entity); - void deleteVspAll(String vspId, Version version); + void deleteAll(ProcessEntity entity); + + void deleteVspAll(String vspId, Version version); - ProcessEntity getArtifact(ProcessEntity entity); + ProcessEntity getArtifact(ProcessEntity entity); - void uploadArtifact(ProcessEntity entity); + void uploadArtifact(ProcessEntity entity); - void deleteArtifact(ProcessEntity entity); + void deleteArtifact(ProcessEntity entity); } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ProcessDaoFactory.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ProcessDaoFactory.java index f661a0ccda..59105981f5 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ProcessDaoFactory.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ProcessDaoFactory.java @@ -7,9 +7,9 @@ * 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. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao; import org.openecomp.core.factory.api.AbstractComponentFactory; @@ -25,7 +24,7 @@ import org.openecomp.core.factory.api.AbstractFactory; public abstract class ProcessDaoFactory extends AbstractComponentFactory<ProcessDao> { - public static ProcessDaoFactory getInstance() { - return AbstractFactory.getInstance(ProcessDaoFactory.class); - } + public static ProcessDaoFactory getInstance() { + return AbstractFactory.getInstance(ProcessDaoFactory.class); + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VendorSoftwareProductInfoDao.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VendorSoftwareProductInfoDao.java index c44a9cd89e..442b6043d5 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VendorSoftwareProductInfoDao.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VendorSoftwareProductInfoDao.java @@ -7,9 +7,9 @@ * 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. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao; import org.openecomp.core.dao.BaseDao; @@ -28,9 +27,9 @@ import org.openecomp.sdc.versioning.dao.types.Version; public interface VendorSoftwareProductInfoDao extends VersionableDao, BaseDao<VspDetails> { - void updateQuestionnaireData(String vspId, Version version, String questionnaireData); + void updateQuestionnaireData(String vspId, Version version, String questionnaireData); - VspQuestionnaireEntity getQuestionnaire(String vspId, Version version); + VspQuestionnaireEntity getQuestionnaire(String vspId, Version version); - boolean isManual(String vspId, Version version); + boolean isManual(String vspId, Version version); } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VendorSoftwareProductInfoDaoFactory.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VendorSoftwareProductInfoDaoFactory.java index 570ddc496e..0c10698f0b 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VendorSoftwareProductInfoDaoFactory.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VendorSoftwareProductInfoDaoFactory.java @@ -7,9 +7,9 @@ * 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. @@ -17,16 +17,14 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao; import org.openecomp.core.factory.api.AbstractComponentFactory; import org.openecomp.core.factory.api.AbstractFactory; -public abstract class VendorSoftwareProductInfoDaoFactory - extends AbstractComponentFactory<VendorSoftwareProductInfoDao> { +public abstract class VendorSoftwareProductInfoDaoFactory extends AbstractComponentFactory<VendorSoftwareProductInfoDao> { - public static VendorSoftwareProductInfoDaoFactory getInstance() { - return AbstractFactory.getInstance(VendorSoftwareProductInfoDaoFactory.class); - } + public static VendorSoftwareProductInfoDaoFactory getInstance() { + return AbstractFactory.getInstance(VendorSoftwareProductInfoDaoFactory.class); + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VspMergeDao.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VspMergeDao.java index fbe99b7a79..4c7b1340e6 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VspMergeDao.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VspMergeDao.java @@ -7,9 +7,9 @@ * 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. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao; import com.amdocs.zusammen.datatypes.item.Resolution; @@ -25,14 +24,14 @@ import org.openecomp.sdc.versioning.dao.types.Version; public interface VspMergeDao { - boolean isConflicted(String vspId, Version version); + boolean isConflicted(String vspId, Version version); - void updateHint(String vspId, Version version); + void updateHint(String vspId, Version version); - void deleteHint(String vspId, Version version); + void deleteHint(String vspId, Version version); - // TODO: 11/7/2017 change to sdc Resolution - void updateConflictResolution(String vspId, Version version, Resolution resolution); + // TODO: 11/7/2017 change to sdc Resolution + void updateConflictResolution(String vspId, Version version, Resolution resolution); - void applyConflictResolution(String vspId, Version version); + void applyConflictResolution(String vspId, Version version); } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VspMergeDaoFactory.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VspMergeDaoFactory.java index 84f021c9e3..92ddee756b 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VspMergeDaoFactory.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VspMergeDaoFactory.java @@ -7,9 +7,9 @@ * 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. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao; import org.openecomp.core.factory.api.AbstractComponentFactory; @@ -25,7 +24,7 @@ import org.openecomp.core.factory.api.AbstractFactory; public abstract class VspMergeDaoFactory extends AbstractComponentFactory<VspMergeDao> { - public static VspMergeDaoFactory getInstance() { - return AbstractFactory.getInstance(VspMergeDaoFactory.class); - } + public static VspMergeDaoFactory getInstance() { + return AbstractFactory.getInstance(VspMergeDaoFactory.class); + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VspQuestionnaireDao.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VspQuestionnaireDao.java index 4658f71d2a..dbac6f398c 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VspQuestionnaireDao.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VspQuestionnaireDao.java @@ -7,9 +7,9 @@ * 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. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspQuestionnaireEntity; @@ -26,7 +25,7 @@ import org.openecomp.sdc.versioning.dao.types.Version; public interface VspQuestionnaireDao extends VersionableDao { - VspQuestionnaireEntity get(VspQuestionnaireEntity entity); + VspQuestionnaireEntity get(VspQuestionnaireEntity entity); - void updateQuestionnaireData(String id, Version version, String questionnaireData); + void updateQuestionnaireData(String id, Version version, String questionnaireData); } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VspQuestionnaireDaoFactory.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VspQuestionnaireDaoFactory.java index afc3dc9649..90d0d448b1 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VspQuestionnaireDaoFactory.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VspQuestionnaireDaoFactory.java @@ -7,9 +7,9 @@ * 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. @@ -17,16 +17,14 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao; import org.openecomp.core.factory.api.AbstractComponentFactory; import org.openecomp.core.factory.api.AbstractFactory; -public abstract class VspQuestionnaireDaoFactory - extends AbstractComponentFactory<VspQuestionnaireDao> { +public abstract class VspQuestionnaireDaoFactory extends AbstractComponentFactory<VspQuestionnaireDao> { - public static VspQuestionnaireDaoFactory getInstance() { - return AbstractFactory.getInstance(VspQuestionnaireDaoFactory.class); - } + public static VspQuestionnaireDaoFactory getInstance() { + return AbstractFactory.getInstance(VspQuestionnaireDaoFactory.class); + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/Action.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/Action.java index be78e78f5a..905c094c72 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/Action.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/Action.java @@ -7,9 +7,9 @@ * 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. @@ -17,12 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.type; - -public enum Action { - CREATE_PACKAGE, - CHECK_IN, - CHECK_OUT -} +public enum Action {CREATE_PACKAGE, CHECK_IN, CHECK_OUT} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/ComponentDependencyModelEntity.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/ComponentDependencyModelEntity.java index dfdc0bc0c6..ce08ce6e14 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/ComponentDependencyModelEntity.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/ComponentDependencyModelEntity.java @@ -7,9 +7,9 @@ * 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. @@ -17,10 +17,13 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.type; -import com.datastax.driver.mapping.annotations.*; +import com.datastax.driver.mapping.annotations.ClusteringColumn; +import com.datastax.driver.mapping.annotations.Column; +import com.datastax.driver.mapping.annotations.Frozen; +import com.datastax.driver.mapping.annotations.PartitionKey; +import com.datastax.driver.mapping.annotations.Table; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NoArgsConstructor; @@ -35,44 +38,43 @@ import org.openecomp.sdc.versioning.dao.types.VersionableEntity; @Table(keyspace = "dox", name = "vsp_component_dependency_model") public class ComponentDependencyModelEntity implements VersionableEntity { - public static final String ENTITY_TYPE = "Vendor Software Product Component Dependency Model"; - @PartitionKey - @Column(name = "vsp_id") - private String vspId; - @PartitionKey(value = 1) - @Frozen - private Version version; - @ClusteringColumn - @Column(name = "dependency_id") - private String id; - @Column(name = "sourcecomponent_id") - private String sourceComponentId; - @Column(name = "targetcomponent_id") - private String targetComponentId; - @Column(name = "relation") - private String relation; - + public static final String ENTITY_TYPE = "Vendor Software Product Component Dependency Model"; + @PartitionKey + @Column(name = "vsp_id") + private String vspId; + @PartitionKey(value = 1) + @Frozen + private Version version; + @ClusteringColumn + @Column(name = "dependency_id") + private String id; + @Column(name = "sourcecomponent_id") + private String sourceComponentId; + @Column(name = "targetcomponent_id") + private String targetComponentId; + @Column(name = "relation") + private String relation; - /** - * Instantiates a new ComponentDependencyModelEntity entity. - * - * @param vspId the vsp id - * @param version the version - * @param dependencyId the dependencyId - */ - public ComponentDependencyModelEntity(String vspId, Version version, String dependencyId) { - this.vspId = vspId; - this.version = version; - this.id = dependencyId; - } + /** + * Instantiates a new ComponentDependencyModelEntity entity. + * + * @param vspId the vsp id + * @param version the version + * @param dependencyId the dependencyId + */ + public ComponentDependencyModelEntity(String vspId, Version version, String dependencyId) { + this.vspId = vspId; + this.version = version; + this.id = dependencyId; + } - @Override - public String getEntityType() { - return ENTITY_TYPE; - } + @Override + public String getEntityType() { + return ENTITY_TYPE; + } - @Override - public String getFirstClassCitizenId() { - return getVspId(); - } + @Override + public String getFirstClassCitizenId() { + return getVspId(); + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/ComponentEntity.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/ComponentEntity.java index 18c4d949ab..7a69cff27d 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/ComponentEntity.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/ComponentEntity.java @@ -17,10 +17,16 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.type; -import com.datastax.driver.mapping.annotations.*; +import com.datastax.driver.mapping.annotations.ClusteringColumn; +import com.datastax.driver.mapping.annotations.Column; +import com.datastax.driver.mapping.annotations.Frozen; +import com.datastax.driver.mapping.annotations.PartitionKey; +import com.datastax.driver.mapping.annotations.Table; +import com.datastax.driver.mapping.annotations.Transient; +import java.util.ArrayList; +import java.util.List; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NoArgsConstructor; @@ -31,72 +37,68 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEnti import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityType; import org.openecomp.sdc.versioning.dao.types.Version; -import java.util.ArrayList; -import java.util.List; - @EqualsAndHashCode @Getter @Setter @NoArgsConstructor @Table(keyspace = "dox", name = "vsp_component") public class ComponentEntity implements CompositionEntity { - public static final String ENTITY_TYPE = "Vendor Software Product Component"; - @PartitionKey - @Column(name = "vsp_id") - private String vspId; - @PartitionKey(value = 1) - @Frozen - private Version version; - @ClusteringColumn - @Column(name = "component_id") - private String id; - @Column(name = "composition_data") - private String compositionData; - @Column(name = "questionnaire_data") - private String questionnaireData; - @Transient - private List<NicEntity> nics = new ArrayList<>(); + public static final String ENTITY_TYPE = "Vendor Software Product Component"; + @PartitionKey + @Column(name = "vsp_id") + private String vspId; + @PartitionKey(value = 1) + @Frozen + private Version version; + @ClusteringColumn + @Column(name = "component_id") + private String id; + @Column(name = "composition_data") + private String compositionData; + @Column(name = "questionnaire_data") + private String questionnaireData; + @Transient + private List<NicEntity> nics = new ArrayList<>(); - /** - * Instantiates a new Component entity. - * - * @param vspId the vsp id - * @param version the version - * @param id the id - */ - public ComponentEntity(String vspId, Version version, String id) { - this.vspId = vspId; - this.version = version; - this.id = id; - } + /** + * Instantiates a new Component entity. + * + * @param vspId the vsp id + * @param version the version + * @param id the id + */ + public ComponentEntity(String vspId, Version version, String id) { + this.vspId = vspId; + this.version = version; + this.id = id; + } - @Override - public CompositionEntityType getType() { - return CompositionEntityType.component; - } + @Override + public CompositionEntityType getType() { + return CompositionEntityType.component; + } - @Override - public CompositionEntityId getCompositionEntityId() { - return new CompositionEntityId(getId(), new CompositionEntityId(getVspId(), null)); - } + @Override + public CompositionEntityId getCompositionEntityId() { + return new CompositionEntityId(getId(), new CompositionEntityId(getVspId(), null)); + } - @Override - public String getEntityType() { - return ENTITY_TYPE; - } + @Override + public String getEntityType() { + return ENTITY_TYPE; + } - @Override - public String getFirstClassCitizenId() { - return getVspId(); - } + @Override + public String getFirstClassCitizenId() { + return getVspId(); + } - public ComponentData getComponentCompositionData() { - return compositionData == null ? null - : JsonUtil.json2Object(compositionData, ComponentData.class); - } + public ComponentData getComponentCompositionData() { + return compositionData == null ? null : JsonUtil.json2Object(compositionData, ComponentData.class); + } - public void setComponentCompositionData(ComponentData component) { - this.compositionData = component == null ? null : JsonUtil.object2Json(component); - } + public void setComponentCompositionData(ComponentData component) { + this.compositionData = component == null ? null : JsonUtil.object2Json(component); + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/ComponentMonitoringUploadEntity.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/ComponentMonitoringUploadEntity.java index b8329a850b..69de3fb7ed 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/ComponentMonitoringUploadEntity.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/ComponentMonitoringUploadEntity.java @@ -7,9 +7,9 @@ * 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. @@ -17,138 +17,134 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.type; -import com.datastax.driver.mapping.annotations.*; +import com.datastax.driver.mapping.annotations.ClusteringColumn; +import com.datastax.driver.mapping.annotations.Column; +import com.datastax.driver.mapping.annotations.Frozen; +import com.datastax.driver.mapping.annotations.PartitionKey; +import com.datastax.driver.mapping.annotations.Table; +import java.nio.ByteBuffer; import org.openecomp.core.enrichment.types.MonitoringUploadType; import org.openecomp.sdc.versioning.dao.types.Version; import org.openecomp.sdc.versioning.dao.types.VersionableEntity; -import java.nio.ByteBuffer; - @Table(keyspace = "dox", name = "vsp_component_artifact") public class ComponentMonitoringUploadEntity implements VersionableEntity { - public static final String ENTITY_TYPE = "Vendor Software Product Component Artifact"; - @PartitionKey - @Column(name = "vsp_id") - private String vspId; - @PartitionKey(value = 1) - @Frozen - private Version version; - @ClusteringColumn - @Column(name = "component_id") - private String componentId; - @ClusteringColumn(value = 1) - @Column(name = "artifact_type") - private MonitoringUploadType type; - @ClusteringColumn(value = 2) - @Column(name = "artifact_id") - private String id; - @Column(name = "name") - private String artifactName; - private ByteBuffer artifact; - - /** - * Every entity class must have a default constructor according to - * <a href="http://docs.datastax.com/en/developer/java-driver/2.1/manual/object_mapper/creating/"> - * Definition of mapped classes</a>. - */ - public ComponentMonitoringUploadEntity() { - // Don't delete! Default constructor is required by DataStax driver - } - - /** - * Instantiates a new Component artifact entity. - * - * @param vspId the vsp id - * @param version the version - * @param componentId the component id - * @param id the id - */ - public ComponentMonitoringUploadEntity(String vspId, Version version, String componentId, - String id) { - this.vspId = vspId; - this.version = version; - this.componentId = componentId; - this.id = id; - } - - public String getVspId() { - return vspId; - } - - public void setVspId(String vspId) { - this.vspId = vspId; - } - - public String getComponentId() { - return componentId; - } - - public void setComponentId(String componentId) { - this.componentId = componentId; - } - - @Override - public String getEntityType() { - return ENTITY_TYPE; - } - - @Override - public String getFirstClassCitizenId() { - return getVspId(); - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public Version getVersion() { - return version; - } - - public void setVersion(Version version) { - this.version = version; - } - - public String getArtifactName() { - return artifactName; - } - - public void setArtifactName(String artifactName) { - this.artifactName = artifactName; - } - - public ByteBuffer getArtifact() { - return artifact; - } - - public void setArtifact(ByteBuffer artifact) { - this.artifact = artifact; - } - - public MonitoringUploadType getType() { - return type; - } - - public void setType(MonitoringUploadType type) { - this.type = type; - } - - @Override - public String toString() { - return "ComponentMonitoringUploadEntity{" + - "vspId='" + vspId + '\'' + - ", version=" + version + - ", componentId='" + componentId + '\'' + - ", type=" + type + - ", id='" + id + '\'' + - ", artifactName='" + artifactName + '\'' + - '}'; - } + + public static final String ENTITY_TYPE = "Vendor Software Product Component Artifact"; + @PartitionKey + @Column(name = "vsp_id") + private String vspId; + @PartitionKey(value = 1) + @Frozen + private Version version; + @ClusteringColumn + @Column(name = "component_id") + private String componentId; + @ClusteringColumn(value = 1) + @Column(name = "artifact_type") + private MonitoringUploadType type; + @ClusteringColumn(value = 2) + @Column(name = "artifact_id") + private String id; + @Column(name = "name") + private String artifactName; + private ByteBuffer artifact; + + /** + * Every entity class must have a default constructor according to + * <a href="http://docs.datastax.com/en/developer/java-driver/2.1/manual/object_mapper/creating/"> + * Definition of mapped classes</a>. + */ + public ComponentMonitoringUploadEntity() { + // Don't delete! Default constructor is required by DataStax driver + } + + /** + * Instantiates a new Component artifact entity. + * + * @param vspId the vsp id + * @param version the version + * @param componentId the component id + * @param id the id + */ + public ComponentMonitoringUploadEntity(String vspId, Version version, String componentId, String id) { + this.vspId = vspId; + this.version = version; + this.componentId = componentId; + this.id = id; + } + + public String getVspId() { + return vspId; + } + + public void setVspId(String vspId) { + this.vspId = vspId; + } + + public String getComponentId() { + return componentId; + } + + public void setComponentId(String componentId) { + this.componentId = componentId; + } + + @Override + public String getEntityType() { + return ENTITY_TYPE; + } + + @Override + public String getFirstClassCitizenId() { + return getVspId(); + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public Version getVersion() { + return version; + } + + public void setVersion(Version version) { + this.version = version; + } + + public String getArtifactName() { + return artifactName; + } + + public void setArtifactName(String artifactName) { + this.artifactName = artifactName; + } + + public ByteBuffer getArtifact() { + return artifact; + } + + public void setArtifact(ByteBuffer artifact) { + this.artifact = artifact; + } + + public MonitoringUploadType getType() { + return type; + } + + public void setType(MonitoringUploadType type) { + this.type = type; + } + + @Override + public String toString() { + return "ComponentMonitoringUploadEntity{" + "vspId='" + vspId + '\'' + ", version=" + version + ", componentId='" + componentId + '\'' + + ", type=" + type + ", id='" + id + '\'' + ", artifactName='" + artifactName + '\'' + '}'; + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/CompositionEntity.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/CompositionEntity.java index b3e8eef3f2..46283a06e0 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/CompositionEntity.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/CompositionEntity.java @@ -7,9 +7,9 @@ * 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. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.type; import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityId; @@ -26,15 +25,15 @@ import org.openecomp.sdc.versioning.dao.types.VersionableEntity; public interface CompositionEntity extends VersionableEntity { - CompositionEntityType getType(); + CompositionEntityType getType(); - CompositionEntityId getCompositionEntityId(); + CompositionEntityId getCompositionEntityId(); - String getCompositionData(); + String getCompositionData(); - void setCompositionData(String compositionData); + void setCompositionData(String compositionData); - String getQuestionnaireData(); + String getQuestionnaireData(); - void setQuestionnaireData(String questionnaireData); + void setQuestionnaireData(String questionnaireData); } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/ComputeEntity.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/ComputeEntity.java index 590fca602e..d73258f036 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/ComputeEntity.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/ComputeEntity.java @@ -7,9 +7,9 @@ * 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. @@ -17,10 +17,13 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.type; -import com.datastax.driver.mapping.annotations.*; +import com.datastax.driver.mapping.annotations.ClusteringColumn; +import com.datastax.driver.mapping.annotations.Column; +import com.datastax.driver.mapping.annotations.Frozen; +import com.datastax.driver.mapping.annotations.PartitionKey; +import com.datastax.driver.mapping.annotations.Table; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; @@ -35,61 +38,57 @@ import org.openecomp.sdc.versioning.dao.types.Version; @NoArgsConstructor @Table(keyspace = "dox", name = "vsp_component_compute") public class ComputeEntity implements CompositionEntity { - public static final String ENTITY_TYPE = "Vendor Software Product Component Compute Flavor"; - - @PartitionKey - @Column(name = "vsp_id") - private String vspId; - @PartitionKey(value = 1) - @Frozen - private Version version; - @ClusteringColumn - @Column(name = "component_id") - private String componentId; - @ClusteringColumn(value = 1) - @Column(name = "compute_id") - private String id; - @Column(name = "composition_data") - private String compositionData; - @Column(name = "questionnaire_data") - private String questionnaireData; - - public ComputeEntity(String vspId, Version version, String componentId, String id) { - this.vspId = vspId; - this.version = version; - this.componentId = componentId; - this.id = id; - } - @Override - public String getEntityType() { - return ENTITY_TYPE; - } + public static final String ENTITY_TYPE = "Vendor Software Product Component Compute Flavor"; + @PartitionKey + @Column(name = "vsp_id") + private String vspId; + @PartitionKey(value = 1) + @Frozen + private Version version; + @ClusteringColumn + @Column(name = "component_id") + private String componentId; + @ClusteringColumn(value = 1) + @Column(name = "compute_id") + private String id; + @Column(name = "composition_data") + private String compositionData; + @Column(name = "questionnaire_data") + private String questionnaireData; - @Override - public String getFirstClassCitizenId() { - return getVspId(); - } + public ComputeEntity(String vspId, Version version, String componentId, String id) { + this.vspId = vspId; + this.version = version; + this.componentId = componentId; + this.id = id; + } - @Override - public CompositionEntityType getType() { - return CompositionEntityType.compute; - } + @Override + public String getEntityType() { + return ENTITY_TYPE; + } - @Override - public CompositionEntityId getCompositionEntityId() { - return new CompositionEntityId(getId(), - new CompositionEntityId(getComponentId(), new CompositionEntityId(getVspId(), null))); - } + @Override + public String getFirstClassCitizenId() { + return getVspId(); + } - public ComputeData getComputeCompositionData() { - return compositionData == null ? null - : JsonUtil.json2Object(compositionData, ComputeData.class); - } + @Override + public CompositionEntityType getType() { + return CompositionEntityType.compute; + } - public void setComputeCompositionData(ComputeData computeData){ - this.compositionData = computeData == null ? null : JsonUtil.object2Json(computeData); - } + @Override + public CompositionEntityId getCompositionEntityId() { + return new CompositionEntityId(getId(), new CompositionEntityId(getComponentId(), new CompositionEntityId(getVspId(), null))); + } + public ComputeData getComputeCompositionData() { + return compositionData == null ? null : JsonUtil.json2Object(compositionData, ComputeData.class); + } + public void setComputeCompositionData(ComputeData computeData) { + this.compositionData = computeData == null ? null : JsonUtil.object2Json(computeData); + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/DeploymentFlavorEntity.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/DeploymentFlavorEntity.java index dd145b1f54..03f464b564 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/DeploymentFlavorEntity.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/DeploymentFlavorEntity.java @@ -7,9 +7,9 @@ * 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. @@ -17,10 +17,13 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.type; -import com.datastax.driver.mapping.annotations.*; +import com.datastax.driver.mapping.annotations.ClusteringColumn; +import com.datastax.driver.mapping.annotations.Column; +import com.datastax.driver.mapping.annotations.Frozen; +import com.datastax.driver.mapping.annotations.PartitionKey; +import com.datastax.driver.mapping.annotations.Table; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NoArgsConstructor; @@ -36,9 +39,9 @@ import org.openecomp.sdc.versioning.dao.types.Version; @Setter @NoArgsConstructor @Table(keyspace = "dox", name = "vsp_deployment_flavor") -public class DeploymentFlavorEntity implements CompositionEntity{ - private static final String ENTITY_TYPE = "Vendor Software Product Deployment Flavor"; +public class DeploymentFlavorEntity implements CompositionEntity { + private static final String ENTITY_TYPE = "Vendor Software Product Deployment Flavor"; @PartitionKey @Column(name = "vsp_id") private String vspId; @@ -65,6 +68,7 @@ public class DeploymentFlavorEntity implements CompositionEntity{ this.version = version; this.id = id; } + @Override public CompositionEntityType getType() { return CompositionEntityType.deployment; @@ -85,7 +89,7 @@ public class DeploymentFlavorEntity implements CompositionEntity{ return getVspId(); } - public DeploymentFlavor getDeploymentFlavorCompositionData() { + public DeploymentFlavor getDeploymentFlavorCompositionData() { return compositionData == null ? null : JsonUtil.json2Object(compositionData, DeploymentFlavor.class); } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/ImageEntity.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/ImageEntity.java index b85fd6c76c..55252cde8a 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/ImageEntity.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/ImageEntity.java @@ -7,9 +7,9 @@ * 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. @@ -17,10 +17,13 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.type; -import com.datastax.driver.mapping.annotations.*; +import com.datastax.driver.mapping.annotations.ClusteringColumn; +import com.datastax.driver.mapping.annotations.Column; +import com.datastax.driver.mapping.annotations.Frozen; +import com.datastax.driver.mapping.annotations.PartitionKey; +import com.datastax.driver.mapping.annotations.Table; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NoArgsConstructor; @@ -38,65 +41,63 @@ import org.openecomp.sdc.versioning.dao.types.Version; @Table(keyspace = "dox", name = "vsp_component_image") public class ImageEntity implements CompositionEntity { - private static final String ENTITY_TYPE = "Vendor Software Product Component Image"; - - @PartitionKey - @Column(name = "vsp_id") - private String vspId; - @PartitionKey(value = 1) - @Frozen - private Version version; - @ClusteringColumn - @Column(name = "component_id") - private String componentId; - @ClusteringColumn(value = 1) - @Column(name = "image_id") - private String id; - @Column(name = "composition_data") - private String compositionData; - @Column(name = "questionnaire_data") - private String questionnaireData; + private static final String ENTITY_TYPE = "Vendor Software Product Component Image"; + @PartitionKey + @Column(name = "vsp_id") + private String vspId; + @PartitionKey(value = 1) + @Frozen + private Version version; + @ClusteringColumn + @Column(name = "component_id") + private String componentId; + @ClusteringColumn(value = 1) + @Column(name = "image_id") + private String id; + @Column(name = "composition_data") + private String compositionData; + @Column(name = "questionnaire_data") + private String questionnaireData; - /** - * Instantiates a new Image entity. - * - * @param vspId the vsp id - * @param version the version - * @param id the id - */ - public ImageEntity(String vspId, Version version, String componentId, String id) { - this.vspId = vspId; - this.version = version; - this.componentId = componentId; - this.id = id; - } + /** + * Instantiates a new Image entity. + * + * @param vspId the vsp id + * @param version the version + * @param id the id + */ + public ImageEntity(String vspId, Version version, String componentId, String id) { + this.vspId = vspId; + this.version = version; + this.componentId = componentId; + this.id = id; + } - @Override - public String getEntityType() { - return ENTITY_TYPE; - } + @Override + public String getEntityType() { + return ENTITY_TYPE; + } - @Override - public String getFirstClassCitizenId() { - return getVspId(); - } + @Override + public String getFirstClassCitizenId() { + return getVspId(); + } - @Override - public CompositionEntityType getType() { - return CompositionEntityType.image; - } + @Override + public CompositionEntityType getType() { + return CompositionEntityType.image; + } - @Override - public CompositionEntityId getCompositionEntityId() { - return new CompositionEntityId(getId(), - new CompositionEntityId(getComponentId(), new CompositionEntityId(getVspId(), null))); - } + @Override + public CompositionEntityId getCompositionEntityId() { + return new CompositionEntityId(getId(), new CompositionEntityId(getComponentId(), new CompositionEntityId(getVspId(), null))); + } - public Image getImageCompositionData() { - return compositionData == null ? null : JsonUtil.json2Object(compositionData, Image.class); - } + public Image getImageCompositionData() { + return compositionData == null ? null : JsonUtil.json2Object(compositionData, Image.class); + } - public void setImageCompositionData(Image image) { - this.compositionData = image == null ? null : JsonUtil.object2Json(image); - } + public void setImageCompositionData(Image image) { + this.compositionData = image == null ? null : JsonUtil.object2Json(image); + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/LicenseType.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/LicenseType.java index 35dfda4568..2cd7b05f1e 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/LicenseType.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/LicenseType.java @@ -17,11 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - - package org.openecomp.sdc.vendorsoftwareproduct.dao.type; -public enum LicenseType { - EXTERNAL, - INTERNAL -} +public enum LicenseType {EXTERNAL, INTERNAL} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/NetworkEntity.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/NetworkEntity.java index 4c02fd4723..0b6fae46ea 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/NetworkEntity.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/NetworkEntity.java @@ -7,9 +7,9 @@ * 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. @@ -17,10 +17,13 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.type; -import com.datastax.driver.mapping.annotations.*; +import com.datastax.driver.mapping.annotations.ClusteringColumn; +import com.datastax.driver.mapping.annotations.Column; +import com.datastax.driver.mapping.annotations.Frozen; +import com.datastax.driver.mapping.annotations.PartitionKey; +import com.datastax.driver.mapping.annotations.Table; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NoArgsConstructor; @@ -37,61 +40,60 @@ import org.openecomp.sdc.versioning.dao.types.Version; @NoArgsConstructor @Table(keyspace = "dox", name = "vsp_network") public class NetworkEntity implements CompositionEntity { - private static final String ENTITY_TYPE = "Vendor Software Product Network"; - - @PartitionKey - @Column(name = "vsp_id") - private String vspId; - @PartitionKey(value = 1) - @Frozen - private Version version; - @ClusteringColumn - @Column(name = "network_id") - private String id; - @Column(name = "composition_data") - private String compositionData; - @Column(name = "questionnaire_data") - private String questionnaireData; + private static final String ENTITY_TYPE = "Vendor Software Product Network"; + @PartitionKey + @Column(name = "vsp_id") + private String vspId; + @PartitionKey(value = 1) + @Frozen + private Version version; + @ClusteringColumn + @Column(name = "network_id") + private String id; + @Column(name = "composition_data") + private String compositionData; + @Column(name = "questionnaire_data") + private String questionnaireData; - /** - * Instantiates a new Network entity. - * - * @param vspId the vsp id - * @param version the version - * @param id the id - */ - public NetworkEntity(String vspId, Version version, String id) { - this.vspId = vspId; - this.version = version; - this.id = id; - } + /** + * Instantiates a new Network entity. + * + * @param vspId the vsp id + * @param version the version + * @param id the id + */ + public NetworkEntity(String vspId, Version version, String id) { + this.vspId = vspId; + this.version = version; + this.id = id; + } - @Override - public CompositionEntityType getType() { - return CompositionEntityType.network; - } + @Override + public CompositionEntityType getType() { + return CompositionEntityType.network; + } - @Override - public CompositionEntityId getCompositionEntityId() { - return new CompositionEntityId(getId(), new CompositionEntityId(getVspId(), null)); - } + @Override + public CompositionEntityId getCompositionEntityId() { + return new CompositionEntityId(getId(), new CompositionEntityId(getVspId(), null)); + } - @Override - public String getEntityType() { - return ENTITY_TYPE; - } + @Override + public String getEntityType() { + return ENTITY_TYPE; + } - @Override - public String getFirstClassCitizenId() { - return getVspId(); - } + @Override + public String getFirstClassCitizenId() { + return getVspId(); + } - public Network getNetworkCompositionData() { - return compositionData == null ? null : JsonUtil.json2Object(compositionData, Network.class); - } + public Network getNetworkCompositionData() { + return compositionData == null ? null : JsonUtil.json2Object(compositionData, Network.class); + } - public void setNetworkCompositionData(Network network) { - this.compositionData = network == null ? null : JsonUtil.object2Json(network); - } + public void setNetworkCompositionData(Network network) { + this.compositionData = network == null ? null : JsonUtil.object2Json(network); + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/NicEntity.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/NicEntity.java index 59e94ce62a..0a3cc41000 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/NicEntity.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/NicEntity.java @@ -17,10 +17,13 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.type; -import com.datastax.driver.mapping.annotations.*; +import com.datastax.driver.mapping.annotations.ClusteringColumn; +import com.datastax.driver.mapping.annotations.Column; +import com.datastax.driver.mapping.annotations.Frozen; +import com.datastax.driver.mapping.annotations.PartitionKey; +import com.datastax.driver.mapping.annotations.Table; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NoArgsConstructor; @@ -37,66 +40,65 @@ import org.openecomp.sdc.versioning.dao.types.Version; @NoArgsConstructor @Table(keyspace = "dox", name = "vsp_component_nic") public class NicEntity implements CompositionEntity { - private static final String ENTITY_TYPE = "Vendor Software Product NIC"; - @PartitionKey - @Column(name = "vsp_id") - private String vspId; - @PartitionKey(value = 1) - @Frozen - private Version version; - @ClusteringColumn - @Column(name = "component_id") - private String componentId; - @ClusteringColumn(value = 1) - @Column(name = "nic_id") - private String id; - @Column(name = "composition_data") - private String compositionData; - @Column(name = "questionnaire_data") - private String questionnaireData; + private static final String ENTITY_TYPE = "Vendor Software Product NIC"; + @PartitionKey + @Column(name = "vsp_id") + private String vspId; + @PartitionKey(value = 1) + @Frozen + private Version version; + @ClusteringColumn + @Column(name = "component_id") + private String componentId; + @ClusteringColumn(value = 1) + @Column(name = "nic_id") + private String id; + @Column(name = "composition_data") + private String compositionData; + @Column(name = "questionnaire_data") + private String questionnaireData; - /** - * Instantiates a new Nic entity. - * - * @param vspId the vsp id - * @param version the version - * @param componentId the component id - * @param id the id - */ - public NicEntity(String vspId, Version version, String componentId, String id) { - this.vspId = vspId; - this.version = version; - this.componentId = componentId; - this.id = id; - } + /** + * Instantiates a new Nic entity. + * + * @param vspId the vsp id + * @param version the version + * @param componentId the component id + * @param id the id + */ + public NicEntity(String vspId, Version version, String componentId, String id) { + this.vspId = vspId; + this.version = version; + this.componentId = componentId; + this.id = id; + } - @Override - public CompositionEntityType getType() { - return CompositionEntityType.nic; - } + @Override + public CompositionEntityType getType() { + return CompositionEntityType.nic; + } - @Override - public CompositionEntityId getCompositionEntityId() { - return new CompositionEntityId(getId(), - new CompositionEntityId(getComponentId(), new CompositionEntityId(getVspId(), null))); - } + @Override + public CompositionEntityId getCompositionEntityId() { + return new CompositionEntityId(getId(), new CompositionEntityId(getComponentId(), new CompositionEntityId(getVspId(), null))); + } - @Override - public String getEntityType() { - return ENTITY_TYPE; - } + @Override + public String getEntityType() { + return ENTITY_TYPE; + } - @Override - public String getFirstClassCitizenId() { - return getVspId(); - } + @Override + public String getFirstClassCitizenId() { + return getVspId(); + } - public Nic getNicCompositionData() { - return compositionData == null ? null : JsonUtil.json2Object(compositionData, Nic.class); - } + public Nic getNicCompositionData() { + return compositionData == null ? null : JsonUtil.json2Object(compositionData, Nic.class); + } - public void setNicCompositionData(Nic nic) { - this.compositionData = nic == null ? null : JsonUtil.object2Json(nic); - } + public void setNicCompositionData(Nic nic) { + this.compositionData = nic == null ? null : JsonUtil.object2Json(nic); + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/OnboardingMethod.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/OnboardingMethod.java index 137ada4838..33d58b93ad 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/OnboardingMethod.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/OnboardingMethod.java @@ -7,9 +7,9 @@ * 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. @@ -17,10 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.type; -public enum OnboardingMethod { - NetworkPackage, - Manual; -} +public enum OnboardingMethod {NetworkPackage, Manual;} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/OrchestrationTemplateCandidateData.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/OrchestrationTemplateCandidateData.java index c5e470e9c6..fdd143d1d2 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/OrchestrationTemplateCandidateData.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/OrchestrationTemplateCandidateData.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.type; import java.nio.ByteBuffer; @@ -37,11 +36,8 @@ public class OrchestrationTemplateCandidateData { private String originalFileName; private String originalFileSuffix; - public OrchestrationTemplateCandidateData(final ByteBuffer contentData, - final String dataStructureJson, - final String fileSuffix, final String fileName, - final String originalFileName, - final String originalFileSuffix, + public OrchestrationTemplateCandidateData(final ByteBuffer contentData, final String dataStructureJson, final String fileSuffix, + final String fileName, final String originalFileName, final String originalFileSuffix, final ByteBuffer originalFileContentData) { this.contentData = contentData; this.filesDataStructure = dataStructureJson; @@ -53,8 +49,6 @@ public class OrchestrationTemplateCandidateData { } public ValidationStructureList getValidationDataStructure() { - return validationData == null ? null - : JsonUtil.json2Object(validationData, ValidationStructureList.class); + return validationData == null ? null : JsonUtil.json2Object(validationData, ValidationStructureList.class); } - } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/OrchestrationTemplateCandidateDataEntity.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/OrchestrationTemplateCandidateDataEntity.java index e342e0b3bf..571c3ae914 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/OrchestrationTemplateCandidateDataEntity.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/OrchestrationTemplateCandidateDataEntity.java @@ -7,9 +7,9 @@ * 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. @@ -17,116 +17,107 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.type; import com.datastax.driver.mapping.annotations.Column; import com.datastax.driver.mapping.annotations.Frozen; import com.datastax.driver.mapping.annotations.PartitionKey; import com.datastax.driver.mapping.annotations.Table; +import java.nio.ByteBuffer; import org.openecomp.sdc.versioning.dao.types.Version; import org.openecomp.sdc.versioning.dao.types.VersionableEntity; -import java.nio.ByteBuffer; - @Table(keyspace = "dox", name = "vsp_orchestration_template_candidate") public class OrchestrationTemplateCandidateDataEntity implements VersionableEntity { - private static final String ENTITY_TYPE = - "Vendor Software Product Upload Orchestration_candidate data"; - - @PartitionKey - @Column(name = "vsp_id") - private String id; - - @PartitionKey(value = 1) - @Frozen - private Version version; - - @Column(name = "content_data") - private ByteBuffer contentData; - - @Column(name = "files_data_structure") - private String filesDataStructure; - - /** - * Every entity class must have a default constructor according to - * <a href="http://docs.datastax.com/en/developer/java-driver/2.1/manual/object_mapper/creating/"> - * Definition of mapped classes</a>. - */ - public OrchestrationTemplateCandidateDataEntity() { - // Don't delete! Default constructor is required by DataStax driver - } - - /** - * Instantiates a new OrchestrationTemplateCandidateDataEntity. - * - * @param id the id - * @param version the Version - - */ - public OrchestrationTemplateCandidateDataEntity(String id, Version version) { - this.id = id; - this.version = version; - } - - /** - * Instantiates a new OrchestrationTemplateCandidateDataEntity. - * - * @param filesDataStructure the files data Structure - * @param version the version - * @param contentData the contentData - * @param id the id - */ - public OrchestrationTemplateCandidateDataEntity(String id, Version version, - ByteBuffer contentData, - String filesDataStructure) { - this.id = id; - this.contentData = contentData; - this.filesDataStructure = filesDataStructure; - this.version = version; - } - - @Override - public String getEntityType() { - return ENTITY_TYPE; - } - - @Override - public String getFirstClassCitizenId() { - return null; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - @Override - public Version getVersion() { - return version; - } - - @Override - public void setVersion(Version version) { - this.version = version; - } - - public ByteBuffer getContentData() { - return contentData; - } - - public void setContentData(ByteBuffer contentData) { - this.contentData = contentData; - } - - public String getFilesDataStructure() { - return filesDataStructure; - } - - public void setFilesDataStructure(String filesDataStructure) { - this.filesDataStructure = filesDataStructure; - } + + private static final String ENTITY_TYPE = "Vendor Software Product Upload Orchestration_candidate data"; + @PartitionKey + @Column(name = "vsp_id") + private String id; + @PartitionKey(value = 1) + @Frozen + private Version version; + @Column(name = "content_data") + private ByteBuffer contentData; + @Column(name = "files_data_structure") + private String filesDataStructure; + + /** + * Every entity class must have a default constructor according to + * <a href="http://docs.datastax.com/en/developer/java-driver/2.1/manual/object_mapper/creating/"> + * Definition of mapped classes</a>. + */ + public OrchestrationTemplateCandidateDataEntity() { + // Don't delete! Default constructor is required by DataStax driver + } + + /** + * Instantiates a new OrchestrationTemplateCandidateDataEntity. + * + * @param id the id + * @param version the Version + */ + public OrchestrationTemplateCandidateDataEntity(String id, Version version) { + this.id = id; + this.version = version; + } + + /** + * Instantiates a new OrchestrationTemplateCandidateDataEntity. + * + * @param filesDataStructure the files data Structure + * @param version the version + * @param contentData the contentData + * @param id the id + */ + public OrchestrationTemplateCandidateDataEntity(String id, Version version, ByteBuffer contentData, String filesDataStructure) { + this.id = id; + this.contentData = contentData; + this.filesDataStructure = filesDataStructure; + this.version = version; + } + + @Override + public String getEntityType() { + return ENTITY_TYPE; + } + + @Override + public String getFirstClassCitizenId() { + return null; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + @Override + public Version getVersion() { + return version; + } + + @Override + public void setVersion(Version version) { + this.version = version; + } + + public ByteBuffer getContentData() { + return contentData; + } + + public void setContentData(ByteBuffer contentData) { + this.contentData = contentData; + } + + public String getFilesDataStructure() { + return filesDataStructure; + } + + public void setFilesDataStructure(String filesDataStructure) { + this.filesDataStructure = filesDataStructure; + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/OrchestrationTemplateEntity.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/OrchestrationTemplateEntity.java index 1bbe1b0ddf..105fb743e8 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/OrchestrationTemplateEntity.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/OrchestrationTemplateEntity.java @@ -13,131 +13,127 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.type; +import java.nio.ByteBuffer; import org.openecomp.core.utilities.json.JsonUtil; import org.openecomp.sdc.heat.datatypes.structure.ValidationStructureList; import org.openecomp.sdc.versioning.dao.types.Version; import org.openecomp.sdc.versioning.dao.types.VersionableEntity; -import java.nio.ByteBuffer; - public class OrchestrationTemplateEntity implements VersionableEntity { - private static final String ENTITY_TYPE = "Vendor Software Product Orchestration Template"; - - private String id; - private Version version; - private String fileSuffix; - private String fileName; - private String packageName; - private String packageVersion; - private String validationData; - private ByteBuffer contentData; - private String filesDataStructure; - - public OrchestrationTemplateEntity() { - //default constructor implementation is not provided for OrchestrationTemplateEntity - } - - public OrchestrationTemplateEntity(String id, Version version) { - this.id = id; - this.version = version; - } - - @Override - public String getEntityType() { - return ENTITY_TYPE; - } - - @Override - public String getFirstClassCitizenId() { - return getId(); - } - - @Override - public String getId() { - return id; - } - - @Override - public void setId(String id) { - this.id = id; - } - - @Override - public Version getVersion() { - return version; - } - - @Override - public void setVersion(Version version) { - this.version = version; - } - - public String getFileSuffix() { - return fileSuffix; - } - - public void setFileSuffix(String fileSuffix) { - this.fileSuffix = fileSuffix; - } - - public String getFileName() { - return fileName; - } - - public void setFileName(String fileName) { - this.fileName = fileName; - } - - public String getPackageName() { - return packageName; - } - - public void setPackageName(String packageName) { - this.packageName = packageName; - } - - public String getPackageVersion() { - return packageVersion; - } - - public void setPackageVersion(String packageVersion) { - this.packageVersion = packageVersion; - } - - public String getValidationData() { - return validationData; - } - - public void setValidationData(String validationData) { - this.validationData = validationData; - } - - public ValidationStructureList getValidationDataStructure() { - return validationData == null ? null - : JsonUtil.json2Object(validationData, ValidationStructureList.class); - } - - public void setValidationDataStructure(ValidationStructureList validationData) { - this.validationData = validationData == null ? null - : JsonUtil.object2Json(validationData); - } - - public ByteBuffer getContentData() { - return contentData; - } - - public void setContentData(ByteBuffer contentData) { - this.contentData = contentData; - } - - public String getFilesDataStructure() { - return filesDataStructure; - } - - public void setFilesDataStructure(String filesDataStructure) { - this.filesDataStructure = filesDataStructure; - } + + private static final String ENTITY_TYPE = "Vendor Software Product Orchestration Template"; + private String id; + private Version version; + private String fileSuffix; + private String fileName; + private String packageName; + private String packageVersion; + private String validationData; + private ByteBuffer contentData; + private String filesDataStructure; + + public OrchestrationTemplateEntity() { + //default constructor implementation is not provided for OrchestrationTemplateEntity + } + + public OrchestrationTemplateEntity(String id, Version version) { + this.id = id; + this.version = version; + } + + @Override + public String getEntityType() { + return ENTITY_TYPE; + } + + @Override + public String getFirstClassCitizenId() { + return getId(); + } + + @Override + public String getId() { + return id; + } + + @Override + public void setId(String id) { + this.id = id; + } + + @Override + public Version getVersion() { + return version; + } + + @Override + public void setVersion(Version version) { + this.version = version; + } + + public String getFileSuffix() { + return fileSuffix; + } + + public void setFileSuffix(String fileSuffix) { + this.fileSuffix = fileSuffix; + } + + public String getFileName() { + return fileName; + } + + public void setFileName(String fileName) { + this.fileName = fileName; + } + + public String getPackageName() { + return packageName; + } + + public void setPackageName(String packageName) { + this.packageName = packageName; + } + + public String getPackageVersion() { + return packageVersion; + } + + public void setPackageVersion(String packageVersion) { + this.packageVersion = packageVersion; + } + + public String getValidationData() { + return validationData; + } + + public void setValidationData(String validationData) { + this.validationData = validationData; + } + + public ValidationStructureList getValidationDataStructure() { + return validationData == null ? null : JsonUtil.json2Object(validationData, ValidationStructureList.class); + } + + public void setValidationDataStructure(ValidationStructureList validationData) { + this.validationData = validationData == null ? null : JsonUtil.object2Json(validationData); + } + + public ByteBuffer getContentData() { + return contentData; + } + + public void setContentData(ByteBuffer contentData) { + this.contentData = contentData; + } + + public String getFilesDataStructure() { + return filesDataStructure; + } + + public void setFilesDataStructure(String filesDataStructure) { + this.filesDataStructure = filesDataStructure; + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/PackageInfo.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/PackageInfo.java index 6aac77acfa..9c751a239d 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/PackageInfo.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/PackageInfo.java @@ -7,9 +7,9 @@ * 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. @@ -17,67 +17,51 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.type; import com.datastax.driver.mapping.annotations.Column; import com.datastax.driver.mapping.annotations.PartitionKey; import com.datastax.driver.mapping.annotations.Table; -import lombok.NoArgsConstructor; +import java.nio.ByteBuffer; import lombok.Data; +import lombok.NoArgsConstructor; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; import org.openecomp.sdc.versioning.dao.types.Version; -import java.nio.ByteBuffer; - - @Data @NoArgsConstructor @Table(keyspace = "dox", name = "package_details") public class PackageInfo { - - @PartitionKey - @Column(name = "vsp_id") - private String vspId; - - @PartitionKey(value = 1) - private String version; - - @Column(name = "display_name") - private String displayName; - - @Column(name = "vsp_name") - private String vspName; - - @Column(name = "vsp_description") - private String vspDescription; - - @Column(name = "vendor_name") - private String vendorName; - - private String category; - - @Column(name = "sub_category") - private String subCategory; - - @Column(name = "vendor_release") - private String vendorRelease; - - @Column(name = "package_checksum") - private String packageChecksum; - - @Column(name = "package_type") - private String packageType; - - @Column(name = "translate_content") - private ByteBuffer translatedFile; - - @Column(name = "resource_type") - private String resourceType = ResourceTypeEnum.VF.name(); - - public PackageInfo(String packageId, Version version) { - this.vspId = packageId; - this.version = version.getName(); - } + @PartitionKey + @Column(name = "vsp_id") + private String vspId; + @PartitionKey(value = 1) + private String version; + @Column(name = "display_name") + private String displayName; + @Column(name = "vsp_name") + private String vspName; + @Column(name = "vsp_description") + private String vspDescription; + @Column(name = "vendor_name") + private String vendorName; + private String category; + @Column(name = "sub_category") + private String subCategory; + @Column(name = "vendor_release") + private String vendorRelease; + @Column(name = "package_checksum") + private String packageChecksum; + @Column(name = "package_type") + private String packageType; + @Column(name = "translate_content") + private ByteBuffer translatedFile; + @Column(name = "resource_type") + private String resourceType = ResourceTypeEnum.VF.name(); + + public PackageInfo(String packageId, Version version) { + this.vspId = packageId; + this.version = version.getName(); + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/ProcessEntity.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/ProcessEntity.java index 6e2c371adb..2ed8a535a3 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/ProcessEntity.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/ProcessEntity.java @@ -7,9 +7,9 @@ * 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. @@ -17,213 +17,203 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.type; -import com.datastax.driver.mapping.annotations.*; +import com.datastax.driver.mapping.annotations.ClusteringColumn; +import com.datastax.driver.mapping.annotations.Column; +import com.datastax.driver.mapping.annotations.Frozen; +import com.datastax.driver.mapping.annotations.PartitionKey; +import com.datastax.driver.mapping.annotations.Table; +import java.nio.ByteBuffer; import org.openecomp.sdc.versioning.dao.types.Version; import org.openecomp.sdc.versioning.dao.types.VersionableEntity; -import java.nio.ByteBuffer; - @Table(keyspace = "dox", name = "vsp_process") public class ProcessEntity implements VersionableEntity { - public static final String ENTITY_TYPE = "Vendor Software Product Process"; - @PartitionKey - @Column(name = "vsp_id") - private String vspId; - @PartitionKey(value = 1) - @Frozen - private Version version; - @ClusteringColumn - @Column(name = "component_id") - private String componentId; - @ClusteringColumn(value = 1) - @Column(name = "process_id") - private String id; - private String name; - private String description; - @Column(name = "type") - private ProcessType type; - @Column(name = "artifact_name") - private String artifactName; - private ByteBuffer artifact; - - /** - * Every entity class must have a default constructor according to - * <a href="http://docs.datastax.com/en/developer/java-driver/2.1/manual/object_mapper/creating/"> - * Definition of mapped classes</a>. - */ - public ProcessEntity() { - // Don't delete! Default constructor is required by DataStax driver - } - - /** - * Instantiates a new Process entity. - * - * @param vspId the vsp id - * @param version the version - * @param componentId the component id - * @param id the id - */ - public ProcessEntity(String vspId, Version version, String componentId, String id) { - this.vspId = vspId; - this.version = version; - this.componentId = componentId; - this.id = id; - } - - public String getVspId() { - return vspId; - } - - public void setVspId(String vspId) { - this.vspId = vspId; - } - - public String getComponentId() { - return componentId; - } - - public void setComponentId(String componentId) { - this.componentId = componentId; - } - - @Override - public String getEntityType() { - return ENTITY_TYPE; - } - - @Override - public String getFirstClassCitizenId() { - return getVspId(); - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public Version getVersion() { - return version; - } - - public void setVersion(Version version) { - this.version = version; - } - - public String getName() { - return name == null ? "" : name; - } - - public void setName(String name) { - this.name = name; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public ProcessType getType() { - return type; - } - - public void setType(ProcessType type) { - this.type = type; - } - - public String getArtifactName() { - return artifactName; - } - - public void setArtifactName(String artifactName) { - this.artifactName = artifactName; - } - - public ByteBuffer getArtifact() { - return artifact; - } - - public void setArtifact(ByteBuffer artifact) { - this.artifact = artifact; - } - - @Override - public boolean equals(Object other) { - if (this == other) { - return true; - } - if (other == null || getClass() != other.getClass()) { - return false; - } - - ProcessEntity that = (ProcessEntity) other; - - if (vspId != null ? !vspId.equals(that.vspId) : that.vspId != null) { - return false; - } - if (version != null ? !version.equals(that.version) : that.version != null) { - return false; + + public static final String ENTITY_TYPE = "Vendor Software Product Process"; + @PartitionKey + @Column(name = "vsp_id") + private String vspId; + @PartitionKey(value = 1) + @Frozen + private Version version; + @ClusteringColumn + @Column(name = "component_id") + private String componentId; + @ClusteringColumn(value = 1) + @Column(name = "process_id") + private String id; + private String name; + private String description; + @Column(name = "type") + private ProcessType type; + @Column(name = "artifact_name") + private String artifactName; + private ByteBuffer artifact; + + /** + * Every entity class must have a default constructor according to + * <a href="http://docs.datastax.com/en/developer/java-driver/2.1/manual/object_mapper/creating/"> + * Definition of mapped classes</a>. + */ + public ProcessEntity() { + // Don't delete! Default constructor is required by DataStax driver + } + + /** + * Instantiates a new Process entity. + * + * @param vspId the vsp id + * @param version the version + * @param componentId the component id + * @param id the id + */ + public ProcessEntity(String vspId, Version version, String componentId, String id) { + this.vspId = vspId; + this.version = version; + this.componentId = componentId; + this.id = id; + } + + public String getVspId() { + return vspId; + } + + public void setVspId(String vspId) { + this.vspId = vspId; + } + + public String getComponentId() { + return componentId; + } + + public void setComponentId(String componentId) { + this.componentId = componentId; + } + + @Override + public String getEntityType() { + return ENTITY_TYPE; + } + + @Override + public String getFirstClassCitizenId() { + return getVspId(); + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; } - if (componentId != null ? !componentId.equals(that.componentId) : that.componentId != null) { - return false; - } - if (id != null ? !id.equals(that.id) : that.id != null) { - return false; - } - if (name != null ? !name.equals(that.name) : that.name != null) { - return false; + + public Version getVersion() { + return version; + } + + public void setVersion(Version version) { + this.version = version; + } + + public String getName() { + return name == null ? "" : name; + } + + public void setName(String name) { + this.name = name; } - if (description != null ? !description.equals(that.description) : that.description != null) { - return false; + + public String getDescription() { + return description; } - if (artifactName != null ? !artifactName.equals(that.artifactName) - : that.artifactName != null) { - return false; - } - if (artifact != null ? !artifact.equals(that.artifact) : that.artifact != null) { - return false; + + public void setDescription(String description) { + this.description = description; } - if (type != null ? !type.equals(that.type) : that.type != null) { - return false; - } + public ProcessType getType() { + return type; + } - return true; - } + public void setType(ProcessType type) { + this.type = type; + } - @Override - public int hashCode() { - int result = vspId != null ? vspId.hashCode() : 0; - result = 31 * result + (version != null ? version.hashCode() : 0); - result = 31 * result + (componentId != null ? componentId.hashCode() : 0); - result = 31 * result + (id != null ? id.hashCode() : 0); - result = 31 * result + (name != null ? name.hashCode() : 0); - result = 31 * result + (description != null ? description.hashCode() : 0); - result = 31 * result + (type != null ? type.hashCode() : 0); - result = 31 * result + (artifactName != null ? artifactName.hashCode() : 0); - result = 31 * result + (artifact != null ? artifact.hashCode() : 0); - return result; - } + public String getArtifactName() { + return artifactName; + } - @Override - public String toString() { - return "ProcessEntity{" + - "vspId='" + vspId + '\'' + - ", version=" + version + - ", componentId='" + componentId + '\'' + - ", id='" + id + '\'' + - ", name='" + name + '\'' + - ", description='" + description + '\'' + - ", type=" + type + - ", artifactName='" + artifactName + '\'' + - '}'; - } + public void setArtifactName(String artifactName) { + this.artifactName = artifactName; + } + + public ByteBuffer getArtifact() { + return artifact; + } + + public void setArtifact(ByteBuffer artifact) { + this.artifact = artifact; + } + + @Override + public boolean equals(Object other) { + if (this == other) { + return true; + } + if (other == null || getClass() != other.getClass()) { + return false; + } + ProcessEntity that = (ProcessEntity) other; + if (vspId != null ? !vspId.equals(that.vspId) : that.vspId != null) { + return false; + } + if (version != null ? !version.equals(that.version) : that.version != null) { + return false; + } + if (componentId != null ? !componentId.equals(that.componentId) : that.componentId != null) { + return false; + } + if (id != null ? !id.equals(that.id) : that.id != null) { + return false; + } + if (name != null ? !name.equals(that.name) : that.name != null) { + return false; + } + if (description != null ? !description.equals(that.description) : that.description != null) { + return false; + } + if (artifactName != null ? !artifactName.equals(that.artifactName) : that.artifactName != null) { + return false; + } + if (artifact != null ? !artifact.equals(that.artifact) : that.artifact != null) { + return false; + } + if (type != null ? !type.equals(that.type) : that.type != null) { + return false; + } + return true; + } + + @Override + public int hashCode() { + int result = vspId != null ? vspId.hashCode() : 0; + result = 31 * result + (version != null ? version.hashCode() : 0); + result = 31 * result + (componentId != null ? componentId.hashCode() : 0); + result = 31 * result + (id != null ? id.hashCode() : 0); + result = 31 * result + (name != null ? name.hashCode() : 0); + result = 31 * result + (description != null ? description.hashCode() : 0); + result = 31 * result + (type != null ? type.hashCode() : 0); + result = 31 * result + (artifactName != null ? artifactName.hashCode() : 0); + result = 31 * result + (artifact != null ? artifact.hashCode() : 0); + return result; + } + + @Override + public String toString() { + return "ProcessEntity{" + "vspId='" + vspId + '\'' + ", version=" + version + ", componentId='" + componentId + '\'' + ", id='" + id + '\'' + + ", name='" + name + '\'' + ", description='" + description + '\'' + ", type=" + type + ", artifactName='" + artifactName + '\'' + '}'; + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/ProcessType.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/ProcessType.java index d49386c3bf..09cdc95a29 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/ProcessType.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/ProcessType.java @@ -17,11 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - - package org.openecomp.sdc.vendorsoftwareproduct.dao.type; -public enum ProcessType { - Lifecycle_Operations, - Other -} +public enum ProcessType {Lifecycle_Operations, Other} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/TranslatedFileData.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/TranslatedFileData.java index 0dc3ac25a6..6a392cd44f 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/TranslatedFileData.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/TranslatedFileData.java @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.type; import lombok.Getter; @@ -37,5 +36,4 @@ public class TranslatedFileData { private String vendorRelease; private String packageChecksum; private String packageType; - } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/VspDetails.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/VspDetails.java index 8f4aed8c71..88b020b673 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/VspDetails.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/VspDetails.java @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.type; import java.util.List; @@ -33,7 +32,6 @@ import org.openecomp.sdc.versioning.dao.types.VersionableEntity; public class VspDetails implements VersionableEntity { public static final String ENTITY_TYPE = "Vendor Software Product"; - private String id; private Version version; private String name; @@ -66,8 +64,8 @@ public class VspDetails implements VersionableEntity { @Override public String toString() { - return String.format( - "Vsp id = '%s', Version = %s', Name = %s', Category = %s', Description = %s', Vendor = %s'", - this.id, this.version, this.name, this.category, this.description, this.vendorName); + return String + .format("Vsp id = '%s', Version = %s', Name = %s', Category = %s', Description = %s', Vendor = %s'", this.id, this.version, this.name, + this.category, this.description, this.vendorName); } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/VspQuestionnaireEntity.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/VspQuestionnaireEntity.java index e463605d39..1b3dec0a59 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/VspQuestionnaireEntity.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/VspQuestionnaireEntity.java @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.type; import lombok.Getter; @@ -33,7 +32,6 @@ import org.openecomp.sdc.versioning.dao.types.Version; public class VspQuestionnaireEntity implements CompositionEntity { private static final String ENTITY_TYPE = "Vendor Software Product"; - private String id; private Version version; private String questionnaireData; @@ -72,5 +70,4 @@ public class VspQuestionnaireEntity implements CompositionEntity { public void setCompositionData(String compositionData) { //none } - } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/utils/ErrorsUtil.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/utils/ErrorsUtil.java index fc23a77bef..cce965b874 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/utils/ErrorsUtil.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/utils/ErrorsUtil.java @@ -7,9 +7,9 @@ * 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. @@ -17,14 +17,12 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.errors.utils; -import org.openecomp.sdc.datatypes.error.ErrorMessage; - import java.util.ArrayList; import java.util.List; import java.util.Map; +import org.openecomp.sdc.datatypes.error.ErrorMessage; /** * Created by Talio on 11/30/2016. diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/CandidateServiceFactory.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/CandidateServiceFactory.java index f16d8d4ebe..d728ff3bad 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/CandidateServiceFactory.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/CandidateServiceFactory.java @@ -7,9 +7,9 @@ * 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. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.factory; import org.openecomp.core.factory.api.AbstractComponentFactory; @@ -29,7 +28,7 @@ import org.openecomp.sdc.vendorsoftwareproduct.services.filedatastructuremodule. */ public abstract class CandidateServiceFactory extends AbstractComponentFactory<CandidateService> { - public static CandidateServiceFactory getInstance(){ - return AbstractFactory.getInstance(CandidateServiceFactory.class); - } + public static CandidateServiceFactory getInstance() { + return AbstractFactory.getInstance(CandidateServiceFactory.class); + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/CompositionDataExtractorFactory.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/CompositionDataExtractorFactory.java index d10b8b715d..e811df829a 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/CompositionDataExtractorFactory.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/CompositionDataExtractorFactory.java @@ -7,9 +7,9 @@ * 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. @@ -17,17 +17,15 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.factory; import org.openecomp.core.factory.api.AbstractComponentFactory; import org.openecomp.core.factory.api.AbstractFactory; import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionDataExtractor; -public abstract class CompositionDataExtractorFactory extends - AbstractComponentFactory<CompositionDataExtractor> { +public abstract class CompositionDataExtractorFactory extends AbstractComponentFactory<CompositionDataExtractor> { - public static CompositionDataExtractorFactory getInstance() { - return AbstractFactory.getInstance(CompositionDataExtractorFactory.class); - } + public static CompositionDataExtractorFactory getInstance() { + return AbstractFactory.getInstance(CompositionDataExtractorFactory.class); + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/InformationArtifactGeneratorFactory.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/InformationArtifactGeneratorFactory.java index 7e6e7db5dc..f9fb58a20c 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/InformationArtifactGeneratorFactory.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/InformationArtifactGeneratorFactory.java @@ -7,9 +7,9 @@ * 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. @@ -17,17 +17,15 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.factory; import org.openecomp.core.factory.api.AbstractComponentFactory; import org.openecomp.core.factory.api.AbstractFactory; import org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.InformationArtifactGenerator; - public abstract class InformationArtifactGeneratorFactory extends AbstractComponentFactory<InformationArtifactGenerator> { - public static InformationArtifactGeneratorFactory getInstance() { - return AbstractFactory.getInstance(InformationArtifactGeneratorFactory.class); - } + public static InformationArtifactGeneratorFactory getInstance() { + return AbstractFactory.getInstance(InformationArtifactGeneratorFactory.class); + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/ManifestCreatorFactory.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/ManifestCreatorFactory.java index 9189ffce6d..6c1ec911b0 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/ManifestCreatorFactory.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/ManifestCreatorFactory.java @@ -7,9 +7,9 @@ * 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. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.factory; import org.openecomp.core.factory.api.AbstractComponentFactory; @@ -27,9 +26,9 @@ import org.openecomp.sdc.vendorsoftwareproduct.services.filedatastructuremodule. /** * Created by Talio on 12/15/2016. */ -public abstract class ManifestCreatorFactory extends AbstractComponentFactory<ManifestCreator>{ +public abstract class ManifestCreatorFactory extends AbstractComponentFactory<ManifestCreator> { - public static ManifestCreatorFactory getInstance(){ - return AbstractFactory.getInstance(ManifestCreatorFactory.class); - } + public static ManifestCreatorFactory getInstance() { + return AbstractFactory.getInstance(ManifestCreatorFactory.class); + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/QuestionnnaireDataServiceFactory.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/QuestionnnaireDataServiceFactory.java index a45eb3db6f..2a46aabe11 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/QuestionnnaireDataServiceFactory.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/QuestionnnaireDataServiceFactory.java @@ -7,9 +7,9 @@ * 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. @@ -17,17 +17,15 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.factory; import org.openecomp.core.factory.api.AbstractComponentFactory; import org.openecomp.core.factory.api.AbstractFactory; import org.openecomp.sdc.vendorsoftwareproduct.questionnaire.QuestionnaireDataService; - public abstract class QuestionnnaireDataServiceFactory extends AbstractComponentFactory<QuestionnaireDataService> { - public static QuestionnnaireDataServiceFactory getInstance() { - return AbstractFactory.getInstance(QuestionnnaireDataServiceFactory.class); - } + public static QuestionnnaireDataServiceFactory getInstance() { + return AbstractFactory.getInstance(QuestionnnaireDataServiceFactory.class); + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/informationArtifact/InformationArtifactData.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/informationArtifact/InformationArtifactData.java index 8f68f1088b..f3db4d3a88 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/informationArtifact/InformationArtifactData.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/informationArtifact/InformationArtifactData.java @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.informationArtifact; import java.util.List; @@ -40,5 +39,4 @@ public class InformationArtifactData { private VspQuestionnaire vspQuestionnaire; private List<ComponentQuestionnaire> componentQuestionnaires; private List<NicQuestionnaire> nicQuestionnaires; - } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/informationArtifact/InformationArtifactGenerator.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/informationArtifact/InformationArtifactGenerator.java index 5813a18bd7..abc3f5ca19 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/informationArtifact/InformationArtifactGenerator.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/informationArtifact/InformationArtifactGenerator.java @@ -7,9 +7,9 @@ * 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. @@ -17,18 +17,16 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.informationArtifact; -import org.openecomp.sdc.versioning.dao.types.Version; - import java.io.IOException; +import org.openecomp.sdc.versioning.dao.types.Version; /** * @author katyr * @since November 29, 2016 */ - public interface InformationArtifactGenerator { + String generate(String vspId, Version version) throws IOException; } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/questionnaire/QuestionnaireDataService.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/questionnaire/QuestionnaireDataService.java index 0bf10c09e8..e339f49f7f 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/questionnaire/QuestionnaireDataService.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/questionnaire/QuestionnaireDataService.java @@ -7,9 +7,9 @@ * 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. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.questionnaire; import org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.InformationArtifactData; @@ -27,7 +26,7 @@ import org.openecomp.sdc.versioning.dao.types.Version; * @author katyr * @since November 29, 2016 */ - public interface QuestionnaireDataService { + InformationArtifactData generateQuestionnaireDataForInformationArtifact(String vspId, Version version); } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/HeatFileAnalyzer.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/HeatFileAnalyzer.java index 533f041621..a1b85daa8c 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/HeatFileAnalyzer.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/HeatFileAnalyzer.java @@ -7,9 +7,9 @@ * 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. @@ -17,13 +17,11 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.services; -import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.AnalyzedZipHeatFiles; - import java.io.IOException; import java.util.Map; +import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.AnalyzedZipHeatFiles; /** * @author Avrahamg @@ -31,17 +29,17 @@ import java.util.Map; */ public interface HeatFileAnalyzer { - static boolean isEnvFile(String fileName) { - return fileName.endsWith(".env"); - } + static boolean isEnvFile(String fileName) { + return fileName.endsWith(".env"); + } - static boolean isYamlFile(String fileName) { - return fileName.endsWith(".yml") || fileName.endsWith(".yaml"); - } + static boolean isYamlFile(String fileName) { + return fileName.endsWith(".yml") || fileName.endsWith(".yaml"); + } - static boolean isYamlOrEnvFile(String fileName) { - return isYamlFile(fileName) || isEnvFile(fileName); - } + static boolean isYamlOrEnvFile(String fileName) { + return isYamlFile(fileName) || isEnvFile(fileName); + } - AnalyzedZipHeatFiles analyzeFilesNotEligibleForModulesFromFileAnalyzer(Map<String, byte[]> files) throws IOException; + AnalyzedZipHeatFiles analyzeFilesNotEligibleForModulesFromFileAnalyzer(Map<String, byte[]> files) throws IOException; } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/composition/CompositionDataExtractor.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/composition/CompositionDataExtractor.java index 0b82638277..3696bd33fd 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/composition/CompositionDataExtractor.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/composition/CompositionDataExtractor.java @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.services.composition; import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel; @@ -25,7 +24,7 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionData public interface CompositionDataExtractor { - CompositionData extractServiceCompositionData(ToscaServiceModel toscaServiceModel); + CompositionData extractServiceCompositionData(ToscaServiceModel toscaServiceModel); - String getComponentDisplayName(String componentName); + String getComponentDisplayName(String componentName); } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/filedatastructuremodule/CandidateService.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/filedatastructuremodule/CandidateService.java index d33533a7d0..7467d59c04 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/filedatastructuremodule/CandidateService.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/filedatastructuremodule/CandidateService.java @@ -15,9 +15,15 @@ * * Modifications copyright (c) 2021 Nokia */ - package org.openecomp.sdc.vendorsoftwareproduct.services.filedatastructuremodule; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.nio.ByteBuffer; +import java.util.List; +import java.util.Map; +import java.util.Optional; import org.openecomp.core.utilities.file.FileContentHandler; import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum; import org.openecomp.sdc.datatypes.error.ErrorMessage; @@ -30,61 +36,42 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.AnalyzedZipHe import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.FilesDataStructure; import org.openecomp.sdc.versioning.dao.types.Version; -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.nio.ByteBuffer; -import java.util.List; -import java.util.Map; -import java.util.Optional; - public interface CandidateService { - Optional<ErrorMessage> validateNonEmptyFileToUpload(InputStream heatFileToUpload, - String fileSuffix); - Optional<ErrorMessage> validateRawZipData(String fileSuffix, byte[] uploadedFileData); + Optional<ErrorMessage> validateNonEmptyFileToUpload(InputStream heatFileToUpload, String fileSuffix); + + Optional<ErrorMessage> validateRawZipData(String fileSuffix, byte[] uploadedFileData); - OrchestrationTemplateCandidateData createCandidateDataEntity( - CandidateDataEntityTo candidateDataEntityTo, InputStream zipFileManifest, - AnalyzedZipHeatFiles analyzedZipHeatFiles); + OrchestrationTemplateCandidateData createCandidateDataEntity(CandidateDataEntityTo candidateDataEntityTo, InputStream zipFileManifest, + AnalyzedZipHeatFiles analyzedZipHeatFiles); - void updateCandidateUploadData(String vspId, Version version, - OrchestrationTemplateCandidateData uploadData); + void updateCandidateUploadData(String vspId, Version version, OrchestrationTemplateCandidateData uploadData); - Optional<FilesDataStructure> getOrchestrationTemplateCandidateFileDataStructure(String vspId, - Version version); + Optional<FilesDataStructure> getOrchestrationTemplateCandidateFileDataStructure(String vspId, Version version); - void updateOrchestrationTemplateCandidateFileDataStructure(String vspId, Version version, - FilesDataStructure fileDataStructure); + void updateOrchestrationTemplateCandidateFileDataStructure(String vspId, Version version, FilesDataStructure fileDataStructure); - Optional<OrchestrationTemplateCandidateData> getOrchestrationTemplateCandidate(String vspId, - Version version); + Optional<OrchestrationTemplateCandidateData> getOrchestrationTemplateCandidate(String vspId, Version version); - Optional<OrchestrationTemplateCandidateData> getOrchestrationTemplateCandidateInfo(String vspId, - Version version); + Optional<OrchestrationTemplateCandidateData> getOrchestrationTemplateCandidateInfo(String vspId, Version version); - byte[] getZipData(ByteBuffer contentData) throws IOException; + byte[] getZipData(ByteBuffer contentData) throws IOException; - void deleteOrchestrationTemplateCandidate(String vspId, Version version); + void deleteOrchestrationTemplateCandidate(String vspId, Version version); - Optional<ByteArrayInputStream> fetchZipFileByteArrayInputStream(String vspId, - OrchestrationTemplateCandidateData candidateDataEntity, - String manifest, - OnboardingTypesEnum type, - Map<String, List<ErrorMessage>> uploadErrors); + Optional<ByteArrayInputStream> fetchZipFileByteArrayInputStream(String vspId, OrchestrationTemplateCandidateData candidateDataEntity, + String manifest, OnboardingTypesEnum type, + Map<String, List<ErrorMessage>> uploadErrors); - byte[] replaceManifestInZip(ByteBuffer contentData, String manifest, - OnboardingTypesEnum type) throws IOException; + byte[] replaceManifestInZip(ByteBuffer contentData, String manifest, OnboardingTypesEnum type) throws IOException; - Optional<ManifestContent> createManifest(VspDetails vspDetails, - FileContentHandler fileContentHandler, - AnalyzedZipHeatFiles analyzedZipHeatFiles); + Optional<ManifestContent> createManifest(VspDetails vspDetails, FileContentHandler fileContentHandler, AnalyzedZipHeatFiles analyzedZipHeatFiles); - String createManifest(VspDetails vspDetails, FilesDataStructure structure); + String createManifest(VspDetails vspDetails, FilesDataStructure structure); - String createManifestFromExisting(VspDetails vspDetails, FilesDataStructure structure, ManifestContent existingManifest); + String createManifestFromExisting(VspDetails vspDetails, FilesDataStructure structure, ManifestContent existingManifest); - Optional<List<ErrorMessage>> validateFileDataStructure(FilesDataStructure filesDataStructure); + Optional<List<ErrorMessage>> validateFileDataStructure(FilesDataStructure filesDataStructure); - void updateValidationData(String vspId, Version version, ValidationStructureList validationData); + void updateValidationData(String vspId, Version version, ValidationStructureList validationData); } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/filedatastructuremodule/ManifestCreator.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/filedatastructuremodule/ManifestCreator.java index 90490e7153..22ec1c3f79 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/filedatastructuremodule/ManifestCreator.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/filedatastructuremodule/ManifestCreator.java @@ -8,9 +8,9 @@ * 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. @@ -18,24 +18,23 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.services.filedatastructuremodule; +import java.util.Optional; import org.openecomp.core.utilities.file.FileContentHandler; import org.openecomp.sdc.heat.datatypes.manifest.ManifestContent; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails; import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.AnalyzedZipHeatFiles; import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.FilesDataStructure; -import java.util.Optional; - public interface ManifestCreator { - Optional<ManifestContent> createManifest(VspDetails vspDetails, FilesDataStructure filesDataStructure); - Optional<ManifestContent> createManifestFromExisting(VspDetails vspDetails, FilesDataStructure filesDataStructure, ManifestContent existingManifest); + Optional<ManifestContent> createManifest(VspDetails vspDetails, FilesDataStructure filesDataStructure); + + Optional<ManifestContent> createManifestFromExisting(VspDetails vspDetails, FilesDataStructure filesDataStructure, + ManifestContent existingManifest); - Optional<ManifestContent> createManifest(VspDetails vspDetails, FileContentHandler - fileContentHandler, AnalyzedZipHeatFiles analyzedZipHeatFiles); + Optional<ManifestContent> createManifest(VspDetails vspDetails, FileContentHandler fileContentHandler, AnalyzedZipHeatFiles analyzedZipHeatFiles); - boolean isFileBaseFile(String fileName); + boolean isFileBaseFile(String fileName); } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/HeatFileAnalyzerRowDataImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/HeatFileAnalyzerRowDataImpl.java index 04d240a8e6..fffdaef75a 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/HeatFileAnalyzerRowDataImpl.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/HeatFileAnalyzerRowDataImpl.java @@ -7,9 +7,9 @@ * 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. @@ -17,134 +17,126 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.services.impl; +import java.io.BufferedReader; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.regex.Pattern; import org.openecomp.sdc.vendorsoftwareproduct.services.HeatFileAnalyzer; import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.AnalyzedZipHeatFiles; -import java.io.*; -import java.util.*; -import java.util.regex.Pattern; - public class HeatFileAnalyzerRowDataImpl implements HeatFileAnalyzer { - private static final String HEAT_IDENTIFIER_REGEX = "^heat_template_version:.*"; - private static final String HEAT_RESOURCES_REGEX = "^resources:\\s*$"; - private static final String HEAT_PARAMETERS_REGEX = "^parameters:\\s*$"; - private static final String HEAT_CONDITIONS_REGEX = "^conditions:\\s*$"; - private static final String HEAT_OUTPUTS_REGEX = "^outputs:\\s*$"; - private static final String HEAT_PARAMETER_GROUP_REGEX = "^parameter_groups:\\s*$"; - private static final String HEAT_DESCRIPTION_REGEX = "^description:\\s*$"; - //allowing spaces at start followed by 'type:' + spaces + any characters + ('.yml' or '.yaml')+ - // spaces - private static final String HEAT_NESTED_RESOURCE_REGEX = "\\s*type:\\s*\\S*.(yml|yaml)\\s*$"; - - - private static final String IDENTIFIER = "IDENTIFIER"; - private static final String RESOURCES = "RESOURCES"; - private static final String PARAMETERS = "PARAMETERS"; - private static final String CONDITIONS = "CONDITIONS"; - private static final String OUTPUTS = "OUTPUTS"; - private static final String PARAMETER_GROUP = "PARAMETER_GROUP"; - private static final String DESCRIPTION = "DESCRIPTION"; - private static final String NESTED_PATTERN = "NESTED_PATTERN"; - - private final Map<String, Pattern> patterns; - - public HeatFileAnalyzerRowDataImpl() { - patterns = new HashMap<>(); - patterns.put(IDENTIFIER, Pattern.compile(HEAT_IDENTIFIER_REGEX)); - patterns.put(RESOURCES, Pattern.compile(HEAT_RESOURCES_REGEX)); - patterns.put(PARAMETERS, Pattern.compile(HEAT_PARAMETERS_REGEX)); - patterns.put(CONDITIONS, Pattern.compile(HEAT_CONDITIONS_REGEX)); - patterns.put(OUTPUTS, Pattern.compile(HEAT_OUTPUTS_REGEX)); - patterns.put(PARAMETER_GROUP, Pattern.compile(HEAT_PARAMETER_GROUP_REGEX)); - patterns.put(DESCRIPTION, Pattern.compile(HEAT_DESCRIPTION_REGEX)); - patterns.put(NESTED_PATTERN, Pattern.compile(HEAT_NESTED_RESOURCE_REGEX)); - } - - @Override - public AnalyzedZipHeatFiles analyzeFilesNotEligibleForModulesFromFileAnalyzer(Map<String, byte[]> files) - throws IOException { - AnalyzedZipHeatFiles analyzedZipHeatFiles = new AnalyzedZipHeatFiles(); - for (Map.Entry<String, byte[]> fileData : files.entrySet()) { - String fileName = fileData.getKey(); - if (!HeatFileAnalyzer.isYamlFile(fileName)) { - analyzedZipHeatFiles.addOtherNonModuleFile(fileName); - continue; - } - - boolean foundHeatIdentifier = false; - try (InputStream is = new ByteArrayInputStream(fileData.getValue()); - BufferedReader bfReader = new BufferedReader(new InputStreamReader(is))) { + private static final String HEAT_IDENTIFIER_REGEX = "^heat_template_version:.*"; + private static final String HEAT_RESOURCES_REGEX = "^resources:\\s*$"; + private static final String HEAT_PARAMETERS_REGEX = "^parameters:\\s*$"; + private static final String HEAT_CONDITIONS_REGEX = "^conditions:\\s*$"; + private static final String HEAT_OUTPUTS_REGEX = "^outputs:\\s*$"; + private static final String HEAT_PARAMETER_GROUP_REGEX = "^parameter_groups:\\s*$"; + private static final String HEAT_DESCRIPTION_REGEX = "^description:\\s*$"; + //allowing spaces at start followed by 'type:' + spaces + any characters + ('.yml' or '.yaml')+ + + // spaces + private static final String HEAT_NESTED_RESOURCE_REGEX = "\\s*type:\\s*\\S*.(yml|yaml)\\s*$"; + private static final String IDENTIFIER = "IDENTIFIER"; + private static final String RESOURCES = "RESOURCES"; + private static final String PARAMETERS = "PARAMETERS"; + private static final String CONDITIONS = "CONDITIONS"; + private static final String OUTPUTS = "OUTPUTS"; + private static final String PARAMETER_GROUP = "PARAMETER_GROUP"; + private static final String DESCRIPTION = "DESCRIPTION"; + private static final String NESTED_PATTERN = "NESTED_PATTERN"; + private final Map<String, Pattern> patterns; + + public HeatFileAnalyzerRowDataImpl() { + patterns = new HashMap<>(); + patterns.put(IDENTIFIER, Pattern.compile(HEAT_IDENTIFIER_REGEX)); + patterns.put(RESOURCES, Pattern.compile(HEAT_RESOURCES_REGEX)); + patterns.put(PARAMETERS, Pattern.compile(HEAT_PARAMETERS_REGEX)); + patterns.put(CONDITIONS, Pattern.compile(HEAT_CONDITIONS_REGEX)); + patterns.put(OUTPUTS, Pattern.compile(HEAT_OUTPUTS_REGEX)); + patterns.put(PARAMETER_GROUP, Pattern.compile(HEAT_PARAMETER_GROUP_REGEX)); + patterns.put(DESCRIPTION, Pattern.compile(HEAT_DESCRIPTION_REGEX)); + patterns.put(NESTED_PATTERN, Pattern.compile(HEAT_NESTED_RESOURCE_REGEX)); + } - String line; - boolean isResourcesSection = false; - Set<String> nestedFilesNames = new HashSet<>(); - while ((line = bfReader.readLine()) != null) { - if (!foundHeatIdentifier && isMatch(patterns.get(IDENTIFIER), line)) { - foundHeatIdentifier = true; - analyzedZipHeatFiles.addModuleFile(fileName); - if (isResourcesSection) // it means the identifier is located after the resources - // section - { - break; + @Override + public AnalyzedZipHeatFiles analyzeFilesNotEligibleForModulesFromFileAnalyzer(Map<String, byte[]> files) throws IOException { + AnalyzedZipHeatFiles analyzedZipHeatFiles = new AnalyzedZipHeatFiles(); + for (Map.Entry<String, byte[]> fileData : files.entrySet()) { + String fileName = fileData.getKey(); + if (!HeatFileAnalyzer.isYamlFile(fileName)) { + analyzedZipHeatFiles.addOtherNonModuleFile(fileName); + continue; } - } else if (isMatch(patterns.get(RESOURCES), line)) { - isResourcesSection = true; - } else if (isResourceSectionEnd(line, isResourcesSection)) { - if (foundHeatIdentifier) { - break; + boolean foundHeatIdentifier = false; + try (InputStream is = new ByteArrayInputStream(fileData.getValue()); BufferedReader bfReader = new BufferedReader( + new InputStreamReader(is))) { + String line; + boolean isResourcesSection = false; + Set<String> nestedFilesNames = new HashSet<>(); + while ((line = bfReader.readLine()) != null) { + if (!foundHeatIdentifier && isMatch(patterns.get(IDENTIFIER), line)) { + foundHeatIdentifier = true; + analyzedZipHeatFiles.addModuleFile(fileName); + if (isResourcesSection) // it means the identifier is located after the resources + + // section + { + break; + } + } else if (isMatch(patterns.get(RESOURCES), line)) { + isResourcesSection = true; + } else if (isResourceSectionEnd(line, isResourcesSection)) { + if (foundHeatIdentifier) { + break; + } + } else if (isResourcesSection) { + Optional<String> optionalNestedFileName = fetchNestedFileName(line); + optionalNestedFileName.ifPresent(nestedFilesNames::add); + } + } + analyzedZipHeatFiles.addNestedFiles(fetchFileNamesToReturn(nestedFilesNames, foundHeatIdentifier)); } - } else if (isResourcesSection) { - Optional<String> optionalNestedFileName = fetchNestedFileName(line); - optionalNestedFileName - .ifPresent(nestedFilesNames::add); - } } - analyzedZipHeatFiles.addNestedFiles(fetchFileNamesToReturn(nestedFilesNames, - foundHeatIdentifier)); - } + return analyzedZipHeatFiles; } - return analyzedZipHeatFiles; - } - - private Optional<String> fetchNestedFileName(String line) { - if (isMatch(patterns.get(NESTED_PATTERN), line)) { - String trimmedLine = line.trim(); - String nestedFileName = trimmedLine - .substring(trimmedLine.indexOf("type:") + "type:".length(), trimmedLine.length()) - .trim(); - return Optional.of(nestedFileName); + private Optional<String> fetchNestedFileName(String line) { + if (isMatch(patterns.get(NESTED_PATTERN), line)) { + String trimmedLine = line.trim(); + String nestedFileName = trimmedLine.substring(trimmedLine.indexOf("type:") + "type:".length(), trimmedLine.length()).trim(); + return Optional.of(nestedFileName); + } + return Optional.empty(); } - return Optional.empty(); - } - private Set<String> fetchFileNamesToReturn(Set<String> filesNamesToReturn, - boolean foundHeatIdentifier) { - if (!foundHeatIdentifier) { - return new HashSet<>(); - } else { - return filesNamesToReturn; + private Set<String> fetchFileNamesToReturn(Set<String> filesNamesToReturn, boolean foundHeatIdentifier) { + if (!foundHeatIdentifier) { + return new HashSet<>(); + } else { + return filesNamesToReturn; + } } - } - private boolean isResourceSectionEnd(String line, boolean isResourcesSection) { - return isResourcesSection && isStartOfNonResourcesHeatSection(line); - } - - private boolean isStartOfNonResourcesHeatSection(String line) { - return isMatch(patterns.get(PARAMETERS), line) || - isMatch(patterns.get(CONDITIONS), line) || - isMatch(patterns.get(OUTPUTS), line) || - isMatch(patterns.get(PARAMETER_GROUP), line) || - isMatch(patterns.get(DESCRIPTION), line); - } + private boolean isResourceSectionEnd(String line, boolean isResourcesSection) { + return isResourcesSection && isStartOfNonResourcesHeatSection(line); + } - private boolean isMatch(Pattern pattern, String line) { - return pattern.matcher(line).matches(); - } + private boolean isStartOfNonResourcesHeatSection(String line) { + return isMatch(patterns.get(PARAMETERS), line) || isMatch(patterns.get(CONDITIONS), line) || isMatch(patterns.get(OUTPUTS), line) || isMatch( + patterns.get(PARAMETER_GROUP), line) || isMatch(patterns.get(DESCRIPTION), line); + } + private boolean isMatch(Pattern pattern, String line) { + return pattern.matcher(line).matches(); + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/etsi/ETSIService.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/etsi/ETSIService.java index 8b56b3fbc0..dad05b64f2 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/etsi/ETSIService.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/etsi/ETSIService.java @@ -17,27 +17,23 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.services.impl.etsi; +import com.vdurmont.semver4j.Semver; import java.io.IOException; import java.nio.file.Path; import java.util.Map; import java.util.Optional; - import org.openecomp.core.utilities.file.FileContentHandler; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; import org.openecomp.sdc.tosca.csar.Manifest; import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel; -import com.vdurmont.semver4j.Semver; - - public interface ETSIService { /** - * Checks package structure is CSAR with TOSCA-Metadata directory according to SOL004 v2.5.1 - * and contains mandatory Entries in Tosca.meta + * Checks package structure is CSAR with TOSCA-Metadata directory according to SOL004 v2.5.1 and contains mandatory Entries in Tosca.meta + * * @param handler contains csar artifacts * @return true if all condition matched, false otherwise * @throws IOException when TOSCA.meta file is invalid @@ -50,20 +46,19 @@ public interface ETSIService { * @param handler The file handler containing the artifacts to move. * @return A Map with pairs of from and to path of the moved artifacts. */ - Optional<Map<String, Path>> moveNonManoFileToArtifactFolder(final FileContentHandler handler) - throws IOException; + Optional<Map<String, Path>> moveNonManoFileToArtifactFolder(final FileContentHandler handler) throws IOException; /** * Updates the main descriptor paths referring the artifacts that were moved. * - * @param toscaServiceModel The tosca service model containing the main descriptor. + * @param toscaServiceModel The tosca service model containing the main descriptor. * @param fromToMovedArtifactMap A Map representing the from and to artifacts path changes. */ - void updateMainDescriptorPaths(final ToscaServiceModel toscaServiceModel, - final Map<String, Path> fromToMovedArtifactMap); + void updateMainDescriptorPaths(final ToscaServiceModel toscaServiceModel, final Map<String, Path> fromToMovedArtifactMap); /** * Retrieves the manifest file from the CSAR + * * @param handler contains csar artifacts * @throws IOException when TOSCA.meta file or manifest file is invalid */ @@ -71,6 +66,7 @@ public interface ETSIService { /** * Determines the type of resource that the CSAR represents + * * @param handler contains csar artifacts * @throws IOException when TOSCA.meta file or manifest file is invalid */ @@ -78,6 +74,7 @@ public interface ETSIService { /** * Determines the type of resource that the CSAR represents + * * @param manifest contains manifest content * @throws IOException when TOSCA.meta file or manifest file is invalid */ @@ -85,9 +82,9 @@ public interface ETSIService { Path getOriginalManifestPath(final FileContentHandler handler) throws IOException; - /** * Determines the highest compatible specification version based on ETSI manifest file + * * @param handler contains csar artifacts * @return Semver representing highest compatible specification version */ @@ -95,6 +92,7 @@ public interface ETSIService { /** * Verifies if SOL004 3.3.1 manifest file has onap_cnf_helm non mano entry + * * @return true if manifest files has onap_cnf_helm non mano entry */ boolean hasCnfEnhancements(final FileContentHandler fileContentHandler) throws IOException; diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/schemagenerator/SchemaGenerator.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/schemagenerator/SchemaGenerator.java index 4aaa9a8a03..35bed3852b 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/schemagenerator/SchemaGenerator.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/schemagenerator/SchemaGenerator.java @@ -12,12 +12,14 @@ * 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. -*/ - + */ package org.openecomp.sdc.vendorsoftwareproduct.services.schemagenerator; import freemarker.template.Template; import freemarker.template.TemplateException; +import java.io.IOException; +import java.io.StringWriter; +import java.io.Writer; import org.openecomp.sdc.common.errors.CoreException; import org.openecomp.sdc.common.errors.ErrorCategory; import org.openecomp.sdc.common.errors.ErrorCode; @@ -25,39 +27,34 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEnti import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.SchemaTemplateContext; import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.SchemaTemplateInput; -import java.io.IOException; -import java.io.StringWriter; -import java.io.Writer; - public class SchemaGenerator { - public static final String SCHEMA_GENERATION_ERROR = "SCHEMA_GENERATION_ERROR"; - private SchemaGenerator() { - // Utility classes, which are a collection of static members, are not meant to be instantiated - } - /** - * Generate string. - * - * @param schemaTemplateContext the schema template context - * @param entityType the entity type - * @param input the input - * @return the string - */ - public static String generate(SchemaTemplateContext schemaTemplateContext, - CompositionEntityType entityType, SchemaTemplateInput input) { - Template schemaTemplate = - SchemaGeneratorConfig.getSchemaTemplate(schemaTemplateContext, entityType); - return processTemplate(input, schemaTemplate); - } + public static final String SCHEMA_GENERATION_ERROR = "SCHEMA_GENERATION_ERROR"; + + private SchemaGenerator() { + // Utility classes, which are a collection of static members, are not meant to be instantiated + } + + /** + * Generate string. + * + * @param schemaTemplateContext the schema template context + * @param entityType the entity type + * @param input the input + * @return the string + */ + public static String generate(SchemaTemplateContext schemaTemplateContext, CompositionEntityType entityType, SchemaTemplateInput input) { + Template schemaTemplate = SchemaGeneratorConfig.getSchemaTemplate(schemaTemplateContext, entityType); + return processTemplate(input, schemaTemplate); + } - private static String processTemplate(SchemaTemplateInput input, Template schemaTemplate) { - try (Writer writer = new StringWriter(1024)) { - schemaTemplate.process(input, writer); - return writer.toString(); - } catch (IOException | TemplateException exception) { - throw new CoreException( - new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION) - .withId(SCHEMA_GENERATION_ERROR).withMessage(exception.getMessage()).build(), exception); + private static String processTemplate(SchemaTemplateInput input, Template schemaTemplate) { + try (Writer writer = new StringWriter(1024)) { + schemaTemplate.process(input, writer); + return writer.toString(); + } catch (IOException | TemplateException exception) { + throw new CoreException(new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION).withId(SCHEMA_GENERATION_ERROR) + .withMessage(exception.getMessage()).build(), exception); + } } - } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/schemagenerator/SchemaGeneratorConfig.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/schemagenerator/SchemaGeneratorConfig.java index 3937ca2f2e..9d00e45bc5 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/schemagenerator/SchemaGeneratorConfig.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/schemagenerator/SchemaGeneratorConfig.java @@ -7,9 +7,9 @@ * 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. @@ -17,13 +17,16 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.services.schemagenerator; import freemarker.cache.StringTemplateLoader; import freemarker.template.Configuration; import freemarker.template.Template; import freemarker.template.TemplateExceptionHandler; +import java.io.File; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; import org.openecomp.core.utilities.applicationconfig.ApplicationConfig; import org.openecomp.core.utilities.applicationconfig.ApplicationConfigFactory; import org.openecomp.core.utilities.applicationconfig.type.ConfigurationData; @@ -33,122 +36,106 @@ import org.openecomp.sdc.common.errors.ErrorCode; import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityType; import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.SchemaTemplateContext; -import java.io.File; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; - public class SchemaGeneratorConfig { - public static final String SCHEMA_GENERATOR_INITIALIZATION_ERROR = - "SCHEMA_GENERATOR_INITIALIZATION_ERROR"; - public static final String SCHEMA_GENERATOR_INITIALIZATION_ERROR_MSG = - "Error occurred while loading questionnaire schema schemaTemplates"; - private static final String CONFIGURATION_NAMESPACE = "vsp.schemaTemplates"; - private static Map<SchemaTemplateId, SchemaTemplate> schemaTemplates = new HashMap<>(); - private static ApplicationConfig applicationConfig = - ApplicationConfigFactory.getInstance().createInterface(); - private static Configuration configuration = new Configuration(Configuration.VERSION_2_3_23); - private static StringTemplateLoader stringLoader = new StringTemplateLoader(); - - static { - configuration.setClassLoaderForTemplateLoading(SchemaGenerator.class.getClassLoader(), - File.pathSeparator); - configuration.setDefaultEncoding("UTF-8"); - configuration.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER); - configuration.setLogTemplateExceptions(true); - configuration.setTemplateLoader(stringLoader); - } - - public static void insertSchemaTemplate(SchemaTemplateContext schemaTemplateContext, - CompositionEntityType entityType, - String schemaTemplateString) { - applicationConfig.insertValue(CONFIGURATION_NAMESPACE, - new SchemaTemplateId(schemaTemplateContext, entityType).toString(), schemaTemplateString); - } - - /** - * Gets schema template. - * - * @param schemaTemplateContext the schema template context - * @param entityType the entity type - * @return the schema template - */ - public static Template getSchemaTemplate(SchemaTemplateContext schemaTemplateContext, - CompositionEntityType entityType) { - SchemaTemplateId id = new SchemaTemplateId(schemaTemplateContext, entityType); - ConfigurationData configurationData = - applicationConfig.getConfigurationData(CONFIGURATION_NAMESPACE, id.toString()); - - SchemaTemplate schemaTemplate = schemaTemplates.get(id); - if (schemaTemplate == null || schemaTemplate.timestamp != configurationData.getTimeStamp()) { - stringLoader.putTemplate(id.toString(), configurationData.getValue()); - Template template; - try { - template = configuration.getTemplate(id.toString()); - } catch (IOException exception) { - throw new CoreException( - new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION) - .withId(SCHEMA_GENERATOR_INITIALIZATION_ERROR) - .withMessage(SCHEMA_GENERATOR_INITIALIZATION_ERROR_MSG).build(), exception); - } - schemaTemplate = new SchemaTemplate(template, configurationData.getTimeStamp()); - schemaTemplates.put(id, schemaTemplate); + public static final String SCHEMA_GENERATOR_INITIALIZATION_ERROR = "SCHEMA_GENERATOR_INITIALIZATION_ERROR"; + public static final String SCHEMA_GENERATOR_INITIALIZATION_ERROR_MSG = "Error occurred while loading questionnaire schema schemaTemplates"; + private static final String CONFIGURATION_NAMESPACE = "vsp.schemaTemplates"; + private static Map<SchemaTemplateId, SchemaTemplate> schemaTemplates = new HashMap<>(); + private static ApplicationConfig applicationConfig = ApplicationConfigFactory.getInstance().createInterface(); + private static Configuration configuration = new Configuration(Configuration.VERSION_2_3_23); + private static StringTemplateLoader stringLoader = new StringTemplateLoader(); + + static { + configuration.setClassLoaderForTemplateLoading(SchemaGenerator.class.getClassLoader(), File.pathSeparator); + configuration.setDefaultEncoding("UTF-8"); + configuration.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER); + configuration.setLogTemplateExceptions(true); + configuration.setTemplateLoader(stringLoader); } - return schemaTemplate.template; - } - - private static class SchemaTemplateId { - private SchemaTemplateContext context; - private CompositionEntityType entityType; - public SchemaTemplateId(SchemaTemplateContext context, CompositionEntityType entityType) { - this.context = context; - this.entityType = entityType; + public static void insertSchemaTemplate(SchemaTemplateContext schemaTemplateContext, CompositionEntityType entityType, + String schemaTemplateString) { + applicationConfig + .insertValue(CONFIGURATION_NAMESPACE, new SchemaTemplateId(schemaTemplateContext, entityType).toString(), schemaTemplateString); } - @Override - public String toString() { - return context + "." + entityType; + /** + * Gets schema template. + * + * @param schemaTemplateContext the schema template context + * @param entityType the entity type + * @return the schema template + */ + public static Template getSchemaTemplate(SchemaTemplateContext schemaTemplateContext, CompositionEntityType entityType) { + SchemaTemplateId id = new SchemaTemplateId(schemaTemplateContext, entityType); + ConfigurationData configurationData = applicationConfig.getConfigurationData(CONFIGURATION_NAMESPACE, id.toString()); + SchemaTemplate schemaTemplate = schemaTemplates.get(id); + if (schemaTemplate == null || schemaTemplate.timestamp != configurationData.getTimeStamp()) { + stringLoader.putTemplate(id.toString(), configurationData.getValue()); + Template template; + try { + template = configuration.getTemplate(id.toString()); + } catch (IOException exception) { + throw new CoreException( + new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION).withId(SCHEMA_GENERATOR_INITIALIZATION_ERROR) + .withMessage(SCHEMA_GENERATOR_INITIALIZATION_ERROR_MSG).build(), exception); + } + schemaTemplate = new SchemaTemplate(template, configurationData.getTimeStamp()); + schemaTemplates.put(id, schemaTemplate); + } + return schemaTemplate.template; } - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null || getClass() != obj.getClass()) { - return false; - } - - SchemaTemplateId that = (SchemaTemplateId) obj; - - if (entityType != that.entityType) { - return false; - } - if (context != that.context) { - return false; - } - - return true; + private static class SchemaTemplateId { + + private SchemaTemplateContext context; + private CompositionEntityType entityType; + + public SchemaTemplateId(SchemaTemplateContext context, CompositionEntityType entityType) { + this.context = context; + this.entityType = entityType; + } + + @Override + public String toString() { + return context + "." + entityType; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || getClass() != obj.getClass()) { + return false; + } + SchemaTemplateId that = (SchemaTemplateId) obj; + if (entityType != that.entityType) { + return false; + } + if (context != that.context) { + return false; + } + return true; + } + + @Override + public int hashCode() { + int result = entityType != null ? entityType.hashCode() : 0; + result = 31 * result + (context != null ? context.hashCode() : 0); + return result; + } } - @Override - public int hashCode() { - int result = entityType != null ? entityType.hashCode() : 0; - result = 31 * result + (context != null ? context.hashCode() : 0); - return result; - } - } + private static class SchemaTemplate { - private static class SchemaTemplate { - private Template template; - private long timestamp; + private Template template; + private long timestamp; - public SchemaTemplate(Template template, long timestamp) { - this.template = template; - this.timestamp = timestamp; + public SchemaTemplate(Template template, long timestamp) { + this.template = template; + this.timestamp = timestamp; + } } - } - } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/utils/CandidateEntityBuilder.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/utils/CandidateEntityBuilder.java index eb4b29d742..726fcbf21f 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/utils/CandidateEntityBuilder.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/utils/CandidateEntityBuilder.java @@ -7,9 +7,9 @@ * 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. @@ -17,9 +17,14 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.services.utils; +import java.io.IOException; +import java.io.InputStream; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; import org.openecomp.core.utilities.file.FileContentHandler; import org.openecomp.core.utilities.json.JsonUtil; import org.openecomp.sdc.common.errors.Messages; @@ -37,70 +42,52 @@ import org.openecomp.sdc.vendorsoftwareproduct.services.impl.HeatFileAnalyzerRow import org.openecomp.sdc.vendorsoftwareproduct.types.CandidateDataEntityTo; import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.AnalyzedZipHeatFiles; -import java.io.IOException; -import java.io.InputStream; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - public class CandidateEntityBuilder { - private final CandidateService candidateService; - - public CandidateEntityBuilder(CandidateService candidateService) { - this.candidateService = candidateService; - } - public OrchestrationTemplateCandidateData buildCandidateEntityFromZip( - VspDetails vspDetails, byte[] uploadedFileData, FileContentHandler contentMap, - Map<String, List<ErrorMessage>> uploadErrors) throws Exception { - //mdcDataDebugMessage.debugEntryMessage("VSP Id", vspDetails.getId()); + private final CandidateService candidateService; - try (InputStream zipFileManifest = contentMap.getFileContentAsStream(SdcCommon.MANIFEST_NAME)) { - HeatFileAnalyzer heatFileAnalyzer = new HeatFileAnalyzerRowDataImpl(); - AnalyzedZipHeatFiles analyzedZipHeatFiles = - heatFileAnalyzer.analyzeFilesNotEligibleForModulesFromFileAnalyzer(contentMap.getFiles()); - HeatStructureTree tree = getHeatStructureTree(vspDetails, contentMap, analyzedZipHeatFiles); - - CandidateDataEntityTo candidateDataEntityTo = - new CandidateDataEntityTo(vspDetails.getId(), vspDetails.getVersion(), uploadedFileData, - tree, contentMap); - candidateDataEntityTo.setErrors(uploadErrors); - OrchestrationTemplateCandidateData candidateDataEntity = - candidateService.createCandidateDataEntity(candidateDataEntityTo, zipFileManifest, - analyzedZipHeatFiles); - return candidateDataEntity; + public CandidateEntityBuilder(CandidateService candidateService) { + this.candidateService = candidateService; } - } - private HeatStructureTree getHeatStructureTree(VspDetails vspDetails, - FileContentHandler contentMap, - AnalyzedZipHeatFiles analyzedZipHeatFiles) - throws IOException { - addManifestToFileContentMapIfNotExist(vspDetails, contentMap, analyzedZipHeatFiles); - HeatTreeManager heatTreeManager = HeatTreeManagerUtil.initHeatTreeManager(contentMap); - heatTreeManager.createTree(); - return heatTreeManager.getTree(); - } + public OrchestrationTemplateCandidateData buildCandidateEntityFromZip(VspDetails vspDetails, byte[] uploadedFileData, + FileContentHandler contentMap, Map<String, List<ErrorMessage>> uploadErrors) + throws Exception { + //mdcDataDebugMessage.debugEntryMessage("VSP Id", vspDetails.getId()); + try (InputStream zipFileManifest = contentMap.getFileContentAsStream(SdcCommon.MANIFEST_NAME)) { + HeatFileAnalyzer heatFileAnalyzer = new HeatFileAnalyzerRowDataImpl(); + AnalyzedZipHeatFiles analyzedZipHeatFiles = heatFileAnalyzer.analyzeFilesNotEligibleForModulesFromFileAnalyzer(contentMap.getFiles()); + HeatStructureTree tree = getHeatStructureTree(vspDetails, contentMap, analyzedZipHeatFiles); + CandidateDataEntityTo candidateDataEntityTo = new CandidateDataEntityTo(vspDetails.getId(), vspDetails.getVersion(), uploadedFileData, + tree, contentMap); + candidateDataEntityTo.setErrors(uploadErrors); + OrchestrationTemplateCandidateData candidateDataEntity = candidateService + .createCandidateDataEntity(candidateDataEntityTo, zipFileManifest, analyzedZipHeatFiles); + return candidateDataEntity; + } + } - private void addManifestToFileContentMapIfNotExist(VspDetails vspDetails, - FileContentHandler fileContentHandler, - AnalyzedZipHeatFiles analyzedZipHeatFiles) - throws IOException { - try (InputStream manifest = fileContentHandler.getFileContentAsStream(SdcCommon.MANIFEST_NAME)) { + private HeatStructureTree getHeatStructureTree(VspDetails vspDetails, FileContentHandler contentMap, AnalyzedZipHeatFiles analyzedZipHeatFiles) + throws IOException { + addManifestToFileContentMapIfNotExist(vspDetails, contentMap, analyzedZipHeatFiles); + HeatTreeManager heatTreeManager = HeatTreeManagerUtil.initHeatTreeManager(contentMap); + heatTreeManager.createTree(); + return heatTreeManager.getTree(); + } - if (Objects.isNull(manifest)) { - Optional<ManifestContent> manifestContentOptional = - candidateService.createManifest(vspDetails, fileContentHandler, analyzedZipHeatFiles); - if (!manifestContentOptional.isPresent()) { - throw new RuntimeException(Messages.CREATE_MANIFEST_FROM_ZIP.getErrorMessage()); + private void addManifestToFileContentMapIfNotExist(VspDetails vspDetails, FileContentHandler fileContentHandler, + AnalyzedZipHeatFiles analyzedZipHeatFiles) throws IOException { + try (InputStream manifest = fileContentHandler.getFileContentAsStream(SdcCommon.MANIFEST_NAME)) { + if (Objects.isNull(manifest)) { + Optional<ManifestContent> manifestContentOptional = candidateService + .createManifest(vspDetails, fileContentHandler, analyzedZipHeatFiles); + if (!manifestContentOptional.isPresent()) { + throw new RuntimeException(Messages.CREATE_MANIFEST_FROM_ZIP.getErrorMessage()); + } + ManifestContent manifestContent = manifestContentOptional.get(); + fileContentHandler.addFile(SdcCommon.MANIFEST_NAME, String.valueOf(JsonUtil.sbObject2Json(manifestContent)).getBytes()); + } + } finally { } - ManifestContent manifestContent = manifestContentOptional.get(); - fileContentHandler.addFile( - SdcCommon.MANIFEST_NAME, - String.valueOf(JsonUtil.sbObject2Json(manifestContent)).getBytes()); - } - } finally { } - } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/CandidateDataEntityTo.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/CandidateDataEntityTo.java index 3a535e125e..89090aaeb4 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/CandidateDataEntityTo.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/CandidateDataEntityTo.java @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.types; import java.util.HashMap; @@ -49,13 +48,11 @@ public class CandidateDataEntityTo { * @param tree the tree * @param contentMap the content map */ - public CandidateDataEntityTo(String vspId, Version version, byte[] uploadedFileData, - HeatStructureTree tree, FileContentHandler contentMap) { + public CandidateDataEntityTo(String vspId, Version version, byte[] uploadedFileData, HeatStructureTree tree, FileContentHandler contentMap) { this.vspId = vspId; this.version = version; this.uploadedFileData = uploadedFileData; this.tree = tree; this.contentMap = contentMap; } - } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/candidateheat/AnalyzedZipHeatFiles.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/candidateheat/AnalyzedZipHeatFiles.java index 63067e3ede..d4d658b67e 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/candidateheat/AnalyzedZipHeatFiles.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/candidateheat/AnalyzedZipHeatFiles.java @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat; import java.util.Collection; @@ -62,5 +61,4 @@ public class AnalyzedZipHeatFiles { public Collection<String> getFilesNotEligbleForModules() { return CollectionUtils.union(this.getNestedFiles(), this.getOtherNonModuleFiles()); } - } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/candidateheat/Constants.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/candidateheat/Constants.java index 4e19dd67e9..c834fccae5 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/candidateheat/Constants.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/candidateheat/Constants.java @@ -7,9 +7,9 @@ * 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. @@ -17,11 +17,11 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat; public class Constants { - public static final String BASE_HEAT_REGEX = "(^base_.*\\.|.*_base\\.|.*_base_.*\\.|^base\\.)(yaml|yml)$"; - public static final String VOL_FILE_NAME_SUFFIX = "_volume"; - public static final String ENV_FILE_EXTENSION = ".env"; + + public static final String BASE_HEAT_REGEX = "(^base_.*\\.|.*_base\\.|.*_base_.*\\.|^base\\.)(yaml|yml)$"; + public static final String VOL_FILE_NAME_SUFFIX = "_volume"; + public static final String ENV_FILE_EXTENSION = ".env"; } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/candidateheat/FilesDataStructure.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/candidateheat/FilesDataStructure.java index 22c4534b6c..3c0bf8eb3e 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/candidateheat/FilesDataStructure.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/candidateheat/FilesDataStructure.java @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat; import java.util.ArrayList; @@ -35,5 +34,4 @@ public class FilesDataStructure { private List<String> unassigned = new ArrayList<>(); private List<String> artifacts = new ArrayList<>(); private List<String> nested = new ArrayList<>(); - } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/candidateheat/Module.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/candidateheat/Module.java index 25a004e890..30c8e0796a 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/candidateheat/Module.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/candidateheat/Module.java @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat; import lombok.Getter; @@ -37,5 +36,4 @@ public class Module { private String vol; private String volEnv; private FileData.Type type; - } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/Component.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/Component.java index de15c64433..7ae20c6975 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/Component.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/Component.java @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.types.composition; import java.util.List; @@ -34,5 +33,4 @@ public class Component { private List<Nic> nics; private List<Image> images; private List<ComputeData> compute; - } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/ComponentComputeAssociation.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/ComponentComputeAssociation.java index c58a1df163..0130b708bd 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/ComponentComputeAssociation.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/ComponentComputeAssociation.java @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.types.composition; import lombok.Getter; @@ -31,5 +30,4 @@ public class ComponentComputeAssociation { private String componentId; private String computeFlavorId; - } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/ComponentData.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/ComponentData.java index 8e0d1874c2..cfc97bdf74 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/ComponentData.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/ComponentData.java @@ -17,7 +17,6 @@ * Modifications copyright (c) 2019 Nokia * ================================================================================ */ - package org.openecomp.sdc.vendorsoftwareproduct.types.composition; import lombok.EqualsAndHashCode; @@ -34,5 +33,4 @@ public class ComponentData implements CompositionDataEntity { private String name; private String description; private String displayName; - } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/CompositionData.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/CompositionData.java index 7809cf5949..c0b239533e 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/CompositionData.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/CompositionData.java @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.types.composition; import java.util.List; @@ -32,5 +31,4 @@ public class CompositionData { private List<Network> networks; private List<Component> components; - } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/CompositionDataEntity.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/CompositionDataEntity.java index 9c09b0ded4..0194c57477 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/CompositionDataEntity.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/CompositionDataEntity.java @@ -7,9 +7,9 @@ * 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. @@ -17,8 +17,8 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.types.composition; public interface CompositionDataEntity { + } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/CompositionEntityId.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/CompositionEntityId.java index c361179a50..ec026436f8 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/CompositionEntityId.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/CompositionEntityId.java @@ -19,7 +19,6 @@ * Modifications copyright (c) 2019 Nokia * ================================================================================ */ - package org.openecomp.sdc.vendorsoftwareproduct.types.composition; import lombok.EqualsAndHashCode; @@ -36,9 +35,6 @@ public class CompositionEntityId { @Override public String toString() { - return parentId == null - ? id - : parentId + "/" + id; + return parentId == null ? id : parentId + "/" + id; } - } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/CompositionEntityType.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/CompositionEntityType.java index 2b1ea16889..3c92977040 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/CompositionEntityType.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/CompositionEntityType.java @@ -7,9 +7,9 @@ * 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. @@ -17,16 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.types.composition; - -public enum CompositionEntityType { - vsp, - network, - component, - deployment, - image, - nic, - compute -} +public enum CompositionEntityType {vsp, network, component, deployment, image, nic, compute} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/CompositionEntityValidationData.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/CompositionEntityValidationData.java index 8bb0881fa7..b3116ce0a5 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/CompositionEntityValidationData.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/CompositionEntityValidationData.java @@ -19,7 +19,6 @@ * Modifications copyright (c) 2019 Nokia * ================================================================================ */ - package org.openecomp.sdc.vendorsoftwareproduct.types.composition; import java.util.ArrayList; @@ -57,5 +56,4 @@ public class CompositionEntityValidationData { } subEntitiesValidationData.add(subEntityValidationData); } - } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/ComputeData.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/ComputeData.java index bff5df6b08..a78d62ca4d 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/ComputeData.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/ComputeData.java @@ -19,7 +19,6 @@ * Modifications copyright (c) 2019 Nokia * ================================================================================ */ - package org.openecomp.sdc.vendorsoftwareproduct.types.composition; import lombok.EqualsAndHashCode; @@ -39,5 +38,4 @@ public class ComputeData implements CompositionDataEntity { public ComputeData(String name) { this.name = name; } - } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/DeploymentFlavor.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/DeploymentFlavor.java index 6357799e65..6d802a3ef4 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/DeploymentFlavor.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/DeploymentFlavor.java @@ -17,10 +17,8 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.types.composition; - import java.util.List; import lombok.Getter; import lombok.NoArgsConstructor; @@ -35,5 +33,4 @@ public class DeploymentFlavor implements CompositionDataEntity { private String description; private String featureGroupId; private List<ComponentComputeAssociation> componentComputeAssociations; - } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/ExtractCompositionDataContext.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/ExtractCompositionDataContext.java index ef202d013d..b5ac61fc36 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/ExtractCompositionDataContext.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/ExtractCompositionDataContext.java @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.types.composition; import java.util.ArrayList; diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/Image.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/Image.java index 2c624721cb..e3e19bea49 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/Image.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/Image.java @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.types.composition; import lombok.Getter; @@ -35,5 +34,4 @@ public class Image implements CompositionDataEntity { public Image(String fileName) { this.fileName = fileName; } - } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/ImageData.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/ImageData.java index 191a454091..0c4346bcd5 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/ImageData.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/ImageData.java @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.types.composition; import lombok.AllArgsConstructor; @@ -33,5 +32,4 @@ public class ImageData implements CompositionDataEntity { private String fileName; private String description; - } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/ImageFormat.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/ImageFormat.java index a9de3483ef..d12ca6739d 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/ImageFormat.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/ImageFormat.java @@ -7,9 +7,9 @@ * 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. @@ -17,17 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.types.composition; -public enum ImageFormat { - aki, - ami, - ari, - iso, - qcow2, - raw, - vdi, - vhd, - vmdk -} +public enum ImageFormat {aki, ami, ari, iso, qcow2, raw, vdi, vhd, vmdk} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/Network.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/Network.java index cc5a5afbae..b0cf064d9b 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/Network.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/Network.java @@ -19,7 +19,6 @@ * Modifications copyright (c) 2019 Nokia * ================================================================================ */ - package org.openecomp.sdc.vendorsoftwareproduct.types.composition; import lombok.EqualsAndHashCode; @@ -35,5 +34,4 @@ public class Network implements CompositionDataEntity { private String name; private boolean dhcp; - } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/NetworkType.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/NetworkType.java index d90135a205..c8c60c861a 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/NetworkType.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/NetworkType.java @@ -7,9 +7,9 @@ * 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. @@ -17,10 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.types.composition; -public enum NetworkType { - Internal, - External -} +public enum NetworkType {Internal, External} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/Nic.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/Nic.java index cc23d24407..96beed2c3e 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/Nic.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/Nic.java @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.types.composition; import lombok.EqualsAndHashCode; @@ -37,5 +36,4 @@ public class Nic implements CompositionDataEntity { private String networkName; private NetworkType networkType; private String networkDescription; - } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/ComponentQuestionnaire.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/ComponentQuestionnaire.java index 6699671d61..5c61b8f787 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/ComponentQuestionnaire.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/ComponentQuestionnaire.java @@ -17,10 +17,8 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component; - import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; @@ -40,5 +38,4 @@ public class ComponentQuestionnaire { private HighAvailabilityAndLoadBalancing highAvailabilityAndLoadBalancing; private Network network; private Storage storage; - } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/compute/Compute.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/compute/Compute.java index dd5fb9057c..60fe72ada6 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/compute/Compute.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/compute/Compute.java @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.compute; import lombok.Getter; @@ -32,5 +31,4 @@ public class Compute { private GuestOS guestOS; private NumOfVMs numOfVMs; private VmSizing vmSizing; - } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/compute/GuestOS.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/compute/GuestOS.java index 54de06b1c4..16aef5866d 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/compute/GuestOS.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/compute/GuestOS.java @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.compute; import lombok.Getter; @@ -32,5 +31,4 @@ public class GuestOS { private String name; private String tools; private Number bitSize; - } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/compute/NumOfVMs.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/compute/NumOfVMs.java index f135ba78ff..37bb2573b8 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/compute/NumOfVMs.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/compute/NumOfVMs.java @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.compute; import lombok.Getter; @@ -33,6 +32,4 @@ public class NumOfVMs { private int maximum; private String CpuOverSubscriptionRatio; private String MemoryRAM; - - } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/compute/VmSizing.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/compute/VmSizing.java index 0f72d03d10..9bf3ff4c6b 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/compute/VmSizing.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/compute/VmSizing.java @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.compute; import lombok.Getter; @@ -35,5 +34,4 @@ public class VmSizing { private Number IOOperationsPerSec; private String cpuOverSubscriptionRatio; private String memoryRAM; - } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/general/General.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/general/General.java index 328715b90e..6482faff8a 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/general/General.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/general/General.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.general; import lombok.Getter; @@ -25,12 +24,11 @@ import lombok.Setter; @NoArgsConstructor public class General { + protected Recovery recovery; private Hypervisor hypervisor; private Image image; - protected Recovery recovery; private String dnsConfiguration; private String vmCloneUsage; private String nfcNamingCode; private String nfcFunction; - } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/general/Hypervisor.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/general/Hypervisor.java index d2ef0456a9..7ae9cb3ccd 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/general/Hypervisor.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/general/Hypervisor.java @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.general; import lombok.Getter; @@ -32,5 +31,4 @@ public class Hypervisor { private String hypervisor; private String drivers; private String containerFeaturesDescription; - } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/general/Image.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/general/Image.java index e00d022532..989914a1df 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/general/Image.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/general/Image.java @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.general; import lombok.Getter; @@ -33,5 +32,4 @@ public class Image { private String providedBy; private Number bootDiskSizePerVM; private Number ephemeralDiskSizePerVM; - } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/general/Recovery.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/general/Recovery.java index 255e9f9235..84d253999d 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/general/Recovery.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/general/Recovery.java @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.general; import lombok.Getter; @@ -32,5 +31,4 @@ public class Recovery { private Number pointObjective; private Number timeObjective; private String vmProcessFailuresHandling; - } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/highAvailability/HighAvailabilityAndLoadBalancing.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/highAvailability/HighAvailabilityAndLoadBalancing.java index 75c4e31b15..61ba8b1e00 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/highAvailability/HighAvailabilityAndLoadBalancing.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/highAvailability/HighAvailabilityAndLoadBalancing.java @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.highAvailability; import lombok.Getter; @@ -37,5 +36,4 @@ public class HighAvailabilityAndLoadBalancing { private String loadDistributionMechanism; private String isComponentMandatory; private String highAvailabilityMode; - } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/image/ImageDetails.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/image/ImageDetails.java index 9d136a167f..25aa9abe37 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/image/ImageDetails.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/image/ImageDetails.java @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.image; import lombok.Getter; @@ -32,5 +31,4 @@ public class ImageDetails { private String version; private String format; private String md5; - } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/network/Network.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/network/Network.java index 197df1c277..665d69ed56 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/network/Network.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/network/Network.java @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.network; import lombok.Getter; @@ -30,5 +29,4 @@ import lombok.Setter; public class Network { private NetworkCapacity networkCapacity; - } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/network/NetworkCapacity.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/network/NetworkCapacity.java index 8976d8298e..2175000040 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/network/NetworkCapacity.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/network/NetworkCapacity.java @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.network; import lombok.Getter; @@ -31,5 +30,4 @@ public class NetworkCapacity { private String protocolWithHighestTrafficProfileAcrossAllNICs; private int networkTransactionsPerSecond; - } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/storage/Backup.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/storage/Backup.java index 01b6f7fe1f..bd280bc868 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/storage/Backup.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/storage/Backup.java @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.storage; import lombok.Getter; @@ -33,5 +32,4 @@ public class Backup { private String backupSolution; private String backupNIC; private Number backupStorageSize; - } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/storage/LogBackup.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/storage/LogBackup.java index ff46e6f095..a266ab9939 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/storage/LogBackup.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/storage/LogBackup.java @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.storage; import lombok.Getter; @@ -33,5 +32,4 @@ public class LogBackup { private Number logBackupFrequency; private int logRetentionPeriod; private String logFileLocation; - } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/storage/SnapshotBackup.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/storage/SnapshotBackup.java index 4266ffbdf8..a9d49ccbc4 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/storage/SnapshotBackup.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/storage/SnapshotBackup.java @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.storage; import lombok.Getter; @@ -30,5 +29,4 @@ import lombok.Setter; public class SnapshotBackup { private int snapshotFrequency; - } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/storage/Storage.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/storage/Storage.java index b41536b720..80fd9c76ff 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/storage/Storage.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/storage/Storage.java @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.storage; import lombok.Getter; @@ -32,5 +31,4 @@ public class Storage { private Backup backup; private LogBackup logBackup; private SnapshotBackup snapshotBackup; - } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/AcceptableJitter.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/AcceptableJitter.java index 0a6b993bde..0fc4c64a15 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/AcceptableJitter.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/AcceptableJitter.java @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.nic; import lombok.Getter; @@ -32,5 +31,4 @@ public class AcceptableJitter { private int mean; private int max; private int variable; - } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/IpConfiguration.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/IpConfiguration.java index 355fafbc6e..f031f29331 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/IpConfiguration.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/IpConfiguration.java @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.nic; import lombok.Getter; @@ -31,5 +30,4 @@ public class IpConfiguration { private boolean ipv4Required; private boolean ipv6Required; - } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/Network.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/Network.java index af0ad1f7f6..3892fcb635 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/Network.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/Network.java @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.nic; import lombok.Getter; @@ -32,5 +31,4 @@ import lombok.ToString; public class Network { private String networkDescription; - } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/NicQuestionnaire.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/NicQuestionnaire.java index d41c85506e..9b5dd396d5 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/NicQuestionnaire.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/NicQuestionnaire.java @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.nic; import lombok.Getter; @@ -33,5 +32,4 @@ public class NicQuestionnaire { private IpConfiguration ipConfiguration; private Network network; private Sizing sizing; - } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/PacketsAndBytes.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/PacketsAndBytes.java index 9eddf3bf6c..2f8788646b 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/PacketsAndBytes.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/PacketsAndBytes.java @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.nic; import lombok.Getter; @@ -31,5 +30,4 @@ public class PacketsAndBytes { private PeakAndAvg packets; private PeakAndAvg bytes; - } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/PeakAndAvg.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/PeakAndAvg.java index 6e50f3b29b..811c35b89f 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/PeakAndAvg.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/PeakAndAvg.java @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.nic; import lombok.Getter; @@ -31,5 +30,4 @@ public class PeakAndAvg { private int peak; private Number avg; - } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/Protocols.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/Protocols.java index f50d909fbb..2e9c923227 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/Protocols.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/Protocols.java @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.nic; import java.util.ArrayList; @@ -35,5 +34,4 @@ public class Protocols { private List<String> protocols = new ArrayList<>(); private String protocolWithHighestTrafficProfile; - } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/Sizing.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/Sizing.java index c77d25903d..45797b8d70 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/Sizing.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/Sizing.java @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.nic; import lombok.Getter; @@ -35,5 +34,4 @@ public class Sizing { private PacketsAndBytes outflowTrafficPerSecond; private PacketsAndBytes flowLength; private AcceptableJitter acceptableJitter; - } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/vsp/VspQuestionnaire.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/vsp/VspQuestionnaire.java index ab416d47d3..1919fb0fe5 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/vsp/VspQuestionnaire.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/vsp/VspQuestionnaire.java @@ -17,10 +17,8 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.vsp; - import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; @@ -32,5 +30,4 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.vsp.general.G public class VspQuestionnaire { private General general; - } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/vsp/general/Availability.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/vsp/general/Availability.java index 1c457c546c..5130342bba 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/vsp/general/Availability.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/vsp/general/Availability.java @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.vsp.general; import lombok.Getter; @@ -30,5 +29,4 @@ import lombok.Setter; public class Availability { private boolean useAvailabilityZonesForHighAvailability; - } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/vsp/general/General.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/vsp/general/General.java index 1aaba93f8e..eb38ce14d4 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/vsp/general/General.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/vsp/general/General.java @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.vsp.general; import lombok.Getter; @@ -33,5 +32,4 @@ public class General { private Availability availability; private RegionsData regionsData; private StorageDataReplication storageDataReplication; - } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/vsp/general/RegionsData.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/vsp/general/RegionsData.java index 093abcd652..bacbff4799 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/vsp/general/RegionsData.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/vsp/general/RegionsData.java @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.vsp.general; import java.util.ArrayList; @@ -33,5 +32,4 @@ public class RegionsData { private boolean multiRegion; private List<String> regions = new ArrayList<>(); - } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/vsp/general/StorageDataReplication.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/vsp/general/StorageDataReplication.java index 766b3bb1f9..bea4cf3ab8 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/vsp/general/StorageDataReplication.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/vsp/general/StorageDataReplication.java @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.vsp.general; import lombok.Getter; @@ -34,5 +33,4 @@ public class StorageDataReplication { private Number storageReplicationFrequency; private String storageReplicationSource; private String storageReplicationDestination; - } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/ComponentCompositionSchemaInput.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/ComponentCompositionSchemaInput.java index d20d3efb93..fab11e7d8b 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/ComponentCompositionSchemaInput.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/ComponentCompositionSchemaInput.java @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator; import lombok.Getter; @@ -32,5 +31,4 @@ public class ComponentCompositionSchemaInput implements SchemaTemplateInput { private boolean manual; private ComponentData component; - } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/ComponentQuestionnaireSchemaInput.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/ComponentQuestionnaireSchemaInput.java index b0c2b89536..c2e6478389 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/ComponentQuestionnaireSchemaInput.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/ComponentQuestionnaireSchemaInput.java @@ -14,7 +14,6 @@ * limitations under the License. * Modifications copyright (c) 2019 Nokia */ - package org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator; import java.util.List; @@ -30,5 +29,4 @@ public class ComponentQuestionnaireSchemaInput implements SchemaTemplateInput { private Map componentQuestionnaireData; private String componentDisplayName; private boolean manual; - } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/ComputeCompositionSchemaInput.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/ComputeCompositionSchemaInput.java index 5d87dd82c1..2410838b5e 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/ComputeCompositionSchemaInput.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/ComputeCompositionSchemaInput.java @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator; import lombok.Getter; @@ -32,5 +31,4 @@ public class ComputeCompositionSchemaInput implements SchemaTemplateInput { private boolean manual; private ComputeData compute; - } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/DeploymentFlavorCompositionSchemaInput.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/DeploymentFlavorCompositionSchemaInput.java index ce8d51cac2..81f3922a5e 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/DeploymentFlavorCompositionSchemaInput.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/DeploymentFlavorCompositionSchemaInput.java @@ -17,10 +17,8 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator; - import java.util.Collection; import lombok.Getter; import lombok.NoArgsConstructor; @@ -35,5 +33,4 @@ public class DeploymentFlavorCompositionSchemaInput implements SchemaTemplateInp private boolean manual; private DeploymentFlavor deploymentFlavor; private Collection<String> featureGroupIds; - } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/ImageCompositionSchemaInput.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/ImageCompositionSchemaInput.java index a9ab142cc1..f603a981ec 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/ImageCompositionSchemaInput.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/ImageCompositionSchemaInput.java @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator; import lombok.Getter; @@ -32,5 +31,4 @@ public class ImageCompositionSchemaInput implements SchemaTemplateInput { private boolean manual; private Image image; - } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/NetworkCompositionSchemaInput.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/NetworkCompositionSchemaInput.java index d652e0af44..c6970a3a01 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/NetworkCompositionSchemaInput.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/NetworkCompositionSchemaInput.java @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator; import lombok.Getter; @@ -32,5 +31,4 @@ public class NetworkCompositionSchemaInput implements SchemaTemplateInput { private boolean manual; private Network network; - } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/NicCompositionSchemaInput.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/NicCompositionSchemaInput.java index 3cf729bec7..e5b9392f51 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/NicCompositionSchemaInput.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/NicCompositionSchemaInput.java @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator; import java.util.Collection; @@ -34,5 +33,4 @@ public class NicCompositionSchemaInput implements SchemaTemplateInput { private boolean manual; private Nic nic; private Collection<String> networkIds; - } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/SchemaTemplateContext.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/SchemaTemplateContext.java index 3ee3e4a5e6..511cfb2f27 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/SchemaTemplateContext.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/SchemaTemplateContext.java @@ -7,9 +7,9 @@ * 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. @@ -17,10 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator; -public enum SchemaTemplateContext { - composition, - questionnaire -} +public enum SchemaTemplateContext {composition, questionnaire} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/SchemaTemplateInput.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/SchemaTemplateInput.java index 93e614f98b..fd13f2daeb 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/SchemaTemplateInput.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/SchemaTemplateInput.java @@ -7,9 +7,9 @@ * 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. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator; public interface SchemaTemplateInput { diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/errors/OrchestrationTemplateFileExtensionErrorBuilder.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/errors/OrchestrationTemplateFileExtensionErrorBuilder.java index 58faa41872..caf4f0486d 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/errors/OrchestrationTemplateFileExtensionErrorBuilder.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/errors/OrchestrationTemplateFileExtensionErrorBuilder.java @@ -7,9 +7,9 @@ * 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. @@ -17,26 +17,25 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.errors; +import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.INVALID_EXTENSION; + import org.openecomp.sdc.common.errors.ErrorCategory; import org.openecomp.sdc.common.errors.ErrorCode; -import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.INVALID_EXTENSION; - public class OrchestrationTemplateFileExtensionErrorBuilder { - private static final String INVALID_EXTENSION_MSG = "Invalid file extension. Valid extensions " + - "are : zip, csar."; - private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder(); - public OrchestrationTemplateFileExtensionErrorBuilder(){ - builder.withId(INVALID_EXTENSION); - builder.withCategory(ErrorCategory.APPLICATION); - builder.withMessage(String.format(INVALID_EXTENSION_MSG)); - } + private static final String INVALID_EXTENSION_MSG = "Invalid file extension. Valid extensions " + "are : zip, csar."; + private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder(); + + public OrchestrationTemplateFileExtensionErrorBuilder() { + builder.withId(INVALID_EXTENSION); + builder.withCategory(ErrorCategory.APPLICATION); + builder.withMessage(String.format(INVALID_EXTENSION_MSG)); + } - public ErrorCode build() { - return builder.build(); - } + public ErrorCode build() { + return builder.build(); + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/errors/VendorSoftwareProductCreationFailedBuilder.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/errors/VendorSoftwareProductCreationFailedBuilder.java index a7abbe0dd9..1dc1c40ca9 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/errors/VendorSoftwareProductCreationFailedBuilder.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/errors/VendorSoftwareProductCreationFailedBuilder.java @@ -7,9 +7,9 @@ * 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. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.errors; import org.openecomp.sdc.common.errors.ErrorCategory; @@ -25,21 +24,20 @@ import org.openecomp.sdc.common.errors.ErrorCode; import org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes; public class VendorSoftwareProductCreationFailedBuilder { - private static final String VSP_CREATION_FAILED = "Failed to create VSP; %s"; - private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder(); - /** - * Instantiates a new Vendor software product creation failed error builder. - * - */ - public VendorSoftwareProductCreationFailedBuilder(String reason) { - builder.withId(VendorSoftwareProductErrorCodes.FAILED_TO_CREATE_VSP); - builder.withCategory(ErrorCategory.APPLICATION); - builder - .withMessage(String.format(VSP_CREATION_FAILED, reason)); - } + private static final String VSP_CREATION_FAILED = "Failed to create VSP; %s"; + private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder(); + + /** + * Instantiates a new Vendor software product creation failed error builder. + */ + public VendorSoftwareProductCreationFailedBuilder(String reason) { + builder.withId(VendorSoftwareProductErrorCodes.FAILED_TO_CREATE_VSP); + builder.withCategory(ErrorCategory.APPLICATION); + builder.withMessage(String.format(VSP_CREATION_FAILED, reason)); + } - public ErrorCode build() { - return builder.build(); - } + public ErrorCode build() { + return builder.build(); + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/errors/VendorSoftwareProductNotFoundErrorBuilder.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/errors/VendorSoftwareProductNotFoundErrorBuilder.java index ef5b43fad4..8cb2d72d25 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/errors/VendorSoftwareProductNotFoundErrorBuilder.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/errors/VendorSoftwareProductNotFoundErrorBuilder.java @@ -7,9 +7,9 @@ * 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. @@ -17,31 +17,30 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.errors; +import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.VSP_NOT_FOUND; import org.openecomp.sdc.common.errors.ErrorCategory; import org.openecomp.sdc.common.errors.ErrorCode; -import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.VSP_NOT_FOUND; - public class VendorSoftwareProductNotFoundErrorBuilder { - private static final String VSP_FOUND_MSG = "Vendor software product with Id %s not found."; - private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder(); - /** - * Instantiates a new Vendor software product not found error builder. - * - * @param vendorSoftwareProductId the vendor software product id - */ - public VendorSoftwareProductNotFoundErrorBuilder(String vendorSoftwareProductId) { - builder.withId(VSP_NOT_FOUND); - builder.withCategory(ErrorCategory.APPLICATION); - builder.withMessage(String.format(VSP_FOUND_MSG, vendorSoftwareProductId)); - } + private static final String VSP_FOUND_MSG = "Vendor software product with Id %s not found."; + private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder(); + + /** + * Instantiates a new Vendor software product not found error builder. + * + * @param vendorSoftwareProductId the vendor software product id + */ + public VendorSoftwareProductNotFoundErrorBuilder(String vendorSoftwareProductId) { + builder.withId(VSP_NOT_FOUND); + builder.withCategory(ErrorCategory.APPLICATION); + builder.withMessage(String.format(VSP_FOUND_MSG, vendorSoftwareProductId)); + } - public ErrorCode build() { - return builder.build(); - } + public ErrorCode build() { + return builder.build(); + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/ComponentDaoFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/ComponentDaoFactoryImpl.java index 1ef0caac0c..bcf4cf1dcd 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/ComponentDaoFactoryImpl.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/ComponentDaoFactoryImpl.java @@ -7,9 +7,9 @@ * 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. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.impl; import org.openecomp.core.zusammen.api.ZusammenAdaptorFactory; @@ -26,11 +25,11 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDaoFactory; import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.ComponentDaoZusammenImpl; public class ComponentDaoFactoryImpl extends ComponentDaoFactory { - private static final ComponentDao INSTANCE = new ComponentDaoZusammenImpl( - ZusammenAdaptorFactory.getInstance().createInterface()); - @Override - public ComponentDao createInterface() { - return INSTANCE; - } + private static final ComponentDao INSTANCE = new ComponentDaoZusammenImpl(ZusammenAdaptorFactory.getInstance().createInterface()); + + @Override + public ComponentDao createInterface() { + return INSTANCE; + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/ComponentDependencyModelDaoFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/ComponentDependencyModelDaoFactoryImpl.java index f4f36c3355..180f11917a 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/ComponentDependencyModelDaoFactoryImpl.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/ComponentDependencyModelDaoFactoryImpl.java @@ -7,9 +7,9 @@ * 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. @@ -17,10 +17,8 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.impl; - import org.openecomp.core.zusammen.api.ZusammenAdaptorFactory; import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDependencyModelDao; import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDependencyModelDaoFactory; @@ -28,11 +26,11 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.ComponentDepend public class ComponentDependencyModelDaoFactoryImpl extends ComponentDependencyModelDaoFactory { - private static final ComponentDependencyModelDao INSTANCE = new - ComponentDependencyModelDaoZusammenImpl( ZusammenAdaptorFactory.getInstance().createInterface()); + private static final ComponentDependencyModelDao INSTANCE = new ComponentDependencyModelDaoZusammenImpl( + ZusammenAdaptorFactory.getInstance().createInterface()); - @Override - public ComponentDependencyModelDao createInterface() { - return INSTANCE; - } + @Override + public ComponentDependencyModelDao createInterface() { + return INSTANCE; + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/ComputeDaoFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/ComputeDaoFactoryImpl.java index 3032d523c4..1a9127c95a 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/ComputeDaoFactoryImpl.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/ComputeDaoFactoryImpl.java @@ -7,9 +7,9 @@ * 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. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.impl; import org.openecomp.core.zusammen.api.ZusammenAdaptorFactory; @@ -26,11 +25,11 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.ComputeDaoFactory; import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.ComputeDaoZusammenImpl; public class ComputeDaoFactoryImpl extends ComputeDaoFactory { - private static final ComputeDao INSTANCE = new ComputeDaoZusammenImpl( - ZusammenAdaptorFactory.getInstance().createInterface()); - @Override - public ComputeDao createInterface() { - return INSTANCE; - } + private static final ComputeDao INSTANCE = new ComputeDaoZusammenImpl(ZusammenAdaptorFactory.getInstance().createInterface()); + + @Override + public ComputeDao createInterface() { + return INSTANCE; + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/DeploymentFlavorDaoFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/DeploymentFlavorDaoFactoryImpl.java index 93ce6b122c..b4ad183539 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/DeploymentFlavorDaoFactoryImpl.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/DeploymentFlavorDaoFactoryImpl.java @@ -7,9 +7,9 @@ * 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. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.impl; import org.openecomp.core.zusammen.api.ZusammenAdaptorFactory; @@ -25,10 +24,9 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.DeploymentFlavorDao; import org.openecomp.sdc.vendorsoftwareproduct.dao.DeploymentFlavorDaoFactory; import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.DeploymentFlavorDaoZusammenImpl; +public class DeploymentFlavorDaoFactoryImpl extends DeploymentFlavorDaoFactory { -public class DeploymentFlavorDaoFactoryImpl extends DeploymentFlavorDaoFactory{ - private static final DeploymentFlavorDao INSTANCE = new DeploymentFlavorDaoZusammenImpl( - ZusammenAdaptorFactory.getInstance().createInterface()); + private static final DeploymentFlavorDao INSTANCE = new DeploymentFlavorDaoZusammenImpl(ZusammenAdaptorFactory.getInstance().createInterface()); @Override public DeploymentFlavorDao createInterface() { diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/ImageDaoFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/ImageDaoFactoryImpl.java index 21abcae517..2d01ecf96a 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/ImageDaoFactoryImpl.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/ImageDaoFactoryImpl.java @@ -7,9 +7,9 @@ * 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. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.impl; import org.openecomp.core.zusammen.api.ZusammenAdaptorFactory; @@ -27,11 +26,10 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.ImageDaoZusamme public class ImageDaoFactoryImpl extends ImageDaoFactory { - private static final ImageDao INSTANCE = new ImageDaoZusammenImpl( - ZusammenAdaptorFactory.getInstance().createInterface()); + private static final ImageDao INSTANCE = new ImageDaoZusammenImpl(ZusammenAdaptorFactory.getInstance().createInterface()); - @Override - public ImageDao createInterface() { - return INSTANCE; - } + @Override + public ImageDao createInterface() { + return INSTANCE; + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/MonitoringUploadDaoFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/MonitoringUploadDaoFactoryImpl.java index fa6a0cbfc2..bcee3a2789 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/MonitoringUploadDaoFactoryImpl.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/MonitoringUploadDaoFactoryImpl.java @@ -7,9 +7,9 @@ * 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. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.impl; import org.openecomp.core.zusammen.api.ZusammenAdaptorFactory; @@ -26,11 +25,11 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.MonitoringUploadDaoFactory; import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.ComponentArtifactDaoZusammenImpl; public class MonitoringUploadDaoFactoryImpl extends MonitoringUploadDaoFactory { - private static final ComponentArtifactDao INSTANCE = new ComponentArtifactDaoZusammenImpl( - ZusammenAdaptorFactory.getInstance().createInterface()); - @Override - public ComponentArtifactDao createInterface() { - return INSTANCE; - } + private static final ComponentArtifactDao INSTANCE = new ComponentArtifactDaoZusammenImpl(ZusammenAdaptorFactory.getInstance().createInterface()); + + @Override + public ComponentArtifactDao createInterface() { + return INSTANCE; + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/NetworkDaoFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/NetworkDaoFactoryImpl.java index 5bccc5ced2..cc555b4a6c 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/NetworkDaoFactoryImpl.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/NetworkDaoFactoryImpl.java @@ -7,9 +7,9 @@ * 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. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.impl; import org.openecomp.core.zusammen.api.ZusammenAdaptorFactory; @@ -26,11 +25,11 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.NetworkDaoFactory; import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.NetworkDaoZusammenImpl; public class NetworkDaoFactoryImpl extends NetworkDaoFactory { - private static final NetworkDao INSTANCE = new NetworkDaoZusammenImpl( - ZusammenAdaptorFactory.getInstance().createInterface()); - @Override - public NetworkDao createInterface() { - return INSTANCE; - } + private static final NetworkDao INSTANCE = new NetworkDaoZusammenImpl(ZusammenAdaptorFactory.getInstance().createInterface()); + + @Override + public NetworkDao createInterface() { + return INSTANCE; + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/NicDaoFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/NicDaoFactoryImpl.java index 76e5d443f2..956d84e2d4 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/NicDaoFactoryImpl.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/NicDaoFactoryImpl.java @@ -7,9 +7,9 @@ * 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. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.impl; import org.openecomp.core.zusammen.api.ZusammenAdaptorFactory; @@ -26,11 +25,11 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDaoFactory; import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.NicDaoZusammenImpl; public class NicDaoFactoryImpl extends NicDaoFactory { - private static final NicDao INSTANCE = new NicDaoZusammenImpl( - ZusammenAdaptorFactory.getInstance().createInterface()); - @Override - public NicDao createInterface() { - return INSTANCE; - } + private static final NicDao INSTANCE = new NicDaoZusammenImpl(ZusammenAdaptorFactory.getInstance().createInterface()); + + @Override + public NicDao createInterface() { + return INSTANCE; + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/OrchestrationTemplateCandidateDaoFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/OrchestrationTemplateCandidateDaoFactoryImpl.java index 8cc2c6f61f..d0e838ff19 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/OrchestrationTemplateCandidateDaoFactoryImpl.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/OrchestrationTemplateCandidateDaoFactoryImpl.java @@ -7,9 +7,9 @@ * 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. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.impl; import org.openecomp.core.zusammen.api.ZusammenAdaptorFactory; @@ -25,14 +24,13 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateCandidat import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateCandidateDaoFactory; import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.OrchestrationTemplateCandidateDaoZusammenImpl; -public class OrchestrationTemplateCandidateDaoFactoryImpl - extends OrchestrationTemplateCandidateDaoFactory { - private static final OrchestrationTemplateCandidateDao INSTANCE = - new OrchestrationTemplateCandidateDaoZusammenImpl( - ZusammenAdaptorFactory.getInstance().createInterface()); +public class OrchestrationTemplateCandidateDaoFactoryImpl extends OrchestrationTemplateCandidateDaoFactory { + + private static final OrchestrationTemplateCandidateDao INSTANCE = new OrchestrationTemplateCandidateDaoZusammenImpl( + ZusammenAdaptorFactory.getInstance().createInterface()); - @Override - public OrchestrationTemplateCandidateDao createInterface() { - return INSTANCE; - } + @Override + public OrchestrationTemplateCandidateDao createInterface() { + return INSTANCE; + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/OrchestrationTemplateDaoFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/OrchestrationTemplateDaoFactoryImpl.java index 8b90462131..57f37beb24 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/OrchestrationTemplateDaoFactoryImpl.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/OrchestrationTemplateDaoFactoryImpl.java @@ -7,9 +7,9 @@ * 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. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.impl; import org.openecomp.core.zusammen.api.ZusammenAdaptorFactory; @@ -25,15 +24,13 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDao; import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDaoFactory; import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.OrchestrationTemplateDaoZusammenImpl; +public class OrchestrationTemplateDaoFactoryImpl extends OrchestrationTemplateDaoFactory { -public class OrchestrationTemplateDaoFactoryImpl - extends OrchestrationTemplateDaoFactory { - private static final OrchestrationTemplateDao INSTANCE = - new OrchestrationTemplateDaoZusammenImpl( - ZusammenAdaptorFactory.getInstance().createInterface()); + private static final OrchestrationTemplateDao INSTANCE = new OrchestrationTemplateDaoZusammenImpl( + ZusammenAdaptorFactory.getInstance().createInterface()); - @Override - public OrchestrationTemplateDao createInterface() { - return INSTANCE; - } + @Override + public OrchestrationTemplateDao createInterface() { + return INSTANCE; + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/PackageInfoDaoFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/PackageInfoDaoFactoryImpl.java index 8b9bedcd3a..2982e07d2f 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/PackageInfoDaoFactoryImpl.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/PackageInfoDaoFactoryImpl.java @@ -7,9 +7,9 @@ * 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. @@ -17,17 +17,17 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.impl; import org.openecomp.sdc.vendorsoftwareproduct.dao.PackageInfoDao; import org.openecomp.sdc.vendorsoftwareproduct.dao.PackageInfoDaoFactory; public class PackageInfoDaoFactoryImpl extends PackageInfoDaoFactory { - private static final PackageInfoDao INSTANCE = new PackageInfoDaoImpl(); - @Override - public PackageInfoDao createInterface() { - return INSTANCE; - } + private static final PackageInfoDao INSTANCE = new PackageInfoDaoImpl(); + + @Override + public PackageInfoDao createInterface() { + return INSTANCE; + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/PackageInfoDaoImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/PackageInfoDaoImpl.java index ff4fd45420..591af3c8b9 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/PackageInfoDaoImpl.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/PackageInfoDaoImpl.java @@ -7,9 +7,9 @@ * 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. @@ -17,72 +17,67 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.impl; import com.datastax.driver.mapping.Mapper; import com.datastax.driver.mapping.Result; import com.datastax.driver.mapping.annotations.Accessor; import com.datastax.driver.mapping.annotations.Query; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; import org.openecomp.core.dao.impl.CassandraBaseDao; import org.openecomp.core.nosqldb.api.NoSqlDb; import org.openecomp.core.nosqldb.factory.NoSqlDbFactory; import org.openecomp.sdc.vendorsoftwareproduct.dao.PackageInfoDao; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.PackageInfo; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - public class PackageInfoDaoImpl extends CassandraBaseDao<PackageInfo> implements PackageInfoDao { - private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface(); - private static final Mapper<PackageInfo> mapper = - noSqlDb.getMappingManager().mapper(PackageInfo.class); - private static final PackageInfoAccessor accessor = - noSqlDb.getMappingManager().createAccessor(PackageInfoAccessor.class); - @Override - protected Mapper<PackageInfo> getMapper() { - return mapper; - } + private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface(); + private static final Mapper<PackageInfo> mapper = noSqlDb.getMappingManager().mapper(PackageInfo.class); + private static final PackageInfoAccessor accessor = noSqlDb.getMappingManager().createAccessor(PackageInfoAccessor.class); - @Override - protected Object[] getKeys(PackageInfo entity) { - return new Object[]{entity.getVspId(), entity.getVersion()}; - } + @Override + protected Mapper<PackageInfo> getMapper() { + return mapper; + } - @Override - public Collection<PackageInfo> list(PackageInfo entity) { - return accessor.listInfo().all(); - } + @Override + protected Object[] getKeys(PackageInfo entity) { + return new Object[]{entity.getVspId(), entity.getVersion()}; + } - @Override - public List<PackageInfo> listByCategory(String category, String subCategory) { - Result<PackageInfo> packages = accessor.listInfo(); + @Override + public Collection<PackageInfo> list(PackageInfo entity) { + return accessor.listInfo().all(); + } - List<PackageInfo> filteredPackages = new ArrayList<>(); - for (PackageInfo packageInfo : packages) { - if (category != null) { - if (category.equals(packageInfo.getCategory())) { - filteredPackages.add(packageInfo); - } - } else if (subCategory != null) { - if (subCategory.equals(packageInfo.getSubCategory())) { - filteredPackages.add(packageInfo); + @Override + public List<PackageInfo> listByCategory(String category, String subCategory) { + Result<PackageInfo> packages = accessor.listInfo(); + List<PackageInfo> filteredPackages = new ArrayList<>(); + for (PackageInfo packageInfo : packages) { + if (category != null) { + if (category.equals(packageInfo.getCategory())) { + filteredPackages.add(packageInfo); + } + } else if (subCategory != null) { + if (subCategory.equals(packageInfo.getSubCategory())) { + filteredPackages.add(packageInfo); + } + } else { + filteredPackages.add(packageInfo); + } } - } else { - filteredPackages.add(packageInfo); - } + return filteredPackages; } - return filteredPackages; - } - @Accessor - interface PackageInfoAccessor { + @Accessor + interface PackageInfoAccessor { - @Query( - "SELECT vsp_id,version,display_name,vsp_name,vsp_description,vendor_name,category" + @Query("SELECT vsp_id,version,display_name,vsp_name,vsp_description,vendor_name,category" + " ,sub_category, vendor_release,package_checksum,package_type, resource_type FROM package_details") - Result<PackageInfo> listInfo(); - } + Result<PackageInfo> listInfo(); + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/ProcessDaoFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/ProcessDaoFactoryImpl.java index 0205446ae8..72b9c76615 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/ProcessDaoFactoryImpl.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/ProcessDaoFactoryImpl.java @@ -7,9 +7,9 @@ * 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. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.impl; import org.openecomp.core.zusammen.api.ZusammenAdaptorFactory; @@ -26,11 +25,11 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.ProcessDaoFactory; import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.ProcessDaoZusammenImpl; public class ProcessDaoFactoryImpl extends ProcessDaoFactory { - private static final ProcessDao INSTANCE = new ProcessDaoZusammenImpl( - ZusammenAdaptorFactory.getInstance().createInterface()); - @Override - public ProcessDao createInterface() { - return INSTANCE; - } + private static final ProcessDao INSTANCE = new ProcessDaoZusammenImpl(ZusammenAdaptorFactory.getInstance().createInterface()); + + @Override + public ProcessDao createInterface() { + return INSTANCE; + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VendorSoftwareProductInfoDaoFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VendorSoftwareProductInfoDaoFactoryImpl.java index a5f9d17431..978d11cd3b 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VendorSoftwareProductInfoDaoFactoryImpl.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VendorSoftwareProductInfoDaoFactoryImpl.java @@ -7,9 +7,9 @@ * 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. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.impl; import org.openecomp.core.zusammen.api.ZusammenAdaptorFactory; @@ -26,12 +25,12 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoF import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.VendorSoftwareProductInfoDaoZusammenImpl; public class VendorSoftwareProductInfoDaoFactoryImpl extends VendorSoftwareProductInfoDaoFactory { - private static final VendorSoftwareProductInfoDao INSTANCE = - new VendorSoftwareProductInfoDaoZusammenImpl( - ZusammenAdaptorFactory.getInstance().createInterface()); - @Override - public VendorSoftwareProductInfoDao createInterface() { - return INSTANCE; - } + private static final VendorSoftwareProductInfoDao INSTANCE = new VendorSoftwareProductInfoDaoZusammenImpl( + ZusammenAdaptorFactory.getInstance().createInterface()); + + @Override + public VendorSoftwareProductInfoDao createInterface() { + return INSTANCE; + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VspMergeDaoFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VspMergeDaoFactoryImpl.java index f6f3c84303..0c7c552489 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VspMergeDaoFactoryImpl.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VspMergeDaoFactoryImpl.java @@ -7,9 +7,9 @@ * 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. @@ -17,21 +17,18 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.impl; - import org.openecomp.core.zusammen.api.ZusammenAdaptorFactory; import org.openecomp.sdc.vendorsoftwareproduct.dao.VspMergeDao; import org.openecomp.sdc.vendorsoftwareproduct.dao.VspMergeDaoFactory; public class VspMergeDaoFactoryImpl extends VspMergeDaoFactory { - private static final VspMergeDao INSTANCE = new - VspMergeDaoImpl(ZusammenAdaptorFactory.getInstance().createInterface()); + private static final VspMergeDao INSTANCE = new VspMergeDaoImpl(ZusammenAdaptorFactory.getInstance().createInterface()); - @Override - public VspMergeDao createInterface() { - return INSTANCE; - } + @Override + public VspMergeDao createInterface() { + return INSTANCE; + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VspMergeDaoImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VspMergeDaoImpl.java index 86045ab20a..e7579c6ce6 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VspMergeDaoImpl.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VspMergeDaoImpl.java @@ -7,9 +7,9 @@ * 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. @@ -17,9 +17,11 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.impl; +import static org.openecomp.core.zusammen.api.ZusammenUtil.buildElement; +import static org.openecomp.core.zusammen.api.ZusammenUtil.createSessionContext; + import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo; import com.amdocs.zusammen.datatypes.Id; import com.amdocs.zusammen.datatypes.SessionContext; @@ -32,6 +34,8 @@ import com.datastax.driver.extras.codecs.enums.EnumNameCodec; import com.datastax.driver.mapping.MappingManager; import com.datastax.driver.mapping.annotations.Accessor; import com.datastax.driver.mapping.annotations.Query; +import java.util.List; +import java.util.stream.Collectors; import org.openecomp.core.nosqldb.factory.NoSqlDbFactory; import org.openecomp.core.zusammen.api.ZusammenAdaptor; import org.openecomp.sdc.common.session.SessionContextProviderFactory; @@ -39,155 +43,120 @@ import org.openecomp.sdc.datatypes.model.ElementType; import org.openecomp.sdc.vendorsoftwareproduct.dao.VspMergeDao; import org.openecomp.sdc.versioning.dao.types.Version; -import java.util.List; -import java.util.stream.Collectors; +public class VspMergeDaoImpl implements VspMergeDao { -import static org.openecomp.core.zusammen.api.ZusammenUtil.buildElement; -import static org.openecomp.core.zusammen.api.ZusammenUtil.createSessionContext; + private static final String VSP_MODEL_NOT_EXIST = "Vsp model does not exist for Vsp %s, version %s."; + private static final VspMergeHintAccessor accessor; -public class VspMergeDaoImpl implements VspMergeDao { - private static final String VSP_MODEL_NOT_EXIST = - "Vsp model does not exist for Vsp %s, version %s."; - - private static final VspMergeHintAccessor accessor; - - static { - MappingManager mappingManager = NoSqlDbFactory.getInstance().createInterface().getMappingManager(); - mappingManager.getSession().getCluster().getConfiguration().getCodecRegistry() - .register(new EnumNameCodec<>(Resolution.class)); - accessor = mappingManager.createAccessor(VspMergeHintAccessor.class); - } - - private ZusammenAdaptor zusammenAdaptor; - - public VspMergeDaoImpl(ZusammenAdaptor zusammenAdaptor) { - this.zusammenAdaptor = zusammenAdaptor; - } - - @Override - public boolean isConflicted(String vspId, Version version) { - SessionContext context = createSessionContext(); - ElementContext elementContext = new ElementContext(new Id(vspId), new Id(version.getId())); - - return listVspModels(context, elementContext).size() > 1; - } - - @Override - public void updateHint(String vspId, Version version) { - SessionContext context = createSessionContext(); - ElementContext elementContext = new ElementContext(new Id(vspId), new Id(version.getId())); - - String vspModelId = zusammenAdaptor - .getElementInfoByName(context, elementContext, null, ElementType.VspModel.name()) - .orElseThrow(() -> new IllegalStateException( - String.format(VSP_MODEL_NOT_EXIST, vspId, version.getId()))) - .getId().getValue(); - - updateVspModelId(vspId, version, vspModelId); - } - - @Override - public void deleteHint(String vspId, Version version) { - accessor.delete(getUser(),vspId,version.getId()); - } - - @Override - public void updateConflictResolution(String vspId, Version version, - Resolution resolution) { - accessor.updateModelResolution(resolution, getUser(), vspId, version.getId()); - } - - @Override - public void applyConflictResolution(String vspId, Version version) { - //called only when no conflicts - - SessionContext context = createSessionContext(); - ElementContext elementContext = new ElementContext(new Id(vspId), new Id(version.getId())); - - List<ElementInfo> vspModels = listVspModels(context, elementContext); - if (vspModels.size() == 1) { - updateVspModelId(vspId, version, vspModels.iterator().next().getId().getValue()); - return; + static { + MappingManager mappingManager = NoSqlDbFactory.getInstance().createInterface().getMappingManager(); + mappingManager.getSession().getCluster().getConfiguration().getCodecRegistry().register(new EnumNameCodec<>(Resolution.class)); + accessor = mappingManager.createAccessor(VspMergeHintAccessor.class); + } + + private ZusammenAdaptor zusammenAdaptor; + + public VspMergeDaoImpl(ZusammenAdaptor zusammenAdaptor) { + this.zusammenAdaptor = zusammenAdaptor; + } + + @Override + public boolean isConflicted(String vspId, Version version) { + SessionContext context = createSessionContext(); + ElementContext elementContext = new ElementContext(new Id(vspId), new Id(version.getId())); + return listVspModels(context, elementContext).size() > 1; } - if (vspModels.size() != 2) { - return; + @Override + public void updateHint(String vspId, Version version) { + SessionContext context = createSessionContext(); + ElementContext elementContext = new ElementContext(new Id(vspId), new Id(version.getId())); + String vspModelId = zusammenAdaptor.getElementInfoByName(context, elementContext, null, ElementType.VspModel.name()) + .orElseThrow(() -> new IllegalStateException(String.format(VSP_MODEL_NOT_EXIST, vspId, version.getId()))).getId().getValue(); + updateVspModelId(vspId, version, vspModelId); } - String user = getUser(); - Row row = accessor.get(user, vspId, version.getId()).one(); - if (row == null) { - throw new IllegalStateException( - "Vsp model id must exists if its conflict is being resolved"); + @Override + public void deleteHint(String vspId, Version version) { + accessor.delete(getUser(), vspId, version.getId()); } - String resolutionValue = row.getString("model_resolution"); - if (resolutionValue == null) { - return; // model conflict is not resolved yet + + @Override + public void updateConflictResolution(String vspId, Version version, Resolution resolution) { + accessor.updateModelResolution(resolution, getUser(), vspId, version.getId()); + } + + @Override + public void applyConflictResolution(String vspId, Version version) { + //called only when no conflicts + SessionContext context = createSessionContext(); + ElementContext elementContext = new ElementContext(new Id(vspId), new Id(version.getId())); + List<ElementInfo> vspModels = listVspModels(context, elementContext); + if (vspModels.size() == 1) { + updateVspModelId(vspId, version, vspModels.iterator().next().getId().getValue()); + return; + } + if (vspModels.size() != 2) { + return; + } + String user = getUser(); + Row row = accessor.get(user, vspId, version.getId()).one(); + if (row == null) { + throw new IllegalStateException("Vsp model id must exists if its conflict is being resolved"); + } + String resolutionValue = row.getString("model_resolution"); + if (resolutionValue == null) { + return; // model conflict is not resolved yet + } + Resolution resolution = Resolution.valueOf(resolutionValue); + String localModelId = row.getString("model_id"); + String chosenModelId = keepOnlyChosenVspModel(context, elementContext, vspModels, resolution, localModelId); + accessor.update(chosenModelId, null, user, vspId, version.getId()); + } + + private String keepOnlyChosenVspModel(SessionContext context, ElementContext elementContext, List<ElementInfo> vspModels, Resolution resolution, + String localModelId) { + String newLocalModelId = null; + for (ElementInfo vspModel : vspModels) { + if (isRedundantModel(vspModel.getId().getValue(), localModelId, resolution)) { + zusammenAdaptor.saveElement(context, elementContext, buildElement(vspModel.getId(), Action.DELETE), "Delete Redundant Vsp Model"); + } else { + newLocalModelId = vspModel.getId().getValue(); + } + } + return newLocalModelId; + } + + private boolean isRedundantModel(String modelId, String localModelId, Resolution resolution) { + return resolution == Resolution.THEIRS && modelId.equals(localModelId) || resolution == Resolution.YOURS && !modelId.equals(localModelId); + } + + private List<ElementInfo> listVspModels(SessionContext context, ElementContext elementContext) { + return zusammenAdaptor.listElements(context, elementContext, null).stream() + .filter(elementInfo -> ElementType.VspModel.name().equals(elementInfo.getInfo().getName())).collect(Collectors.toList()); } - Resolution resolution = Resolution.valueOf(resolutionValue); - String localModelId = row.getString("model_id"); - - String chosenModelId = - keepOnlyChosenVspModel(context, elementContext, vspModels, resolution, localModelId); - - accessor.update(chosenModelId, null, user, vspId, version.getId()); - } - - private String keepOnlyChosenVspModel(SessionContext context, ElementContext elementContext, - List<ElementInfo> vspModels, Resolution resolution, - String localModelId) { - String newLocalModelId = null; - for (ElementInfo vspModel : vspModels) { - if (isRedundantModel(vspModel.getId().getValue(), localModelId, resolution)) { - zusammenAdaptor - .saveElement(context, elementContext, buildElement(vspModel.getId(), Action.DELETE), - "Delete Redundant Vsp Model"); - } else { - newLocalModelId = vspModel.getId().getValue(); - } + private void updateVspModelId(String vspId, Version version, String vspModelId) { + accessor.update(vspModelId, null, getUser(), vspId, version.getId()); + } + + private String getUser() { + return SessionContextProviderFactory.getInstance().createInterface().get().getUser().getUserId(); + } + + @Accessor + interface VspMergeHintAccessor { + + @Query("SELECT model_id, model_resolution FROM vsp_merge_hint " + "WHERE space=? AND item_id=? AND version_id=?") + ResultSet get(String space, String itemId, String versionId); + + @Query("UPDATE vsp_merge_hint SET model_id=?, model_resolution=? " + "WHERE space=? AND item_id=? AND version_id=?") + void update(String vspModelId, Resolution modelResolution, String space, String itemId, String versionId); + + @Query("UPDATE vsp_merge_hint SET model_resolution=? WHERE space=? AND item_id=? AND version_id=?") + void updateModelResolution(Resolution modelResolution, String space, String itemId, String versionId); + + @Query("DELETE from vsp_merge_hint WHERE space=? AND item_id=? AND version_id=?") + void delete(String space, String itemId, String versionId); } - return newLocalModelId; - } - - private boolean isRedundantModel(String modelId, String localModelId, Resolution resolution) { - return resolution == Resolution.THEIRS && modelId.equals(localModelId) || - resolution == Resolution.YOURS && !modelId.equals(localModelId); - } - - private List<ElementInfo> listVspModels(SessionContext context, ElementContext elementContext) { - return zusammenAdaptor.listElements(context, elementContext, null).stream() - .filter(elementInfo -> ElementType.VspModel.name().equals(elementInfo.getInfo().getName())) - .collect(Collectors.toList()); - } - - private void updateVspModelId(String vspId, Version version, String vspModelId) { - accessor.update(vspModelId, null, getUser(), vspId, version.getId()); - } - - private String getUser() { - return SessionContextProviderFactory.getInstance().createInterface() - .get().getUser().getUserId(); - } - - @Accessor - interface VspMergeHintAccessor { - - @Query("SELECT model_id, model_resolution FROM vsp_merge_hint " + - "WHERE space=? AND item_id=? AND version_id=?") - ResultSet get(String space, String itemId, String versionId); - - @Query("UPDATE vsp_merge_hint SET model_id=?, model_resolution=? " + - "WHERE space=? AND item_id=? AND version_id=?") - void update(String vspModelId, Resolution modelResolution, String space, - String itemId, String versionId); - - @Query( - "UPDATE vsp_merge_hint SET model_resolution=? WHERE space=? AND item_id=? AND version_id=?") - void updateModelResolution(Resolution modelResolution, String space, String itemId, - String versionId); - - @Query("DELETE from vsp_merge_hint WHERE space=? AND item_id=? AND version_id=?") - void delete(String space, String itemId, String versionId); - } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ComponentArtifactDaoZusammenImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ComponentArtifactDaoZusammenImpl.java index e80e7d5d66..dbfee03219 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ComponentArtifactDaoZusammenImpl.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ComponentArtifactDaoZusammenImpl.java @@ -7,9 +7,9 @@ * 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. @@ -17,15 +17,24 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen; +import static org.openecomp.core.zusammen.api.ZusammenUtil.buildElement; +import static org.openecomp.core.zusammen.api.ZusammenUtil.buildStructuralElement; +import static org.openecomp.core.zusammen.api.ZusammenUtil.createSessionContext; + import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element; import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement; import com.amdocs.zusammen.datatypes.Id; import com.amdocs.zusammen.datatypes.SessionContext; import com.amdocs.zusammen.datatypes.item.Action; import com.amdocs.zusammen.datatypes.item.ElementContext; +import java.io.ByteArrayInputStream; +import java.nio.ByteBuffer; +import java.util.Collection; +import java.util.Collections; +import java.util.Optional; +import java.util.stream.Collectors; import org.openecomp.core.enrichment.types.MonitoringUploadType; import org.openecomp.core.utilities.file.FileUtils; import org.openecomp.core.zusammen.api.ZusammenAdaptor; @@ -34,202 +43,145 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentArtifactDao; import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToComponentMonitoringUploadConvertor; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentMonitoringUploadEntity; -import java.io.ByteArrayInputStream; -import java.nio.ByteBuffer; -import java.util.Collection; -import java.util.Collections; -import java.util.Optional; -import java.util.stream.Collectors; - -import static org.openecomp.core.zusammen.api.ZusammenUtil.*; - /** * @author Avrahamg. * @since March 21, 2017 */ public class ComponentArtifactDaoZusammenImpl implements ComponentArtifactDao { - private static final String ARTIFACT_NAME = "artifactName"; + private static final String ARTIFACT_NAME = "artifactName"; + private ZusammenAdaptor zusammenAdaptor; - private ZusammenAdaptor zusammenAdaptor; - - public ComponentArtifactDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) { - this.zusammenAdaptor = zusammenAdaptor; - } + public ComponentArtifactDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) { + this.zusammenAdaptor = zusammenAdaptor; + } - @Override - public void registerVersioning(String versionableEntityType) { - // registerVersioning is not implemented for ComponentArtifactDaoZusammenImpl - } + @Override + public void registerVersioning(String versionableEntityType) { + // registerVersioning is not implemented for ComponentArtifactDaoZusammenImpl + } - @Override - public Optional<ComponentMonitoringUploadEntity> getByType( - ComponentMonitoringUploadEntity componentMonitoringUploadEntity) { - SessionContext context = createSessionContext(); - ElementContext elementContext = - new ElementContext(componentMonitoringUploadEntity.getVspId(), + @Override + public Optional<ComponentMonitoringUploadEntity> getByType(ComponentMonitoringUploadEntity componentMonitoringUploadEntity) { + SessionContext context = createSessionContext(); + ElementContext elementContext = new ElementContext(componentMonitoringUploadEntity.getVspId(), componentMonitoringUploadEntity.getVersion().getId()); - - Optional<Element> mibsElement = - zusammenAdaptor.getElementByName(context, elementContext, - new Id(componentMonitoringUploadEntity.getComponentId()), ElementType.Mibs.toString()); - if (mibsElement.isPresent()) { - Optional<Element> monitoringElement = zusammenAdaptor - .getElementByName(context, elementContext, mibsElement.get().getElementId(), - getMonitoringStructuralElement(componentMonitoringUploadEntity.getType()).toString()); - if (monitoringElement.isPresent()) { - ComponentMonitoringUploadEntity entity = - new ElementToComponentMonitoringUploadConvertor().convert(monitoringElement.get()); - entity.setVspId(componentMonitoringUploadEntity.getVspId()); - entity.setVersion(componentMonitoringUploadEntity.getVersion()); - entity.setComponentId(componentMonitoringUploadEntity.getComponentId()); - return Optional.of(entity); - } + Optional<Element> mibsElement = zusammenAdaptor + .getElementByName(context, elementContext, new Id(componentMonitoringUploadEntity.getComponentId()), ElementType.Mibs.toString()); + if (mibsElement.isPresent()) { + Optional<Element> monitoringElement = zusammenAdaptor.getElementByName(context, elementContext, mibsElement.get().getElementId(), + getMonitoringStructuralElement(componentMonitoringUploadEntity.getType()).toString()); + if (monitoringElement.isPresent()) { + ComponentMonitoringUploadEntity entity = new ElementToComponentMonitoringUploadConvertor().convert(monitoringElement.get()); + entity.setVspId(componentMonitoringUploadEntity.getVspId()); + entity.setVersion(componentMonitoringUploadEntity.getVersion()); + entity.setComponentId(componentMonitoringUploadEntity.getComponentId()); + return Optional.of(entity); + } + } + return Optional.empty(); } - return Optional.empty(); - } - - @Override - public void create(ComponentMonitoringUploadEntity entity) { - ZusammenElement mibElement = buildMibElement(entity); - - ZusammenElement mibsElement = buildStructuralElement(ElementType.Mibs, null); - - ZusammenElement componentElement = buildElement(new Id(entity.getComponentId()), Action.IGNORE); - - SessionContext context = createSessionContext(); - ElementContext elementContext = - new ElementContext(entity.getVspId(), entity.getVersion().getId()); - - Element savedElement = zusammenAdaptor.saveElement(context, elementContext, - VspZusammenUtil.aggregateElements(componentElement, mibsElement, mibElement), - "Create monitoring upload"); - entity.setId(savedElement.getSubElements().iterator().next() - .getSubElements().iterator().next().getElementId().getValue()); - } - - @Override - public void delete(ComponentMonitoringUploadEntity componentMonitoringUploadEntity) { + @Override + public void create(ComponentMonitoringUploadEntity entity) { + ZusammenElement mibElement = buildMibElement(entity); + ZusammenElement mibsElement = buildStructuralElement(ElementType.Mibs, null); + ZusammenElement componentElement = buildElement(new Id(entity.getComponentId()), Action.IGNORE); + SessionContext context = createSessionContext(); + ElementContext elementContext = new ElementContext(entity.getVspId(), entity.getVersion().getId()); + Element savedElement = zusammenAdaptor + .saveElement(context, elementContext, VspZusammenUtil.aggregateElements(componentElement, mibsElement, mibElement), + "Create monitoring upload"); + entity.setId(savedElement.getSubElements().iterator().next().getSubElements().iterator().next().getElementId().getValue()); + } - ZusammenElement mibElement = buildMibElementStructure(componentMonitoringUploadEntity); - mibElement.setElementId(new Id(componentMonitoringUploadEntity.getId())); - SessionContext context = createSessionContext(); - ElementContext elementContext = - new ElementContext(componentMonitoringUploadEntity.getVspId(), + @Override + public void delete(ComponentMonitoringUploadEntity componentMonitoringUploadEntity) { + ZusammenElement mibElement = buildMibElementStructure(componentMonitoringUploadEntity); + mibElement.setElementId(new Id(componentMonitoringUploadEntity.getId())); + SessionContext context = createSessionContext(); + ElementContext elementContext = new ElementContext(componentMonitoringUploadEntity.getVspId(), componentMonitoringUploadEntity.getVersion().getId()); + zusammenAdaptor + .saveElement(context, elementContext, mibElement, String.format("Delete mib with id %s", componentMonitoringUploadEntity.getId())); + } + + @Override + public Collection<ComponentMonitoringUploadEntity> list(ComponentMonitoringUploadEntity mibEntity) { + SessionContext context = createSessionContext(); + ElementContext elementContext = new ElementContext(mibEntity.getVspId(), mibEntity.getVersion().getId()); + return zusammenAdaptor.listElementsByName(context, elementContext, new Id(mibEntity.getComponentId()), ElementType.Mibs.toString()).stream() + .map(new ElementToComponentMonitoringUploadConvertor()::convert).map(mib -> { + mib.setVspId(mibEntity.getVspId()); + mib.setVersion(mibEntity.getVersion()); + mib.setComponentId(mibEntity.getComponentId()); + return mib; + }).collect(Collectors.toList()); + } - zusammenAdaptor.saveElement(context, elementContext, mibElement, - String.format("Delete mib with id %s", componentMonitoringUploadEntity.getId())); - } - - - - @Override - public Collection<ComponentMonitoringUploadEntity> list( - ComponentMonitoringUploadEntity mibEntity) { - SessionContext context = createSessionContext(); - ElementContext elementContext = - new ElementContext(mibEntity.getVspId(), mibEntity.getVersion().getId()); - return zusammenAdaptor - .listElementsByName(context, elementContext, new Id(mibEntity.getComponentId()), - ElementType.Mibs.toString()) - .stream() - .map(new ElementToComponentMonitoringUploadConvertor()::convert) - .map(mib -> { - mib.setVspId(mibEntity.getVspId()); - mib.setVersion(mibEntity.getVersion()); - mib.setComponentId(mibEntity.getComponentId()); - return mib; - }) - .collect(Collectors.toList()); - } - - @Override - public void deleteAll(ComponentMonitoringUploadEntity componentMonitoringUploadEntity) { - SessionContext context = createSessionContext(); - ElementContext elementContext = - new ElementContext(componentMonitoringUploadEntity.getVspId(), + @Override + public void deleteAll(ComponentMonitoringUploadEntity componentMonitoringUploadEntity) { + SessionContext context = createSessionContext(); + ElementContext elementContext = new ElementContext(componentMonitoringUploadEntity.getVspId(), componentMonitoringUploadEntity.getVersion().getId()); + Optional<Element> optionalElement = zusammenAdaptor + .getElementByName(context, elementContext, new Id(componentMonitoringUploadEntity.getComponentId()), ElementType.Mibs.name()); + if (optionalElement.isPresent()) { + Element mibsElement = optionalElement.get(); + Collection<Element> mibs = mibsElement.getSubElements(); + mibs.forEach(mib -> { + ZusammenElement mibZusammenElement = buildElement(mib.getElementId(), Action.DELETE); + zusammenAdaptor.saveElement(context, elementContext, mibZusammenElement, "Delete mib with id " + mib.getElementId()); + }); + } + } - Optional<Element> optionalElement = zusammenAdaptor.getElementByName(context, - elementContext, new Id(componentMonitoringUploadEntity.getComponentId()), ElementType.Mibs - .name()); + @Override + public Collection<ComponentMonitoringUploadEntity> listArtifacts(ComponentMonitoringUploadEntity monitoringUploadEntity) { + SessionContext context = createSessionContext(); + ElementContext elementContext = new ElementContext(monitoringUploadEntity.getVspId(), monitoringUploadEntity.getVersion().getId()); + final Optional<Element> elementByName = zusammenAdaptor + .getElementByName(context, elementContext, new Id(monitoringUploadEntity.getComponentId()), ElementType.Mibs.name()); + if (!elementByName.isPresent()) { + return Collections.emptyList(); + } else { + final Id elementId = elementByName.get().getElementId(); + return zusammenAdaptor.listElementData(context, elementContext, elementId).stream() + .map(element -> buildMibEntity(element, monitoringUploadEntity)).collect(Collectors.toList()); + } + } - if (optionalElement.isPresent()) { - Element mibsElement = optionalElement.get(); - Collection<Element> mibs = mibsElement.getSubElements(); + private ComponentMonitoringUploadEntity buildMibEntity(Element element, ComponentMonitoringUploadEntity monitoringUploadEntity) { + final String componentId = monitoringUploadEntity.getComponentId(); + ComponentMonitoringUploadEntity createdMib = new ComponentMonitoringUploadEntity(monitoringUploadEntity.getVspId(), + monitoringUploadEntity.getVersion(), componentId, null); + createdMib.setArtifactName((String) element.getInfo().getProperties().get(ARTIFACT_NAME)); + createdMib.setArtifact(ByteBuffer.wrap(FileUtils.toByteArray(element.getData()))); + createdMib.setType(MonitoringUploadType.valueOf(element.getInfo().getName())); + return createdMib; + } - mibs.forEach(mib -> { - ZusammenElement mibZusammenElement = buildElement(mib.getElementId(), Action.DELETE); - zusammenAdaptor.saveElement(context, elementContext, mibZusammenElement, - "Delete mib with id " + mib.getElementId()); - }); + private ZusammenElement buildMibElement(ComponentMonitoringUploadEntity monitoringUploadEntity) { + ZusammenElement monitoringElement = buildMibElementStructure(monitoringUploadEntity); + monitoringElement.getInfo().getProperties().put(ARTIFACT_NAME, monitoringUploadEntity.getArtifactName()); + monitoringElement.setData(new ByteArrayInputStream(monitoringUploadEntity.getArtifact().array())); + return monitoringElement; } - } - - @Override - public Collection<ComponentMonitoringUploadEntity> listArtifacts( - ComponentMonitoringUploadEntity monitoringUploadEntity) { - SessionContext context = createSessionContext(); - ElementContext elementContext = new ElementContext(monitoringUploadEntity.getVspId(), - monitoringUploadEntity.getVersion().getId()); - - final Optional<Element> elementByName = - zusammenAdaptor.getElementByName(context, elementContext, - new Id(monitoringUploadEntity.getComponentId()), ElementType.Mibs.name()); - - if (!elementByName.isPresent()) { - return Collections.emptyList(); - } else { - final Id elementId = elementByName.get().getElementId(); - return zusammenAdaptor.listElementData(context, elementContext, elementId).stream() - .map(element -> buildMibEntity(element, monitoringUploadEntity)) - .collect(Collectors.toList()); + + private ZusammenElement buildMibElementStructure(ComponentMonitoringUploadEntity componentMonitoringUploadEntity) { + return buildStructuralElement(getMonitoringStructuralElement(componentMonitoringUploadEntity.getType()), Action.UPDATE); } - } - - private ComponentMonitoringUploadEntity buildMibEntity(Element element, - ComponentMonitoringUploadEntity monitoringUploadEntity) { - final String componentId = monitoringUploadEntity.getComponentId(); - ComponentMonitoringUploadEntity - createdMib = new ComponentMonitoringUploadEntity(monitoringUploadEntity.getVspId(), - monitoringUploadEntity.getVersion(), - componentId, - null); - createdMib.setArtifactName((String) element.getInfo().getProperties().get(ARTIFACT_NAME)); - createdMib.setArtifact(ByteBuffer.wrap(FileUtils.toByteArray(element.getData()))); - createdMib.setType(MonitoringUploadType.valueOf(element.getInfo().getName())); - return createdMib; - } - - private ZusammenElement buildMibElement( - ComponentMonitoringUploadEntity monitoringUploadEntity) { - - ZusammenElement monitoringElement = buildMibElementStructure(monitoringUploadEntity); - monitoringElement.getInfo().getProperties() - .put(ARTIFACT_NAME, monitoringUploadEntity.getArtifactName()); - monitoringElement - .setData(new ByteArrayInputStream(monitoringUploadEntity.getArtifact().array())); - return monitoringElement; - } - - private ZusammenElement buildMibElementStructure( - ComponentMonitoringUploadEntity componentMonitoringUploadEntity) { - return buildStructuralElement(getMonitoringStructuralElement(componentMonitoringUploadEntity - .getType()), Action.UPDATE); - } - - private ElementType getMonitoringStructuralElement(MonitoringUploadType type){ - switch (type) { - case SNMP_POLL: - return ElementType.SNMP_POLL; - case SNMP_TRAP: - return ElementType.SNMP_TRAP; - case VES_EVENTS: - return ElementType.VES_EVENTS; - default: - throw new IllegalArgumentException(); + + private ElementType getMonitoringStructuralElement(MonitoringUploadType type) { + switch (type) { + case SNMP_POLL: + return ElementType.SNMP_POLL; + case SNMP_TRAP: + return ElementType.SNMP_TRAP; + case VES_EVENTS: + return ElementType.VES_EVENTS; + default: + throw new IllegalArgumentException(); + } } - } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ComponentDaoZusammenImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ComponentDaoZusammenImpl.java index d38db0b0da..8c2fb92f17 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ComponentDaoZusammenImpl.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ComponentDaoZusammenImpl.java @@ -7,9 +7,9 @@ * 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. @@ -17,9 +17,12 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen; +import static org.openecomp.core.zusammen.api.ZusammenUtil.buildElement; +import static org.openecomp.core.zusammen.api.ZusammenUtil.buildStructuralElement; +import static org.openecomp.core.zusammen.api.ZusammenUtil.createSessionContext; + import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element; import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo; import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement; @@ -28,6 +31,12 @@ import com.amdocs.zusammen.datatypes.SessionContext; import com.amdocs.zusammen.datatypes.item.Action; import com.amdocs.zusammen.datatypes.item.ElementContext; import com.amdocs.zusammen.datatypes.item.Info; +import java.io.ByteArrayInputStream; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Optional; +import java.util.stream.Collectors; import org.openecomp.core.zusammen.api.ZusammenAdaptor; import org.openecomp.sdc.datatypes.model.ElementType; import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao; @@ -37,233 +46,170 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity; import org.openecomp.sdc.versioning.dao.types.Version; import org.openecomp.types.ElementPropertyName; -import java.io.ByteArrayInputStream; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Optional; -import java.util.stream.Collectors; - -import static org.openecomp.core.zusammen.api.ZusammenUtil.*; - public class ComponentDaoZusammenImpl implements ComponentDao { - private ZusammenAdaptor zusammenAdaptor; - - public ComponentDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) { - this.zusammenAdaptor = zusammenAdaptor; - } - - @Override - public void registerVersioning(String versionableEntityType) { - // registerVersioning is not implemented for ComponentDaoZusammenImpl - } - - @Override - public Collection<ComponentEntity> list(ComponentEntity component) { - SessionContext context = createSessionContext(); - - return listComponents(zusammenAdaptor, context, component.getVspId(), component.getVersion()); - } - - static Collection<ComponentEntity> listComponents(ZusammenAdaptor zusammenAdaptor, - SessionContext context, - String vspId, Version version) { - ElementContext elementContext = new ElementContext(vspId, version.getId()); + private ZusammenAdaptor zusammenAdaptor; - Optional<ElementInfo> vspModel = zusammenAdaptor - .getElementInfoByName(context, elementContext, null, ElementType.VspModel.name()); - if (!vspModel.isPresent()) { - return new ArrayList<>(); + public ComponentDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) { + this.zusammenAdaptor = zusammenAdaptor; } - ElementToComponentConvertor convertor = new ElementToComponentConvertor(); - return zusammenAdaptor.listElementsByName(context, elementContext, vspModel.get().getId(), - ElementType.Components.name()).stream() - .map(elementInfo -> { - ComponentEntity entity = convertor.convert(elementInfo); - entity.setVspId(vspId); - entity.setVersion(version); - return entity; - }) - .collect(Collectors.toList()); - } - - - @Override - public void create(ComponentEntity component) { - ZusammenElement componentElement = componentToZusammen(component, Action.CREATE); - - ZusammenElement componentsElement = - buildStructuralElement(ElementType.Components, Action.IGNORE); - componentsElement.getSubElements().add(componentElement); - - ZusammenElement vspModel = buildStructuralElement(ElementType.VspModel, Action.IGNORE); - vspModel.addSubElement(componentsElement); - - SessionContext context = createSessionContext(); - Element savedVspModel = zusammenAdaptor.saveElement(context, - new ElementContext(component.getVspId(), component.getVersion().getId()), - vspModel, "Create component"); - component.setId(savedVspModel.getSubElements().iterator().next() - .getSubElements().iterator().next().getElementId().getValue()); - } - - @Override - public void update(ComponentEntity component) { - ZusammenElement componentElement = componentToZusammen(component, Action.UPDATE); - - SessionContext context = createSessionContext(); - zusammenAdaptor.saveElement(context, - new ElementContext(component.getVspId(), component.getVersion().getId()), - componentElement, String.format("Update component with id %s", component.getId())); - } - - @Override - public ComponentEntity get(ComponentEntity component) { - SessionContext context = createSessionContext(); - - Optional<Element> element = - zusammenAdaptor.getElement(context, - new ElementContext(component.getVspId(), component.getVersion().getId()), - component.getId()); - - if (element.isPresent()) { - ComponentEntity entity = new ElementToComponentConvertor().convert(element.get()); - entity.setVspId(component.getVspId()); - entity.setVersion(component.getVersion()); - return entity; + static Collection<ComponentEntity> listComponents(ZusammenAdaptor zusammenAdaptor, SessionContext context, String vspId, Version version) { + ElementContext elementContext = new ElementContext(vspId, version.getId()); + Optional<ElementInfo> vspModel = zusammenAdaptor.getElementInfoByName(context, elementContext, null, ElementType.VspModel.name()); + if (!vspModel.isPresent()) { + return new ArrayList<>(); + } + ElementToComponentConvertor convertor = new ElementToComponentConvertor(); + return zusammenAdaptor.listElementsByName(context, elementContext, vspModel.get().getId(), ElementType.Components.name()).stream() + .map(elementInfo -> { + ComponentEntity entity = convertor.convert(elementInfo); + entity.setVspId(vspId); + entity.setVersion(version); + return entity; + }).collect(Collectors.toList()); } - return null; - } - - @Override - public void delete(ComponentEntity component) { - ZusammenElement componentElement = buildElement(new Id(component.getId()), Action.DELETE); - - SessionContext context = createSessionContext(); - zusammenAdaptor.saveElement(context, - new ElementContext(component.getVspId(), component.getVersion().getId()), - componentElement, String.format("Delete component with id %s", component.getId())); - } - - @Override - public ComponentEntity getQuestionnaireData(String vspId, Version version, String componentId) { - SessionContext context = createSessionContext(); - - return getQuestionnaire(context, new ElementContext(vspId, version.getId()), - new ComponentEntity(vspId, version, componentId)); - } - - private ComponentEntity getQuestionnaire(SessionContext context, ElementContext elementContext, - ComponentEntity component) { - Optional<Element> questionnaireElement = zusammenAdaptor - .getElementByName(context, elementContext, new Id(component.getId()), - ElementType.ComponentQuestionnaire.name()); - return questionnaireElement.map(new ElementToComponentQuestionnnaireConvertor()::convert) - .map(entity -> { - entity.setVspId(component.getVspId()); - entity.setVersion(component.getVersion()); - return entity; - }) - .orElse(null); - } - - @Override - public void updateQuestionnaireData(String vspId, Version version, String componentId, - String questionnaireData) { - ZusammenElement questionnaireElement = - componentQuestionnaireToZusammen(questionnaireData, Action.UPDATE); - - ZusammenElement componentElement = buildElement(new Id(componentId), Action.IGNORE); - componentElement.setSubElements(Collections.singletonList(questionnaireElement)); - - SessionContext context = createSessionContext(); - zusammenAdaptor.saveElement(context, new ElementContext(vspId, version.getId()), - componentElement, "Update component questionnaire"); - } - - @Override - public Collection<ComponentEntity> listQuestionnaires(String vspId, Version version) { - return listCompositionAndQuestionnaire(vspId, version); - } - @Override - public Collection<ComponentEntity> listCompositionAndQuestionnaire(String vspId, - Version version) { - SessionContext context = createSessionContext(); + @Override + public void registerVersioning(String versionableEntityType) { + // registerVersioning is not implemented for ComponentDaoZusammenImpl + } - Collection<ComponentEntity> components = - listComponents(zusammenAdaptor, context, vspId, version); + @Override + public Collection<ComponentEntity> list(ComponentEntity component) { + SessionContext context = createSessionContext(); + return listComponents(zusammenAdaptor, context, component.getVspId(), component.getVersion()); + } - ElementContext elementContext = new ElementContext(vspId, version.getId()); - components.forEach(component -> component.setQuestionnaireData( - getQuestionnaire(context, elementContext, component).getQuestionnaireData())); - return components; - } + @Override + public void create(ComponentEntity component) { + ZusammenElement componentElement = componentToZusammen(component, Action.CREATE); + ZusammenElement componentsElement = buildStructuralElement(ElementType.Components, Action.IGNORE); + componentsElement.getSubElements().add(componentElement); + ZusammenElement vspModel = buildStructuralElement(ElementType.VspModel, Action.IGNORE); + vspModel.addSubElement(componentsElement); + SessionContext context = createSessionContext(); + Element savedVspModel = zusammenAdaptor + .saveElement(context, new ElementContext(component.getVspId(), component.getVersion().getId()), vspModel, "Create component"); + component.setId(savedVspModel.getSubElements().iterator().next().getSubElements().iterator().next().getElementId().getValue()); + } - @Override - public void deleteAll(String vspId, Version version) { - SessionContext context = createSessionContext(); - ElementContext elementContext = new ElementContext(vspId, version.getId()); + @Override + public void update(ComponentEntity component) { + ZusammenElement componentElement = componentToZusammen(component, Action.UPDATE); + SessionContext context = createSessionContext(); + zusammenAdaptor.saveElement(context, new ElementContext(component.getVspId(), component.getVersion().getId()), componentElement, + String.format("Update component with id %s", component.getId())); + } - Collection<ElementInfo> vspModelSubs = zusammenAdaptor - .listElementsByName(context, elementContext, null, ElementType.VspModel.name()); + @Override + public ComponentEntity get(ComponentEntity component) { + SessionContext context = createSessionContext(); + Optional<Element> element = zusammenAdaptor + .getElement(context, new ElementContext(component.getVspId(), component.getVersion().getId()), component.getId()); + if (element.isPresent()) { + ComponentEntity entity = new ElementToComponentConvertor().convert(element.get()); + entity.setVspId(component.getVspId()); + entity.setVersion(component.getVersion()); + return entity; + } + return null; + } - Optional<ElementInfo> componentsElement = vspModelSubs.stream() - .filter(elementInfo -> elementInfo.getInfo() != null - && ElementType.Components.name().equals(elementInfo.getInfo().getName())) - .findFirst(); - if (!componentsElement.isPresent()) { - return; + @Override + public void delete(ComponentEntity component) { + ZusammenElement componentElement = buildElement(new Id(component.getId()), Action.DELETE); + SessionContext context = createSessionContext(); + zusammenAdaptor.saveElement(context, new ElementContext(component.getVspId(), component.getVersion().getId()), componentElement, + String.format("Delete component with id %s", component.getId())); } - ZusammenElement components = buildElement(componentsElement.get().getId(), Action.IGNORE); - components.setSubElements(componentsElement.get().getSubElements().stream() - .map(component -> buildElement(component.getId(), Action.DELETE)) - .collect(Collectors.toList())); + @Override + public ComponentEntity getQuestionnaireData(String vspId, Version version, String componentId) { + SessionContext context = createSessionContext(); + return getQuestionnaire(context, new ElementContext(vspId, version.getId()), new ComponentEntity(vspId, version, componentId)); + } - zusammenAdaptor.saveElement(context, elementContext, components, "Delete all components"); - } + private ComponentEntity getQuestionnaire(SessionContext context, ElementContext elementContext, ComponentEntity component) { + Optional<Element> questionnaireElement = zusammenAdaptor + .getElementByName(context, elementContext, new Id(component.getId()), ElementType.ComponentQuestionnaire.name()); + return questionnaireElement.map(new ElementToComponentQuestionnnaireConvertor()::convert).map(entity -> { + entity.setVspId(component.getVspId()); + entity.setVersion(component.getVersion()); + return entity; + }).orElse(null); + } - private ZusammenElement componentToZusammen(ComponentEntity component, Action action) { - ZusammenElement componentElement = buildComponentElement(component, action); + @Override + public void updateQuestionnaireData(String vspId, Version version, String componentId, String questionnaireData) { + ZusammenElement questionnaireElement = componentQuestionnaireToZusammen(questionnaireData, Action.UPDATE); + ZusammenElement componentElement = buildElement(new Id(componentId), Action.IGNORE); + componentElement.setSubElements(Collections.singletonList(questionnaireElement)); + SessionContext context = createSessionContext(); + zusammenAdaptor.saveElement(context, new ElementContext(vspId, version.getId()), componentElement, "Update component questionnaire"); + } - if (action == Action.CREATE) { - ZusammenElement mibs = buildStructuralElement(ElementType.Mibs, Action.CREATE); - mibs.addSubElement(buildStructuralElement(ElementType.SNMP_TRAP, Action.CREATE)); - mibs.addSubElement(buildStructuralElement(ElementType.VES_EVENTS, Action.CREATE)); - mibs.addSubElement(buildStructuralElement(ElementType.SNMP_POLL, Action.CREATE)); + @Override + public Collection<ComponentEntity> listQuestionnaires(String vspId, Version version) { + return listCompositionAndQuestionnaire(vspId, version); + } - componentElement.addSubElement(mibs); - componentElement.addSubElement( - componentQuestionnaireToZusammen(component.getQuestionnaireData(), Action.CREATE)); - componentElement.addSubElement(buildStructuralElement(ElementType.Nics, Action.CREATE)); - componentElement.addSubElement(buildStructuralElement(ElementType.Processes, Action.CREATE)); - componentElement.addSubElement(buildStructuralElement(ElementType.Computes, Action.CREATE)); - componentElement.addSubElement(buildStructuralElement(ElementType.Images, Action.CREATE)); + @Override + public Collection<ComponentEntity> listCompositionAndQuestionnaire(String vspId, Version version) { + SessionContext context = createSessionContext(); + Collection<ComponentEntity> components = listComponents(zusammenAdaptor, context, vspId, version); + ElementContext elementContext = new ElementContext(vspId, version.getId()); + components.forEach(component -> component.setQuestionnaireData(getQuestionnaire(context, elementContext, component).getQuestionnaireData())); + return components; } - return componentElement; - } - private ZusammenElement componentQuestionnaireToZusammen(String questionnaireData, - Action action) { - ZusammenElement questionnaireElement = - buildStructuralElement(ElementType.ComponentQuestionnaire, action); - questionnaireElement.setData(new ByteArrayInputStream(questionnaireData.getBytes())); - return questionnaireElement; - } + @Override + public void deleteAll(String vspId, Version version) { + SessionContext context = createSessionContext(); + ElementContext elementContext = new ElementContext(vspId, version.getId()); + Collection<ElementInfo> vspModelSubs = zusammenAdaptor.listElementsByName(context, elementContext, null, ElementType.VspModel.name()); + Optional<ElementInfo> componentsElement = vspModelSubs.stream() + .filter(elementInfo -> elementInfo.getInfo() != null && ElementType.Components.name().equals(elementInfo.getInfo().getName())) + .findFirst(); + if (!componentsElement.isPresent()) { + return; + } + ZusammenElement components = buildElement(componentsElement.get().getId(), Action.IGNORE); + components.setSubElements(componentsElement.get().getSubElements().stream().map(component -> buildElement(component.getId(), Action.DELETE)) + .collect(Collectors.toList())); + zusammenAdaptor.saveElement(context, elementContext, components, "Delete all components"); + } - private ZusammenElement buildComponentElement(ComponentEntity component, Action action) { - ZusammenElement componentElement = - buildElement(component.getId() == null ? null : new Id(component.getId()), action); - Info info = new Info(); - info.addProperty(ElementPropertyName.elementType.name(), ElementType.Component); - info.addProperty(ElementPropertyName.compositionData.name(), component.getCompositionData()); - componentElement.setInfo(info); - componentElement.setData(new ByteArrayInputStream(component.getCompositionData().getBytes())); - return componentElement; - } + private ZusammenElement componentToZusammen(ComponentEntity component, Action action) { + ZusammenElement componentElement = buildComponentElement(component, action); + if (action == Action.CREATE) { + ZusammenElement mibs = buildStructuralElement(ElementType.Mibs, Action.CREATE); + mibs.addSubElement(buildStructuralElement(ElementType.SNMP_TRAP, Action.CREATE)); + mibs.addSubElement(buildStructuralElement(ElementType.VES_EVENTS, Action.CREATE)); + mibs.addSubElement(buildStructuralElement(ElementType.SNMP_POLL, Action.CREATE)); + componentElement.addSubElement(mibs); + componentElement.addSubElement(componentQuestionnaireToZusammen(component.getQuestionnaireData(), Action.CREATE)); + componentElement.addSubElement(buildStructuralElement(ElementType.Nics, Action.CREATE)); + componentElement.addSubElement(buildStructuralElement(ElementType.Processes, Action.CREATE)); + componentElement.addSubElement(buildStructuralElement(ElementType.Computes, Action.CREATE)); + componentElement.addSubElement(buildStructuralElement(ElementType.Images, Action.CREATE)); + } + return componentElement; + } + private ZusammenElement componentQuestionnaireToZusammen(String questionnaireData, Action action) { + ZusammenElement questionnaireElement = buildStructuralElement(ElementType.ComponentQuestionnaire, action); + questionnaireElement.setData(new ByteArrayInputStream(questionnaireData.getBytes())); + return questionnaireElement; + } + private ZusammenElement buildComponentElement(ComponentEntity component, Action action) { + ZusammenElement componentElement = buildElement(component.getId() == null ? null : new Id(component.getId()), action); + Info info = new Info(); + info.addProperty(ElementPropertyName.elementType.name(), ElementType.Component); + info.addProperty(ElementPropertyName.compositionData.name(), component.getCompositionData()); + componentElement.setInfo(info); + componentElement.setData(new ByteArrayInputStream(component.getCompositionData().getBytes())); + return componentElement; + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ComponentDependencyModelDaoZusammenImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ComponentDependencyModelDaoZusammenImpl.java index bb80a95aab..5662da2769 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ComponentDependencyModelDaoZusammenImpl.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ComponentDependencyModelDaoZusammenImpl.java @@ -7,9 +7,9 @@ * 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. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen; import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element; @@ -34,7 +33,6 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDependencyModelDao; import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToComponentDependencyModelConvertor; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity; import org.openecomp.types.ElementPropertyName; - import java.util.ArrayList; import java.util.Collection; import java.util.Optional; @@ -47,148 +45,103 @@ import static org.openecomp.core.zusammen.api.ZusammenUtil.*; */ public class ComponentDependencyModelDaoZusammenImpl implements ComponentDependencyModelDao { - private ZusammenAdaptor zusammenAdaptor; - - public ComponentDependencyModelDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) { - this.zusammenAdaptor = zusammenAdaptor; - } - - @Override - public ComponentDependencyModelEntity get(ComponentDependencyModelEntity dependency) { + private ZusammenAdaptor zusammenAdaptor; - SessionContext context = createSessionContext(); - ElementContext elementContext = - new ElementContext(dependency.getVspId(), dependency.getVersion().getId()); - - Optional<ElementInfo> componentDependencyElement = - zusammenAdaptor.getElementInfo(context, elementContext, new Id(dependency.getId())); - - if (componentDependencyElement.isPresent()) { - ElementToComponentDependencyModelConvertor convertor = new - ElementToComponentDependencyModelConvertor(); - - ComponentDependencyModelEntity entity = convertor.convert(componentDependencyElement.get()); - entity.setVspId(dependency.getVspId()); - entity.setVersion(dependency.getVersion()); - return entity; + public ComponentDependencyModelDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) { + this.zusammenAdaptor = zusammenAdaptor; } - return null; - } - - @Override - public void create(ComponentDependencyModelEntity dependency) { - ZusammenElement componentDependency = - buildComponentDependencyElement(dependency, Action.CREATE); - - ZusammenElement componentDependencies = - buildStructuralElement(ElementType.ComponentDependencies, Action.IGNORE); - componentDependencies.addSubElement(componentDependency); - - ZusammenElement vspModel = buildStructuralElement(ElementType.VspModel, Action.IGNORE); - vspModel.addSubElement(componentDependencies); - - SessionContext context = createSessionContext(); - ElementContext elementContext = - new ElementContext(dependency.getVspId(), dependency.getVersion().getId()); - - Element compDepsSavedElement = zusammenAdaptor - .saveElement(context, elementContext, vspModel, "Create component dependency model"); - - dependency.setId(compDepsSavedElement.getSubElements().iterator().next() - .getSubElements().iterator().next().getElementId().getValue()); - } - - @Override - public void update(ComponentDependencyModelEntity dependency) { - ZusammenElement componentDependencyElement = - buildComponentDependencyElement(dependency, Action.UPDATE); - - SessionContext context = createSessionContext(); - ElementContext elementContext = - new ElementContext(dependency.getVspId(), dependency.getVersion().getId()); - - zusammenAdaptor.saveElement(context, elementContext, componentDependencyElement, - String.format("Update component dependency model with id %s", dependency.getId())); - } - - @Override - public void delete(ComponentDependencyModelEntity dependency) { - ZusammenElement componentDependencyElement = - buildElement(new Id(dependency.getId()), Action.DELETE); - - SessionContext context = createSessionContext(); - ElementContext elementContext = - new ElementContext(dependency.getVspId(), dependency.getVersion().getId()); - - zusammenAdaptor.saveElement(context, elementContext, componentDependencyElement, - String.format("Delete component dependency model with id %s", dependency.getId())); - } - - @Override - public void registerVersioning(String versionableEntityType) { - //not implemented? - } - - @Override - public Collection<ComponentDependencyModelEntity> list( - ComponentDependencyModelEntity dependency) { - SessionContext context = createSessionContext(); - ElementContext elementContext = - new ElementContext(dependency.getVspId(), dependency.getVersion().getId()); - - Optional<ElementInfo> vspModel = zusammenAdaptor - .getElementInfoByName(context, elementContext, null, ElementType.VspModel.name()); - if (!vspModel.isPresent()) { - return new ArrayList<>(); + @Override + public ComponentDependencyModelEntity get(ComponentDependencyModelEntity dependency) { + SessionContext context = createSessionContext(); + ElementContext elementContext = new ElementContext(dependency.getVspId(), dependency.getVersion().getId()); + Optional<ElementInfo> componentDependencyElement = zusammenAdaptor.getElementInfo(context, elementContext, new Id(dependency.getId())); + if (componentDependencyElement.isPresent()) { + ElementToComponentDependencyModelConvertor convertor = new ElementToComponentDependencyModelConvertor(); + ComponentDependencyModelEntity entity = convertor.convert(componentDependencyElement.get()); + entity.setVspId(dependency.getVspId()); + entity.setVersion(dependency.getVersion()); + return entity; + } + return null; } - ElementToComponentDependencyModelConvertor convertor = - new ElementToComponentDependencyModelConvertor(); - return zusammenAdaptor.listElementsByName(context, elementContext, vspModel.get().getId(), - ElementType.ComponentDependencies.name()).stream() - .map(elementInfo -> { - ComponentDependencyModelEntity entity = convertor.convert(elementInfo); - entity.setVspId(dependency.getVspId()); - entity.setVersion(dependency.getVersion()); - entity.setId(elementInfo.getId().getValue()); - return entity; - }) - .collect(Collectors.toList()); - } + @Override + public void create(ComponentDependencyModelEntity dependency) { + ZusammenElement componentDependency = buildComponentDependencyElement(dependency, Action.CREATE); + ZusammenElement componentDependencies = buildStructuralElement(ElementType.ComponentDependencies, Action.IGNORE); + componentDependencies.addSubElement(componentDependency); + ZusammenElement vspModel = buildStructuralElement(ElementType.VspModel, Action.IGNORE); + vspModel.addSubElement(componentDependencies); + SessionContext context = createSessionContext(); + ElementContext elementContext = new ElementContext(dependency.getVspId(), dependency.getVersion().getId()); + Element compDepsSavedElement = zusammenAdaptor.saveElement(context, elementContext, vspModel, "Create component dependency model"); + dependency.setId(compDepsSavedElement.getSubElements().iterator().next().getSubElements().iterator().next().getElementId().getValue()); + } - private ZusammenElement buildComponentDependencyElement(ComponentDependencyModelEntity compDep, - Action action) { - ZusammenElement componentDependencyElement = - buildElement(compDep.getId() == null ? null : new Id(compDep.getId()), action); + @Override + public void update(ComponentDependencyModelEntity dependency) { + ZusammenElement componentDependencyElement = buildComponentDependencyElement(dependency, Action.UPDATE); + SessionContext context = createSessionContext(); + ElementContext elementContext = new ElementContext(dependency.getVspId(), dependency.getVersion().getId()); + zusammenAdaptor.saveElement(context, elementContext, componentDependencyElement, + String.format("Update component dependency model with id %s", dependency.getId())); + } - Info info = new Info(); - info.addProperty(ElementPropertyName.elementType.name(), ElementType.ComponentDependency); - info.addProperty(ComponentDependencyModelPropertyName.RELATION.getVal(), compDep.getRelation()); - info.addProperty(ComponentDependencyModelPropertyName.SOURCE_COMPONENT_ID.getVal(), - compDep.getSourceComponentId()); - info.addProperty(ComponentDependencyModelPropertyName.TARGET_COMPONENT_ID.getVal(), - compDep.getTargetComponentId()); + @Override + public void delete(ComponentDependencyModelEntity dependency) { + ZusammenElement componentDependencyElement = buildElement(new Id(dependency.getId()), Action.DELETE); + SessionContext context = createSessionContext(); + ElementContext elementContext = new ElementContext(dependency.getVspId(), dependency.getVersion().getId()); + zusammenAdaptor.saveElement(context, elementContext, componentDependencyElement, + String.format("Delete component dependency model with id %s", dependency.getId())); + } - componentDependencyElement.setInfo(info); + @Override + public void registerVersioning(String versionableEntityType) { + //not implemented? + } - return componentDependencyElement; - } + @Override + public Collection<ComponentDependencyModelEntity> list(ComponentDependencyModelEntity dependency) { + SessionContext context = createSessionContext(); + ElementContext elementContext = new ElementContext(dependency.getVspId(), dependency.getVersion().getId()); + Optional<ElementInfo> vspModel = zusammenAdaptor.getElementInfoByName(context, elementContext, null, ElementType.VspModel.name()); + if (!vspModel.isPresent()) { + return new ArrayList<>(); + } + ElementToComponentDependencyModelConvertor convertor = new ElementToComponentDependencyModelConvertor(); + return zusammenAdaptor.listElementsByName(context, elementContext, vspModel.get().getId(), ElementType.ComponentDependencies.name()).stream() + .map(elementInfo -> { + ComponentDependencyModelEntity entity = convertor.convert(elementInfo); + entity.setVspId(dependency.getVspId()); + entity.setVersion(dependency.getVersion()); + entity.setId(elementInfo.getId().getValue()); + return entity; + }).collect(Collectors.toList()); + } - private enum ComponentDependencyModelPropertyName { - ID("id"), - RELATION("relation"), - SOURCE_COMPONENT_ID("sourcecomponent_id"), - TARGET_COMPONENT_ID("targetcomponent_id"); + private ZusammenElement buildComponentDependencyElement(ComponentDependencyModelEntity compDep, Action action) { + ZusammenElement componentDependencyElement = buildElement(compDep.getId() == null ? null : new Id(compDep.getId()), action); + Info info = new Info(); + info.addProperty(ElementPropertyName.elementType.name(), ElementType.ComponentDependency); + info.addProperty(ComponentDependencyModelPropertyName.RELATION.getVal(), compDep.getRelation()); + info.addProperty(ComponentDependencyModelPropertyName.SOURCE_COMPONENT_ID.getVal(), compDep.getSourceComponentId()); + info.addProperty(ComponentDependencyModelPropertyName.TARGET_COMPONENT_ID.getVal(), compDep.getTargetComponentId()); + componentDependencyElement.setInfo(info); + return componentDependencyElement; + } - private String val; + private enum ComponentDependencyModelPropertyName { + ID("id"), RELATION("relation"), SOURCE_COMPONENT_ID("sourcecomponent_id"), TARGET_COMPONENT_ID("targetcomponent_id"); + private String val; - ComponentDependencyModelPropertyName(String val){ - this.val=val; - } + ComponentDependencyModelPropertyName(String val) { + this.val = val; + } - public String getVal() { - return val; + public String getVal() { + return val; + } } - } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ComponentDependencyModelPropertyName.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ComponentDependencyModelPropertyName.java index 534c253811..7624886b9c 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ComponentDependencyModelPropertyName.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ComponentDependencyModelPropertyName.java @@ -7,9 +7,9 @@ * 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. @@ -17,16 +17,9 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen; /** * Created by ayalaben on 5/16/2017 */ -public enum ComponentDependencyModelPropertyName { - id, - relation, - sourcecomponent_id, - targetcomponent_id, - -} +public enum ComponentDependencyModelPropertyName {id, relation, sourcecomponent_id, targetcomponent_id,} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ComputeDaoZusammenImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ComputeDaoZusammenImpl.java index d1b540b312..48111ad041 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ComputeDaoZusammenImpl.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ComputeDaoZusammenImpl.java @@ -7,9 +7,9 @@ * 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. @@ -17,9 +17,11 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen; +import static org.openecomp.core.zusammen.api.ZusammenUtil.buildElement; +import static org.openecomp.core.zusammen.api.ZusammenUtil.buildStructuralElement; +import static org.openecomp.core.zusammen.api.ZusammenUtil.createSessionContext; import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element; import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement; @@ -28,6 +30,11 @@ import com.amdocs.zusammen.datatypes.SessionContext; import com.amdocs.zusammen.datatypes.item.Action; import com.amdocs.zusammen.datatypes.item.ElementContext; import com.amdocs.zusammen.datatypes.item.Info; +import java.io.ByteArrayInputStream; +import java.util.Collection; +import java.util.Collections; +import java.util.Optional; +import java.util.stream.Collectors; import org.openecomp.core.utilities.file.FileUtils; import org.openecomp.core.zusammen.api.ZusammenAdaptor; import org.openecomp.sdc.datatypes.model.ElementType; @@ -38,222 +45,156 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComputeEntity; import org.openecomp.sdc.versioning.dao.types.Version; import org.openecomp.types.ElementPropertyName; -import java.io.ByteArrayInputStream; -import java.util.Collection; -import java.util.Collections; -import java.util.Optional; -import java.util.stream.Collectors; - -import static org.openecomp.core.zusammen.api.ZusammenUtil.*; - public class ComputeDaoZusammenImpl implements ComputeDao { - private ZusammenAdaptor zusammenAdaptor; - - public ComputeDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) { - this.zusammenAdaptor = zusammenAdaptor; - } - - @Override - public void registerVersioning(String versionableEntityType) { - // registerVersioning not implemented for ComputeDaoZusammenImpl - } - - @Override - public Collection<ComputeEntity> list(ComputeEntity compute) { - SessionContext context = createSessionContext(); - ElementContext elementContext = - new ElementContext(compute.getVspId(), compute.getVersion().getId()); - - return listComputes(context, elementContext, compute); - } - - private Collection<ComputeEntity> listComputes(SessionContext context, - ElementContext elementContext, - ComputeEntity compute) { - return zusammenAdaptor - .listElementsByName(context, elementContext, new Id(compute.getComponentId()), - ElementType.Computes.name()) - .stream() - .map(new ElementToComputeConvertor()::convert) - .map(computeEntity -> { - computeEntity.setComponentId(compute.getComponentId()); - computeEntity.setVspId(compute.getVspId()); - computeEntity.setVersion(compute.getVersion()); - return computeEntity; - }) - .collect(Collectors.toList()); - } - - @Override - public void create(ComputeEntity compute) { - ZusammenElement computeElement = computeToZusammen(compute, Action.CREATE); - - ZusammenElement computesElement = buildStructuralElement(ElementType.Computes, Action.IGNORE); - computesElement.setSubElements(Collections.singletonList(computeElement)); - - ZusammenElement componentElement = - buildElement(new Id(compute.getComponentId()), Action.IGNORE); - componentElement.setSubElements(Collections.singletonList(computesElement)); - - SessionContext context = createSessionContext(); - ElementContext elementContext = - new ElementContext(compute.getVspId(), compute.getVersion().getId()); + private ZusammenAdaptor zusammenAdaptor; - Element savedElement = - zusammenAdaptor.saveElement(context, elementContext, componentElement, "Create compute"); - compute.setId(savedElement.getSubElements().iterator().next() - .getSubElements().iterator().next().getElementId().getValue()); - } - - @Override - public void update(ComputeEntity compute) { - ZusammenElement computeElement = computeToZusammen(compute, Action.UPDATE); - - SessionContext context = createSessionContext(); - ElementContext elementContext = - new ElementContext(compute.getVspId(), compute.getVersion().getId()); - zusammenAdaptor.saveElement(context, elementContext, computeElement, - String.format("Update compute with id %s", compute.getId())); - } - - @Override - public ComputeEntity get(ComputeEntity compute) { - SessionContext context = createSessionContext(); - ElementContext elementContext = - new ElementContext(compute.getVspId(), compute.getVersion().getId()); - Optional<Element> element = - zusammenAdaptor.getElement(context, elementContext, compute.getId()); - - if (element.isPresent()) { - - ElementToComputeConvertor convertor = new ElementToComputeConvertor(); - ComputeEntity entity = convertor.convert(element.get()); - entity.setVspId(compute.getVspId()); - entity.setVersion(compute.getVersion()); - entity.setComponentId(compute.getComponentId()); - return entity; - } else { - return null; + public ComputeDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) { + this.zusammenAdaptor = zusammenAdaptor; } - } - - @Override - public void delete(ComputeEntity compute) { - ZusammenElement computeElement = buildElement(new Id(compute.getId()), Action.DELETE); - SessionContext context = createSessionContext(); - ElementContext elementContext = - new ElementContext(compute.getVspId(), compute.getVersion().getId()); - zusammenAdaptor.saveElement(context, elementContext, computeElement, - String.format("Delete compute with id %s", compute.getId())); - } - - @Override - public ComputeEntity getQuestionnaireData(String vspId, Version version, String componentId, - String computeId) { - SessionContext context = createSessionContext(); - ElementContext elementContext = new ElementContext(vspId, version.getId()); - - return getQuestionnaire(context, elementContext, - new ComputeEntity(vspId, version, componentId, computeId)); - } - - private ComputeEntity getQuestionnaire(SessionContext context, ElementContext elementContext, - ComputeEntity compute) { - Optional<Element> questionnaireElement = zusammenAdaptor - .getElementByName(context, elementContext, new Id(compute.getId()), - ElementType.ComputeQuestionnaire.name()); - return questionnaireElement.map( - element -> element.getData() == null - ? null - : new String(FileUtils.toByteArray(element.getData()))) - .map(questionnaireData -> { - compute.setQuestionnaireData(questionnaireData); - return compute; - }) - .orElse(null); - } + @Override + public void registerVersioning(String versionableEntityType) { + // registerVersioning not implemented for ComputeDaoZusammenImpl + } - @Override - public void updateQuestionnaireData(String vspId, Version version, String componentId, - String computeId, String questionnaireData) { - ZusammenElement questionnaireElement = - computeQuestionnaireToZusammen(questionnaireData, Action.UPDATE); + @Override + public Collection<ComputeEntity> list(ComputeEntity compute) { + SessionContext context = createSessionContext(); + ElementContext elementContext = new ElementContext(compute.getVspId(), compute.getVersion().getId()); + return listComputes(context, elementContext, compute); + } - ZusammenElement computeElement = buildElement(new Id(computeId), Action.IGNORE); - computeElement.setSubElements(Collections.singletonList(questionnaireElement)); + private Collection<ComputeEntity> listComputes(SessionContext context, ElementContext elementContext, ComputeEntity compute) { + return zusammenAdaptor.listElementsByName(context, elementContext, new Id(compute.getComponentId()), ElementType.Computes.name()).stream() + .map(new ElementToComputeConvertor()::convert).map(computeEntity -> { + computeEntity.setComponentId(compute.getComponentId()); + computeEntity.setVspId(compute.getVspId()); + computeEntity.setVersion(compute.getVersion()); + return computeEntity; + }).collect(Collectors.toList()); + } - SessionContext context = createSessionContext(); - ElementContext elementContext = new ElementContext(vspId, version.getId()); - zusammenAdaptor.saveElement(context, elementContext, computeElement, "Update compute " - + "questionnaire"); - } + @Override + public void create(ComputeEntity compute) { + ZusammenElement computeElement = computeToZusammen(compute, Action.CREATE); + ZusammenElement computesElement = buildStructuralElement(ElementType.Computes, Action.IGNORE); + computesElement.setSubElements(Collections.singletonList(computeElement)); + ZusammenElement componentElement = buildElement(new Id(compute.getComponentId()), Action.IGNORE); + componentElement.setSubElements(Collections.singletonList(computesElement)); + SessionContext context = createSessionContext(); + ElementContext elementContext = new ElementContext(compute.getVspId(), compute.getVersion().getId()); + Element savedElement = zusammenAdaptor.saveElement(context, elementContext, componentElement, "Create compute"); + compute.setId(savedElement.getSubElements().iterator().next().getSubElements().iterator().next().getElementId().getValue()); + } - @Override - public Collection<ComputeEntity> listByVsp(String vspId, Version version) { - SessionContext context = createSessionContext(); - ElementContext elementContext = new ElementContext(vspId, version.getId()); + @Override + public void update(ComputeEntity compute) { + ZusammenElement computeElement = computeToZusammen(compute, Action.UPDATE); + SessionContext context = createSessionContext(); + ElementContext elementContext = new ElementContext(compute.getVspId(), compute.getVersion().getId()); + zusammenAdaptor.saveElement(context, elementContext, computeElement, String.format("Update compute with id %s", compute.getId())); + } - Collection<ComponentEntity> components = ComponentDaoZusammenImpl - .listComponents(zusammenAdaptor, context, vspId, version); + @Override + public ComputeEntity get(ComputeEntity compute) { + SessionContext context = createSessionContext(); + ElementContext elementContext = new ElementContext(compute.getVspId(), compute.getVersion().getId()); + Optional<Element> element = zusammenAdaptor.getElement(context, elementContext, compute.getId()); + if (element.isPresent()) { + ElementToComputeConvertor convertor = new ElementToComputeConvertor(); + ComputeEntity entity = convertor.convert(element.get()); + entity.setVspId(compute.getVspId()); + entity.setVersion(compute.getVersion()); + entity.setComponentId(compute.getComponentId()); + return entity; + } else { + return null; + } + } - return components.stream() - .map(component -> - listComputes(context, elementContext, - new ComputeEntity(vspId, version, component.getId(), null)).stream() - .map(compute -> getQuestionnaire(context, elementContext, compute)) - .collect(Collectors.toList())) - .flatMap(Collection::stream) - .collect(Collectors.toList()); - } + @Override + public void delete(ComputeEntity compute) { + ZusammenElement computeElement = buildElement(new Id(compute.getId()), Action.DELETE); + SessionContext context = createSessionContext(); + ElementContext elementContext = new ElementContext(compute.getVspId(), compute.getVersion().getId()); + zusammenAdaptor.saveElement(context, elementContext, computeElement, String.format("Delete compute with id %s", compute.getId())); + } - @Override - public void deleteAll(String vspId, Version version) { + @Override + public ComputeEntity getQuestionnaireData(String vspId, Version version, String componentId, String computeId) { + SessionContext context = createSessionContext(); + ElementContext elementContext = new ElementContext(vspId, version.getId()); + return getQuestionnaire(context, elementContext, new ComputeEntity(vspId, version, componentId, computeId)); + } - SessionContext context = createSessionContext(); - ElementContext elementContext = new ElementContext(vspId, version.getId()); + private ComputeEntity getQuestionnaire(SessionContext context, ElementContext elementContext, ComputeEntity compute) { + Optional<Element> questionnaireElement = zusammenAdaptor + .getElementByName(context, elementContext, new Id(compute.getId()), ElementType.ComputeQuestionnaire.name()); + return questionnaireElement.map(element -> element.getData() == null ? null : new String(FileUtils.toByteArray(element.getData()))) + .map(questionnaireData -> { + compute.setQuestionnaireData(questionnaireData); + return compute; + }).orElse(null); + } - Optional<Element> optionalElement = zusammenAdaptor.getElementByName(context, - elementContext, null, ElementType.Computes.name()); + @Override + public void updateQuestionnaireData(String vspId, Version version, String componentId, String computeId, String questionnaireData) { + ZusammenElement questionnaireElement = computeQuestionnaireToZusammen(questionnaireData, Action.UPDATE); + ZusammenElement computeElement = buildElement(new Id(computeId), Action.IGNORE); + computeElement.setSubElements(Collections.singletonList(questionnaireElement)); + SessionContext context = createSessionContext(); + ElementContext elementContext = new ElementContext(vspId, version.getId()); + zusammenAdaptor.saveElement(context, elementContext, computeElement, "Update compute " + "questionnaire"); + } - if (optionalElement.isPresent()) { - Element computesElement = optionalElement.get(); - Collection<Element> computes = computesElement.getSubElements(); + @Override + public Collection<ComputeEntity> listByVsp(String vspId, Version version) { + SessionContext context = createSessionContext(); + ElementContext elementContext = new ElementContext(vspId, version.getId()); + Collection<ComponentEntity> components = ComponentDaoZusammenImpl.listComponents(zusammenAdaptor, context, vspId, version); + return components.stream().map( + component -> listComputes(context, elementContext, new ComputeEntity(vspId, version, component.getId(), null)).stream() + .map(compute -> getQuestionnaire(context, elementContext, compute)).collect(Collectors.toList())).flatMap(Collection::stream) + .collect(Collectors.toList()); + } - computes.forEach(compute -> { - ZusammenElement computeElement = buildElement(compute.getElementId(), Action.DELETE); - zusammenAdaptor.saveElement(context, elementContext, computeElement, - "Delete compute with id " + compute.getElementId()); - }); + @Override + public void deleteAll(String vspId, Version version) { + SessionContext context = createSessionContext(); + ElementContext elementContext = new ElementContext(vspId, version.getId()); + Optional<Element> optionalElement = zusammenAdaptor.getElementByName(context, elementContext, null, ElementType.Computes.name()); + if (optionalElement.isPresent()) { + Element computesElement = optionalElement.get(); + Collection<Element> computes = computesElement.getSubElements(); + computes.forEach(compute -> { + ZusammenElement computeElement = buildElement(compute.getElementId(), Action.DELETE); + zusammenAdaptor.saveElement(context, elementContext, computeElement, "Delete compute with id " + compute.getElementId()); + }); + } } - } - private ZusammenElement computeToZusammen(ComputeEntity compute, Action action) { - ZusammenElement computeElement = buildComputeElement(compute, action); - if (action == Action.CREATE) { - computeElement.setSubElements(Collections.singletonList( - computeQuestionnaireToZusammen(compute.getQuestionnaireData(), Action.CREATE))); + private ZusammenElement computeToZusammen(ComputeEntity compute, Action action) { + ZusammenElement computeElement = buildComputeElement(compute, action); + if (action == Action.CREATE) { + computeElement.setSubElements(Collections.singletonList(computeQuestionnaireToZusammen(compute.getQuestionnaireData(), Action.CREATE))); + } + return computeElement; } - return computeElement; - } - private ZusammenElement computeQuestionnaireToZusammen(String questionnaireData, - Action action) { - ZusammenElement questionnaireElement = - buildStructuralElement(ElementType.ComputeQuestionnaire, action); - questionnaireElement.setData(new ByteArrayInputStream(questionnaireData.getBytes())); - return questionnaireElement; - } + private ZusammenElement computeQuestionnaireToZusammen(String questionnaireData, Action action) { + ZusammenElement questionnaireElement = buildStructuralElement(ElementType.ComputeQuestionnaire, action); + questionnaireElement.setData(new ByteArrayInputStream(questionnaireData.getBytes())); + return questionnaireElement; + } - private ZusammenElement buildComputeElement(ComputeEntity compute, Action action) { - ZusammenElement computeElement = - buildElement(compute.getId() == null ? null : new Id(compute.getId()), action); - Info info = new Info(); - info.addProperty(ElementPropertyName.elementType.name(), ElementType.Compute); - info.addProperty(ElementPropertyName.compositionData.name(), compute.getCompositionData()); - computeElement.setInfo(info); - computeElement.setData(new ByteArrayInputStream(compute.getCompositionData().getBytes())); - return computeElement; - } + private ZusammenElement buildComputeElement(ComputeEntity compute, Action action) { + ZusammenElement computeElement = buildElement(compute.getId() == null ? null : new Id(compute.getId()), action); + Info info = new Info(); + info.addProperty(ElementPropertyName.elementType.name(), ElementType.Compute); + info.addProperty(ElementPropertyName.compositionData.name(), compute.getCompositionData()); + computeElement.setInfo(info); + computeElement.setData(new ByteArrayInputStream(compute.getCompositionData().getBytes())); + return computeElement; + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/DeploymentFlavorDaoZusammenImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/DeploymentFlavorDaoZusammenImpl.java index 8ccaf083d1..d72bd6b9b9 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/DeploymentFlavorDaoZusammenImpl.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/DeploymentFlavorDaoZusammenImpl.java @@ -7,9 +7,9 @@ * 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. @@ -17,9 +17,12 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen; +import static org.openecomp.core.zusammen.api.ZusammenUtil.buildElement; +import static org.openecomp.core.zusammen.api.ZusammenUtil.buildStructuralElement; +import static org.openecomp.core.zusammen.api.ZusammenUtil.createSessionContext; + import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element; import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement; import com.amdocs.zusammen.datatypes.Id; @@ -27,6 +30,10 @@ import com.amdocs.zusammen.datatypes.SessionContext; import com.amdocs.zusammen.datatypes.item.Action; import com.amdocs.zusammen.datatypes.item.ElementContext; import com.amdocs.zusammen.datatypes.item.Info; +import java.io.ByteArrayInputStream; +import java.util.Collection; +import java.util.Optional; +import java.util.stream.Collectors; import org.openecomp.core.utilities.file.FileUtils; import org.openecomp.core.zusammen.api.ZusammenAdaptor; import org.openecomp.sdc.datatypes.model.ElementType; @@ -36,153 +43,105 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity; import org.openecomp.sdc.versioning.dao.types.Version; import org.openecomp.types.ElementPropertyName; -import java.io.ByteArrayInputStream; -import java.util.Collection; -import java.util.Optional; -import java.util.stream.Collectors; - -import static org.openecomp.core.zusammen.api.ZusammenUtil.*; - public class DeploymentFlavorDaoZusammenImpl implements DeploymentFlavorDao { - private ZusammenAdaptor zusammenAdaptor; - - public DeploymentFlavorDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) { - this.zusammenAdaptor = zusammenAdaptor; - } - - @Override - public void registerVersioning(String versionableEntityType) { - // registerVersioning not implemented for DeploymentFlavorDaoZusammenImpl - } - - @Override - public Collection<DeploymentFlavorEntity> list(DeploymentFlavorEntity deploymentFlavor) { - SessionContext context = createSessionContext(); - ElementContext elementContext = - new ElementContext(deploymentFlavor.getVspId(), deploymentFlavor.getVersion().getId()); - - return listDeploymentFlavor(zusammenAdaptor, context, elementContext, - deploymentFlavor.getVspId(), - deploymentFlavor.getVersion()); - } + private ZusammenAdaptor zusammenAdaptor; - private static Collection<DeploymentFlavorEntity> listDeploymentFlavor( - ZusammenAdaptor zusammenAdaptor, - SessionContext context, - ElementContext elementContext, - String vspId, Version version) { - ElementToDeploymentFlavorConvertor convertor = new ElementToDeploymentFlavorConvertor(); - return zusammenAdaptor - .listElementsByName(context, elementContext, null, - ElementType.DeploymentFlavors.name()) - .stream().map(elementInfo -> { - DeploymentFlavorEntity entity = convertor.convert( - elementInfo); - entity.setVspId(vspId); - entity.setVersion(version); - return entity; - }) - .collect(Collectors.toList()); - } - - - @Override - public void create(DeploymentFlavorEntity deploymentFlavor) { - ZusammenElement deploymentFlavorElement = deploymentFlavorToZusammen(deploymentFlavor, - Action.CREATE); - ZusammenElement deploymentFlavorElements = - buildStructuralElement(ElementType.DeploymentFlavors, Action.IGNORE); - deploymentFlavorElements.getSubElements().add(deploymentFlavorElement); - - SessionContext context = createSessionContext(); - Element savedElement = zusammenAdaptor.saveElement(context, - new ElementContext(deploymentFlavor.getVspId(), deploymentFlavor.getVersion().getId()), - deploymentFlavorElements, "Create deloymentFlavor"); - deploymentFlavor.setId(savedElement.getSubElements().iterator().next().getElementId() - .getValue()); - } - - @Override - public void update(DeploymentFlavorEntity deploymentFlavor) { - ZusammenElement deploymentFlavorElement = deploymentFlavorToZusammen(deploymentFlavor, - Action.UPDATE); - - SessionContext context = createSessionContext(); - zusammenAdaptor.saveElement(context, - new ElementContext(deploymentFlavor.getVspId(), deploymentFlavor.getVersion().getId()), - deploymentFlavorElement, String.format("Update deloymentFlavor with id %s", - deploymentFlavor.getId())); - } - - @Override - public DeploymentFlavorEntity get(DeploymentFlavorEntity deploymentFlavor) { - SessionContext context = createSessionContext(); - ElementContext elementContext = - new ElementContext(deploymentFlavor.getVspId(), deploymentFlavor.getVersion().getId()); - - Optional<Element> element = - zusammenAdaptor.getElement(context, elementContext, deploymentFlavor.getId()); + public DeploymentFlavorDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) { + this.zusammenAdaptor = zusammenAdaptor; + } - if (element.isPresent()) { - ElementToDeploymentFlavorConvertor convertor = new ElementToDeploymentFlavorConvertor(); - DeploymentFlavorEntity entity = convertor.convert(element.get()); - deploymentFlavor.setCompositionData(new String(FileUtils.toByteArray(element.get() - .getData()))); - entity.setVspId(deploymentFlavor.getVspId()); - entity.setVersion(deploymentFlavor.getVersion()); - return entity; + private static Collection<DeploymentFlavorEntity> listDeploymentFlavor(ZusammenAdaptor zusammenAdaptor, SessionContext context, + ElementContext elementContext, String vspId, Version version) { + ElementToDeploymentFlavorConvertor convertor = new ElementToDeploymentFlavorConvertor(); + return zusammenAdaptor.listElementsByName(context, elementContext, null, ElementType.DeploymentFlavors.name()).stream().map(elementInfo -> { + DeploymentFlavorEntity entity = convertor.convert(elementInfo); + entity.setVspId(vspId); + entity.setVersion(version); + return entity; + }).collect(Collectors.toList()); } - return null; - } - @Override - public void delete(DeploymentFlavorEntity deploymentFlavor) { - ZusammenElement componentElement = - buildElement(new Id(deploymentFlavor.getId()), Action.DELETE); + @Override + public void registerVersioning(String versionableEntityType) { + // registerVersioning not implemented for DeploymentFlavorDaoZusammenImpl + } - SessionContext context = createSessionContext(); - zusammenAdaptor.saveElement(context, - new ElementContext(deploymentFlavor.getVspId(), deploymentFlavor.getVersion().getId()), - componentElement, String.format("Delete deloymentFlavor with id %s", - deploymentFlavor.getId())); - } + @Override + public Collection<DeploymentFlavorEntity> list(DeploymentFlavorEntity deploymentFlavor) { + SessionContext context = createSessionContext(); + ElementContext elementContext = new ElementContext(deploymentFlavor.getVspId(), deploymentFlavor.getVersion().getId()); + return listDeploymentFlavor(zusammenAdaptor, context, elementContext, deploymentFlavor.getVspId(), deploymentFlavor.getVersion()); + } - @Override - public void deleteAll(String vspId, Version version) { - SessionContext context = createSessionContext(); - ElementContext elementContext = new ElementContext(vspId, version.getId()); + @Override + public void create(DeploymentFlavorEntity deploymentFlavor) { + ZusammenElement deploymentFlavorElement = deploymentFlavorToZusammen(deploymentFlavor, Action.CREATE); + ZusammenElement deploymentFlavorElements = buildStructuralElement(ElementType.DeploymentFlavors, Action.IGNORE); + deploymentFlavorElements.getSubElements().add(deploymentFlavorElement); + SessionContext context = createSessionContext(); + Element savedElement = zusammenAdaptor + .saveElement(context, new ElementContext(deploymentFlavor.getVspId(), deploymentFlavor.getVersion().getId()), deploymentFlavorElements, + "Create deloymentFlavor"); + deploymentFlavor.setId(savedElement.getSubElements().iterator().next().getElementId().getValue()); + } - Optional<Element> optionalElement = zusammenAdaptor.getElementByName(context, - elementContext, null, ElementType.DeploymentFlavors.name()); + @Override + public void update(DeploymentFlavorEntity deploymentFlavor) { + ZusammenElement deploymentFlavorElement = deploymentFlavorToZusammen(deploymentFlavor, Action.UPDATE); + SessionContext context = createSessionContext(); + zusammenAdaptor + .saveElement(context, new ElementContext(deploymentFlavor.getVspId(), deploymentFlavor.getVersion().getId()), deploymentFlavorElement, + String.format("Update deloymentFlavor with id %s", deploymentFlavor.getId())); + } - if (optionalElement.isPresent()) { - Element deploymentFlavorsElement = optionalElement.get(); - Collection<Element> deploymentFlavors = deploymentFlavorsElement.getSubElements(); + @Override + public DeploymentFlavorEntity get(DeploymentFlavorEntity deploymentFlavor) { + SessionContext context = createSessionContext(); + ElementContext elementContext = new ElementContext(deploymentFlavor.getVspId(), deploymentFlavor.getVersion().getId()); + Optional<Element> element = zusammenAdaptor.getElement(context, elementContext, deploymentFlavor.getId()); + if (element.isPresent()) { + ElementToDeploymentFlavorConvertor convertor = new ElementToDeploymentFlavorConvertor(); + DeploymentFlavorEntity entity = convertor.convert(element.get()); + deploymentFlavor.setCompositionData(new String(FileUtils.toByteArray(element.get().getData()))); + entity.setVspId(deploymentFlavor.getVspId()); + entity.setVersion(deploymentFlavor.getVersion()); + return entity; + } + return null; + } - deploymentFlavors.forEach(deplymentFlavor -> { - ZusammenElement deplymentFlavorZusammenElement = - buildElement(deplymentFlavor.getElementId(), Action.DELETE); - zusammenAdaptor.saveElement(context, - elementContext, deplymentFlavorZusammenElement, " Delete Deplyment Flavor with id " - + deplymentFlavor.getElementId()); - }); + @Override + public void delete(DeploymentFlavorEntity deploymentFlavor) { + ZusammenElement componentElement = buildElement(new Id(deploymentFlavor.getId()), Action.DELETE); + SessionContext context = createSessionContext(); + zusammenAdaptor.saveElement(context, new ElementContext(deploymentFlavor.getVspId(), deploymentFlavor.getVersion().getId()), componentElement, + String.format("Delete deloymentFlavor with id %s", deploymentFlavor.getId())); } - } - private ZusammenElement deploymentFlavorToZusammen(DeploymentFlavorEntity deploymentFlavor, - Action action) { - ZusammenElement deploymentFlavorElement = - buildElement(deploymentFlavor.getId() == null ? null : new Id(deploymentFlavor.getId()), - action); - Info info = new Info(); - info.addProperty(ElementPropertyName.elementType.name(), ElementType.DeploymentFlavor); - info.addProperty(ElementPropertyName.compositionData.name(), deploymentFlavor - .getCompositionData()); - deploymentFlavorElement.setInfo(info); - deploymentFlavorElement.setData(new ByteArrayInputStream(deploymentFlavor.getCompositionData() - .getBytes())); - return deploymentFlavorElement; - } + @Override + public void deleteAll(String vspId, Version version) { + SessionContext context = createSessionContext(); + ElementContext elementContext = new ElementContext(vspId, version.getId()); + Optional<Element> optionalElement = zusammenAdaptor.getElementByName(context, elementContext, null, ElementType.DeploymentFlavors.name()); + if (optionalElement.isPresent()) { + Element deploymentFlavorsElement = optionalElement.get(); + Collection<Element> deploymentFlavors = deploymentFlavorsElement.getSubElements(); + deploymentFlavors.forEach(deplymentFlavor -> { + ZusammenElement deplymentFlavorZusammenElement = buildElement(deplymentFlavor.getElementId(), Action.DELETE); + zusammenAdaptor.saveElement(context, elementContext, deplymentFlavorZusammenElement, + " Delete Deplyment Flavor with id " + deplymentFlavor.getElementId()); + }); + } + } + private ZusammenElement deploymentFlavorToZusammen(DeploymentFlavorEntity deploymentFlavor, Action action) { + ZusammenElement deploymentFlavorElement = buildElement(deploymentFlavor.getId() == null ? null : new Id(deploymentFlavor.getId()), action); + Info info = new Info(); + info.addProperty(ElementPropertyName.elementType.name(), ElementType.DeploymentFlavor); + info.addProperty(ElementPropertyName.compositionData.name(), deploymentFlavor.getCompositionData()); + deploymentFlavorElement.setInfo(info); + deploymentFlavorElement.setData(new ByteArrayInputStream(deploymentFlavor.getCompositionData().getBytes())); + return deploymentFlavorElement; + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ImageDaoZusammenImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ImageDaoZusammenImpl.java index f82827d02b..5227a4cff4 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ImageDaoZusammenImpl.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ImageDaoZusammenImpl.java @@ -7,9 +7,9 @@ * 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. @@ -17,9 +17,11 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen; +import static org.openecomp.core.zusammen.api.ZusammenUtil.buildElement; +import static org.openecomp.core.zusammen.api.ZusammenUtil.buildStructuralElement; +import static org.openecomp.core.zusammen.api.ZusammenUtil.createSessionContext; import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element; import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement; @@ -28,6 +30,11 @@ import com.amdocs.zusammen.datatypes.SessionContext; import com.amdocs.zusammen.datatypes.item.Action; import com.amdocs.zusammen.datatypes.item.ElementContext; import com.amdocs.zusammen.datatypes.item.Info; +import java.io.ByteArrayInputStream; +import java.util.Collection; +import java.util.Collections; +import java.util.Optional; +import java.util.stream.Collectors; import org.openecomp.core.utilities.file.FileUtils; import org.openecomp.core.zusammen.api.ZusammenAdaptor; import org.openecomp.sdc.datatypes.model.ElementType; @@ -38,220 +45,156 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ImageEntity; import org.openecomp.sdc.versioning.dao.types.Version; import org.openecomp.types.ElementPropertyName; -import java.io.ByteArrayInputStream; -import java.util.Collection; -import java.util.Collections; -import java.util.Optional; -import java.util.stream.Collectors; - -import static org.openecomp.core.zusammen.api.ZusammenUtil.*; - public class ImageDaoZusammenImpl implements ImageDao { - private ZusammenAdaptor zusammenAdaptor; - - public ImageDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) { - this.zusammenAdaptor = zusammenAdaptor; - } - - @Override - public void registerVersioning(String versionableEntityType) { - // registerVersioning not implemented for ImageDaoZusammenImpl - } - - @Override - public Collection<ImageEntity> list(ImageEntity image) { - SessionContext context = createSessionContext(); - ElementContext elementContext = - new ElementContext(image.getVspId(), image.getVersion().getId()); - - return listImages(context, elementContext, image); - } - - private Collection<ImageEntity> listImages(SessionContext context, - ElementContext elementContext, ImageEntity image) { - return zusammenAdaptor - .listElementsByName(context, elementContext, new Id(image.getComponentId()), - ElementType.Images.name()) - .stream().map(new ElementToImageConvertor()::convert) - .map(imageEntity -> { - imageEntity.setComponentId(image.getComponentId()); - imageEntity.setVspId(image.getVspId()); - imageEntity.setVersion(image.getVersion()); - return imageEntity; - }) - .collect(Collectors.toList()); - } - - @Override - public void create(ImageEntity image) { - ZusammenElement imageElement = imageToZusammen(image, Action.CREATE); - - ZusammenElement imagesElement = - buildStructuralElement(ElementType.Images, Action.IGNORE); - imagesElement.setSubElements(Collections.singletonList(imageElement)); - - ZusammenElement componentElement = buildElement(new Id(image.getComponentId()), Action.IGNORE); - componentElement.setSubElements(Collections.singletonList(imagesElement)); - - SessionContext context = createSessionContext(); - ElementContext elementContext = - new ElementContext(image.getVspId(), image.getVersion().getId()); - - Element savedElement = - zusammenAdaptor.saveElement(context, elementContext, componentElement, "Create image"); - image.setId(savedElement.getSubElements().iterator().next() - .getSubElements().iterator().next().getElementId().getValue()); - } + private ZusammenAdaptor zusammenAdaptor; - @Override - public void update(ImageEntity image) { - ZusammenElement imageElement = imageToZusammen(image, Action.UPDATE); - - SessionContext context = createSessionContext(); - ElementContext elementContext = - new ElementContext(image.getVspId(), image.getVersion().getId()); - zusammenAdaptor.saveElement(context, elementContext, imageElement, - String.format("Update image with id %s", image.getId())); - } - - @Override - public ImageEntity get(ImageEntity image) { - SessionContext context = createSessionContext(); - - ElementContext elementContext = - new ElementContext(image.getVspId(), image.getVersion().getId()); - Optional<Element> element = zusammenAdaptor.getElement(context, elementContext, image.getId()); - - if (element.isPresent()) { - ElementToImageConvertor convertor = new ElementToImageConvertor(); - ImageEntity entity = convertor.convert(element.get()); - entity.setComponentId(image.getComponentId()); - entity.setVspId(image.getVspId()); - entity.setVersion(image.getVersion()); - return entity; - } else { - return null; + public ImageDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) { + this.zusammenAdaptor = zusammenAdaptor; } - } - - @Override - public void delete(ImageEntity image) { - ZusammenElement imageElement = buildElement(new Id(image.getId()), Action.DELETE); - - SessionContext context = createSessionContext(); - ElementContext elementContext = - new ElementContext(image.getVspId(), image.getVersion().getId()); - zusammenAdaptor.saveElement(context, elementContext, imageElement, - String.format("Delete image with id %s", image.getId())); - } - @Override - public void deleteByVspId(String vspId, Version version) { - SessionContext context = createSessionContext(); - ElementContext elementContext = new ElementContext(vspId, version.getId()); - - Optional<Element> elementOptional = zusammenAdaptor.getElementByName(context, elementContext, - null, ElementType.Images.name()); - - if (elementOptional.isPresent()) { - Element imagesElement = elementOptional.get(); - Collection<Element> images = imagesElement.getSubElements(); - images.forEach(image -> { - ZusammenElement imageZusammenElement = buildElement(image.getElementId(), Action.DELETE); - zusammenAdaptor.saveElement(context, elementContext, imageZusammenElement, "Delete image " + - "with id " + image.getElementId()); - }); + @Override + public void registerVersioning(String versionableEntityType) { + // registerVersioning not implemented for ImageDaoZusammenImpl } - } - - @Override - public Collection<ImageEntity> listByVsp(String vspId, Version version) { - SessionContext context = createSessionContext(); - ElementContext elementContext = new ElementContext(vspId, version.getId()); - Collection<ComponentEntity> components = ComponentDaoZusammenImpl - .listComponents(zusammenAdaptor, context, vspId, version); + @Override + public Collection<ImageEntity> list(ImageEntity image) { + SessionContext context = createSessionContext(); + ElementContext elementContext = new ElementContext(image.getVspId(), image.getVersion().getId()); + return listImages(context, elementContext, image); + } - return components.stream() - .map(component -> - listImages(context, elementContext, - new ImageEntity(vspId, version, component.getId(), null)).stream() - .map(image -> getQuestionnaire(context, elementContext, image)) - .collect(Collectors.toList())) - .flatMap(Collection::stream) - .collect(Collectors.toList()); - } + private Collection<ImageEntity> listImages(SessionContext context, ElementContext elementContext, ImageEntity image) { + return zusammenAdaptor.listElementsByName(context, elementContext, new Id(image.getComponentId()), ElementType.Images.name()).stream() + .map(new ElementToImageConvertor()::convert).map(imageEntity -> { + imageEntity.setComponentId(image.getComponentId()); + imageEntity.setVspId(image.getVspId()); + imageEntity.setVersion(image.getVersion()); + return imageEntity; + }).collect(Collectors.toList()); + } - @Override - public ImageEntity getQuestionnaireData(String vspId, Version version, String componentId, - String imageId) { - SessionContext context = createSessionContext(); - ElementContext elementContext = new ElementContext(vspId, version.getId()); + @Override + public void create(ImageEntity image) { + ZusammenElement imageElement = imageToZusammen(image, Action.CREATE); + ZusammenElement imagesElement = buildStructuralElement(ElementType.Images, Action.IGNORE); + imagesElement.setSubElements(Collections.singletonList(imageElement)); + ZusammenElement componentElement = buildElement(new Id(image.getComponentId()), Action.IGNORE); + componentElement.setSubElements(Collections.singletonList(imagesElement)); + SessionContext context = createSessionContext(); + ElementContext elementContext = new ElementContext(image.getVspId(), image.getVersion().getId()); + Element savedElement = zusammenAdaptor.saveElement(context, elementContext, componentElement, "Create image"); + image.setId(savedElement.getSubElements().iterator().next().getSubElements().iterator().next().getElementId().getValue()); + } - return getQuestionnaire(context, elementContext, - new ImageEntity(vspId, version, componentId, imageId)); - } + @Override + public void update(ImageEntity image) { + ZusammenElement imageElement = imageToZusammen(image, Action.UPDATE); + SessionContext context = createSessionContext(); + ElementContext elementContext = new ElementContext(image.getVspId(), image.getVersion().getId()); + zusammenAdaptor.saveElement(context, elementContext, imageElement, String.format("Update image with id %s", image.getId())); + } - private ImageEntity getQuestionnaire(SessionContext context, ElementContext elementContext, - ImageEntity image) { - Optional<Element> questionnaireElement = zusammenAdaptor - .getElementByName(context, elementContext, new Id(image.getId()), - ElementType.ImageQuestionnaire.name()); - return questionnaireElement.map( - element -> element.getData() == null - ? null - : new String(FileUtils.toByteArray(element.getData()))) - .map(questionnaireData -> { - image.setQuestionnaireData(questionnaireData); - return image; - }) - .orElse(null); - } + @Override + public ImageEntity get(ImageEntity image) { + SessionContext context = createSessionContext(); + ElementContext elementContext = new ElementContext(image.getVspId(), image.getVersion().getId()); + Optional<Element> element = zusammenAdaptor.getElement(context, elementContext, image.getId()); + if (element.isPresent()) { + ElementToImageConvertor convertor = new ElementToImageConvertor(); + ImageEntity entity = convertor.convert(element.get()); + entity.setComponentId(image.getComponentId()); + entity.setVspId(image.getVspId()); + entity.setVersion(image.getVersion()); + return entity; + } else { + return null; + } + } - @Override - public void updateQuestionnaireData(String vspId, Version version, String componentId, - String imageId, String questionnaireData) { - ZusammenElement questionnaireElement = - imageQuestionnaireToZusammen(questionnaireData, Action.UPDATE); + @Override + public void delete(ImageEntity image) { + ZusammenElement imageElement = buildElement(new Id(image.getId()), Action.DELETE); + SessionContext context = createSessionContext(); + ElementContext elementContext = new ElementContext(image.getVspId(), image.getVersion().getId()); + zusammenAdaptor.saveElement(context, elementContext, imageElement, String.format("Delete image with id %s", image.getId())); + } - ZusammenElement imageElement = buildElement(new Id(imageId), Action.IGNORE); - imageElement.setSubElements(Collections.singletonList(questionnaireElement)); + @Override + public void deleteByVspId(String vspId, Version version) { + SessionContext context = createSessionContext(); + ElementContext elementContext = new ElementContext(vspId, version.getId()); + Optional<Element> elementOptional = zusammenAdaptor.getElementByName(context, elementContext, null, ElementType.Images.name()); + if (elementOptional.isPresent()) { + Element imagesElement = elementOptional.get(); + Collection<Element> images = imagesElement.getSubElements(); + images.forEach(image -> { + ZusammenElement imageZusammenElement = buildElement(image.getElementId(), Action.DELETE); + zusammenAdaptor.saveElement(context, elementContext, imageZusammenElement, "Delete image " + "with id " + image.getElementId()); + }); + } + } - SessionContext context = createSessionContext(); - ElementContext elementContext = new ElementContext(vspId, version.getId()); - zusammenAdaptor.saveElement(context, elementContext, imageElement, "Update image " - + "questionnaire"); - } + @Override + public Collection<ImageEntity> listByVsp(String vspId, Version version) { + SessionContext context = createSessionContext(); + ElementContext elementContext = new ElementContext(vspId, version.getId()); + Collection<ComponentEntity> components = ComponentDaoZusammenImpl.listComponents(zusammenAdaptor, context, vspId, version); + return components.stream().map( + component -> listImages(context, elementContext, new ImageEntity(vspId, version, component.getId(), null)).stream() + .map(image -> getQuestionnaire(context, elementContext, image)).collect(Collectors.toList())).flatMap(Collection::stream) + .collect(Collectors.toList()); + } + @Override + public ImageEntity getQuestionnaireData(String vspId, Version version, String componentId, String imageId) { + SessionContext context = createSessionContext(); + ElementContext elementContext = new ElementContext(vspId, version.getId()); + return getQuestionnaire(context, elementContext, new ImageEntity(vspId, version, componentId, imageId)); + } - private ZusammenElement imageToZusammen(ImageEntity image, Action action) { - ZusammenElement imageElement = buildImageElement(image, action); - if (action == Action.CREATE) { - imageElement.setSubElements(Collections.singletonList( - imageQuestionnaireToZusammen(image.getQuestionnaireData(), Action.CREATE))); + private ImageEntity getQuestionnaire(SessionContext context, ElementContext elementContext, ImageEntity image) { + Optional<Element> questionnaireElement = zusammenAdaptor + .getElementByName(context, elementContext, new Id(image.getId()), ElementType.ImageQuestionnaire.name()); + return questionnaireElement.map(element -> element.getData() == null ? null : new String(FileUtils.toByteArray(element.getData()))) + .map(questionnaireData -> { + image.setQuestionnaireData(questionnaireData); + return image; + }).orElse(null); } - return imageElement; - } - private ZusammenElement imageQuestionnaireToZusammen(String questionnaireData, - Action action) { - ZusammenElement questionnaireElement = - buildStructuralElement(ElementType.ImageQuestionnaire, action); - questionnaireElement.setData(new ByteArrayInputStream(questionnaireData.getBytes())); - return questionnaireElement; - } + @Override + public void updateQuestionnaireData(String vspId, Version version, String componentId, String imageId, String questionnaireData) { + ZusammenElement questionnaireElement = imageQuestionnaireToZusammen(questionnaireData, Action.UPDATE); + ZusammenElement imageElement = buildElement(new Id(imageId), Action.IGNORE); + imageElement.setSubElements(Collections.singletonList(questionnaireElement)); + SessionContext context = createSessionContext(); + ElementContext elementContext = new ElementContext(vspId, version.getId()); + zusammenAdaptor.saveElement(context, elementContext, imageElement, "Update image " + "questionnaire"); + } - private ZusammenElement buildImageElement(ImageEntity image, Action action) { - ZusammenElement imageElement = - buildElement(image.getId() == null ? null : new Id(image.getId()), action); - Info info = new Info(); - info.addProperty(ElementPropertyName.elementType.name(), ElementType.Image); - info.addProperty(ElementPropertyName.compositionData.name(), image.getCompositionData()); - imageElement.setInfo(info); - imageElement.setData(new ByteArrayInputStream(image.getCompositionData().getBytes())); - return imageElement; - } + private ZusammenElement imageToZusammen(ImageEntity image, Action action) { + ZusammenElement imageElement = buildImageElement(image, action); + if (action == Action.CREATE) { + imageElement.setSubElements(Collections.singletonList(imageQuestionnaireToZusammen(image.getQuestionnaireData(), Action.CREATE))); + } + return imageElement; + } + private ZusammenElement imageQuestionnaireToZusammen(String questionnaireData, Action action) { + ZusammenElement questionnaireElement = buildStructuralElement(ElementType.ImageQuestionnaire, action); + questionnaireElement.setData(new ByteArrayInputStream(questionnaireData.getBytes())); + return questionnaireElement; + } + private ZusammenElement buildImageElement(ImageEntity image, Action action) { + ZusammenElement imageElement = buildElement(image.getId() == null ? null : new Id(image.getId()), action); + Info info = new Info(); + info.addProperty(ElementPropertyName.elementType.name(), ElementType.Image); + info.addProperty(ElementPropertyName.compositionData.name(), image.getCompositionData()); + imageElement.setInfo(info); + imageElement.setData(new ByteArrayInputStream(image.getCompositionData().getBytes())); + return imageElement; + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/NetworkDaoZusammenImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/NetworkDaoZusammenImpl.java index 4099e1264b..0230f3e486 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/NetworkDaoZusammenImpl.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/NetworkDaoZusammenImpl.java @@ -7,9 +7,9 @@ * 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. @@ -17,9 +17,12 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen; +import static org.openecomp.core.zusammen.api.ZusammenUtil.buildElement; +import static org.openecomp.core.zusammen.api.ZusammenUtil.buildStructuralElement; +import static org.openecomp.core.zusammen.api.ZusammenUtil.createSessionContext; + import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element; import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo; import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement; @@ -28,6 +31,12 @@ import com.amdocs.zusammen.datatypes.SessionContext; import com.amdocs.zusammen.datatypes.item.Action; import com.amdocs.zusammen.datatypes.item.ElementContext; import com.amdocs.zusammen.datatypes.item.Info; +import java.io.ByteArrayInputStream; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Optional; +import java.util.stream.Collectors; import org.openecomp.core.zusammen.api.ZusammenAdaptor; import org.openecomp.sdc.datatypes.model.ElementType; import org.openecomp.sdc.vendorsoftwareproduct.dao.NetworkDao; @@ -36,141 +45,103 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NetworkEntity; import org.openecomp.sdc.versioning.dao.types.Version; import org.openecomp.types.ElementPropertyName; -import java.io.ByteArrayInputStream; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Optional; -import java.util.stream.Collectors; - -import static org.openecomp.core.zusammen.api.ZusammenUtil.*; - public class NetworkDaoZusammenImpl implements NetworkDao { - private ZusammenAdaptor zusammenAdaptor; - - public NetworkDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) { - this.zusammenAdaptor = zusammenAdaptor; - } - - @Override - public void registerVersioning(String versionableEntityType) { - // registerVersioning not implemented for NetworkDaoZusammenImpl - } + private ZusammenAdaptor zusammenAdaptor; - @Override - public Collection<NetworkEntity> list(NetworkEntity network) { - SessionContext context = createSessionContext(); - ElementContext elementContext = - new ElementContext(network.getVspId(), network.getVersion().getId()); - - Optional<ElementInfo> vspModel = zusammenAdaptor - .getElementInfoByName(context, elementContext, null, ElementType.VspModel.name()); - if (!vspModel.isPresent()) { - return new ArrayList<>(); + public NetworkDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) { + this.zusammenAdaptor = zusammenAdaptor; } - return zusammenAdaptor.listElementsByName(context, elementContext, vspModel.get().getId(), - ElementType.Networks.name()).stream() - .map(new ElementToNetworkConvertor()::convert) - .map(entity -> { - entity.setVspId(network.getVspId()); - entity.setVersion(network.getVersion()); - return entity; - }) - .collect(Collectors.toList()); - } - - @Override - public void create(NetworkEntity network) { - ZusammenElement networkElement = buildNetworkElement(network, Action.CREATE); - - ZusammenElement networksElement = buildStructuralElement(ElementType.Networks, Action.IGNORE); - networksElement.setSubElements(Collections.singletonList(networkElement)); - - ZusammenElement vspModel = buildStructuralElement(ElementType.VspModel, Action.IGNORE); - vspModel.addSubElement(networksElement); - - SessionContext context = createSessionContext(); - Element savedElement = zusammenAdaptor - .saveElement(context, new ElementContext(network.getVspId(), network.getVersion().getId()), - vspModel, "Create network"); - network.setId(savedElement.getSubElements().iterator().next() - .getSubElements().iterator().next().getElementId().getValue()); - } - - @Override - public void update(NetworkEntity network) { - ZusammenElement networkElement = buildNetworkElement(network, Action.UPDATE); - - SessionContext context = createSessionContext(); - zusammenAdaptor - .saveElement(context, new ElementContext(network.getVspId(), network.getVersion().getId()), - networkElement, String.format("Update network with id %s", network.getId())); - } - - @Override - public NetworkEntity get(NetworkEntity network) { - SessionContext context = createSessionContext(); - - Optional<Element> element = - zusammenAdaptor.getElement(context, - new ElementContext(network.getVspId(), network.getVersion().getId()), network.getId()); - - if (element.isPresent()) { - ElementToNetworkConvertor convertor = new ElementToNetworkConvertor(); - NetworkEntity entity = convertor.convert(element.get()); - entity.setVspId(network.getVspId()); - entity.setVersion(network.getVersion()); - return entity; - } else { - return null; + @Override + public void registerVersioning(String versionableEntityType) { + // registerVersioning not implemented for NetworkDaoZusammenImpl } - } - - @Override - public void delete(NetworkEntity network) { - ZusammenElement networkElement = buildElement(new Id(network.getId()), Action.DELETE); - - SessionContext context = createSessionContext(); - zusammenAdaptor - .saveElement(context, new ElementContext(network.getVspId(), network.getVersion().getId()), - networkElement, String.format("Delete network with id %s", network.getId())); - } + @Override + public Collection<NetworkEntity> list(NetworkEntity network) { + SessionContext context = createSessionContext(); + ElementContext elementContext = new ElementContext(network.getVspId(), network.getVersion().getId()); + Optional<ElementInfo> vspModel = zusammenAdaptor.getElementInfoByName(context, elementContext, null, ElementType.VspModel.name()); + if (!vspModel.isPresent()) { + return new ArrayList<>(); + } + return zusammenAdaptor.listElementsByName(context, elementContext, vspModel.get().getId(), ElementType.Networks.name()).stream() + .map(new ElementToNetworkConvertor()::convert).map(entity -> { + entity.setVspId(network.getVspId()); + entity.setVersion(network.getVersion()); + return entity; + }).collect(Collectors.toList()); + } - @Override - public void deleteAll(String vspId, Version version) { - SessionContext context = createSessionContext(); - ElementContext elementContext = new ElementContext(vspId, version.getId()); + @Override + public void create(NetworkEntity network) { + ZusammenElement networkElement = buildNetworkElement(network, Action.CREATE); + ZusammenElement networksElement = buildStructuralElement(ElementType.Networks, Action.IGNORE); + networksElement.setSubElements(Collections.singletonList(networkElement)); + ZusammenElement vspModel = buildStructuralElement(ElementType.VspModel, Action.IGNORE); + vspModel.addSubElement(networksElement); + SessionContext context = createSessionContext(); + Element savedElement = zusammenAdaptor + .saveElement(context, new ElementContext(network.getVspId(), network.getVersion().getId()), vspModel, "Create network"); + network.setId(savedElement.getSubElements().iterator().next().getSubElements().iterator().next().getElementId().getValue()); + } - Collection<ElementInfo> vspModelSubs = zusammenAdaptor - .listElementsByName(context, elementContext, null, ElementType.VspModel.name()); + @Override + public void update(NetworkEntity network) { + ZusammenElement networkElement = buildNetworkElement(network, Action.UPDATE); + SessionContext context = createSessionContext(); + zusammenAdaptor.saveElement(context, new ElementContext(network.getVspId(), network.getVersion().getId()), networkElement, + String.format("Update network with id %s", network.getId())); + } - Optional<ElementInfo> networksElement = vspModelSubs.stream() - .filter(elementInfo -> elementInfo.getInfo() != null - && ElementType.Networks.name().equals(elementInfo.getInfo().getName())) - .findFirst(); - if (!networksElement.isPresent()) { - return; + @Override + public NetworkEntity get(NetworkEntity network) { + SessionContext context = createSessionContext(); + Optional<Element> element = zusammenAdaptor + .getElement(context, new ElementContext(network.getVspId(), network.getVersion().getId()), network.getId()); + if (element.isPresent()) { + ElementToNetworkConvertor convertor = new ElementToNetworkConvertor(); + NetworkEntity entity = convertor.convert(element.get()); + entity.setVspId(network.getVspId()); + entity.setVersion(network.getVersion()); + return entity; + } else { + return null; + } } - ZusammenElement networks = buildElement(networksElement.get().getId(), Action.IGNORE); - networks.setSubElements(networksElement.get().getSubElements().stream() - .map(network -> buildElement(network.getId(), Action.DELETE)) - .collect(Collectors.toList())); + @Override + public void delete(NetworkEntity network) { + ZusammenElement networkElement = buildElement(new Id(network.getId()), Action.DELETE); + SessionContext context = createSessionContext(); + zusammenAdaptor.saveElement(context, new ElementContext(network.getVspId(), network.getVersion().getId()), networkElement, + String.format("Delete network with id %s", network.getId())); + } - zusammenAdaptor.saveElement(context, elementContext, networks, "Delete all networks"); - } + @Override + public void deleteAll(String vspId, Version version) { + SessionContext context = createSessionContext(); + ElementContext elementContext = new ElementContext(vspId, version.getId()); + Collection<ElementInfo> vspModelSubs = zusammenAdaptor.listElementsByName(context, elementContext, null, ElementType.VspModel.name()); + Optional<ElementInfo> networksElement = vspModelSubs.stream() + .filter(elementInfo -> elementInfo.getInfo() != null && ElementType.Networks.name().equals(elementInfo.getInfo().getName())).findFirst(); + if (!networksElement.isPresent()) { + return; + } + ZusammenElement networks = buildElement(networksElement.get().getId(), Action.IGNORE); + networks.setSubElements(networksElement.get().getSubElements().stream().map(network -> buildElement(network.getId(), Action.DELETE)) + .collect(Collectors.toList())); + zusammenAdaptor.saveElement(context, elementContext, networks, "Delete all networks"); + } - private ZusammenElement buildNetworkElement(NetworkEntity network, Action action) { - ZusammenElement networkElement = - buildElement(network.getId() == null ? null : new Id(network.getId()), action); - Info info = new Info(); - info.addProperty(ElementPropertyName.elementType.name(), ElementType.Network); - info.addProperty(ElementPropertyName.compositionData.name(), network.getCompositionData()); - networkElement.setInfo(info); - networkElement.setData(new ByteArrayInputStream(network.getCompositionData().getBytes())); - return networkElement; - } + private ZusammenElement buildNetworkElement(NetworkEntity network, Action action) { + ZusammenElement networkElement = buildElement(network.getId() == null ? null : new Id(network.getId()), action); + Info info = new Info(); + info.addProperty(ElementPropertyName.elementType.name(), ElementType.Network); + info.addProperty(ElementPropertyName.compositionData.name(), network.getCompositionData()); + networkElement.setInfo(info); + networkElement.setData(new ByteArrayInputStream(network.getCompositionData().getBytes())); + return networkElement; + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/NicDaoZusammenImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/NicDaoZusammenImpl.java index 05f8d9dcfc..baad1d7c89 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/NicDaoZusammenImpl.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/NicDaoZusammenImpl.java @@ -7,9 +7,9 @@ * 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. @@ -17,9 +17,12 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen; +import static org.openecomp.core.zusammen.api.ZusammenUtil.buildElement; +import static org.openecomp.core.zusammen.api.ZusammenUtil.buildStructuralElement; +import static org.openecomp.core.zusammen.api.ZusammenUtil.createSessionContext; + import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element; import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement; import com.amdocs.zusammen.datatypes.Id; @@ -27,6 +30,11 @@ import com.amdocs.zusammen.datatypes.SessionContext; import com.amdocs.zusammen.datatypes.item.Action; import com.amdocs.zusammen.datatypes.item.ElementContext; import com.amdocs.zusammen.datatypes.item.Info; +import java.io.ByteArrayInputStream; +import java.util.Collection; +import java.util.Collections; +import java.util.Optional; +import java.util.stream.Collectors; import org.openecomp.core.zusammen.api.ZusammenAdaptor; import org.openecomp.sdc.datatypes.model.ElementType; import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDao; @@ -37,217 +45,159 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity; import org.openecomp.sdc.versioning.dao.types.Version; import org.openecomp.types.ElementPropertyName; -import java.io.ByteArrayInputStream; -import java.util.Collection; -import java.util.Collections; -import java.util.Optional; -import java.util.stream.Collectors; +public class NicDaoZusammenImpl implements NicDao { -import static org.openecomp.core.zusammen.api.ZusammenUtil.*; + private ZusammenAdaptor zusammenAdaptor; -public class NicDaoZusammenImpl implements NicDao { + public NicDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) { + this.zusammenAdaptor = zusammenAdaptor; + } + + @Override + public void registerVersioning(String versionableEntityType) { + // registerVersioning is not implemented for NicDaoZusammenImpl + } + + @Override + public Collection<NicEntity> list(NicEntity nic) { + SessionContext context = createSessionContext(); + return listNics(context, new ElementContext(nic.getVspId(), nic.getVersion().getId()), nic); + } + + private Collection<NicEntity> listNics(SessionContext context, ElementContext elementContext, NicEntity nic) { + return zusammenAdaptor.listElementsByName(context, elementContext, new Id(nic.getComponentId()), ElementType.Nics.name()).stream() + .map(new ElementToNicConvertor()::convert).map(nicEntity -> { + nicEntity.setComponentId(nic.getComponentId()); + nicEntity.setVspId(nic.getVspId()); + nicEntity.setVersion(nic.getVersion()); + return nicEntity; + }).collect(Collectors.toList()); + } + + @Override + public void create(NicEntity nic) { + ZusammenElement nicElement = nicToZusammen(nic, Action.CREATE); + ZusammenElement nicsElement = buildStructuralElement(ElementType.Nics, Action.IGNORE); + nicsElement.setSubElements(Collections.singletonList(nicElement)); + ZusammenElement componentElement = buildElement(new Id(nic.getComponentId()), Action.IGNORE); + componentElement.setSubElements(Collections.singletonList(nicsElement)); + SessionContext context = createSessionContext(); + ElementContext elementContext = new ElementContext(nic.getVspId(), nic.getVersion().getId()); + Element savedElement = zusammenAdaptor.saveElement(context, elementContext, componentElement, "Create nic"); + nic.setId(savedElement.getSubElements().iterator().next().getSubElements().iterator().next().getElementId().getValue()); + } - private ZusammenAdaptor zusammenAdaptor; - - public NicDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) { - this.zusammenAdaptor = zusammenAdaptor; - } - - @Override - public void registerVersioning(String versionableEntityType) { - // registerVersioning is not implemented for NicDaoZusammenImpl - } - - @Override - public Collection<NicEntity> list(NicEntity nic) { - SessionContext context = createSessionContext(); - return listNics(context, new ElementContext(nic.getVspId(), nic.getVersion().getId()), nic); - } - - private Collection<NicEntity> listNics(SessionContext context, ElementContext elementContext, - NicEntity nic) { - return zusammenAdaptor.listElementsByName(context, elementContext, new Id(nic.getComponentId()), - ElementType.Nics.name()) - .stream() - .map(new ElementToNicConvertor()::convert) - .map(nicEntity -> { - nicEntity.setComponentId(nic.getComponentId()); - nicEntity.setVspId(nic.getVspId()); - nicEntity.setVersion(nic.getVersion()); - return nicEntity; - }) - .collect(Collectors.toList()); - } - - - @Override - public void create(NicEntity nic) { - ZusammenElement nicElement = nicToZusammen(nic, Action.CREATE); - - ZusammenElement nicsElement = buildStructuralElement(ElementType.Nics, Action.IGNORE); - nicsElement.setSubElements(Collections.singletonList(nicElement)); - - ZusammenElement componentElement = buildElement(new Id(nic.getComponentId()), Action.IGNORE); - componentElement.setSubElements(Collections.singletonList(nicsElement)); - - SessionContext context = createSessionContext(); - ElementContext elementContext = new ElementContext(nic.getVspId(), nic.getVersion().getId()); - - Element savedElement = - zusammenAdaptor.saveElement(context, elementContext, componentElement, "Create nic"); - nic.setId(savedElement.getSubElements().iterator().next() - .getSubElements().iterator().next().getElementId().getValue()); - } - - @Override - public void update(NicEntity nic) { - ZusammenElement nicElement = nicToZusammen(nic, Action.UPDATE); - - SessionContext context = createSessionContext(); - zusammenAdaptor - .saveElement(context, new ElementContext(nic.getVspId(), nic.getVersion().getId()), - nicElement, String.format("Update nic with id %s", nic.getId())); - } - - @Override - public NicEntity get(NicEntity nic) { - SessionContext context = createSessionContext(); - ElementToNicConvertor convertor = new ElementToNicConvertor(); - Optional<Element> element = zusammenAdaptor - .getElement(context, new ElementContext(nic.getVspId(), nic.getVersion().getId()), - nic.getId()); - - if (element.isPresent()) { - NicEntity entity = convertor.convert(element.get()); - entity.setVspId(nic.getVspId()); - entity.setVersion(nic.getVersion()); - entity.setComponentId(nic.getComponentId()); - - return entity; - } else { - return null; - } - } - - @Override - public void delete(NicEntity nic) { - ZusammenElement nicElement = buildElement(new Id(nic.getId()), Action.DELETE); - - SessionContext context = createSessionContext(); - zusammenAdaptor - .saveElement(context, new ElementContext(nic.getVspId(), nic.getVersion().getId()), - nicElement, String.format("Delete nic with id %s", nic.getId())); - } - - @Override - public NicEntity getQuestionnaireData(String vspId, Version version, String componentId, - String nicId) { - SessionContext context = createSessionContext(); - - return getQuestionnaire(context, new ElementContext(vspId, version.getId()), - new NicEntity(vspId, version, componentId, nicId)); - } - - private NicEntity getQuestionnaire(SessionContext context, ElementContext elementContext, - NicEntity nic) { - Optional<Element> questionnaireElement = zusammenAdaptor - .getElementByName(context, elementContext, new Id(nic.getId()), - ElementType.NicQuestionnaire.name()); - return questionnaireElement.map(new ElementToNicQuestionnaireConvertor()::convert) - .map(entity -> { - entity.setVspId(nic.getVspId()); - entity.setVersion(nic.getVersion()); - entity.setComponentId(nic.getComponentId()); - return entity; - }) - .orElse(null); - } - - @Override - public void updateQuestionnaireData(String vspId, Version version, String componentId, - String nicId, String questionnaireData) { - ZusammenElement questionnaireElement = - nicQuestionnaireToZusammen(questionnaireData, Action.UPDATE); - - ZusammenElement nicElement = buildElement(new Id(nicId), Action.IGNORE); - nicElement.setSubElements(Collections.singletonList(questionnaireElement)); - - SessionContext context = createSessionContext(); - zusammenAdaptor.saveElement(context, new ElementContext(vspId, version.getId()), nicElement, - "Update nic questionnaire"); - } - - @Override - public Collection<NicEntity> listByVsp(String vspId, Version version) { - SessionContext context = createSessionContext(); - - Collection<ComponentEntity> components = ComponentDaoZusammenImpl - .listComponents(zusammenAdaptor, context, vspId, version); - - ElementContext elementContext = new ElementContext(vspId, version.getId()); - return components.stream() - .map(component -> - listNics(context, elementContext, - new NicEntity(vspId, version, component.getId(), null)).stream() - .map(nic -> { - nic.setQuestionnaireData(getQuestionnaire(context, elementContext, nic).getQuestionnaireData()); - return nic; - }) - .collect(Collectors.toList())) - .flatMap(Collection::stream) - .collect(Collectors.toList()); - } - - @Override - public void deleteByComponentId(String vspId, Version version, String componentId) { - SessionContext context = createSessionContext(); - ElementContext elementContext = new ElementContext(vspId, version.getId()); - - Optional<Element> optionalElement = zusammenAdaptor.getElementByName(context, - elementContext, new Id(componentId), ElementType.Nics.name()); - - if (optionalElement.isPresent()) { - Element nicsElement = optionalElement.get(); - Collection<Element> nics = nicsElement.getSubElements(); - - nics.forEach(nic -> { - ZusammenElement nicZusammenElement = buildElement(nic.getElementId(), Action.DELETE); - zusammenAdaptor.saveElement(context, elementContext, nicZusammenElement, - "Delete nic with id " + nic.getElementId()); - }); - } - } - - @Override - public void deleteByVspId(String vspId, Version version) { - // deleteByVspId not implemented for NicDaoZusammenImpl - } - - private ZusammenElement nicToZusammen(NicEntity nic, Action action) { - ZusammenElement nicElement = buildNicElement(nic, action); - if (action == Action.CREATE) { - nicElement.setSubElements(Collections.singletonList( - nicQuestionnaireToZusammen(nic.getQuestionnaireData(), Action.CREATE))); - } - return nicElement; - } - - private ZusammenElement nicQuestionnaireToZusammen(String questionnaireData, - Action action) { - ZusammenElement questionnaireElement = - buildStructuralElement(ElementType.NicQuestionnaire, action); - questionnaireElement.setData(new ByteArrayInputStream(questionnaireData.getBytes())); - return questionnaireElement; - } - - private ZusammenElement buildNicElement(NicEntity nic, Action action) { - ZusammenElement nicElement = - buildElement(nic.getId() == null ? null : new Id(nic.getId()), action); - Info info = new Info(); - info.addProperty(ElementPropertyName.elementType.name(), ElementType.Nic); - info.addProperty(ElementPropertyName.compositionData.name(), nic.getCompositionData()); - nicElement.setInfo(info); - nicElement.setData(new ByteArrayInputStream(nic.getCompositionData().getBytes())); - return nicElement; - } + @Override + public void update(NicEntity nic) { + ZusammenElement nicElement = nicToZusammen(nic, Action.UPDATE); + SessionContext context = createSessionContext(); + zusammenAdaptor.saveElement(context, new ElementContext(nic.getVspId(), nic.getVersion().getId()), nicElement, + String.format("Update nic with id %s", nic.getId())); + } + + @Override + public NicEntity get(NicEntity nic) { + SessionContext context = createSessionContext(); + ElementToNicConvertor convertor = new ElementToNicConvertor(); + Optional<Element> element = zusammenAdaptor.getElement(context, new ElementContext(nic.getVspId(), nic.getVersion().getId()), nic.getId()); + if (element.isPresent()) { + NicEntity entity = convertor.convert(element.get()); + entity.setVspId(nic.getVspId()); + entity.setVersion(nic.getVersion()); + entity.setComponentId(nic.getComponentId()); + return entity; + } else { + return null; + } + } + + @Override + public void delete(NicEntity nic) { + ZusammenElement nicElement = buildElement(new Id(nic.getId()), Action.DELETE); + SessionContext context = createSessionContext(); + zusammenAdaptor.saveElement(context, new ElementContext(nic.getVspId(), nic.getVersion().getId()), nicElement, + String.format("Delete nic with id %s", nic.getId())); + } + + @Override + public NicEntity getQuestionnaireData(String vspId, Version version, String componentId, String nicId) { + SessionContext context = createSessionContext(); + return getQuestionnaire(context, new ElementContext(vspId, version.getId()), new NicEntity(vspId, version, componentId, nicId)); + } + + private NicEntity getQuestionnaire(SessionContext context, ElementContext elementContext, NicEntity nic) { + Optional<Element> questionnaireElement = zusammenAdaptor + .getElementByName(context, elementContext, new Id(nic.getId()), ElementType.NicQuestionnaire.name()); + return questionnaireElement.map(new ElementToNicQuestionnaireConvertor()::convert).map(entity -> { + entity.setVspId(nic.getVspId()); + entity.setVersion(nic.getVersion()); + entity.setComponentId(nic.getComponentId()); + return entity; + }).orElse(null); + } + + @Override + public void updateQuestionnaireData(String vspId, Version version, String componentId, String nicId, String questionnaireData) { + ZusammenElement questionnaireElement = nicQuestionnaireToZusammen(questionnaireData, Action.UPDATE); + ZusammenElement nicElement = buildElement(new Id(nicId), Action.IGNORE); + nicElement.setSubElements(Collections.singletonList(questionnaireElement)); + SessionContext context = createSessionContext(); + zusammenAdaptor.saveElement(context, new ElementContext(vspId, version.getId()), nicElement, "Update nic questionnaire"); + } + + @Override + public Collection<NicEntity> listByVsp(String vspId, Version version) { + SessionContext context = createSessionContext(); + Collection<ComponentEntity> components = ComponentDaoZusammenImpl.listComponents(zusammenAdaptor, context, vspId, version); + ElementContext elementContext = new ElementContext(vspId, version.getId()); + return components.stream() + .map(component -> listNics(context, elementContext, new NicEntity(vspId, version, component.getId(), null)).stream().map(nic -> { + nic.setQuestionnaireData(getQuestionnaire(context, elementContext, nic).getQuestionnaireData()); + return nic; + }).collect(Collectors.toList())).flatMap(Collection::stream).collect(Collectors.toList()); + } + + @Override + public void deleteByComponentId(String vspId, Version version, String componentId) { + SessionContext context = createSessionContext(); + ElementContext elementContext = new ElementContext(vspId, version.getId()); + Optional<Element> optionalElement = zusammenAdaptor.getElementByName(context, elementContext, new Id(componentId), ElementType.Nics.name()); + if (optionalElement.isPresent()) { + Element nicsElement = optionalElement.get(); + Collection<Element> nics = nicsElement.getSubElements(); + nics.forEach(nic -> { + ZusammenElement nicZusammenElement = buildElement(nic.getElementId(), Action.DELETE); + zusammenAdaptor.saveElement(context, elementContext, nicZusammenElement, "Delete nic with id " + nic.getElementId()); + }); + } + } + + @Override + public void deleteByVspId(String vspId, Version version) { + // deleteByVspId not implemented for NicDaoZusammenImpl + } + + private ZusammenElement nicToZusammen(NicEntity nic, Action action) { + ZusammenElement nicElement = buildNicElement(nic, action); + if (action == Action.CREATE) { + nicElement.setSubElements(Collections.singletonList(nicQuestionnaireToZusammen(nic.getQuestionnaireData(), Action.CREATE))); + } + return nicElement; + } + + private ZusammenElement nicQuestionnaireToZusammen(String questionnaireData, Action action) { + ZusammenElement questionnaireElement = buildStructuralElement(ElementType.NicQuestionnaire, action); + questionnaireElement.setData(new ByteArrayInputStream(questionnaireData.getBytes())); + return questionnaireElement; + } + + private ZusammenElement buildNicElement(NicEntity nic, Action action) { + ZusammenElement nicElement = buildElement(nic.getId() == null ? null : new Id(nic.getId()), action); + Info info = new Info(); + info.addProperty(ElementPropertyName.elementType.name(), ElementType.Nic); + info.addProperty(ElementPropertyName.compositionData.name(), nic.getCompositionData()); + nicElement.setInfo(info); + nicElement.setData(new ByteArrayInputStream(nic.getCompositionData().getBytes())); + return nicElement; + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/OrchestrationTemplateCandidateDaoZusammenImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/OrchestrationTemplateCandidateDaoZusammenImpl.java index 4c1e2e1ef2..fb26714375 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/OrchestrationTemplateCandidateDaoZusammenImpl.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/OrchestrationTemplateCandidateDaoZusammenImpl.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen; import static org.openecomp.core.zusammen.api.ZusammenUtil.buildStructuralElement; @@ -41,251 +40,173 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateCan import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.FilesDataStructure; import org.openecomp.sdc.versioning.dao.types.Version; -public class OrchestrationTemplateCandidateDaoZusammenImpl - implements OrchestrationTemplateCandidateDao { - - private static final Logger logger = - LoggerFactory.getLogger(OrchestrationTemplateCandidateDaoZusammenImpl.class); - - private final ZusammenAdaptor zusammenAdaptor; - - private static final String EMPTY_DATA = "{}"; - - public OrchestrationTemplateCandidateDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) { - this.zusammenAdaptor = zusammenAdaptor; - } +public class OrchestrationTemplateCandidateDaoZusammenImpl implements OrchestrationTemplateCandidateDao { - @Override - public void registerVersioning(String versionableEntityType) { - // registerVersioning not implemented for OrchestrationTemplateCandidateDaoZusammenImpl - } + private static final Logger logger = LoggerFactory.getLogger(OrchestrationTemplateCandidateDaoZusammenImpl.class); + private static final String EMPTY_DATA = "{}"; + private final ZusammenAdaptor zusammenAdaptor; - @Override - public Optional<OrchestrationTemplateCandidateData> get(String vspId, Version version) { - logger.info("Getting orchestration template for vsp id {}", vspId); - - SessionContext context = createSessionContext(); - ElementContext elementContext = new ElementContext(vspId, version.getId()); - - Optional<Element> candidateElement = - zusammenAdaptor.getElementByName(context, elementContext, null, - ElementType.OrchestrationTemplateCandidate.name()); - - if (!candidateElement.isPresent() || - VspZusammenUtil.hasEmptyData(candidateElement.get().getData()) || - candidateElement.get().getSubElements().isEmpty()) { - logger.info("Orchestration template for vsp id {} does not exist / has empty data", vspId); - return Optional.empty(); + public OrchestrationTemplateCandidateDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) { + this.zusammenAdaptor = zusammenAdaptor; } - OrchestrationTemplateCandidateData candidate = new OrchestrationTemplateCandidateData(); - candidate.setFilesDataStructure( - new String(FileUtils.toByteArray(candidateElement.get().getData()))); - - candidateElement.get().getSubElements().stream() - .map(element -> zusammenAdaptor - .getElement(context, elementContext, element.getElementId().toString())) - .forEach(element -> element.ifPresent( - candidateInfoElement -> populateCandidate(candidate, candidateInfoElement, true))); - - logger.info("Finished getting orchestration template for vsp id {}", vspId); - return candidate.getFileSuffix() == null ? Optional.empty() : Optional.of(candidate); - } - - @Override - public Optional<OrchestrationTemplateCandidateData> getInfo(String vspId, Version version) { - logger.info("Getting orchestration template info for vsp id {}", vspId); - - SessionContext context = createSessionContext(); - ElementContext elementContext = new ElementContext(vspId, version.getId()); - - Optional<ElementInfo> candidateElement = - zusammenAdaptor.getElementInfoByName(context, elementContext, null, - ElementType.OrchestrationTemplateCandidate.name()); - - if (!candidateElement.isPresent() || candidateElement.get().getSubElements().isEmpty()) { - logger.info("Orchestration template info for vsp id {} does not exist", vspId); - return Optional.empty(); + @Override + public void registerVersioning(String versionableEntityType) { + // registerVersioning not implemented for OrchestrationTemplateCandidateDaoZusammenImpl } - OrchestrationTemplateCandidateData candidate = new OrchestrationTemplateCandidateData(); - candidateElement.get().getSubElements().stream() - .map(elementInfo -> zusammenAdaptor - .getElement(context, elementContext, elementInfo.getId().toString())) - .forEach(element -> element.ifPresent( - candidateInfoElement -> populateCandidate(candidate, candidateInfoElement, false))); - logger.info("Finished getting orchestration template info for vsp id {}", vspId); - return candidate.getFileSuffix() == null ? Optional.empty() : Optional.of(candidate); - } - - private void populateCandidate(final OrchestrationTemplateCandidateData candidate, - final Element candidateInfoElement, - final boolean fullData) { - final String elementName = candidateInfoElement.getInfo().getName(); - if (ElementType.OrchestrationTemplateCandidateContent.name().equals(elementName)) { - if (fullData) { - candidate.setContentData(ByteBuffer.wrap(FileUtils.toByteArray(candidateInfoElement.getData()))); - } - candidate.setFileSuffix(candidateInfoElement.getInfo() - .getProperty(InfoPropertyName.FILE_SUFFIX.getVal())); - candidate.setFileName(candidateInfoElement.getInfo() - .getProperty(InfoPropertyName.FILE_NAME.getVal())); - } else if (ElementType.OrchestrationTemplateCandidateValidationData.name().equals(elementName)) { - candidate.setValidationData(new String(FileUtils.toByteArray(candidateInfoElement.getData()))); - } else if (ElementType.ORIGINAL_ONBOARDED_PACKAGE.name().equals(elementName)) { - candidate.setOriginalFileName(candidateInfoElement.getInfo() - .getProperty(InfoPropertyName.ORIGINAL_FILE_NAME.getVal())); - candidate.setOriginalFileSuffix(candidateInfoElement.getInfo() - .getProperty(InfoPropertyName.ORIGINAL_FILE_SUFFIX.getVal())); - if (fullData) { - candidate.setOriginalFileContentData( - ByteBuffer.wrap(FileUtils.toByteArray(candidateInfoElement.getData())) - ); - } + @Override + public Optional<OrchestrationTemplateCandidateData> get(String vspId, Version version) { + logger.info("Getting orchestration template for vsp id {}", vspId); + SessionContext context = createSessionContext(); + ElementContext elementContext = new ElementContext(vspId, version.getId()); + Optional<Element> candidateElement = zusammenAdaptor + .getElementByName(context, elementContext, null, ElementType.OrchestrationTemplateCandidate.name()); + if (!candidateElement.isPresent() || VspZusammenUtil.hasEmptyData(candidateElement.get().getData()) || candidateElement.get().getSubElements() + .isEmpty()) { + logger.info("Orchestration template for vsp id {} does not exist / has empty data", vspId); + return Optional.empty(); + } + OrchestrationTemplateCandidateData candidate = new OrchestrationTemplateCandidateData(); + candidate.setFilesDataStructure(new String(FileUtils.toByteArray(candidateElement.get().getData()))); + candidateElement.get().getSubElements().stream() + .map(element -> zusammenAdaptor.getElement(context, elementContext, element.getElementId().toString())) + .forEach(element -> element.ifPresent(candidateInfoElement -> populateCandidate(candidate, candidateInfoElement, true))); + logger.info("Finished getting orchestration template for vsp id {}", vspId); + return candidate.getFileSuffix() == null ? Optional.empty() : Optional.of(candidate); } - } - - @Override - public void delete(String vspId, Version version) { - ByteArrayInputStream emptyData = new ByteArrayInputStream(EMPTY_DATA.getBytes()); - - ZusammenElement candidateContentElement = - buildStructuralElement(ElementType.OrchestrationTemplateCandidateContent, Action.UPDATE); - candidateContentElement.setData(emptyData); - - ZusammenElement validationData = buildStructuralElement(ElementType - .OrchestrationTemplateCandidateValidationData, Action.UPDATE); - validationData.setData(emptyData); - - ZusammenElement candidateElement = - buildStructuralElement(ElementType.OrchestrationTemplateCandidate, Action.UPDATE); - candidateElement.setData(emptyData); - candidateElement.addSubElement(candidateContentElement); - candidateElement.addSubElement(validationData); - SessionContext context = createSessionContext(); - ElementContext elementContext = new ElementContext(vspId, version.getId()); - zusammenAdaptor.saveElement(context, elementContext, candidateElement, - "Delete Orchestration Template Candidate Elements's content"); - } - - @Override - public void update(final String vspId, final Version version, - final OrchestrationTemplateCandidateData candidateData) { - logger.info("Uploading candidate data entity for vsp id {}", vspId); - final ZusammenElement candidateElement = - buildStructuralElement(ElementType.OrchestrationTemplateCandidate, Action.UPDATE); - candidateElement - .setData(new ByteArrayInputStream(candidateData.getFilesDataStructure().getBytes())); - - final ZusammenElement candidateContentElement = - buildStructuralElement(ElementType.OrchestrationTemplateCandidateContent, Action.UPDATE); - candidateContentElement - .setData(new ByteArrayInputStream(candidateData.getContentData().array())); - candidateContentElement.getInfo() - .addProperty(InfoPropertyName.FILE_SUFFIX.getVal(), candidateData.getFileSuffix()); - candidateContentElement.getInfo() - .addProperty(InfoPropertyName.FILE_NAME.getVal(), candidateData.getFileName()); - - if (OnboardingTypesEnum.CSAR.toString().equalsIgnoreCase(candidateData.getFileSuffix())) { - final ZusammenElement originalPackageElement = - buildStructuralElement(ElementType.ORIGINAL_ONBOARDED_PACKAGE, Action.UPDATE); - originalPackageElement.getInfo() - .addProperty(InfoPropertyName.ORIGINAL_FILE_NAME.getVal(), candidateData.getOriginalFileName()); - originalPackageElement.getInfo() - .addProperty(InfoPropertyName.ORIGINAL_FILE_SUFFIX.getVal(), candidateData.getOriginalFileSuffix()); - originalPackageElement.setData(new ByteArrayInputStream(candidateData.getOriginalFileContentData().array())); - candidateElement.addSubElement(originalPackageElement); + @Override + public Optional<OrchestrationTemplateCandidateData> getInfo(String vspId, Version version) { + logger.info("Getting orchestration template info for vsp id {}", vspId); + SessionContext context = createSessionContext(); + ElementContext elementContext = new ElementContext(vspId, version.getId()); + Optional<ElementInfo> candidateElement = zusammenAdaptor + .getElementInfoByName(context, elementContext, null, ElementType.OrchestrationTemplateCandidate.name()); + if (!candidateElement.isPresent() || candidateElement.get().getSubElements().isEmpty()) { + logger.info("Orchestration template info for vsp id {} does not exist", vspId); + return Optional.empty(); + } + OrchestrationTemplateCandidateData candidate = new OrchestrationTemplateCandidateData(); + candidateElement.get().getSubElements().stream() + .map(elementInfo -> zusammenAdaptor.getElement(context, elementContext, elementInfo.getId().toString())) + .forEach(element -> element.ifPresent(candidateInfoElement -> populateCandidate(candidate, candidateInfoElement, false))); + logger.info("Finished getting orchestration template info for vsp id {}", vspId); + return candidate.getFileSuffix() == null ? Optional.empty() : Optional.of(candidate); } - final ZusammenElement validationData = buildStructuralElement(ElementType - .OrchestrationTemplateCandidateValidationData, Action.UPDATE); - if (candidateData.getValidationData() != null) { - validationData - .setData(new ByteArrayInputStream(candidateData.getValidationData().getBytes())); - } - candidateElement.addSubElement(validationData); - candidateElement.addSubElement(candidateContentElement); - SessionContext context = createSessionContext(); - ElementContext elementContext = new ElementContext(vspId, version.getId()); - zusammenAdaptor.saveElement(context, elementContext, candidateElement, - "Update Orchestration Template Candidate"); - logger.info("Finished uploading candidate data entity for vsp id {}", vspId); - } - - @Override - public void updateValidationData(String vspId, Version version, - ValidationStructureList validationData) { - logger - .info("Updating validation data of orchestration template candidate for VSP id {} ", vspId); - - ZusammenElement validationDataElement = buildStructuralElement(ElementType - .OrchestrationTemplateCandidateValidationData, Action.UPDATE); - validationDataElement.setData(validationData == null ? new ByteArrayInputStream(EMPTY_DATA - .getBytes()) : new ByteArrayInputStream(JsonUtil.object2Json(validationData).getBytes())); - - ZusammenElement candidateElement = - buildStructuralElement(ElementType.OrchestrationTemplateCandidate, Action.IGNORE); - candidateElement.addSubElement(validationDataElement); - - SessionContext context = createSessionContext(); - ElementContext elementContext = new ElementContext(vspId, version.getId()); - zusammenAdaptor.saveElement(context, elementContext, candidateElement, - "Update Orchestration Template Candidate validation data"); - logger - .info("Finished updating validation data of orchestration template candidate for VSP id {}", - vspId); - } - - @Override - public void updateStructure(String vspId, Version version, FilesDataStructure fileDataStructure) { - logger.info("Updating orchestration template for VSP id {}", vspId); - - ZusammenElement candidateElement = - buildStructuralElement(ElementType.OrchestrationTemplateCandidate, Action.UPDATE); - candidateElement - .setData(new ByteArrayInputStream(JsonUtil.object2Json(fileDataStructure).getBytes())); - SessionContext context = createSessionContext(); - ElementContext elementContext = new ElementContext(vspId, version.getId()); - zusammenAdaptor.saveElement(context, elementContext, candidateElement, - "Update Orchestration Template Candidate structure"); - logger.info("Finished uploading candidate data entity for vsp id {}", vspId); - } - - - @Override - public Optional<String> getStructure(String vspId, Version version) { - logger.info("Getting orchestration template candidate structure for vsp id {}", vspId); - - SessionContext context = createSessionContext(); - ElementContext elementContext = new ElementContext(vspId, version.getId()); + private void populateCandidate(final OrchestrationTemplateCandidateData candidate, final Element candidateInfoElement, final boolean fullData) { + final String elementName = candidateInfoElement.getInfo().getName(); + if (ElementType.OrchestrationTemplateCandidateContent.name().equals(elementName)) { + if (fullData) { + candidate.setContentData(ByteBuffer.wrap(FileUtils.toByteArray(candidateInfoElement.getData()))); + } + candidate.setFileSuffix(candidateInfoElement.getInfo().getProperty(InfoPropertyName.FILE_SUFFIX.getVal())); + candidate.setFileName(candidateInfoElement.getInfo().getProperty(InfoPropertyName.FILE_NAME.getVal())); + } else if (ElementType.OrchestrationTemplateCandidateValidationData.name().equals(elementName)) { + candidate.setValidationData(new String(FileUtils.toByteArray(candidateInfoElement.getData()))); + } else if (ElementType.ORIGINAL_ONBOARDED_PACKAGE.name().equals(elementName)) { + candidate.setOriginalFileName(candidateInfoElement.getInfo().getProperty(InfoPropertyName.ORIGINAL_FILE_NAME.getVal())); + candidate.setOriginalFileSuffix(candidateInfoElement.getInfo().getProperty(InfoPropertyName.ORIGINAL_FILE_SUFFIX.getVal())); + if (fullData) { + candidate.setOriginalFileContentData(ByteBuffer.wrap(FileUtils.toByteArray(candidateInfoElement.getData()))); + } + } + } - Optional<Element> element = zusammenAdaptor.getElementByName(context, elementContext, null, - ElementType.OrchestrationTemplateCandidate.name()); + @Override + public void delete(String vspId, Version version) { + ByteArrayInputStream emptyData = new ByteArrayInputStream(EMPTY_DATA.getBytes()); + ZusammenElement candidateContentElement = buildStructuralElement(ElementType.OrchestrationTemplateCandidateContent, Action.UPDATE); + candidateContentElement.setData(emptyData); + ZusammenElement validationData = buildStructuralElement(ElementType.OrchestrationTemplateCandidateValidationData, Action.UPDATE); + validationData.setData(emptyData); + ZusammenElement candidateElement = buildStructuralElement(ElementType.OrchestrationTemplateCandidate, Action.UPDATE); + candidateElement.setData(emptyData); + candidateElement.addSubElement(candidateContentElement); + candidateElement.addSubElement(validationData); + SessionContext context = createSessionContext(); + ElementContext elementContext = new ElementContext(vspId, version.getId()); + zusammenAdaptor.saveElement(context, elementContext, candidateElement, "Delete Orchestration Template Candidate Elements's content"); + } - if (element.isPresent() && !VspZusammenUtil.hasEmptyData(element.get().getData())) { - return Optional.of(new String(FileUtils.toByteArray(element.get().getData()))); + @Override + public void update(final String vspId, final Version version, final OrchestrationTemplateCandidateData candidateData) { + logger.info("Uploading candidate data entity for vsp id {}", vspId); + final ZusammenElement candidateElement = buildStructuralElement(ElementType.OrchestrationTemplateCandidate, Action.UPDATE); + candidateElement.setData(new ByteArrayInputStream(candidateData.getFilesDataStructure().getBytes())); + final ZusammenElement candidateContentElement = buildStructuralElement(ElementType.OrchestrationTemplateCandidateContent, Action.UPDATE); + candidateContentElement.setData(new ByteArrayInputStream(candidateData.getContentData().array())); + candidateContentElement.getInfo().addProperty(InfoPropertyName.FILE_SUFFIX.getVal(), candidateData.getFileSuffix()); + candidateContentElement.getInfo().addProperty(InfoPropertyName.FILE_NAME.getVal(), candidateData.getFileName()); + if (OnboardingTypesEnum.CSAR.toString().equalsIgnoreCase(candidateData.getFileSuffix())) { + final ZusammenElement originalPackageElement = buildStructuralElement(ElementType.ORIGINAL_ONBOARDED_PACKAGE, Action.UPDATE); + originalPackageElement.getInfo().addProperty(InfoPropertyName.ORIGINAL_FILE_NAME.getVal(), candidateData.getOriginalFileName()); + originalPackageElement.getInfo().addProperty(InfoPropertyName.ORIGINAL_FILE_SUFFIX.getVal(), candidateData.getOriginalFileSuffix()); + originalPackageElement.setData(new ByteArrayInputStream(candidateData.getOriginalFileContentData().array())); + candidateElement.addSubElement(originalPackageElement); + } + final ZusammenElement validationData = buildStructuralElement(ElementType.OrchestrationTemplateCandidateValidationData, Action.UPDATE); + if (candidateData.getValidationData() != null) { + validationData.setData(new ByteArrayInputStream(candidateData.getValidationData().getBytes())); + } + candidateElement.addSubElement(validationData); + candidateElement.addSubElement(candidateContentElement); + SessionContext context = createSessionContext(); + ElementContext elementContext = new ElementContext(vspId, version.getId()); + zusammenAdaptor.saveElement(context, elementContext, candidateElement, "Update Orchestration Template Candidate"); + logger.info("Finished uploading candidate data entity for vsp id {}", vspId); } - logger.info("Finished getting orchestration template candidate structure for vsp id {}", vspId); + @Override + public void updateValidationData(String vspId, Version version, ValidationStructureList validationData) { + logger.info("Updating validation data of orchestration template candidate for VSP id {} ", vspId); + ZusammenElement validationDataElement = buildStructuralElement(ElementType.OrchestrationTemplateCandidateValidationData, Action.UPDATE); + validationDataElement.setData(validationData == null ? new ByteArrayInputStream(EMPTY_DATA.getBytes()) + : new ByteArrayInputStream(JsonUtil.object2Json(validationData).getBytes())); + ZusammenElement candidateElement = buildStructuralElement(ElementType.OrchestrationTemplateCandidate, Action.IGNORE); + candidateElement.addSubElement(validationDataElement); + SessionContext context = createSessionContext(); + ElementContext elementContext = new ElementContext(vspId, version.getId()); + zusammenAdaptor.saveElement(context, elementContext, candidateElement, "Update Orchestration Template Candidate validation data"); + logger.info("Finished updating validation data of orchestration template candidate for VSP id {}", vspId); + } - return Optional.empty(); - } + @Override + public void updateStructure(String vspId, Version version, FilesDataStructure fileDataStructure) { + logger.info("Updating orchestration template for VSP id {}", vspId); + ZusammenElement candidateElement = buildStructuralElement(ElementType.OrchestrationTemplateCandidate, Action.UPDATE); + candidateElement.setData(new ByteArrayInputStream(JsonUtil.object2Json(fileDataStructure).getBytes())); + SessionContext context = createSessionContext(); + ElementContext elementContext = new ElementContext(vspId, version.getId()); + zusammenAdaptor.saveElement(context, elementContext, candidateElement, "Update Orchestration Template Candidate structure"); + logger.info("Finished uploading candidate data entity for vsp id {}", vspId); + } - public enum InfoPropertyName { - FILE_SUFFIX("fileSuffix"), - FILE_NAME("fileName"), - ORIGINAL_FILE_NAME("originalFilename"), - ORIGINAL_FILE_SUFFIX("originalFileSuffix"); + @Override + public Optional<String> getStructure(String vspId, Version version) { + logger.info("Getting orchestration template candidate structure for vsp id {}", vspId); + SessionContext context = createSessionContext(); + ElementContext elementContext = new ElementContext(vspId, version.getId()); + Optional<Element> element = zusammenAdaptor + .getElementByName(context, elementContext, null, ElementType.OrchestrationTemplateCandidate.name()); + if (element.isPresent() && !VspZusammenUtil.hasEmptyData(element.get().getData())) { + return Optional.of(new String(FileUtils.toByteArray(element.get().getData()))); + } + logger.info("Finished getting orchestration template candidate structure for vsp id {}", vspId); + return Optional.empty(); + } - private final String val; + public enum InfoPropertyName { + FILE_SUFFIX("fileSuffix"), FILE_NAME("fileName"), ORIGINAL_FILE_NAME("originalFilename"), ORIGINAL_FILE_SUFFIX("originalFileSuffix"); + private final String val; - InfoPropertyName(String val) { - this.val = val; - } + InfoPropertyName(String val) { + this.val = val; + } - private String getVal() { - return val; + private String getVal() { + return val; + } } - } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/OrchestrationTemplateDaoZusammenImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/OrchestrationTemplateDaoZusammenImpl.java index bc186e7629..dd78a94eb5 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/OrchestrationTemplateDaoZusammenImpl.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/OrchestrationTemplateDaoZusammenImpl.java @@ -13,9 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen; +import static org.openecomp.core.zusammen.api.ZusammenUtil.buildStructuralElement; +import static org.openecomp.core.zusammen.api.ZusammenUtil.createSessionContext; + import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element; import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo; import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement; @@ -23,6 +25,10 @@ import com.amdocs.zusammen.datatypes.SessionContext; import com.amdocs.zusammen.datatypes.item.Action; import com.amdocs.zusammen.datatypes.item.ElementContext; import com.amdocs.zusammen.utils.fileutils.FileUtils; +import java.io.ByteArrayInputStream; +import java.nio.ByteBuffer; +import java.util.Collection; +import java.util.Optional; import org.openecomp.core.zusammen.api.ZusammenAdaptor; import org.openecomp.sdc.datatypes.model.ElementType; import org.openecomp.sdc.logging.api.Logger; @@ -31,205 +37,142 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDao; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateEntity; import org.openecomp.sdc.versioning.dao.types.Version; -import java.io.ByteArrayInputStream; -import java.nio.ByteBuffer; -import java.util.Collection; -import java.util.Optional; - -import static org.openecomp.core.zusammen.api.ZusammenUtil.buildStructuralElement; -import static org.openecomp.core.zusammen.api.ZusammenUtil.createSessionContext; - public class OrchestrationTemplateDaoZusammenImpl implements OrchestrationTemplateDao { - private static final Logger LOGGER = LoggerFactory.getLogger( - OrchestrationTemplateDaoZusammenImpl.class); - private ZusammenAdaptor zusammenAdaptor; - - public OrchestrationTemplateDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) { - this.zusammenAdaptor = zusammenAdaptor; - } - - @Override - public void registerVersioning(String versionableEntityType) { - // registerVersioning not implemented for OrchestrationTemplateDaoZusammenImpl - } - - @Override - public OrchestrationTemplateEntity getInfo(String vspId, Version version) { - SessionContext context = createSessionContext(); - ElementContext elementContext = new ElementContext(vspId, version.getId()); - - Optional<ElementInfo> vspModel = zusammenAdaptor - .getElementInfoByName(context, elementContext, null, ElementType.VspModel.name()); - if (!vspModel.isPresent()) { - return null; - } - - Optional<ElementInfo> elementInfo = zusammenAdaptor - .getElementInfoByName(context, elementContext, vspModel.get().getId(), - ElementType.OrchestrationTemplate.name()); - if (!elementInfo.isPresent()) { - return null; - } - - Optional<Element> element = - zusammenAdaptor.getElementByName(context, elementContext, elementInfo.get().getId(), - ElementType.OrchestrationTemplateValidationData.name()); + private static final Logger LOGGER = LoggerFactory.getLogger(OrchestrationTemplateDaoZusammenImpl.class); + private ZusammenAdaptor zusammenAdaptor; - OrchestrationTemplateEntity orchestrationTemplate = new OrchestrationTemplateEntity(); - if (!element.isPresent()) { - return orchestrationTemplate; + public OrchestrationTemplateDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) { + this.zusammenAdaptor = zusammenAdaptor; } - orchestrationTemplate - .setFileSuffix(element.get().getInfo().getProperty(InfoPropertyName.FILE_SUFFIX.getVal())); - orchestrationTemplate - .setFileName(element.get().getInfo().getProperty(InfoPropertyName.FILE_NAME.getVal())); - if (!VspZusammenUtil.hasEmptyData(element.get().getData())) { - orchestrationTemplate - .setValidationData(new String(FileUtils.toByteArray(element.get().getData()))); - } - return orchestrationTemplate; - } - - @Override - public OrchestrationTemplateEntity get(String vspId, Version version) { - SessionContext context = createSessionContext(); - ElementContext elementContext = new ElementContext(vspId, version.getId()); - - OrchestrationTemplateEntity orchestrationTemplate = new OrchestrationTemplateEntity(); - Optional<ElementInfo> vspModel = zusammenAdaptor - .getElementInfoByName(context, elementContext, null, ElementType.VspModel.name()); - if (!vspModel.isPresent()) { - return orchestrationTemplate; + @Override + public void registerVersioning(String versionableEntityType) { + // registerVersioning not implemented for OrchestrationTemplateDaoZusammenImpl } - Optional<Element> orchestrationTemplateElementOpt = zusammenAdaptor - .getElementByName(context, elementContext, vspModel.get().getId(), - ElementType.OrchestrationTemplate.name()); - - if (! orchestrationTemplateElementOpt.isPresent()) { - return orchestrationTemplate; - } else { - Element orchestrationTemplateElement = orchestrationTemplateElementOpt.get(); - - if (VspZusammenUtil.hasEmptyData(orchestrationTemplateElement.getData())) { - return orchestrationTemplate; - } - - orchestrationTemplate.setContentData( - ByteBuffer.wrap(FileUtils.toByteArray(orchestrationTemplateElement.getData()))); - - Collection<Element> subElements = orchestrationTemplateElement.getSubElements(); - if (subElements.isEmpty()) { + @Override + public OrchestrationTemplateEntity getInfo(String vspId, Version version) { + SessionContext context = createSessionContext(); + ElementContext elementContext = new ElementContext(vspId, version.getId()); + Optional<ElementInfo> vspModel = zusammenAdaptor.getElementInfoByName(context, elementContext, null, ElementType.VspModel.name()); + if (!vspModel.isPresent()) { + return null; + } + Optional<ElementInfo> elementInfo = zusammenAdaptor + .getElementInfoByName(context, elementContext, vspModel.get().getId(), ElementType.OrchestrationTemplate.name()); + if (!elementInfo.isPresent()) { + return null; + } + Optional<Element> element = zusammenAdaptor + .getElementByName(context, elementContext, elementInfo.get().getId(), ElementType.OrchestrationTemplateValidationData.name()); + OrchestrationTemplateEntity orchestrationTemplate = new OrchestrationTemplateEntity(); + if (!element.isPresent()) { + return orchestrationTemplate; + } + orchestrationTemplate.setFileSuffix(element.get().getInfo().getProperty(InfoPropertyName.FILE_SUFFIX.getVal())); + orchestrationTemplate.setFileName(element.get().getInfo().getProperty(InfoPropertyName.FILE_NAME.getVal())); + if (!VspZusammenUtil.hasEmptyData(element.get().getData())) { + orchestrationTemplate.setValidationData(new String(FileUtils.toByteArray(element.get().getData()))); + } return orchestrationTemplate; - } - - for (Element element : subElements) { - Optional<Element> subElementOpt = zusammenAdaptor.getElement(context, - elementContext, element.getElementId().toString()); - - subElementOpt.ifPresent(subElement -> { - if (subElement.getInfo().getName().equals(ElementType - .OrchestrationTemplateValidationData.name())) { - - orchestrationTemplate.setFileSuffix(subElement.getInfo() - .getProperty(InfoPropertyName.FILE_SUFFIX.getVal())); - orchestrationTemplate.setFileName(subElement.getInfo() - .getProperty(InfoPropertyName.FILE_NAME.getVal())); + } - if (!VspZusammenUtil.hasEmptyData(subElement.getData())) { - orchestrationTemplate.setValidationData( - new String(FileUtils.toByteArray(subElement.getData()))); + @Override + public OrchestrationTemplateEntity get(String vspId, Version version) { + SessionContext context = createSessionContext(); + ElementContext elementContext = new ElementContext(vspId, version.getId()); + OrchestrationTemplateEntity orchestrationTemplate = new OrchestrationTemplateEntity(); + Optional<ElementInfo> vspModel = zusammenAdaptor.getElementInfoByName(context, elementContext, null, ElementType.VspModel.name()); + if (!vspModel.isPresent()) { + return orchestrationTemplate; + } + Optional<Element> orchestrationTemplateElementOpt = zusammenAdaptor + .getElementByName(context, elementContext, vspModel.get().getId(), ElementType.OrchestrationTemplate.name()); + if (!orchestrationTemplateElementOpt.isPresent()) { + return orchestrationTemplate; + } else { + Element orchestrationTemplateElement = orchestrationTemplateElementOpt.get(); + if (VspZusammenUtil.hasEmptyData(orchestrationTemplateElement.getData())) { + return orchestrationTemplate; } - } else if (subElement.getInfo().getName().equals(ElementType - .OrchestrationTemplateStructure.name())) { - orchestrationTemplate.setFilesDataStructure(new String(FileUtils.toByteArray(subElement - .getData()))); - } - }); - } + orchestrationTemplate.setContentData(ByteBuffer.wrap(FileUtils.toByteArray(orchestrationTemplateElement.getData()))); + Collection<Element> subElements = orchestrationTemplateElement.getSubElements(); + if (subElements.isEmpty()) { + return orchestrationTemplate; + } + for (Element element : subElements) { + Optional<Element> subElementOpt = zusammenAdaptor.getElement(context, elementContext, element.getElementId().toString()); + subElementOpt.ifPresent(subElement -> { + if (subElement.getInfo().getName().equals(ElementType.OrchestrationTemplateValidationData.name())) { + orchestrationTemplate.setFileSuffix(subElement.getInfo().getProperty(InfoPropertyName.FILE_SUFFIX.getVal())); + orchestrationTemplate.setFileName(subElement.getInfo().getProperty(InfoPropertyName.FILE_NAME.getVal())); + if (!VspZusammenUtil.hasEmptyData(subElement.getData())) { + orchestrationTemplate.setValidationData(new String(FileUtils.toByteArray(subElement.getData()))); + } + } else if (subElement.getInfo().getName().equals(ElementType.OrchestrationTemplateStructure.name())) { + orchestrationTemplate.setFilesDataStructure(new String(FileUtils.toByteArray(subElement.getData()))); + } + }); + } + } + return orchestrationTemplate; } - return orchestrationTemplate; - } - - @Override - public void update(String vspId, Version version, - OrchestrationTemplateEntity orchestrationTemplate) { - SessionContext context = createSessionContext(); - ElementContext elementContext = new ElementContext(vspId, version.getId()); - - ZusammenElement validationData = - buildStructuralElement(ElementType.OrchestrationTemplateValidationData, Action.UPDATE); - validationData - .setData(new ByteArrayInputStream(orchestrationTemplate.getValidationData().getBytes())); - validationData.getInfo() - .addProperty(InfoPropertyName.FILE_SUFFIX.getVal(), orchestrationTemplate.getFileSuffix()); - validationData.getInfo() - .addProperty(InfoPropertyName.FILE_NAME.getVal(), orchestrationTemplate.getFileName()); - ZusammenElement orchestrationTemplateStructure = buildStructuralElement(ElementType - .OrchestrationTemplateStructure, Action.UPDATE); - orchestrationTemplateStructure - .setData(new ByteArrayInputStream(orchestrationTemplate.getFilesDataStructure() - .getBytes())); - ZusammenElement orchestrationTemplateElement = - buildStructuralElement(ElementType.OrchestrationTemplate, Action.UPDATE); - orchestrationTemplateElement - .setData(new ByteArrayInputStream(orchestrationTemplate.getContentData().array())); - orchestrationTemplateElement.addSubElement(validationData); - orchestrationTemplateElement.addSubElement(orchestrationTemplateStructure); - ZusammenElement vspModel = buildStructuralElement(ElementType.VspModel, Action.IGNORE); - vspModel.addSubElement(orchestrationTemplateElement); - - zusammenAdaptor.saveElement(context, elementContext, vspModel, "Update Orchestration Template"); - } - @Override - public Optional<String> getOrchestrationTemplateStructure(String vspId, Version version) { - LOGGER.info("Getting orchestration template structure for VendorSoftwareProduct id" + - " " + "-> " + vspId); - - SessionContext context = createSessionContext(); - ElementContext elementContext = new ElementContext(vspId, version.getId()); - - Optional<ElementInfo> vspModel = zusammenAdaptor.getElementInfoByName(context, elementContext, - null, ElementType.VspModel.name()); - if (!vspModel.isPresent()) { - return Optional.empty(); - } - Optional<Element> orchestrationTemplateElement = zusammenAdaptor.getElementByName(context, - elementContext, vspModel.get().getId(), ElementType.OrchestrationTemplate.name()); - if (!orchestrationTemplateElement.isPresent()) { - return Optional.empty(); + @Override + public void update(String vspId, Version version, OrchestrationTemplateEntity orchestrationTemplate) { + SessionContext context = createSessionContext(); + ElementContext elementContext = new ElementContext(vspId, version.getId()); + ZusammenElement validationData = buildStructuralElement(ElementType.OrchestrationTemplateValidationData, Action.UPDATE); + validationData.setData(new ByteArrayInputStream(orchestrationTemplate.getValidationData().getBytes())); + validationData.getInfo().addProperty(InfoPropertyName.FILE_SUFFIX.getVal(), orchestrationTemplate.getFileSuffix()); + validationData.getInfo().addProperty(InfoPropertyName.FILE_NAME.getVal(), orchestrationTemplate.getFileName()); + ZusammenElement orchestrationTemplateStructure = buildStructuralElement(ElementType.OrchestrationTemplateStructure, Action.UPDATE); + orchestrationTemplateStructure.setData(new ByteArrayInputStream(orchestrationTemplate.getFilesDataStructure().getBytes())); + ZusammenElement orchestrationTemplateElement = buildStructuralElement(ElementType.OrchestrationTemplate, Action.UPDATE); + orchestrationTemplateElement.setData(new ByteArrayInputStream(orchestrationTemplate.getContentData().array())); + orchestrationTemplateElement.addSubElement(validationData); + orchestrationTemplateElement.addSubElement(orchestrationTemplateStructure); + ZusammenElement vspModel = buildStructuralElement(ElementType.VspModel, Action.IGNORE); + vspModel.addSubElement(orchestrationTemplateElement); + zusammenAdaptor.saveElement(context, elementContext, vspModel, "Update Orchestration Template"); } - Optional<Element> orchestrationTemplateStructureElement = zusammenAdaptor - .getElementByName(context, elementContext, - orchestrationTemplateElement.get().getElementId(), - ElementType.OrchestrationTemplateStructure.name()); - if (orchestrationTemplateStructureElement.isPresent() && - !VspZusammenUtil.hasEmptyData(orchestrationTemplateStructureElement.get().getData())) { - return Optional.of(new String( - FileUtils.toByteArray(orchestrationTemplateStructureElement.get().getData()))); + @Override + public Optional<String> getOrchestrationTemplateStructure(String vspId, Version version) { + LOGGER.info("Getting orchestration template structure for VendorSoftwareProduct id" + " " + "-> " + vspId); + SessionContext context = createSessionContext(); + ElementContext elementContext = new ElementContext(vspId, version.getId()); + Optional<ElementInfo> vspModel = zusammenAdaptor.getElementInfoByName(context, elementContext, null, ElementType.VspModel.name()); + if (!vspModel.isPresent()) { + return Optional.empty(); + } + Optional<Element> orchestrationTemplateElement = zusammenAdaptor + .getElementByName(context, elementContext, vspModel.get().getId(), ElementType.OrchestrationTemplate.name()); + if (!orchestrationTemplateElement.isPresent()) { + return Optional.empty(); + } + Optional<Element> orchestrationTemplateStructureElement = zusammenAdaptor + .getElementByName(context, elementContext, orchestrationTemplateElement.get().getElementId(), + ElementType.OrchestrationTemplateStructure.name()); + if (orchestrationTemplateStructureElement.isPresent() && !VspZusammenUtil + .hasEmptyData(orchestrationTemplateStructureElement.get().getData())) { + return Optional.of(new String(FileUtils.toByteArray(orchestrationTemplateStructureElement.get().getData()))); + } + LOGGER.info("Finished getting orchestration template structure for VendorSoftwareProduct " + "id -> " + vspId); + return Optional.empty(); } - LOGGER.info("Finished getting orchestration template structure for VendorSoftwareProduct " + - "id -> " + vspId); - return Optional.empty(); - } + private enum InfoPropertyName { + FILE_SUFFIX("fileSuffix"), FILE_NAME("fileName"); + private String val; - private enum InfoPropertyName { - FILE_SUFFIX("fileSuffix"), - FILE_NAME("fileName"); - - private String val; - - InfoPropertyName(String val){ - this.val=val; - } + InfoPropertyName(String val) { + this.val = val; + } - public String getVal() { - return val; + public String getVal() { + return val; + } } - } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ProcessDaoZusammenImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ProcessDaoZusammenImpl.java index 76e14d8606..28bf1d8ddb 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ProcessDaoZusammenImpl.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ProcessDaoZusammenImpl.java @@ -7,9 +7,9 @@ * 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. @@ -17,9 +17,16 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen; +import static org.openecomp.core.zusammen.api.ZusammenUtil.buildElement; +import static org.openecomp.core.zusammen.api.ZusammenUtil.buildStructuralElement; +import static org.openecomp.core.zusammen.api.ZusammenUtil.createSessionContext; +import static org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToProcessConvertor.ARTIFACT_NAME; +import static org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToProcessConvertor.DESCRIPTION; +import static org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToProcessConvertor.NAME; +import static org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToProcessConvertor.PROCESS_TYPE; + import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element; import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo; import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement; @@ -28,6 +35,12 @@ import com.amdocs.zusammen.datatypes.SessionContext; import com.amdocs.zusammen.datatypes.item.Action; import com.amdocs.zusammen.datatypes.item.ElementContext; import com.amdocs.zusammen.datatypes.item.Info; +import java.io.ByteArrayInputStream; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Objects; +import java.util.Optional; +import java.util.stream.Collectors; import org.openecomp.core.zusammen.api.ZusammenAdaptor; import org.openecomp.sdc.datatypes.model.ElementType; import org.openecomp.sdc.vendorsoftwareproduct.dao.ProcessDao; @@ -36,238 +49,176 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity; import org.openecomp.sdc.versioning.dao.types.Version; import org.openecomp.types.ElementPropertyName; -import java.io.ByteArrayInputStream; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Objects; -import java.util.Optional; -import java.util.stream.Collectors; - -import static org.openecomp.core.zusammen.api.ZusammenUtil.*; -import static org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToProcessConvertor.*; - /** * @author Avrahamg. * @since March 23, 2017 */ public class ProcessDaoZusammenImpl implements ProcessDao { - private ZusammenAdaptor zusammenAdaptor; - - public ProcessDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) { - this.zusammenAdaptor = zusammenAdaptor; - } - - @Override - public void registerVersioning(String versionableEntityType) { - // registerVersioning not implemented for ProcessDaoZusammenImpl - } + private ZusammenAdaptor zusammenAdaptor; - @Override - public void create(ProcessEntity processEntity) { - ZusammenElement processElement = buildProcessElement(processEntity, Action.CREATE); - - ZusammenElement processesElement = - buildStructuralElement(ElementType.Processes, Action.IGNORE); - ZusammenElement aggregatedElement = VspZusammenUtil.aggregateElements(processesElement, - processElement); - ZusammenElement componentElement; - if (processEntity.getComponentId() != null) { - componentElement = buildElement(new Id(processEntity.getComponentId()), Action.IGNORE); - aggregatedElement = - VspZusammenUtil.aggregateElements(componentElement, aggregatedElement); + public ProcessDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) { + this.zusammenAdaptor = zusammenAdaptor; } - SessionContext context = createSessionContext(); - ElementContext elementContext = - new ElementContext(processEntity.getVspId(), processEntity.getVersion().getId()); - - Element savedElement = - zusammenAdaptor.saveElement(context, elementContext, aggregatedElement, "Create process"); - processEntity - .setId(processEntity.getComponentId() == null - ? savedElement.getSubElements().iterator().next().getElementId().getValue() - : savedElement.getSubElements().iterator().next().getSubElements() - .iterator().next().getElementId().getValue()); - } - - @Override - public ProcessEntity get(ProcessEntity processEntity) { - SessionContext context = createSessionContext(); - ElementContext elementContext = - new ElementContext(processEntity.getVspId(), processEntity.getVersion().getId()); - - return zusammenAdaptor.getElementInfo(context, elementContext, new Id(processEntity.getId())) - .map(elementInfo -> convertToProcessEntity(elementInfo, new ElementToProcessConvertor(), - processEntity)) - .orElse(null); - } - - @Override - public void update(ProcessEntity processEntity) { - ProcessEntity retrieved = getArtifact(processEntity); - if (retrieved != null && retrieved.getArtifact() != null) { - processEntity.setArtifactName(retrieved.getArtifactName()); - processEntity.setArtifact(retrieved.getArtifact()); + @Override + public void registerVersioning(String versionableEntityType) { + // registerVersioning not implemented for ProcessDaoZusammenImpl } - update(processEntity, "Update process"); - } - - @Override - public void delete(ProcessEntity processEntity) { - ZusammenElement processElement = buildElement(new Id(processEntity.getId()), Action.DELETE); - - SessionContext context = createSessionContext(); - ElementContext elementContext = - new ElementContext(processEntity.getVspId(), processEntity.getVersion().getId()); - - zusammenAdaptor.saveElement(context, elementContext, processElement, - String.format("Delete process with id %s", processEntity.getId())); - } - - @Override - public void deleteAll(ProcessEntity processEntity) { - SessionContext context = createSessionContext(); - ElementContext elementContext = - new ElementContext(processEntity.getVspId(), processEntity.getVersion().getId()); - - Optional<Element> optionalElement = zusammenAdaptor.getElementByName(context, - elementContext, new Id(processEntity.getComponentId()), ElementType.Processes.name()); - - if (optionalElement.isPresent()) { - Element processesElement = optionalElement.get(); - Collection<Element> processes = processesElement.getSubElements(); - - processes.forEach(process -> { - ZusammenElement processZusammenElement = - buildElement(process.getElementId(), Action.DELETE); - zusammenAdaptor.saveElement(context, elementContext, processZusammenElement, - "Delete Process with id " + process.getElementId()); - }); + @Override + public void create(ProcessEntity processEntity) { + ZusammenElement processElement = buildProcessElement(processEntity, Action.CREATE); + ZusammenElement processesElement = buildStructuralElement(ElementType.Processes, Action.IGNORE); + ZusammenElement aggregatedElement = VspZusammenUtil.aggregateElements(processesElement, processElement); + ZusammenElement componentElement; + if (processEntity.getComponentId() != null) { + componentElement = buildElement(new Id(processEntity.getComponentId()), Action.IGNORE); + aggregatedElement = VspZusammenUtil.aggregateElements(componentElement, aggregatedElement); + } + SessionContext context = createSessionContext(); + ElementContext elementContext = new ElementContext(processEntity.getVspId(), processEntity.getVersion().getId()); + Element savedElement = zusammenAdaptor.saveElement(context, elementContext, aggregatedElement, "Create process"); + processEntity.setId(processEntity.getComponentId() == null ? savedElement.getSubElements().iterator().next().getElementId().getValue() + : savedElement.getSubElements().iterator().next().getSubElements().iterator().next().getElementId().getValue()); } - } - - @Override - public void deleteVspAll(String vspId, Version version) { - SessionContext context = createSessionContext(); - ElementContext elementContext = - new ElementContext(vspId, version.getId()); - - Optional<Element> optionalElement = zusammenAdaptor.getElementByName(context, - elementContext, null, ElementType.Processes.name()); - if (optionalElement.isPresent()) { - Element processesElement = optionalElement.get(); - Collection<Element> processes = processesElement.getSubElements(); - - processes.forEach(process -> { - ZusammenElement processZusammenElement = - buildElement(process.getElementId(), Action.DELETE); - zusammenAdaptor.saveElement(context, elementContext, processZusammenElement, - "Delete Process with id " + process.getElementId()); - }); + @Override + public ProcessEntity get(ProcessEntity processEntity) { + SessionContext context = createSessionContext(); + ElementContext elementContext = new ElementContext(processEntity.getVspId(), processEntity.getVersion().getId()); + return zusammenAdaptor.getElementInfo(context, elementContext, new Id(processEntity.getId())) + .map(elementInfo -> convertToProcessEntity(elementInfo, new ElementToProcessConvertor(), processEntity)).orElse(null); } - } - - @Override - public ProcessEntity getArtifact(ProcessEntity processEntity) { - SessionContext context = createSessionContext(); - ElementContext elementContext = - new ElementContext(processEntity.getVspId(), processEntity.getVersion().getId()); - - return zusammenAdaptor.getElement(context, elementContext, processEntity.getId()) - .map(element -> { - ProcessEntity process = new ElementToProcessConvertor().convert(element); - process.setVspId(processEntity.getVspId()); - process.setVersion(processEntity.getVersion()); - process.setComponentId(processEntity.getComponentId()); - return process; - }) - .orElse(null); - } - @Override - public void uploadArtifact(ProcessEntity processEntity) { - ProcessEntity retrieved = get(processEntity); - if (retrieved != null) { - retrieved.setArtifactName(processEntity.getArtifactName()); - retrieved.setArtifact(processEntity.getArtifact()); - - update(retrieved, "Upload process artifact"); + @Override + public void update(ProcessEntity processEntity) { + ProcessEntity retrieved = getArtifact(processEntity); + if (retrieved != null && retrieved.getArtifact() != null) { + processEntity.setArtifactName(retrieved.getArtifactName()); + processEntity.setArtifact(retrieved.getArtifact()); + } + update(processEntity, "Update process"); } - } - - @Override - public void deleteArtifact(ProcessEntity processEntity) { - ProcessEntity retrieved = get(processEntity); - if (retrieved != null) { - retrieved.setArtifactName(null); - retrieved.setArtifact(null); - update(retrieved, "Delete process artifact"); + @Override + public void delete(ProcessEntity processEntity) { + ZusammenElement processElement = buildElement(new Id(processEntity.getId()), Action.DELETE); + SessionContext context = createSessionContext(); + ElementContext elementContext = new ElementContext(processEntity.getVspId(), processEntity.getVersion().getId()); + zusammenAdaptor.saveElement(context, elementContext, processElement, String.format("Delete process with id %s", processEntity.getId())); } - } - - @Override - public Collection<ProcessEntity> list(ProcessEntity processEntity) { - SessionContext context = createSessionContext(); - ElementContext elementContext = - new ElementContext(processEntity.getVspId(), processEntity.getVersion().getId()); - Optional<ElementInfo> processesOptional = - zusammenAdaptor.getElementInfoByName(context, elementContext, - extractParentElementId(processEntity), ElementType.Processes.name()); - if (!processesOptional.isPresent()) { - return new ArrayList<>(); + @Override + public void deleteAll(ProcessEntity processEntity) { + SessionContext context = createSessionContext(); + ElementContext elementContext = new ElementContext(processEntity.getVspId(), processEntity.getVersion().getId()); + Optional<Element> optionalElement = zusammenAdaptor + .getElementByName(context, elementContext, new Id(processEntity.getComponentId()), ElementType.Processes.name()); + if (optionalElement.isPresent()) { + Element processesElement = optionalElement.get(); + Collection<Element> processes = processesElement.getSubElements(); + processes.forEach(process -> { + ZusammenElement processZusammenElement = buildElement(process.getElementId(), Action.DELETE); + zusammenAdaptor.saveElement(context, elementContext, processZusammenElement, "Delete Process with id " + process.getElementId()); + }); + } } - ElementToProcessConvertor convertor = new ElementToProcessConvertor(); - return zusammenAdaptor.listElements(context, elementContext, processesOptional.get().getId()) - .stream() - .map(elementInfo -> convertToProcessEntity(elementInfo, convertor, processEntity)) - .collect(Collectors.toList()); - } - private ProcessEntity convertToProcessEntity(ElementInfo elementInfo, - ElementToProcessConvertor convertor, - ProcessEntity inputProcess) { - ProcessEntity process = convertor.convert(elementInfo); - process.setVspId(inputProcess.getVspId()); - process.setVersion(inputProcess.getVersion()); - process.setComponentId(inputProcess.getComponentId()); - return process; - } + @Override + public void deleteVspAll(String vspId, Version version) { + SessionContext context = createSessionContext(); + ElementContext elementContext = new ElementContext(vspId, version.getId()); + Optional<Element> optionalElement = zusammenAdaptor.getElementByName(context, elementContext, null, ElementType.Processes.name()); + if (optionalElement.isPresent()) { + Element processesElement = optionalElement.get(); + Collection<Element> processes = processesElement.getSubElements(); + processes.forEach(process -> { + ZusammenElement processZusammenElement = buildElement(process.getElementId(), Action.DELETE); + zusammenAdaptor.saveElement(context, elementContext, processZusammenElement, "Delete Process with id " + process.getElementId()); + }); + } + } - private void update(ProcessEntity processEntity, String message) { - ZusammenElement processElement = buildProcessElement(processEntity, Action.UPDATE); + @Override + public ProcessEntity getArtifact(ProcessEntity processEntity) { + SessionContext context = createSessionContext(); + ElementContext elementContext = new ElementContext(processEntity.getVspId(), processEntity.getVersion().getId()); + return zusammenAdaptor.getElement(context, elementContext, processEntity.getId()).map(element -> { + ProcessEntity process = new ElementToProcessConvertor().convert(element); + process.setVspId(processEntity.getVspId()); + process.setVersion(processEntity.getVersion()); + process.setComponentId(processEntity.getComponentId()); + return process; + }).orElse(null); + } - SessionContext context = createSessionContext(); - ElementContext elementContext = - new ElementContext(processEntity.getVspId(), processEntity.getVersion().getId()); + @Override + public void uploadArtifact(ProcessEntity processEntity) { + ProcessEntity retrieved = get(processEntity); + if (retrieved != null) { + retrieved.setArtifactName(processEntity.getArtifactName()); + retrieved.setArtifact(processEntity.getArtifact()); + update(retrieved, "Upload process artifact"); + } + } - zusammenAdaptor.saveElement(context, elementContext, processElement, message); - } + @Override + public void deleteArtifact(ProcessEntity processEntity) { + ProcessEntity retrieved = get(processEntity); + if (retrieved != null) { + retrieved.setArtifactName(null); + retrieved.setArtifact(null); + update(retrieved, "Delete process artifact"); + } + } - private Id extractParentElementId(ProcessEntity processEntity) { - return processEntity.getComponentId() == null ? null : new Id(processEntity.getComponentId()); - } + @Override + public Collection<ProcessEntity> list(ProcessEntity processEntity) { + SessionContext context = createSessionContext(); + ElementContext elementContext = new ElementContext(processEntity.getVspId(), processEntity.getVersion().getId()); + Optional<ElementInfo> processesOptional = zusammenAdaptor + .getElementInfoByName(context, elementContext, extractParentElementId(processEntity), ElementType.Processes.name()); + if (!processesOptional.isPresent()) { + return new ArrayList<>(); + } + ElementToProcessConvertor convertor = new ElementToProcessConvertor(); + return zusammenAdaptor.listElements(context, elementContext, processesOptional.get().getId()).stream() + .map(elementInfo -> convertToProcessEntity(elementInfo, convertor, processEntity)).collect(Collectors.toList()); + } - private ZusammenElement buildProcessElement(ProcessEntity process, Action action) { + private ProcessEntity convertToProcessEntity(ElementInfo elementInfo, ElementToProcessConvertor convertor, ProcessEntity inputProcess) { + ProcessEntity process = convertor.convert(elementInfo); + process.setVspId(inputProcess.getVspId()); + process.setVersion(inputProcess.getVersion()); + process.setComponentId(inputProcess.getComponentId()); + return process; + } - Info info = new Info(); - info.setName(process.getName()); - info.addProperty(NAME, process.getName()); - info.addProperty(ElementPropertyName.elementType.name(), ElementType.Process); - info.addProperty(ARTIFACT_NAME, process.getArtifactName()); - info.addProperty(DESCRIPTION, process.getDescription()); - info.addProperty(PROCESS_TYPE, process.getType() != null ? process.getType().name() : null); + private void update(ProcessEntity processEntity, String message) { + ZusammenElement processElement = buildProcessElement(processEntity, Action.UPDATE); + SessionContext context = createSessionContext(); + ElementContext elementContext = new ElementContext(processEntity.getVspId(), processEntity.getVersion().getId()); + zusammenAdaptor.saveElement(context, elementContext, processElement, message); + } - ZusammenElement processElement = buildElement(new Id(process.getId()), action); - processElement.setInfo(info); - if (Objects.nonNull(process.getArtifact())) { - processElement.setData(new ByteArrayInputStream(process.getArtifact().array())); + private Id extractParentElementId(ProcessEntity processEntity) { + return processEntity.getComponentId() == null ? null : new Id(processEntity.getComponentId()); } - return processElement; - } + private ZusammenElement buildProcessElement(ProcessEntity process, Action action) { + Info info = new Info(); + info.setName(process.getName()); + info.addProperty(NAME, process.getName()); + info.addProperty(ElementPropertyName.elementType.name(), ElementType.Process); + info.addProperty(ARTIFACT_NAME, process.getArtifactName()); + info.addProperty(DESCRIPTION, process.getDescription()); + info.addProperty(PROCESS_TYPE, process.getType() != null ? process.getType().name() : null); + ZusammenElement processElement = buildElement(new Id(process.getId()), action); + processElement.setInfo(info); + if (Objects.nonNull(process.getArtifact())) { + processElement.setData(new ByteArrayInputStream(process.getArtifact().array())); + } + return processElement; + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/VendorSoftwareProductInfoDaoZusammenImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/VendorSoftwareProductInfoDaoZusammenImpl.java index de42344788..9655434e74 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/VendorSoftwareProductInfoDaoZusammenImpl.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/VendorSoftwareProductInfoDaoZusammenImpl.java @@ -15,11 +15,17 @@ */ package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen; +import static org.openecomp.core.zusammen.api.ZusammenUtil.buildStructuralElement; +import static org.openecomp.core.zusammen.api.ZusammenUtil.createSessionContext; + import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement; import com.amdocs.zusammen.datatypes.SessionContext; import com.amdocs.zusammen.datatypes.item.Action; import com.amdocs.zusammen.datatypes.item.ElementContext; import com.amdocs.zusammen.datatypes.item.Info; +import java.io.ByteArrayInputStream; +import java.util.Collection; +import java.util.stream.Collectors; import org.openecomp.core.zusammen.api.ZusammenAdaptor; import org.openecomp.sdc.datatypes.model.ElementType; import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao; @@ -33,256 +39,197 @@ import org.openecomp.sdc.versioning.dao.types.Version; import org.openecomp.sdc.versioning.types.VersionableEntityMetadata; import org.openecomp.sdc.versioning.types.VersionableEntityStoreType; -import java.io.ByteArrayInputStream; -import java.util.Collection; -import java.util.stream.Collectors; - -import static org.openecomp.core.zusammen.api.ZusammenUtil.buildStructuralElement; -import static org.openecomp.core.zusammen.api.ZusammenUtil.createSessionContext; - public class VendorSoftwareProductInfoDaoZusammenImpl implements VendorSoftwareProductInfoDao { - private static final String EMPTY_DATA = "{}"; - - private ZusammenAdaptor zusammenAdaptor; - - public VendorSoftwareProductInfoDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) { - this.zusammenAdaptor = zusammenAdaptor; - } - - @Override - public void registerVersioning(String versionableEntityType) { - VersionableEntityMetadata metadata = - new VersionableEntityMetadata(VersionableEntityStoreType.Zusammen, "VendorSoftwareProduct", - null, null); - - ActionVersioningManagerFactory.getInstance().createInterface() - .register(versionableEntityType, metadata); - } - - @Override - public Collection<VspDetails> list(VspDetails entity) { - return zusammenAdaptor.listItems(createSessionContext()).stream() - .filter(item -> "VendorSoftwareProduct".equals(item.getInfo().getProperty("item_type"))) - .map(new ElementToVSPGeneralConvertor()::convert) - .collect(Collectors.toList()); - } - - @Override - public void create(VspDetails vspDetails) { - ZusammenElement generalElement = mapVspDetailsToZusammenElement(vspDetails, Action.CREATE); - - SessionContext context = createSessionContext(); - ElementContext elementContext = - new ElementContext(vspDetails.getId(), vspDetails.getVersion().getId()); - zusammenAdaptor.saveElement(context, elementContext, generalElement, - "Create VSP General Info Element"); - - createVspStructure(context, elementContext); - } - - private void createVspStructure(SessionContext context, ElementContext elementContext) { - createOrchestrationTemplateCandidateStructure(context, elementContext); - createVspModelStructure(context, elementContext); - - zusammenAdaptor.saveElement(context, elementContext, - buildStructuralElement(ElementType.DeploymentFlavors, Action.CREATE), - "Create VSP Deployment Flavors Element"); - - zusammenAdaptor.saveElement(context, elementContext, - buildStructuralElement(ElementType.Processes, Action.CREATE), - "Create VSP Processes Element"); - } - - private void createOrchestrationTemplateCandidateStructure(SessionContext context, - ElementContext elementContext) { - ByteArrayInputStream emptyData = new ByteArrayInputStream(EMPTY_DATA.getBytes()); - ZusammenElement candidateContentElement = - buildStructuralElement(ElementType.OrchestrationTemplateCandidateContent, Action.CREATE); - candidateContentElement.setData(emptyData); - ZusammenElement validationData = buildStructuralElement(ElementType - .OrchestrationTemplateCandidateValidationData, Action.CREATE); - ZusammenElement candidateElement = - buildStructuralElement(ElementType.OrchestrationTemplateCandidate, Action.CREATE); - candidateElement.setData(emptyData); - candidateElement.addSubElement(candidateContentElement); - candidateElement.addSubElement(validationData); - zusammenAdaptor.saveElement(context, elementContext, candidateElement, - "Create Orchestration Template Candidate Elements"); - } + private static final String EMPTY_DATA = "{}"; + private ZusammenAdaptor zusammenAdaptor; - private void createVspModelStructure(SessionContext context, ElementContext elementContext) { - ZusammenElement vspModel = buildStructuralElement(ElementType.VspModel, Action.CREATE); - vspModel.addSubElement(buildOrchestrationTemplateStructure()); - vspModel.addSubElement(buildStructuralElement(ElementType.Networks, Action.CREATE)); - vspModel.addSubElement(buildStructuralElement(ElementType.Components, Action.CREATE)); - vspModel - .addSubElement(buildStructuralElement(ElementType.ComponentDependencies, Action.CREATE)); - - ZusammenElement templates = buildStructuralElement(ElementType.Templates, Action.CREATE); - ZusammenElement artifacts = buildStructuralElement(ElementType.Artifacts, Action.CREATE); - vspModel.addSubElement( - buildServiceModelStructure(ElementType.ServiceModel, templates, artifacts)); - vspModel.addSubElement( - buildServiceModelStructure(ElementType.EnrichedServiceModel, templates, artifacts)); - - zusammenAdaptor.saveElement(context, elementContext, vspModel, "Create VSP Model Elements"); - } - - private ZusammenElement buildOrchestrationTemplateStructure() { - ByteArrayInputStream emptyData = new ByteArrayInputStream(EMPTY_DATA.getBytes()); - - ZusammenElement validationData = - buildStructuralElement(ElementType.OrchestrationTemplateValidationData, Action.CREATE); - validationData.setData(emptyData); - - ZusammenElement orchestrationTemplateStructure = buildStructuralElement(ElementType - .OrchestrationTemplateStructure, Action.CREATE); - validationData.setData(emptyData); - - ZusammenElement orchestrationTemplate = - buildStructuralElement(ElementType.OrchestrationTemplate, Action.CREATE); - orchestrationTemplate.setData(emptyData); - orchestrationTemplate.addSubElement(validationData); - orchestrationTemplate.addSubElement(orchestrationTemplateStructure); - - return orchestrationTemplate; - } - - private ZusammenElement buildServiceModelStructure(ElementType serviceModelElementType, - ZusammenElement templates, - ZusammenElement artifacts) { - ZusammenElement serviceModel = buildStructuralElement(serviceModelElementType, Action.CREATE); - serviceModel.addSubElement(templates); - serviceModel.addSubElement(artifacts); - return serviceModel; - } + public VendorSoftwareProductInfoDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) { + this.zusammenAdaptor = zusammenAdaptor; + } - @Override - public void update(VspDetails vspDetails) { - ZusammenElement generalElement = mapVspDetailsToZusammenElement(vspDetails, Action.UPDATE); + @Override + public void registerVersioning(String versionableEntityType) { + VersionableEntityMetadata metadata = new VersionableEntityMetadata(VersionableEntityStoreType.Zusammen, "VendorSoftwareProduct", null, null); + ActionVersioningManagerFactory.getInstance().createInterface().register(versionableEntityType, metadata); + } - SessionContext context = createSessionContext(); - zusammenAdaptor.saveElement(context, - new ElementContext(vspDetails.getId(), vspDetails.getVersion().getId()), generalElement, - "Update VSP General Info Element"); - } + @Override + public Collection<VspDetails> list(VspDetails entity) { + return zusammenAdaptor.listItems(createSessionContext()).stream() + .filter(item -> "VendorSoftwareProduct".equals(item.getInfo().getProperty("item_type"))).map(new ElementToVSPGeneralConvertor()::convert) + .collect(Collectors.toList()); + } - @Override - public VspDetails get(VspDetails vspDetails) { - SessionContext context = createSessionContext(); - ElementContext elementContext = - new ElementContext(vspDetails.getId(), vspDetails.getVersion().getId()); - return zusammenAdaptor.getElementInfoByName(context, elementContext, null, - ElementType.VendorSoftwareProduct.name()) - .map(new ElementToVSPGeneralConvertor()::convert) - .map(vsp -> { - vsp.setId(vspDetails.getId()); - vsp.setVersion(vspDetails.getVersion()); - return vsp; - }) - .orElse(null); - } + @Override + public void create(VspDetails vspDetails) { + ZusammenElement generalElement = mapVspDetailsToZusammenElement(vspDetails, Action.CREATE); + SessionContext context = createSessionContext(); + ElementContext elementContext = new ElementContext(vspDetails.getId(), vspDetails.getVersion().getId()); + zusammenAdaptor.saveElement(context, elementContext, generalElement, "Create VSP General Info Element"); + createVspStructure(context, elementContext); + } - @Override - public void delete(VspDetails vspDetails) { - SessionContext context = createSessionContext(); - ElementContext elementContext = - new ElementContext(vspDetails.getId(), vspDetails.getVersion().getId()); + private void createVspStructure(SessionContext context, ElementContext elementContext) { + createOrchestrationTemplateCandidateStructure(context, elementContext); + createVspModelStructure(context, elementContext); + zusammenAdaptor.saveElement(context, elementContext, buildStructuralElement(ElementType.DeploymentFlavors, Action.CREATE), + "Create VSP Deployment Flavors Element"); + zusammenAdaptor + .saveElement(context, elementContext, buildStructuralElement(ElementType.Processes, Action.CREATE), "Create VSP Processes Element"); + } - zusammenAdaptor.saveElement(context, elementContext, - buildStructuralElement(ElementType.VspModel, Action.DELETE), - "Delete VSP Model Elements"); + private void createOrchestrationTemplateCandidateStructure(SessionContext context, ElementContext elementContext) { + ByteArrayInputStream emptyData = new ByteArrayInputStream(EMPTY_DATA.getBytes()); + ZusammenElement candidateContentElement = buildStructuralElement(ElementType.OrchestrationTemplateCandidateContent, Action.CREATE); + candidateContentElement.setData(emptyData); + ZusammenElement validationData = buildStructuralElement(ElementType.OrchestrationTemplateCandidateValidationData, Action.CREATE); + ZusammenElement candidateElement = buildStructuralElement(ElementType.OrchestrationTemplateCandidate, Action.CREATE); + candidateElement.setData(emptyData); + candidateElement.addSubElement(candidateContentElement); + candidateElement.addSubElement(validationData); + zusammenAdaptor.saveElement(context, elementContext, candidateElement, "Create Orchestration Template Candidate Elements"); + } - createVspModelStructure(context, elementContext); - } + private void createVspModelStructure(SessionContext context, ElementContext elementContext) { + ZusammenElement vspModel = buildStructuralElement(ElementType.VspModel, Action.CREATE); + vspModel.addSubElement(buildOrchestrationTemplateStructure()); + vspModel.addSubElement(buildStructuralElement(ElementType.Networks, Action.CREATE)); + vspModel.addSubElement(buildStructuralElement(ElementType.Components, Action.CREATE)); + vspModel.addSubElement(buildStructuralElement(ElementType.ComponentDependencies, Action.CREATE)); + ZusammenElement templates = buildStructuralElement(ElementType.Templates, Action.CREATE); + ZusammenElement artifacts = buildStructuralElement(ElementType.Artifacts, Action.CREATE); + vspModel.addSubElement(buildServiceModelStructure(ElementType.ServiceModel, templates, artifacts)); + vspModel.addSubElement(buildServiceModelStructure(ElementType.EnrichedServiceModel, templates, artifacts)); + zusammenAdaptor.saveElement(context, elementContext, vspModel, "Create VSP Model Elements"); + } - @Override - public void updateQuestionnaireData(String vspId, Version version, String questionnaireData) { - SessionContext context = createSessionContext(); + private ZusammenElement buildOrchestrationTemplateStructure() { + ByteArrayInputStream emptyData = new ByteArrayInputStream(EMPTY_DATA.getBytes()); + ZusammenElement validationData = buildStructuralElement(ElementType.OrchestrationTemplateValidationData, Action.CREATE); + validationData.setData(emptyData); + ZusammenElement orchestrationTemplateStructure = buildStructuralElement(ElementType.OrchestrationTemplateStructure, Action.CREATE); + validationData.setData(emptyData); + ZusammenElement orchestrationTemplate = buildStructuralElement(ElementType.OrchestrationTemplate, Action.CREATE); + orchestrationTemplate.setData(emptyData); + orchestrationTemplate.addSubElement(validationData); + orchestrationTemplate.addSubElement(orchestrationTemplateStructure); + return orchestrationTemplate; + } - ZusammenElement questionnaireElement = mapQuestionnaireToZusammenElement(questionnaireData); - zusammenAdaptor.saveElement(context, new ElementContext(vspId, version.getId()), - questionnaireElement, "Update VSP Questionnaire"); - } + private ZusammenElement buildServiceModelStructure(ElementType serviceModelElementType, ZusammenElement templates, ZusammenElement artifacts) { + ZusammenElement serviceModel = buildStructuralElement(serviceModelElementType, Action.CREATE); + serviceModel.addSubElement(templates); + serviceModel.addSubElement(artifacts); + return serviceModel; + } - @Override - public VspQuestionnaireEntity getQuestionnaire(String vspId, Version version) { - SessionContext context = createSessionContext(); - VspQuestionnaireEntity entity = new ElementToVSPQuestionnaireConvertor().convert(zusammenAdaptor - .getElementByName(context, new ElementContext(vspId, version.getId()), null, - ElementType.VSPQuestionnaire.name()) - .orElse(null)); - entity.setId(vspId); - entity.setVersion(version); - return entity; - } + @Override + public void update(VspDetails vspDetails) { + ZusammenElement generalElement = mapVspDetailsToZusammenElement(vspDetails, Action.UPDATE); + SessionContext context = createSessionContext(); + zusammenAdaptor.saveElement(context, new ElementContext(vspDetails.getId(), vspDetails.getVersion().getId()), generalElement, + "Update VSP General Info Element"); + } - @Override - public boolean isManual(String vspId, Version version) { - final VspDetails vspDetails = get(new VspDetails(vspId, version)); - return vspDetails != null && - OnboardingMethod.Manual.name().equals(vspDetails.getOnboardingMethod()); - } + @Override + public VspDetails get(VspDetails vspDetails) { + SessionContext context = createSessionContext(); + ElementContext elementContext = new ElementContext(vspDetails.getId(), vspDetails.getVersion().getId()); + return zusammenAdaptor.getElementInfoByName(context, elementContext, null, ElementType.VendorSoftwareProduct.name()) + .map(new ElementToVSPGeneralConvertor()::convert).map(vsp -> { + vsp.setId(vspDetails.getId()); + vsp.setVersion(vspDetails.getVersion()); + return vsp; + }).orElse(null); + } - private ZusammenElement mapVspDetailsToZusammenElement(VspDetails vspDetails, Action action) { - ZusammenElement generalElement = - buildStructuralElement(ElementType.VendorSoftwareProduct, action); - addVspDetailsToInfo(generalElement.getInfo(), vspDetails); - return generalElement; - } + @Override + public void delete(VspDetails vspDetails) { + SessionContext context = createSessionContext(); + ElementContext elementContext = new ElementContext(vspDetails.getId(), vspDetails.getVersion().getId()); + zusammenAdaptor + .saveElement(context, elementContext, buildStructuralElement(ElementType.VspModel, Action.DELETE), "Delete VSP Model Elements"); + createVspModelStructure(context, elementContext); + } - private ZusammenElement mapQuestionnaireToZusammenElement(String questionnaireData) { - ZusammenElement questionnaireElement = - buildStructuralElement(ElementType.VSPQuestionnaire, Action.UPDATE); - questionnaireElement.setData(new ByteArrayInputStream(questionnaireData.getBytes())); - return questionnaireElement; - } + @Override + public void updateQuestionnaireData(String vspId, Version version, String questionnaireData) { + SessionContext context = createSessionContext(); + ZusammenElement questionnaireElement = mapQuestionnaireToZusammenElement(questionnaireData); + zusammenAdaptor.saveElement(context, new ElementContext(vspId, version.getId()), questionnaireElement, "Update VSP Questionnaire"); + } - private void addVspDetailsToInfo(Info info, VspDetails vspDetails) { - info.addProperty(InfoPropertyName.NAME.getValue(), vspDetails.getName()); - info.addProperty(InfoPropertyName.DESCRIPTION.getValue(), vspDetails.getDescription()); - info.addProperty(InfoPropertyName.ICON.getValue(), vspDetails.getIcon()); - info.addProperty(InfoPropertyName.CATEGORY.getValue(), vspDetails.getCategory()); - info.addProperty(InfoPropertyName.SUB_CATEGORY.getValue(), vspDetails.getSubCategory()); - info.addProperty(InfoPropertyName.VENDOR_ID.getValue(), vspDetails.getVendorId()); - info.addProperty(InfoPropertyName.VENDOR_NAME.getValue(), vspDetails.getVendorName()); - if (vspDetails.getVlmVersion() != null) { - info.addProperty(InfoPropertyName.VENDOR_VERSION.getValue(), - vspDetails.getVlmVersion().getId()); + @Override + public VspQuestionnaireEntity getQuestionnaire(String vspId, Version version) { + SessionContext context = createSessionContext(); + VspQuestionnaireEntity entity = new ElementToVSPQuestionnaireConvertor().convert( + zusammenAdaptor.getElementByName(context, new ElementContext(vspId, version.getId()), null, ElementType.VSPQuestionnaire.name()) + .orElse(null)); + entity.setId(vspId); + entity.setVersion(version); + return entity; } - info.addProperty(InfoPropertyName.LICENSE_TYPE.getValue(), - vspDetails.getLicenseType()); - info.addProperty(InfoPropertyName.LICENSE_AGREEMENT.getValue(), - vspDetails.getLicenseAgreement()); - info.addProperty(InfoPropertyName.FEATURE_GROUPS.getValue(), vspDetails.getFeatureGroups()); - info.addProperty(InfoPropertyName.ON_BOARDING_METHOD.getValue(), - vspDetails.getOnboardingMethod()); - } - public enum InfoPropertyName { - NAME("name"), - DESCRIPTION("description"), - ICON("icon"), - CATEGORY("category"), - SUB_CATEGORY("subCategory"), - VENDOR_ID("vendorId"), - VENDOR_NAME("vendorName"), - VENDOR_VERSION("vendorVersion"), - LICENSE_TYPE("licenseType"), - LICENSE_AGREEMENT("licenseAgreement"), - FEATURE_GROUPS("featureGroups"), - ON_BOARDING_METHOD("onboardingMethod"); + @Override + public boolean isManual(String vspId, Version version) { + final VspDetails vspDetails = get(new VspDetails(vspId, version)); + return vspDetails != null && OnboardingMethod.Manual.name().equals(vspDetails.getOnboardingMethod()); + } - private String value; + private ZusammenElement mapVspDetailsToZusammenElement(VspDetails vspDetails, Action action) { + ZusammenElement generalElement = buildStructuralElement(ElementType.VendorSoftwareProduct, action); + addVspDetailsToInfo(generalElement.getInfo(), vspDetails); + return generalElement; + } - InfoPropertyName(String value) { - this.value = value; + private ZusammenElement mapQuestionnaireToZusammenElement(String questionnaireData) { + ZusammenElement questionnaireElement = buildStructuralElement(ElementType.VSPQuestionnaire, Action.UPDATE); + questionnaireElement.setData(new ByteArrayInputStream(questionnaireData.getBytes())); + return questionnaireElement; } - public String getValue() { - return value; + private void addVspDetailsToInfo(Info info, VspDetails vspDetails) { + info.addProperty(InfoPropertyName.NAME.getValue(), vspDetails.getName()); + info.addProperty(InfoPropertyName.DESCRIPTION.getValue(), vspDetails.getDescription()); + info.addProperty(InfoPropertyName.ICON.getValue(), vspDetails.getIcon()); + info.addProperty(InfoPropertyName.CATEGORY.getValue(), vspDetails.getCategory()); + info.addProperty(InfoPropertyName.SUB_CATEGORY.getValue(), vspDetails.getSubCategory()); + info.addProperty(InfoPropertyName.VENDOR_ID.getValue(), vspDetails.getVendorId()); + info.addProperty(InfoPropertyName.VENDOR_NAME.getValue(), vspDetails.getVendorName()); + if (vspDetails.getVlmVersion() != null) { + info.addProperty(InfoPropertyName.VENDOR_VERSION.getValue(), vspDetails.getVlmVersion().getId()); + } + info.addProperty(InfoPropertyName.LICENSE_TYPE.getValue(), vspDetails.getLicenseType()); + info.addProperty(InfoPropertyName.LICENSE_AGREEMENT.getValue(), vspDetails.getLicenseAgreement()); + info.addProperty(InfoPropertyName.FEATURE_GROUPS.getValue(), vspDetails.getFeatureGroups()); + info.addProperty(InfoPropertyName.ON_BOARDING_METHOD.getValue(), vspDetails.getOnboardingMethod()); } - } + public enum InfoPropertyName { + // @formatter:off + NAME("name"), + DESCRIPTION("description"), + ICON("icon"), + CATEGORY("category"), + SUB_CATEGORY("subCategory"), + VENDOR_ID("vendorId"), + VENDOR_NAME("vendorName"), + VENDOR_VERSION("vendorVersion"), + LICENSE_TYPE("licenseType"), + LICENSE_AGREEMENT("licenseAgreement"), + FEATURE_GROUPS("featureGroups"), + ON_BOARDING_METHOD("onboardingMethod"); + // @formatter:on + + private String value; + + InfoPropertyName(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/VspZusammenUtil.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/VspZusammenUtil.java index d78e48bff8..c0b1be61bf 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/VspZusammenUtil.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/VspZusammenUtil.java @@ -7,9 +7,9 @@ * 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. @@ -17,49 +17,47 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen; import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement; -import org.apache.commons.io.IOUtils; - import java.io.IOException; import java.io.InputStream; import java.util.Arrays; import java.util.Objects; +import org.apache.commons.io.IOUtils; class VspZusammenUtil { - private VspZusammenUtil(){} + private VspZusammenUtil() { + } - static ZusammenElement aggregateElements(ZusammenElement... elements) { - ZusammenElement head = null; - ZusammenElement father = null; - for (ZusammenElement element : elements) { - if (Objects.isNull(head)) { - head = father = element; - } else { - if (father != null) { - father.getSubElements().add(element); - father = element; + static ZusammenElement aggregateElements(ZusammenElement... elements) { + ZusammenElement head = null; + ZusammenElement father = null; + for (ZusammenElement element : elements) { + if (Objects.isNull(head)) { + head = father = element; + } else { + if (father != null) { + father.getSubElements().add(element); + father = element; + } + } } - } + return head; } - return head; - } - - static boolean hasEmptyData(InputStream elementData) { - String EMPTY_DATA = "{}"; - byte[] byteElementData; - try { - byteElementData = IOUtils.toByteArray(elementData); - } catch (IOException ex) { - return false; - } - if (Arrays.equals(EMPTY_DATA.getBytes(), byteElementData)) { - return true; + static boolean hasEmptyData(InputStream elementData) { + String EMPTY_DATA = "{}"; + byte[] byteElementData; + try { + byteElementData = IOUtils.toByteArray(elementData); + } catch (IOException ex) { + return false; + } + if (Arrays.equals(EMPTY_DATA.getBytes(), byteElementData)) { + return true; + } + return false; } - return false; - } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToComponentConvertor.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToComponentConvertor.java index b7a172ed90..d4c7fd05db 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToComponentConvertor.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToComponentConvertor.java @@ -7,9 +7,9 @@ * 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. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor; import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element; @@ -30,29 +29,24 @@ import org.openecomp.types.ElementPropertyName; public class ElementToComponentConvertor extends ElementConvertor<ComponentEntity> { - @Override - public ComponentEntity convert(Element element) { - ComponentEntity componentEntity = new ComponentEntity(); - componentEntity.setId(element.getElementId().getValue()); - componentEntity.setCompositionData(new String(FileUtils.toByteArray(element.getData()))); - mapInfoToComponentEntity(componentEntity,element.getInfo()); - return componentEntity; - } - - @Override - public ComponentEntity convert( ElementInfo elementInfo) { - ComponentEntity componentEntity = new ComponentEntity(); - componentEntity.setId(elementInfo.getId().getValue()); - mapInfoToComponentEntity(componentEntity,elementInfo.getInfo()); - return componentEntity; - } - - - public void mapInfoToComponentEntity(ComponentEntity componentEntity,Info info){ - - - componentEntity.setCompositionData( - info.getProperty(ElementPropertyName.compositionData.name())); - } - + @Override + public ComponentEntity convert(Element element) { + ComponentEntity componentEntity = new ComponentEntity(); + componentEntity.setId(element.getElementId().getValue()); + componentEntity.setCompositionData(new String(FileUtils.toByteArray(element.getData()))); + mapInfoToComponentEntity(componentEntity, element.getInfo()); + return componentEntity; + } + + @Override + public ComponentEntity convert(ElementInfo elementInfo) { + ComponentEntity componentEntity = new ComponentEntity(); + componentEntity.setId(elementInfo.getId().getValue()); + mapInfoToComponentEntity(componentEntity, elementInfo.getInfo()); + return componentEntity; + } + + public void mapInfoToComponentEntity(ComponentEntity componentEntity, Info info) { + componentEntity.setCompositionData(info.getProperty(ElementPropertyName.compositionData.name())); + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToComponentDependencyModelConvertor.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToComponentDependencyModelConvertor.java index 232ff336aa..b00f4e4846 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToComponentDependencyModelConvertor.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToComponentDependencyModelConvertor.java @@ -7,9 +7,9 @@ * 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. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor; import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element; @@ -27,35 +26,27 @@ import org.openecomp.convertor.ElementConvertor; import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.ComponentDependencyModelPropertyName; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity; -public class ElementToComponentDependencyModelConvertor extends ElementConvertor <ComponentDependencyModelEntity>{ - - @Override - public ComponentDependencyModelEntity convert( Element element) { - ComponentDependencyModelEntity componentDependencyModelEntity = new ComponentDependencyModelEntity(); - componentDependencyModelEntity.setId(element.getElementId().getValue()); - mapInfoToComponentDependencyModelEntity(componentDependencyModelEntity,element.getInfo()); - return componentDependencyModelEntity; - } - - @Override - public ComponentDependencyModelEntity convert(ElementInfo elementInfo) { - ComponentDependencyModelEntity componentDependencyModelEntity = new ComponentDependencyModelEntity(); - - componentDependencyModelEntity.setId(elementInfo.getId().getValue()); - mapInfoToComponentDependencyModelEntity(componentDependencyModelEntity,elementInfo.getInfo()); - return componentDependencyModelEntity; - } - - - public void mapInfoToComponentDependencyModelEntity(ComponentDependencyModelEntity componentDependencyModelEntity,Info info){ - - componentDependencyModelEntity.setSourceComponentId(info - .getProperty(ComponentDependencyModelPropertyName.sourcecomponent_id.name())); - componentDependencyModelEntity.setTargetComponentId(info - .getProperty(ComponentDependencyModelPropertyName.targetcomponent_id.name())); - componentDependencyModelEntity.setRelation(info - .getProperty(ComponentDependencyModelPropertyName.relation.name())); - - } - +public class ElementToComponentDependencyModelConvertor extends ElementConvertor<ComponentDependencyModelEntity> { + + @Override + public ComponentDependencyModelEntity convert(Element element) { + ComponentDependencyModelEntity componentDependencyModelEntity = new ComponentDependencyModelEntity(); + componentDependencyModelEntity.setId(element.getElementId().getValue()); + mapInfoToComponentDependencyModelEntity(componentDependencyModelEntity, element.getInfo()); + return componentDependencyModelEntity; + } + + @Override + public ComponentDependencyModelEntity convert(ElementInfo elementInfo) { + ComponentDependencyModelEntity componentDependencyModelEntity = new ComponentDependencyModelEntity(); + componentDependencyModelEntity.setId(elementInfo.getId().getValue()); + mapInfoToComponentDependencyModelEntity(componentDependencyModelEntity, elementInfo.getInfo()); + return componentDependencyModelEntity; + } + + public void mapInfoToComponentDependencyModelEntity(ComponentDependencyModelEntity componentDependencyModelEntity, Info info) { + componentDependencyModelEntity.setSourceComponentId(info.getProperty(ComponentDependencyModelPropertyName.sourcecomponent_id.name())); + componentDependencyModelEntity.setTargetComponentId(info.getProperty(ComponentDependencyModelPropertyName.targetcomponent_id.name())); + componentDependencyModelEntity.setRelation(info.getProperty(ComponentDependencyModelPropertyName.relation.name())); + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToComponentMonitoringUploadConvertor.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToComponentMonitoringUploadConvertor.java index 2a8b3b9c81..044a862e4d 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToComponentMonitoringUploadConvertor.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToComponentMonitoringUploadConvertor.java @@ -7,9 +7,9 @@ * 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. @@ -17,49 +17,40 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor; +import static org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToProcessConvertor.ARTIFACT_NAME; + import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element; import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo; import com.amdocs.zusammen.datatypes.item.Info; +import java.nio.ByteBuffer; import org.openecomp.convertor.ElementConvertor; import org.openecomp.core.enrichment.types.MonitoringUploadType; import org.openecomp.core.utilities.file.FileUtils; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentMonitoringUploadEntity; -import java.nio.ByteBuffer; - -import static org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToProcessConvertor.ARTIFACT_NAME; - public class ElementToComponentMonitoringUploadConvertor extends ElementConvertor<ComponentMonitoringUploadEntity> { - @Override - public ComponentMonitoringUploadEntity convert(Element element) { - ComponentMonitoringUploadEntity mibEntity = new ComponentMonitoringUploadEntity(); - - mibEntity.setId(element.getElementId().getValue()); - mibEntity.setArtifact(ByteBuffer.wrap(FileUtils.toByteArray(element.getData()))); - mapInfoToComponentMonitoringUploadEntity(mibEntity, element.getInfo()); - return mibEntity; - } - - @Override - public ComponentMonitoringUploadEntity convert(ElementInfo elementInfo) { - ComponentMonitoringUploadEntity mibEntity = new ComponentMonitoringUploadEntity(); - - mibEntity.setId(elementInfo.getId().getValue()); - mapInfoToComponentMonitoringUploadEntity(mibEntity, elementInfo.getInfo()); - return mibEntity; - } - - - public void mapInfoToComponentMonitoringUploadEntity(ComponentMonitoringUploadEntity mibEntity, - Info info) { - - mibEntity.setArtifactName((String) info.getProperties().get(ARTIFACT_NAME)); - mibEntity.setType(MonitoringUploadType.valueOf(info.getName())); - } - - + @Override + public ComponentMonitoringUploadEntity convert(Element element) { + ComponentMonitoringUploadEntity mibEntity = new ComponentMonitoringUploadEntity(); + mibEntity.setId(element.getElementId().getValue()); + mibEntity.setArtifact(ByteBuffer.wrap(FileUtils.toByteArray(element.getData()))); + mapInfoToComponentMonitoringUploadEntity(mibEntity, element.getInfo()); + return mibEntity; + } + + @Override + public ComponentMonitoringUploadEntity convert(ElementInfo elementInfo) { + ComponentMonitoringUploadEntity mibEntity = new ComponentMonitoringUploadEntity(); + mibEntity.setId(elementInfo.getId().getValue()); + mapInfoToComponentMonitoringUploadEntity(mibEntity, elementInfo.getInfo()); + return mibEntity; + } + + public void mapInfoToComponentMonitoringUploadEntity(ComponentMonitoringUploadEntity mibEntity, Info info) { + mibEntity.setArtifactName((String) info.getProperties().get(ARTIFACT_NAME)); + mibEntity.setType(MonitoringUploadType.valueOf(info.getName())); + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToComponentQuestionnnaireConvertor.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToComponentQuestionnnaireConvertor.java index f8ab803280..febafaae2f 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToComponentQuestionnnaireConvertor.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToComponentQuestionnnaireConvertor.java @@ -7,9 +7,9 @@ * 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. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor; import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element; @@ -25,17 +24,16 @@ import org.openecomp.convertor.ElementConvertor; import org.openecomp.core.utilities.file.FileUtils; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity; - /** * Created by ayalaben on 9/27/2017 */ public class ElementToComponentQuestionnnaireConvertor extends ElementConvertor<ComponentEntity> { - @Override - public ComponentEntity convert( Element element) { - ComponentEntity componentEntity = new ComponentEntity(); - componentEntity.setId(element.getElementId().getValue()); - componentEntity.setQuestionnaireData(new String(FileUtils.toByteArray(element.getData()))); - return componentEntity; - } + @Override + public ComponentEntity convert(Element element) { + ComponentEntity componentEntity = new ComponentEntity(); + componentEntity.setId(element.getElementId().getValue()); + componentEntity.setQuestionnaireData(new String(FileUtils.toByteArray(element.getData()))); + return componentEntity; + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToCompositionEntityConvertor.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToCompositionEntityConvertor.java index ca0d564ce2..b3271f5db4 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToCompositionEntityConvertor.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToCompositionEntityConvertor.java @@ -7,9 +7,9 @@ * 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. @@ -17,45 +17,44 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor; import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element; import org.openecomp.convertor.ElementConvertor; import org.openecomp.core.utilities.file.FileUtils; -import org.openecomp.sdc.vendorsoftwareproduct.dao.type.*; - -public class ElementToCompositionEntityConvertor extends ElementConvertor <CompositionEntity>{ +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.CompositionEntity; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ImageEntity; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspQuestionnaireEntity; - @Override - public CompositionEntity convert(Element element) { +public class ElementToCompositionEntityConvertor extends ElementConvertor<CompositionEntity> { - CompositionEntity compositionEntity = null; - switch (getElementType(element)) { - case ComponentQuestionnaire: - compositionEntity = new ComponentEntity(); - break; - case VSPQuestionnaire: - compositionEntity = new VspQuestionnaireEntity(); - break; - case ImageQuestionnaire: - compositionEntity = new ImageEntity(); - break; - case ComputeQuestionnaire: - compositionEntity = new ComponentEntity(); - break; - case NicQuestionnaire: - compositionEntity = new NicEntity(); + @Override + public CompositionEntity convert(Element element) { + CompositionEntity compositionEntity = null; + switch (getElementType(element)) { + case ComponentQuestionnaire: + compositionEntity = new ComponentEntity(); + break; + case VSPQuestionnaire: + compositionEntity = new VspQuestionnaireEntity(); + break; + case ImageQuestionnaire: + compositionEntity = new ImageEntity(); + break; + case ComputeQuestionnaire: + compositionEntity = new ComponentEntity(); + break; + case NicQuestionnaire: + compositionEntity = new NicEntity(); + } + if (compositionEntity != null) { + compositionEntity.setId(element.getElementId().getValue()); + compositionEntity.setQuestionnaireData(element.getData() == null ? null : new String(FileUtils.toByteArray(element.getData()))); + return compositionEntity; + } else { + return null; + } } - if (compositionEntity != null) { - compositionEntity.setId(element.getElementId().getValue()); - compositionEntity.setQuestionnaireData(element.getData() == null - ? null - : new String(FileUtils.toByteArray(element.getData()))); - return compositionEntity; - } else { - return null; - } - } - } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToComputeConvertor.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToComputeConvertor.java index ee10221862..12fba38009 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToComputeConvertor.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToComputeConvertor.java @@ -7,9 +7,9 @@ * 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. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor; import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element; @@ -28,33 +27,26 @@ import org.openecomp.core.utilities.file.FileUtils; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComputeEntity; import org.openecomp.types.ElementPropertyName; -public class ElementToComputeConvertor extends ElementConvertor <ComputeEntity>{ - - @Override - public ComputeEntity convert( Element element) { - ComputeEntity computeEntity = new ComputeEntity(); - - computeEntity.setId(element.getElementId().getValue()); - computeEntity.setCompositionData(new String(FileUtils.toByteArray(element.getData()))); - mapInfoToComputeEntity(computeEntity,element.getInfo()); - return computeEntity; - } - - @Override - public ComputeEntity convert( ElementInfo elementInfo) { - ComputeEntity computeEntity = new ComputeEntity(); - - computeEntity.setId(elementInfo.getId().getValue()); - mapInfoToComputeEntity(computeEntity,elementInfo.getInfo()); - return computeEntity; - } - - - public void mapInfoToComputeEntity(ComputeEntity computeEntity,Info info){ - - - computeEntity.setCompositionData( - info.getProperty(ElementPropertyName.compositionData.name())); - } - +public class ElementToComputeConvertor extends ElementConvertor<ComputeEntity> { + + @Override + public ComputeEntity convert(Element element) { + ComputeEntity computeEntity = new ComputeEntity(); + computeEntity.setId(element.getElementId().getValue()); + computeEntity.setCompositionData(new String(FileUtils.toByteArray(element.getData()))); + mapInfoToComputeEntity(computeEntity, element.getInfo()); + return computeEntity; + } + + @Override + public ComputeEntity convert(ElementInfo elementInfo) { + ComputeEntity computeEntity = new ComputeEntity(); + computeEntity.setId(elementInfo.getId().getValue()); + mapInfoToComputeEntity(computeEntity, elementInfo.getInfo()); + return computeEntity; + } + + public void mapInfoToComputeEntity(ComputeEntity computeEntity, Info info) { + computeEntity.setCompositionData(info.getProperty(ElementPropertyName.compositionData.name())); + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToComputeQuestionnaireConvertor.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToComputeQuestionnaireConvertor.java index bc5b556625..c255dcce24 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToComputeQuestionnaireConvertor.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToComputeQuestionnaireConvertor.java @@ -7,9 +7,9 @@ * 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. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor; import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element; @@ -25,15 +24,13 @@ import org.openecomp.convertor.ElementConvertor; import org.openecomp.core.utilities.file.FileUtils; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComputeEntity; -public class ElementToComputeQuestionnaireConvertor extends ElementConvertor <ComputeEntity>{ - - @Override - public ComputeEntity convert( Element element) { - ComputeEntity computeEntity = new ComputeEntity(); - - computeEntity.setId(element.getElementId().getValue()); - computeEntity.setQuestionnaireData(new String(FileUtils.toByteArray(element.getData()))); - return computeEntity; - } +public class ElementToComputeQuestionnaireConvertor extends ElementConvertor<ComputeEntity> { + @Override + public ComputeEntity convert(Element element) { + ComputeEntity computeEntity = new ComputeEntity(); + computeEntity.setId(element.getElementId().getValue()); + computeEntity.setQuestionnaireData(new String(FileUtils.toByteArray(element.getData()))); + return computeEntity; + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToDeploymentFlavorConvertor.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToDeploymentFlavorConvertor.java index 19719c6827..c354da1707 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToDeploymentFlavorConvertor.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToDeploymentFlavorConvertor.java @@ -7,9 +7,9 @@ * 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. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor; import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element; @@ -28,33 +27,26 @@ import org.openecomp.core.utilities.file.FileUtils; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity; import org.openecomp.types.ElementPropertyName; -public class ElementToDeploymentFlavorConvertor extends ElementConvertor <DeploymentFlavorEntity>{ - - @Override - public DeploymentFlavorEntity convert( Element element) { - DeploymentFlavorEntity deploymentFlavorEntity = new DeploymentFlavorEntity(); - - deploymentFlavorEntity.setId(element.getElementId().getValue()); - deploymentFlavorEntity.setCompositionData(new String(FileUtils.toByteArray(element.getData()))); - mapInfoToDeploymentFlavorEntity(deploymentFlavorEntity,element.getInfo()); - return deploymentFlavorEntity; - } - - @Override - public DeploymentFlavorEntity convert( ElementInfo elementInfo) { - DeploymentFlavorEntity deploymentFlavorEntity = new DeploymentFlavorEntity(); - - deploymentFlavorEntity.setId(elementInfo.getId().getValue()); - mapInfoToDeploymentFlavorEntity(deploymentFlavorEntity,elementInfo.getInfo()); - return deploymentFlavorEntity; - } - - - public void mapInfoToDeploymentFlavorEntity(DeploymentFlavorEntity deploymentFlavorEntity,Info info){ - - - deploymentFlavorEntity.setCompositionData( - info.getProperty(ElementPropertyName.compositionData.name())); - } - +public class ElementToDeploymentFlavorConvertor extends ElementConvertor<DeploymentFlavorEntity> { + + @Override + public DeploymentFlavorEntity convert(Element element) { + DeploymentFlavorEntity deploymentFlavorEntity = new DeploymentFlavorEntity(); + deploymentFlavorEntity.setId(element.getElementId().getValue()); + deploymentFlavorEntity.setCompositionData(new String(FileUtils.toByteArray(element.getData()))); + mapInfoToDeploymentFlavorEntity(deploymentFlavorEntity, element.getInfo()); + return deploymentFlavorEntity; + } + + @Override + public DeploymentFlavorEntity convert(ElementInfo elementInfo) { + DeploymentFlavorEntity deploymentFlavorEntity = new DeploymentFlavorEntity(); + deploymentFlavorEntity.setId(elementInfo.getId().getValue()); + mapInfoToDeploymentFlavorEntity(deploymentFlavorEntity, elementInfo.getInfo()); + return deploymentFlavorEntity; + } + + public void mapInfoToDeploymentFlavorEntity(DeploymentFlavorEntity deploymentFlavorEntity, Info info) { + deploymentFlavorEntity.setCompositionData(info.getProperty(ElementPropertyName.compositionData.name())); + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToImageConvertor.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToImageConvertor.java index 66621d6934..5aa164c06b 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToImageConvertor.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToImageConvertor.java @@ -7,9 +7,9 @@ * 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. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor; import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element; @@ -28,33 +27,26 @@ import org.openecomp.core.utilities.file.FileUtils; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ImageEntity; import org.openecomp.types.ElementPropertyName; -public class ElementToImageConvertor extends ElementConvertor <ImageEntity>{ - - @Override - public ImageEntity convert( Element element) { - ImageEntity imageEntity = new ImageEntity(); - - imageEntity.setId(element.getElementId().getValue()); - imageEntity.setCompositionData(new String(FileUtils.toByteArray(element.getData()))); - mapInfoToImageEntity(imageEntity,element.getInfo()); - return imageEntity; - } - - @Override - public ImageEntity convert( ElementInfo elementInfo) { - ImageEntity imageEntity = new ImageEntity(); - - imageEntity.setId(elementInfo.getId().getValue()); - mapInfoToImageEntity(imageEntity,elementInfo.getInfo()); - return imageEntity; - } - - - public void mapInfoToImageEntity(ImageEntity imageEntity,Info info){ - - - imageEntity.setCompositionData( - info.getProperty(ElementPropertyName.compositionData.name())); - } - +public class ElementToImageConvertor extends ElementConvertor<ImageEntity> { + + @Override + public ImageEntity convert(Element element) { + ImageEntity imageEntity = new ImageEntity(); + imageEntity.setId(element.getElementId().getValue()); + imageEntity.setCompositionData(new String(FileUtils.toByteArray(element.getData()))); + mapInfoToImageEntity(imageEntity, element.getInfo()); + return imageEntity; + } + + @Override + public ImageEntity convert(ElementInfo elementInfo) { + ImageEntity imageEntity = new ImageEntity(); + imageEntity.setId(elementInfo.getId().getValue()); + mapInfoToImageEntity(imageEntity, elementInfo.getInfo()); + return imageEntity; + } + + public void mapInfoToImageEntity(ImageEntity imageEntity, Info info) { + imageEntity.setCompositionData(info.getProperty(ElementPropertyName.compositionData.name())); + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToImageQuestionnaireConvertor.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToImageQuestionnaireConvertor.java index 4dfe9d297f..32aa3c4041 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToImageQuestionnaireConvertor.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToImageQuestionnaireConvertor.java @@ -7,9 +7,9 @@ * 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. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor; import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element; @@ -25,15 +24,13 @@ import org.openecomp.convertor.ElementConvertor; import org.openecomp.core.utilities.file.FileUtils; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ImageEntity; -public class ElementToImageQuestionnaireConvertor extends ElementConvertor <ImageEntity>{ - - @Override - public ImageEntity convert( Element element) { - ImageEntity imageEntity = new ImageEntity(); - - imageEntity.setId(element.getElementId().getValue()); - imageEntity.setQuestionnaireData(new String(FileUtils.toByteArray(element.getData()))); - return imageEntity; - } +public class ElementToImageQuestionnaireConvertor extends ElementConvertor<ImageEntity> { + @Override + public ImageEntity convert(Element element) { + ImageEntity imageEntity = new ImageEntity(); + imageEntity.setId(element.getElementId().getValue()); + imageEntity.setQuestionnaireData(new String(FileUtils.toByteArray(element.getData()))); + return imageEntity; + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToMonitoringUploadMapConvertor.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToMonitoringUploadMapConvertor.java index 8c4a284fa4..0f2b208808 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToMonitoringUploadMapConvertor.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToMonitoringUploadMapConvertor.java @@ -7,9 +7,9 @@ * 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. @@ -17,27 +17,24 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor; -import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element; -import org.openecomp.convertor.ElementConvertor; +import static org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToProcessConvertor.ARTIFACT_NAME; +import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element; import java.util.HashMap; import java.util.Map; - -import static org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToProcessConvertor.ARTIFACT_NAME; +import org.openecomp.convertor.ElementConvertor; /** * Created by ayalaben on 9/5/2017. */ +public class ElementToMonitoringUploadMapConvertor extends ElementConvertor<Map<String, String>> { -public class ElementToMonitoringUploadMapConvertor extends ElementConvertor<Map<String ,String>> { - - @Override - public Map<String ,String> convert(Element element) { - HashMap<String,String> map = new HashMap<>(); - map.put("File Name",element.getInfo().getProperty(ARTIFACT_NAME)); - return map; - } + @Override + public Map<String, String> convert(Element element) { + HashMap<String, String> map = new HashMap<>(); + map.put("File Name", element.getInfo().getProperty(ARTIFACT_NAME)); + return map; + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToNetworkConvertor.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToNetworkConvertor.java index a34e650e78..0a64ff54c2 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToNetworkConvertor.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToNetworkConvertor.java @@ -7,9 +7,9 @@ * 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. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor; import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element; @@ -28,31 +27,26 @@ import org.openecomp.core.utilities.file.FileUtils; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NetworkEntity; import org.openecomp.types.ElementPropertyName; -public class ElementToNetworkConvertor extends ElementConvertor <NetworkEntity>{ - - @Override - public NetworkEntity convert( Element element) { - NetworkEntity networkEntity = new NetworkEntity(); - - networkEntity.setId(element.getElementId().getValue()); - networkEntity.setCompositionData(new String(FileUtils.toByteArray(element.getData()))); - mapInfoToNetworkEntity(networkEntity,element.getInfo()); - return networkEntity; - } - - @Override - public NetworkEntity convert( ElementInfo elementInfo) { - NetworkEntity networkEntity = new NetworkEntity(); - - networkEntity.setId(elementInfo.getId().getValue()); - mapInfoToNetworkEntity(networkEntity,elementInfo.getInfo()); - return networkEntity; - } - - - public void mapInfoToNetworkEntity(NetworkEntity networkEntity,Info info){ - networkEntity.setCompositionData( - info.getProperty(ElementPropertyName.compositionData.name())); - } - +public class ElementToNetworkConvertor extends ElementConvertor<NetworkEntity> { + + @Override + public NetworkEntity convert(Element element) { + NetworkEntity networkEntity = new NetworkEntity(); + networkEntity.setId(element.getElementId().getValue()); + networkEntity.setCompositionData(new String(FileUtils.toByteArray(element.getData()))); + mapInfoToNetworkEntity(networkEntity, element.getInfo()); + return networkEntity; + } + + @Override + public NetworkEntity convert(ElementInfo elementInfo) { + NetworkEntity networkEntity = new NetworkEntity(); + networkEntity.setId(elementInfo.getId().getValue()); + mapInfoToNetworkEntity(networkEntity, elementInfo.getInfo()); + return networkEntity; + } + + public void mapInfoToNetworkEntity(NetworkEntity networkEntity, Info info) { + networkEntity.setCompositionData(info.getProperty(ElementPropertyName.compositionData.name())); + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToNicConvertor.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToNicConvertor.java index a41eb382b2..e126586420 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToNicConvertor.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToNicConvertor.java @@ -7,9 +7,9 @@ * 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. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor; import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element; @@ -28,32 +27,26 @@ import org.openecomp.core.utilities.file.FileUtils; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity; import org.openecomp.types.ElementPropertyName; -public class ElementToNicConvertor extends ElementConvertor <NicEntity>{ - - @Override - public NicEntity convert( Element element) { - NicEntity nicEntity = new NicEntity(); - - nicEntity.setId(element.getElementId().getValue()); - nicEntity.setCompositionData(new String(FileUtils.toByteArray(element.getData()))); - mapInfoToNicEntity(nicEntity,element.getInfo()); - return nicEntity; - } - - @Override - public NicEntity convert( ElementInfo elementInfo) { - NicEntity nicEntity = new NicEntity(); - - nicEntity.setId(elementInfo.getId().getValue()); - mapInfoToNicEntity(nicEntity,elementInfo.getInfo()); - return nicEntity; - } - - - public void mapInfoToNicEntity(NicEntity nicEntity,Info info){ - - nicEntity.setCompositionData( - info.getProperty(ElementPropertyName.compositionData.name())); - } - +public class ElementToNicConvertor extends ElementConvertor<NicEntity> { + + @Override + public NicEntity convert(Element element) { + NicEntity nicEntity = new NicEntity(); + nicEntity.setId(element.getElementId().getValue()); + nicEntity.setCompositionData(new String(FileUtils.toByteArray(element.getData()))); + mapInfoToNicEntity(nicEntity, element.getInfo()); + return nicEntity; + } + + @Override + public NicEntity convert(ElementInfo elementInfo) { + NicEntity nicEntity = new NicEntity(); + nicEntity.setId(elementInfo.getId().getValue()); + mapInfoToNicEntity(nicEntity, elementInfo.getInfo()); + return nicEntity; + } + + public void mapInfoToNicEntity(NicEntity nicEntity, Info info) { + nicEntity.setCompositionData(info.getProperty(ElementPropertyName.compositionData.name())); + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToNicQuestionnaireConvertor.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToNicQuestionnaireConvertor.java index ec84ae9f6d..fe397f772d 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToNicQuestionnaireConvertor.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToNicQuestionnaireConvertor.java @@ -7,9 +7,9 @@ * 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. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor; import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element; @@ -25,17 +24,13 @@ import org.openecomp.convertor.ElementConvertor; import org.openecomp.core.utilities.file.FileUtils; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity; -public class ElementToNicQuestionnaireConvertor extends ElementConvertor <NicEntity>{ - - @Override - public NicEntity convert( Element element) { - NicEntity nicEntity = new NicEntity(); - - nicEntity.setId(element.getElementId().getValue()); - nicEntity.setQuestionnaireData( element.getData() == null - ? null - : new String(FileUtils.toByteArray(element.getData()))); - return nicEntity; - } +public class ElementToNicQuestionnaireConvertor extends ElementConvertor<NicEntity> { + @Override + public NicEntity convert(Element element) { + NicEntity nicEntity = new NicEntity(); + nicEntity.setId(element.getElementId().getValue()); + nicEntity.setQuestionnaireData(element.getData() == null ? null : new String(FileUtils.toByteArray(element.getData()))); + return nicEntity; + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToOrchestrationTemplateCandidateMapConvertor.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToOrchestrationTemplateCandidateMapConvertor.java index de9cc520b3..653c561ca6 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToOrchestrationTemplateCandidateMapConvertor.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToOrchestrationTemplateCandidateMapConvertor.java @@ -7,9 +7,9 @@ * 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. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor; import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element; @@ -29,12 +28,10 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.FilesDataStru /** * Created by ayalaben on 9/6/2017 */ -public class ElementToOrchestrationTemplateCandidateMapConvertor - extends ElementConvertor<FilesDataStructure> { +public class ElementToOrchestrationTemplateCandidateMapConvertor extends ElementConvertor<FilesDataStructure> { - @Override - public FilesDataStructure convert(Element element) { - return JsonUtil.json2Object(new String(FileUtils.toByteArray(element.getData())), - FilesDataStructure.class); - } + @Override + public FilesDataStructure convert(Element element) { + return JsonUtil.json2Object(new String(FileUtils.toByteArray(element.getData())), FilesDataStructure.class); + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToProcessConvertor.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToProcessConvertor.java index ec8aa172bd..d14f870eac 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToProcessConvertor.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToProcessConvertor.java @@ -7,9 +7,9 @@ * 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. @@ -17,55 +17,51 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor; import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element; import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo; import com.amdocs.zusammen.datatypes.item.Info; +import java.nio.ByteBuffer; import org.openecomp.convertor.ElementConvertor; import org.openecomp.core.utilities.file.FileUtils; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessType; -import java.nio.ByteBuffer; - public class ElementToProcessConvertor extends ElementConvertor<ProcessEntity> { - public static final String NAME = "name"; - public static final String ARTIFACT_NAME = "artifactName"; - public static final String DESCRIPTION = "description"; - public static final String PROCESS_TYPE = "processType"; + public static final String NAME = "name"; + public static final String ARTIFACT_NAME = "artifactName"; + public static final String DESCRIPTION = "description"; + public static final String PROCESS_TYPE = "processType"; - @Override - public ProcessEntity convert(Element element) { - if (element == null) { - return null; + @Override + public ProcessEntity convert(Element element) { + if (element == null) { + return null; + } + ProcessEntity processEntity = new ProcessEntity(); + processEntity.setId(element.getElementId().getValue()); + processEntity.setArtifact(ByteBuffer.wrap(FileUtils.toByteArray(element.getData()))); + mapInfoToProcessEntity(processEntity, element.getInfo()); + return processEntity; } - ProcessEntity processEntity = new ProcessEntity(); - processEntity.setId(element.getElementId().getValue()); - processEntity.setArtifact(ByteBuffer.wrap(FileUtils.toByteArray(element.getData()))); - mapInfoToProcessEntity(processEntity, element.getInfo()); - return processEntity; - } - @Override - public ProcessEntity convert(ElementInfo elementInfo) { - if (elementInfo == null) { - return null; + @Override + public ProcessEntity convert(ElementInfo elementInfo) { + if (elementInfo == null) { + return null; + } + ProcessEntity processEntity = new ProcessEntity(); + processEntity.setId(elementInfo.getId().getValue()); + mapInfoToProcessEntity(processEntity, elementInfo.getInfo()); + return processEntity; } - ProcessEntity processEntity = new ProcessEntity(); - processEntity.setId(elementInfo.getId().getValue()); - mapInfoToProcessEntity(processEntity, elementInfo.getInfo()); - return processEntity; - } - public void mapInfoToProcessEntity(ProcessEntity processEntity, Info info) { - processEntity.setName(info.getProperty(NAME)); - processEntity.setArtifactName(info.getProperty(ARTIFACT_NAME)); - processEntity.setDescription(info.getProperty(DESCRIPTION)); - processEntity.setType(info.getProperty - (PROCESS_TYPE) != null ? ProcessType.valueOf(info.getProperty - (PROCESS_TYPE)) : null); - } + public void mapInfoToProcessEntity(ProcessEntity processEntity, Info info) { + processEntity.setName(info.getProperty(NAME)); + processEntity.setArtifactName(info.getProperty(ARTIFACT_NAME)); + processEntity.setDescription(info.getProperty(DESCRIPTION)); + processEntity.setType(info.getProperty(PROCESS_TYPE) != null ? ProcessType.valueOf(info.getProperty(PROCESS_TYPE)) : null); + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToServiceModelMapConvertor.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToServiceModelMapConvertor.java index 574d3b30f6..e6a151a6c3 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToServiceModelMapConvertor.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToServiceModelMapConvertor.java @@ -7,9 +7,9 @@ * 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. @@ -17,24 +17,23 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor; import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element; -import org.openecomp.convertor.ElementConvertor; - import java.util.HashMap; import java.util.Map; +import org.openecomp.convertor.ElementConvertor; /** * Created by ayalaben on 9/11/2017 */ -public class ElementToServiceModelMapConvertor extends ElementConvertor<Map<String ,String>> { - @Override - public Map<String ,String> convert(Element element) { - //TODO : after merge with 1802 change to heat fle name/TOSCA file name - HashMap<String,String> map = new HashMap<>(); - map.put("Service Model Definition Entry", element.getInfo().getProperty("base")); - return map; - } +public class ElementToServiceModelMapConvertor extends ElementConvertor<Map<String, String>> { + + @Override + public Map<String, String> convert(Element element) { + //TODO : after merge with 1802 change to heat fle name/TOSCA file name + HashMap<String, String> map = new HashMap<>(); + map.put("Service Model Definition Entry", element.getInfo().getProperty("base")); + return map; + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToVSPGeneralConvertor.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToVSPGeneralConvertor.java index d8bb1798ff..8234eeeaf1 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToVSPGeneralConvertor.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToVSPGeneralConvertor.java @@ -7,9 +7,9 @@ * 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. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor; import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element; @@ -29,72 +28,51 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.VendorSoftwareP import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails; import org.openecomp.sdc.versioning.dao.types.Version; - public class ElementToVSPGeneralConvertor extends ElementConvertor { - @Override - public VspDetails convert(Element element) { - if (element == null) { - return null; - } - return mapInfoToVspDetails(element.getInfo()); - } - - @Override - public VspDetails convert(Item item) { - if (item == null) { - return null; + @Override + public VspDetails convert(Element element) { + if (element == null) { + return null; + } + return mapInfoToVspDetails(element.getInfo()); } - VspDetails vspDetails = mapInfoToVspDetails(item.getInfo()); - vspDetails.setId(item.getId().getValue()); - return vspDetails; - } - @Override - public VspDetails convert(ElementInfo elementInfo) { - if (elementInfo == null) { - return null; + @Override + public VspDetails convert(Item item) { + if (item == null) { + return null; + } + VspDetails vspDetails = mapInfoToVspDetails(item.getInfo()); + vspDetails.setId(item.getId().getValue()); + return vspDetails; } - return mapInfoToVspDetails(elementInfo.getInfo()); - - } - - private VspDetails mapInfoToVspDetails(Info info) { - - VspDetails vspDetails = new VspDetails(); - - vspDetails.setName(info.getProperty(VendorSoftwareProductInfoDaoZusammenImpl - .InfoPropertyName.NAME.getValue())); - vspDetails.setDescription(info.getProperty( - VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.DESCRIPTION.getValue())); - vspDetails.setIcon(info.getProperty( - VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.ICON.getValue())); - vspDetails.setCategory(info.getProperty( - VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.CATEGORY.getValue())); - vspDetails.setSubCategory(info.getProperty( - VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.SUB_CATEGORY.getValue())); - vspDetails.setVendorId(info.getProperty( - VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.VENDOR_ID.getValue())); - vspDetails.setVendorName(info.getProperty( - VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.VENDOR_NAME.getValue())); - if (info.getProperty( - VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.VENDOR_VERSION.getValue()) != null) { - vspDetails.setVlmVersion(new Version(info.getProperty( - VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.VENDOR_VERSION.getValue()))); + @Override + public VspDetails convert(ElementInfo elementInfo) { + if (elementInfo == null) { + return null; + } + return mapInfoToVspDetails(elementInfo.getInfo()); } - vspDetails.setLicenseType(info.getProperty( - VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.LICENSE_TYPE.getValue())); - vspDetails.setLicenseAgreement(info.getProperty( - VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.LICENSE_AGREEMENT.getValue())); - vspDetails.setFeatureGroups(info.getProperty( - VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.FEATURE_GROUPS.getValue())); - vspDetails.setOnboardingMethod(info.getProperty( - VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.ON_BOARDING_METHOD.getValue())); - - return vspDetails; - } - - + private VspDetails mapInfoToVspDetails(Info info) { + VspDetails vspDetails = new VspDetails(); + vspDetails.setName(info.getProperty(VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.NAME.getValue())); + vspDetails.setDescription(info.getProperty(VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.DESCRIPTION.getValue())); + vspDetails.setIcon(info.getProperty(VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.ICON.getValue())); + vspDetails.setCategory(info.getProperty(VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.CATEGORY.getValue())); + vspDetails.setSubCategory(info.getProperty(VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.SUB_CATEGORY.getValue())); + vspDetails.setVendorId(info.getProperty(VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.VENDOR_ID.getValue())); + vspDetails.setVendorName(info.getProperty(VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.VENDOR_NAME.getValue())); + if (info.getProperty(VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.VENDOR_VERSION.getValue()) != null) { + vspDetails + .setVlmVersion(new Version(info.getProperty(VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.VENDOR_VERSION.getValue()))); + } + vspDetails.setLicenseType(info.getProperty(VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.LICENSE_TYPE.getValue())); + vspDetails.setLicenseAgreement(info.getProperty(VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.LICENSE_AGREEMENT.getValue())); + vspDetails.setFeatureGroups(info.getProperty(VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.FEATURE_GROUPS.getValue())); + vspDetails.setOnboardingMethod(info.getProperty(VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.ON_BOARDING_METHOD.getValue())); + return vspDetails; + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToVSPQuestionnaireConvertor.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToVSPQuestionnaireConvertor.java index b8797cf8e2..71a2b4782d 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToVSPQuestionnaireConvertor.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToVSPQuestionnaireConvertor.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor; import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element; @@ -23,11 +22,10 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspQuestionnaireEntity; public class ElementToVSPQuestionnaireConvertor extends ElementConvertor { - @Override - public VspQuestionnaireEntity convert(Element element) { - VspQuestionnaireEntity entity = new VspQuestionnaireEntity(); - entity.setQuestionnaireData( - element == null ? "{}" : new String(FileUtils.toByteArray(element.getData()))); - return entity; - } + @Override + public VspQuestionnaireEntity convert(Element element) { + VspQuestionnaireEntity entity = new VspQuestionnaireEntity(); + entity.setQuestionnaireData(element == null ? "{}" : new String(FileUtils.toByteArray(element.getData()))); + return entity; + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/VendorSoftwareProductErrorCodes.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/VendorSoftwareProductErrorCodes.java index 83abbfb123..13ade278bf 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/VendorSoftwareProductErrorCodes.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/VendorSoftwareProductErrorCodes.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.openecomp.sdc.vendorsoftwareproduct.errors; /** @@ -21,110 +20,64 @@ package org.openecomp.sdc.vendorsoftwareproduct.errors; */ public class VendorSoftwareProductErrorCodes { - public static final String VSP_NOT_FOUND = "VSP_NOT_FOUND"; - public static final String VSP_INVALID = "VSP_INVALID"; - public static final String VFC_INVALID = "VFC_INVALID"; - public static final String FAILED_TO_CREATE_VSP = "FAILED_TO_CREATE_VSP"; - - public static final String UPLOAD_INVALID = "UPLOAD_INVALID"; - - public static final String PACKAGE_NOT_FOUND = "PACKAGE_NOT_FOUND"; - - public static final String PACKAGE_INVALID = "PACKAGE_INVALID"; - public static final String VSP_COMPOSITION_EDIT_NOT_ALLOWED = "VSP_COMPOSITION_EDIT_NOT_ALLOWED"; - - public static final String CREATE_PACKAGE_FOR_NON_FINAL_VSP = "CREATE_PACKAGE_FOR_NON_FINAL_VSP"; - - public static final String TRANSLATION_FILE_CREATION = "TRANSLATION_FILE_CREATION"; - - public static final String HEAT_PACKAGE_FILE_CREATION = "HEAT_PACKAGE_FILE_CREATION"; - - public static final String TOSCA_ENTRY_NOT_FOUND = "TOSCA_ENTRY_NOT_FOUND"; - public static final String TOSCA_INVALID_SUBSTITUTE_NODE_TEMPLATE = - "TOSCA_INVALID_SUBSTITUTE_NODE_TEMPLATE"; - - public static final String MONITORING_UPLOAD_INVALID = "MONITORING_UPLOAD_INVALID"; - - public static final String ORCHESTRATION_NOT_FOUND = "ORCHESTRATION_NOT_FOUND"; - - - public static final String CYCLIC_DEPENDENCY_IN_COMPONENTS = "CYCLIC_DEPENDENCY_IN_COMPONENTS"; - - public static final String INVALID_COMPONENT_RELATION_TYPE = "INVALID_COMPONENT_RELATION_TYPE"; - - public static final String NO_SOURCE_COMPONENT = "NO_SOURCE_COMPONENT"; - - public static final String SAME_SOURCE_TARGET_COMPONENT = "SAME_SOURCE_TARGET_COMPONENT"; - - public static final String DUPLICATE_NIC_NAME_NOT_ALLOWED = "DUPLICATE_NIC_NAME_NOT_ALLOWED"; - public static final String NIC_NAME_FORMAT_NOT_ALLOWED = "NIC_NAME_FORMAT_NOT_ALLOWED"; - - public static final String NULL_NETWORKID_NOT_ALLOWED = "NULL_NETWORKID_NOT_ALLOWED"; - - public static final String NETWORKID_NOT_ALLOWED_FOR_EXTERNAL_NETWORK = - "NETWORKID_NOT_ALLOWED_FOR_EXTERNAL_NETWORK"; - - public static final String VFC_ADD_NOT_ALLOWED_IN_HEAT_ONBOARDING = - "VFC_ADD_NOT_ALLOWED_IN_HEAT_ONBOARDING"; - public static final String VSP_VFC_COUNT_EXCEED = "VSP_VFC_COUNT_EXCEED"; - public static final String VSP_VFC_DUPLICATE_NAME = "VSP_VFC_DUPLICATE_NAME"; - public static final String VSP_INVALID_ONBOARDING_METHOD = "VSP_INVALID_ONBOARDING_METHOD"; - public static final String - ADD_NIC_NOT_ALLOWED_IN_HEAT_ONBOARDING = "ADD_NIC_NOT_ALLOWED_IN_HEAT_ONBOARDING"; - public static final String NETWORK_DESCRIPTION_NOT_ALLOWED_FOR_INTERNAL_NETWORK - = "NETWORK_DESCRIPTION_NOT_ALLOWED_FOR_INTERNAL_NETWORK"; - - public static final String VFC_ATTRIBUTE_UPDATE_NOT_ALLOWED = - "VFC_ATTRIBUTE_UPDATE_NOT_ALLOWED"; - public static final String NETWORK_TYPE_UPDATE_NOT_ALLOWED - = "NETWORK_TYPE_UPDATE_NOT_ALLOWED"; - public static final String DELETE_NIC_NOT_ALLOWED = "DELETE_NIC_NOT_ALLOWED"; - - public static final String CREATE_DEPLOYMENT_FLAVOR_NOT_ALLOWED_IN_HEAT_ONBOARDING = - "CREATE_DEPLOYMENT_FLAVOR_NOT_ALLOWED_IN_HEAT_ONBOARDING"; - - public static final String DELETE_DEPLOYMENT_FLAVOR_NOT_ALLOWED_IN_HEAT_ONBOARDING = - "DELETE_DEPLOYMENT_FLAVOR_NOT_ALLOWED_IN_HEAT_ONBOARDING"; - - public static final String EDIT_DEPLOYMENT_FLAVOR_NOT_ALLOWED_IN_HEAT_ONBOARDING = - "EDIT_DEPLOYMENT_FLAVOR_NOT_ALLOWED_IN_HEAT_ONBOARDING"; - - public static final String FEATUREGROUP_REQUIRED_IN_DEPLOYMENT_FLAVOR = - "FEATUREGROUP_REQUIRED_IN_DEPLOYMENT_FLAVOR"; - - public static final String - ADD_IMAGE_NOT_ALLOWED_IN_HEAT_ONBOARDING = "ADD_IMAGE_NOT_ALLOWED_IN_HEAT_ONBOARDING"; - - public static final String DUPLICATE_IMAGE_NAME_NOT_ALLOWED = "DUPLICATE_IMAGE_NAME_NOT_ALLOWED"; - public static final String DUPLICATE_IMAGE_VERSION_NOT_ALLOWED = "DUPLICATE_IMAGE_VERSION_NOT_ALLOWED"; - public static final String IMAGE_NAME_FORMAT_NOT_ALLOWED = "IMAGE_NAME_FORMAT_NOT_ALLOWED"; - public static final String VFC_IMAGE_INVALID_FORMAT = "VFC_IMAGE_INVALID_FORMAT"; - public static final String FEATURE_GROUP_NOT_EXIST_FOR_VSP = "FEATURE_GROUP_NOT_EXIST_FOR_VSP"; - - public static final String - ADD_COMPUTE_NOT_ALLOWED_IN_HEAT_ONBOARDING = "ADD_COMPUTE_NOT_ALLOWED_IN_HEAT_ONBOARDING"; - public static final String VFC_COMPUTE_INVALID_FORMAT = "VFC_COMPUTE_INVALID_FORMAT"; - public static final String UPDATE_COMPUTE_NOT_ALLOWED = "UPDATE_COMPUTE_NOT_ALLOWED"; - public static final String - INVALID_COMPONENT_COMPUTE_ASSOCIATION = "INVALID_COMPONENT_COMPUTE_ASSOCIATION"; - public static final String SAME_VFC_ASSOCIATION_MORE_THAN_ONCE_NOT_ALLOWED - = "SAME_VFC_ASSOCIATION_MORE_THAN_ONCE_NOT_ALLOWED"; - public static final String DUPLICATE_DEPLOYMENT_FLAVOR_MODEL_NOT_ALLOWED - = "DUPLICATE_DEPLOYMENT_FLAVOR_MODEL_NOT_ALLOWED"; - public static final String DEPLOYMENT_FLAVOR_NAME_FORMAT_NOT_ALLOWED = - "DEPLOYMENT_FLAVOR_NAME_FORMAT_NOT_ALLOWED"; - public static final String INVALID_COMPUTE_FLAVOR_ID = "INVALID_COMPUTE_FLAVOR_ID"; - public static final String INVALID_COMPONENT_ID = "INVALID_COMPONENT_ID"; - public static final String DUPLICATE_COMPUTE_NAME_NOT_ALLOWED = "DUPLICATE_COMPUTE_NAME_NOT_ALLOWED"; - public static final String COMPUTE_NAME_FORMAT_NOT_ALLOWED = "COMPUTE_NAME_FORMAT_NOT_ALLOWED"; - - public static final String DELETE_IMAGE_NOT_ALLOWED = "DELETE_IMAGE_NOT_ALLOWED"; - public static final String UPDATE_IMAGE_NOT_ALLOWED = "UPDATE_IMAGE_NOT_ALLOWED"; - - public static final String INVALID_EXTENSION = "INVALID_EXTENSION"; - - public static final String VSP_ONBOARD_METHOD_UPDATE_NOT_ALLOWED = - "VSP_ONBOARD_METHOD_UPDATE_NOT_ALLOWED"; - - private VendorSoftwareProductErrorCodes(){} + public static final String VSP_NOT_FOUND = "VSP_NOT_FOUND"; + public static final String VSP_INVALID = "VSP_INVALID"; + public static final String VFC_INVALID = "VFC_INVALID"; + public static final String FAILED_TO_CREATE_VSP = "FAILED_TO_CREATE_VSP"; + public static final String UPLOAD_INVALID = "UPLOAD_INVALID"; + public static final String PACKAGE_NOT_FOUND = "PACKAGE_NOT_FOUND"; + public static final String PACKAGE_INVALID = "PACKAGE_INVALID"; + public static final String VSP_COMPOSITION_EDIT_NOT_ALLOWED = "VSP_COMPOSITION_EDIT_NOT_ALLOWED"; + public static final String CREATE_PACKAGE_FOR_NON_FINAL_VSP = "CREATE_PACKAGE_FOR_NON_FINAL_VSP"; + public static final String TRANSLATION_FILE_CREATION = "TRANSLATION_FILE_CREATION"; + public static final String HEAT_PACKAGE_FILE_CREATION = "HEAT_PACKAGE_FILE_CREATION"; + public static final String TOSCA_ENTRY_NOT_FOUND = "TOSCA_ENTRY_NOT_FOUND"; + public static final String TOSCA_INVALID_SUBSTITUTE_NODE_TEMPLATE = "TOSCA_INVALID_SUBSTITUTE_NODE_TEMPLATE"; + public static final String MONITORING_UPLOAD_INVALID = "MONITORING_UPLOAD_INVALID"; + public static final String ORCHESTRATION_NOT_FOUND = "ORCHESTRATION_NOT_FOUND"; + public static final String CYCLIC_DEPENDENCY_IN_COMPONENTS = "CYCLIC_DEPENDENCY_IN_COMPONENTS"; + public static final String INVALID_COMPONENT_RELATION_TYPE = "INVALID_COMPONENT_RELATION_TYPE"; + public static final String NO_SOURCE_COMPONENT = "NO_SOURCE_COMPONENT"; + public static final String SAME_SOURCE_TARGET_COMPONENT = "SAME_SOURCE_TARGET_COMPONENT"; + public static final String DUPLICATE_NIC_NAME_NOT_ALLOWED = "DUPLICATE_NIC_NAME_NOT_ALLOWED"; + public static final String NIC_NAME_FORMAT_NOT_ALLOWED = "NIC_NAME_FORMAT_NOT_ALLOWED"; + public static final String NULL_NETWORKID_NOT_ALLOWED = "NULL_NETWORKID_NOT_ALLOWED"; + public static final String NETWORKID_NOT_ALLOWED_FOR_EXTERNAL_NETWORK = "NETWORKID_NOT_ALLOWED_FOR_EXTERNAL_NETWORK"; + public static final String VFC_ADD_NOT_ALLOWED_IN_HEAT_ONBOARDING = "VFC_ADD_NOT_ALLOWED_IN_HEAT_ONBOARDING"; + public static final String VSP_VFC_COUNT_EXCEED = "VSP_VFC_COUNT_EXCEED"; + public static final String VSP_VFC_DUPLICATE_NAME = "VSP_VFC_DUPLICATE_NAME"; + public static final String VSP_INVALID_ONBOARDING_METHOD = "VSP_INVALID_ONBOARDING_METHOD"; + public static final String ADD_NIC_NOT_ALLOWED_IN_HEAT_ONBOARDING = "ADD_NIC_NOT_ALLOWED_IN_HEAT_ONBOARDING"; + public static final String NETWORK_DESCRIPTION_NOT_ALLOWED_FOR_INTERNAL_NETWORK = "NETWORK_DESCRIPTION_NOT_ALLOWED_FOR_INTERNAL_NETWORK"; + public static final String VFC_ATTRIBUTE_UPDATE_NOT_ALLOWED = "VFC_ATTRIBUTE_UPDATE_NOT_ALLOWED"; + public static final String NETWORK_TYPE_UPDATE_NOT_ALLOWED = "NETWORK_TYPE_UPDATE_NOT_ALLOWED"; + public static final String DELETE_NIC_NOT_ALLOWED = "DELETE_NIC_NOT_ALLOWED"; + public static final String CREATE_DEPLOYMENT_FLAVOR_NOT_ALLOWED_IN_HEAT_ONBOARDING = "CREATE_DEPLOYMENT_FLAVOR_NOT_ALLOWED_IN_HEAT_ONBOARDING"; + public static final String DELETE_DEPLOYMENT_FLAVOR_NOT_ALLOWED_IN_HEAT_ONBOARDING = "DELETE_DEPLOYMENT_FLAVOR_NOT_ALLOWED_IN_HEAT_ONBOARDING"; + public static final String EDIT_DEPLOYMENT_FLAVOR_NOT_ALLOWED_IN_HEAT_ONBOARDING = "EDIT_DEPLOYMENT_FLAVOR_NOT_ALLOWED_IN_HEAT_ONBOARDING"; + public static final String FEATUREGROUP_REQUIRED_IN_DEPLOYMENT_FLAVOR = "FEATUREGROUP_REQUIRED_IN_DEPLOYMENT_FLAVOR"; + public static final String ADD_IMAGE_NOT_ALLOWED_IN_HEAT_ONBOARDING = "ADD_IMAGE_NOT_ALLOWED_IN_HEAT_ONBOARDING"; + public static final String DUPLICATE_IMAGE_NAME_NOT_ALLOWED = "DUPLICATE_IMAGE_NAME_NOT_ALLOWED"; + public static final String DUPLICATE_IMAGE_VERSION_NOT_ALLOWED = "DUPLICATE_IMAGE_VERSION_NOT_ALLOWED"; + public static final String IMAGE_NAME_FORMAT_NOT_ALLOWED = "IMAGE_NAME_FORMAT_NOT_ALLOWED"; + public static final String VFC_IMAGE_INVALID_FORMAT = "VFC_IMAGE_INVALID_FORMAT"; + public static final String FEATURE_GROUP_NOT_EXIST_FOR_VSP = "FEATURE_GROUP_NOT_EXIST_FOR_VSP"; + public static final String ADD_COMPUTE_NOT_ALLOWED_IN_HEAT_ONBOARDING = "ADD_COMPUTE_NOT_ALLOWED_IN_HEAT_ONBOARDING"; + public static final String VFC_COMPUTE_INVALID_FORMAT = "VFC_COMPUTE_INVALID_FORMAT"; + public static final String UPDATE_COMPUTE_NOT_ALLOWED = "UPDATE_COMPUTE_NOT_ALLOWED"; + public static final String INVALID_COMPONENT_COMPUTE_ASSOCIATION = "INVALID_COMPONENT_COMPUTE_ASSOCIATION"; + public static final String SAME_VFC_ASSOCIATION_MORE_THAN_ONCE_NOT_ALLOWED = "SAME_VFC_ASSOCIATION_MORE_THAN_ONCE_NOT_ALLOWED"; + public static final String DUPLICATE_DEPLOYMENT_FLAVOR_MODEL_NOT_ALLOWED = "DUPLICATE_DEPLOYMENT_FLAVOR_MODEL_NOT_ALLOWED"; + public static final String DEPLOYMENT_FLAVOR_NAME_FORMAT_NOT_ALLOWED = "DEPLOYMENT_FLAVOR_NAME_FORMAT_NOT_ALLOWED"; + public static final String INVALID_COMPUTE_FLAVOR_ID = "INVALID_COMPUTE_FLAVOR_ID"; + public static final String INVALID_COMPONENT_ID = "INVALID_COMPONENT_ID"; + public static final String DUPLICATE_COMPUTE_NAME_NOT_ALLOWED = "DUPLICATE_COMPUTE_NAME_NOT_ALLOWED"; + public static final String COMPUTE_NAME_FORMAT_NOT_ALLOWED = "COMPUTE_NAME_FORMAT_NOT_ALLOWED"; + public static final String DELETE_IMAGE_NOT_ALLOWED = "DELETE_IMAGE_NOT_ALLOWED"; + public static final String UPDATE_IMAGE_NOT_ALLOWED = "UPDATE_IMAGE_NOT_ALLOWED"; + public static final String INVALID_EXTENSION = "INVALID_EXTENSION"; + public static final String VSP_ONBOARD_METHOD_UPDATE_NOT_ALLOWED = "VSP_ONBOARD_METHOD_UPDATE_NOT_ALLOWED"; + + private VendorSoftwareProductErrorCodes() { + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/InformationArtifactGeneratorFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/InformationArtifactGeneratorFactoryImpl.java index df5e44122d..90019a2467 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/InformationArtifactGeneratorFactoryImpl.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/InformationArtifactGeneratorFactoryImpl.java @@ -7,9 +7,9 @@ * 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. @@ -17,18 +17,15 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.factory; - import org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.InformationArtifactGenerator; import org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.impl.TxtInformationArtifactGeneratorImpl; - public class InformationArtifactGeneratorFactoryImpl extends InformationArtifactGeneratorFactory { - @Override - public InformationArtifactGenerator createInterface() { - return new TxtInformationArtifactGeneratorImpl(); - } + @Override + public InformationArtifactGenerator createInterface() { + return new TxtInformationArtifactGeneratorImpl(); + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/QuestionnaireDataServiceFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/QuestionnaireDataServiceFactoryImpl.java index 865c7f1189..3c0cbe5ff3 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/QuestionnaireDataServiceFactoryImpl.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/QuestionnaireDataServiceFactoryImpl.java @@ -7,9 +7,9 @@ * 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. @@ -17,18 +17,15 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.factory; - import org.openecomp.sdc.vendorsoftwareproduct.questionnaire.QuestionnaireDataService; import org.openecomp.sdc.vendorsoftwareproduct.quiestionnaire.QuestionnaireDataServiceImpl; - public class QuestionnaireDataServiceFactoryImpl extends QuestionnnaireDataServiceFactory { - @Override - public QuestionnaireDataService createInterface() { - return new QuestionnaireDataServiceImpl(); - } + @Override + public QuestionnaireDataService createInterface() { + return new QuestionnaireDataServiceImpl(); + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/impl/CandidateServiceFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/impl/CandidateServiceFactoryImpl.java index b98605a53d..b777b586d0 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/impl/CandidateServiceFactoryImpl.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/impl/CandidateServiceFactoryImpl.java @@ -7,9 +7,9 @@ * 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. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.factory.impl; import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.OrchestrationTemplateCandidateDaoFactoryImpl; @@ -26,12 +25,11 @@ import org.openecomp.sdc.vendorsoftwareproduct.factory.ManifestCreatorFactory; import org.openecomp.sdc.vendorsoftwareproduct.services.filedatastructuremodule.CandidateService; import org.openecomp.sdc.vendorsoftwareproduct.services.impl.filedatastructuremodule.CandidateServiceImpl; - public class CandidateServiceFactoryImpl extends CandidateServiceFactory { - @Override - public CandidateService createInterface() { - return new CandidateServiceImpl(ManifestCreatorFactory.getInstance().createInterface(), - OrchestrationTemplateCandidateDaoFactoryImpl.getInstance().createInterface()); - } + @Override + public CandidateService createInterface() { + return new CandidateServiceImpl(ManifestCreatorFactory.getInstance().createInterface(), + OrchestrationTemplateCandidateDaoFactoryImpl.getInstance().createInterface()); + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/impl/CompositionDataExtractorFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/impl/CompositionDataExtractorFactoryImpl.java index 21b0d9c0a8..fe0e82e9f4 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/impl/CompositionDataExtractorFactoryImpl.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/impl/CompositionDataExtractorFactoryImpl.java @@ -7,9 +7,9 @@ * 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. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.factory.impl; import org.openecomp.sdc.vendorsoftwareproduct.factory.CompositionDataExtractorFactory; @@ -26,8 +25,8 @@ import org.openecomp.sdc.vendorsoftwareproduct.services.impl.composition.Composi public class CompositionDataExtractorFactoryImpl extends CompositionDataExtractorFactory { - @Override - public CompositionDataExtractor createInterface() { - return new CompositionDataExtractorImpl(); - } + @Override + public CompositionDataExtractor createInterface() { + return new CompositionDataExtractorImpl(); + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/impl/ManifestCreatorFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/impl/ManifestCreatorFactoryImpl.java index c7d088408e..6700fe977c 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/impl/ManifestCreatorFactoryImpl.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/impl/ManifestCreatorFactoryImpl.java @@ -7,9 +7,9 @@ * 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. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.factory.impl; import org.openecomp.sdc.vendorsoftwareproduct.factory.ManifestCreatorFactory; @@ -29,8 +28,8 @@ import org.openecomp.sdc.vendorsoftwareproduct.services.impl.filedatastructuremo */ public class ManifestCreatorFactoryImpl extends ManifestCreatorFactory { - @Override - public ManifestCreator createInterface(){ - return new ManifestCreatorNamingConventionImpl(); - } + @Override + public ManifestCreator createInterface() { + return new ManifestCreatorNamingConventionImpl(); + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/informationArtifact/impl/TxtInformationArtifactConstants.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/informationArtifact/impl/TxtInformationArtifactConstants.java index 4fee8aec75..28575c77c0 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/informationArtifact/impl/TxtInformationArtifactConstants.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/informationArtifact/impl/TxtInformationArtifactConstants.java @@ -7,9 +7,9 @@ * 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. @@ -17,81 +17,68 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.impl; /** * @author KATYR * @since December 07, 2016 */ - public class TxtInformationArtifactConstants { - public static final String QUOTEMARK = "\""; - public static final String SPACE = " "; - public static final String TAB = SPACE + SPACE + SPACE + SPACE; - public static final String NL = System.lineSeparator(); - public static final String DELIMITER = ":"; - public static final String FOUR_TABS = TAB + TAB + TAB + TAB; - - - public static final String TITLE = "1." + TAB + "VSP Details" + DELIMITER; - public static final String VSP_NAME = "a." + TAB + "Name" + DELIMITER; - public static final String VSP_DESC = "b." + TAB + "Description"; - public static final String VSP_VENDOR = "d." + TAB + "Vendor" + DELIMITER; - public static final String VSP_VERSION = "c." + TAB + "Version" + DELIMITER; - public static final String VSP_CATEGORY = "e." + TAB + "Category" + DELIMITER; - public static final String LICENSE_DETAILS = "f." + TAB + "License Details" + DELIMITER; - public static final String LICENSE_MODEL_VERSION = - "i." + TAB + "License Model Version" + DELIMITER; - public static final String LICENSE_AGREEMENT_NAME = - "ii." + TAB + "License Agreement Name" + DELIMITER; - public static final String LIST_OF_FEATURE_GROUPS = "iii" + TAB + "List of Feature Groups"+DELIMITER; - public static final String HIGH_AVAILABILITY = "g." + TAB + "High Availability"; - public static final String USING_AVAILABILITY_ZONES = "i." + TAB + "Using Availability " - + "Zones" + DELIMITER; - public static final String STORAGE_BACKUP_DETAILS = "h." + TAB + "Storage Data Back-up " - + "Details" + DELIMITER; - public static final String IS_DATA_REPLICATION = - "i." + TAB + "Data Replication Required?" + DELIMITER; - public static final String DATA_SIZE_TO_REP = - "ii." + TAB + " Data Size to replicate in GB" + DELIMITER; - public static final String DATA_REP_FREQUENCY = - "iii." + TAB + "Data replication frequency" + DELIMITER; - public static final String DATA_REP_SOURCE = "iv." + TAB + "Replication Source" + DELIMITER; - public static final String DATA_REP_DEST = "v." + TAB + "Replication Destination" + DELIMITER; - public static final String LIST_OF_NETWORKS = "List of Internal Networks";//currently not used - public static final String LIST_OF_VFCS = "3." + TAB + "List of VFCs"; - public static final String FOR_EACH_VFC = "a." + TAB + "For each VFC" + DELIMITER; - public static final String VFC_NAME = "i." + TAB + "VFC Name" + DELIMITER; - public static final String VFC_DESC = "ii." + TAB + "Description" + DELIMITER; - public static final String VFC_IMAGES = "iii." + TAB + "Images" + DELIMITER; - public static final String VFC_COMPUTE = "iv." + TAB + "Compute/VM Characteristics"; - public static final String VFC_COMPUTE_VCPU = "1." + TAB + "vCPU" + DELIMITER; - public static final String VFC_COMPUTE_CPU_OVER_SUBSCRIPTION = "2." + TAB + "CPU " - + "over-subscription" + DELIMITER; - public static final String VFC_COMPUTE_MEMORY = "3." + TAB + "Memory" + DELIMITER; - public static final String VFC_COMPUTE_DISK = "4." + TAB + "Disk" + DELIMITER; - public static final String HYPERVISOR_DETAILS = "v." + TAB + "Hypervisor Details"; - public static final String HYPERVISOR_DETAILS_NAME = "1." + TAB + "Name" + DELIMITER; - public static final String HYPERVISOR_DETAILS_DRIVERS = "2." + TAB + "Drivers" + DELIMITER; - public static final String GUEST_OS_DETAILS = "vi." + TAB + "Guest OS Details"; - public static final String GUEST_OS_NAME = "1." + TAB + "Name" + DELIMITER; - public static final String GUEST_OS_BIT_SIZE = "2." + TAB + "Bit Size" + DELIMITER; - public static final String GUEST_OS_TOOLS = "3." + TAB + "Tools" + DELIMITER; - public static final String VFC_INSTANCE_NUMBER = "vii." + TAB + "Number of VFC Instances"; - public static final String VFC_INSTANCE_NUMBER_MIN = "1." + TAB + "Minimum" + DELIMITER; - public static final String VFC_INSTANCE_NUMBER_MAX = "2." + TAB + "Maximum" + DELIMITER; - public static final String VNICS = "viii." + TAB + "vNICs"; - public static final String VNICS_NAME = "1." + TAB + "Name" + DELIMITER; - public static final String VNICS_PURPOSE = "2." + TAB + "Purpose" + DELIMITER; - public static final String VNICS_INT_EXT = "3." + TAB + "Internal/External" + DELIMITER; - public static final String VNICS_NETWORK = "4." + TAB + "Network" + DELIMITER; - public static final String VNICS_PROTOCOLS = "5." + TAB + "Protocols" + DELIMITER; - public static final String VNICS_IPV4 = "6." + TAB + "IP v4 Required" + DELIMITER; - public static final String VNICS_IPV6 = "7." + TAB + "IP v6 Required" + DELIMITER; - public static final String RECOVERY_DETAILS = "ix." + TAB + "Recovery Details" + DELIMITER; - public static final String RECOVERY_DETAILS_POINT = "1." + TAB + "Recovery Point" + DELIMITER; - public static final String RECOVERY_DETAILS_TIME = "2." + TAB + "Recovery Time" + DELIMITER; - + public static final String QUOTEMARK = "\""; + public static final String SPACE = " "; + public static final String TAB = SPACE + SPACE + SPACE + SPACE; + public static final String NL = System.lineSeparator(); + public static final String DELIMITER = ":"; + public static final String FOUR_TABS = TAB + TAB + TAB + TAB; + public static final String TITLE = "1." + TAB + "VSP Details" + DELIMITER; + public static final String VSP_NAME = "a." + TAB + "Name" + DELIMITER; + public static final String VSP_DESC = "b." + TAB + "Description"; + public static final String VSP_VENDOR = "d." + TAB + "Vendor" + DELIMITER; + public static final String VSP_VERSION = "c." + TAB + "Version" + DELIMITER; + public static final String VSP_CATEGORY = "e." + TAB + "Category" + DELIMITER; + public static final String LICENSE_DETAILS = "f." + TAB + "License Details" + DELIMITER; + public static final String LICENSE_MODEL_VERSION = "i." + TAB + "License Model Version" + DELIMITER; + public static final String LICENSE_AGREEMENT_NAME = "ii." + TAB + "License Agreement Name" + DELIMITER; + public static final String LIST_OF_FEATURE_GROUPS = "iii" + TAB + "List of Feature Groups" + DELIMITER; + public static final String HIGH_AVAILABILITY = "g." + TAB + "High Availability"; + public static final String USING_AVAILABILITY_ZONES = "i." + TAB + "Using Availability " + "Zones" + DELIMITER; + public static final String STORAGE_BACKUP_DETAILS = "h." + TAB + "Storage Data Back-up " + "Details" + DELIMITER; + public static final String IS_DATA_REPLICATION = "i." + TAB + "Data Replication Required?" + DELIMITER; + public static final String DATA_SIZE_TO_REP = "ii." + TAB + " Data Size to replicate in GB" + DELIMITER; + public static final String DATA_REP_FREQUENCY = "iii." + TAB + "Data replication frequency" + DELIMITER; + public static final String DATA_REP_SOURCE = "iv." + TAB + "Replication Source" + DELIMITER; + public static final String DATA_REP_DEST = "v." + TAB + "Replication Destination" + DELIMITER; + public static final String LIST_OF_NETWORKS = "List of Internal Networks";//currently not used + public static final String LIST_OF_VFCS = "3." + TAB + "List of VFCs"; + public static final String FOR_EACH_VFC = "a." + TAB + "For each VFC" + DELIMITER; + public static final String VFC_NAME = "i." + TAB + "VFC Name" + DELIMITER; + public static final String VFC_DESC = "ii." + TAB + "Description" + DELIMITER; + public static final String VFC_IMAGES = "iii." + TAB + "Images" + DELIMITER; + public static final String VFC_COMPUTE = "iv." + TAB + "Compute/VM Characteristics"; + public static final String VFC_COMPUTE_VCPU = "1." + TAB + "vCPU" + DELIMITER; + public static final String VFC_COMPUTE_CPU_OVER_SUBSCRIPTION = "2." + TAB + "CPU " + "over-subscription" + DELIMITER; + public static final String VFC_COMPUTE_MEMORY = "3." + TAB + "Memory" + DELIMITER; + public static final String VFC_COMPUTE_DISK = "4." + TAB + "Disk" + DELIMITER; + public static final String HYPERVISOR_DETAILS = "v." + TAB + "Hypervisor Details"; + public static final String HYPERVISOR_DETAILS_NAME = "1." + TAB + "Name" + DELIMITER; + public static final String HYPERVISOR_DETAILS_DRIVERS = "2." + TAB + "Drivers" + DELIMITER; + public static final String GUEST_OS_DETAILS = "vi." + TAB + "Guest OS Details"; + public static final String GUEST_OS_NAME = "1." + TAB + "Name" + DELIMITER; + public static final String GUEST_OS_BIT_SIZE = "2." + TAB + "Bit Size" + DELIMITER; + public static final String GUEST_OS_TOOLS = "3." + TAB + "Tools" + DELIMITER; + public static final String VFC_INSTANCE_NUMBER = "vii." + TAB + "Number of VFC Instances"; + public static final String VFC_INSTANCE_NUMBER_MIN = "1." + TAB + "Minimum" + DELIMITER; + public static final String VFC_INSTANCE_NUMBER_MAX = "2." + TAB + "Maximum" + DELIMITER; + public static final String VNICS = "viii." + TAB + "vNICs"; + public static final String VNICS_NAME = "1." + TAB + "Name" + DELIMITER; + public static final String VNICS_PURPOSE = "2." + TAB + "Purpose" + DELIMITER; + public static final String VNICS_INT_EXT = "3." + TAB + "Internal/External" + DELIMITER; + public static final String VNICS_NETWORK = "4." + TAB + "Network" + DELIMITER; + public static final String VNICS_PROTOCOLS = "5." + TAB + "Protocols" + DELIMITER; + public static final String VNICS_IPV4 = "6." + TAB + "IP v4 Required" + DELIMITER; + public static final String VNICS_IPV6 = "7." + TAB + "IP v6 Required" + DELIMITER; + public static final String RECOVERY_DETAILS = "ix." + TAB + "Recovery Details" + DELIMITER; + public static final String RECOVERY_DETAILS_POINT = "1." + TAB + "Recovery Point" + DELIMITER; + public static final String RECOVERY_DETAILS_TIME = "2." + TAB + "Recovery Time" + DELIMITER; } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/informationArtifact/impl/TxtInformationArtifactGeneratorImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/informationArtifact/impl/TxtInformationArtifactGeneratorImpl.java index e69ca8d149..7a50d9aab8 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/informationArtifact/impl/TxtInformationArtifactGeneratorImpl.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/informationArtifact/impl/TxtInformationArtifactGeneratorImpl.java @@ -7,9 +7,9 @@ * 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. @@ -17,9 +17,63 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.impl; +import static org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.impl.TxtInformationArtifactConstants.DATA_REP_DEST; +import static org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.impl.TxtInformationArtifactConstants.DATA_REP_FREQUENCY; +import static org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.impl.TxtInformationArtifactConstants.DATA_REP_SOURCE; +import static org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.impl.TxtInformationArtifactConstants.DATA_SIZE_TO_REP; +import static org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.impl.TxtInformationArtifactConstants.FOR_EACH_VFC; +import static org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.impl.TxtInformationArtifactConstants.GUEST_OS_BIT_SIZE; +import static org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.impl.TxtInformationArtifactConstants.GUEST_OS_DETAILS; +import static org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.impl.TxtInformationArtifactConstants.GUEST_OS_NAME; +import static org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.impl.TxtInformationArtifactConstants.GUEST_OS_TOOLS; +import static org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.impl.TxtInformationArtifactConstants.HIGH_AVAILABILITY; +import static org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.impl.TxtInformationArtifactConstants.HYPERVISOR_DETAILS; +import static org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.impl.TxtInformationArtifactConstants.HYPERVISOR_DETAILS_DRIVERS; +import static org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.impl.TxtInformationArtifactConstants.HYPERVISOR_DETAILS_NAME; +import static org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.impl.TxtInformationArtifactConstants.IS_DATA_REPLICATION; +import static org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.impl.TxtInformationArtifactConstants.LICENSE_AGREEMENT_NAME; +import static org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.impl.TxtInformationArtifactConstants.LICENSE_DETAILS; +import static org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.impl.TxtInformationArtifactConstants.LICENSE_MODEL_VERSION; +import static org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.impl.TxtInformationArtifactConstants.LIST_OF_FEATURE_GROUPS; +import static org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.impl.TxtInformationArtifactConstants.LIST_OF_VFCS; +import static org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.impl.TxtInformationArtifactConstants.NL; +import static org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.impl.TxtInformationArtifactConstants.RECOVERY_DETAILS; +import static org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.impl.TxtInformationArtifactConstants.RECOVERY_DETAILS_POINT; +import static org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.impl.TxtInformationArtifactConstants.RECOVERY_DETAILS_TIME; +import static org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.impl.TxtInformationArtifactConstants.SPACE; +import static org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.impl.TxtInformationArtifactConstants.STORAGE_BACKUP_DETAILS; +import static org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.impl.TxtInformationArtifactConstants.TAB; +import static org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.impl.TxtInformationArtifactConstants.TITLE; +import static org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.impl.TxtInformationArtifactConstants.USING_AVAILABILITY_ZONES; +import static org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.impl.TxtInformationArtifactConstants.VFC_COMPUTE; +import static org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.impl.TxtInformationArtifactConstants.VFC_COMPUTE_CPU_OVER_SUBSCRIPTION; +import static org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.impl.TxtInformationArtifactConstants.VFC_COMPUTE_DISK; +import static org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.impl.TxtInformationArtifactConstants.VFC_COMPUTE_MEMORY; +import static org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.impl.TxtInformationArtifactConstants.VFC_COMPUTE_VCPU; +import static org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.impl.TxtInformationArtifactConstants.VFC_DESC; +import static org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.impl.TxtInformationArtifactConstants.VFC_IMAGES; +import static org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.impl.TxtInformationArtifactConstants.VFC_INSTANCE_NUMBER; +import static org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.impl.TxtInformationArtifactConstants.VFC_INSTANCE_NUMBER_MAX; +import static org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.impl.TxtInformationArtifactConstants.VFC_INSTANCE_NUMBER_MIN; +import static org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.impl.TxtInformationArtifactConstants.VFC_NAME; +import static org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.impl.TxtInformationArtifactConstants.VNICS; +import static org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.impl.TxtInformationArtifactConstants.VNICS_INT_EXT; +import static org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.impl.TxtInformationArtifactConstants.VNICS_IPV4; +import static org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.impl.TxtInformationArtifactConstants.VNICS_IPV6; +import static org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.impl.TxtInformationArtifactConstants.VNICS_NAME; +import static org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.impl.TxtInformationArtifactConstants.VNICS_NETWORK; +import static org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.impl.TxtInformationArtifactConstants.VNICS_PROTOCOLS; +import static org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.impl.TxtInformationArtifactConstants.VNICS_PURPOSE; +import static org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.impl.TxtInformationArtifactConstants.VSP_CATEGORY; +import static org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.impl.TxtInformationArtifactConstants.VSP_DESC; +import static org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.impl.TxtInformationArtifactConstants.VSP_NAME; +import static org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.impl.TxtInformationArtifactConstants.VSP_VENDOR; +import static org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.impl.TxtInformationArtifactConstants.VSP_VERSION; + +import java.util.List; +import java.util.Optional; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails; import org.openecomp.sdc.vendorsoftwareproduct.factory.QuestionnnaireDataServiceFactory; import org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.InformationArtifactData; @@ -40,223 +94,149 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.vsp.general.G import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.vsp.general.StorageDataReplication; import org.openecomp.sdc.versioning.dao.types.Version; -import java.util.List; -import java.util.Optional; - -import static org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.impl.TxtInformationArtifactConstants.*; - /** * @author katyr * @since November 23, 2016 */ - public class TxtInformationArtifactGeneratorImpl implements InformationArtifactGenerator { - private QuestionnaireDataService questionnaireDataService = QuestionnnaireDataServiceFactory - .getInstance().createInterface(); - private StringBuilder textArtifact; - @Override - public String generate(String vspId, Version version) { - InformationArtifactData informationArtifactData = - questionnaireDataService.generateQuestionnaireDataForInformationArtifact(vspId, version); - return createTxtArtifact(informationArtifactData); - } - private String createTxtArtifact(InformationArtifactData informationArtifactData) { - textArtifact = new StringBuilder(); - addVspVlmEntries(informationArtifactData); - addAvailabilityEntries(); - addDataEntries(informationArtifactData); - addEntryWithIndent(LIST_OF_VFCS, "", TAB); - addEntryWithIndent(FOR_EACH_VFC, "", TAB + TAB); - List<ComponentQuestionnaire> componentQuestionnaires = - informationArtifactData.getComponentQuestionnaires(); - - for (ComponentQuestionnaire componentQuestionnaire : componentQuestionnaires) { - addEntriesPerComponent(componentQuestionnaire); + private QuestionnaireDataService questionnaireDataService = QuestionnnaireDataServiceFactory.getInstance().createInterface(); + private StringBuilder textArtifact; + static String roundVersionAsNeeded(Version version) { + if (version.isFinal()) { + return version.toString(); + } else { + return String.valueOf(Math.ceil(Double.valueOf(version.toString()))); + } } - List<NicQuestionnaire> nicQuestionnaires = informationArtifactData.getNicQuestionnaires(); - for (NicQuestionnaire nicQuestionnaire : nicQuestionnaires) { - addEntriesPerNic(nicQuestionnaire); - + @Override + public String generate(String vspId, Version version) { + InformationArtifactData informationArtifactData = questionnaireDataService.generateQuestionnaireDataForInformationArtifact(vspId, version); + return createTxtArtifact(informationArtifactData); } - for (ComponentQuestionnaire componentQuestionnaire : componentQuestionnaires) { - addRecoveryEntriesPerComponent(componentQuestionnaire); - } - return textArtifact.toString(); - - } - - private void addDataEntries(InformationArtifactData informationArtifactData) { - addEntryWithIndent(STORAGE_BACKUP_DETAILS, "", TAB); - - Optional<StorageDataReplication> storageDataReplication = - Optional.of(informationArtifactData).map(InformationArtifactData::getVspQuestionnaire) - .map(VspQuestionnaire::getGeneral).map(General::getStorageDataReplication); - storageDataReplication - .ifPresent(replication -> addEntryWithIndent(IS_DATA_REPLICATION, - String.valueOf(replication.isStorageReplicationAcrossRegion()), TAB + TAB)); - - storageDataReplication.ifPresent(rep -> addEntryWithIndent(DATA_SIZE_TO_REP, - String.valueOf(rep.getStorageReplicationSize()), TAB + TAB)); - - storageDataReplication.ifPresent(rep -> addEntryWithIndent(DATA_REP_FREQUENCY, - String.valueOf(rep.getStorageReplicationFrequency()), TAB + TAB)); - - storageDataReplication.ifPresent(rep -> addEntryWithIndent(DATA_REP_SOURCE, - String.valueOf(rep.getStorageReplicationSource()), TAB + TAB)); - - storageDataReplication.ifPresent(rep -> addEntryWithIndent(DATA_REP_DEST, - String.valueOf(rep.getStorageReplicationDestination()), TAB + TAB)); - } + private String createTxtArtifact(InformationArtifactData informationArtifactData) { + textArtifact = new StringBuilder(); + addVspVlmEntries(informationArtifactData); + addAvailabilityEntries(); + addDataEntries(informationArtifactData); + addEntryWithIndent(LIST_OF_VFCS, "", TAB); + addEntryWithIndent(FOR_EACH_VFC, "", TAB + TAB); + List<ComponentQuestionnaire> componentQuestionnaires = informationArtifactData.getComponentQuestionnaires(); + for (ComponentQuestionnaire componentQuestionnaire : componentQuestionnaires) { + addEntriesPerComponent(componentQuestionnaire); + } + List<NicQuestionnaire> nicQuestionnaires = informationArtifactData.getNicQuestionnaires(); + for (NicQuestionnaire nicQuestionnaire : nicQuestionnaires) { + addEntriesPerNic(nicQuestionnaire); + } + for (ComponentQuestionnaire componentQuestionnaire : componentQuestionnaires) { + addRecoveryEntriesPerComponent(componentQuestionnaire); + } + return textArtifact.toString(); + } - private void addAvailabilityEntries() { - addEntryWithIndent(HIGH_AVAILABILITY, "", TAB); + private void addDataEntries(InformationArtifactData informationArtifactData) { + addEntryWithIndent(STORAGE_BACKUP_DETAILS, "", TAB); + Optional<StorageDataReplication> storageDataReplication = Optional.of(informationArtifactData) + .map(InformationArtifactData::getVspQuestionnaire).map(VspQuestionnaire::getGeneral).map(General::getStorageDataReplication); + storageDataReplication.ifPresent( + replication -> addEntryWithIndent(IS_DATA_REPLICATION, String.valueOf(replication.isStorageReplicationAcrossRegion()), TAB + TAB)); + storageDataReplication.ifPresent(rep -> addEntryWithIndent(DATA_SIZE_TO_REP, String.valueOf(rep.getStorageReplicationSize()), TAB + TAB)); + storageDataReplication + .ifPresent(rep -> addEntryWithIndent(DATA_REP_FREQUENCY, String.valueOf(rep.getStorageReplicationFrequency()), TAB + TAB)); + storageDataReplication.ifPresent(rep -> addEntryWithIndent(DATA_REP_SOURCE, String.valueOf(rep.getStorageReplicationSource()), TAB + TAB)); + storageDataReplication.ifPresent(rep -> addEntryWithIndent(DATA_REP_DEST, String.valueOf(rep.getStorageReplicationDestination()), TAB + TAB)); + } - Optional<Availability> availability = - Optional.of(new InformationArtifactData()).map(InformationArtifactData::getVspQuestionnaire) + private void addAvailabilityEntries() { + addEntryWithIndent(HIGH_AVAILABILITY, "", TAB); + Optional<Availability> availability = Optional.of(new InformationArtifactData()).map(InformationArtifactData::getVspQuestionnaire) .map(VspQuestionnaire::getGeneral).map(General::getAvailability); - availability - .ifPresent(availabilityVal -> addEntryWithIndent(USING_AVAILABILITY_ZONES, String.valueOf( - availabilityVal.isUseAvailabilityZonesForHighAvailability()), TAB + TAB)); - } - - private void addVspVlmEntries(InformationArtifactData informationArtifactData) { - addEntryWithIndent(TITLE, "", ""); - Optional<VspDetails> vspDetails = Optional.of(informationArtifactData).map - (InformationArtifactData::getVspDetails); - addEntryWithIndent(VSP_NAME, informationArtifactData.getVspDetails().getName(), TAB); - addEntryWithIndent(VSP_DESC, informationArtifactData.getVspDetails().getDescription(), TAB); - addEntryWithIndent(VSP_VERSION, - roundVersionAsNeeded(informationArtifactData.getVspDetails().getVersion()), TAB); - addEntryWithIndent(VSP_VENDOR, informationArtifactData.getVspDetails().getVendorName(), TAB); - addEntryWithIndent(VSP_CATEGORY, informationArtifactData.getVspDetails().getCategory(), TAB); - addEntryWithIndent(LICENSE_DETAILS, "", TAB); - addEntryWithIndent(LICENSE_MODEL_VERSION, - informationArtifactData.getVspDetails().getVlmVersion() == null - ? "" - : informationArtifactData.getVspDetails().getVlmVersion().toString(), - TAB + TAB); - addEntryWithIndent(LICENSE_AGREEMENT_NAME, informationArtifactData.getVspDetails() - .getLicenseAgreement(), TAB + TAB); - addEntryWithIndent(LIST_OF_FEATURE_GROUPS, "", TAB + TAB); - vspDetails.ifPresent(vspDets -> addListEntriesWithIndent(vspDets - .getFeatureGroups(), TAB + TAB + TAB)); - } - - static String roundVersionAsNeeded(Version version) { - if (version.isFinal()) { - return version.toString(); - } else { - return String.valueOf(Math.ceil(Double.valueOf(version.toString()))); + availability.ifPresent(availabilityVal -> addEntryWithIndent(USING_AVAILABILITY_ZONES, + String.valueOf(availabilityVal.isUseAvailabilityZonesForHighAvailability()), TAB + TAB)); } - } - - private void addRecoveryEntriesPerComponent(ComponentQuestionnaire componentQuestionnaire) { - addEntryWithIndent(RECOVERY_DETAILS, "", TAB + TAB + TAB); - Optional<Recovery> recovery = Optional.of(componentQuestionnaire).map( - ComponentQuestionnaire::getGeneral).map( - org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.general - .General::getRecovery); - recovery.ifPresent(recoveryVal -> addEntryWithIndent(RECOVERY_DETAILS_POINT, String.valueOf( - recoveryVal.getPointObjective()), TAB + TAB + TAB + TAB)); - - recovery.ifPresent(recoveryVal -> addEntryWithIndent(RECOVERY_DETAILS_TIME, String.valueOf( - recoveryVal.getTimeObjective()), TAB + TAB + TAB + TAB)); - } - - private void addEntriesPerNic(NicQuestionnaire nicQuestionnaire) { - addEntryWithIndent(VNICS, "", TAB + TAB + TAB); - Optional<Network> networkOpt = Optional.of(nicQuestionnaire).map( - NicQuestionnaire::getNetwork); - - networkOpt.ifPresent(network -> addEntryWithIndent(VNICS_NAME, network - .getNetworkDescription(), - TAB + TAB + TAB + TAB)); - networkOpt.ifPresent(network -> addEntryWithIndent(VNICS_PURPOSE, network - .getNetworkDescription(), TAB + TAB + TAB + TAB)); - networkOpt.ifPresent(network -> addEntryWithIndent(VNICS_INT_EXT, network - .getNetworkDescription(), TAB + TAB + TAB + TAB)); - networkOpt.ifPresent(network -> addEntryWithIndent(VNICS_NETWORK, network.toString(), - TAB + TAB + TAB + TAB)); - addEntryWithIndent(VNICS_PROTOCOLS, nicQuestionnaire.getProtocols() == null ? "" : nicQuestionnaire.getProtocols().toString(), - TAB + TAB + TAB + TAB); - - Optional<IpConfiguration> ipconfigOpt = Optional.of(nicQuestionnaire).map - (NicQuestionnaire::getIpConfiguration); - ipconfigOpt.ifPresent(ipconfig -> addEntryWithIndent(VNICS_IPV4, String.valueOf(ipconfig - .isIpv4Required()), TAB + TAB + TAB + TAB)); - ipconfigOpt.ifPresent(ipconfig -> addEntryWithIndent(VNICS_IPV6, String.valueOf(ipconfig - .isIpv6Required()), TAB + TAB + TAB + TAB)); - } - - private void addEntriesPerComponent(ComponentQuestionnaire componentQuestionnaire) { - addEntryWithIndent(VFC_NAME, "", TAB + TAB + TAB); - addEntryWithIndent(VFC_DESC, "", TAB + TAB + TAB); - addEntryWithIndent(VFC_IMAGES, "", TAB + TAB + TAB); - //todo component name +desc +img+vcpu - addEntryWithIndent(VFC_COMPUTE, "", TAB + TAB + TAB); - addEntryWithIndent(VFC_COMPUTE_VCPU, "", TAB + TAB + TAB + TAB); - addEntryWithIndent(VFC_COMPUTE_CPU_OVER_SUBSCRIPTION, "", - TAB + TAB + TAB + TAB); - addEntryWithIndent(VFC_COMPUTE_MEMORY, "", TAB + TAB + TAB + TAB); - addEntryWithIndent(VFC_COMPUTE_DISK, "", TAB + TAB + TAB + TAB); - - addEntryWithIndent(HYPERVISOR_DETAILS, "", TAB + TAB + TAB); - - Optional<Hypervisor> hypervisorOpt = Optional.of(componentQuestionnaire).map( - ComponentQuestionnaire::getGeneral).map( - org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.general - .General::getHypervisor); - hypervisorOpt.ifPresent(hypervisor -> addEntryWithIndent(HYPERVISOR_DETAILS_NAME, hypervisor - .getHypervisor(), TAB - + TAB + TAB + TAB)); - - hypervisorOpt.ifPresent(hypervisor -> addEntryWithIndent(HYPERVISOR_DETAILS_DRIVERS, hypervisor - .getDrivers(), TAB + TAB + TAB + TAB)); - addEntryWithIndent(GUEST_OS_DETAILS, "", TAB + TAB + TAB); - Optional<GuestOS> guestOSOptional = Optional.of(componentQuestionnaire).map - (ComponentQuestionnaire::getCompute).map(Compute::getGuestOS); - guestOSOptional.ifPresent(guestOs -> addEntryWithIndent(GUEST_OS_NAME, guestOs.getName(), - TAB + TAB + TAB + TAB)); - - - guestOSOptional - .ifPresent(guestOs -> addEntryWithIndent(GUEST_OS_BIT_SIZE, String.valueOf(guestOs - .getBitSize()), TAB + TAB + TAB + TAB)); - guestOSOptional.ifPresent(guestOs -> addEntryWithIndent(GUEST_OS_TOOLS, guestOs.getTools - (), TAB + TAB + TAB + TAB)); - - addEntryWithIndent(VFC_INSTANCE_NUMBER, "", - TAB + TAB + TAB); - - Optional<NumOfVMs> numVmsOpt = Optional.of(componentQuestionnaire).map - (ComponentQuestionnaire::getCompute).map(Compute::getNumOfVMs); - numVmsOpt.ifPresent(numVms -> addEntryWithIndent(VFC_INSTANCE_NUMBER_MIN, String.valueOf - (numVms.getMinimum()), TAB + TAB + TAB + TAB)); - - numVmsOpt.ifPresent(numVms -> addEntryWithIndent(VFC_INSTANCE_NUMBER_MAX, String.valueOf - (numVms.getMaximum()), TAB + TAB + TAB + TAB)); - } + private void addVspVlmEntries(InformationArtifactData informationArtifactData) { + addEntryWithIndent(TITLE, "", ""); + Optional<VspDetails> vspDetails = Optional.of(informationArtifactData).map(InformationArtifactData::getVspDetails); + addEntryWithIndent(VSP_NAME, informationArtifactData.getVspDetails().getName(), TAB); + addEntryWithIndent(VSP_DESC, informationArtifactData.getVspDetails().getDescription(), TAB); + addEntryWithIndent(VSP_VERSION, roundVersionAsNeeded(informationArtifactData.getVspDetails().getVersion()), TAB); + addEntryWithIndent(VSP_VENDOR, informationArtifactData.getVspDetails().getVendorName(), TAB); + addEntryWithIndent(VSP_CATEGORY, informationArtifactData.getVspDetails().getCategory(), TAB); + addEntryWithIndent(LICENSE_DETAILS, "", TAB); + addEntryWithIndent(LICENSE_MODEL_VERSION, + informationArtifactData.getVspDetails().getVlmVersion() == null ? "" : informationArtifactData.getVspDetails().getVlmVersion().toString(), + TAB + TAB); + addEntryWithIndent(LICENSE_AGREEMENT_NAME, informationArtifactData.getVspDetails().getLicenseAgreement(), TAB + TAB); + addEntryWithIndent(LIST_OF_FEATURE_GROUPS, "", TAB + TAB); + vspDetails.ifPresent(vspDets -> addListEntriesWithIndent(vspDets.getFeatureGroups(), TAB + TAB + TAB)); + } - private void addListEntriesWithIndent(List<String> fieldValues, String indent) { - int counter = 1; - if (fieldValues == null) { - return; + private void addRecoveryEntriesPerComponent(ComponentQuestionnaire componentQuestionnaire) { + addEntryWithIndent(RECOVERY_DETAILS, "", TAB + TAB + TAB); + Optional<Recovery> recovery = Optional.of(componentQuestionnaire).map(ComponentQuestionnaire::getGeneral) + .map(org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.general.General::getRecovery); + recovery.ifPresent( + recoveryVal -> addEntryWithIndent(RECOVERY_DETAILS_POINT, String.valueOf(recoveryVal.getPointObjective()), TAB + TAB + TAB + TAB)); + recovery.ifPresent( + recoveryVal -> addEntryWithIndent(RECOVERY_DETAILS_TIME, String.valueOf(recoveryVal.getTimeObjective()), TAB + TAB + TAB + TAB)); } - for (String fieldValue : fieldValues) { - textArtifact.append(indent).append(counter++).append(".").append(TAB).append(fieldValue) - .append - (NL); + + private void addEntriesPerNic(NicQuestionnaire nicQuestionnaire) { + addEntryWithIndent(VNICS, "", TAB + TAB + TAB); + Optional<Network> networkOpt = Optional.of(nicQuestionnaire).map(NicQuestionnaire::getNetwork); + networkOpt.ifPresent(network -> addEntryWithIndent(VNICS_NAME, network.getNetworkDescription(), TAB + TAB + TAB + TAB)); + networkOpt.ifPresent(network -> addEntryWithIndent(VNICS_PURPOSE, network.getNetworkDescription(), TAB + TAB + TAB + TAB)); + networkOpt.ifPresent(network -> addEntryWithIndent(VNICS_INT_EXT, network.getNetworkDescription(), TAB + TAB + TAB + TAB)); + networkOpt.ifPresent(network -> addEntryWithIndent(VNICS_NETWORK, network.toString(), TAB + TAB + TAB + TAB)); + addEntryWithIndent(VNICS_PROTOCOLS, nicQuestionnaire.getProtocols() == null ? "" : nicQuestionnaire.getProtocols().toString(), + TAB + TAB + TAB + TAB); + Optional<IpConfiguration> ipconfigOpt = Optional.of(nicQuestionnaire).map(NicQuestionnaire::getIpConfiguration); + ipconfigOpt.ifPresent(ipconfig -> addEntryWithIndent(VNICS_IPV4, String.valueOf(ipconfig.isIpv4Required()), TAB + TAB + TAB + TAB)); + ipconfigOpt.ifPresent(ipconfig -> addEntryWithIndent(VNICS_IPV6, String.valueOf(ipconfig.isIpv6Required()), TAB + TAB + TAB + TAB)); } - } + private void addEntriesPerComponent(ComponentQuestionnaire componentQuestionnaire) { + addEntryWithIndent(VFC_NAME, "", TAB + TAB + TAB); + addEntryWithIndent(VFC_DESC, "", TAB + TAB + TAB); + addEntryWithIndent(VFC_IMAGES, "", TAB + TAB + TAB); + //todo component name +desc +img+vcpu + addEntryWithIndent(VFC_COMPUTE, "", TAB + TAB + TAB); + addEntryWithIndent(VFC_COMPUTE_VCPU, "", TAB + TAB + TAB + TAB); + addEntryWithIndent(VFC_COMPUTE_CPU_OVER_SUBSCRIPTION, "", TAB + TAB + TAB + TAB); + addEntryWithIndent(VFC_COMPUTE_MEMORY, "", TAB + TAB + TAB + TAB); + addEntryWithIndent(VFC_COMPUTE_DISK, "", TAB + TAB + TAB + TAB); + addEntryWithIndent(HYPERVISOR_DETAILS, "", TAB + TAB + TAB); + Optional<Hypervisor> hypervisorOpt = Optional.of(componentQuestionnaire).map(ComponentQuestionnaire::getGeneral) + .map(org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.general.General::getHypervisor); + hypervisorOpt.ifPresent(hypervisor -> addEntryWithIndent(HYPERVISOR_DETAILS_NAME, hypervisor.getHypervisor(), TAB + TAB + TAB + TAB)); + hypervisorOpt.ifPresent(hypervisor -> addEntryWithIndent(HYPERVISOR_DETAILS_DRIVERS, hypervisor.getDrivers(), TAB + TAB + TAB + TAB)); + addEntryWithIndent(GUEST_OS_DETAILS, "", TAB + TAB + TAB); + Optional<GuestOS> guestOSOptional = Optional.of(componentQuestionnaire).map(ComponentQuestionnaire::getCompute).map(Compute::getGuestOS); + guestOSOptional.ifPresent(guestOs -> addEntryWithIndent(GUEST_OS_NAME, guestOs.getName(), TAB + TAB + TAB + TAB)); + guestOSOptional.ifPresent(guestOs -> addEntryWithIndent(GUEST_OS_BIT_SIZE, String.valueOf(guestOs.getBitSize()), TAB + TAB + TAB + TAB)); + guestOSOptional.ifPresent(guestOs -> addEntryWithIndent(GUEST_OS_TOOLS, guestOs.getTools(), TAB + TAB + TAB + TAB)); + addEntryWithIndent(VFC_INSTANCE_NUMBER, "", TAB + TAB + TAB); + Optional<NumOfVMs> numVmsOpt = Optional.of(componentQuestionnaire).map(ComponentQuestionnaire::getCompute).map(Compute::getNumOfVMs); + numVmsOpt.ifPresent(numVms -> addEntryWithIndent(VFC_INSTANCE_NUMBER_MIN, String.valueOf(numVms.getMinimum()), TAB + TAB + TAB + TAB)); + numVmsOpt.ifPresent(numVms -> addEntryWithIndent(VFC_INSTANCE_NUMBER_MAX, String.valueOf(numVms.getMaximum()), TAB + TAB + TAB + TAB)); + } + private void addListEntriesWithIndent(List<String> fieldValues, String indent) { + int counter = 1; + if (fieldValues == null) { + return; + } + for (String fieldValue : fieldValues) { + textArtifact.append(indent).append(counter++).append(".").append(TAB).append(fieldValue).append(NL); + } + } - private void addEntryWithIndent(String fieldName, String fieldValue, String indent) { - textArtifact.append(indent).append(fieldName).append(SPACE).append(fieldValue).append(NL); - } + private void addEntryWithIndent(String fieldName, String fieldValue, String indent) { + textArtifact.append(indent).append(fieldName).append(SPACE).append(fieldValue).append(NL); + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/quiestionnaire/QuestionnaireDataServiceImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/quiestionnaire/QuestionnaireDataServiceImpl.java index 3af6dfc598..0142091176 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/quiestionnaire/QuestionnaireDataServiceImpl.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/quiestionnaire/QuestionnaireDataServiceImpl.java @@ -13,13 +13,23 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.openecomp.sdc.vendorsoftwareproduct.quiestionnaire; - +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; import org.openecomp.core.utilities.json.JsonUtil; -import org.openecomp.sdc.vendorsoftwareproduct.dao.*; -import org.openecomp.sdc.vendorsoftwareproduct.dao.type.*; +import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao; +import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDaoFactory; +import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDao; +import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDaoFactory; +import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao; +import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoFactory; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.CompositionEntity; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspQuestionnaireEntity; import org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.InformationArtifactData; import org.openecomp.sdc.vendorsoftwareproduct.questionnaire.QuestionnaireDataService; import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.ComponentQuestionnaire; @@ -27,67 +37,47 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.nic.NicQuesti import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.vsp.VspQuestionnaire; import org.openecomp.sdc.versioning.dao.types.Version; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - /** * Created by TALIO on 11/22/2016 */ public class QuestionnaireDataServiceImpl implements QuestionnaireDataService { - private static final ComponentDao componentDao = - ComponentDaoFactory.getInstance().createInterface(); - private static final NicDao nicDao = NicDaoFactory.getInstance().createInterface(); - private static final VendorSoftwareProductInfoDao vspInfoDao = - VendorSoftwareProductInfoDaoFactory.getInstance().createInterface(); - @Override - public InformationArtifactData generateQuestionnaireDataForInformationArtifact(String vspId, - Version version) { - VspDetails vspDetails = vspInfoDao.get(new VspDetails(vspId, version)); - Collection<ComponentEntity> componentEntities = componentDao.listQuestionnaires(vspId, version); - Collection<NicEntity> nicEntities = nicDao.listByVsp(vspId, version); - VspQuestionnaire vspQuestionnaire = getVspQuestionnaireFromJson(vspId, version); - List<ComponentQuestionnaire> componentQuestionnaireList = - getListOfComponentQuestionnaireFromJson(componentEntities); - List<NicQuestionnaire> nicQuestionnaireList = getListOfNicQuestionnaireFromJson(nicEntities); - return new InformationArtifactData(vspDetails, vspQuestionnaire, componentQuestionnaireList, - nicQuestionnaireList); - } - - private VspQuestionnaire getVspQuestionnaireFromJson(String vspId, Version version) { - VspQuestionnaireEntity vspQuestionnaireEntity = - vspInfoDao.getQuestionnaire(vspId, version); - - if (vspQuestionnaireEntity == null) { - return null; + private static final ComponentDao componentDao = ComponentDaoFactory.getInstance().createInterface(); + private static final NicDao nicDao = NicDaoFactory.getInstance().createInterface(); + private static final VendorSoftwareProductInfoDao vspInfoDao = VendorSoftwareProductInfoDaoFactory.getInstance().createInterface(); + + @Override + public InformationArtifactData generateQuestionnaireDataForInformationArtifact(String vspId, Version version) { + VspDetails vspDetails = vspInfoDao.get(new VspDetails(vspId, version)); + Collection<ComponentEntity> componentEntities = componentDao.listQuestionnaires(vspId, version); + Collection<NicEntity> nicEntities = nicDao.listByVsp(vspId, version); + VspQuestionnaire vspQuestionnaire = getVspQuestionnaireFromJson(vspId, version); + List<ComponentQuestionnaire> componentQuestionnaireList = getListOfComponentQuestionnaireFromJson(componentEntities); + List<NicQuestionnaire> nicQuestionnaireList = getListOfNicQuestionnaireFromJson(nicEntities); + return new InformationArtifactData(vspDetails, vspQuestionnaire, componentQuestionnaireList, nicQuestionnaireList); } - return JsonUtil - .json2Object(vspQuestionnaireEntity.getQuestionnaireData(), VspQuestionnaire.class); - } - - private List<ComponentQuestionnaire> getListOfComponentQuestionnaireFromJson( - Collection<ComponentEntity> entities) { - List<ComponentQuestionnaire> componentQuestionnaireList = new ArrayList<>(); - - for (CompositionEntity componentEntity : entities) { - componentQuestionnaireList.add(JsonUtil - .json2Object(componentEntity.getQuestionnaireData(), ComponentQuestionnaire.class)); + private VspQuestionnaire getVspQuestionnaireFromJson(String vspId, Version version) { + VspQuestionnaireEntity vspQuestionnaireEntity = vspInfoDao.getQuestionnaire(vspId, version); + if (vspQuestionnaireEntity == null) { + return null; + } + return JsonUtil.json2Object(vspQuestionnaireEntity.getQuestionnaireData(), VspQuestionnaire.class); } - return componentQuestionnaireList; - } - - private List<NicQuestionnaire> getListOfNicQuestionnaireFromJson(Collection<NicEntity> entities) { - List<NicQuestionnaire> nicQuestionnaireList = new ArrayList<>(); - - for (NicEntity nicEntity : entities) { - nicQuestionnaireList - .add(JsonUtil.json2Object(nicEntity.getQuestionnaireData(), NicQuestionnaire.class)); + private List<ComponentQuestionnaire> getListOfComponentQuestionnaireFromJson(Collection<ComponentEntity> entities) { + List<ComponentQuestionnaire> componentQuestionnaireList = new ArrayList<>(); + for (CompositionEntity componentEntity : entities) { + componentQuestionnaireList.add(JsonUtil.json2Object(componentEntity.getQuestionnaireData(), ComponentQuestionnaire.class)); + } + return componentQuestionnaireList; } - return nicQuestionnaireList; - } - + private List<NicQuestionnaire> getListOfNicQuestionnaireFromJson(Collection<NicEntity> entities) { + List<NicQuestionnaire> nicQuestionnaireList = new ArrayList<>(); + for (NicEntity nicEntity : entities) { + nicQuestionnaireList.add(JsonUtil.json2Object(nicEntity.getQuestionnaireData(), NicQuestionnaire.class)); + } + return nicQuestionnaireList; + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/ManualVspDataCollectionService.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/ManualVspDataCollectionService.java index dc60419973..f50c1339b3 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/ManualVspDataCollectionService.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/ManualVspDataCollectionService.java @@ -12,374 +12,355 @@ * 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. -*/ - + */ package org.openecomp.sdc.vendorsoftwareproduct.services; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang.StringUtils; import org.openecomp.core.utilities.json.JsonUtil; -import org.openecomp.sdc.generator.datatypes.tosca.*; +import org.openecomp.sdc.generator.datatypes.tosca.ComputeFlavor; +import org.openecomp.sdc.generator.datatypes.tosca.DeploymentFlavorModel; +import org.openecomp.sdc.generator.datatypes.tosca.LicenseFlavor; +import org.openecomp.sdc.generator.datatypes.tosca.MultiFlavorVfcImage; +import org.openecomp.sdc.generator.datatypes.tosca.VendorInfo; import org.openecomp.sdc.logging.api.Logger; import org.openecomp.sdc.logging.api.LoggerFactory; import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity; import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupModel; import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacade; import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacadeFactory; -import org.openecomp.sdc.vendorsoftwareproduct.dao.*; -import org.openecomp.sdc.vendorsoftwareproduct.dao.type.*; -import org.openecomp.sdc.vendorsoftwareproduct.types.composition.*; +import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao; +import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDaoFactory; +import org.openecomp.sdc.vendorsoftwareproduct.dao.ComputeDao; +import org.openecomp.sdc.vendorsoftwareproduct.dao.ComputeDaoFactory; +import org.openecomp.sdc.vendorsoftwareproduct.dao.DeploymentFlavorDao; +import org.openecomp.sdc.vendorsoftwareproduct.dao.DeploymentFlavorDaoFactory; +import org.openecomp.sdc.vendorsoftwareproduct.dao.ImageDao; +import org.openecomp.sdc.vendorsoftwareproduct.dao.ImageDaoFactory; +import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDao; +import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDaoFactory; +import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao; +import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoFactory; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComputeEntity; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ImageEntity; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentComputeAssociation; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentData; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.DeploymentFlavor; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Image; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Nic; import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.compute.Compute; import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.image.ImageDetails; import org.openecomp.sdc.versioning.dao.types.Version; -import java.util.*; - - public class ManualVspDataCollectionService { - private static final VendorSoftwareProductInfoDao vendorSoftwareProductInfoDao = - VendorSoftwareProductInfoDaoFactory.getInstance().createInterface(); - private static final DeploymentFlavorDao deploymentFlavorDao = - DeploymentFlavorDaoFactory.getInstance().createInterface(); - private static final ComputeDao computeDao = - ComputeDaoFactory.getInstance().createInterface(); - private static final ImageDao imageDao = - ImageDaoFactory.getInstance().createInterface(); - private static final ComponentDao componentDao = - ComponentDaoFactory.getInstance().createInterface(); - - private static final NicDao nicDao = - NicDaoFactory.getInstance().createInterface(); - private static final VendorLicenseFacade vendorLicenseFacade = - VendorLicenseFacadeFactory.getInstance().createInterface(); - - private final Logger log = LoggerFactory.getLogger(this.getClass().getName()); - - /** - * Gets vendor name for the vsp. - * - * @param vspId the vsp id - * @param version the version - * @return the release vendor name - */ - public Optional<String> getReleaseVendor(String vspId, Version version) { - String vendorName = null; - VspDetails vspDetails = vendorSoftwareProductInfoDao.get(new VspDetails(vspId, version)); - if (Objects.nonNull(vspDetails)) { - vendorName = vspDetails.getVendorName(); - } - return Optional.ofNullable(vendorName); - } - - /** - * Gets the deployment flavor data for manually onboarded VSPs. - * - * @param vspId the vsp id - * @param version the version - * @return the allowed flavors - */ - public Map<String, DeploymentFlavorModel> getAllowedFlavors(String vspId, Version version) { - Map<String, DeploymentFlavorModel> allowedFlavors = new HashMap<>(); - Collection<DeploymentFlavorEntity> deploymentFlavorEntities = - deploymentFlavorDao.list(new DeploymentFlavorEntity(vspId, version, null)); - if (CollectionUtils.isNotEmpty(deploymentFlavorEntities)) { - for (DeploymentFlavorEntity deploymentFlavorEntity : deploymentFlavorEntities) { - DeploymentFlavor deploymentFlavorCompositionData = - deploymentFlavorEntity.getDeploymentFlavorCompositionData(); + private static final VendorSoftwareProductInfoDao vendorSoftwareProductInfoDao = VendorSoftwareProductInfoDaoFactory.getInstance() + .createInterface(); + private static final DeploymentFlavorDao deploymentFlavorDao = DeploymentFlavorDaoFactory.getInstance().createInterface(); + private static final ComputeDao computeDao = ComputeDaoFactory.getInstance().createInterface(); + private static final ImageDao imageDao = ImageDaoFactory.getInstance().createInterface(); + private static final ComponentDao componentDao = ComponentDaoFactory.getInstance().createInterface(); + private static final NicDao nicDao = NicDaoFactory.getInstance().createInterface(); + private static final VendorLicenseFacade vendorLicenseFacade = VendorLicenseFacadeFactory.getInstance().createInterface(); + private final Logger log = LoggerFactory.getLogger(this.getClass().getName()); + /** + * Gets vendor name for the vsp. + * + * @param vspId the vsp id + * @param version the version + * @return the release vendor name + */ + public Optional<String> getReleaseVendor(String vspId, Version version) { + String vendorName = null; VspDetails vspDetails = vendorSoftwareProductInfoDao.get(new VspDetails(vspId, version)); - String vspVlmId; - Version vlmVersion; if (Objects.nonNull(vspDetails)) { - vspVlmId = vspDetails.getVendorId(); - vlmVersion = vspDetails.getVlmVersion(); - if (StringUtils.isNotEmpty(vspVlmId)) { - DeploymentFlavorModel deploymentFlavorModel = new DeploymentFlavorModel(); - String featureGroupId = deploymentFlavorCompositionData.getFeatureGroupId(); - if (Objects.isNull(featureGroupId)) { - //No feature group associated with deployment flavor. So excluding this deployment - // flavor for Tosca model - continue; - } - //Gather and set License flavor info - LicenseFlavor licenseFlavor = getLicenseFlavor(featureGroupId); - deploymentFlavorModel.setLicense_flavor(licenseFlavor); - //Get sp_part_number - Optional<String> partNumber = getPartNumber(vspVlmId, vlmVersion, featureGroupId); - partNumber.ifPresent(deploymentFlavorModel::setSp_part_number); - //Gather and set Vendor Info - String vendorModel = deploymentFlavorCompositionData.getModel(); - Optional<VendorInfo> vendorInfo = getVendorInfo(vspVlmId, vendorModel, vlmVersion, - featureGroupId); - vendorInfo.ifPresent(deploymentFlavorModel::setVendor_info); - //Gather and set Compute info - List<ComponentComputeAssociation> componentComputeAssociations = - deploymentFlavorCompositionData.getComponentComputeAssociations(); - if (CollectionUtils.isNotEmpty(componentComputeAssociations)) { - for (ComponentComputeAssociation componentComputeAssociation : - componentComputeAssociations) { - String componentId = componentComputeAssociation.getComponentId(); - String computeFlavorId = componentComputeAssociation.getComputeFlavorId(); - Optional<ComputeFlavor> computeFlavor = - getComputeFlavor(vspId, version, componentId, computeFlavorId); - computeFlavor.ifPresent(deploymentFlavorModel::setCompute_flavor); - } - } - partNumber.ifPresent(spPartNumber -> allowedFlavors.put(spPartNumber, - deploymentFlavorModel)); - } + vendorName = vspDetails.getVendorName(); } - } + return Optional.ofNullable(vendorName); } - return allowedFlavors; - } - /** - * Gets the component image data for manually onboarded VSPs. - * - * @param vspId the vsp id - * @param version the version - * @return the vsp component images - */ - public Map<String, List<MultiFlavorVfcImage>> getVspComponentImages(String vspId, - Version version) { - Map<String, List<MultiFlavorVfcImage>> vspComponentImages = new HashMap<>(); - Collection<DeploymentFlavorEntity> deploymentFlavorEntities = - deploymentFlavorDao.list(new DeploymentFlavorEntity(vspId, version, null)); - for (DeploymentFlavorEntity deploymentFlavorEntity : deploymentFlavorEntities) { - DeploymentFlavor deploymentFlavorCompositionData = - deploymentFlavorEntity.getDeploymentFlavorCompositionData(); + /** + * Gets the deployment flavor data for manually onboarded VSPs. + * + * @param vspId the vsp id + * @param version the version + * @return the allowed flavors + */ + public Map<String, DeploymentFlavorModel> getAllowedFlavors(String vspId, Version version) { + Map<String, DeploymentFlavorModel> allowedFlavors = new HashMap<>(); + Collection<DeploymentFlavorEntity> deploymentFlavorEntities = deploymentFlavorDao.list(new DeploymentFlavorEntity(vspId, version, null)); + if (CollectionUtils.isNotEmpty(deploymentFlavorEntities)) { + for (DeploymentFlavorEntity deploymentFlavorEntity : deploymentFlavorEntities) { + DeploymentFlavor deploymentFlavorCompositionData = deploymentFlavorEntity.getDeploymentFlavorCompositionData(); + VspDetails vspDetails = vendorSoftwareProductInfoDao.get(new VspDetails(vspId, version)); + String vspVlmId; + Version vlmVersion; + if (Objects.nonNull(vspDetails)) { + vspVlmId = vspDetails.getVendorId(); + vlmVersion = vspDetails.getVlmVersion(); + if (StringUtils.isNotEmpty(vspVlmId)) { + DeploymentFlavorModel deploymentFlavorModel = new DeploymentFlavorModel(); + String featureGroupId = deploymentFlavorCompositionData.getFeatureGroupId(); + if (Objects.isNull(featureGroupId)) { + //No feature group associated with deployment flavor. So excluding this deployment - List<ComponentComputeAssociation> componentComputeAssociations = - deploymentFlavorCompositionData.getComponentComputeAssociations(); - if (CollectionUtils.isNotEmpty(componentComputeAssociations)) { - for (ComponentComputeAssociation componentComputeAssociation : - componentComputeAssociations) { - String componentId = componentComputeAssociation.getComponentId(); - List<MultiFlavorVfcImage> componentImages = - getComponentImages(vspId, version, componentId); - if (CollectionUtils.isNotEmpty(componentImages)) { - vspComponentImages.put(componentId, componentImages); - } + // flavor for Tosca model + continue; + } + //Gather and set License flavor info + LicenseFlavor licenseFlavor = getLicenseFlavor(featureGroupId); + deploymentFlavorModel.setLicense_flavor(licenseFlavor); + //Get sp_part_number + Optional<String> partNumber = getPartNumber(vspVlmId, vlmVersion, featureGroupId); + partNumber.ifPresent(deploymentFlavorModel::setSp_part_number); + //Gather and set Vendor Info + String vendorModel = deploymentFlavorCompositionData.getModel(); + Optional<VendorInfo> vendorInfo = getVendorInfo(vspVlmId, vendorModel, vlmVersion, featureGroupId); + vendorInfo.ifPresent(deploymentFlavorModel::setVendor_info); + //Gather and set Compute info + List<ComponentComputeAssociation> componentComputeAssociations = deploymentFlavorCompositionData + .getComponentComputeAssociations(); + if (CollectionUtils.isNotEmpty(componentComputeAssociations)) { + for (ComponentComputeAssociation componentComputeAssociation : componentComputeAssociations) { + String componentId = componentComputeAssociation.getComponentId(); + String computeFlavorId = componentComputeAssociation.getComputeFlavorId(); + Optional<ComputeFlavor> computeFlavor = getComputeFlavor(vspId, version, componentId, computeFlavorId); + computeFlavor.ifPresent(deploymentFlavorModel::setCompute_flavor); + } + } + partNumber.ifPresent(spPartNumber -> allowedFlavors.put(spPartNumber, deploymentFlavorModel)); + } + } + } } - } + return allowedFlavors; } - return vspComponentImages; - } - /** - * Gets the component data for manually onboarded VSPs. - * - * @param vspId the vsp id - * @param version the version - * @return the vsp components - */ - public Map<String, String> getVspComponents(String vspId, Version version) { - Map<String, String> componentIdNameMap = new HashMap<>(); - Collection<DeploymentFlavorEntity> deploymentFlavorEntities = - deploymentFlavorDao.list(new DeploymentFlavorEntity(vspId, version, null)); - for (DeploymentFlavorEntity deploymentFlavorEntity : deploymentFlavorEntities) { - DeploymentFlavor deploymentFlavorCompositionData = - deploymentFlavorEntity.getDeploymentFlavorCompositionData(); - - List<ComponentComputeAssociation> componentComputeAssociations = - deploymentFlavorCompositionData.getComponentComputeAssociations(); - if (CollectionUtils.isNotEmpty(componentComputeAssociations)) { - for (ComponentComputeAssociation componentComputeAssociation : - componentComputeAssociations) { - String componentId = componentComputeAssociation.getComponentId(); - Optional<String> componentName = getComponentName(vspId, version, componentId); - componentName.ifPresent(name -> componentIdNameMap.put(componentId, name)); + /** + * Gets the component image data for manually onboarded VSPs. + * + * @param vspId the vsp id + * @param version the version + * @return the vsp component images + */ + public Map<String, List<MultiFlavorVfcImage>> getVspComponentImages(String vspId, Version version) { + Map<String, List<MultiFlavorVfcImage>> vspComponentImages = new HashMap<>(); + Collection<DeploymentFlavorEntity> deploymentFlavorEntities = deploymentFlavorDao.list(new DeploymentFlavorEntity(vspId, version, null)); + for (DeploymentFlavorEntity deploymentFlavorEntity : deploymentFlavorEntities) { + DeploymentFlavor deploymentFlavorCompositionData = deploymentFlavorEntity.getDeploymentFlavorCompositionData(); + List<ComponentComputeAssociation> componentComputeAssociations = deploymentFlavorCompositionData.getComponentComputeAssociations(); + if (CollectionUtils.isNotEmpty(componentComputeAssociations)) { + for (ComponentComputeAssociation componentComputeAssociation : componentComputeAssociations) { + String componentId = componentComputeAssociation.getComponentId(); + List<MultiFlavorVfcImage> componentImages = getComponentImages(vspId, version, componentId); + if (CollectionUtils.isNotEmpty(componentImages)) { + vspComponentImages.put(componentId, componentImages); + } + } + } } - } + return vspComponentImages; } - return componentIdNameMap; - } - /** - * Gets the NIC data for manually onboarded VSPs. - * - * @param vspId the vsp id - * @param version the version - * @return the vsp component nics - */ - public Map<String, List<Nic>> getVspComponentNics(String vspId, Version version) { - Map<String, List<Nic>> vspComponentNics = new HashMap<>(); - Collection<DeploymentFlavorEntity> deploymentFlavorEntities = - deploymentFlavorDao.list(new DeploymentFlavorEntity(vspId, version, null)); - if (CollectionUtils.isNotEmpty(deploymentFlavorEntities)) { - for (DeploymentFlavorEntity deploymentFlavorEntity : deploymentFlavorEntities) { - DeploymentFlavor deploymentFlavorCompositionData = - deploymentFlavorEntity.getDeploymentFlavorCompositionData(); - if (Objects.nonNull(deploymentFlavorCompositionData)) { - List<ComponentComputeAssociation> componentComputeAssociations = - deploymentFlavorCompositionData.getComponentComputeAssociations(); - if (CollectionUtils.isNotEmpty(componentComputeAssociations)) { - for (ComponentComputeAssociation componentComputeAssociation : - componentComputeAssociations) { - String componentId = componentComputeAssociation.getComponentId(); - List<Nic> componentNics = getComponentNics(vspId, version, componentId); - if (CollectionUtils.isNotEmpty(componentNics)) { - vspComponentNics.put(componentId, componentNics); - } + /** + * Gets the component data for manually onboarded VSPs. + * + * @param vspId the vsp id + * @param version the version + * @return the vsp components + */ + public Map<String, String> getVspComponents(String vspId, Version version) { + Map<String, String> componentIdNameMap = new HashMap<>(); + Collection<DeploymentFlavorEntity> deploymentFlavorEntities = deploymentFlavorDao.list(new DeploymentFlavorEntity(vspId, version, null)); + for (DeploymentFlavorEntity deploymentFlavorEntity : deploymentFlavorEntities) { + DeploymentFlavor deploymentFlavorCompositionData = deploymentFlavorEntity.getDeploymentFlavorCompositionData(); + List<ComponentComputeAssociation> componentComputeAssociations = deploymentFlavorCompositionData.getComponentComputeAssociations(); + if (CollectionUtils.isNotEmpty(componentComputeAssociations)) { + for (ComponentComputeAssociation componentComputeAssociation : componentComputeAssociations) { + String componentId = componentComputeAssociation.getComponentId(); + Optional<String> componentName = getComponentName(vspId, version, componentId); + componentName.ifPresent(name -> componentIdNameMap.put(componentId, name)); + } } - } } - } + return componentIdNameMap; } - return vspComponentNics; - } - private List<Nic> getComponentNics(String vspId, Version version, String componentId) { - List<Nic> componentNics = new ArrayList<>(); - Collection<NicEntity> nics = nicDao.list(new NicEntity(vspId, version, componentId, null)); - if (Objects.nonNull(nics)) { - for (NicEntity nic : nics) { - String nicId = nic.getId(); - NicEntity nicEntity = nicDao.get(new NicEntity(vspId, version, componentId, nicId)); - if (Objects.nonNull(nicEntity) - && Objects.nonNull(nicEntity.getCompositionData())) { - componentNics.add(nicEntity.getNicCompositionData()); + /** + * Gets the NIC data for manually onboarded VSPs. + * + * @param vspId the vsp id + * @param version the version + * @return the vsp component nics + */ + public Map<String, List<Nic>> getVspComponentNics(String vspId, Version version) { + Map<String, List<Nic>> vspComponentNics = new HashMap<>(); + Collection<DeploymentFlavorEntity> deploymentFlavorEntities = deploymentFlavorDao.list(new DeploymentFlavorEntity(vspId, version, null)); + if (CollectionUtils.isNotEmpty(deploymentFlavorEntities)) { + for (DeploymentFlavorEntity deploymentFlavorEntity : deploymentFlavorEntities) { + DeploymentFlavor deploymentFlavorCompositionData = deploymentFlavorEntity.getDeploymentFlavorCompositionData(); + if (Objects.nonNull(deploymentFlavorCompositionData)) { + List<ComponentComputeAssociation> componentComputeAssociations = deploymentFlavorCompositionData + .getComponentComputeAssociations(); + if (CollectionUtils.isNotEmpty(componentComputeAssociations)) { + for (ComponentComputeAssociation componentComputeAssociation : componentComputeAssociations) { + String componentId = componentComputeAssociation.getComponentId(); + List<Nic> componentNics = getComponentNics(vspId, version, componentId); + if (CollectionUtils.isNotEmpty(componentNics)) { + vspComponentNics.put(componentId, componentNics); + } + } + } + } + } } - } + return vspComponentNics; } - return componentNics; - } - private LicenseFlavor getLicenseFlavor(String featureGroupId) { - LicenseFlavor licenseFlavor = new LicenseFlavor(); - licenseFlavor.setFeature_group_uuid(featureGroupId); - return licenseFlavor; - } + private List<Nic> getComponentNics(String vspId, Version version, String componentId) { + List<Nic> componentNics = new ArrayList<>(); + Collection<NicEntity> nics = nicDao.list(new NicEntity(vspId, version, componentId, null)); + if (Objects.nonNull(nics)) { + for (NicEntity nic : nics) { + String nicId = nic.getId(); + NicEntity nicEntity = nicDao.get(new NicEntity(vspId, version, componentId, nicId)); + if (Objects.nonNull(nicEntity) && Objects.nonNull(nicEntity.getCompositionData())) { + componentNics.add(nicEntity.getNicCompositionData()); + } + } + } + return componentNics; + } - private Optional<String> getPartNumber(String vlmId, Version version, - String featureGroupId) { - FeatureGroupModel featureGroup = getFeatureGroup(vlmId, version, featureGroupId); - if (Objects.nonNull(featureGroup)) { - return Optional.ofNullable(featureGroup.getFeatureGroup().getPartNumber()); + private LicenseFlavor getLicenseFlavor(String featureGroupId) { + LicenseFlavor licenseFlavor = new LicenseFlavor(); + licenseFlavor.setFeature_group_uuid(featureGroupId); + return licenseFlavor; } - return Optional.empty(); - } - private Optional<VendorInfo> getVendorInfo(String vlmId, String vendorModel, Version version, - String featureGroupId) { - VendorInfo vendorInfo = null; - FeatureGroupModel featureGroup = getFeatureGroup(vlmId, version, featureGroupId); - if (Objects.nonNull(featureGroup)) { - //Process Feature group to get Manufacturer ref no. - String manufacturerReferenceNumber = featureGroup.getEntityManufacturerReferenceNumber(); - vendorInfo = new VendorInfo(); - vendorInfo.setVendor_model(vendorModel); - if (Objects.nonNull(manufacturerReferenceNumber)) { - vendorInfo.setManufacturer_reference_number(manufacturerReferenceNumber); - } + private Optional<String> getPartNumber(String vlmId, Version version, String featureGroupId) { + FeatureGroupModel featureGroup = getFeatureGroup(vlmId, version, featureGroupId); + if (Objects.nonNull(featureGroup)) { + return Optional.ofNullable(featureGroup.getFeatureGroup().getPartNumber()); + } + return Optional.empty(); } - return Optional.ofNullable(vendorInfo); - } - private Optional<ComputeFlavor> getComputeFlavor(String vspId, Version version, - String componentId, String computeFlavorId) { - ComputeFlavor computeFlavor = null; - ComputeEntity computeQuestionnaire; - try { - computeQuestionnaire = computeDao.getQuestionnaireData(vspId, version, componentId, - computeFlavorId); - } catch (Exception ex) { - log.warn("Failed to get QuestionnaireData from computeDao," + - " initializing computeQuestionnaire to null", ex); - computeQuestionnaire = null; + private Optional<VendorInfo> getVendorInfo(String vlmId, String vendorModel, Version version, String featureGroupId) { + VendorInfo vendorInfo = null; + FeatureGroupModel featureGroup = getFeatureGroup(vlmId, version, featureGroupId); + if (Objects.nonNull(featureGroup)) { + //Process Feature group to get Manufacturer ref no. + String manufacturerReferenceNumber = featureGroup.getEntityManufacturerReferenceNumber(); + vendorInfo = new VendorInfo(); + vendorInfo.setVendor_model(vendorModel); + if (Objects.nonNull(manufacturerReferenceNumber)) { + vendorInfo.setManufacturer_reference_number(manufacturerReferenceNumber); + } + } + return Optional.ofNullable(vendorInfo); } - if (Objects.nonNull(computeQuestionnaire)) { - String computeQuestionnaireData = computeQuestionnaire.getQuestionnaireData(); - if (Objects.nonNull(computeQuestionnaireData)) { - Compute compute; + + private Optional<ComputeFlavor> getComputeFlavor(String vspId, Version version, String componentId, String computeFlavorId) { + ComputeFlavor computeFlavor = null; + ComputeEntity computeQuestionnaire; try { - compute = JsonUtil.json2Object(computeQuestionnaireData, Compute.class); + computeQuestionnaire = computeDao.getQuestionnaireData(vspId, version, componentId, computeFlavorId); } catch (Exception ex) { - log.warn("Failed to convert json value to compute object," + - "initializing compute to null", ex); - compute = null; + log.warn("Failed to get QuestionnaireData from computeDao," + " initializing computeQuestionnaire to null", ex); + computeQuestionnaire = null; } - if (compute != null && Objects.nonNull(compute.getVmSizing())) { - computeFlavor = new ComputeFlavor(); - if (Objects.nonNull(compute.getVmSizing().getNumOfCPUs())) { - computeFlavor.setNum_cpus(compute.getVmSizing().getNumOfCPUs()); - } - if (Objects.nonNull(compute.getVmSizing().getFileSystemSizeGB())) { - computeFlavor.setDisk_size(compute.getVmSizing().getFileSystemSizeGB() + " GB"); - } - if (Objects.nonNull(compute.getVmSizing().getMemoryRAM())) { - computeFlavor.setMem_size(compute.getVmSizing().getMemoryRAM()); - } + if (Objects.nonNull(computeQuestionnaire)) { + String computeQuestionnaireData = computeQuestionnaire.getQuestionnaireData(); + if (Objects.nonNull(computeQuestionnaireData)) { + Compute compute; + try { + compute = JsonUtil.json2Object(computeQuestionnaireData, Compute.class); + } catch (Exception ex) { + log.warn("Failed to convert json value to compute object," + "initializing compute to null", ex); + compute = null; + } + if (compute != null && Objects.nonNull(compute.getVmSizing())) { + computeFlavor = new ComputeFlavor(); + if (Objects.nonNull(compute.getVmSizing().getNumOfCPUs())) { + computeFlavor.setNum_cpus(compute.getVmSizing().getNumOfCPUs()); + } + if (Objects.nonNull(compute.getVmSizing().getFileSystemSizeGB())) { + computeFlavor.setDisk_size(compute.getVmSizing().getFileSystemSizeGB() + " GB"); + } + if (Objects.nonNull(compute.getVmSizing().getMemoryRAM())) { + computeFlavor.setMem_size(compute.getVmSizing().getMemoryRAM()); + } + } + } } - } + return Optional.ofNullable(computeFlavor); } - return Optional.ofNullable(computeFlavor); - } - private FeatureGroupModel getFeatureGroup(String vlmId, Version version, String featureGroupId) { - FeatureGroupEntity fgInput = new FeatureGroupEntity(); - fgInput.setVendorLicenseModelId(vlmId); - fgInput.setVersion(version); - fgInput.setId(featureGroupId); - return vendorLicenseFacade.getFeatureGroupModel(fgInput); - } - - private Optional<String> getComponentName(String vspId, Version version, String componentId) { + private FeatureGroupModel getFeatureGroup(String vlmId, Version version, String featureGroupId) { + FeatureGroupEntity fgInput = new FeatureGroupEntity(); + fgInput.setVendorLicenseModelId(vlmId); + fgInput.setVersion(version); + fgInput.setId(featureGroupId); + return vendorLicenseFacade.getFeatureGroupModel(fgInput); + } - ComponentEntity componentEntity = - componentDao.get(new ComponentEntity(vspId, version, componentId)); - if (Objects.nonNull(componentEntity) - && Objects.nonNull(componentEntity.getComponentCompositionData())) { - ComponentData componentCompositionData = componentEntity.getComponentCompositionData(); - return Optional.ofNullable(componentCompositionData.getDisplayName()); + private Optional<String> getComponentName(String vspId, Version version, String componentId) { + ComponentEntity componentEntity = componentDao.get(new ComponentEntity(vspId, version, componentId)); + if (Objects.nonNull(componentEntity) && Objects.nonNull(componentEntity.getComponentCompositionData())) { + ComponentData componentCompositionData = componentEntity.getComponentCompositionData(); + return Optional.ofNullable(componentCompositionData.getDisplayName()); + } + return Optional.empty(); } - return Optional.empty(); - } - private List<MultiFlavorVfcImage> getComponentImages(String vspId, Version version, - String componentId) { - List<MultiFlavorVfcImage> multiFlavorVfcImages = new ArrayList<>(); - MultiFlavorVfcImage multiFlavorVfcImage; - Collection<ImageEntity> componentImages = - imageDao.list(new ImageEntity(vspId, version, componentId, null)); - if (Objects.nonNull(componentImages)) { - for (ImageEntity componentImage : componentImages) { - ImageEntity imageEntity = imageDao.get(componentImage); - ImageEntity imageQuestionnaireDataEntity = imageDao.getQuestionnaireData(vspId, version, - componentId, componentImage.getId()); - Image imageCompositionData = imageEntity.getImageCompositionData(); - if (Objects.nonNull(imageEntity) - && Objects.nonNull(imageQuestionnaireDataEntity) - && Objects.nonNull(imageCompositionData)) { - ImageDetails imageDetails; - try { - imageDetails = JsonUtil.json2Object(imageQuestionnaireDataEntity - .getQuestionnaireData(), ImageDetails.class); - } catch (Exception ex) { - log.warn("Failed to convert json value to ImageDetails object," + - "initializing imageDetails to null", ex); - imageDetails = null; - } - if (Objects.nonNull(imageDetails) - && Objects.nonNull(imageDetails.getVersion())) { - //Image version is used as a key for the image block - //So excluding the population if questionnaire data is absent or invalid - multiFlavorVfcImage = new MultiFlavorVfcImage(); - multiFlavorVfcImage.setSoftware_version(imageDetails.getVersion()); - if (Objects.nonNull(imageCompositionData.getFileName())) { - multiFlavorVfcImage.setFile_name(imageCompositionData.getFileName()); - } - if (Objects.nonNull(imageDetails.getMd5())) { - multiFlavorVfcImage.setFile_hash(imageDetails.getMd5()); + private List<MultiFlavorVfcImage> getComponentImages(String vspId, Version version, String componentId) { + List<MultiFlavorVfcImage> multiFlavorVfcImages = new ArrayList<>(); + MultiFlavorVfcImage multiFlavorVfcImage; + Collection<ImageEntity> componentImages = imageDao.list(new ImageEntity(vspId, version, componentId, null)); + if (Objects.nonNull(componentImages)) { + for (ImageEntity componentImage : componentImages) { + ImageEntity imageEntity = imageDao.get(componentImage); + ImageEntity imageQuestionnaireDataEntity = imageDao.getQuestionnaireData(vspId, version, componentId, componentImage.getId()); + Image imageCompositionData = imageEntity.getImageCompositionData(); + if (Objects.nonNull(imageEntity) && Objects.nonNull(imageQuestionnaireDataEntity) && Objects.nonNull(imageCompositionData)) { + ImageDetails imageDetails; + try { + imageDetails = JsonUtil.json2Object(imageQuestionnaireDataEntity.getQuestionnaireData(), ImageDetails.class); + } catch (Exception ex) { + log.warn("Failed to convert json value to ImageDetails object," + "initializing imageDetails to null", ex); + imageDetails = null; + } + if (Objects.nonNull(imageDetails) && Objects.nonNull(imageDetails.getVersion())) { + //Image version is used as a key for the image block + + //So excluding the population if questionnaire data is absent or invalid + multiFlavorVfcImage = new MultiFlavorVfcImage(); + multiFlavorVfcImage.setSoftware_version(imageDetails.getVersion()); + if (Objects.nonNull(imageCompositionData.getFileName())) { + multiFlavorVfcImage.setFile_name(imageCompositionData.getFileName()); + } + if (Objects.nonNull(imageDetails.getMd5())) { + multiFlavorVfcImage.setFile_hash(imageDetails.getMd5()); + } + multiFlavorVfcImage.setFile_hash_type("md5"); + multiFlavorVfcImages.add(multiFlavorVfcImage); + } + } } - multiFlavorVfcImage.setFile_hash_type("md5"); - multiFlavorVfcImages.add(multiFlavorVfcImage); - } } - } + return multiFlavorVfcImages; } - return multiFlavorVfcImages; - } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/composition/CompositionDataExtractorImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/composition/CompositionDataExtractorImpl.java index 00781c1512..15289025b1 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/composition/CompositionDataExtractorImpl.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/composition/CompositionDataExtractorImpl.java @@ -13,10 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.openecomp.sdc.vendorsoftwareproduct.services.impl.composition; import com.fasterxml.jackson.databind.ObjectMapper; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import java.util.stream.Collectors; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.MapUtils; import org.onap.sdc.tosca.datatypes.model.NodeTemplate; @@ -27,7 +33,11 @@ import org.onap.sdc.tosca.services.ToscaExtensionYamlUtil; import org.openecomp.sdc.common.errors.CoreException; import org.openecomp.sdc.logging.api.Logger; import org.openecomp.sdc.logging.api.LoggerFactory; -import org.openecomp.sdc.tosca.datatypes.*; +import org.openecomp.sdc.tosca.datatypes.ToscaCapabilityType; +import org.openecomp.sdc.tosca.datatypes.ToscaFunctions; +import org.openecomp.sdc.tosca.datatypes.ToscaNodeType; +import org.openecomp.sdc.tosca.datatypes.ToscaRelationshipType; +import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel; import org.openecomp.sdc.tosca.errors.ToscaInvalidEntryNotFoundErrorBuilder; import org.openecomp.sdc.tosca.errors.ToscaInvalidSubstituteNodeTemplateErrorBuilder; import org.openecomp.sdc.tosca.errors.ToscaMissingSubstitutionMappingForReqCapErrorBuilder; @@ -35,427 +45,343 @@ import org.openecomp.sdc.tosca.services.ToscaAnalyzerService; import org.openecomp.sdc.tosca.services.ToscaConstants; import org.openecomp.sdc.tosca.services.impl.ToscaAnalyzerServiceImpl; import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionDataExtractor; -import org.openecomp.sdc.vendorsoftwareproduct.types.composition.*; - -import java.util.*; -import java.util.stream.Collectors; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Component; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentData; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionData; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComputeData; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ExtractCompositionDataContext; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Image; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Network; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Nic; public class CompositionDataExtractorImpl implements CompositionDataExtractor { - protected static Logger logger; - private static ToscaAnalyzerService toscaAnalyzerService; - static { - logger = LoggerFactory.getLogger(CompositionDataExtractorImpl.class); - toscaAnalyzerService = new ToscaAnalyzerServiceImpl(); - } + protected static Logger logger; + private static ToscaAnalyzerService toscaAnalyzerService; - /** - * Extract service composition data composition data. - * - * @param toscaServiceModel the tosca service model - * @return the composition data - */ - public CompositionData extractServiceCompositionData(ToscaServiceModel toscaServiceModel) { - ExtractCompositionDataContext context = new ExtractCompositionDataContext(); - String entryDefinitionServiceTemplateFileName = - toscaServiceModel.getEntryDefinitionServiceTemplate(); - ServiceTemplate entryDefinitionServiceTemplate = - toscaServiceModel.getServiceTemplates().get(entryDefinitionServiceTemplateFileName); - extractServiceCompositionData(entryDefinitionServiceTemplateFileName, - entryDefinitionServiceTemplate, toscaServiceModel, context); - - CompositionData compositionData = new CompositionData(); - compositionData.setNetworks(context.getNetworks()); - compositionData.setComponents(context.getComponents()); - return compositionData; - } - - private void extractServiceCompositionData(String serviceTemplateFileName, - ServiceTemplate serviceTemplate, - ToscaServiceModel toscaServiceModel, - ExtractCompositionDataContext context) { - if (context.getHandledServiceTemplates().contains(serviceTemplateFileName)) { - return; + static { + logger = LoggerFactory.getLogger(CompositionDataExtractorImpl.class); + toscaAnalyzerService = new ToscaAnalyzerServiceImpl(); } - context.addNetworks(extractNetworks(serviceTemplate, toscaServiceModel)); - extractComponents(serviceTemplate, toscaServiceModel, context); - handleSubstitution(serviceTemplate, toscaServiceModel, context); - context.addHandledServiceTemplates(serviceTemplateFileName); - } - private void handleSubstitution(ServiceTemplate serviceTemplate, - ToscaServiceModel toscaServiceModel, - ExtractCompositionDataContext context) { - Map<String, NodeTemplate> substitutableNodeTemplates = - toscaAnalyzerService.getSubstitutableNodeTemplates(serviceTemplate); - - if (substitutableNodeTemplates != null) { - for (String substitutableNodeTemplateId : substitutableNodeTemplates.keySet()) { - handleSubstitutableNodeTemplate(serviceTemplate, toscaServiceModel, - substitutableNodeTemplateId, - substitutableNodeTemplates.get(substitutableNodeTemplateId), context); - } + /** + * Extract service composition data composition data. + * + * @param toscaServiceModel the tosca service model + * @return the composition data + */ + public CompositionData extractServiceCompositionData(ToscaServiceModel toscaServiceModel) { + ExtractCompositionDataContext context = new ExtractCompositionDataContext(); + String entryDefinitionServiceTemplateFileName = toscaServiceModel.getEntryDefinitionServiceTemplate(); + ServiceTemplate entryDefinitionServiceTemplate = toscaServiceModel.getServiceTemplates().get(entryDefinitionServiceTemplateFileName); + extractServiceCompositionData(entryDefinitionServiceTemplateFileName, entryDefinitionServiceTemplate, toscaServiceModel, context); + CompositionData compositionData = new CompositionData(); + compositionData.setNetworks(context.getNetworks()); + compositionData.setComponents(context.getComponents()); + return compositionData; } - } - private void handleSubstitutableNodeTemplate(ServiceTemplate serviceTemplate, - ToscaServiceModel toscaServiceModel, - String substitutableNodeTemplateId, - NodeTemplate substitutableNodeTemplate, - ExtractCompositionDataContext context) { - ToscaExtensionYamlUtil toscaExtensionYamlUtil = new ToscaExtensionYamlUtil(); - Optional<String> substituteServiceTemplateFileName = toscaAnalyzerService - .getSubstituteServiceTemplateName(substitutableNodeTemplateId, substitutableNodeTemplate); - if (!substituteServiceTemplateFileName.isPresent()) { - throw new CoreException( - new ToscaInvalidSubstituteNodeTemplateErrorBuilder(substitutableNodeTemplateId).build()); - } - if (context.getHandledServiceTemplates().contains(substituteServiceTemplateFileName.get())) { - //each substitution is should be handled once, and will get the connection to the upper - // service level according to the first one which was processed - return; - } - - ServiceTemplate substituteServiceTemplate = - toscaServiceModel.getServiceTemplates().get(substituteServiceTemplateFileName.get()); - extractServiceCompositionData(substituteServiceTemplateFileName.get(), - substituteServiceTemplate, toscaServiceModel, context); - - List<Map<String, RequirementAssignment>> substitutableRequirements = - substitutableNodeTemplate.getRequirements(); - - if (CollectionUtils.isEmpty(substitutableRequirements)) { - return; + private void extractServiceCompositionData(String serviceTemplateFileName, ServiceTemplate serviceTemplate, ToscaServiceModel toscaServiceModel, + ExtractCompositionDataContext context) { + if (context.getHandledServiceTemplates().contains(serviceTemplateFileName)) { + return; + } + context.addNetworks(extractNetworks(serviceTemplate, toscaServiceModel)); + extractComponents(serviceTemplate, toscaServiceModel, context); + handleSubstitution(serviceTemplate, toscaServiceModel, context); + context.addHandledServiceTemplates(serviceTemplateFileName); } - for (Map<String, RequirementAssignment> substitutableReq : substitutableRequirements) { - substitutableReq.keySet().stream().filter(reqId -> { - RequirementAssignment reqAssignment = toscaExtensionYamlUtil - .yamlToObject(toscaExtensionYamlUtil.objectToYaml(substitutableReq.get(reqId)), - RequirementAssignment.class); - return isLinkToNetworkRequirementAssignment(reqAssignment); - }).forEach(reqId -> { - RequirementAssignment linkToNetworkRequirement = toscaExtensionYamlUtil - .yamlToObject(toscaExtensionYamlUtil.objectToYaml(substitutableReq.get(reqId)), - RequirementAssignment.class); - String connectedNodeId = linkToNetworkRequirement.getNode(); - Optional<NodeTemplate> connectedNodeTemplate = - toscaAnalyzerService.getNodeTemplateById(serviceTemplate, connectedNodeId); - - if (connectedNodeTemplate.isPresent() && toscaAnalyzerService - .isTypeOf(connectedNodeTemplate.get(), ToscaNodeType.NATIVE_NETWORK, - serviceTemplate, toscaServiceModel)) { - Optional<Map.Entry<String, NodeTemplate>> mappedNodeTemplate = toscaAnalyzerService - .getSubstitutionMappedNodeTemplateByExposedReq( - substituteServiceTemplateFileName.get(), substituteServiceTemplate, reqId); - if (!mappedNodeTemplate.isPresent()) { - throw new CoreException(new ToscaMissingSubstitutionMappingForReqCapErrorBuilder( - ToscaMissingSubstitutionMappingForReqCapErrorBuilder.MappingExposedEntry - .REQUIREMENT, connectedNodeId).build()); - } - - if (toscaAnalyzerService.isTypeOf(mappedNodeTemplate.get().getValue(), - ToscaNodeType.NATIVE_NETWORK_PORT, serviceTemplate, - toscaServiceModel)) { - Nic port = context.getNics().get(mappedNodeTemplate.get().getKey()); - if (port != null) { - port.setNetworkName(connectedNodeId); - } else { - logger.warn( - "Different ports define for the same component which is used in different " - + "substitution service templates."); + private void handleSubstitution(ServiceTemplate serviceTemplate, ToscaServiceModel toscaServiceModel, ExtractCompositionDataContext context) { + Map<String, NodeTemplate> substitutableNodeTemplates = toscaAnalyzerService.getSubstitutableNodeTemplates(serviceTemplate); + if (substitutableNodeTemplates != null) { + for (String substitutableNodeTemplateId : substitutableNodeTemplates.keySet()) { + handleSubstitutableNodeTemplate(serviceTemplate, toscaServiceModel, substitutableNodeTemplateId, + substitutableNodeTemplates.get(substitutableNodeTemplateId), context); } - } - } else if (!connectedNodeTemplate.isPresent()) { - throw new CoreException( - new ToscaInvalidEntryNotFoundErrorBuilder("Node Template", connectedNodeId).build()); } - }); } - } - private boolean isLinkToNetworkRequirementAssignment(RequirementAssignment requirement) { - return toscaAnalyzerService.isDesiredRequirementAssignment(requirement, - ToscaCapabilityType.NATIVE_NETWORK_LINKABLE, null, - ToscaRelationshipType.NATIVE_NETWORK_LINK_TO); - } - - - private void connectPortToNetwork(Nic port, NodeTemplate portNodeTemplate) { - List<RequirementAssignment> linkRequirementsToNetwork = - toscaAnalyzerService.getRequirements(portNodeTemplate, ToscaConstants.LINK_REQUIREMENT_ID); + private void handleSubstitutableNodeTemplate(ServiceTemplate serviceTemplate, ToscaServiceModel toscaServiceModel, + String substitutableNodeTemplateId, NodeTemplate substitutableNodeTemplate, + ExtractCompositionDataContext context) { + ToscaExtensionYamlUtil toscaExtensionYamlUtil = new ToscaExtensionYamlUtil(); + Optional<String> substituteServiceTemplateFileName = toscaAnalyzerService + .getSubstituteServiceTemplateName(substitutableNodeTemplateId, substitutableNodeTemplate); + if (!substituteServiceTemplateFileName.isPresent()) { + throw new CoreException(new ToscaInvalidSubstituteNodeTemplateErrorBuilder(substitutableNodeTemplateId).build()); + } + if (context.getHandledServiceTemplates().contains(substituteServiceTemplateFileName.get())) { + //each substitution is should be handled once, and will get the connection to the upper - //port is connected to one network - for (RequirementAssignment linkRequirementToNetwork : linkRequirementsToNetwork) { - port.setNetworkName(linkRequirementToNetwork.getNode()); + // service level according to the first one which was processed + return; + } + ServiceTemplate substituteServiceTemplate = toscaServiceModel.getServiceTemplates().get(substituteServiceTemplateFileName.get()); + extractServiceCompositionData(substituteServiceTemplateFileName.get(), substituteServiceTemplate, toscaServiceModel, context); + List<Map<String, RequirementAssignment>> substitutableRequirements = substitutableNodeTemplate.getRequirements(); + if (CollectionUtils.isEmpty(substitutableRequirements)) { + return; + } + for (Map<String, RequirementAssignment> substitutableReq : substitutableRequirements) { + substitutableReq.keySet().stream().filter(reqId -> { + RequirementAssignment reqAssignment = toscaExtensionYamlUtil + .yamlToObject(toscaExtensionYamlUtil.objectToYaml(substitutableReq.get(reqId)), RequirementAssignment.class); + return isLinkToNetworkRequirementAssignment(reqAssignment); + }).forEach(reqId -> { + RequirementAssignment linkToNetworkRequirement = toscaExtensionYamlUtil + .yamlToObject(toscaExtensionYamlUtil.objectToYaml(substitutableReq.get(reqId)), RequirementAssignment.class); + String connectedNodeId = linkToNetworkRequirement.getNode(); + Optional<NodeTemplate> connectedNodeTemplate = toscaAnalyzerService.getNodeTemplateById(serviceTemplate, connectedNodeId); + if (connectedNodeTemplate.isPresent() && toscaAnalyzerService + .isTypeOf(connectedNodeTemplate.get(), ToscaNodeType.NATIVE_NETWORK, serviceTemplate, toscaServiceModel)) { + Optional<Map.Entry<String, NodeTemplate>> mappedNodeTemplate = toscaAnalyzerService + .getSubstitutionMappedNodeTemplateByExposedReq(substituteServiceTemplateFileName.get(), substituteServiceTemplate, reqId); + if (!mappedNodeTemplate.isPresent()) { + throw new CoreException(new ToscaMissingSubstitutionMappingForReqCapErrorBuilder( + ToscaMissingSubstitutionMappingForReqCapErrorBuilder.MappingExposedEntry.REQUIREMENT, connectedNodeId).build()); + } + if (toscaAnalyzerService + .isTypeOf(mappedNodeTemplate.get().getValue(), ToscaNodeType.NATIVE_NETWORK_PORT, serviceTemplate, toscaServiceModel)) { + Nic port = context.getNics().get(mappedNodeTemplate.get().getKey()); + if (port != null) { + port.setNetworkName(connectedNodeId); + } else { + logger.warn( + "Different ports define for the same component which is used in different " + "substitution service templates."); + } + } + } else if (!connectedNodeTemplate.isPresent()) { + throw new CoreException(new ToscaInvalidEntryNotFoundErrorBuilder("Node Template", connectedNodeId).build()); + } + }); + } } - } - /* - return Map with key - compute node template id, value - list of connected port node template id - */ - private Map<String, List<String>> getComputeToPortsConnection( - Map<String, NodeTemplate> portNodeTemplates) { - Map<String, List<String>> computeToPortConnection = new HashMap<>(); - if (MapUtils.isEmpty(portNodeTemplates)) { - return computeToPortConnection; + private boolean isLinkToNetworkRequirementAssignment(RequirementAssignment requirement) { + return toscaAnalyzerService.isDesiredRequirementAssignment(requirement, ToscaCapabilityType.NATIVE_NETWORK_LINKABLE, null, + ToscaRelationshipType.NATIVE_NETWORK_LINK_TO); } - for (String portId : portNodeTemplates.keySet()) { - List<RequirementAssignment> bindingRequirementsToCompute = toscaAnalyzerService - .getRequirements(portNodeTemplates.get(portId), ToscaConstants.BINDING_REQUIREMENT_ID); - for (RequirementAssignment bindingRequirementToCompute : bindingRequirementsToCompute) { - computeToPortConnection - .putIfAbsent(bindingRequirementToCompute.getNode(), new ArrayList<>()); - computeToPortConnection.get(bindingRequirementToCompute.getNode()).add(portId); - } - } - return computeToPortConnection; - } - private void extractComponents(ServiceTemplate serviceTemplate, - ToscaServiceModel toscaServiceModel, - ExtractCompositionDataContext context) { - Map<String, NodeTemplate> computeNodeTemplates = toscaAnalyzerService - .getNodeTemplatesByType(serviceTemplate, ToscaNodeType.NATIVE_COMPUTE, - toscaServiceModel); - if (MapUtils.isEmpty(computeNodeTemplates)) { - return; + private void connectPortToNetwork(Nic port, NodeTemplate portNodeTemplate) { + List<RequirementAssignment> linkRequirementsToNetwork = toscaAnalyzerService + .getRequirements(portNodeTemplate, ToscaConstants.LINK_REQUIREMENT_ID); + //port is connected to one network + for (RequirementAssignment linkRequirementToNetwork : linkRequirementsToNetwork) { + port.setNetworkName(linkRequirementToNetwork.getNode()); + } } - Map<String, List<String>> imageNodeTemplates = getComponentImages(computeNodeTemplates, - toscaServiceModel); - Map<String, List<String>> computeFlavorNodeTemplates = - getComponentComputeFlavor(computeNodeTemplates, toscaServiceModel); - Map<String, NodeTemplate> portNodeTemplates = toscaAnalyzerService - .getNodeTemplatesByType(serviceTemplate, ToscaNodeType.NATIVE_NETWORK_PORT, - toscaServiceModel); - Map<String, List<String>> computeToPortsConnection = - getComputeToPortsConnection(portNodeTemplates); - Map<String, List<String>> computesGroupedByType = - getNodeTemplatesGroupedByType(computeNodeTemplates); - computesGroupedByType.keySet() - .stream() - .filter(nodeType -> - !context.getCreatedComponents().contains(nodeType)) - .forEach(nodeType -> extractComponent(serviceTemplate, computeToPortsConnection, - computesGroupedByType, imageNodeTemplates, computeFlavorNodeTemplates, nodeType, - context)); - } - - private Map<String,List<String>> getComponentImages(Map<String, NodeTemplate> - computeNodeTemplates, - ToscaServiceModel toscaServiceModel) { - return getComponentProperty(ToscaConstants.COMPUTE_IMAGE, computeNodeTemplates, toscaServiceModel); - } - - private Map<String,List<String>> getComponentComputeFlavor(Map<String, NodeTemplate> - computeNodeTemplates, - ToscaServiceModel toscaServiceModel) { - return getComponentProperty(ToscaConstants.COMPUTE_FLAVOR, computeNodeTemplates, toscaServiceModel); - } - - private Map<String, List<String>> getComponentProperty(String propertyName, - Map<String, NodeTemplate> computeNodeTemplates, - ToscaServiceModel toscaServiceModel) { - Map<String,List<String>> componentPropertyValues = new HashMap<>(); - for (String component : computeNodeTemplates.keySet()) { - List<String> computes = new ArrayList<>(); - Map<String,Object> properties = computeNodeTemplates.get(component).getProperties(); - - if(MapUtils.isEmpty(properties)){ - continue; - } - - List<Object> computesList = properties.entrySet() - .stream() - .filter(map -> map.getKey().equals(propertyName)) - .map(Map.Entry::getValue) - .collect(Collectors.toList()); - for (Object obj : computesList) { - if (obj instanceof String) { - computes.add((String) obj); - } else { - Map<String, String> objMap = new ObjectMapper().convertValue(obj, Map.class); - computes.add(getInputs(toscaServiceModel, objMap.get("get_input"))); + /* + return Map with key - compute node template id, value - list of connected port node template id + */ + private Map<String, List<String>> getComputeToPortsConnection(Map<String, NodeTemplate> portNodeTemplates) { + Map<String, List<String>> computeToPortConnection = new HashMap<>(); + if (MapUtils.isEmpty(portNodeTemplates)) { + return computeToPortConnection; } - } - componentPropertyValues.put(component,computes); + for (String portId : portNodeTemplates.keySet()) { + List<RequirementAssignment> bindingRequirementsToCompute = toscaAnalyzerService + .getRequirements(portNodeTemplates.get(portId), ToscaConstants.BINDING_REQUIREMENT_ID); + for (RequirementAssignment bindingRequirementToCompute : bindingRequirementsToCompute) { + computeToPortConnection.putIfAbsent(bindingRequirementToCompute.getNode(), new ArrayList<>()); + computeToPortConnection.get(bindingRequirementToCompute.getNode()).add(portId); + } + } + return computeToPortConnection; } - return componentPropertyValues; - } - - private String getInputs(ToscaServiceModel toscaServiceModel, String inputValue) { - String mainTemplate = toscaServiceModel.getEntryDefinitionServiceTemplate(); - List<ServiceTemplate> toscaServiceTemplates = toscaServiceModel.getServiceTemplates().entrySet() - .stream() - .filter(map -> map.getKey().equals(mainTemplate)) - .map(Map.Entry::getValue) - .collect(Collectors.toList()); - ServiceTemplate serviceTemplate = toscaServiceTemplates.get(0); - if (Objects.nonNull(serviceTemplate.getTopology_template()) - && MapUtils.isNotEmpty(serviceTemplate.getTopology_template().getInputs())) { - for (Map.Entry<String, ParameterDefinition> inputEntry : serviceTemplate - .getTopology_template().getInputs().entrySet()) { - if (inputEntry.getKey().equals(inputValue)) { - String value; - try { - value= (String) inputEntry.getValue().get_default(); - } catch (Exception e) { - logger.debug(e.getMessage(), e); - value = inputEntry.getValue().get_default().toString(); - } - return value; + private void extractComponents(ServiceTemplate serviceTemplate, ToscaServiceModel toscaServiceModel, ExtractCompositionDataContext context) { + Map<String, NodeTemplate> computeNodeTemplates = toscaAnalyzerService + .getNodeTemplatesByType(serviceTemplate, ToscaNodeType.NATIVE_COMPUTE, toscaServiceModel); + if (MapUtils.isEmpty(computeNodeTemplates)) { + return; } - } + Map<String, List<String>> imageNodeTemplates = getComponentImages(computeNodeTemplates, toscaServiceModel); + Map<String, List<String>> computeFlavorNodeTemplates = getComponentComputeFlavor(computeNodeTemplates, toscaServiceModel); + Map<String, NodeTemplate> portNodeTemplates = toscaAnalyzerService + .getNodeTemplatesByType(serviceTemplate, ToscaNodeType.NATIVE_NETWORK_PORT, toscaServiceModel); + Map<String, List<String>> computeToPortsConnection = getComputeToPortsConnection(portNodeTemplates); + Map<String, List<String>> computesGroupedByType = getNodeTemplatesGroupedByType(computeNodeTemplates); + computesGroupedByType.keySet().stream().filter(nodeType -> !context.getCreatedComponents().contains(nodeType)).forEach( + nodeType -> extractComponent(serviceTemplate, computeToPortsConnection, computesGroupedByType, imageNodeTemplates, + computeFlavorNodeTemplates, nodeType, context)); } - return inputValue; - } - - private void extractComponent(ServiceTemplate serviceTemplate, - Map<String, List<String>> computeToPortsConnection, - Map<String, List<String>> computesGroupedByType, - Map<String, List<String>> imageList, - Map<String, List<String>> computeFlavorNodeTemplates, - String computeNodeType, - ExtractCompositionDataContext context) { - ComponentData component = new ComponentData(); - component.setName(computeNodeType); - component.setDisplayName(getComponentDisplayName(component.getName())); - Component componentModel = new Component(); - componentModel.setData(component); - - String computeId = computesGroupedByType.get(computeNodeType).get(0); - List<String> connectedPortIds = computeToPortsConnection.get(computeId); - List<String> images = imageList.get(computeId); - List<String> computeFlavors = computeFlavorNodeTemplates.get(computeId); - if (CollectionUtils.isNotEmpty(connectedPortIds)) { - componentModel.setNics(new ArrayList<>()); - componentModel.setImages(new ArrayList<>()); - componentModel.setCompute(new ArrayList<>()); - - connectedPortIds.forEach(portId -> { - Nic port = extractPort(serviceTemplate, portId); - componentModel.getNics().add(port); - context.addNic(portId, port); - }); - - if (CollectionUtils.isNotEmpty(images)) { - images.forEach(image -> { - Image img = new Image(image); - componentModel.getImages().add(img); - context.addImage(image, img); - }); - } - - if (CollectionUtils.isNotEmpty(computeFlavors)) { - computeFlavors.forEach(flavor -> { - ComputeData computeFlavor = new ComputeData(flavor); - componentModel.getCompute().add(computeFlavor); - context.addCompute(flavor, computeFlavor); - }); - } + private Map<String, List<String>> getComponentImages(Map<String, NodeTemplate> computeNodeTemplates, ToscaServiceModel toscaServiceModel) { + return getComponentProperty(ToscaConstants.COMPUTE_IMAGE, computeNodeTemplates, toscaServiceModel); } - context.addComponent(componentModel); - context.getCreatedComponents().add(computeNodeType); - } - private Nic extractPort(ServiceTemplate serviceTemplate, String portNodeTemplateId) { - Optional<NodeTemplate> portNodeTemplate = - toscaAnalyzerService.getNodeTemplateById(serviceTemplate, portNodeTemplateId); - if (portNodeTemplate.isPresent()) { - Nic port = new Nic(); - port.setName(portNodeTemplateId); - connectPortToNetwork(port, portNodeTemplate.get()); - return port; - } else { - throw new CoreException( - new ToscaInvalidEntryNotFoundErrorBuilder("Node Template", portNodeTemplateId).build()); + private Map<String, List<String>> getComponentComputeFlavor(Map<String, NodeTemplate> computeNodeTemplates, ToscaServiceModel toscaServiceModel) { + return getComponentProperty(ToscaConstants.COMPUTE_FLAVOR, computeNodeTemplates, toscaServiceModel); } - } - private Map<String, List<String>> getNodeTemplatesGroupedByType( - Map<String, NodeTemplate> nodeTemplates) { - Map<String, List<String>> nodeTemplatesGrouped = - new HashMap<>(); //key - node type, value - list of node ids with this type - for (String nodeId : nodeTemplates.keySet()) { - String nodeType = nodeTemplates.get(nodeId).getType(); - nodeTemplatesGrouped.putIfAbsent(nodeType, new ArrayList<>()); - nodeTemplatesGrouped.get(nodeType).add(nodeId); + private Map<String, List<String>> getComponentProperty(String propertyName, Map<String, NodeTemplate> computeNodeTemplates, + ToscaServiceModel toscaServiceModel) { + Map<String, List<String>> componentPropertyValues = new HashMap<>(); + for (String component : computeNodeTemplates.keySet()) { + List<String> computes = new ArrayList<>(); + Map<String, Object> properties = computeNodeTemplates.get(component).getProperties(); + if (MapUtils.isEmpty(properties)) { + continue; + } + List<Object> computesList = properties.entrySet().stream().filter(map -> map.getKey().equals(propertyName)).map(Map.Entry::getValue) + .collect(Collectors.toList()); + for (Object obj : computesList) { + if (obj instanceof String) { + computes.add((String) obj); + } else { + Map<String, String> objMap = new ObjectMapper().convertValue(obj, Map.class); + computes.add(getInputs(toscaServiceModel, objMap.get("get_input"))); + } + } + componentPropertyValues.put(component, computes); + } + return componentPropertyValues; } - return nodeTemplatesGrouped; - } - private List<Network> extractNetworks(ServiceTemplate serviceTemplate, - ToscaServiceModel toscaServiceModel) { - List<Network> networks = new ArrayList<>(); - Map<String, NodeTemplate> networkNodeTemplates = toscaAnalyzerService - .getNodeTemplatesByType(serviceTemplate, ToscaNodeType.NATIVE_NETWORK, - toscaServiceModel); - if (MapUtils.isEmpty(networkNodeTemplates)) { - return networks; - } - for (String networkId : networkNodeTemplates.keySet()) { - Network network = new Network(); - network.setName(networkId); - Optional<Boolean> networkDhcpValue = - getNetworkDhcpValue(serviceTemplate, networkNodeTemplates.get(networkId)); - network.setDhcp(networkDhcpValue.orElse(true)); - networks.add(network); + private String getInputs(ToscaServiceModel toscaServiceModel, String inputValue) { + String mainTemplate = toscaServiceModel.getEntryDefinitionServiceTemplate(); + List<ServiceTemplate> toscaServiceTemplates = toscaServiceModel.getServiceTemplates().entrySet().stream() + .filter(map -> map.getKey().equals(mainTemplate)).map(Map.Entry::getValue).collect(Collectors.toList()); + ServiceTemplate serviceTemplate = toscaServiceTemplates.get(0); + if (Objects.nonNull(serviceTemplate.getTopology_template()) && MapUtils.isNotEmpty(serviceTemplate.getTopology_template().getInputs())) { + for (Map.Entry<String, ParameterDefinition> inputEntry : serviceTemplate.getTopology_template().getInputs().entrySet()) { + if (inputEntry.getKey().equals(inputValue)) { + String value; + try { + value = (String) inputEntry.getValue().get_default(); + } catch (Exception e) { + logger.debug(e.getMessage(), e); + value = inputEntry.getValue().get_default().toString(); + } + return value; + } + } + } + return inputValue; } - return networks; - } - //dhcp default value is true - private Optional<Boolean> getNetworkDhcpValue(ServiceTemplate serviceTemplate, - NodeTemplate networkNodeTemplate) { - if (networkNodeTemplate == null) { - return Optional.empty(); - } - if (networkNodeTemplate.getProperties() == null - || networkNodeTemplate.getProperties().get(ToscaConstants.DHCP_ENABLED_PROPERTY_NAME) - == null) { - return Optional.of(true); + private void extractComponent(ServiceTemplate serviceTemplate, Map<String, List<String>> computeToPortsConnection, + Map<String, List<String>> computesGroupedByType, Map<String, List<String>> imageList, + Map<String, List<String>> computeFlavorNodeTemplates, String computeNodeType, + ExtractCompositionDataContext context) { + ComponentData component = new ComponentData(); + component.setName(computeNodeType); + component.setDisplayName(getComponentDisplayName(component.getName())); + Component componentModel = new Component(); + componentModel.setData(component); + String computeId = computesGroupedByType.get(computeNodeType).get(0); + List<String> connectedPortIds = computeToPortsConnection.get(computeId); + List<String> images = imageList.get(computeId); + List<String> computeFlavors = computeFlavorNodeTemplates.get(computeId); + if (CollectionUtils.isNotEmpty(connectedPortIds)) { + componentModel.setNics(new ArrayList<>()); + componentModel.setImages(new ArrayList<>()); + componentModel.setCompute(new ArrayList<>()); + connectedPortIds.forEach(portId -> { + Nic port = extractPort(serviceTemplate, portId); + componentModel.getNics().add(port); + context.addNic(portId, port); + }); + if (CollectionUtils.isNotEmpty(images)) { + images.forEach(image -> { + Image img = new Image(image); + componentModel.getImages().add(img); + context.addImage(image, img); + }); + } + if (CollectionUtils.isNotEmpty(computeFlavors)) { + computeFlavors.forEach(flavor -> { + ComputeData computeFlavor = new ComputeData(flavor); + componentModel.getCompute().add(computeFlavor); + context.addCompute(flavor, computeFlavor); + }); + } + } + context.addComponent(componentModel); + context.getCreatedComponents().add(computeNodeType); } - Object dhcp = - networkNodeTemplate.getProperties().get(ToscaConstants.DHCP_ENABLED_PROPERTY_NAME); - if (dhcp instanceof String) { - return Optional.of(Boolean.valueOf((String) dhcp)); - } else if (dhcp instanceof Boolean) { - return Optional.of((Boolean) dhcp); - } else if (dhcp instanceof Map) { - String inputParameterName = - (String) ((Map) dhcp).get(ToscaFunctions.GET_INPUT.getFunctionName()); - if (inputParameterName != null) { - ParameterDefinition inputParameterDefinition = - serviceTemplate.getTopology_template().getInputs().get(inputParameterName); - if (inputParameterDefinition != null) { - if (inputParameterDefinition.get_default() != null) { - return Optional.of(Boolean.valueOf(inputParameterDefinition.get_default().toString())); - } + private Nic extractPort(ServiceTemplate serviceTemplate, String portNodeTemplateId) { + Optional<NodeTemplate> portNodeTemplate = toscaAnalyzerService.getNodeTemplateById(serviceTemplate, portNodeTemplateId); + if (portNodeTemplate.isPresent()) { + Nic port = new Nic(); + port.setName(portNodeTemplateId); + connectPortToNetwork(port, portNodeTemplate.get()); + return port; } else { - throw new CoreException( - new ToscaInvalidEntryNotFoundErrorBuilder("Input Parameter", inputParameterName) - .build()); + throw new CoreException(new ToscaInvalidEntryNotFoundErrorBuilder("Node Template", portNodeTemplateId).build()); } - } } - return Optional.of(true); - } - @Override - public String getComponentDisplayName(String componentName) { - if (componentName == null) { - return null; + private Map<String, List<String>> getNodeTemplatesGroupedByType(Map<String, NodeTemplate> nodeTemplates) { + Map<String, List<String>> nodeTemplatesGrouped = + new HashMap<>(); //key - node type, value - list of node ids with this type + for (String nodeId : nodeTemplates.keySet()) { + String nodeType = nodeTemplates.get(nodeId).getType(); + nodeTemplatesGrouped.putIfAbsent(nodeType, new ArrayList<>()); + nodeTemplatesGrouped.get(nodeType).add(nodeId); + } + return nodeTemplatesGrouped; } - String delimiterChar = "."; - if (componentName.contains(delimiterChar)) { - return componentName.substring(componentName.lastIndexOf(delimiterChar) + 1); + + private List<Network> extractNetworks(ServiceTemplate serviceTemplate, ToscaServiceModel toscaServiceModel) { + List<Network> networks = new ArrayList<>(); + Map<String, NodeTemplate> networkNodeTemplates = toscaAnalyzerService + .getNodeTemplatesByType(serviceTemplate, ToscaNodeType.NATIVE_NETWORK, toscaServiceModel); + if (MapUtils.isEmpty(networkNodeTemplates)) { + return networks; + } + for (String networkId : networkNodeTemplates.keySet()) { + Network network = new Network(); + network.setName(networkId); + Optional<Boolean> networkDhcpValue = getNetworkDhcpValue(serviceTemplate, networkNodeTemplates.get(networkId)); + network.setDhcp(networkDhcpValue.orElse(true)); + networks.add(network); + } + return networks; } - return componentName; - } + //dhcp default value is true + private Optional<Boolean> getNetworkDhcpValue(ServiceTemplate serviceTemplate, NodeTemplate networkNodeTemplate) { + if (networkNodeTemplate == null) { + return Optional.empty(); + } + if (networkNodeTemplate.getProperties() == null + || networkNodeTemplate.getProperties().get(ToscaConstants.DHCP_ENABLED_PROPERTY_NAME) == null) { + return Optional.of(true); + } + Object dhcp = networkNodeTemplate.getProperties().get(ToscaConstants.DHCP_ENABLED_PROPERTY_NAME); + if (dhcp instanceof String) { + return Optional.of(Boolean.valueOf((String) dhcp)); + } else if (dhcp instanceof Boolean) { + return Optional.of((Boolean) dhcp); + } else if (dhcp instanceof Map) { + String inputParameterName = (String) ((Map) dhcp).get(ToscaFunctions.GET_INPUT.getFunctionName()); + if (inputParameterName != null) { + ParameterDefinition inputParameterDefinition = serviceTemplate.getTopology_template().getInputs().get(inputParameterName); + if (inputParameterDefinition != null) { + if (inputParameterDefinition.get_default() != null) { + return Optional.of(Boolean.valueOf(inputParameterDefinition.get_default().toString())); + } + } else { + throw new CoreException(new ToscaInvalidEntryNotFoundErrorBuilder("Input Parameter", inputParameterName).build()); + } + } + } + return Optional.of(true); + } + @Override + public String getComponentDisplayName(String componentName) { + if (componentName == null) { + return null; + } + String delimiterChar = "."; + if (componentName.contains(delimiterChar)) { + return componentName.substring(componentName.lastIndexOf(delimiterChar) + 1); + } + return componentName; + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/etsi/ETSIServiceImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/etsi/ETSIServiceImpl.java index 951cfc7d1f..258b058df7 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/etsi/ETSIServiceImpl.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/etsi/ETSIServiceImpl.java @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.services.impl.etsi; import static org.openecomp.sdc.tosca.csar.CSARConstants.ARTIFACTS_FOLDER; @@ -63,7 +62,6 @@ import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel; public class ETSIServiceImpl implements ETSIService { private static final Logger LOGGER = LoggerFactory.getLogger(ETSIServiceImpl.class); - private final NonManoConfiguration nonManoConfiguration; public ETSIServiceImpl() { @@ -99,25 +97,19 @@ public class ETSIServiceImpl implements ETSIService { .forEach(manifestNonManoSourceEntry -> { final NonManoFolderType nonManoFolderType = nonManoKeyFolderMapping.get(manifestNonManoSourceEntry.getKey()); final List<String> nonManoFileList = manifestNonManoSourceEntry.getValue(); - final Map<String, Path> actualFromToPathMap = nonManoFileList.stream() - .map(nonManoFilePath -> { - final Path normalizedFilePath = resolveNonManoFilePath(originalManifestPath, nonManoFilePath); - final Optional<Path> changedPath = updateNonManoPathInHandler(handler, nonManoFolderType, normalizedFilePath); - if (changedPath.isPresent()) { - final Map<String, Path> fromAndToPathMap = new HashMap<>(); - fromAndToPathMap.put(nonManoFilePath, Paths.get(ARTIFACTS_FOLDER).resolve(changedPath.get())); - return fromAndToPathMap; - } - return null; - }) - .filter(Objects::nonNull) - .collect(Collectors.toMap( - fromToPathEntry -> fromToPathEntry.keySet().iterator().next(), - fromToPathEntry -> fromToPathEntry.values().iterator().next() - )); + final Map<String, Path> actualFromToPathMap = nonManoFileList.stream().map(nonManoFilePath -> { + final Path normalizedFilePath = resolveNonManoFilePath(originalManifestPath, nonManoFilePath); + final Optional<Path> changedPath = updateNonManoPathInHandler(handler, nonManoFolderType, normalizedFilePath); + if (changedPath.isPresent()) { + final Map<String, Path> fromAndToPathMap = new HashMap<>(); + fromAndToPathMap.put(nonManoFilePath, Paths.get(ARTIFACTS_FOLDER).resolve(changedPath.get())); + return fromAndToPathMap; + } + return null; + }).filter(Objects::nonNull).collect(Collectors.toMap(fromToPathEntry -> fromToPathEntry.keySet().iterator().next(), + fromToPathEntry -> fromToPathEntry.values().iterator().next())); fromToPathMap.putAll(actualFromToPathMap); }); - return MapUtils.isEmpty(fromToPathMap) ? Optional.empty() : Optional.of(fromToPathMap); } @@ -125,7 +117,7 @@ public class ETSIServiceImpl implements ETSIService { * Resolves the non mano file path based on the original manifest path of the onboarded package. * * @param originalManifestPath The original path from the onboarded package manifest - * @param nonManoFilePath The non mano file path defined in the manifest + * @param nonManoFilePath The non mano file path defined in the manifest * @return The resolved and normalized non mano path. */ private Path resolveNonManoFilePath(final Path originalManifestPath, final String nonManoFilePath) { @@ -135,8 +127,8 @@ public class ETSIServiceImpl implements ETSIService { /** * Updates the non mano file path in the package file handler based on the non mano type. * - * @param handler The package file handler - * @param nonManoFolderType The Non Mano type of the file to update + * @param handler The package file handler + * @param nonManoFolderType The Non Mano type of the file to update * @param nonManoOriginalFilePath The Non Mano file original path * @return The new file path if it was updated in the package file handler, otherwise empty. */ @@ -144,23 +136,22 @@ public class ETSIServiceImpl implements ETSIService { final Path nonManoOriginalFilePath) { final Path fixedSourcePath = fixNonManoPath(nonManoOriginalFilePath); if (handler.containsFile(fixedSourcePath.toString())) { - final Path newNonManoPath = Paths.get(nonManoFolderType.getType(), nonManoFolderType.getLocation() - , fixedSourcePath.getFileName().toString()); + final Path newNonManoPath = Paths + .get(nonManoFolderType.getType(), nonManoFolderType.getLocation(), fixedSourcePath.getFileName().toString()); if (!handler.containsFile(newNonManoPath.toString())) { handler.addFile(newNonManoPath.toString(), handler.remove(fixedSourcePath.toString())); return Optional.of(newNonManoPath); } } - return Optional.empty(); } /** * Fix the original non mano file path to the ONAP package file path. - * - * Non mano artifacts that were inside the {@link org.openecomp.sdc.tosca.csar.CSARConstants#ARTIFACTS_FOLDER} path - * are not moved when parsed to ONAP package, but the Manifest declaration can still have the {@link - * org.openecomp.sdc.tosca.csar.CSARConstants#ARTIFACTS_FOLDER} reference in it. If so, that reference is removed. + * <p> + * Non mano artifacts that were inside the {@link org.openecomp.sdc.tosca.csar.CSARConstants#ARTIFACTS_FOLDER} path are not moved when parsed to + * ONAP package, but the Manifest declaration can still have the {@link org.openecomp.sdc.tosca.csar.CSARConstants#ARTIFACTS_FOLDER} reference in + * it. If so, that reference is removed. * * @param nonManoOriginalFilePath The original non mano file path * @return The non mano fixed path to ONAP package structure. @@ -174,28 +165,22 @@ public class ETSIServiceImpl implements ETSIService { if (nonManoOriginalFilePath.startsWith(relativeArtifactsPath)) { return relativeArtifactsPath.relativize(nonManoOriginalFilePath); } - return nonManoOriginalFilePath; } @Override - public void updateMainDescriptorPaths(final ToscaServiceModel toscaServiceModel, - final Map<String, Path> fromToMovedArtifactMap) { - final ServiceTemplate entryDefinition = toscaServiceModel.getServiceTemplates() - .get(toscaServiceModel.getEntryDefinitionServiceTemplate()); + public void updateMainDescriptorPaths(final ToscaServiceModel toscaServiceModel, final Map<String, Path> fromToMovedArtifactMap) { + final ServiceTemplate entryDefinition = toscaServiceModel.getServiceTemplates().get(toscaServiceModel.getEntryDefinitionServiceTemplate()); final YamlUtil yamlUtil = new YamlUtil(); final String[] entryDefinitionYaml = {yamlUtil.objectToYaml(entryDefinition)}; - fromToMovedArtifactMap.forEach((fromPath, toPath) -> entryDefinitionYaml[0] = entryDefinitionYaml[0] - .replaceAll(fromPath, toPath.toString())); - - toscaServiceModel.addServiceTemplate(toscaServiceModel.getEntryDefinitionServiceTemplate() - , yamlUtil.yamlToObject(entryDefinitionYaml[0], ServiceTemplate.class)); + fromToMovedArtifactMap.forEach((fromPath, toPath) -> entryDefinitionYaml[0] = entryDefinitionYaml[0].replaceAll(fromPath, toPath.toString())); + toscaServiceModel.addServiceTemplate(toscaServiceModel.getEntryDefinitionServiceTemplate(), + yamlUtil.yamlToObject(entryDefinitionYaml[0], ServiceTemplate.class)); } private boolean hasMetaMandatoryEntries(final ToscaMetadata toscaMetadata) { final Map<String, String> metaDataEntries = toscaMetadata.getMetaEntries(); - return metaDataEntries.containsKey(ENTRY_DEFINITIONS.getName()) && metaDataEntries - .containsKey(ETSI_ENTRY_MANIFEST.getName()) + return metaDataEntries.containsKey(ENTRY_DEFINITIONS.getName()) && metaDataEntries.containsKey(ETSI_ENTRY_MANIFEST.getName()) && metaDataEntries.containsKey(ETSI_ENTRY_CHANGE_LOG.getName()); } @@ -204,23 +189,21 @@ public class ETSIServiceImpl implements ETSIService { try { Map<String, String> metadata = getManifest(handler).getMetadata(); if (metadata.containsKey(COMPATIBLE_SPECIFICATION_VERSIONS.getToken())) { - return Arrays.asList(metadata.get(COMPATIBLE_SPECIFICATION_VERSIONS.getToken()).split(",")) - .stream().map(Semver::new).max((v1, v2) -> v1.compareTo(v2)) - .orElse(new Semver(ETSI_VERSION_2_6_1)); + return Arrays.asList(metadata.get(COMPATIBLE_SPECIFICATION_VERSIONS.getToken()).split(",")).stream().map(Semver::new) + .max((v1, v2) -> v1.compareTo(v2)).orElse(new Semver(ETSI_VERSION_2_6_1)); } } catch (Exception ex) { LOGGER.error("An error occurred while getting highest compatible version from manifest file", ex); } return new Semver(ETSI_VERSION_2_6_1); - } @Override public boolean hasCnfEnhancements(final FileContentHandler fileContentHandler) throws IOException { final Manifest manifest = loadManifest(fileContentHandler); return manifest.getNonManoSources().entrySet().stream() - .filter(manifestNonManoSourceEntry -> NonManoArtifactType.ONAP_CNF_HELM.getType() - .equalsIgnoreCase(manifestNonManoSourceEntry.getKey())).findFirst().isPresent(); + .filter(manifestNonManoSourceEntry -> NonManoArtifactType.ONAP_CNF_HELM.getType().equalsIgnoreCase(manifestNonManoSourceEntry.getKey())) + .findFirst().isPresent(); } private Manifest loadManifest(final FileContentHandler handler) throws IOException { @@ -248,9 +231,10 @@ public class ETSIServiceImpl implements ETSIService { public ResourceTypeEnum getResourceType(Manifest manifest) { // Valid manifest should contain whether vnf or pnf related metadata data exclusively in SOL004 standard, + // validation of manifest done during package upload stage - if (manifest != null && !manifest.getMetadata().isEmpty() - && MANIFEST_PNF_METADATA.stream().anyMatch(e -> manifest.getMetadata().containsKey(e))) { + if (manifest != null && !manifest.getMetadata().isEmpty() && MANIFEST_PNF_METADATA.stream() + .anyMatch(e -> manifest.getMetadata().containsKey(e))) { return ResourceTypeEnum.PNF; } // VNF is default resource type @@ -280,11 +264,9 @@ public class ETSIServiceImpl implements ETSIService { private ToscaMetadata getMetadata(FileContentHandler handler) throws IOException { ToscaMetadata metadata; if (handler.containsFile(TOSCA_META_PATH_FILE_NAME)) { - metadata = OnboardingToscaMetadata - .parseToscaMetadataFile(handler.getFileContentAsStream(TOSCA_META_PATH_FILE_NAME)); + metadata = OnboardingToscaMetadata.parseToscaMetadataFile(handler.getFileContentAsStream(TOSCA_META_PATH_FILE_NAME)); } else if (handler.containsFile(TOSCA_META_ORIG_PATH_FILE_NAME)) { - metadata = OnboardingToscaMetadata - .parseToscaMetadataFile(handler.getFileContentAsStream(TOSCA_META_ORIG_PATH_FILE_NAME)); + metadata = OnboardingToscaMetadata.parseToscaMetadataFile(handler.getFileContentAsStream(TOSCA_META_ORIG_PATH_FILE_NAME)); } else { throw new IOException("TOSCA.meta file not found!"); } @@ -293,8 +275,7 @@ public class ETSIServiceImpl implements ETSIService { private ToscaMetadata getOriginalMetadata(final FileContentHandler handler) throws IOException { if (handler.containsFile(TOSCA_META_ORIG_PATH_FILE_NAME)) { - return OnboardingToscaMetadata - .parseToscaMetadataFile(handler.getFileContentAsStream(TOSCA_META_ORIG_PATH_FILE_NAME)); + return OnboardingToscaMetadata.parseToscaMetadataFile(handler.getFileContentAsStream(TOSCA_META_ORIG_PATH_FILE_NAME)); } else { throw new IOException(String.format("%s file not found", TOSCA_META_ORIG_PATH_FILE_NAME)); } @@ -307,7 +288,6 @@ public class ETSIServiceImpl implements ETSIService { } else { io = handler.getFileContentAsStream(manifestLocation); } - if (io == null) { throw new IOException("Manifest file not found!"); } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/CandidateServiceImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/CandidateServiceImpl.java index 7c11fb65ab..7ba8732091 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/CandidateServiceImpl.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/CandidateServiceImpl.java @@ -14,7 +14,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.openecomp.sdc.vendorsoftwareproduct.services.impl.filedatastructuremodule; import static org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder.getErrorWithParameters; @@ -72,578 +71,491 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class CandidateServiceImpl implements CandidateService { - private static final Logger logger = LoggerFactory.getLogger(CandidateServiceImpl.class); - private CandidateServiceValidator candidateServiceValidator = new CandidateServiceValidator(); - private ManifestCreator manifestCreator; - private OrchestrationTemplateCandidateDao orchestrationTemplateCandidateDao; - - public CandidateServiceImpl(ManifestCreator manifestCreator, - OrchestrationTemplateCandidateDao orchestrationTemplateCandidateDao) { - this.manifestCreator = manifestCreator; - this.orchestrationTemplateCandidateDao = orchestrationTemplateCandidateDao; - } - - public CandidateServiceImpl() { - } - - @Override - public Optional<ErrorMessage> validateNonEmptyFileToUpload(InputStream fileToUpload, - String fileSuffix) { - String errorMessage = - getErrorWithParameters(Messages.NO_FILE_WAS_UPLOADED_OR_FILE_NOT_EXIST.getErrorMessage(), - fileSuffix); - - if (Objects.isNull(fileToUpload)) { - return Optional.of(new ErrorMessage(ErrorLevel.ERROR, - errorMessage)); - } else { - try { - int available = fileToUpload.available(); - if (available == 0) { - return Optional.of(new ErrorMessage(ErrorLevel.ERROR, - errorMessage)); + + private static final Logger logger = LoggerFactory.getLogger(CandidateServiceImpl.class); + private CandidateServiceValidator candidateServiceValidator = new CandidateServiceValidator(); + private ManifestCreator manifestCreator; + private OrchestrationTemplateCandidateDao orchestrationTemplateCandidateDao; + + public CandidateServiceImpl(ManifestCreator manifestCreator, OrchestrationTemplateCandidateDao orchestrationTemplateCandidateDao) { + this.manifestCreator = manifestCreator; + this.orchestrationTemplateCandidateDao = orchestrationTemplateCandidateDao; + } + + public CandidateServiceImpl() { + } + + @Override + public Optional<ErrorMessage> validateNonEmptyFileToUpload(InputStream fileToUpload, String fileSuffix) { + String errorMessage = getErrorWithParameters(Messages.NO_FILE_WAS_UPLOADED_OR_FILE_NOT_EXIST.getErrorMessage(), fileSuffix); + if (Objects.isNull(fileToUpload)) { + return Optional.of(new ErrorMessage(ErrorLevel.ERROR, errorMessage)); + } else { + try { + int available = fileToUpload.available(); + if (available == 0) { + return Optional.of(new ErrorMessage(ErrorLevel.ERROR, errorMessage)); + } + } catch (IOException e) { + logger.debug(e.getMessage(), e); + return Optional.of(new ErrorMessage(ErrorLevel.ERROR, errorMessage)); + } } - } catch (IOException e) { - logger.debug(e.getMessage(), e); - return Optional.of(new ErrorMessage(ErrorLevel.ERROR, - errorMessage)); - } - } - return Optional.empty(); - } - - @Override - public Optional<ErrorMessage> validateRawZipData(String fileSuffix, - byte[] uploadedFileData) { - if (Objects.isNull(uploadedFileData)) { - return Optional.of(new ErrorMessage(ErrorLevel.ERROR, - getErrorWithParameters(Messages.NO_FILE_WAS_UPLOADED_OR_FILE_NOT_EXIST.getErrorMessage(), - fileSuffix))); - } - return Optional.empty(); - } - - private String heatStructureTreeToFileDataStructure(HeatStructureTree tree, - FileContentHandler zipContentMap, - Map<String, List<ErrorMessage>> uploadErrors, - AnalyzedZipHeatFiles analyzedZipHeatFiles) { - FilesDataStructure structure = new FilesDataStructure(); - Set<String> usedEnvFiles = new HashSet<>(); - addHeatsToFileDataStructure(tree, usedEnvFiles, structure, uploadErrors, - analyzedZipHeatFiles); - handleOtherResources(tree, usedEnvFiles, structure); - FilesDataStructure fileDataStructureFromManifest = - createFileDataStructureFromManifest(zipContentMap.getFileContentAsStream(SdcCommon.MANIFEST_NAME)); - List<String> structureArtifacts = structure.getArtifacts(); - structureArtifacts.addAll(fileDataStructureFromManifest.getArtifacts().stream().filter - (artifact -> isNotStrctureArtifact(structureArtifacts, artifact)) - .collect(Collectors.toList())); - handleArtifactsFromTree(tree, structure); - - return JsonUtil.object2Json(structure); - } - - private boolean isNotStrctureArtifact(List<String> structureArtifacts, String artifact) { - return !structureArtifacts.contains(artifact); - } - - @Override - public OrchestrationTemplateCandidateData createCandidateDataEntity( - CandidateDataEntityTo candidateDataEntityTo, InputStream zipFileManifest, - AnalyzedZipHeatFiles analyzedZipHeatFiles) { - FileContentHandler zipContentMap = candidateDataEntityTo.getContentMap(); - FilesDataStructure filesDataStructure; - String dataStructureJson; - - if (zipFileManifest != null) { - // create data structure from manifest - filesDataStructure = createFileDataStructureFromManifest(zipFileManifest); - Set<String> zipFileList = zipContentMap.getFileList(); - balanceManifestFilesWithZipFiles(filesDataStructure, - zipContentMap, analyzedZipHeatFiles); - Set<String> filesDataStructureFiles = getFlatFileNames(filesDataStructure); - filesDataStructure.getUnassigned().addAll(zipFileList.stream() - .filter(fileName -> (!filesDataStructureFiles.contains(fileName) - && !filesDataStructure.getNested().contains(fileName) - && !fileName.equals(SdcCommon.MANIFEST_NAME))) - .collect(Collectors.toList())); - dataStructureJson = JsonUtil.object2Json(filesDataStructure); - } else { - // create data structure from based on naming convention - dataStructureJson = - heatStructureTreeToFileDataStructure(candidateDataEntityTo.getTree(), zipContentMap, - candidateDataEntityTo.getErrors(), analyzedZipHeatFiles); - } - - OrchestrationTemplateCandidateData candidateData = new OrchestrationTemplateCandidateData(); - candidateData.setContentData(ByteBuffer.wrap(candidateDataEntityTo.getUploadedFileData())); - candidateData.setFilesDataStructure(dataStructureJson); - return candidateData; - } - - private void balanceManifestFilesWithZipFiles( - FilesDataStructure filesDataStructure, - FileContentHandler fileContentHandler, AnalyzedZipHeatFiles analyzedZipHeatFiles) { - Set<String> zipFileList = fileContentHandler.getFileList(); - filesDataStructure.getNested().addAll(analyzedZipHeatFiles.getNestedFiles()); - List<Module> modules = filesDataStructure.getModules(); - if (CollectionUtils.isEmpty(modules)) { - return; - } - - for (int i = 0; i < modules.size(); i++) { - Module module = modules.get(i); - if (!isFileExistInZipContains(zipFileList, module.getYaml())) { - addFileToUnassigned(filesDataStructure, zipFileList, module.getEnv()); - addFileToUnassigned(filesDataStructure, zipFileList, module.getVol()); - addFileToUnassigned(filesDataStructure, zipFileList, module.getVolEnv()); - modules.remove(i--); - } else if (Objects.nonNull(module.getVol()) && !zipFileList.contains(module.getVol())) { - module.setVol(null); - CollectionUtils - .addIgnoreNull(filesDataStructure.getUnassigned(), module.getVolEnv()); - } else { - if (filesDataStructure.getNested().contains(module.getYaml())) { - moveModuleFileToNested(filesDataStructure, i--, module); + return Optional.empty(); + } + + @Override + public Optional<ErrorMessage> validateRawZipData(String fileSuffix, byte[] uploadedFileData) { + if (Objects.isNull(uploadedFileData)) { + return Optional.of(new ErrorMessage(ErrorLevel.ERROR, + getErrorWithParameters(Messages.NO_FILE_WAS_UPLOADED_OR_FILE_NOT_EXIST.getErrorMessage(), fileSuffix))); } - } - } - } - - private void addFileToUnassigned(FilesDataStructure filesDataStructure, Set<String> zipFileList, - String fileName) { - if (isFileExistInZipContains(zipFileList, fileName)) { - filesDataStructure.getUnassigned().add(fileName); - } - } - - private boolean isFileExistInZipContains(Set<String> zipFileList, String fileName) { - return Objects.nonNull(fileName) && zipFileList.contains(fileName); - } - - private void moveModuleFileToNested(FilesDataStructure filesDataStructure, int i, - Module module) { - if (!filesDataStructure.getNested().contains(module.getYaml())) { - filesDataStructure.getNested().add(module.getYaml()); - } - if (Objects.nonNull(module.getEnv())) { - filesDataStructure.getNested().add(module.getEnv()); - } - if (Objects.nonNull(module.getVol())) { - filesDataStructure.getNested().add(module.getVol()); - } - if (Objects.nonNull(module.getVolEnv())) { - filesDataStructure.getNested().add(module.getVolEnv()); - } - filesDataStructure.getModules().remove(i); - } - - private Set<String> getFlatFileNames(FilesDataStructure filesDataStructure) { - Set<String> fileNames = new HashSet<>(); - if (!CollectionUtils.isEmpty(filesDataStructure.getModules())) { - for (Module module : filesDataStructure.getModules()) { - CollectionUtils.addIgnoreNull(fileNames, module.getEnv()); - CollectionUtils.addIgnoreNull(fileNames, module.getVol()); - CollectionUtils.addIgnoreNull(fileNames, module.getVolEnv()); - CollectionUtils.addIgnoreNull(fileNames, module.getYaml()); - } - } - fileNames.addAll(filesDataStructure.getArtifacts()); - fileNames.addAll(filesDataStructure.getNested()); - fileNames.addAll(filesDataStructure.getUnassigned()); - - return fileNames; - } - - private FilesDataStructure createFileDataStructureFromManifest(InputStream isManifestContent) { - ManifestContent manifestContent = - JsonUtil.json2Object(isManifestContent, ManifestContent.class); - FilesDataStructure structure = new FilesDataStructure(); - for (FileData fileData : manifestContent.getData()) { - if (Objects.nonNull(fileData.getType()) && - fileData.getType().equals(FileData.Type.HEAT)) { - Module module = new Module(); - module.setType(FileData.Type.HEAT); - module.setYaml(fileData.getFile()); - module.setIsBase(fileData.getBase()); - addHeatDependenciesToModule(module, fileData.getData()); - structure.getModules().add(module); - }else if (Objects.nonNull(fileData.getType()) && - fileData.getType().equals(FileData.Type.HELM)) { - Module module = new Module(); - module.setType(FileData.Type.HELM); - module.setYaml(fileData.getFile()); - module.setIsBase(fileData.getBase()); - structure.getModules().add(module); - } - else if (HeatFileAnalyzer.isYamlOrEnvFile(fileData.getFile()) && - !FileData.Type.isArtifact(fileData.getType())) { - structure.getUnassigned().add(fileData.getFile()); - } else { - structure.getArtifacts().add(fileData.getFile()); - } - } - return structure; - } - - private void addHeatDependenciesToModule(Module module, List<FileData> data) { - if (CollectionUtils.isEmpty(data)) { - return; - } - - for (FileData fileData : data) { - if (fileData.getType().equals(FileData.Type.HEAT_ENV)) { - module.setEnv(fileData.getFile()); - } else if (fileData.getType().equals(FileData.Type.HEAT_VOL)) { // must be volume - module.setVol(fileData.getFile()); - if (!CollectionUtils.isEmpty(fileData.getData())) { - FileData volEnv = fileData.getData().get(0); - if (volEnv.getType().equals(FileData.Type.HEAT_ENV)) { - module.setVolEnv(volEnv.getFile()); - } else { - throw new CoreException((new ErrorCode.ErrorCodeBuilder()) - .withMessage(Messages.ILLEGAL_MANIFEST.getErrorMessage()) - .withId(Messages.ILLEGAL_MANIFEST.getErrorMessage()) - .withCategory(ErrorCategory.APPLICATION).build()); - } + return Optional.empty(); + } + + private String heatStructureTreeToFileDataStructure(HeatStructureTree tree, FileContentHandler zipContentMap, + Map<String, List<ErrorMessage>> uploadErrors, AnalyzedZipHeatFiles analyzedZipHeatFiles) { + FilesDataStructure structure = new FilesDataStructure(); + Set<String> usedEnvFiles = new HashSet<>(); + addHeatsToFileDataStructure(tree, usedEnvFiles, structure, uploadErrors, analyzedZipHeatFiles); + handleOtherResources(tree, usedEnvFiles, structure); + FilesDataStructure fileDataStructureFromManifest = createFileDataStructureFromManifest( + zipContentMap.getFileContentAsStream(SdcCommon.MANIFEST_NAME)); + List<String> structureArtifacts = structure.getArtifacts(); + structureArtifacts.addAll( + fileDataStructureFromManifest.getArtifacts().stream().filter(artifact -> isNotStrctureArtifact(structureArtifacts, artifact)) + .collect(Collectors.toList())); + handleArtifactsFromTree(tree, structure); + return JsonUtil.object2Json(structure); + } + + private boolean isNotStrctureArtifact(List<String> structureArtifacts, String artifact) { + return !structureArtifacts.contains(artifact); + } + + @Override + public OrchestrationTemplateCandidateData createCandidateDataEntity(CandidateDataEntityTo candidateDataEntityTo, InputStream zipFileManifest, + AnalyzedZipHeatFiles analyzedZipHeatFiles) { + FileContentHandler zipContentMap = candidateDataEntityTo.getContentMap(); + FilesDataStructure filesDataStructure; + String dataStructureJson; + if (zipFileManifest != null) { + // create data structure from manifest + filesDataStructure = createFileDataStructureFromManifest(zipFileManifest); + Set<String> zipFileList = zipContentMap.getFileList(); + balanceManifestFilesWithZipFiles(filesDataStructure, zipContentMap, analyzedZipHeatFiles); + Set<String> filesDataStructureFiles = getFlatFileNames(filesDataStructure); + filesDataStructure.getUnassigned().addAll(zipFileList.stream().filter( + fileName -> (!filesDataStructureFiles.contains(fileName) && !filesDataStructure.getNested().contains(fileName) && !fileName + .equals(SdcCommon.MANIFEST_NAME))).collect(Collectors.toList())); + dataStructureJson = JsonUtil.object2Json(filesDataStructure); + } else { + // create data structure from based on naming convention + dataStructureJson = heatStructureTreeToFileDataStructure(candidateDataEntityTo.getTree(), zipContentMap, + candidateDataEntityTo.getErrors(), analyzedZipHeatFiles); } - } else { - throw new CoreException((new ErrorCode.ErrorCodeBuilder()) - .withMessage(Messages.FILE_TYPE_NOT_LEGAL.getErrorMessage()) - .withId(Messages.FILE_TYPE_NOT_LEGAL.getErrorMessage()) - .withCategory(ErrorCategory.APPLICATION).build()); - } - } - } - - @Override - public void updateCandidateUploadData(final String vspId, final Version version, - final OrchestrationTemplateCandidateData uploadData) { - orchestrationTemplateCandidateDao.update(vspId, version, uploadData); - } - - @Override - public Optional<FilesDataStructure> getOrchestrationTemplateCandidateFileDataStructure( - String vspId, Version version) { - Optional<String> jsonFileDataStructure = - orchestrationTemplateCandidateDao.getStructure(vspId, version); - - if (jsonFileDataStructure.isPresent() && JsonUtil.isValidJson(jsonFileDataStructure.get())) { - return Optional - .of(JsonUtil.json2Object(jsonFileDataStructure.get(), FilesDataStructure.class)); - } else { - return Optional.empty(); - } - } - - @Override - public void updateOrchestrationTemplateCandidateFileDataStructure(String vspId, Version version, - FilesDataStructure fileDataStructure) { - OrchestrationTemplateCandidateDaoFactory.getInstance().createInterface() - .updateStructure(vspId, version, fileDataStructure); - } - - @Override - public Optional<OrchestrationTemplateCandidateData> getOrchestrationTemplateCandidate(String vspId, - Version version) { - return orchestrationTemplateCandidateDao.get(vspId, version); - } - - @Override - public Optional<OrchestrationTemplateCandidateData> getOrchestrationTemplateCandidateInfo( - String vspId, - Version version) { - return orchestrationTemplateCandidateDao.getInfo(vspId, version); - } - - @Override - public String createManifest(VspDetails vspDetails, FilesDataStructure structure) { - return JsonUtil.object2Json(manifestCreator.createManifest(vspDetails, structure) - .orElseThrow(() -> new CoreException(new ErrorCode.ErrorCodeBuilder() - .withMessage(Messages.CREATE_MANIFEST_FROM_ZIP.getErrorMessage()).build()))); - } - - @Override - public String createManifestFromExisting(VspDetails vspDetails, FilesDataStructure structure, ManifestContent existingManifest) { - return JsonUtil.object2Json(manifestCreator.createManifestFromExisting(vspDetails, structure, existingManifest) - .orElseThrow(() -> new CoreException(new ErrorCode.ErrorCodeBuilder() - .withMessage(Messages.CREATE_MANIFEST_FROM_ZIP.getErrorMessage()).build()))); - } - - @Override - public Optional<ManifestContent> createManifest(VspDetails vspDetails, - FileContentHandler fileContentHandler, + OrchestrationTemplateCandidateData candidateData = new OrchestrationTemplateCandidateData(); + candidateData.setContentData(ByteBuffer.wrap(candidateDataEntityTo.getUploadedFileData())); + candidateData.setFilesDataStructure(dataStructureJson); + return candidateData; + } + + private void balanceManifestFilesWithZipFiles(FilesDataStructure filesDataStructure, FileContentHandler fileContentHandler, AnalyzedZipHeatFiles analyzedZipHeatFiles) { - return manifestCreator.createManifest(vspDetails, fileContentHandler, analyzedZipHeatFiles); - } - - @Override - public Optional<ByteArrayInputStream> fetchZipFileByteArrayInputStream(String vspId, - OrchestrationTemplateCandidateData candidateDataEntity, - String manifest, - OnboardingTypesEnum type, - Map<String, List<ErrorMessage>> uploadErrors) { - byte[] file; - ByteArrayInputStream byteArrayInputStream = null; - try { - file = replaceManifestInZip(candidateDataEntity.getContentData(), manifest, type); - byteArrayInputStream = new ByteArrayInputStream( - Objects.isNull(file) ? candidateDataEntity.getContentData().array() - : file); - } catch (IOException e) { - ErrorMessage errorMessage = - new ErrorMessage(ErrorLevel.ERROR, - Messages.CANDIDATE_PROCESS_FAILED.getErrorMessage()); - logger.error(errorMessage.getMessage(), e); - ErrorsUtil - .addStructureErrorToErrorMap(SdcCommon.UPLOAD_FILE, errorMessage, uploadErrors); - } - return Optional.ofNullable(byteArrayInputStream); - } - - @Override - public byte[] replaceManifestInZip(ByteBuffer contentData, String manifest, - OnboardingTypesEnum type) - throws IOException { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - - try (final ZipOutputStream zos = new ZipOutputStream(baos); - ZipInputStream zipStream = new ZipInputStream( - new ByteArrayInputStream(contentData.array()))) { - ZipEntry zipEntry; - boolean manifestWritten = false; - while ((zipEntry = zipStream.getNextEntry()) != null) { - if (!zipEntry.getName().equalsIgnoreCase(SdcCommon.MANIFEST_NAME)) { - ZipEntry loc_ze = new ZipEntry(zipEntry.getName()); - zos.putNextEntry(loc_ze); - byte[] buf = new byte[1024]; - int len; - while ((len = zipStream.read(buf)) > 0) { - zos.write(buf, 0, (len < buf.length) ? len : buf.length); - } + Set<String> zipFileList = fileContentHandler.getFileList(); + filesDataStructure.getNested().addAll(analyzedZipHeatFiles.getNestedFiles()); + List<Module> modules = filesDataStructure.getModules(); + if (CollectionUtils.isEmpty(modules)) { + return; + } + for (int i = 0; i < modules.size(); i++) { + Module module = modules.get(i); + if (!isFileExistInZipContains(zipFileList, module.getYaml())) { + addFileToUnassigned(filesDataStructure, zipFileList, module.getEnv()); + addFileToUnassigned(filesDataStructure, zipFileList, module.getVol()); + addFileToUnassigned(filesDataStructure, zipFileList, module.getVolEnv()); + modules.remove(i--); + } else if (Objects.nonNull(module.getVol()) && !zipFileList.contains(module.getVol())) { + module.setVol(null); + CollectionUtils.addIgnoreNull(filesDataStructure.getUnassigned(), module.getVolEnv()); + } else { + if (filesDataStructure.getNested().contains(module.getYaml())) { + moveModuleFileToNested(filesDataStructure, i--, module); + } + } + } + } + + private void addFileToUnassigned(FilesDataStructure filesDataStructure, Set<String> zipFileList, String fileName) { + if (isFileExistInZipContains(zipFileList, fileName)) { + filesDataStructure.getUnassigned().add(fileName); + } + } + + private boolean isFileExistInZipContains(Set<String> zipFileList, String fileName) { + return Objects.nonNull(fileName) && zipFileList.contains(fileName); + } + + private void moveModuleFileToNested(FilesDataStructure filesDataStructure, int i, Module module) { + if (!filesDataStructure.getNested().contains(module.getYaml())) { + filesDataStructure.getNested().add(module.getYaml()); + } + if (Objects.nonNull(module.getEnv())) { + filesDataStructure.getNested().add(module.getEnv()); + } + if (Objects.nonNull(module.getVol())) { + filesDataStructure.getNested().add(module.getVol()); + } + if (Objects.nonNull(module.getVolEnv())) { + filesDataStructure.getNested().add(module.getVolEnv()); + } + filesDataStructure.getModules().remove(i); + } + + private Set<String> getFlatFileNames(FilesDataStructure filesDataStructure) { + Set<String> fileNames = new HashSet<>(); + if (!CollectionUtils.isEmpty(filesDataStructure.getModules())) { + for (Module module : filesDataStructure.getModules()) { + CollectionUtils.addIgnoreNull(fileNames, module.getEnv()); + CollectionUtils.addIgnoreNull(fileNames, module.getVol()); + CollectionUtils.addIgnoreNull(fileNames, module.getVolEnv()); + CollectionUtils.addIgnoreNull(fileNames, module.getYaml()); + } + } + fileNames.addAll(filesDataStructure.getArtifacts()); + fileNames.addAll(filesDataStructure.getNested()); + fileNames.addAll(filesDataStructure.getUnassigned()); + return fileNames; + } + + private FilesDataStructure createFileDataStructureFromManifest(InputStream isManifestContent) { + ManifestContent manifestContent = JsonUtil.json2Object(isManifestContent, ManifestContent.class); + FilesDataStructure structure = new FilesDataStructure(); + for (FileData fileData : manifestContent.getData()) { + if (Objects.nonNull(fileData.getType()) && fileData.getType().equals(FileData.Type.HEAT)) { + Module module = new Module(); + module.setType(FileData.Type.HEAT); + module.setYaml(fileData.getFile()); + module.setIsBase(fileData.getBase()); + addHeatDependenciesToModule(module, fileData.getData()); + structure.getModules().add(module); + } else if (Objects.nonNull(fileData.getType()) && fileData.getType().equals(FileData.Type.HELM)) { + Module module = new Module(); + module.setType(FileData.Type.HELM); + module.setYaml(fileData.getFile()); + module.setIsBase(fileData.getBase()); + structure.getModules().add(module); + } else if (HeatFileAnalyzer.isYamlOrEnvFile(fileData.getFile()) && !FileData.Type.isArtifact(fileData.getType())) { + structure.getUnassigned().add(fileData.getFile()); + } else { + structure.getArtifacts().add(fileData.getFile()); + } + } + return structure; + } + + private void addHeatDependenciesToModule(Module module, List<FileData> data) { + if (CollectionUtils.isEmpty(data)) { + return; + } + for (FileData fileData : data) { + if (fileData.getType().equals(FileData.Type.HEAT_ENV)) { + module.setEnv(fileData.getFile()); + } else if (fileData.getType().equals(FileData.Type.HEAT_VOL)) { // must be volume + module.setVol(fileData.getFile()); + if (!CollectionUtils.isEmpty(fileData.getData())) { + FileData volEnv = fileData.getData().get(0); + if (volEnv.getType().equals(FileData.Type.HEAT_ENV)) { + module.setVolEnv(volEnv.getFile()); + } else { + throw new CoreException((new ErrorCode.ErrorCodeBuilder()).withMessage(Messages.ILLEGAL_MANIFEST.getErrorMessage()) + .withId(Messages.ILLEGAL_MANIFEST.getErrorMessage()).withCategory(ErrorCategory.APPLICATION).build()); + } + } + } else { + throw new CoreException((new ErrorCode.ErrorCodeBuilder()).withMessage(Messages.FILE_TYPE_NOT_LEGAL.getErrorMessage()) + .withId(Messages.FILE_TYPE_NOT_LEGAL.getErrorMessage()).withCategory(ErrorCategory.APPLICATION).build()); + } + } + } + + @Override + public void updateCandidateUploadData(final String vspId, final Version version, final OrchestrationTemplateCandidateData uploadData) { + orchestrationTemplateCandidateDao.update(vspId, version, uploadData); + } + + @Override + public Optional<FilesDataStructure> getOrchestrationTemplateCandidateFileDataStructure(String vspId, Version version) { + Optional<String> jsonFileDataStructure = orchestrationTemplateCandidateDao.getStructure(vspId, version); + if (jsonFileDataStructure.isPresent() && JsonUtil.isValidJson(jsonFileDataStructure.get())) { + return Optional.of(JsonUtil.json2Object(jsonFileDataStructure.get(), FilesDataStructure.class)); } else { - manifestWritten = true; - writeManifest(manifest, type, zos); + return Optional.empty(); } - zos.closeEntry(); - } - if (!manifestWritten) { - writeManifest(manifest, type, zos); - zos.closeEntry(); - } - } - return baos.toByteArray(); - } - - @Override - public byte[] getZipData(ByteBuffer contentData) - throws IOException { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - - try (final ZipOutputStream zos = new ZipOutputStream(baos); - ZipInputStream zipStream = new ZipInputStream( - new ByteArrayInputStream(contentData.array()))) { - ZipEntry zipEntry; - while ((zipEntry = zipStream.getNextEntry()) != null) { + } + + @Override + public void updateOrchestrationTemplateCandidateFileDataStructure(String vspId, Version version, FilesDataStructure fileDataStructure) { + OrchestrationTemplateCandidateDaoFactory.getInstance().createInterface().updateStructure(vspId, version, fileDataStructure); + } + + @Override + public Optional<OrchestrationTemplateCandidateData> getOrchestrationTemplateCandidate(String vspId, Version version) { + return orchestrationTemplateCandidateDao.get(vspId, version); + } + + @Override + public Optional<OrchestrationTemplateCandidateData> getOrchestrationTemplateCandidateInfo(String vspId, Version version) { + return orchestrationTemplateCandidateDao.getInfo(vspId, version); + } + + @Override + public String createManifest(VspDetails vspDetails, FilesDataStructure structure) { + return JsonUtil.object2Json(manifestCreator.createManifest(vspDetails, structure).orElseThrow( + () -> new CoreException(new ErrorCode.ErrorCodeBuilder().withMessage(Messages.CREATE_MANIFEST_FROM_ZIP.getErrorMessage()).build()))); + } + + @Override + public String createManifestFromExisting(VspDetails vspDetails, FilesDataStructure structure, ManifestContent existingManifest) { + return JsonUtil.object2Json(manifestCreator.createManifestFromExisting(vspDetails, structure, existingManifest).orElseThrow( + () -> new CoreException(new ErrorCode.ErrorCodeBuilder().withMessage(Messages.CREATE_MANIFEST_FROM_ZIP.getErrorMessage()).build()))); + } + + @Override + public Optional<ManifestContent> createManifest(VspDetails vspDetails, FileContentHandler fileContentHandler, + AnalyzedZipHeatFiles analyzedZipHeatFiles) { + return manifestCreator.createManifest(vspDetails, fileContentHandler, analyzedZipHeatFiles); + } + + @Override + public Optional<ByteArrayInputStream> fetchZipFileByteArrayInputStream(String vspId, OrchestrationTemplateCandidateData candidateDataEntity, + String manifest, OnboardingTypesEnum type, + Map<String, List<ErrorMessage>> uploadErrors) { + byte[] file; + ByteArrayInputStream byteArrayInputStream = null; try { - ZipUtils.checkForZipSlipInRead(zipEntry); - } catch (ZipSlipException e) { - throw new IOException(e); + file = replaceManifestInZip(candidateDataEntity.getContentData(), manifest, type); + byteArrayInputStream = new ByteArrayInputStream(Objects.isNull(file) ? candidateDataEntity.getContentData().array() : file); + } catch (IOException e) { + ErrorMessage errorMessage = new ErrorMessage(ErrorLevel.ERROR, Messages.CANDIDATE_PROCESS_FAILED.getErrorMessage()); + logger.error(errorMessage.getMessage(), e); + ErrorsUtil.addStructureErrorToErrorMap(SdcCommon.UPLOAD_FILE, errorMessage, uploadErrors); } - ZipEntry locZipEntry = new ZipEntry(zipEntry.getName()); - zos.putNextEntry(locZipEntry); - byte[] buf = new byte[1024]; - int len; - while ((len = zipStream.read(buf)) > 0) { - zos.write(buf, 0, (len < buf.length) ? len : buf.length); + return Optional.ofNullable(byteArrayInputStream); + } + + @Override + public byte[] replaceManifestInZip(ByteBuffer contentData, String manifest, OnboardingTypesEnum type) throws IOException { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + try (final ZipOutputStream zos = new ZipOutputStream(baos); ZipInputStream zipStream = new ZipInputStream( + new ByteArrayInputStream(contentData.array()))) { + ZipEntry zipEntry; + boolean manifestWritten = false; + while ((zipEntry = zipStream.getNextEntry()) != null) { + if (!zipEntry.getName().equalsIgnoreCase(SdcCommon.MANIFEST_NAME)) { + ZipEntry loc_ze = new ZipEntry(zipEntry.getName()); + zos.putNextEntry(loc_ze); + byte[] buf = new byte[1024]; + int len; + while ((len = zipStream.read(buf)) > 0) { + zos.write(buf, 0, (len < buf.length) ? len : buf.length); + } + } else { + manifestWritten = true; + writeManifest(manifest, type, zos); + } + zos.closeEntry(); + } + if (!manifestWritten) { + writeManifest(manifest, type, zos); + zos.closeEntry(); + } } - zos.closeEntry(); - } + return baos.toByteArray(); } - return baos.toByteArray(); - } - @Override - public Optional<List<ErrorMessage>> validateFileDataStructure( - FilesDataStructure filesDataStructure) { - return candidateServiceValidator.validateFileDataStructure(filesDataStructure); - } + @Override + public byte[] getZipData(ByteBuffer contentData) throws IOException { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + try (final ZipOutputStream zos = new ZipOutputStream(baos); ZipInputStream zipStream = new ZipInputStream( + new ByteArrayInputStream(contentData.array()))) { + ZipEntry zipEntry; + while ((zipEntry = zipStream.getNextEntry()) != null) { + try { + ZipUtils.checkForZipSlipInRead(zipEntry); + } catch (ZipSlipException e) { + throw new IOException(e); + } + ZipEntry locZipEntry = new ZipEntry(zipEntry.getName()); + zos.putNextEntry(locZipEntry); + byte[] buf = new byte[1024]; + int len; + while ((len = zipStream.read(buf)) > 0) { + zos.write(buf, 0, (len < buf.length) ? len : buf.length); + } + zos.closeEntry(); + } + } + return baos.toByteArray(); + } - @Override - public void deleteOrchestrationTemplateCandidate(String vspId, Version versionId) { - orchestrationTemplateCandidateDao.delete(vspId, versionId); - } + @Override + public Optional<List<ErrorMessage>> validateFileDataStructure(FilesDataStructure filesDataStructure) { + return candidateServiceValidator.validateFileDataStructure(filesDataStructure); + } - @Override - public void updateValidationData(String vspId, Version version, ValidationStructureList - validationData) { - orchestrationTemplateCandidateDao.updateValidationData(vspId, version, validationData); - } + @Override + public void deleteOrchestrationTemplateCandidate(String vspId, Version versionId) { + orchestrationTemplateCandidateDao.delete(vspId, versionId); + } - private void writeManifest(String manifest, - OnboardingTypesEnum type, - ZipOutputStream zos) throws IOException { + @Override + public void updateValidationData(String vspId, Version version, ValidationStructureList validationData) { + orchestrationTemplateCandidateDao.updateValidationData(vspId, version, validationData); + } - if (isManifestNeedsToGetWritten(type)) { - return; + private void writeManifest(String manifest, OnboardingTypesEnum type, ZipOutputStream zos) throws IOException { + if (isManifestNeedsToGetWritten(type)) { + return; + } + zos.putNextEntry(new ZipEntry(SdcCommon.MANIFEST_NAME)); + try (InputStream manifestStream = new ByteArrayInputStream(manifest.getBytes(StandardCharsets.UTF_8))) { + byte[] buf = new byte[1024]; + int len; + while ((len = (manifestStream.read(buf))) > 0) { + zos.write(buf, 0, (len < buf.length) ? len : buf.length); + } + } } - zos.putNextEntry(new ZipEntry(SdcCommon.MANIFEST_NAME)); - try (InputStream manifestStream = new ByteArrayInputStream( - manifest.getBytes(StandardCharsets.UTF_8))) { - byte[] buf = new byte[1024]; - int len; - while ((len = (manifestStream.read(buf))) > 0) { - zos.write(buf, 0, (len < buf.length) ? len : buf.length); - } + private boolean isManifestNeedsToGetWritten(OnboardingTypesEnum type) { + return type.equals(OnboardingTypesEnum.CSAR); } - } - private boolean isManifestNeedsToGetWritten(OnboardingTypesEnum type) { - return type.equals(OnboardingTypesEnum.CSAR); - } + private void handleArtifactsFromTree(HeatStructureTree tree, FilesDataStructure structure) { + if (Objects.isNull(tree) || Objects.isNull(tree.getArtifacts())) { + return; + } + if (CollectionUtils.isNotEmpty(tree.getArtifacts())) { + structure.getArtifacts().addAll( + tree.getArtifacts().stream().map(Artifact::getFileName).filter(fileName -> !structure.getArtifacts().contains(fileName)) + .collect(Collectors.toList())); + } + } + + private void handleOtherResources(HeatStructureTree tree, Set<String> usedEnvFiles, FilesDataStructure structure) { + Set<HeatStructureTree> others = tree.getOther(); + if (Objects.isNull(others)) { + return; + } + List<String> artifacts = new ArrayList<>(); + List<String> unassigned = new ArrayList<>(); + for (HeatStructureTree other : others) { + if (HeatFileAnalyzer.isYamlOrEnvFile(other.getFileName())) { + if (isEnvFileUsedByHeatFile(usedEnvFiles, other)) { + continue; + } + unassigned.add(other.getFileName()); + } else { + artifacts.add(other.getFileName()); + } + handleArtifactsFromTree(other, structure); + } + structure.getArtifacts().addAll(artifacts); + structure.getUnassigned().addAll(unassigned); + } - private void handleArtifactsFromTree(HeatStructureTree tree, FilesDataStructure structure) { + private boolean isEnvFileUsedByHeatFile(Set<String> usedEnvFiles, HeatStructureTree other) { + return HeatFileAnalyzer.isEnvFile(other.getFileName()) && usedEnvFiles.contains(other.getFileName()); + } - if (Objects.isNull(tree) || Objects.isNull(tree.getArtifacts())) { - return; + private void addHeatsToFileDataStructure(HeatStructureTree tree, Set<String> usedEnvFiles, FilesDataStructure structure, + Map<String, List<ErrorMessage>> uploadErrors, AnalyzedZipHeatFiles analyzedZipHeatFiles) { + List<Module> modules = new ArrayList<>(); + Set<HeatStructureTree> heatsSet = tree.getHeat(); + if (Objects.isNull(heatsSet)) { + return; + } + for (HeatStructureTree heat : heatsSet) { + if (isFileBaseFile(heat.getFileName())) { + handleSingleHeat(structure, modules, heat, uploadErrors); + } else if (isFileModuleFile(heat.getFileName(), analyzedZipHeatFiles.getModuleFiles())) { + handleSingleHeat(structure, modules, heat, uploadErrors); + } else { + structure.getUnassigned().add(heat.getFileName()); + addNestedToFileDataStructure(heat, structure); + } + if (!Objects.isNull(heat.getEnv())) { + usedEnvFiles.add(heat.getEnv() == null ? null : heat.getEnv().getFileName()); + } + } + structure.setModules(modules); } - if (CollectionUtils.isNotEmpty(tree.getArtifacts())) { - structure.getArtifacts().addAll( - tree.getArtifacts() - .stream() - .map(Artifact::getFileName) - .filter(fileName -> !structure.getArtifacts().contains(fileName)) - .collect(Collectors.toList())); + private boolean isFileModuleFile(String fileName, Set<String> modulesFileNames) { + return modulesFileNames.contains(fileName); } - } - private void handleOtherResources(HeatStructureTree tree, Set<String> usedEnvFiles, - FilesDataStructure structure) { - Set<HeatStructureTree> others = tree.getOther(); - if (Objects.isNull(others)) { - return; + private boolean isFileBaseFile(String fileName) { + return manifestCreator.isFileBaseFile(fileName); } - List<String> artifacts = new ArrayList<>(); - List<String> unassigned = new ArrayList<>(); - for (HeatStructureTree other : others) { - if (HeatFileAnalyzer.isYamlOrEnvFile(other.getFileName())) { - if (isEnvFileUsedByHeatFile(usedEnvFiles, other)) { - continue; - } - unassigned.add(other.getFileName()); - } else { - artifacts.add(other.getFileName()); - } - handleArtifactsFromTree(other, structure); - } - structure.getArtifacts().addAll(artifacts); - structure.getUnassigned().addAll(unassigned); - } - - private boolean isEnvFileUsedByHeatFile(Set<String> usedEnvFiles, HeatStructureTree other) { - return HeatFileAnalyzer.isEnvFile(other.getFileName()) && - usedEnvFiles.contains(other.getFileName()); - } - - private void addHeatsToFileDataStructure(HeatStructureTree tree, Set<String> usedEnvFiles, - FilesDataStructure structure, - Map<String, List<ErrorMessage>> uploadErrors, - AnalyzedZipHeatFiles analyzedZipHeatFiles) { - List<Module> modules = new ArrayList<>(); - Set<HeatStructureTree> heatsSet = tree.getHeat(); - if (Objects.isNull(heatsSet)) { - return; - } - for (HeatStructureTree heat : heatsSet) { - if (isFileBaseFile(heat.getFileName())) { - handleSingleHeat(structure, modules, heat, uploadErrors); - } else if (isFileModuleFile(heat.getFileName(), - analyzedZipHeatFiles.getModuleFiles())) { - handleSingleHeat(structure, modules, heat, uploadErrors); - } else { - structure.getUnassigned().add(heat.getFileName()); + private void handleSingleHeat(FilesDataStructure structure, List<Module> modules, HeatStructureTree heat, + Map<String, List<ErrorMessage>> uploadErrors) { + Module module = new Module(); + module.setYaml(heat.getFileName()); + module.setIsBase(heat.getBase()); addNestedToFileDataStructure(heat, structure); - } - if (!Objects.isNull(heat.getEnv())) { - usedEnvFiles.add(heat.getEnv() == null ? null : heat.getEnv().getFileName()); - } - } - structure.setModules(modules); - - } - - private boolean isFileModuleFile(String fileName, Set<String> modulesFileNames) { - return modulesFileNames.contains(fileName); - } - - private boolean isFileBaseFile(String fileName) { - return manifestCreator.isFileBaseFile(fileName); - } - - private void handleSingleHeat(FilesDataStructure structure, List<Module> modules, - HeatStructureTree heat, - Map<String, List<ErrorMessage>> uploadErrors) { - Module module = new Module(); - module.setYaml(heat.getFileName()); - module.setIsBase(heat.getBase()); - addNestedToFileDataStructure(heat, structure); - Set<HeatStructureTree> volumeSet = heat.getVolume(); - int inx = 0; - if (Objects.nonNull(volumeSet)) { - handleVolumes(module, volumeSet, structure, inx, uploadErrors); - } - handleEnv(module, heat, false, structure); - modules.add(module); - } - - private void handleVolumes(Module module, Set<HeatStructureTree> volumeSet, - FilesDataStructure structure, int inx, - Map<String, List<ErrorMessage>> uploadErrors) { - for (HeatStructureTree volume : volumeSet) { - Objects.requireNonNull(volume, "volume cannot be null!"); - if (inx++ > 0) { - ErrorsUtil.addStructureErrorToErrorMap(SdcCommon.UPLOAD_FILE, - new ErrorMessage(ErrorLevel.WARNING, - Messages.MORE_THEN_ONE_VOL_FOR_HEAT.getErrorMessage()), uploadErrors); - break; - } - handleArtifactsFromTree(volume, structure); - module.setVol(volume.getFileName()); - handleEnv(module, volume, true, structure); - addNestedToFileDataStructure(volume, structure); - } - } - - private void handleEnv(Module module, HeatStructureTree tree, boolean isVolEnv, - FilesDataStructure structure) { - if (Objects.nonNull(tree.getEnv())) { - if (isVolEnv) { - module.setVolEnv(tree.getEnv().getFileName()); - } else { - module.setEnv(tree.getEnv().getFileName()); - } - handleArtifactsFromTree(tree.getEnv(), structure); - } - } - - private void addNestedToFileDataStructure(HeatStructureTree heat, - FilesDataStructure structure) { - Set<HeatStructureTree> nestedSet = heat.getNested(); - if (Objects.isNull(nestedSet)) { - return; - } - for (HeatStructureTree nested : nestedSet) { - if (structure.getNested().contains(nested.getFileName())) { - continue; - } - structure.getNested().add(nested.getFileName()); - if (CollectionUtils.isNotEmpty(nested.getArtifacts())) { - handleArtifactsFromTree(nested, structure); - } - addNestedToFileDataStructure(nested, structure); - } - } + Set<HeatStructureTree> volumeSet = heat.getVolume(); + int inx = 0; + if (Objects.nonNull(volumeSet)) { + handleVolumes(module, volumeSet, structure, inx, uploadErrors); + } + handleEnv(module, heat, false, structure); + modules.add(module); + } + + private void handleVolumes(Module module, Set<HeatStructureTree> volumeSet, FilesDataStructure structure, int inx, + Map<String, List<ErrorMessage>> uploadErrors) { + for (HeatStructureTree volume : volumeSet) { + Objects.requireNonNull(volume, "volume cannot be null!"); + if (inx++ > 0) { + ErrorsUtil.addStructureErrorToErrorMap(SdcCommon.UPLOAD_FILE, + new ErrorMessage(ErrorLevel.WARNING, Messages.MORE_THEN_ONE_VOL_FOR_HEAT.getErrorMessage()), uploadErrors); + break; + } + handleArtifactsFromTree(volume, structure); + module.setVol(volume.getFileName()); + handleEnv(module, volume, true, structure); + addNestedToFileDataStructure(volume, structure); + } + } + + private void handleEnv(Module module, HeatStructureTree tree, boolean isVolEnv, FilesDataStructure structure) { + if (Objects.nonNull(tree.getEnv())) { + if (isVolEnv) { + module.setVolEnv(tree.getEnv().getFileName()); + } else { + module.setEnv(tree.getEnv().getFileName()); + } + handleArtifactsFromTree(tree.getEnv(), structure); + } + } + + private void addNestedToFileDataStructure(HeatStructureTree heat, FilesDataStructure structure) { + Set<HeatStructureTree> nestedSet = heat.getNested(); + if (Objects.isNull(nestedSet)) { + return; + } + for (HeatStructureTree nested : nestedSet) { + if (structure.getNested().contains(nested.getFileName())) { + continue; + } + structure.getNested().add(nested.getFileName()); + if (CollectionUtils.isNotEmpty(nested.getArtifacts())) { + handleArtifactsFromTree(nested, structure); + } + addNestedToFileDataStructure(nested, structure); + } + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/ManifestCreatorNamingConventionImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/ManifestCreatorNamingConventionImpl.java index 54cc1fbf1c..f935318d01 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/ManifestCreatorNamingConventionImpl.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/ManifestCreatorNamingConventionImpl.java @@ -14,9 +14,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.openecomp.sdc.vendorsoftwareproduct.services.impl.filedatastructuremodule; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.regex.Pattern; import org.apache.commons.collections4.CollectionUtils; import org.openecomp.core.utilities.file.FileContentHandler; import org.openecomp.sdc.heat.datatypes.manifest.FileData; @@ -31,322 +40,278 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.Module; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.*; -import java.util.regex.Pattern; - 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*/}; - private static final String CONTROLLER_BLUEPRINT_ARCHIVE_FIXED_KEY_WORD = "CBA"; - private static final String HELM_KEY_WORD = "HELM"; - @Override - public Optional<ManifestContent> createManifest( - VspDetails vspDetails, FilesDataStructure filesDataStructure) { - if (Objects.isNull(filesDataStructure)) { - return Optional.empty(); + 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*/}; + private static final String CONTROLLER_BLUEPRINT_ARCHIVE_FIXED_KEY_WORD = "CBA"; + private static final String HELM_KEY_WORD = "HELM"; + + @Override + public Optional<ManifestContent> createManifest(VspDetails vspDetails, FilesDataStructure filesDataStructure) { + if (Objects.isNull(filesDataStructure)) { + return Optional.empty(); + } + List<FileData> fileDataList = new ArrayList<>(); + addModulesToManifestFileDataList(filesDataStructure, fileDataList); + addNestedToManifest(filesDataStructure, fileDataList); + addArtifactsToManifestFileDataList(filesDataStructure, fileDataList); + ManifestContent manifestContent = createManifest(vspDetails, fileDataList); + return Optional.of(manifestContent); } - List<FileData> fileDataList = new ArrayList<>(); - addModulesToManifestFileDataList(filesDataStructure, fileDataList); - addNestedToManifest(filesDataStructure, fileDataList); - addArtifactsToManifestFileDataList(filesDataStructure, fileDataList); - - ManifestContent manifestContent = createManifest(vspDetails, fileDataList); - return Optional.of(manifestContent); - } - - @Override - public Optional<ManifestContent> createManifestFromExisting(VspDetails vspDetails, FilesDataStructure filesDataStructure, ManifestContent existingManifest) { - if (Objects.isNull(filesDataStructure)) { - return Optional.empty(); + @Override + public Optional<ManifestContent> createManifestFromExisting(VspDetails vspDetails, FilesDataStructure filesDataStructure, + ManifestContent existingManifest) { + if (Objects.isNull(filesDataStructure)) { + return Optional.empty(); + } + List<FileData> fileDataList = new ArrayList<>(); + addModulesToManifestFileDataList(filesDataStructure, fileDataList); + addNestedToManifest(filesDataStructure, fileDataList); + addArtifactsToManifestFileDataList(filesDataStructure, fileDataList, existingManifest); + ManifestContent manifestContent = createManifest(vspDetails, fileDataList); + return Optional.of(manifestContent); } - List<FileData> fileDataList = new ArrayList<>(); - addModulesToManifestFileDataList(filesDataStructure, fileDataList); - addNestedToManifest(filesDataStructure, fileDataList); - addArtifactsToManifestFileDataList(filesDataStructure, fileDataList, existingManifest); - - ManifestContent manifestContent = createManifest(vspDetails, fileDataList); - return Optional.of(manifestContent); - } - - private void addArtifactsToManifestFileDataList(FilesDataStructure filesDataStructure, List<FileData> fileDataList, ManifestContent existingManifest) { - Collection<String> forArtifacts = CollectionUtils - .union(filesDataStructure.getArtifacts(), filesDataStructure.getUnassigned()); - if (CollectionUtils.isNotEmpty(forArtifacts)) { - for (String artifact : forArtifacts) { - if (isCloudSpecificArtifact(artifact)) { - fileDataList.add(createBaseFileData(FileData.Type.CLOUD_TECHNOLOGY_SPECIFIC_ARTIFACT, artifact)); - } else if (isControllerBlueprintArchive(artifact)) { - fileDataList.add(createBaseFileData(FileData.Type.CONTROLLER_BLUEPRINT_ARCHIVE, artifact)); - } else if (isHelm(artifact)) { - fileDataList.add(createBaseFileData(FileData.Type.HELM, artifact)); - } else if (isPmDictionary(artifact, existingManifest)) { - fileDataList.add(createBaseFileData(FileData.Type.PM_DICTIONARY, artifact)); + private void addArtifactsToManifestFileDataList(FilesDataStructure filesDataStructure, List<FileData> fileDataList, + ManifestContent existingManifest) { + Collection<String> forArtifacts = CollectionUtils.union(filesDataStructure.getArtifacts(), filesDataStructure.getUnassigned()); + if (CollectionUtils.isNotEmpty(forArtifacts)) { + for (String artifact : forArtifacts) { + if (isCloudSpecificArtifact(artifact)) { + fileDataList.add(createBaseFileData(FileData.Type.CLOUD_TECHNOLOGY_SPECIFIC_ARTIFACT, artifact)); + } else if (isControllerBlueprintArchive(artifact)) { + fileDataList.add(createBaseFileData(FileData.Type.CONTROLLER_BLUEPRINT_ARCHIVE, artifact)); + } else if (isHelm(artifact)) { + fileDataList.add(createBaseFileData(FileData.Type.HELM, artifact)); + } else if (isPmDictionary(artifact, existingManifest)) { + fileDataList.add(createBaseFileData(FileData.Type.PM_DICTIONARY, artifact)); + } else { + fileDataList.add(createBaseFileData(FileData.Type.OTHER, artifact)); + } + } } - else { - fileDataList.add(createBaseFileData(FileData.Type.OTHER, artifact)); - } - } } - } - private boolean isPmDictionary(String artifact, ManifestContent existingManifest) { - return existingManifest.getData() - .stream() - .filter(fileData -> fileData.getType() - .equals(FileData.Type.PM_DICTIONARY)) - .map(FileData::getFile) + private boolean isPmDictionary(String artifact, ManifestContent existingManifest) { + return existingManifest.getData().stream().filter(fileData -> fileData.getType().equals(FileData.Type.PM_DICTIONARY)).map(FileData::getFile) .anyMatch(pmDictionaryFile -> pmDictionaryFile.equals(artifact)); - } - - private void addNestedToManifest( - FilesDataStructure filesDataStructure, List<FileData> fileDataList) { - if (CollectionUtils.isNotEmpty(filesDataStructure.getNested())) { - for (String nested : filesDataStructure.getNested()) { - fileDataList.add(createBaseFileData(FileData.Type.HEAT, nested)); - } } - } - @Override - public Optional<ManifestContent> createManifest(VspDetails vspDetails, - FileContentHandler fileContentHandler, - AnalyzedZipHeatFiles analyzedZipHeatFiles) { - logger.info("Trying to generate manifest"); - if (Objects.isNull(fileContentHandler) - || CollectionUtils.isEmpty(fileContentHandler.getFileList())) { - logger.info("fileContentHandler or filesList is empty. ManifestContent will not be created"); - return Optional.empty(); + private void addNestedToManifest(FilesDataStructure filesDataStructure, List<FileData> fileDataList) { + if (CollectionUtils.isNotEmpty(filesDataStructure.getNested())) { + for (String nested : filesDataStructure.getNested()) { + fileDataList.add(createBaseFileData(FileData.Type.HEAT, nested)); + } + } } - Map<String, byte[]> files = fileContentHandler.getFiles(); + @Override + public Optional<ManifestContent> createManifest(VspDetails vspDetails, FileContentHandler fileContentHandler, + AnalyzedZipHeatFiles analyzedZipHeatFiles) { + logger.info("Trying to generate manifest"); + if (Objects.isNull(fileContentHandler) || CollectionUtils.isEmpty(fileContentHandler.getFileList())) { + logger.info("fileContentHandler or filesList is empty. ManifestContent will not be created"); + return Optional.empty(); + } + Map<String, byte[]> files = fileContentHandler.getFiles(); + List<FileData> fileDataList = createFileDataListFromZipFiles(fileContentHandler, files, analyzedZipHeatFiles.getFilesNotEligbleForModules()); + ManifestContent manifestContent = createManifest(vspDetails, fileDataList); + return Optional.of(manifestContent); + } - List<FileData> fileDataList = - createFileDataListFromZipFiles(fileContentHandler, files, - analyzedZipHeatFiles.getFilesNotEligbleForModules()); - ManifestContent manifestContent = createManifest(vspDetails, fileDataList); + private ManifestContent createManifest(VspDetails vspDetails, List<FileData> fileDataList) { + ManifestContent manifestContent = new ManifestContent(); + manifestContent.setName(vspDetails.getName()); + manifestContent.setDescription(vspDetails.getDescription()); + manifestContent.setVersion(vspDetails.getVersion() == null ? null : vspDetails.getVersion().toString()); + // vsp version, need to check in confluence + manifestContent.setData(fileDataList); + return manifestContent; + } - return Optional.of(manifestContent); - } + private List<FileData> createFileDataListFromZipFiles(FileContentHandler fileContentHandler, Map<String, byte[]> files, + Collection<String> filesNotEligibleForModules) { + Set<String> processedFiles = new HashSet<>(); + List<FileData> fileDataList = new ArrayList<>(); + for (String fileName : files.keySet()) { + if (processedFiles.contains(fileName)) { + continue; + } + if (isFileBaseFile(fileName)) { + fileDataList.add(createModuleFileData(fileName, true, processedFiles, fileContentHandler.getFileList(), fileDataList)); + } else if (isFileModuleFile(fileName, filesNotEligibleForModules)) { + fileDataList.add(createModuleFileData(fileName, false, processedFiles, fileContentHandler.getFileList(), fileDataList)); + } else { + if (HeatFileAnalyzer.isYamlFile(fileName)) { + fileDataList.add(createBasicFileData(fileName, FileData.Type.HEAT, null)); + } else if (HeatFileAnalyzer.isEnvFile(fileName)) { + fileDataList.add(createBasicFileData(fileName, FileData.Type.HEAT_ENV, null)); + } else { + fileDataList.add(createBasicFileData(fileName, FileData.Type.OTHER, null)); + } + } + } + return fileDataList; + } - private ManifestContent createManifest(VspDetails vspDetails, List<FileData> fileDataList) { - ManifestContent manifestContent = new ManifestContent(); - manifestContent.setName(vspDetails.getName()); - manifestContent.setDescription(vspDetails.getDescription()); - manifestContent - .setVersion(vspDetails.getVersion() == null ? null : vspDetails.getVersion().toString()); - // vsp version, need to check in confluence - manifestContent.setData(fileDataList); - return manifestContent; - } + private boolean isFileModuleFile(String fileName, Collection<String> filesCannotBeModule) { + return !filesCannotBeModule.contains(fileName); + } - private List<FileData> createFileDataListFromZipFiles(FileContentHandler fileContentHandler, - Map<String, byte[]> files, - Collection<String> filesNotEligibleForModules) { + @Override + public boolean isFileBaseFile(String fileName) { + return Pattern.matches(Constants.BASE_HEAT_REGEX, fileName) && !isVolFile(fileName); + } - Set<String> processedFiles = new HashSet<>(); - List<FileData> fileDataList = new ArrayList<>(); - for (String fileName : files.keySet()) { - if (processedFiles.contains(fileName)) { - continue; - } - if (isFileBaseFile(fileName)) { - fileDataList - .add(createModuleFileData( - fileName, true, processedFiles, fileContentHandler.getFileList(), fileDataList)); - } else if (isFileModuleFile(fileName, filesNotEligibleForModules)) { - fileDataList - .add(createModuleFileData( - fileName, false, processedFiles, fileContentHandler.getFileList(), fileDataList)); - } else { - if (HeatFileAnalyzer.isYamlFile(fileName)) { - fileDataList.add(createBasicFileData(fileName, FileData.Type.HEAT, null)); - } else if (HeatFileAnalyzer.isEnvFile(fileName)) { - fileDataList.add(createBasicFileData(fileName, FileData.Type.HEAT_ENV, null)); + 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 { - fileDataList.add(createBasicFileData(fileName, FileData.Type.OTHER, null)); + return false; } - } } - return fileDataList; - } - - private boolean isFileModuleFile(String fileName, Collection<String> filesCannotBeModule) { - return !filesCannotBeModule.contains(fileName); - } - @Override - public boolean isFileBaseFile(String fileName) { - 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 boolean isControllerBlueprintArchive(String artifact) { - return artifact.toUpperCase().contains(CONTROLLER_BLUEPRINT_ARCHIVE_FIXED_KEY_WORD); - } + private boolean isControllerBlueprintArchive(String artifact) { + return artifact.toUpperCase().contains(CONTROLLER_BLUEPRINT_ARCHIVE_FIXED_KEY_WORD); + } - private boolean isHelm(String artifact) { - return artifact.toUpperCase().contains(HELM_KEY_WORD); - } + private boolean isHelm(String artifact) { + return artifact.toUpperCase().contains(HELM_KEY_WORD); + } - private void addArtifactsToManifestFileDataList( - FilesDataStructure filesDataStructure, List<FileData> fileDataList) { - Collection<String> forArtifacts = CollectionUtils - .union(filesDataStructure.getArtifacts(), filesDataStructure.getUnassigned()); - if (CollectionUtils.isNotEmpty(forArtifacts)) { - for (String artifact : forArtifacts) { - if (isCloudSpecificArtifact(artifact)) { - fileDataList.add(createBaseFileData(FileData.Type.CLOUD_TECHNOLOGY_SPECIFIC_ARTIFACT, artifact)); - } else if (isControllerBlueprintArchive(artifact)) { - fileDataList.add(createBaseFileData(FileData.Type.CONTROLLER_BLUEPRINT_ARCHIVE, artifact)); - } else if (isHelm(artifact)) { - fileDataList.add(createBaseFileData(FileData.Type.HELM, artifact)); - } else { - fileDataList.add(createBaseFileData(FileData.Type.OTHER, artifact)); + private void addArtifactsToManifestFileDataList(FilesDataStructure filesDataStructure, List<FileData> fileDataList) { + Collection<String> forArtifacts = CollectionUtils.union(filesDataStructure.getArtifacts(), filesDataStructure.getUnassigned()); + if (CollectionUtils.isNotEmpty(forArtifacts)) { + for (String artifact : forArtifacts) { + if (isCloudSpecificArtifact(artifact)) { + fileDataList.add(createBaseFileData(FileData.Type.CLOUD_TECHNOLOGY_SPECIFIC_ARTIFACT, artifact)); + } else if (isControllerBlueprintArchive(artifact)) { + fileDataList.add(createBaseFileData(FileData.Type.CONTROLLER_BLUEPRINT_ARCHIVE, artifact)); + } else if (isHelm(artifact)) { + fileDataList.add(createBaseFileData(FileData.Type.HELM, artifact)); + } else { + fileDataList.add(createBaseFileData(FileData.Type.OTHER, artifact)); + } + } } - } } - } - private void addModulesToManifestFileDataList( - FilesDataStructure filesDataStructure, List<FileData> fileDataList) { - if (CollectionUtils.isNotEmpty(filesDataStructure.getModules())) { - for (Module module : filesDataStructure.getModules()) { - FileData.Type type = module.getType(); - if (type == null) { - type = FileData.Type.HEAT; + private void addModulesToManifestFileDataList(FilesDataStructure filesDataStructure, List<FileData> fileDataList) { + if (CollectionUtils.isNotEmpty(filesDataStructure.getModules())) { + for (Module module : filesDataStructure.getModules()) { + FileData.Type type = module.getType(); + if (type == null) { + type = FileData.Type.HEAT; + } + FileData fileData = createBaseFileData(type, module.getYaml()); + fileData.setBase(module.getIsBase()); + addEnv(module, fileData); + addVolume(module, fileData); + fileDataList.add(fileData); + } } - FileData fileData = createBaseFileData(type, module.getYaml()); - fileData.setBase(module.getIsBase()); - addEnv(module, fileData); - addVolume(module, fileData); - fileDataList.add(fileData); - } } - } - private void addEnv(Module module, FileData fileData) { - if (Objects.nonNull(module.getEnv())) { - FileData env = createBaseFileData(FileData.Type.HEAT_ENV, module.getEnv()); - fileData.addFileData(env); + private void addEnv(Module module, FileData fileData) { + if (Objects.nonNull(module.getEnv())) { + FileData env = createBaseFileData(FileData.Type.HEAT_ENV, module.getEnv()); + fileData.addFileData(env); + } } - } - private void addVolume(Module module, FileData fileData) { - String volModule = module.getVol(); - if (Objects.nonNull(volModule)) { - FileData vol = createBaseFileData(FileData.Type.HEAT_VOL, volModule); - if (Objects.nonNull(module.getVolEnv())) { - vol.addFileData(createBaseFileData(FileData.Type.HEAT_ENV, module.getVolEnv())); - } - fileData.addFileData(vol); + private void addVolume(Module module, FileData fileData) { + String volModule = module.getVol(); + if (Objects.nonNull(volModule)) { + FileData vol = createBaseFileData(FileData.Type.HEAT_VOL, volModule); + if (Objects.nonNull(module.getVolEnv())) { + vol.addFileData(createBaseFileData(FileData.Type.HEAT_ENV, module.getVolEnv())); + } + fileData.addFileData(vol); + } } - } - - private FileData createBaseFileData(FileData.Type heat, String yaml) { - FileData fileData = new FileData(); - fileData.setType(heat); - fileData.setFile(yaml); - return fileData; - } - - private FileData createModuleFileData( - String moduleFileName, boolean isBase, Set<String> processedFiles, - Set<String> fileNames, List<FileData> fileDataList) { - FileData moduleFileData = createBasicFileData(moduleFileName, FileData.Type.HEAT, isBase); - Optional<String> volFile = fetchRelatedVolume(moduleFileName, fileNames); - volFile.ifPresent(vol -> { - markFileAsProcessed(vol, processedFiles); - removeFromFileDataListIfAlreadyProcessed(fileDataList, vol); - FileData volFileData = createBasicFileData(vol, FileData.Type.HEAT_VOL, null); - Optional<String> envFile = fetchRelatedEnv(vol, fileNames); - envFile.ifPresent(env -> { - markFileAsProcessed(env, processedFiles); - removeFromFileDataListIfAlreadyProcessed(fileDataList, env); - FileData envFileData = createBasicFileData(env, FileData.Type.HEAT_ENV, null); - volFileData.addFileData(envFileData); - }); - moduleFileData.addFileData(volFileData); - }); - Optional<String> envFile = fetchRelatedEnv(moduleFileName, fileNames); - envFile.ifPresent(env -> { - markFileAsProcessed(env, processedFiles); - FileData envFileData = createBasicFileData(env, FileData.Type.HEAT_ENV, null); - moduleFileData.addFileData(envFileData); - }); - return moduleFileData; - } - private void removeFromFileDataListIfAlreadyProcessed(List<FileData> fileDataList, String vol) { - fileDataList.removeIf(fileData -> fileData.getFile().equals(vol)); - } - - private FileData createBasicFileData(String fileName, FileData.Type type, Boolean isBase) { - FileData fileData = new FileData(); - if (isBase != null) { - fileData.setBase(isBase); + private FileData createBaseFileData(FileData.Type heat, String yaml) { + FileData fileData = new FileData(); + fileData.setType(heat); + fileData.setFile(yaml); + return fileData; } - fileData.setType(type); - fileData.setFile(fileName); - return fileData; - } - - private Optional<String> fetchRelatedEnv(String fileName, Set<String> fileNames) { - String envFileName - = fileName.substring(0, fileName.lastIndexOf(".")) + Constants.ENV_FILE_EXTENSION; - return fileNames.contains(envFileName) ? Optional.of(envFileName) : Optional.empty(); - } - private Optional<String> fetchRelatedVolume(String fileName, Set<String> fileNames) { - - String volFile1stExt = - extractVolFileName(fileName, ".yaml"); - String volFile2ndExt = - extractVolFileName(fileName, ".yml"); + private FileData createModuleFileData(String moduleFileName, boolean isBase, Set<String> processedFiles, Set<String> fileNames, + List<FileData> fileDataList) { + FileData moduleFileData = createBasicFileData(moduleFileName, FileData.Type.HEAT, isBase); + Optional<String> volFile = fetchRelatedVolume(moduleFileName, fileNames); + volFile.ifPresent(vol -> { + markFileAsProcessed(vol, processedFiles); + removeFromFileDataListIfAlreadyProcessed(fileDataList, vol); + FileData volFileData = createBasicFileData(vol, FileData.Type.HEAT_VOL, null); + Optional<String> envFile = fetchRelatedEnv(vol, fileNames); + envFile.ifPresent(env -> { + markFileAsProcessed(env, processedFiles); + removeFromFileDataListIfAlreadyProcessed(fileDataList, env); + FileData envFileData = createBasicFileData(env, FileData.Type.HEAT_ENV, null); + volFileData.addFileData(envFileData); + }); + moduleFileData.addFileData(volFileData); + }); + Optional<String> envFile = fetchRelatedEnv(moduleFileName, fileNames); + envFile.ifPresent(env -> { + markFileAsProcessed(env, processedFiles); + FileData envFileData = createBasicFileData(env, FileData.Type.HEAT_ENV, null); + moduleFileData.addFileData(envFileData); + }); + return moduleFileData; + } - if (fileNames.contains(volFile1stExt)) { - return Optional.of(volFile1stExt); + private void removeFromFileDataListIfAlreadyProcessed(List<FileData> fileDataList, String vol) { + fileDataList.removeIf(fileData -> fileData.getFile().equals(vol)); } - if (fileNames.contains(volFile2ndExt)) { - return Optional.of(volFile2ndExt); + + private FileData createBasicFileData(String fileName, FileData.Type type, Boolean isBase) { + FileData fileData = new FileData(); + if (isBase != null) { + fileData.setBase(isBase); + } + fileData.setType(type); + fileData.setFile(fileName); + return fileData; } - return Optional.empty(); - } - private String extractVolFileName(String fileName, String fileExt) { - return fileName.substring( - 0, fileName.lastIndexOf(".")) - + Constants.VOL_FILE_NAME_SUFFIX + fileExt; - } + private Optional<String> fetchRelatedEnv(String fileName, Set<String> fileNames) { + String envFileName = fileName.substring(0, fileName.lastIndexOf(".")) + Constants.ENV_FILE_EXTENSION; + return fileNames.contains(envFileName) ? Optional.of(envFileName) : Optional.empty(); + } + private Optional<String> fetchRelatedVolume(String fileName, Set<String> fileNames) { + String volFile1stExt = extractVolFileName(fileName, ".yaml"); + String volFile2ndExt = extractVolFileName(fileName, ".yml"); + if (fileNames.contains(volFile1stExt)) { + return Optional.of(volFile1stExt); + } + if (fileNames.contains(volFile2ndExt)) { + return Optional.of(volFile2ndExt); + } + return Optional.empty(); + } - private boolean isVolFile(String fileName) { - return fileName - .endsWith( - Constants.VOL_FILE_NAME_SUFFIX + ".yaml") - || fileName.endsWith(Constants.VOL_FILE_NAME_SUFFIX + ".yml"); - } + private String extractVolFileName(String fileName, String fileExt) { + return fileName.substring(0, fileName.lastIndexOf(".")) + Constants.VOL_FILE_NAME_SUFFIX + fileExt; + } + private boolean isVolFile(String fileName) { + return fileName.endsWith(Constants.VOL_FILE_NAME_SUFFIX + ".yaml") || fileName.endsWith(Constants.VOL_FILE_NAME_SUFFIX + ".yml"); + } - private void markFileAsProcessed(String fileName, Set<String> processedFiles) { - processedFiles.add(fileName); - } + private void markFileAsProcessed(String fileName, Set<String> processedFiles) { + processedFiles.add(fileName); + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/utils/CandidateServiceValidator.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/utils/CandidateServiceValidator.java index c366b7f4b9..a3d2e65889 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/utils/CandidateServiceValidator.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/utils/CandidateServiceValidator.java @@ -7,9 +7,9 @@ * 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. @@ -17,9 +17,13 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.services.utils; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Objects; +import java.util.Optional; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang.StringUtils; import org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder; @@ -29,48 +33,41 @@ import org.openecomp.sdc.datatypes.error.ErrorMessage; import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.FilesDataStructure; import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.Module; -import java.util.*; - /** * Created by Talio on 12/6/2016. */ public class CandidateServiceValidator { - public Optional<List<ErrorMessage>> validateFileDataStructure( - FilesDataStructure filesDataStructure) { - if (Objects.isNull(filesDataStructure)) { - return Optional.empty(); - } - if (validateAtLeaseOneModuleExist(filesDataStructure)) { - return Optional.of(Arrays.asList(new ErrorMessage(ErrorLevel.ERROR, Messages - .NO_MODULES_IN_MANIFEST.getErrorMessage()))); - } - List<ErrorMessage> errors = new ArrayList<>(); - for (Module module : filesDataStructure.getModules()) { - validateModuleHaveYaml(errors, module); - validateNoVolEnvWithoutVol(errors, module); + public Optional<List<ErrorMessage>> validateFileDataStructure(FilesDataStructure filesDataStructure) { + if (Objects.isNull(filesDataStructure)) { + return Optional.empty(); + } + if (validateAtLeaseOneModuleExist(filesDataStructure)) { + return Optional.of(Arrays.asList(new ErrorMessage(ErrorLevel.ERROR, Messages.NO_MODULES_IN_MANIFEST.getErrorMessage()))); + } + List<ErrorMessage> errors = new ArrayList<>(); + for (Module module : filesDataStructure.getModules()) { + validateModuleHaveYaml(errors, module); + validateNoVolEnvWithoutVol(errors, module); + } + return Optional.of(errors); } - return Optional.of(errors); - } - - private boolean validateAtLeaseOneModuleExist(FilesDataStructure filesDataStructure) { - return CollectionUtils.isEmpty(filesDataStructure.getModules()); - } + private boolean validateAtLeaseOneModuleExist(FilesDataStructure filesDataStructure) { + return CollectionUtils.isEmpty(filesDataStructure.getModules()); + } - private void validateNoVolEnvWithoutVol(List<ErrorMessage> errors, Module module) { - if (StringUtils.isEmpty(module.getVol()) && StringUtils.isNotEmpty(module.getVolEnv())) { - errors.add(new ErrorMessage(ErrorLevel.ERROR, ErrorMessagesFormatBuilder - .getErrorWithParameters(Messages.MODULE_IN_MANIFEST_VOL_ENV_NO_VOL.getErrorMessage(), - module.getName()))); + private void validateNoVolEnvWithoutVol(List<ErrorMessage> errors, Module module) { + if (StringUtils.isEmpty(module.getVol()) && StringUtils.isNotEmpty(module.getVolEnv())) { + errors.add(new ErrorMessage(ErrorLevel.ERROR, + ErrorMessagesFormatBuilder.getErrorWithParameters(Messages.MODULE_IN_MANIFEST_VOL_ENV_NO_VOL.getErrorMessage(), module.getName()))); + } } - } - private void validateModuleHaveYaml(List<ErrorMessage> errors, Module module) { - if (StringUtils.isEmpty(module.getYaml())) { - errors.add(new ErrorMessage(ErrorLevel.ERROR, ErrorMessagesFormatBuilder - .getErrorWithParameters(Messages.MODULE_IN_MANIFEST_NO_YAML.getErrorMessage(), - module.getName()))); + private void validateModuleHaveYaml(List<ErrorMessage> errors, Module module) { + if (StringUtils.isEmpty(module.getYaml())) { + errors.add(new ErrorMessage(ErrorLevel.ERROR, + ErrorMessagesFormatBuilder.getErrorWithParameters(Messages.MODULE_IN_MANIFEST_NO_YAML.getErrorMessage(), module.getName()))); + } } - } } |