DOIIdentifierProvider extends IdentifierProvider { @Override public String mint(Context context, DSpaceObject dso) throws IdentifierException { String doi = null; try { doi = getDOIByObject(context, dso); } catch (SQLException e) { log.error("Error while attemping to retrieve information about a DOI for " + contentServiceFactory.getDSpaceObjectService(dso).getTypeText(dso) + " with ID " + dso.getID() + "."); throw new RuntimeException("Error while attempting to retrieve " + "information about a DOI for " + contentServiceFactory.getDSpaceObjectService(dso).getTypeText(dso) + " with ID " + dso.getID() + ".", e); } if (null == doi) { try { DOI doiRow = loadOrCreateDOI(context, dso, null); doi = DOI.SCHEME + doiRow.getDoi(); } catch (SQLException e) { log.error("Error while creating new DOI for Object of " + "ResourceType {} with id {}.", dso.getType(), dso.getID()); throw new RuntimeException("Error while attempting to create a " + "new DOI for " + contentServiceFactory.getDSpaceObjectService(dso).getTypeText(dso) + " with ID " + dso.getID() + ".", e); } } return doi; } protected  DOIIdentifierProvider(); @Required void setDOIConnector(DOIConnector connector); @Override boolean supports(Class<? extends Identifier> identifier); @Override boolean supports(String identifier); @Override String register(Context context, DSpaceObject dso); @Override void register(Context context, DSpaceObject dso, String identifier); @Override void reserve(Context context, DSpaceObject dso, String identifier); void reserveOnline(Context context, DSpaceObject dso, String identifier); void registerOnline(Context context, DSpaceObject dso, String identifier); void updateMetadata(Context context, DSpaceObject dso, String identifier); void updateMetadataOnline(Context context, DSpaceObject dso, String identifier); @Override String mint(Context context, DSpaceObject dso); @Override DSpaceObject resolve(Context context, String identifier, String... attributes); @Override String lookup(Context context, DSpaceObject dso); @Override void delete(Context context, DSpaceObject dso); @Override void delete(Context context, DSpaceObject dso, String identifier); void deleteOnline(Context context, String identifier); DSpaceObject getObjectByDOI(Context context, String identifier); String getDOIByObject(Context context, DSpaceObject dso); String getDOIOutOfObject(DSpaceObject dso); static final String MD_SCHEMA; static final String DOI_ELEMENT; static final String DOI_QUALIFIER; static final Integer TO_BE_REGISTERED; static final Integer TO_BE_RESERVED; static final Integer IS_REGISTERED; static final Integer IS_RESERVED; static final Integer UPDATE_RESERVED; static final Integer UPDATE_REGISTERED; static final Integer UPDATE_BEFORE_REGISTRATION; static final Integer TO_BE_DELETED; static final Integer DELETED; }
@Test public void testMintDOI() throws SQLException, AuthorizeException, IOException, IllegalAccessException, IdentifierException, WorkflowException { Item item = newItem(); String doi = null; try { doi = provider.mint(context, item); } catch(IdentifierException e) { e.printStackTrace(); fail("Got an IdentifierException: " + e.getMessage()); } assertNotNull("Minted DOI is null!", doi); assertFalse("Minted DOI is empty!", doi.isEmpty()); try { doiService.formatIdentifier(doi); } catch (Exception e) { e.printStackTrace(); fail("Minted an unrecognizable DOI: " + e.getMessage()); } }
@Test public void testMint_returns_existing_DOI() throws SQLException, AuthorizeException, IOException, IdentifierException, WorkflowException, IllegalAccessException { Item item = newItem(); String doi = this.createDOI(item, null, true); String retrievedDOI = provider.mint(context, item); assertNotNull("Minted DOI is null?!", retrievedDOI); assertEquals("Mint did not returned an existing DOI!", doi, retrievedDOI); }