@Override public void removeCollection(Context context, Community community, Collection collection) throws SQLException, AuthorizeException, IOException { // Check authorisation authorizeService.authorizeAction(context, community, Constants.REMOVE); ArrayList<String> removedIdentifiers = collectionService.getIdentifiers(context, collection); String removedHandle = collection.getHandle(); UUID removedId = collection.getID(); if (collection.getCommunities().size() == 1) { collectionService.delete(context, collection); } else { community.removeCollection(collection); collection.removeCommunity(community); } log.info(LogManager.getHeader(context, "remove_collection", "community_id=" + community.getID() + ",collection_id=" + collection.getID())); // Remove any mappings context.addEvent(new Event(Event.REMOVE, Constants.COMMUNITY, community.getID(), Constants.COLLECTION, removedId, removedHandle, removedIdentifiers)); }
community.removeCollection(collection); removeCollection(context, community, collection);
community.removeCollection(collection);
/** * Delete collection itself * * @param context The current DSpace context. * @param collectionID The collection id. * @return A process result's object. */ public static FlowResult processDeleteCollection(Context context, int collectionID) throws SQLException, AuthorizeException, IOException { FlowResult result = new FlowResult(); Collection collection = Collection.find(context, collectionID); Community[] parents = collection.getCommunities(); for (Community parent: parents) { parent.removeCollection(collection); parent.update(); } context.commit(); result.setContinue(true); result.setOutcome(true); result.setMessage(new Message("default","The collection was successfully deleted.")); return result; }
Community owningCommunity = owningCommunities.next(); collection.removeCommunity(owningCommunity); owningCommunity.removeCollection(collection);