DeleteLinksStatusReport report = new DeleteLinksStatusReport(); report.addTotalLinksFoundCount(linkNodeIds.size()); report.addErrorDetail(linkNodeRef, new AccessDeniedException("User '" + AuthenticationUtil.getFullyAuthenticatedUser() + "' doesn't have permission to create discussion on node '" + linkNodeRef + "'")); report.incrementDeletedLinksCount(); if (report.getTotalLinksFoundCount() == report.getDeletedLinksCount())
/** * Tests the deletion of a document's links, with and without write * permissions * * @throws Exception */ public void testDeleteLinks() throws Exception { DeleteLinksStatusReport report = AuthenticationUtil.runAs(new RunAsWork<DeleteLinksStatusReport>() { @Override public DeleteLinksStatusReport doWork() throws Exception { return documentLinkService.deleteLinksToDocument(site1File2); } }, TEST_USER); // check if the service found 2 links of the document assertEquals(2, report.getTotalLinksFoundCount()); // check if the service successfully deleted one assertEquals(1, report.getDeletedLinksCount()); assertEquals(true, nodeService.hasAspect(site1File2, ApplicationModel.ASPECT_LINKED)); // check if the second one failed with access denied Throwable ex = report.getErrorDetails().get(linkOfFile1Site2); assertNotNull(ex); assertEquals(ex.getClass(), AccessDeniedException.class); }
DeleteLinksStatusReport report = new DeleteLinksStatusReport(); report.addTotalLinksFoundCount(linkNodeIds.size()); report.addErrorDetail(linkNodeRef, new AccessDeniedException("User '" + AuthenticationUtil.getFullyAuthenticatedUser() + "' doesn't have permission to create discussion on node '" + linkNodeRef + "'")); report.incrementDeletedLinksCount(); if (report.getTotalLinksFoundCount() == report.getDeletedLinksCount())