mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
ACS-2331 handle RestoreInProgressException (#839)
This commit is contained in:
@@ -31,6 +31,7 @@ import org.alfresco.rest.api.ContentStorageInformation;
|
|||||||
import org.alfresco.rest.api.model.ArchiveContentRequest;
|
import org.alfresco.rest.api.model.ArchiveContentRequest;
|
||||||
import org.alfresco.rest.api.model.ContentStorageInfo;
|
import org.alfresco.rest.api.model.ContentStorageInfo;
|
||||||
import org.alfresco.rest.api.model.RestoreArchivedContentRequest;
|
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.rest.framework.resource.parameters.Parameters;
|
||||||
import org.alfresco.service.Experimental;
|
import org.alfresco.service.Experimental;
|
||||||
import org.alfresco.service.cmr.repository.ContentService;
|
import org.alfresco.service.cmr.repository.ContentService;
|
||||||
@@ -104,8 +105,16 @@ public class ContentStorageInformationImpl implements ContentStorageInformation
|
|||||||
final Map<String, Serializable> restoreParams = restoreArchivedContentRequest.getRestorePriority() == null ?
|
final Map<String, Serializable> restoreParams = restoreArchivedContentRequest.getRestorePriority() == null ?
|
||||||
Collections.emptyMap() :
|
Collections.emptyMap() :
|
||||||
Map.of(ContentRestoreParams.RESTORE_PRIORITY.name(), restoreArchivedContentRequest.getRestorePriority());
|
Map.of(ContentRestoreParams.RESTORE_PRIORITY.name(), restoreArchivedContentRequest.getRestorePriority());
|
||||||
|
try
|
||||||
|
{
|
||||||
return contentService.requestRestoreContentFromArchive(nodeRef, propQName, restoreParams);
|
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)
|
private QName getQName(final String contentPropName)
|
||||||
{
|
{
|
||||||
|
@@ -30,6 +30,7 @@ import org.alfresco.repo.content.ContentRestoreParams;
|
|||||||
import org.alfresco.rest.api.model.ArchiveContentRequest;
|
import org.alfresco.rest.api.model.ArchiveContentRequest;
|
||||||
import org.alfresco.rest.api.model.ContentStorageInfo;
|
import org.alfresco.rest.api.model.ContentStorageInfo;
|
||||||
import org.alfresco.rest.api.model.RestoreArchivedContentRequest;
|
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.ContentService;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.repository.StoreRef;
|
import org.alfresco.service.cmr.repository.StoreRef;
|
||||||
@@ -198,4 +199,19 @@ public class ContentStorageInformationImplTest
|
|||||||
assertThrows(UnsupportedOperationException.class,
|
assertThrows(UnsupportedOperationException.class,
|
||||||
() -> objectUnderTest.requestRestoreContentFromArchive(DUMMY_NODE_ID, CONTENT_PROP_NAME, restoreArchivedContentRequest));
|
() -> 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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user