@Override public void updateLastModified(Context context, Community community) { //Also fire a modified event since the community HAS been modified context.addEvent(new Event(Event.MODIFY, Constants.COMMUNITY, community.getID(), null, getIdentifiers(context, community))); }
@Override public void updateLastModified(Context context, Collection collection) throws SQLException, AuthorizeException { //Also fire a modified event since the collection HAS been modified context.addEvent(new Event(Event.MODIFY, Constants.COLLECTION, collection.getID(), null, getIdentifiers(context, collection))); }
@Override public void updateLastModified(Context context, Bitstream bitstream) { //Also fire a modified event since the bitstream HAS been modified context.addEvent( new Event(Event.MODIFY, Constants.BITSTREAM, bitstream.getID(), null, getIdentifiers(context, bitstream))); }
@Override public void updateLastModified(Context context, Item item) throws SQLException, AuthorizeException { item.setLastModified(new Date()); update(context, item); //Also fire a modified event since the item HAS been modified context.addEvent(new Event(Event.MODIFY, Constants.ITEM, item.getID(), null, getIdentifiers(context, item))); }
@Override public void addMember(Context context, Group group, EPerson e) { if (isDirectMember(group, e)) { return; } group.addMember(e); e.getGroups().add(group); context.addEvent( new Event(Event.ADD, Constants.GROUP, group.getID(), Constants.EPERSON, e.getID(), e.getEmail(), getIdentifiers(context, group))); }
@Override public Bitstream create(Context context, InputStream is) throws IOException, SQLException { // Store the bits UUID bitstreamID = bitstreamStorageService.store(context, bitstreamDAO.create(context, new Bitstream()), is); log.info(LogManager.getHeader(context, "create_bitstream", "bitstream_id=" + bitstreamID)); // Set the format to "unknown" Bitstream bitstream = find(context, bitstreamID); setFormat(context, bitstream, null); context.addEvent( new Event(Event.CREATE, Constants.BITSTREAM, bitstreamID, null, getIdentifiers(context, bitstream))); return bitstream; }
@Override public void removeMember(Context context, Group group, EPerson ePerson) { if (group.remove(ePerson)) { context.addEvent(new Event(Event.REMOVE, Constants.GROUP, group.getID(), Constants.EPERSON, ePerson.getID(), ePerson.getEmail(), getIdentifiers(context, group))); } }
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 void addItem(Context context, Collection collection, Item item) throws SQLException, AuthorizeException { // Check authorisation authorizeService.authorizeAction(context, collection, Constants.ADD); log.info(LogManager.getHeader(context, "add_item", "collection_id=" + collection.getID() + ",item_id=" + item.getID())); // Create mapping // We do NOT add the item to the collection template since we would have to load in all our items // Instead we add the collection to an item which works in the same way. if (!item.getCollections().contains(collection)) { item.addCollection(collection); } context.addEvent(new Event(Event.ADD, Constants.COLLECTION, collection.getID(), Constants.ITEM, item.getID(), item.getHandle(), getIdentifiers(context, collection))); }
@Override public EPerson create(Context context) throws SQLException, AuthorizeException { // authorized? if (!authorizeService.isAdmin(context)) { throw new AuthorizeException( "You must be an admin to create an EPerson"); } // Create a table row EPerson e = ePersonDAO.create(context, new EPerson()); log.info(LogManager.getHeader(context, "create_eperson", "eperson_id=" + e.getID())); context.addEvent(new Event(Event.CREATE, Constants.EPERSON, e.getID(), null, getIdentifiers(context, e))); return e; }
@Override public void addSubcommunity(Context context, Community parentCommunity, Community childCommunity) throws SQLException, AuthorizeException { // Check authorisation authorizeService.authorizeAction(context, parentCommunity, Constants.ADD); log.info(LogManager.getHeader(context, "add_subcommunity", "parent_comm_id=" + parentCommunity.getID() + ",child_comm_id=" + childCommunity .getID())); if (!parentCommunity.getSubcommunities().contains(childCommunity)) { parentCommunity.addSubCommunity(childCommunity); childCommunity.addParentCommunity(parentCommunity); } context.addEvent(new Event(Event.ADD, Constants.COMMUNITY, parentCommunity.getID(), Constants.COMMUNITY, childCommunity.getID(), parentCommunity.getHandle(), getIdentifiers(context, parentCommunity))); }
@Override public void removeMember(Context context, Group groupParent, Group childGroup) throws SQLException { if (groupParent.remove(childGroup)) { childGroup.removeParentGroup(groupParent); context.addEvent( new Event(Event.REMOVE, Constants.GROUP, groupParent.getID(), Constants.GROUP, childGroup.getID(), childGroup.getName(), getIdentifiers(context, groupParent))); } }
@Override public void addCollection(Context context, Community community, Collection collection) throws SQLException, AuthorizeException { // Check authorisation authorizeService.authorizeAction(context, community, Constants.ADD); log.info(LogManager.getHeader(context, "add_collection", "community_id=" + community.getID() + ",collection_id=" + collection.getID())); if (!community.getCollections().contains(collection)) { community.addCollection(collection); collection.addCommunity(community); } context.addEvent( new Event(Event.ADD, Constants.COMMUNITY, community.getID(), Constants.COLLECTION, collection.getID(), community.getHandle(), getIdentifiers(context, community))); }
@Override public void removeSubcommunity(Context context, Community parentCommunity, Community childCommunity) throws SQLException, AuthorizeException, IOException { // Check authorisation authorizeService.authorizeAction(context, parentCommunity, Constants.REMOVE); ArrayList<String> removedIdentifiers = getIdentifiers(context, childCommunity); String removedHandle = childCommunity.getHandle(); UUID removedId = childCommunity.getID(); rawDelete(context, childCommunity); log.info(LogManager.getHeader(context, "remove_subcommunity", "parent_comm_id=" + parentCommunity.getID() + ",child_comm_id=" + childCommunity .getID())); context.addEvent( new Event(Event.REMOVE, Constants.COMMUNITY, parentCommunity.getID(), Constants.COMMUNITY, removedId, removedHandle, removedIdentifiers)); }
@Override public void removeItem(Context context, Collection collection, Item item) throws SQLException, AuthorizeException, IOException { // Check authorisation authorizeService.authorizeAction(context, collection, Constants.REMOVE); //Check if we orphaned our poor item if (item.getCollections().size() == 1) { // Orphan; delete it itemService.delete(context, item); } else { //Remove the item from the collection if we have multiple collections item.removeCollection(collection); } context.addEvent(new Event(Event.REMOVE, Constants.COLLECTION, collection.getID(), Constants.ITEM, item.getID(), item.getHandle(), getIdentifiers(context, collection))); }
@Override public Group create(Context context) throws SQLException, AuthorizeException { // FIXME - authorization? if (!authorizeService.isAdmin(context)) { throw new AuthorizeException( "You must be an admin to create an EPerson Group"); } // Create a table row Group g = groupDAO.create(context, new Group()); log.info(LogManager.getHeader(context, "create_group", "group_id=" + g.getID())); context.addEvent(new Event(Event.CREATE, Constants.GROUP, g.getID(), null, getIdentifiers(context, g))); update(context, g); return g; }
protected Item createItem(Context context) throws SQLException, AuthorizeException { Item item = itemDAO.create(context, new Item()); // set discoverable to true (default) item.setDiscoverable(true); // Call update to give the item a last modified date. OK this isn't // amazingly efficient but creates don't happen that often. context.turnOffAuthorisationSystem(); update(context, item); context.restoreAuthSystemState(); context.addEvent(new Event(Event.CREATE, Constants.ITEM, item.getID(), null, getIdentifiers(context, item))); log.info(LogManager.getHeader(context, "create_item", "item_id=" + item.getID())); return item; }
@Override public void addMember(Context context, Group groupParent, Group groupChild) throws SQLException { // don't add if it's already a member // and don't add itself if (groupParent.contains(groupChild) || groupParent.getID() == groupChild.getID()) { return; } groupParent.addMember(groupChild); groupChild.addParentGroup(groupParent); context.addEvent(new Event(Event.ADD, Constants.GROUP, groupParent.getID(), Constants.GROUP, groupChild.getID(), groupChild.getName(), getIdentifiers(context, groupParent))); }
@Override public void update(Context context, Collection collection) throws SQLException, AuthorizeException { // Check authorisation canEdit(context, collection, true); log.info(LogManager.getHeader(context, "update_collection", "collection_id=" + collection.getID())); super.update(context, collection); collectionDAO.save(context, collection); if (collection.isModified()) { context.addEvent(new Event(Event.MODIFY, Constants.COLLECTION, collection.getID(), null, getIdentifiers(context, collection))); collection.clearModified(); } if (collection.isMetadataModified()) { collection.clearDetails(); } }