mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +00:00
Merge pull request #8310 from atmire/w2p-91356_detached-bitstream-moved-to-new-bundle-remains-deleted_upstream-latest
When a bitstream is removed from one bundle and added to another, the bitstream should NOT be marked as deleted
This commit is contained in:
@@ -158,6 +158,11 @@ public class BundleServiceImpl extends DSpaceObjectServiceImpl<Bundle> implement
|
||||
}
|
||||
|
||||
bundle.addBitstream(bitstream);
|
||||
// If a bitstream is moved from one bundle to another it may be temporarily flagged as deleted
|
||||
// (when removed from the original bundle)
|
||||
if (bitstream.isDeleted()) {
|
||||
bitstream.setDeleted(false);
|
||||
}
|
||||
bitstream.getBundles().add(bundle);
|
||||
|
||||
|
||||
|
@@ -7,6 +7,8 @@
|
||||
*/
|
||||
package org.dspace.app.rest;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.springframework.data.rest.webmvc.RestMediaTypes.TEXT_URI_LIST_VALUE;
|
||||
import static org.springframework.http.MediaType.parseMediaType;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
@@ -576,6 +578,7 @@ public class BitstreamControllerIT extends AbstractControllerIntegrationTest {
|
||||
.build();
|
||||
}
|
||||
|
||||
// NOTE: this will set deleted = true for the bitstream
|
||||
bundleService.removeBitstream(context, bundle1, bitstream);
|
||||
bundleService.update(context, bundle1);
|
||||
bitstreamService.update(context, bitstream);
|
||||
@@ -615,6 +618,10 @@ public class BitstreamControllerIT extends AbstractControllerIntegrationTest {
|
||||
context.restoreAuthSystemState();
|
||||
String token = getAuthToken(putBundlePerson.getEmail(), "test");
|
||||
|
||||
// at this moment the bitstream is still marked as deleted because it is not attached to any bundle
|
||||
assertTrue(bitstream.isDeleted());
|
||||
|
||||
// add the bitstream to target bundle
|
||||
getClient(token)
|
||||
.perform(put("/api/core/bitstreams/" + bitstream.getID() + "/bundle")
|
||||
.contentType(parseMediaType(TEXT_URI_LIST_VALUE))
|
||||
@@ -622,6 +629,9 @@ public class BitstreamControllerIT extends AbstractControllerIntegrationTest {
|
||||
"https://localhost:8080/spring-rest/api/core/bundles/" + targetBundle.getID()
|
||||
)).andExpect(status().isOk());
|
||||
|
||||
// at this moment the bitstream should NOT be marked as deleted, because it has been attached to target bundle
|
||||
assertFalse(context.reloadEntity(bitstream).isDeleted());
|
||||
|
||||
targetBundle = bundleService.find(context, targetBundle.getID());
|
||||
String name = targetBundle.getName();
|
||||
String handle = targetBundle.getHandle();
|
||||
|
Reference in New Issue
Block a user