mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +00:00
Add the PreAuthorize attribute to getAccessStatus
This commit is contained in:
@@ -23,6 +23,7 @@ import org.dspace.core.Context;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.rest.webmvc.ResourceNotFoundException;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
@@ -38,6 +39,7 @@ public class ItemAccessStatusLinkRepository extends AbstractDSpaceRestRepository
|
||||
@Autowired
|
||||
AccessStatusService accessStatusService;
|
||||
|
||||
@PreAuthorize("hasPermission(#itemId, 'ITEM', 'READ')")
|
||||
public AccessStatusRest getAccessStatus(@Nullable HttpServletRequest request,
|
||||
UUID itemId,
|
||||
@Nullable Pageable optionalPageable,
|
||||
|
@@ -3887,7 +3887,7 @@ public class ItemRestRepositoryIT extends AbstractControllerIntegrationTest {
|
||||
getClient(tokenEperson).perform(get("/api/core/items/" + item.getID())
|
||||
.param("projection", "full"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$", HalMatcher.matchEmbeds("accessStatus")))
|
||||
.andExpect(jsonPath("$", HalMatcher.matchNoEmbeds()))
|
||||
.andExpect(jsonPath("$.uuid", Matchers.is(item.getID().toString())))
|
||||
.andExpect(jsonPath("$.name", Matchers.is(item.getName())))
|
||||
.andExpect(jsonPath("$.handle", Matchers.is(item.getHandle())))
|
||||
@@ -3920,7 +3920,7 @@ public class ItemRestRepositoryIT extends AbstractControllerIntegrationTest {
|
||||
getClient().perform(get("/api/core/items/" + item.getID())
|
||||
.param("projection", "full"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$", HalMatcher.matchEmbeds("accessStatus")))
|
||||
.andExpect(jsonPath("$", HalMatcher.matchNoEmbeds()))
|
||||
.andExpect(jsonPath("$.uuid", Matchers.is(item.getID().toString())))
|
||||
.andExpect(jsonPath("$.name", Matchers.is(item.getName())))
|
||||
.andExpect(jsonPath("$.handle", Matchers.is(item.getHandle())))
|
||||
|
Reference in New Issue
Block a user