static int countBitstream(BundleName bundleName, Item item) { int count = 0; for (Bundle bundle : item.getBundles()) { if (!bundle.getName().equals(bundleName.name())) { continue; } count += bundle.getBitstreams().size(); } return count; }
@Override public void delete(Context context, Bundle bundle) throws SQLException, AuthorizeException, IOException { log.info(LogManager.getHeader(context, "delete_bundle", "bundle_id=" + bundle.getID())); authorizeService.authorizeAction(context, bundle, Constants.DELETE); context.addEvent(new Event(Event.DELETE, Constants.BUNDLE, bundle.getID(), bundle.getName(), getIdentifiers(context, bundle))); // Remove bitstreams List<Bitstream> bitstreams = bundle.getBitstreams(); bundle.clearBitstreams(); for (Bitstream bitstream : bitstreams) { removeBitstream(context, bundle, bitstream); } List<Item> items = new LinkedList<>(bundle.getItems()); bundle.getItems().clear(); for (Item item : items) { item.removeBundle(bundle); } // Remove ourself bundleDAO.delete(context, bundle); }
@Override public void update(Context context, Bundle bundle) throws SQLException, AuthorizeException { // Check authorisation //AuthorizeManager.authorizeAction(ourContext, this, Constants.WRITE); log.info(LogManager.getHeader(context, "update_bundle", "bundle_id=" + bundle.getID())); super.update(context, bundle); bundleDAO.save(context, bundle); if (bundle.isModified() || bundle.isMetadataModified()) { if (bundle.isMetadataModified()) { context.addEvent(new Event(Event.MODIFY_METADATA, bundle.getType(), bundle.getID(), bundle.getDetails(), getIdentifiers(context, bundle))); } context.addEvent(new Event(Event.MODIFY, Constants.BUNDLE, bundle.getID(), null, getIdentifiers(context, bundle))); bundle.clearModified(); bundle.clearDetails(); } }
@Override public Bitstream getBitstreamByName(Bundle bundle, String name) { Bitstream target = null; for (Bitstream bitstream : bundle.getBitstreams()) { if (name.equals(bitstream.getName())) { target = bitstream; break; } } return target; }
validityKey.append(bundle.getID()); validityKey.append(bundle.getName()); validityKey.append(bundle.getPrimaryBitstreamID()); for(Bitstream bitstream : bundle.getBitstreams())
int bitstreamID = Integer.parseInt(st.nextToken()); Bundle bundle = Bundle.find(context, bundleID); Bitstream bitstream = Bitstream.find(context, bitstreamID); bundle.removeBitstream(bitstream); if (bundle.getBitstreams().length == 0) bundle.setPrimaryBitstreamID(primaryBitstreamID); bundle.update(); Bitstream[] bitstreams = bundle.getBitstreams(); int[] newBitstreamOrder = new int[bitstreams.length]; if (button.equals("submit_update_order")) { if(inputKey.startsWith(bundle.getID() + "_")){ String[] vals = request.getParameter(inputKey).split(","); for (int i = 0; i < vals.length; i++) { bundle.setOrder(newBitstreamOrder); bundle.update();
public void deleteBitstream(Context context, Bitstream bitstream) throws SwordError, DSpaceSwordException { // this is equivalent to asking whether the media resource in the item can be deleted try { List<Bundle> bundles = bitstream.getBundles(); for (Bundle bundle : bundles) { // is the bitstream in the ORIGINAL bundle? If not, it can't be worked on if (!Constants.CONTENT_BUNDLE_NAME .equals(bundle.getName())) { throw new SwordError(UriRegistry.ERROR_METHOD_NOT_ALLOWED, "The file is not in a bundle which can be modified"); } List<Item> items = bundle.getItems(); for (Item item : items) { this.deleteMediaResource(context, item); } } } catch (SQLException e) { throw new DSpaceSwordException(e); } }
/** * Set the item this bundle appears in * * @return array of <code>Item</code> s this bundle appears in */ void addItem(Item item) { getItems().add(item); }
bundlePolicies.put(Integer.valueOf(myBundle.getID()), myPolicies); Bitstream[] bitstreams = myBundle.getBitstreams();
throw new DSpaceSWORDException("Orphaned bitstream discovered"); Item[] items = bundles[0].getItems(); if (items.length == 0) log.error("Found orphaned bundle: " + bundles[0].getID()); throw new DSpaceSWORDException("Orphaned bundle discovered"); for (int i = 0; i < lbundles.length; i++) Bitstream[] bss = lbundles[i].getBitstreams(); for (int j = 0; j < bss.length; j++)
protected void createBundlesAndAddBitstreams(Context c, Item itemNew, Item nativeItem) throws SQLException, AuthorizeException, IOException { for (Bundle nativeBundle : nativeItem.getBundles()) { Bundle bundleNew = bundleService.create(c, itemNew, nativeBundle.getName()); authorizeService.addPolicies(c, bundlePolicies, bundleNew); for (Bitstream nativeBitstream : nativeBundle.getBitstreams()) { authorizeService.addPolicies(c, bitstreamPolicies, bitstreamNew); if (nativeBundle.getPrimaryBitstream() != null && nativeBundle.getPrimaryBitstream() .equals(nativeBitstream)) { bundleNew.setPrimaryBitstreamID(bitstreamNew);
/** * Predicate, does this bundle container meta-information. I.e. * does this bundle contain descriptive metadata or other metadata * such as license bitstreams? If so we probably don't want to put * it into the "content" section of a package; hence this predicate. * * @param bn -- the bundle * @return true if this bundle name indicates it is a meta-info bundle. */ public static boolean isMetaInfoBundle(Bundle bn) { return (bn.getName().equals(Constants.LICENSE_BUNDLE_NAME) || bn.getName().equals(CreativeCommonsService.CC_BUNDLE_NAME) || bn.getName().equals(Constants.METADATA_BUNDLE_NAME)); }
protected void deleteBundle(Context context, Item item, Bundle b) throws AuthorizeException, SQLException, IOException { // Check authorisation authorizeService.authorizeAction(context, item, Constants.REMOVE); bundleService.delete(context, b); log.info(LogManager.getHeader(context, "remove_bundle", "item_id=" + item.getID() + ",bundle_id=" + b.getID())); context .addEvent(new Event(Event.REMOVE, Constants.ITEM, item.getID(), Constants.BUNDLE, b.getID(), b.getName())); }
subheader.addCell(null, null, 1, 4, "indent").addHighlight("bold").addContent(T_subhead_bundle.parameterize(bundle.getName(),bundle.getID())); subheader.addCell().addHighlight("bold").addXref(baseURL + "&submit_add_bundle_" + bundle.getID(), T_add_bundlePolicy_link); this.rowBuilder(baseURL, table, bundlePolicies, bundle.getID(), Constants.BUNDLE, highlightID); bitstreams = bundle.getBitstreams(); for (Bitstream bitstream : bitstreams) { subheader = table.addRow(null,Row.ROLE_HEADER,"subheader");
Bitstream[] bitstreams = bundle.getBitstreams(); if(inputKey.startsWith(bundle.getID() + "_")){ String[] vals = request.getParameter(inputKey).split(","); for (int i = 0; i < vals.length; i++) { bundle.setOrder(newBitstreamOrder); bundle.update();
authorizeService.authorizeAction(context, bundle, Constants.WRITE); List<Bitstream> currentBitstreams = bundle.getBitstreams(); List<Bitstream> updatedBitstreams = new ArrayList<Bitstream>(); "Bundle: " + bundle.getID() + ", bitstream id: " + bitstreamId)); continue; "Encountered a bitstream not in this bundle while changing bitstream " + "order. Bitstream order will not be changed.", "Bundle: " + bundle.getID() + ", bitstream id: " + bitstreamId)); return; "Size of old list and new list do not match. Bitstream order will not be " + "changed.", "Bundle: " + bundle.getID())); return; bundle.clearBitstreams(); bundle.addBitstream(bitstream); bitstream.getBundles().add(bundle); bitstreamService.update(context, bitstream);
@Override public Bundle create(Context context, Item item, String name) throws SQLException, AuthorizeException { if (StringUtils.isBlank(name)) { throw new SQLException("Bundle must be created with non-null name"); } authorizeService.authorizeAction(context, item, Constants.ADD); // Create a table row Bundle bundle = bundleDAO.create(context, new Bundle()); bundle.setName(context, name); itemService.addBundle(context, item, bundle); if (!bundle.getItems().contains(item)) { bundle.addItem(item); } log.info(LogManager.getHeader(context, "create_bundle", "bundle_id=" + bundle.getID())); // if we ever use the identifier service for bundles, we should // create the bundle before we create the Event and should add all // identifiers to it. context.addEvent(new Event(Event.CREATE, Constants.BUNDLE, bundle.getID(), null)); return bundle; }
@Override public void addBundle(Context context, Item item, Bundle bundle) throws SQLException, AuthorizeException { // Check authorisation authorizeService.authorizeAction(context, item, Constants.ADD); log.info(LogManager.getHeader(context, "add_bundle", "item_id=" + item.getID() + ",bundle_id=" + bundle.getID())); // Check it's not already there if (item.getBundles().contains(bundle)) { // Bundle is already there; no change return; } // now add authorization policies from owning item // hmm, not very "multiple-inclusion" friendly authorizeService.inheritPolicies(context, item, bundle); // Add the bundle to in-memory list item.addBundle(bundle); bundle.addItem(item); context.addEvent(new Event(Event.ADD, Constants.ITEM, item.getID(), Constants.BUNDLE, bundle.getID(), bundle.getName(), getIdentifiers(context, item))); }
+ bundle.getID() + ",bitstream_id=" + bitstream.getID())); List<Bitstream> bitstreams = bundle.getBitstreams(); int topOrder = 0; bundle.addBitstream(bitstream); bitstream.getBundles().add(bundle); context.addEvent(new Event(Event.ADD, Constants.BUNDLE, bundle.getID(), Constants.BITSTREAM, bitstream.getID(), String.valueOf(bitstream.getSequenceID()), getIdentifiers(context, bundle)));