[CSTPER-221] Fixed Authorization denied during subCommunity creation

We need to persist the newCommunity before adding the handle metadata
value. The failing test was
* CommunityRestRepositoryIT.createSubCommunityAuthorizedTest
This commit is contained in:
Alessandro Martelli
2020-11-09 11:48:22 +01:00
parent ed01db6392
commit dc08f36a94

View File

@@ -94,17 +94,6 @@ public class CommunityServiceImpl extends DSpaceObjectServiceImpl<Community> imp
Community newCommunity = communityDAO.create(context, new Community());
try {
if (handle == null) {
identifierService.register(context, newCommunity);
} else {
identifierService.register(context, newCommunity, handle);
}
} catch (IllegalStateException | IdentifierException ex) {
throw new IllegalStateException(ex);
}
if (parent != null) {
parent.addSubCommunity(newCommunity);
newCommunity.addParentCommunity(parent);
@@ -129,6 +118,16 @@ public class CommunityServiceImpl extends DSpaceObjectServiceImpl<Community> imp
getIdentifiers(context, newCommunity)));
}
try {
if (handle == null) {
identifierService.register(context, newCommunity);
} else {
identifierService.register(context, newCommunity, handle);
}
} catch (IllegalStateException | IdentifierException ex) {
throw new IllegalStateException(ex);
}
log.info(LogManager.getHeader(context, "create_community",
"community_id=" + newCommunity.getID())
+ ",handle=" + newCommunity.getHandle());