summaryrefslogtreecommitdiffstats
path: root/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main
diff options
context:
space:
mode:
authorvasraz <vasyl.razinkov@est.tech>2022-03-31 19:05:00 +0100
committerMichael Morris <michael.morris@est.tech>2022-04-04 14:06:04 +0000
commitf2e43fb0a2c36b484b686d6c22342e72da66f679 (patch)
tree9570618007c9266729ebaa98e1626a56c7285917 /openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main
parent8c565b9d5396e86d431f51952b476007ff4fbe8e (diff)
Implement restore of partially deleted VSP
Change-Id: I790b6cd8494e8f35c3b9891304f15272e9769a68 Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech> Issue-ID: SDC-3935
Diffstat (limited to 'openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main')
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/ItemsImpl.java15
1 files changed, 14 insertions, 1 deletions
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/ItemsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/ItemsImpl.java
index f18de66863..c184eca3c1 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/ItemsImpl.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/ItemsImpl.java
@@ -15,6 +15,8 @@
*/
package org.openecomp.sdcrests.item.rest.services;
+import static javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR;
+import static javax.ws.rs.core.Response.Status.NOT_FOUND;
import static org.openecomp.sdc.itempermissions.notifications.NotificationConstants.PERMISSION_USER;
import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.ITEM_ID;
import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.ITEM_NAME;
@@ -36,6 +38,10 @@ import javax.inject.Named;
import javax.ws.rs.core.Response;
import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity;
import org.openecomp.sdc.activitylog.dao.type.ActivityType;
+import org.openecomp.sdc.be.csar.storage.ArtifactStorageManager;
+import org.openecomp.sdc.be.csar.storage.StorageFactory;
+import org.openecomp.sdc.common.errors.ErrorCode.ErrorCodeBuilder;
+import org.openecomp.sdc.common.errors.ErrorCodeAndMessage;
import org.openecomp.sdc.datatypes.model.ItemType;
import org.openecomp.sdc.itempermissions.impl.types.PermissionTypes;
import org.openecomp.sdc.logging.api.Logger;
@@ -80,13 +86,20 @@ public class ItemsImpl implements Items {
public Response actOn(ItemActionRequestDto request, String itemId, String user) {
Item item = getManagersProvider().getItemManager().get(itemId);
if (item == null) {
- return Response.status(Response.Status.NOT_FOUND).entity(new Exception("Item does not exist.")).build();
+ return Response.status(NOT_FOUND).entity(new Exception("Item does not exist.")).build();
}
switch (request.getAction()) {
case ARCHIVE:
getManagersProvider().getItemManager().archive(item);
break;
case RESTORE:
+ final var artifactStorageManager = new StorageFactory().createArtifactStorageManager();
+ if (artifactStorageManager.isEnabled() && !artifactStorageManager.exists(itemId)) {
+ LOGGER.error("Unable to restore partially deleted item '{}'", itemId);
+ final var errorCode =
+ new ErrorCodeBuilder().withId(INTERNAL_SERVER_ERROR.name()).withMessage("Unable to restore partially deleted VSP, re-try VSP deletion").build();
+ return Response.status(INTERNAL_SERVER_ERROR).entity(new ErrorCodeAndMessage(INTERNAL_SERVER_ERROR, errorCode)).build();
+ }
getManagersProvider().getItemManager().restore(item);
break;
default: