ACS-2331 handle RestoreInProgressException (#839)

This commit is contained in:
David Edwards
2021-12-10 16:41:07 +00:00
committed by GitHub
parent 3492f2fc2a
commit cd7e2a6e05
2 changed files with 26 additions and 1 deletions

View File

@@ -31,6 +31,7 @@ import org.alfresco.rest.api.ContentStorageInformation;
import org.alfresco.rest.api.model.ArchiveContentRequest;
import org.alfresco.rest.api.model.ContentStorageInfo;
import org.alfresco.rest.api.model.RestoreArchivedContentRequest;
import org.alfresco.rest.framework.core.exceptions.RestoreInProgressException;
import org.alfresco.rest.framework.resource.parameters.Parameters;
import org.alfresco.service.Experimental;
import org.alfresco.service.cmr.repository.ContentService;
@@ -104,8 +105,16 @@ public class ContentStorageInformationImpl implements ContentStorageInformation
final Map<String, Serializable> restoreParams = restoreArchivedContentRequest.getRestorePriority() == null ?
Collections.emptyMap() :
Map.of(ContentRestoreParams.RESTORE_PRIORITY.name(), restoreArchivedContentRequest.getRestorePriority());
try
{
return contentService.requestRestoreContentFromArchive(nodeRef, propQName, restoreParams);
}
catch (org.alfresco.service.cmr.repository.RestoreInProgressException e)
{
throw new RestoreInProgressException(e.getMsgId(), e);
}
}
private QName getQName(final String contentPropName)
{

View File

@@ -30,6 +30,7 @@ import org.alfresco.repo.content.ContentRestoreParams;
import org.alfresco.rest.api.model.ArchiveContentRequest;
import org.alfresco.rest.api.model.ContentStorageInfo;
import org.alfresco.rest.api.model.RestoreArchivedContentRequest;
import org.alfresco.rest.framework.core.exceptions.RestoreInProgressException;
import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.StoreRef;
@@ -198,4 +199,19 @@ public class ContentStorageInformationImplTest
assertThrows(UnsupportedOperationException.class,
() -> objectUnderTest.requestRestoreContentFromArchive(DUMMY_NODE_ID, CONTENT_PROP_NAME, restoreArchivedContentRequest));
}
@Test
public void shouldThrowRestoreInProgressExceptionRestoreContentFromArchive()
{
final NodeRef nodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, DUMMY_NODE_ID);
final Map<String, Serializable> restoreParams = Map.of(ContentRestoreParams.RESTORE_PRIORITY.name(), STANDARD_PRIORITY);
final RestoreArchivedContentRequest restoreArchivedContentRequest = new RestoreArchivedContentRequest();
restoreArchivedContentRequest.setRestorePriority(STANDARD_PRIORITY);
when(contentService.requestRestoreContentFromArchive(eq(nodeRef), any(QName.class), eq(restoreParams))).thenThrow(new org.alfresco.service.cmr.repository.RestoreInProgressException("Error"));
when(namespaceService.getNamespaceURI(NamespaceService.CONTENT_MODEL_PREFIX)).thenReturn(NamespaceService.CONTENT_MODEL_1_0_URI);
assertThrows(RestoreInProgressException.class,
() -> objectUnderTest.requestRestoreContentFromArchive(DUMMY_NODE_ID, CONTENT_PROP_NAME, restoreArchivedContentRequest));
}
}