DS-3127: Prevent database updates when directly manipulating the bistream list of a bundle

This commit is contained in:
Tom Desair
2017-06-28 17:46:58 +02:00
committed by Tim Donohue
parent 260f346a74
commit bcc6ebd894
4 changed files with 45 additions and 26 deletions

View File

@@ -198,7 +198,7 @@ public class BundleServiceImpl extends DSpaceObjectServiceImpl<Bundle> implement
// We don't need to remove the link between bundle & bitstream, this will be handled in the delete() method.
bitstreamService.delete(context, bitstream);
}else{
bundle.getBitstreams().remove(bitstream);
bundle.removeBitstream(bitstream);
bitstream.getBundles().remove(bundle);
}
}
@@ -304,13 +304,13 @@ public class BundleServiceImpl extends DSpaceObjectServiceImpl<Bundle> implement
if(CollectionUtils.isNotEmpty(updatedBitstreams) && !updatedBitstreams.equals(currentBitstreams))
{
//First clear out the existing list of bitstreams
bundle.getBitstreams().clear();
bundle.clearBitstreams();
// Now add them back in the proper order
for (Bitstream bitstream : updatedBitstreams)
{
bitstream.getBundles().remove(bundle);
bundle.getBitstreams().add(bitstream);
bundle.addBitstream(bitstream);
bitstream.getBundles().add(bundle);
bitstreamService.update(context, bitstream);
}
@@ -430,8 +430,8 @@ public class BundleServiceImpl extends DSpaceObjectServiceImpl<Bundle> implement
bundle.getName(), getIdentifiers(context, bundle)));
// Remove bitstreams
List<Bitstream> bitstreams = new LinkedList<>(bundle.getBitstreams());
bundle.getBitstreams().clear();
List<Bitstream> bitstreams = bundle.getBitstreams();
bundle.clearBitstreams();
for (Bitstream bitstream : bitstreams) {
removeBitstream(context, bundle, bitstream);
}