public void removeBundle(Context context, Item item, Bundle source, boolean archive) throws SQLException, AuthorizeException, IOException { // archive the bundle contents if desired if (archive) { this.archiveBundle(context, item, source); } // remove all the bitstreams from the bundle Iterator<Bitstream> bitstreams = source.getBitstreams() .iterator(); while (bitstreams.hasNext()) { Bitstream bitstream = bitstreams.next(); bitstreams.remove(); bundleService.removeBitstream(context, source, bitstream); } // delete the bundle itself itemService.removeBundle(context, item, source); }
public void removeBitstream(Context context, Item item, Bitstream bitstream, boolean keep) throws SQLException, AuthorizeException, IOException { Bundle exempt = null; if (keep) { exempt = this.archiveBitstream(context, item, bitstream); } Iterator<Bundle> bundles = bitstream.getBundles() .iterator(); while (bundles.hasNext()) { Bundle bundle = bundles.next(); if (exempt != null && bundle.getID() != exempt.getID()) { bundles.remove(); bundleService .removeBitstream(context, bundle, bitstream); } } // there is nowhere in the metadata to say when this file was moved, so we // are going to drop it into the description SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); String desc = bitstream.getDescription(); String newDesc = "[Deleted on: " + sdf.format(new Date()) + "] "; if (desc != null) { newDesc += desc; } bitstream.setDescription(context, newDesc); bitstreamService.update(context, bitstream); }
bitstreamService.update(context, newBitstream); bundleService.removeBitstream(context, bundle, bitstream);
deleted.add(bs.getName()); bundleService.removeBitstream(context, b, bs); ItemUpdate.pr("Deleted " + bundleName + " bitstream " + bs.getName() + " with id = " + bs.getID());
public void undoDeposit(DepositResult result) throws DSpaceSWORDException { try { SWORDContext sc = swordService.getSwordContext(); BundleService bundleService = ContentServiceFactory.getInstance() .getBundleService(); // obtain the bitstream's owning bundles and remove the bitstream // from them. This will ensure that the bitstream is physically // removed from the disk. Bitstream bs = result.getBitstream(); Iterator<Bundle> bundles = bs.getBundles().iterator(); while (bundles.hasNext()) { Bundle bundle = bundles.next(); bundles.remove(); bundleService.removeBitstream(sc.getContext(), bundle, bs); bundleService.update(sc.getContext(), bundle); } swordService.message("Removing temporary files from disk"); // abort the context, so no database changes are written sc.abort(); swordService.message("Database changes aborted"); } catch (IOException | AuthorizeException | SQLException e) { throw new DSpaceSWORDException(e); } } }
bundleService.removeBitstream(context, original, bs);
ItemUpdate.pr("Delete bitstream with id = " + id); } else { bundleService.removeBitstream(context, b, bs); ItemUpdate.pr("Deleted bitstream with id = " + id);
if (bundle.getID() != pBundle.getID()) { bundleService.addBitstream(context, pBundle, bitstream); bundleService.removeBitstream(context, bundle, bitstream); List<Bitstream> bitstreams = bundle.getBitstreams(); if (bitstreams == null || bitstreams.size() == 0) { bundleService.removeBitstream(context, dBundle, displayMap.get(bitstream.getName()));
bundleService.removeBitstream(context, existingBundle, existingBitstream);
bundleService.removeBitstream(ourContext, OREBundle, OREBitstream);