mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +00:00
[DS-4522] Use more generic IdentifierNotApplicableException where applicable
This commit is contained in:
@@ -891,7 +891,7 @@ public class DOIIdentifierProvider extends FilteredIdentifierProvider {
|
|||||||
* DOI is registered for another object already.
|
* DOI is registered for another object already.
|
||||||
*/
|
*/
|
||||||
protected DOI loadOrCreateDOI(Context context, DSpaceObject dso, String doiIdentifier)
|
protected DOI loadOrCreateDOI(Context context, DSpaceObject dso, String doiIdentifier)
|
||||||
throws SQLException, DOIIdentifierException {
|
throws SQLException, DOIIdentifierException, IdentifierNotApplicableException {
|
||||||
return loadOrCreateDOI(context, dso, doiIdentifier, false);
|
return loadOrCreateDOI(context, dso, doiIdentifier, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -911,7 +911,7 @@ public class DOIIdentifierProvider extends FilteredIdentifierProvider {
|
|||||||
* @throws DOIIdentifierException
|
* @throws DOIIdentifierException
|
||||||
*/
|
*/
|
||||||
protected DOI loadOrCreateDOI(Context context, DSpaceObject dso, String doiIdentifier, Boolean skipFilter)
|
protected DOI loadOrCreateDOI(Context context, DSpaceObject dso, String doiIdentifier, Boolean skipFilter)
|
||||||
throws SQLException, DOIIdentifierException {
|
throws SQLException, DOIIdentifierException, IdentifierNotApplicableException {
|
||||||
|
|
||||||
DOI doi = null;
|
DOI doi = null;
|
||||||
|
|
||||||
|
@@ -0,0 +1,34 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
package org.dspace.identifier;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Thrown when an identifier should not be applied to an item, eg. when it has been filtered by an item filter
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @author Kim Shepherd
|
||||||
|
*/
|
||||||
|
public class IdentifierNotApplicableException extends IdentifierException {
|
||||||
|
|
||||||
|
public IdentifierNotApplicableException() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IdentifierNotApplicableException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IdentifierNotApplicableException(String message, Throwable cause) {
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IdentifierNotApplicableException(Throwable cause) {
|
||||||
|
super(cause);
|
||||||
|
}
|
||||||
|
}
|
@@ -72,8 +72,8 @@ public class IdentifierServiceImpl implements IdentifierService {
|
|||||||
if (!StringUtils.isEmpty(identifier)) {
|
if (!StringUtils.isEmpty(identifier)) {
|
||||||
service.reserve(context, dso, identifier);
|
service.reserve(context, dso, identifier);
|
||||||
}
|
}
|
||||||
} catch (DOIIdentifierNotApplicableException e) {
|
} catch (IdentifierNotApplicableException e) {
|
||||||
log.warn("DOI Identifier not reserved (inapplicable): " + e.getMessage());
|
log.warn("Identifier not reserved (inapplicable): " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Update our item
|
//Update our item
|
||||||
@@ -88,8 +88,8 @@ public class IdentifierServiceImpl implements IdentifierService {
|
|||||||
if (service.supports(identifier)) {
|
if (service.supports(identifier)) {
|
||||||
try {
|
try {
|
||||||
service.reserve(context, dso, identifier);
|
service.reserve(context, dso, identifier);
|
||||||
} catch (DOIIdentifierNotApplicableException e) {
|
} catch (IdentifierNotApplicableException e) {
|
||||||
log.warn("DOI Identifier not reserved (inapplicable): " + e.getMessage());
|
log.warn("Identifier not reserved (inapplicable): " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -105,8 +105,8 @@ public class IdentifierServiceImpl implements IdentifierService {
|
|||||||
for (IdentifierProvider service : providers) {
|
for (IdentifierProvider service : providers) {
|
||||||
try {
|
try {
|
||||||
service.register(context, dso);
|
service.register(context, dso);
|
||||||
} catch (DOIIdentifierNotApplicableException e) {
|
} catch (IdentifierNotApplicableException e) {
|
||||||
log.warn("DOI Identifier not registered (inapplicable): " + e.getMessage());
|
log.warn("Identifier not registered (inapplicable): " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Update our item / collection / community
|
//Update our item / collection / community
|
||||||
@@ -124,8 +124,8 @@ public class IdentifierServiceImpl implements IdentifierService {
|
|||||||
try {
|
try {
|
||||||
service.register(context, object, identifier);
|
service.register(context, object, identifier);
|
||||||
registered = true;
|
registered = true;
|
||||||
} catch (DOIIdentifierNotApplicableException e) {
|
} catch (IdentifierNotApplicableException e) {
|
||||||
log.warn("DOI Identifier not registered (inapplicable): " + e.getMessage());
|
log.warn("Identifier not registered (inapplicable): " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -222,7 +222,7 @@ public class VersionedDOIIdentifierProvider extends DOIIdentifierProvider {
|
|||||||
|
|
||||||
// Should never return null!
|
// Should never return null!
|
||||||
protected String makeIdentifierBasedOnHistory(Context context, DSpaceObject dso, VersionHistory history)
|
protected String makeIdentifierBasedOnHistory(Context context, DSpaceObject dso, VersionHistory history)
|
||||||
throws AuthorizeException, SQLException, DOIIdentifierException {
|
throws AuthorizeException, SQLException, DOIIdentifierException, IdentifierNotApplicableException {
|
||||||
// Mint foreach new version an identifier like: 12345/100.versionNumber
|
// Mint foreach new version an identifier like: 12345/100.versionNumber
|
||||||
// use the bare handle (g.e. 12345/100) for the first version.
|
// use the bare handle (g.e. 12345/100) for the first version.
|
||||||
|
|
||||||
|
@@ -7,6 +7,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.dspace.identifier.doi;
|
package org.dspace.identifier.doi;
|
||||||
|
|
||||||
|
import org.dspace.identifier.IdentifierNotApplicableException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Thrown when an identifier should not be applied to an item, eg. when it has been filtered by an item filter
|
* Thrown when an identifier should not be applied to an item, eg. when it has been filtered by an item filter
|
||||||
@@ -14,7 +16,7 @@ package org.dspace.identifier.doi;
|
|||||||
*
|
*
|
||||||
* @author Kim Shepherd
|
* @author Kim Shepherd
|
||||||
*/
|
*/
|
||||||
public class DOIIdentifierNotApplicableException extends DOIIdentifierException {
|
public class DOIIdentifierNotApplicableException extends IdentifierNotApplicableException {
|
||||||
|
|
||||||
public DOIIdentifierNotApplicableException() {
|
public DOIIdentifierNotApplicableException() {
|
||||||
super();
|
super();
|
||||||
|
@@ -40,6 +40,7 @@ import org.dspace.handle.service.HandleService;
|
|||||||
import org.dspace.identifier.DOI;
|
import org.dspace.identifier.DOI;
|
||||||
import org.dspace.identifier.DOIIdentifierProvider;
|
import org.dspace.identifier.DOIIdentifierProvider;
|
||||||
import org.dspace.identifier.IdentifierException;
|
import org.dspace.identifier.IdentifierException;
|
||||||
|
import org.dspace.identifier.IdentifierNotApplicableException;
|
||||||
import org.dspace.identifier.factory.IdentifierServiceFactory;
|
import org.dspace.identifier.factory.IdentifierServiceFactory;
|
||||||
import org.dspace.identifier.service.DOIService;
|
import org.dspace.identifier.service.DOIService;
|
||||||
import org.dspace.services.ConfigurationService;
|
import org.dspace.services.ConfigurationService;
|
||||||
@@ -243,8 +244,6 @@ public class DOIOrganiser {
|
|||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
System.err.println("Error in database connection:" + ex.getMessage());
|
System.err.println("Error in database connection:" + ex.getMessage());
|
||||||
ex.printStackTrace(System.err);
|
ex.printStackTrace(System.err);
|
||||||
} catch (DOIIdentifierNotApplicableException e) {
|
|
||||||
System.err.println("DOI not registered: " + e.getMessage());
|
|
||||||
} catch (DOIIdentifierException ex) {
|
} catch (DOIIdentifierException ex) {
|
||||||
System.err.println("Error registering DOI identifier:" + ex.getMessage());
|
System.err.println("Error registering DOI identifier:" + ex.getMessage());
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user