aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src
diff options
context:
space:
mode:
authorayalaben <ayala.benzvi@amdocs.com>2018-03-15 15:59:25 +0200
committerayalaben <ayala.benzvi@amdocs.com>2018-03-19 10:45:48 +0200
commit705fc2b672d5802696074be94b446a89d228b94d (patch)
tree135b0d30b36eaf0180314d68531186648ac29882 /openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src
parent3c24190cca30ee77c8c81d1738d7d5cbf454d647 (diff)
Archive Item
Change-Id: Idd5eedc3b0ca9e3cc72f7de9fd432cdbbf77631d Issue-ID: SDC-1086 Signed-off-by: ayalaben <ayala.benzvi@amdocs.com>
Diffstat (limited to 'openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src')
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/VendorSoftwareProducts.java14
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapItemToVspDetailsDto.java1
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VendorSoftwareProductsImpl.java120
3 files changed, 87 insertions, 48 deletions
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/VendorSoftwareProducts.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/VendorSoftwareProducts.java
index 60c68ef302..996b389829 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/VendorSoftwareProducts.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/VendorSoftwareProducts.java
@@ -69,10 +69,13 @@ public interface VendorSoftwareProducts extends VspEntities {
@Path("/")
@ApiOperation(value = "Get list of vendor software products and their description",
responseContainer = "List")
- Response listVsps(@ApiParam(
- value = "Currently supported values: 'Certified' - only vendor software products with final "
- + " version will be return - with their latest final version")
+ Response listVsps(@ApiParam(value = "Filter to return only Vendor Software Products with at" +
+ " least one version at this status. Currently supported values: 'Certified' , 'Draft'")
@QueryParam("versionFilter") String versionStatus,
+ @ApiParam(value = "Filter to only return Vendor Software Products at this status." +
+ "Currently supported values: 'ACTIVE' , 'ARCHIVED'." +
+ "Default value = 'ACTIVE'.")
+ @QueryParam("Status") String itemStatus,
@NotNull(message = USER_MISSING_ERROR_MSG)
@HeaderParam(USER_ID_HEADER_PARAM) String user);
@@ -105,7 +108,10 @@ public interface VendorSoftwareProducts extends VspEntities {
@ApiOperation(value = "Get list of translated CSAR files details",
response = PackageInfoDto.class,
responseContainer = "List")
- Response listPackages(@ApiParam("Category") @QueryParam("category") String category,
+ Response listPackages(@ApiParam("Vendor Software Product status filter. " +
+ "Currently supported values: 'ACTIVE', 'ARCHIVED'")
+ @QueryParam("Status") String status,
+ @ApiParam("Category") @QueryParam("category") String category,
@ApiParam("Sub-category") @QueryParam("subCategory") String subCategory,
@NotNull(message = USER_MISSING_ERROR_MSG)
@HeaderParam(USER_ID_HEADER_PARAM) String user);
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapItemToVspDetailsDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapItemToVspDetailsDto.java
index caa05391c8..93ee1590f0 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapItemToVspDetailsDto.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapItemToVspDetailsDto.java
@@ -15,5 +15,6 @@ public class MapItemToVspDetailsDto extends MappingBase<Item, VspDetailsDto> {
target.setVendorName((String) source.getProperties().get(VspItemProperty.VENDOR_NAME));
target.setOnboardingMethod((String) source.getProperties().get(VspItemProperty.ONBOARDING_METHOD));
target.setOwner(source.getOwner());
+ target.setStatus(source.getStatus().name());
}
}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VendorSoftwareProductsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VendorSoftwareProductsImpl.java
index be196bf326..37804ff865 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VendorSoftwareProductsImpl.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VendorSoftwareProductsImpl.java
@@ -16,6 +16,29 @@
package org.openecomp.sdcrests.vsp.rest.services;
+import static javax.ws.rs.core.HttpHeaders.CONTENT_DISPOSITION;
+import static org.openecomp.sdc.itempermissions.notifications.NotificationConstants.PERMISSION_USER;
+import static org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants.UniqueValues.VENDOR_SOFTWARE_PRODUCT_NAME;
+import static org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants.VALIDATION_VSP_NAME;
+import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.ITEM_ID;
+import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.ITEM_NAME;
+import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.SUBMIT_DESCRIPTION;
+import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.VERSION_ID;
+import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.VERSION_NAME;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.function.Predicate;
+import java.util.stream.Collectors;
+import javax.inject.Named;
+import javax.ws.rs.core.Response;
import org.apache.commons.collections4.MapUtils;
import org.openecomp.core.dao.UniqueValueDaoFactory;
import org.openecomp.core.util.UniqueValueUtil;
@@ -62,6 +85,7 @@ import org.openecomp.sdc.versioning.types.Item;
import org.openecomp.sdc.versioning.types.NotificationEventTypes;
import org.openecomp.sdcrests.item.rest.mapping.MapVersionToDto;
import org.openecomp.sdcrests.item.types.ItemCreationDto;
+import org.openecomp.sdc.versioning.types.ItemStatus;
import org.openecomp.sdcrests.item.types.VersionDto;
import org.openecomp.sdcrests.vendorsoftwareproducts.types.PackageInfoDto;
import org.openecomp.sdcrests.vendorsoftwareproducts.types.QuestionnaireResponseDto;
@@ -85,29 +109,6 @@ import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
-import javax.inject.Named;
-import javax.ws.rs.core.Response;
-import java.io.File;
-import java.io.IOException;
-import java.util.Collection;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.function.Predicate;
-
-import static javax.ws.rs.core.HttpHeaders.CONTENT_DISPOSITION;
-import static org.openecomp.sdc.itempermissions.notifications.NotificationConstants.PERMISSION_USER;
-import static org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants.UniqueValues.VENDOR_SOFTWARE_PRODUCT_NAME;
-import static org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants.VALIDATION_VSP_NAME;
-import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.ITEM_ID;
-import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.ITEM_NAME;
-import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.SUBMIT_DESCRIPTION;
-import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.VERSION_ID;
-import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.VERSION_NAME;
-
@Named
@Service("vendorSoftwareProducts")
@Scope(value = "prototype")
@@ -166,6 +167,7 @@ public class VendorSoftwareProductsImpl implements VendorSoftwareProducts {
Item item = new MapVspDescriptionDtoToItem().applyMapping(vspRequestDto, Item.class);
item.setType(ItemType.vsp.name());
item.setOwner(user);
+ item.setStatus(ItemStatus.ACTIVE);
item.addProperty(VspItemProperty.ONBOARDING_METHOD, onboardingMethod.name());
uniqueValueUtil.validateUniqueValue(VENDOR_SOFTWARE_PRODUCT_NAME, item.getName());
@@ -197,27 +199,14 @@ public class VendorSoftwareProductsImpl implements VendorSoftwareProducts {
throw new CoreException(onboardingMethodUpdateErrorCode, e);
}
- @Override
- public Response listVsps(String versionStatus, String user) {
- Predicate<Item> itemPredicate;
- if (VersionStatus.Certified.name().equals(versionStatus)) {
- itemPredicate = item -> ItemType.vsp.name().equals(item.getType())
- && item.getVersionStatusCounters().containsKey(VersionStatus.Certified);
-
- } else if (VersionStatus.Draft.name().equals(versionStatus)) {
- itemPredicate = item -> ItemType.vsp.name().equals(item.getType())
- && item.getVersionStatusCounters().containsKey(VersionStatus.Draft)
- && userHasPermission(item.getId(), user);
+ @Override
+ public Response listVsps(String versionStatus, String itemStatus, String user) {
- } else {
- itemPredicate = item -> ItemType.vsp.name().equals(item.getType());
- }
+ GenericCollectionWrapper<VspDetailsDto> results = new GenericCollectionWrapper<>();
+ MapItemToVspDetailsDto mapper = new MapItemToVspDetailsDto();
- GenericCollectionWrapper<VspDetailsDto> results = new GenericCollectionWrapper<>();
- MapItemToVspDetailsDto mapper = new MapItemToVspDetailsDto();
- itemManager.list(itemPredicate).stream()
- .sorted((o1, o2) -> o2.getModificationTime().compareTo(o1.getModificationTime()))
- .forEach(vspItem -> results.add(mapper.applyMapping(vspItem, VspDetailsDto.class)));
+ getVspList(versionStatus,itemStatus,user)
+ .forEach(vspItem -> results.add(mapper.applyMapping(vspItem, VspDetailsDto.class)));
return Response.ok(results).build();
}
@@ -299,7 +288,7 @@ public class VendorSoftwareProductsImpl implements VendorSoftwareProducts {
itemManager.delete(vsp);
permissionsManager.deleteItemPermissions(vspId);
uniqueValueUtil.deleteUniqueValue(VENDOR_SOFTWARE_PRODUCT_NAME, vsp.getName());
- notifyUsers(vspId, vsp.getName(), null, "VSP was deleted", user,
+ notifyUsers(vspId, vsp.getName(), null, null, user,
NotificationEventTypes.DELETE);
return Response.ok().build();
@@ -386,10 +375,19 @@ public class VendorSoftwareProductsImpl implements VendorSoftwareProducts {
}
@Override
- public Response listPackages(String category, String subCategory, String user) {
+ public Response listPackages(String status, String category, String subCategory, String user) {
+
+ List<String> VspsIds =
+ getVspList(null, status != null ? ItemStatus.valueOf(status).name(): null, user)
+ .stream().map(Item::getId).collect(Collectors.toList());
+
List<PackageInfo> packageInfoList =
vendorSoftwareProductManager.listPackages(category, subCategory);
+ packageInfoList = packageInfoList.stream().
+ filter(packageInfo -> VspsIds.contains(packageInfo.getVspId()))
+ .collect(Collectors.toList());
+
GenericCollectionWrapper<PackageInfoDto> results = new GenericCollectionWrapper<>();
MapPackageInfoToPackageInfoDto mapper = new MapPackageInfoToPackageInfoDto();
@@ -611,4 +609,38 @@ public class VendorSoftwareProductsImpl implements VendorSoftwareProducts {
return permission != null && permission
.matches(PermissionTypes.Contributor.name() + "|" + PermissionTypes.Owner.name());
}
+
+
+ private Predicate<Item> createItemPredicate(String versionStatus,
+ String itemStatus,
+ String user) {
+ Predicate<Item> itemPredicate = item -> ItemType.vsp.name().equals(item.getType());
+
+ if (ItemStatus.ARCHIVED.name().equals(itemStatus)) {
+ itemPredicate = itemPredicate.and(item -> ItemStatus.ARCHIVED.equals(item.getStatus()));
+ } else {
+ itemPredicate = itemPredicate.and(item -> ItemStatus.ACTIVE.equals(item.getStatus()));
+
+ if (VersionStatus.Certified.name().equals(versionStatus)) {
+ itemPredicate = itemPredicate
+ .and(item -> item.getVersionStatusCounters().containsKey(VersionStatus.Certified));
+
+ } else if (VersionStatus.Draft.name().equals(versionStatus)) {
+ itemPredicate = itemPredicate.and(
+ item -> item.getVersionStatusCounters().containsKey(VersionStatus.Draft)
+ && userHasPermission(item.getId(), user));
+ }
+ }
+ return itemPredicate;
+ }
+
+ private List<Item> getVspList(String versionStatus, String itemStatus, String user) {
+
+ Predicate<Item> itemPredicate = createItemPredicate(versionStatus, itemStatus, user);
+
+ return itemManager.list(itemPredicate).stream()
+ .sorted((o1, o2) -> o2.getModificationTime().compareTo(o1.getModificationTime())).
+ collect(Collectors.toList());
+
+ }
}