/** * 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); }
void removeItem(Item item) { getItems().remove(item); }
@Override public DSpaceObject getParentObject(Context context, Bundle bundle) throws SQLException { List<Item> items = bundle.getItems(); if (CollectionUtils.isNotEmpty(items)) { return items.iterator().next(); } else { return null; } }
/** * Is allowed manage (create, remove, edit) bundle's policies in the * current context? * * @param context the DSpace Context Object * @param bundle the bundle that the policy refer to * @throws AuthorizeException if authorization error * if the current context (current user) is not allowed to * manage the bundle's policies * @throws SQLException if database error * if a db error occur */ public static void authorizeManageBundlePolicy(Context context, Bundle bundle) throws AuthorizeException, SQLException { Item item = bundle.getItems().get(0); authorizeManageItemPolicy(context, item); }
protected boolean isAnyItemInstalled(Context ctx, List<Bundle> bundles) throws SQLException { for (Bundle bundle : bundles) { for (Item item : bundle.getItems()) { if (workspaceItemService.findByItem(ctx, item) == null && workflowItemService.findByItem(ctx, item) == null) { return true; } } } return false; }
private Date getLastModified(Context context, Bitstream bitstream) throws SQLException { Date lm = null; List<Bundle> bundles = bitstream.getBundles(); for (Bundle bundle : bundles) { List<Item> items = bundle.getItems(); for (Item item : items) { Date possible = item.getLastModified(); if (lm == null) { lm = possible; } else if (possible.getTime() > lm.getTime()) { lm = possible; } } } if (lm == null) { return new Date(); } return lm; }
List<Item> items = parent.getItems(); Item item; if (!items.isEmpty()) {
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); } }
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); } }
public void replaceBitstream(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.replaceResourceContent(context, item); } } } catch (SQLException e) { throw new DSpaceSwordException(e); } }
@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); }
List<Item> items = bundle.getItems(); if (items.isEmpty()) { log.error("Found orphaned bundle: " + bundle.getID());
List<Item> items = parent.getItems(); Item item; if (!items.isEmpty()) {
@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; }
List<Item> items = parent.getItems(); Item item; if (!items.isEmpty()) {
List<Item> items = b.getItems(); for (Item i : items) { if (workspaceItemService.findByItem(ctx, i) != null
return; List<Item> items = bundle.getItems(); for (Item i : items) { if (workspaceItemService.findByItem(ctx, i) != null
for (Item item : bundle.getItems()) { this.replaceResourceContent(context, item);
Item[] items = parent.getItems(); Item item; if (items.length > 0)
List<Bundle> bundles = bitstream.getBundles(); for (Bundle bundle : bundles) { List<Item> items = bundle.getItems(); for (Item item : items) { doc1.addField("owningItem", item.getID());