aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java28
1 files changed, 5 insertions, 23 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java
index 9f5436d152..c17af4d4de 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java
@@ -2513,32 +2513,14 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
}
private Service validateServiceNameAndVersion(String serviceName, String serviceVersion) {
- Either<List<Service>, StorageOperationStatus> serviceListBySystemName = toscaOperationFacade
- .getBySystemName(ComponentTypeEnum.SERVICE, serviceName);
- if (serviceListBySystemName.isRight()) {
+ final Either<Service, StorageOperationStatus> serviceBySystemNameAndVersion
+ = toscaOperationFacade.getBySystemNameAndVersion(ComponentTypeEnum.SERVICE, serviceName, serviceVersion);
+ if (serviceBySystemNameAndVersion.isRight()) {
log.debug("Couldn't fetch any service with name {}", serviceName);
throw new ByActionStatusComponentException(
- componentsUtils.convertFromStorageResponse(serviceListBySystemName.right().value(), ComponentTypeEnum.SERVICE), serviceName);
+ componentsUtils.convertFromStorageResponse(serviceBySystemNameAndVersion.right().value(), ComponentTypeEnum.SERVICE), serviceName);
}
- List<Service> serviceList = serviceListBySystemName.left().value();
- if (serviceList == null || serviceList.isEmpty()) {
- log.debug("Couldn't fetch any service with name {}", serviceName);
- throw new ByActionStatusComponentException(ActionStatus.SERVICE_NOT_FOUND, serviceName);
- }
- Service foundService = null;
- for (Service service : serviceList) {
- if (service.getVersion().equals(serviceVersion)) {
- log.trace("Found service with version {}", serviceVersion);
- foundService = service;
- break;
- }
- }
- if (foundService == null) {
- log.debug("Couldn't find version {} for service {}", serviceVersion, serviceName);
- throw new ByActionStatusComponentException(ActionStatus.COMPONENT_VERSION_NOT_FOUND, ComponentTypeEnum.SERVICE.getValue(),
- serviceVersion);
- }
- return foundService;
+ return serviceBySystemNameAndVersion.left().value();
}
private Resource validateResourceNameAndVersion(String resourceName, String resourceVersion) {