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

@@ -10,6 +10,7 @@ package org.dspace.content;
import java.sql.SQLException;
import java.util.*;
import org.apache.commons.collections.CollectionUtils;
import org.dspace.content.factory.ContentServiceFactory;
import org.dspace.content.service.BundleService;
import org.dspace.core.Constants;
@@ -130,18 +131,40 @@ public class Bundle extends DSpaceObject implements DSpaceObjectLegacySupport
}
/**
* Get the bitstreams in this bundle
* Get a copy of the bitstream list of this bundle
* Note that this is a copy and if you wish to manipulate the bistream list, you should use
* {@ref Bundle.addBitstream}, {@ref Bundle.removeBitstream} or {@ref Bundle.clearBitstreams}
*
* @return the bitstreams
*/
public List<Bitstream> getBitstreams() {
return bitstreams;
List<Bitstream> bitstreamList = new LinkedList<>(this.bitstreams);
return bitstreamList;
}
/**
* Add a new bitstream to this bundle.
* @param bitstream
*/
void addBitstream(Bitstream bitstream){
bitstreams.add(bitstream);
}
/**
* Clear the list of bitstream of this bundle
*/
public void clearBitstreams() {
bitstreams.clear();
}
/**
* Remove the given bitstream from this bundles bitstream list
* @param bitstream The bitstream to remove
*/
public void removeBitstream(Bitstream bitstream) {
bitstreams.remove(bitstream);
}
/**
* Get the items this bundle appears in
*
@@ -215,5 +238,4 @@ public class Bundle extends DSpaceObject implements DSpaceObjectLegacySupport
}
return bundleService;
}
}