diff --git a/remote-api/src/main/java/org/alfresco/rest/api/impl/ContentStorageInformationImpl.java b/remote-api/src/main/java/org/alfresco/rest/api/impl/ContentStorageInformationImpl.java index 976fd87148..4ea00fc49e 100644 --- a/remote-api/src/main/java/org/alfresco/rest/api/impl/ContentStorageInformationImpl.java +++ b/remote-api/src/main/java/org/alfresco/rest/api/impl/ContentStorageInformationImpl.java @@ -90,7 +90,9 @@ public class ContentStorageInformationImpl implements ContentStorageInformation { final NodeRef nodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, nodeId); final QName propQName = getQName(contentPropName); - return contentService.requestSendContentToArchive(nodeRef, propQName, archiveContentRequest.getArchiveParams()); + final Map archiveParams = + archiveContentRequest == null ? Collections.emptyMap() : archiveContentRequest.getArchiveParams(); + return contentService.requestSendContentToArchive(nodeRef, propQName, archiveParams); } /** @@ -102,18 +104,19 @@ public class ContentStorageInformationImpl implements ContentStorageInformation { final NodeRef nodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, nodeId); final QName propQName = getQName(contentPropName); - final Map restoreParams = restoreArchivedContentRequest.getRestorePriority() == null ? - Collections.emptyMap() : - Map.of(ContentRestoreParams.RESTORE_PRIORITY.name(), restoreArchivedContentRequest.getRestorePriority()); - try + final Map restoreParams = + (restoreArchivedContentRequest == null || 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) + } + catch (org.alfresco.service.cmr.repository.RestoreInProgressException e) { throw new RestoreInProgressException(e.getMsgId(), e); } - + } private QName getQName(final String contentPropName) diff --git a/remote-api/src/test/java/org/alfresco/rest/api/impl/ContentStorageInformationImplTest.java b/remote-api/src/test/java/org/alfresco/rest/api/impl/ContentStorageInformationImplTest.java index 554f2ee99b..7206b72d6a 100644 --- a/remote-api/src/test/java/org/alfresco/rest/api/impl/ContentStorageInformationImplTest.java +++ b/remote-api/src/test/java/org/alfresco/rest/api/impl/ContentStorageInformationImplTest.java @@ -118,6 +118,21 @@ public class ContentStorageInformationImplTest assertEquals(expectedResult, requestArchiveContent); } + @Test + public void shouldSucceedOnArchiveContentWhenNoRequestBody() + { + final NodeRef nodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, DUMMY_NODE_ID); + final Map archiveProps = Collections.emptyMap(); + final boolean expectedResult = true; + + when(contentService.requestSendContentToArchive(eq(nodeRef), any(QName.class), eq(archiveProps))).thenReturn(expectedResult); + when(namespaceService.getNamespaceURI(NamespaceService.CONTENT_MODEL_PREFIX)).thenReturn(NamespaceService.CONTENT_MODEL_1_0_URI); + + final boolean requestArchiveContent = objectUnderTest.requestArchiveContent(DUMMY_NODE_ID, CONTENT_PROP_NAME, null); + + assertEquals(expectedResult, requestArchiveContent); + } + @Test public void shouldNotSucceedOnArchiveContent() { @@ -167,6 +182,21 @@ public class ContentStorageInformationImplTest assertEquals(expectedResult, requestArchiveContent); } + @Test + public void shouldSucceedOnRestoreContentFromArchiveWhenNoRequestBody() + { + final NodeRef nodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, DUMMY_NODE_ID); + final boolean expectedResult = true; + + when(contentService.requestRestoreContentFromArchive(eq(nodeRef), any(QName.class), eq(Collections.emptyMap()))) + .thenReturn(expectedResult); + when(namespaceService.getNamespaceURI(NamespaceService.CONTENT_MODEL_PREFIX)).thenReturn(NamespaceService.CONTENT_MODEL_1_0_URI); + + final boolean requestArchiveContent = objectUnderTest.requestRestoreContentFromArchive(DUMMY_NODE_ID, CONTENT_PROP_NAME, null); + + assertEquals(expectedResult, requestArchiveContent); + } + @Test public void shouldNotSucceedOnRestoreContentFromArchive() { @@ -191,7 +221,6 @@ public class ContentStorageInformationImplTest final Map restoreParams = Map.of(ContentRestoreParams.RESTORE_PRIORITY.name(), STANDARD_PRIORITY); final RestoreArchivedContentRequest restoreArchivedContentRequest = new RestoreArchivedContentRequest(); restoreArchivedContentRequest.setRestorePriority(STANDARD_PRIORITY); - final boolean expectedResult = false; when(contentService.requestRestoreContentFromArchive(eq(nodeRef), any(QName.class), eq(restoreParams))).thenCallRealMethod(); when(namespaceService.getNamespaceURI(NamespaceService.CONTENT_MODEL_PREFIX)).thenReturn(NamespaceService.CONTENT_MODEL_1_0_URI);