summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src
diff options
context:
space:
mode:
authorvasraz <vasyl.razinkov@est.tech>2021-03-22 15:33:06 +0000
committerChristophe Closset <christophe.closset@intl.att.com>2021-03-24 06:59:47 +0000
commitd378c37fbd1ecec7b43394926f1ca32a695e07de (patch)
tree5c8a085f8732f980d871d966ac49361644efa698 /openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src
parenta6ae7294ecd336d7e88f915710b08e2658eaee00 (diff)
Reformat openecomp-be
Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech> Issue-ID: SDC-3449 Change-Id: I13e02322f8e00820cc5a1d85752caaeda9bf10d1
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src')
-rw-r--r--openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/EnrichedServiceModelDaoFactoryImpl.java18
-rw-r--r--openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/ServiceModelDaoFactoryImpl.java17
-rw-r--r--openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/ElementType.java11
-rw-r--r--openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/EnrichedServiceModelDaoZusammenImpl.java59
-rw-r--r--openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/ServiceModelDaoZusammenImpl.java410
-rw-r--r--openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/StructureElement.java14
6 files changed, 217 insertions, 312 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/EnrichedServiceModelDaoFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/EnrichedServiceModelDaoFactoryImpl.java
index 98cb8724df..7ffd0b0c7b 100644
--- a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/EnrichedServiceModelDaoFactoryImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/EnrichedServiceModelDaoFactoryImpl.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.model.impl;
import org.openecomp.core.model.dao.EnrichedServiceModelDao;
@@ -26,11 +25,12 @@ import org.openecomp.core.zusammen.api.ZusammenAdaptorFactory;
import org.openecomp.sdc.model.impl.zusammen.EnrichedServiceModelDaoZusammenImpl;
public class EnrichedServiceModelDaoFactoryImpl extends EnrichedServiceModelDaoFactory {
- private static final EnrichedServiceModelDao INSTANCE = new EnrichedServiceModelDaoZusammenImpl( ZusammenAdaptorFactory
- .getInstance().createInterface());
- @Override
- public EnrichedServiceModelDao createInterface() {
- return INSTANCE;
- }
+ private static final EnrichedServiceModelDao INSTANCE = new EnrichedServiceModelDaoZusammenImpl(
+ ZusammenAdaptorFactory.getInstance().createInterface());
+
+ @Override
+ public EnrichedServiceModelDao createInterface() {
+ return INSTANCE;
+ }
}
diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/ServiceModelDaoFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/ServiceModelDaoFactoryImpl.java
index 85508670aa..5134076a5f 100644
--- a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/ServiceModelDaoFactoryImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/ServiceModelDaoFactoryImpl.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.model.impl;
import org.openecomp.core.model.dao.ServiceModelDao;
@@ -26,11 +25,11 @@ import org.openecomp.core.zusammen.api.ZusammenAdaptorFactory;
import org.openecomp.sdc.model.impl.zusammen.ServiceModelDaoZusammenImpl;
public class ServiceModelDaoFactoryImpl extends ServiceModelDaoFactory {
- private static final ServiceModelDao INSTANCE = new ServiceModelDaoZusammenImpl(
- ZusammenAdaptorFactory.getInstance().createInterface());
- @Override
- public ServiceModelDao createInterface() {
- return INSTANCE;
- }
+ private static final ServiceModelDao INSTANCE = new ServiceModelDaoZusammenImpl(ZusammenAdaptorFactory.getInstance().createInterface());
+
+ @Override
+ public ServiceModelDao createInterface() {
+ return INSTANCE;
+ }
}
diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/ElementType.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/ElementType.java
index 788bf79423..4f62a16642 100644
--- a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/ElementType.java
+++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/ElementType.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,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.model.impl.zusammen;
-public enum ElementType {
- Servicetemplate,Artifact;
-
-
-}
+public enum ElementType {Servicetemplate, Artifact;}
diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/EnrichedServiceModelDaoZusammenImpl.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/EnrichedServiceModelDaoZusammenImpl.java
index 938f104b1e..6f1492c163 100644
--- a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/EnrichedServiceModelDaoZusammenImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/EnrichedServiceModelDaoZusammenImpl.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,10 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.model.impl.zusammen;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.buildStructuralElement;
+
import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement;
import com.amdocs.zusammen.datatypes.SessionContext;
import com.amdocs.zusammen.datatypes.item.Action;
@@ -35,41 +36,29 @@ import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
-import static org.openecomp.core.zusammen.api.ZusammenUtil.buildStructuralElement;
-
public class EnrichedServiceModelDaoZusammenImpl extends ServiceModelDaoZusammenImpl implements
EnrichedServiceModelDao<ToscaServiceModel, ServiceElement> {
- private static final Logger logger =
- LoggerFactory.getLogger(EnrichedServiceModelDaoZusammenImpl.class);
-
- public EnrichedServiceModelDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) {
- super(zusammenAdaptor);
- this.elementType = ElementType.EnrichedServiceModel;
- }
-
- @Override
- public void storeExternalArtifact(ServiceArtifact serviceArtifact) {
- ZusammenElement artifact = buildArtifactElement(serviceArtifact.getName(),
- FileUtils.toByteArray(serviceArtifact.getContent()), Action.CREATE);
-
- ZusammenElement artifacts = buildStructuralElement(ElementType.Artifacts, Action.IGNORE);
- artifacts.addSubElement(artifact);
-
- ZusammenElement enrichedServiceModel = buildStructuralElement(elementType, Action.IGNORE);
- enrichedServiceModel.addSubElement(artifacts);
-
- ZusammenElement vspModel = buildStructuralElement(ElementType.VspModel, Action.IGNORE);
- vspModel.addSubElement(enrichedServiceModel);
+ private static final Logger logger = LoggerFactory.getLogger(EnrichedServiceModelDaoZusammenImpl.class);
- SessionContext context = ZusammenUtil.createSessionContext();
- ElementContext elementContext =
- new ElementContext(serviceArtifact.getVspId(), serviceArtifact.getVersion().getId());
- zusammenAdaptor
- .saveElement(context, elementContext, vspModel, "add service external artifact.");
+ public EnrichedServiceModelDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) {
+ super(zusammenAdaptor);
+ this.elementType = ElementType.EnrichedServiceModel;
+ }
- logger.info(
- "Finished adding artifact to enriched service model for VendorSoftwareProduct id -> {}",
- elementContext.getItemId().getValue());
- }
+ @Override
+ public void storeExternalArtifact(ServiceArtifact serviceArtifact) {
+ ZusammenElement artifact = buildArtifactElement(serviceArtifact.getName(), FileUtils.toByteArray(serviceArtifact.getContent()),
+ Action.CREATE);
+ ZusammenElement artifacts = buildStructuralElement(ElementType.Artifacts, Action.IGNORE);
+ artifacts.addSubElement(artifact);
+ ZusammenElement enrichedServiceModel = buildStructuralElement(elementType, Action.IGNORE);
+ enrichedServiceModel.addSubElement(artifacts);
+ ZusammenElement vspModel = buildStructuralElement(ElementType.VspModel, Action.IGNORE);
+ vspModel.addSubElement(enrichedServiceModel);
+ SessionContext context = ZusammenUtil.createSessionContext();
+ ElementContext elementContext = new ElementContext(serviceArtifact.getVspId(), serviceArtifact.getVersion().getId());
+ zusammenAdaptor.saveElement(context, elementContext, vspModel, "add service external artifact.");
+ logger.info("Finished adding artifact to enriched service model for VendorSoftwareProduct id -> {}", elementContext.getItemId().getValue());
+ }
}
diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/ServiceModelDaoZusammenImpl.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/ServiceModelDaoZusammenImpl.java
index 8ff78d6401..27ef113204 100644
--- a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/ServiceModelDaoZusammenImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/ServiceModelDaoZusammenImpl.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.model.impl.zusammen;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.buildElement;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.buildStructuralElement;
+
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 +30,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.Collection;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.stream.Collectors;
import org.apache.commons.io.IOUtils;
import org.onap.sdc.tosca.datatypes.model.ServiceTemplate;
import org.onap.sdc.tosca.services.ToscaExtensionYamlUtil;
@@ -45,267 +53,189 @@ import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
import org.openecomp.sdc.versioning.dao.types.Version;
import org.openecomp.types.ElementPropertyName;
-import java.io.ByteArrayInputStream;
-import java.util.Collection;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.stream.Collectors;
-
-import static org.openecomp.core.zusammen.api.ZusammenUtil.buildElement;
-import static org.openecomp.core.zusammen.api.ZusammenUtil.buildStructuralElement;
-
-public class ServiceModelDaoZusammenImpl
- implements ServiceModelDao<ToscaServiceModel, ServiceElement> {
- private static final String BASE_PROPERTY = "base";
- private static final Logger logger = LoggerFactory.getLogger(ServiceModelDaoZusammenImpl.class);
-
- protected ZusammenAdaptor zusammenAdaptor;
- protected ElementType elementType;
+public class ServiceModelDaoZusammenImpl implements ServiceModelDao<ToscaServiceModel, ServiceElement> {
- public ServiceModelDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) {
- this.zusammenAdaptor = zusammenAdaptor;
- this.elementType = ElementType.ServiceModel;
- }
+ private static final String BASE_PROPERTY = "base";
+ private static final Logger logger = LoggerFactory.getLogger(ServiceModelDaoZusammenImpl.class);
+ protected ZusammenAdaptor zusammenAdaptor;
+ protected ElementType elementType;
- @Override
- public void registerVersioning(String versionableEntityType) {
-
- }
-
- @Override
- public ToscaServiceModel getServiceModel(String vspId, Version version) {
- SessionContext context = ZusammenUtil.createSessionContext();
- ElementContext elementContext = new ElementContext(vspId, version.getId());
-
- Optional<ElementInfo> serviceModel = getServiceModelElementInfo(context, elementContext);
- if (!serviceModel.isPresent()) {
- return null;
+ public ServiceModelDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) {
+ this.zusammenAdaptor = zusammenAdaptor;
+ this.elementType = ElementType.ServiceModel;
}
- Id serviceModelElementId = serviceModel.get().getId();
- Map<String, ServiceTemplate> serviceTemplates =
- getTemplates(context, elementContext, serviceModelElementId);
- if (serviceTemplates == null) {
- return null;
+ @Override
+ public void registerVersioning(String versionableEntityType) {
}
- FileContentHandler artifacts = getArtifacts(context, elementContext, serviceModelElementId);
- String entryDefinitionServiceTemplate =
- serviceModel.get().getInfo().getProperty(BASE_PROPERTY);
-
- return new ToscaServiceModel(artifacts, serviceTemplates, entryDefinitionServiceTemplate);
- }
-
- @Override
- public void storeServiceModel(String vspId, Version version, ToscaServiceModel serviceModel) {
- logger.info("Storing service model for VendorSoftwareProduct id -> {}", vspId);
-
- ZusammenElement templatesElement = buildStructuralElement(ElementType.Templates, Action.UPDATE);
- serviceModel.getServiceTemplates().forEach((key, value) -> templatesElement.addSubElement(
- buildServiceTemplateElement(key, value, serviceModel.getEntryDefinitionServiceTemplate(), Action.CREATE)));
-
- ZusammenElement artifactsElement = buildStructuralElement(ElementType.Artifacts, Action.UPDATE);
- if (Objects.nonNull(serviceModel.getArtifactFiles())) {
- serviceModel.getArtifactFiles().getFiles().forEach(
- (key, value) -> artifactsElement.addSubElement(buildArtifactElement(key, value, Action.CREATE)));
+ @Override
+ public ToscaServiceModel getServiceModel(String vspId, Version version) {
+ SessionContext context = ZusammenUtil.createSessionContext();
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
+ Optional<ElementInfo> serviceModel = getServiceModelElementInfo(context, elementContext);
+ if (!serviceModel.isPresent()) {
+ return null;
+ }
+ Id serviceModelElementId = serviceModel.get().getId();
+ Map<String, ServiceTemplate> serviceTemplates = getTemplates(context, elementContext, serviceModelElementId);
+ if (serviceTemplates == null) {
+ return null;
+ }
+ FileContentHandler artifacts = getArtifacts(context, elementContext, serviceModelElementId);
+ String entryDefinitionServiceTemplate = serviceModel.get().getInfo().getProperty(BASE_PROPERTY);
+ return new ToscaServiceModel(artifacts, serviceTemplates, entryDefinitionServiceTemplate);
}
- ZusammenElement serviceModelElement = buildServiceModelElement(serviceModel.getEntryDefinitionServiceTemplate());
-
- serviceModelElement.addSubElement(templatesElement);
- serviceModelElement.addSubElement(artifactsElement);
-
- ZusammenElement vspModel = buildStructuralElement(ElementType.VspModel, Action.IGNORE);
- vspModel.addSubElement(serviceModelElement);
-
- SessionContext context = ZusammenUtil.createSessionContext();
- ElementContext elementContext = new ElementContext(vspId, version.getId());
- zusammenAdaptor.saveElement(context, elementContext, vspModel, "Store service model");
-
- logger
- .info("Finished storing {} for VendorSoftwareProduct id -> {}", elementType.name(), vspId);
- }
-
- @Override
- public ServiceElement getServiceModelInfo(String vspId, Version version, String name) {
- return null;
- }
-
- @Override
- public void deleteAll(String vspId, Version version) {
- logger.info("Started deleting content of Templates and Artifacts of {} of vsp {} version {}",
- elementType.name(), vspId, version.getId());
-
- SessionContext context = ZusammenUtil.createSessionContext();
- ElementContext elementContext = new ElementContext(vspId, version.getId());
-
- Optional<ElementInfo> serviceModel = getServiceModelElementInfo(context, elementContext);
- if (!serviceModel.isPresent()) {
- logger.info("{} of vsp {} version {} does not exist - nothing to delete", elementType.name(),
- vspId, version.getId());
- return;
+ @Override
+ public void storeServiceModel(String vspId, Version version, ToscaServiceModel serviceModel) {
+ logger.info("Storing service model for VendorSoftwareProduct id -> {}", vspId);
+ ZusammenElement templatesElement = buildStructuralElement(ElementType.Templates, Action.UPDATE);
+ serviceModel.getServiceTemplates().forEach((key, value) -> templatesElement
+ .addSubElement(buildServiceTemplateElement(key, value, serviceModel.getEntryDefinitionServiceTemplate(), Action.CREATE)));
+ ZusammenElement artifactsElement = buildStructuralElement(ElementType.Artifacts, Action.UPDATE);
+ if (Objects.nonNull(serviceModel.getArtifactFiles())) {
+ serviceModel.getArtifactFiles().getFiles()
+ .forEach((key, value) -> artifactsElement.addSubElement(buildArtifactElement(key, value, Action.CREATE)));
+ }
+ ZusammenElement serviceModelElement = buildServiceModelElement(serviceModel.getEntryDefinitionServiceTemplate());
+ serviceModelElement.addSubElement(templatesElement);
+ serviceModelElement.addSubElement(artifactsElement);
+ ZusammenElement vspModel = buildStructuralElement(ElementType.VspModel, Action.IGNORE);
+ vspModel.addSubElement(serviceModelElement);
+ SessionContext context = ZusammenUtil.createSessionContext();
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
+ zusammenAdaptor.saveElement(context, elementContext, vspModel, "Store service model");
+ logger.info("Finished storing {} for VendorSoftwareProduct id -> {}", elementType.name(), vspId);
}
- ZusammenElement serviceModelElement = buildElement(serviceModel.get().getId(), Action.IGNORE);
- for (Id serviceModelSubElementId :
- serviceModel.get().getSubElements().stream()
- .map(ElementInfo::getId)
- .collect(Collectors.toSet())) {
- ElementInfo serviceModelSubElementInfo =
- zusammenAdaptor.getElementInfo(context, elementContext, serviceModelSubElementId)
- .orElseThrow(() -> new IllegalStateException(String.format(
- "Element %s declared as sub element of element %s (%s) does not exist",
- serviceModelSubElementId.getValue(),
- serviceModel.get().getId().getValue(),
- elementType.name())));
-
- if (ElementType.Templates.name().equals(serviceModelSubElementInfo.getInfo().getName())
- || ElementType.Artifacts.name().equals(serviceModelSubElementInfo.getInfo().getName())) {
- ZusammenElement serviceModelSubElement =
- buildElement(serviceModelSubElementId, Action.IGNORE);
- serviceModelSubElement.setSubElements(serviceModelSubElementInfo.getSubElements().stream()
- .map(elementInfo -> buildElement(elementInfo.getId(), Action.DELETE))
- .collect(Collectors.toSet()));
- serviceModelElement.addSubElement(serviceModelSubElement);
- }
+ @Override
+ public ServiceElement getServiceModelInfo(String vspId, Version version, String name) {
+ return null;
}
- zusammenAdaptor.saveElement(context, elementContext, serviceModelElement,
- String.format("Delete content of Templates and Artifacts of %s", elementType.name()));
-
- logger.info("Finished deleting content of Templates and Artifacts of {} of vsp {} version {}",
- elementType.name(), vspId, version.getId());
- }
-
- @Override
- public void overrideServiceModel(String vspId,
- Version version,
- ToscaServiceModel serviceModel) {
- SessionContext context = ZusammenUtil.createSessionContext();
- ElementContext elementContext = new ElementContext(vspId, version.getId());
-
- Optional<ElementInfo> origServiceModel = getServiceModelElementInfo(context, elementContext);
- if (!origServiceModel.isPresent()) {
- return;
+ @Override
+ public void deleteAll(String vspId, Version version) {
+ logger.info("Started deleting content of Templates and Artifacts of {} of vsp {} version {}", elementType.name(), vspId, version.getId());
+ SessionContext context = ZusammenUtil.createSessionContext();
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
+ Optional<ElementInfo> serviceModel = getServiceModelElementInfo(context, elementContext);
+ if (!serviceModel.isPresent()) {
+ logger.info("{} of vsp {} version {} does not exist - nothing to delete", elementType.name(), vspId, version.getId());
+ return;
+ }
+ ZusammenElement serviceModelElement = buildElement(serviceModel.get().getId(), Action.IGNORE);
+ for (Id serviceModelSubElementId : serviceModel.get().getSubElements().stream().map(ElementInfo::getId).collect(Collectors.toSet())) {
+ ElementInfo serviceModelSubElementInfo = zusammenAdaptor.getElementInfo(context, elementContext, serviceModelSubElementId).orElseThrow(
+ () -> new IllegalStateException(String
+ .format("Element %s declared as sub element of element %s (%s) does not exist", serviceModelSubElementId.getValue(),
+ serviceModel.get().getId().getValue(), elementType.name())));
+ if (ElementType.Templates.name().equals(serviceModelSubElementInfo.getInfo().getName()) || ElementType.Artifacts.name()
+ .equals(serviceModelSubElementInfo.getInfo().getName())) {
+ ZusammenElement serviceModelSubElement = buildElement(serviceModelSubElementId, Action.IGNORE);
+ serviceModelSubElement.setSubElements(
+ serviceModelSubElementInfo.getSubElements().stream().map(elementInfo -> buildElement(elementInfo.getId(), Action.DELETE))
+ .collect(Collectors.toSet()));
+ serviceModelElement.addSubElement(serviceModelSubElement);
+ }
+ }
+ zusammenAdaptor.saveElement(context, elementContext, serviceModelElement,
+ String.format("Delete content of Templates and Artifacts of %s", elementType.name()));
+ logger.info("Finished deleting content of Templates and Artifacts of {} of vsp {} version {}", elementType.name(), vspId, version.getId());
}
- Id serviceModelElementId = origServiceModel.get().getId();
-
- ZusammenElement serviceModelElement = buildServiceModelElement(serviceModel.getEntryDefinitionServiceTemplate());
- serviceModelElement.setElementId(serviceModelElementId);
-
- overrideServiceTemplates(serviceModelElementId, serviceModel, context, elementContext, serviceModelElement);
- zusammenAdaptor.saveElement(context, elementContext, serviceModelElement, "Override service model");
- }
-
-
- private void overrideServiceTemplates(Id serviceModelElementId,
- ToscaServiceModel serviceModel,
- SessionContext context,
- ElementContext elementContext,
- ZusammenElement serviceModelElement) {
- Optional<ElementInfo> elementInfo = zusammenAdaptor.getElementInfoByName(
- context, elementContext, serviceModelElementId, ElementType.Templates.name());
- if (!elementInfo.isPresent()) {
- return;
+ @Override
+ public void overrideServiceModel(String vspId, Version version, ToscaServiceModel serviceModel) {
+ SessionContext context = ZusammenUtil.createSessionContext();
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
+ Optional<ElementInfo> origServiceModel = getServiceModelElementInfo(context, elementContext);
+ if (!origServiceModel.isPresent()) {
+ return;
+ }
+ Id serviceModelElementId = origServiceModel.get().getId();
+ ZusammenElement serviceModelElement = buildServiceModelElement(serviceModel.getEntryDefinitionServiceTemplate());
+ serviceModelElement.setElementId(serviceModelElementId);
+ overrideServiceTemplates(serviceModelElementId, serviceModel, context, elementContext, serviceModelElement);
+ zusammenAdaptor.saveElement(context, elementContext, serviceModelElement, "Override service model");
}
- ZusammenElement templateElement = buildStructuralElement(ElementType.Templates, Action.UPDATE);
- templateElement.setElementId(elementInfo.get().getId());
- serviceModel.getServiceTemplates().forEach((templateName, serviceTemplate) -> templateElement.addSubElement(
- buildServiceTemplateElement(templateName, serviceTemplate,
- serviceModel.getEntryDefinitionServiceTemplate(), Action.UPDATE)));
- serviceModelElement.addSubElement(templateElement);
- }
-
- private Optional<ElementInfo> getServiceModelElementInfo(SessionContext context,
- ElementContext elementContext) {
- Collection<ElementInfo> vspModelSubs = zusammenAdaptor
- .listElementsByName(context, elementContext, null, ElementType.VspModel.name());
-
- return vspModelSubs.stream()
- .filter(elementInfo -> elementInfo.getInfo() != null
- && elementType.name().equals(elementInfo.getInfo().getName()))
- .findFirst();
- }
- private Map<String, ServiceTemplate> getTemplates(SessionContext context,
- ElementContext elementContext,
- Id serviceModelElementId) {
- Optional<ElementInfo> templatesElementInfo = zusammenAdaptor.getElementInfoByName(
- context, elementContext, serviceModelElementId, ElementType.Templates.name());
-
- if (templatesElementInfo.isPresent()) {
- Collection<Element> elements = zusammenAdaptor.listElementData(context, elementContext,
- templatesElementInfo.get().getId());
-
- return elements.stream().collect(Collectors.toMap(
- element -> element.getInfo().getName(),
- this::elementToServiceTemplate));
+ private void overrideServiceTemplates(Id serviceModelElementId, ToscaServiceModel serviceModel, SessionContext context,
+ ElementContext elementContext, ZusammenElement serviceModelElement) {
+ Optional<ElementInfo> elementInfo = zusammenAdaptor
+ .getElementInfoByName(context, elementContext, serviceModelElementId, ElementType.Templates.name());
+ if (!elementInfo.isPresent()) {
+ return;
+ }
+ ZusammenElement templateElement = buildStructuralElement(ElementType.Templates, Action.UPDATE);
+ templateElement.setElementId(elementInfo.get().getId());
+ serviceModel.getServiceTemplates().forEach((templateName, serviceTemplate) -> templateElement.addSubElement(
+ buildServiceTemplateElement(templateName, serviceTemplate, serviceModel.getEntryDefinitionServiceTemplate(), Action.UPDATE)));
+ serviceModelElement.addSubElement(templateElement);
}
- return null;
- }
-
- private FileContentHandler getArtifacts(SessionContext context, ElementContext elementContext,
- Id serviceModelElementId) {
- Optional<ElementInfo> artifactsElement = zusammenAdaptor.getElementInfoByName(
- context, elementContext, serviceModelElementId, ElementType.Artifacts.name());
- if (artifactsElement.isPresent()) {
-
- Collection<Element> elements = zusammenAdaptor.listElementData(context, elementContext,
- artifactsElement.get().getId());
- FileContentHandler fileContentHandler = new FileContentHandler();
- elements.forEach(element -> fileContentHandler.addFile(element.getInfo().getName(),
- element.getData()));
- return fileContentHandler;
+ private Optional<ElementInfo> getServiceModelElementInfo(SessionContext context, ElementContext elementContext) {
+ Collection<ElementInfo> vspModelSubs = zusammenAdaptor.listElementsByName(context, elementContext, null, ElementType.VspModel.name());
+ return vspModelSubs.stream()
+ .filter(elementInfo -> elementInfo.getInfo() != null && elementType.name().equals(elementInfo.getInfo().getName())).findFirst();
}
- return null;
- }
-
- private ZusammenElement buildServiceModelElement(String entryDefinitionServiceTemplate) {
- ZusammenElement serviceModelElement = buildStructuralElement(elementType, Action.UPDATE);
- serviceModelElement.getInfo().addProperty(BASE_PROPERTY, entryDefinitionServiceTemplate);
- return serviceModelElement;
- }
+ private Map<String, ServiceTemplate> getTemplates(SessionContext context, ElementContext elementContext, Id serviceModelElementId) {
+ Optional<ElementInfo> templatesElementInfo = zusammenAdaptor
+ .getElementInfoByName(context, elementContext, serviceModelElementId, ElementType.Templates.name());
+ if (templatesElementInfo.isPresent()) {
+ Collection<Element> elements = zusammenAdaptor.listElementData(context, elementContext, templatesElementInfo.get().getId());
+ return elements.stream().collect(Collectors.toMap(element -> element.getInfo().getName(), this::elementToServiceTemplate));
+ }
+ return null;
+ }
- private Element buildServiceTemplateElement(String name, ServiceTemplate serviceTemplate,
- String entryDefinitionServiceTemplate,
- Action action) {
- ZusammenElement zusammenElement = buildElement(null, action);
- Info info = new Info();
- info.setName(name);
- info.setDescription(serviceTemplate.getDescription());
- info.addProperty(ElementPropertyName.elementType.name(), ElementType.ServiceTemplate.name());
- info.addProperty(BASE_PROPERTY, entryDefinitionServiceTemplate);
- String yaml = new ToscaExtensionYamlUtil().objectToYaml(serviceTemplate);
- zusammenElement.setData(new ByteArrayInputStream(yaml.getBytes()));
- zusammenElement.setInfo(info);
- return zusammenElement;
- }
+ private FileContentHandler getArtifacts(SessionContext context, ElementContext elementContext, Id serviceModelElementId) {
+ Optional<ElementInfo> artifactsElement = zusammenAdaptor
+ .getElementInfoByName(context, elementContext, serviceModelElementId, ElementType.Artifacts.name());
+ if (artifactsElement.isPresent()) {
+ Collection<Element> elements = zusammenAdaptor.listElementData(context, elementContext, artifactsElement.get().getId());
+ FileContentHandler fileContentHandler = new FileContentHandler();
+ elements.forEach(element -> fileContentHandler.addFile(element.getInfo().getName(), element.getData()));
+ return fileContentHandler;
+ }
+ return null;
+ }
- protected ZusammenElement buildArtifactElement(String name, byte[] artifact, Action action) {
- ZusammenElement artifactElement = buildElement(null, action);
- Info info = new Info();
- info.setName(name);
- info.addProperty(ElementPropertyName.elementType.name(), ElementType.Artifact.name());
- artifactElement.setInfo(info);
- artifactElement.setData(new ByteArrayInputStream(artifact));
+ private ZusammenElement buildServiceModelElement(String entryDefinitionServiceTemplate) {
+ ZusammenElement serviceModelElement = buildStructuralElement(elementType, Action.UPDATE);
+ serviceModelElement.getInfo().addProperty(BASE_PROPERTY, entryDefinitionServiceTemplate);
+ return serviceModelElement;
+ }
- return artifactElement;
- }
+ private Element buildServiceTemplateElement(String name, ServiceTemplate serviceTemplate, String entryDefinitionServiceTemplate, Action action) {
+ ZusammenElement zusammenElement = buildElement(null, action);
+ Info info = new Info();
+ info.setName(name);
+ info.setDescription(serviceTemplate.getDescription());
+ info.addProperty(ElementPropertyName.elementType.name(), ElementType.ServiceTemplate.name());
+ info.addProperty(BASE_PROPERTY, entryDefinitionServiceTemplate);
+ String yaml = new ToscaExtensionYamlUtil().objectToYaml(serviceTemplate);
+ zusammenElement.setData(new ByteArrayInputStream(yaml.getBytes()));
+ zusammenElement.setInfo(info);
+ return zusammenElement;
+ }
+ protected ZusammenElement buildArtifactElement(String name, byte[] artifact, Action action) {
+ ZusammenElement artifactElement = buildElement(null, action);
+ Info info = new Info();
+ info.setName(name);
+ info.addProperty(ElementPropertyName.elementType.name(), ElementType.Artifact.name());
+ artifactElement.setInfo(info);
+ artifactElement.setData(new ByteArrayInputStream(artifact));
+ return artifactElement;
+ }
- private ServiceTemplate elementToServiceTemplate(Element element) {
- try {
- String yamlContent = IOUtils.toString(element.getData());
- return new ToscaExtensionYamlUtil().
- yamlToObject(yamlContent, ServiceTemplate.class);
- } catch (Exception e) {
- throw new CoreException(
- new RetrieveServiceTemplateFromDbErrorBuilder(
- element.getInfo().getName(), e.getMessage()).build());
+ private ServiceTemplate elementToServiceTemplate(Element element) {
+ try {
+ String yamlContent = IOUtils.toString(element.getData());
+ return new ToscaExtensionYamlUtil().yamlToObject(yamlContent, ServiceTemplate.class);
+ } catch (Exception e) {
+ throw new CoreException(new RetrieveServiceTemplateFromDbErrorBuilder(element.getInfo().getName(), e.getMessage()).build());
+ }
}
- }
}
diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/StructureElement.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/StructureElement.java
index a0bbdfce8d..b894db9b93 100644
--- a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/StructureElement.java
+++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/StructureElement.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,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.model.impl.zusammen;
-public enum StructureElement {
- ServiceModel,
- EnrichedServiceModel,
- Artifacts,
- Templates,
- EntryDefinition,
-
-}
+public enum StructureElement {ServiceModel, EnrichedServiceModel, Artifacts, Templates, EntryDefinition,}