aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be')
-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.java27
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/services/VendorSoftwareProductsImplTest.java6
-rw-r--r--openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/PermissionsManagerImpl.java7
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VendorSoftwareProductManager.java2
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java5
5 files changed, 43 insertions, 4 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/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 6431db3354..b424db9b42 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
@@ -27,12 +27,16 @@ import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.VERS
import java.io.File;
import java.io.IOException;
+import java.nio.ByteBuffer;
import java.util.Collection;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
+import java.util.ArrayList;
import java.util.Map;
+import java.util.Set;
import java.util.Objects;
import java.util.Optional;
import java.util.function.Predicate;
@@ -370,13 +374,36 @@ public class VendorSoftwareProductsImpl implements VendorSoftwareProducts {
}
private void deleteVsp(final String vspId, final String user, final Item vsp) {
+ updatePackageDetails(vspId);
versioningManager.list(vspId).forEach(version -> vendorSoftwareProductManager.deleteVsp(vspId, version));
itemManager.delete(vsp);
+ deleteUserPermissions(vspId);
permissionsManager.deleteItemPermissions(vspId);
uniqueValueUtil.deleteUniqueValue(VENDOR_SOFTWARE_PRODUCT_NAME, vsp.getName());
notifyUsers(vspId, vsp.getName(), null, null, user, NotificationEventTypes.DELETE);
}
+ private void updatePackageDetails(final String vspId) {
+ final List<VspDetails> listVsp = new ArrayList<>();
+ versioningManager.list(vspId).forEach(version -> listVsp.add(vendorSoftwareProductManager.getVsp(vspId, version)));
+ listVsp.forEach(vspDetail ->
+ vendorSoftwareProductManager.listPackages(vspDetail.getCategory(), vspDetail.getSubCategory())
+ .stream().filter(packageInfo -> packageInfo.getVspId().equals(vspId)).collect(Collectors.toList())
+ .forEach(packInfo -> {
+ packInfo.setTranslatedFile(ByteBuffer.wrap(new byte[0]));
+ vendorSoftwareProductManager.updatePackage(packInfo);
+ })
+ );
+ }
+
+ private void deleteUserPermissions(String vspId) {
+ permissionsManager.listItemPermissions(vspId).forEach(itemPermissionsEntity -> {
+ Set<String> usersToDelete = new HashSet<>();
+ usersToDelete.add(itemPermissionsEntity.getUserId());
+ permissionsManager.updateItemPermissions(vspId, itemPermissionsEntity.getPermission(), new HashSet<>(), usersToDelete);
+ });
+ }
+
@Override
public Response actOnVendorSoftwareProduct(VersionSoftwareProductActionRequestDto request, String vspId, String versionId, String user)
throws IOException {
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/services/VendorSoftwareProductsImplTest.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/services/VendorSoftwareProductsImplTest.java
index 76e4910a66..9653012789 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/services/VendorSoftwareProductsImplTest.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/services/VendorSoftwareProductsImplTest.java
@@ -63,6 +63,7 @@ import org.openecomp.sdc.datatypes.model.ItemType;
import org.openecomp.sdc.itempermissions.PermissionsManager;
import org.openecomp.sdc.notification.services.NotificationPropagationManager;
import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductManager;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
import org.openecomp.sdc.versioning.AsdcItemManager;
import org.openecomp.sdc.versioning.VersioningManager;
import org.openecomp.sdc.versioning.dao.types.Version;
@@ -199,7 +200,10 @@ class VendorSoftwareProductsImplTest {
final Version version2 = new Version("version2Id");
final List<Version> versionList = List.of(version1, version2);
when(versioningManager.list(vspId)).thenReturn(versionList);
-
+ VspDetails vspDetails = new VspDetails();
+ vspDetails.setCategory("cat");
+ vspDetails.setSubCategory("sub");
+ when(vendorSoftwareProductManager.getVsp(vspId, version1)).thenReturn(vspDetails);
when(itemManager.list(any())).thenReturn(List.of(item));
Response rsp = vendorSoftwareProducts.deleteVsp(vspId, user);
assertEquals(HttpStatus.SC_OK, rsp.getStatus());
diff --git a/openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/PermissionsManagerImpl.java b/openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/PermissionsManagerImpl.java
index 68edb21fd8..d25ea53dc2 100644
--- a/openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/PermissionsManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/PermissionsManagerImpl.java
@@ -82,7 +82,7 @@ public class PermissionsManagerImpl implements PermissionsManager {
new ErrorCode.ErrorCodeBuilder().withMessage(Messages.PERMISSIONS_ERROR.getErrorMessage()).withId(Messages.PERMISSIONS_ERROR.name())
.withCategory(ErrorCategory.SECURITY).build());
}
- if (permission.equals(PermissionTypes.Owner.name())) {
+ if (permission.equals(PermissionTypes.Owner.name()) && !addedUsersIds.isEmpty()) {
if (addedUsersIds.size() == 1) {
asdcItemManager.updateOwner(itemId, addedUsersIds.iterator().next());
} else {
@@ -96,12 +96,13 @@ public class PermissionsManagerImpl implements PermissionsManager {
private void sendNotifications(String itemId, String permission, Set<String> addedUsersIds, Set<String> removedUsersIds, String userName) {
Item item = asdcItemManager.get(itemId);
+ String itemName = null != item ? item.getName() : "";
addedUsersIds.forEach(affectedUser -> {
- notifyUser(userName, true, item.getName(), itemId, affectedUser, permission);
+ notifyUser(userName, true, itemName, itemId, affectedUser, permission);
subscriptionService.subscribe(affectedUser, itemId);
});
removedUsersIds.forEach(affectedUser -> {
- notifyUser(userName, false, item.getName(), itemId, affectedUser, permission);
+ notifyUser(userName, false, itemName, itemId, affectedUser, permission);
subscriptionService.unsubscribe(affectedUser, itemId);
});
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VendorSoftwareProductManager.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VendorSoftwareProductManager.java
index 6a92dbb209..5e59e795e6 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VendorSoftwareProductManager.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VendorSoftwareProductManager.java
@@ -58,6 +58,8 @@ public interface VendorSoftwareProductManager {
PackageInfo createPackage(String vspId, Version version) throws IOException;
+ void updatePackage(PackageInfo packageInfo);
+
List<PackageInfo> listPackages(String category, String subCategory);
File getTranslatedFile(String vspId, Version version);
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java
index bf173a28be..234ee43f05 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java
@@ -539,6 +539,11 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
}
@Override
+ public void updatePackage(PackageInfo packageInfo) {
+ packageInfoDao.update(packageInfo);
+ }
+
+ @Override
public PackageInfo createPackage(final String vspId, final Version version) throws IOException {
final ToscaServiceModel toscaServiceModel = enrichedServiceModelDao.getServiceModel(vspId, version);
final VspDetails vspDetails = vspInfoDao.get(new VspDetails(vspId, version));