[CSTPER-221] Collection handle generation after creation

This commit is contained in:
Alessandro Martelli
2020-11-09 17:06:29 +01:00
parent 572a74afba
commit c84608e81f
2 changed files with 22 additions and 22 deletions

View File

@@ -135,17 +135,6 @@ public class CollectionServiceImpl extends DSpaceObjectServiceImpl<Collection> i
//Add our newly created collection to our community, authorization checks occur in THIS method
communityService.addCollection(context, community, newCollection);
//Update our collection so we have a collection identifier
try {
if (handle == null) {
identifierService.register(context, newCollection);
} else {
identifierService.register(context, newCollection, handle);
}
} catch (IllegalStateException | IdentifierException ex) {
throw new IllegalStateException(ex);
}
// create the default authorization policy for collections
// of 'anonymous' READ
Group anonymousGroup = groupService.findByName(context, Group.ANONYMOUS);
@@ -158,6 +147,18 @@ public class CollectionServiceImpl extends DSpaceObjectServiceImpl<Collection> i
authorizeService
.createResourcePolicy(context, newCollection, anonymousGroup, null, Constants.DEFAULT_BITSTREAM_READ, null);
collectionDAO.save(context, newCollection);
//Update our collection so we have a collection identifier
try {
if (handle == null) {
identifierService.register(context, newCollection);
} else {
identifierService.register(context, newCollection, handle);
}
} catch (IllegalStateException | IdentifierException ex) {
throw new IllegalStateException(ex);
}
context.addEvent(new Event(Event.CREATE, Constants.COLLECTION,
newCollection.getID(), newCollection.getHandle(),
@@ -167,7 +168,6 @@ public class CollectionServiceImpl extends DSpaceObjectServiceImpl<Collection> i
"collection_id=" + newCollection.getID())
+ ",handle=" + newCollection.getHandle());
collectionDAO.save(context, newCollection);
return newCollection;
}