mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-17 15:03:18 +00:00
Fixed the 500 internal server error when calling item delete endpoint with invalid UUID
This commit is contained in:
@@ -181,6 +181,10 @@ public class ItemRestRepository extends DSpaceRestRepository<ItemRest, UUID> {
|
||||
Item item = null;
|
||||
try {
|
||||
item = is.find(context, id);
|
||||
if (item == null) {
|
||||
throw new ResourceNotFoundException(ItemRest.CATEGORY + "." + ItemRest.NAME +
|
||||
" with id: " + id + " not found");
|
||||
}
|
||||
if (is.isInProgressSubmission(context, item)) {
|
||||
throw new UnprocessableEntityException("The item cannot be deleted. "
|
||||
+ "It's part of a in-progress submission.");
|
||||
|
@@ -1696,4 +1696,33 @@ public class ItemRestRepositoryIT extends AbstractControllerIntegrationTest {
|
||||
.andExpect(status().isOk());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void deleteOneWrongUuidResourceNotFoundTest() throws Exception {
|
||||
context.turnOffAuthorisationSystem();
|
||||
|
||||
//** GIVEN **
|
||||
//1. A community with one collection.
|
||||
parentCommunity = CommunityBuilder.createCommunity(context)
|
||||
.withName("Parent Community")
|
||||
.build();
|
||||
Collection col1 = CollectionBuilder
|
||||
.createCollection(context, parentCommunity).withName("Collection 1").build();
|
||||
|
||||
//2. One public item, one workspace item and one template item.
|
||||
Item publicItem = ItemBuilder.createItem(context, col1)
|
||||
.withTitle("Public item 1")
|
||||
.withIssueDate("2017-10-17")
|
||||
.withAuthor("Smith, Donald").withAuthor("Doe, John")
|
||||
.withSubject("ExtraEntry")
|
||||
.build();
|
||||
|
||||
|
||||
String token = getAuthToken(admin.getEmail(), password);
|
||||
|
||||
//Delete public item
|
||||
getClient(token).perform(delete("/api/core/items/" + parentCommunity.getID()))
|
||||
.andExpect(status().is(404));
|
||||
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user