[CSTPER-221] Minor changes and cleanup

This commit is contained in:
Alessandro Martelli
2020-10-30 18:41:04 +01:00
parent 28273ce292
commit b878b0a7e0
6 changed files with 9 additions and 14 deletions

View File

@@ -142,8 +142,8 @@ public class CollectionServiceImpl extends DSpaceObjectServiceImpl<Collection> i
} else { } else {
identifierService.register(context, newCollection, handle); identifierService.register(context, newCollection, handle);
} }
} catch (IdentifierException e) { } catch (IllegalStateException | IdentifierException ex) {
throw new RuntimeException("Can't create an Identifier!"); throw new IllegalStateException(ex);
} }
// create the default authorization policy for collections // create the default authorization policy for collections

View File

@@ -100,10 +100,11 @@ public class CommunityServiceImpl extends DSpaceObjectServiceImpl<Community> imp
} else { } else {
identifierService.register(context, newCommunity, handle); identifierService.register(context, newCommunity, handle);
} }
} catch (IdentifierException e) { } catch (IllegalStateException | IdentifierException ex) {
throw new RuntimeException("Can't create an Identifier!"); throw new IllegalStateException(ex);
} }
if (parent != null) { if (parent != null) {
parent.addSubCommunity(newCommunity); parent.addSubCommunity(newCommunity);
newCommunity.addParentCommunity(parent); newCommunity.addParentCommunity(parent);

View File

@@ -170,6 +170,7 @@ public class DOIIdentifierProvider
public String register(Context context, DSpaceObject dso) public String register(Context context, DSpaceObject dso)
throws IdentifierException { throws IdentifierException {
if (!(dso instanceof Item)) { if (!(dso instanceof Item)) {
// DOI are currently assigned only to Item
return null; return null;
} }
String doi = mint(context, dso); String doi = mint(context, dso);
@@ -183,6 +184,7 @@ public class DOIIdentifierProvider
public void register(Context context, DSpaceObject dso, String identifier) public void register(Context context, DSpaceObject dso, String identifier)
throws IdentifierException { throws IdentifierException {
if (!(dso instanceof Item)) { if (!(dso instanceof Item)) {
// DOI are currently assigned only to Item
return; return;
} }
String doi = doiService.formatIdentifier(identifier); String doi = doiService.formatIdentifier(identifier);

View File

@@ -149,6 +149,7 @@ public class EZIDIdentifierProvider
log.debug("register {}", dso); log.debug("register {}", dso);
if (!(dso instanceof Item)) { if (!(dso instanceof Item)) {
// DOI are currently assigned only to Item
return null; return null;
} }
DSpaceObjectService<DSpaceObject> dsoService = contentServiceFactory.getDSpaceObjectService(dso); DSpaceObjectService<DSpaceObject> dsoService = contentServiceFactory.getDSpaceObjectService(dso);
@@ -175,6 +176,7 @@ public class EZIDIdentifierProvider
log.debug("register {} as {}", object, identifier); log.debug("register {} as {}", object, identifier);
if (!(object instanceof Item)) { if (!(object instanceof Item)) {
// DOI are currently assigned only to Item
return; return;
} }
EZIDResponse response; EZIDResponse response;

View File

@@ -236,11 +236,6 @@ public class CollectionRestRepository extends DSpaceObjectRestRepository<Collect
throw new UnprocessableEntityException("Error parsing request body.", e1); throw new UnprocessableEntityException("Error parsing request body.", e1);
} }
if (collectionRest.getMetadata().getMap().containsKey("dc.identifier.uri")) {
throw new UnprocessableEntityException("Handle identifier cannot be passed "
+ "as metadata during collection creation.");
}
Collection collection; Collection collection;
try { try {
Community parent = communityService.find(context, id); Community parent = communityService.find(context, id);

View File

@@ -135,11 +135,6 @@ public class CommunityRestRepository extends DSpaceObjectRestRepository<Communit
throw new UnprocessableEntityException("Error parsing request body.", e1); throw new UnprocessableEntityException("Error parsing request body.", e1);
} }
if (communityRest.getMetadata().getMap().containsKey("dc.identifier.uri")) {
throw new UnprocessableEntityException("Handle identifier cannot be passed "
+ "as metadata during community creation.");
}
Community community; Community community;
try { try {