[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 {
identifierService.register(context, newCollection, handle);
}
} catch (IdentifierException e) {
throw new RuntimeException("Can't create an Identifier!");
} catch (IllegalStateException | IdentifierException ex) {
throw new IllegalStateException(ex);
}
// create the default authorization policy for collections

View File

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

View File

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

View File

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

View File

@@ -236,11 +236,6 @@ public class CollectionRestRepository extends DSpaceObjectRestRepository<Collect
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;
try {
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);
}
if (communityRest.getMetadata().getMap().containsKey("dc.identifier.uri")) {
throw new UnprocessableEntityException("Handle identifier cannot be passed "
+ "as metadata during community creation.");
}
Community community;
try {