mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-10 11:33:11 +00:00
64640: Move PATCH request for bitstreams in bundles
This commit is contained in:
@@ -268,6 +268,30 @@ public class BundleServiceImpl extends DSpaceObjectServiceImpl<Bundle> implement
|
||||
return authorizeService.getPolicies(context, bundle);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void moveBitstream(Context context, Bundle bundle, int from, int to)
|
||||
throws AuthorizeException, SQLException {
|
||||
List<Bitstream> bitstreams = bundle.getBitstreams();
|
||||
if (bitstreams.size() < 1 || from >= bitstreams.size() || to >= bitstreams.size() || from < 0 || to < 0) {
|
||||
throw new IllegalArgumentException(
|
||||
"Invalid 'from' and 'to' arguments supplied for moving a bitstream within bundle " +
|
||||
bundle.getID() + ". from: " + from + "; to: " + to
|
||||
);
|
||||
}
|
||||
List<UUID> bitstreamIds = new LinkedList<>();
|
||||
for (Bitstream bitstream : bitstreams) {
|
||||
bitstreamIds.add(bitstream.getID());
|
||||
}
|
||||
if (from < to) {
|
||||
bitstreamIds.add(to + 1, bitstreamIds.get(from));
|
||||
bitstreamIds.remove(from);
|
||||
} else {
|
||||
bitstreamIds.add(to, bitstreamIds.get(from));
|
||||
bitstreamIds.remove(from + 1);
|
||||
}
|
||||
setOrder(context, bundle, bitstreamIds.toArray(new UUID[bitstreamIds.size()]));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOrder(Context context, Bundle bundle, UUID[] bitstreamIds) throws AuthorizeException, SQLException {
|
||||
authorizeService.authorizeAction(context, bundle, Constants.WRITE);
|
||||
|
Reference in New Issue
Block a user