@Override public int hashCode() { int hash = 5; hash += 71 * hash + getType(); hash += 71 * hash + getID().hashCode(); return hash; }
@Override public boolean equals(Object obj) { if (obj == null) { return false; } Class<?> objClass = HibernateProxyHelper.getClassWithoutInitializingProxy(obj); if (this.getClass() != objClass) { return false; } final Bundle other = (Bundle) obj; if (this.getType() != other.getType()) { return false; } if (!this.getID().equals(other.getID())) { return false; } return true; }
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); }
bundlePolicies.put(Integer.valueOf(myBundle.getID()), myPolicies);
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())); }
@Override public void removeBundle(Context context, Item item, Bundle bundle) throws SQLException, AuthorizeException, IOException { // Check authorisation authorizeService.authorizeAction(context, item, Constants.REMOVE); log.info(LogManager.getHeader(context, "remove_bundle", "item_id=" + item.getID() + ",bundle_id=" + bundle.getID())); context.addEvent(new Event(Event.REMOVE, Constants.ITEM, item.getID(), Constants.BUNDLE, bundle.getID(), bundle.getName(), getIdentifiers(context, item))); bundleService.delete(context, bundle); }
@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; }
"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;
List<Item> items = bundle.getItems(); if (items.isEmpty()) { log.error("Found orphaned bundle: " + bundle.getID()); throw new DSpaceSWORDException("Orphaned bundle discovered");
@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 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))); }
@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(); } }
if (items.length == 0) log.error("Found orphaned bundle: " + bundles[0].getID()); throw new DSpaceSWORDException("Orphaned bundle discovered");
if(inputKey.startsWith(bundle.getID() + "_")){ String[] vals = request.getParameter(inputKey).split(","); for (int i = 0; i < vals.length; i++) {
System.out.println("Bundle " + bundle.getID());
+ si.getBundle().getID() + "\"/>";
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);