Package org.dspace.identifier.ezid

Examples of org.dspace.identifier.ezid.EZIDResponse


    @Override
    public void register(Context context, DSpaceObject object, String identifier)
    {
        log.debug("register {} as {}", object, identifier);

        EZIDResponse response;
        try {
            EZIDRequest request = requestFactory.getInstance(loadAuthority(),
                    loadUser(), loadPassword());
            response = request.create(identifier, crosswalkMetadata(object));
        } catch (IdentifierException | IOException | URISyntaxException e) {
            log.error("Identifier '{}' not registered:  {}", identifier, e.getMessage());
            return;
        }

        if (response.isSuccess())
        {
            try {
                object.addMetadata(MD_SCHEMA, DOI_ELEMENT, DOI_QUALIFIER, null,
                        idToDOI(identifier));
                object.update();
                context.commit();
                log.info("registered {}", identifier);
            } catch (SQLException | AuthorizeException | IdentifierException ex) {
                // TODO throw new IdentifierException("New identifier not stored", ex);
                log.error("New identifier not stored", ex);
            }
        }
        else
        {
            log.error("Identifier '{}' not registered -- EZID returned: {}",
                    identifier, response.getEZIDStatusValue());
        }
    }
View Full Code Here


    public void reserve(Context context, DSpaceObject dso, String identifier)
            throws IdentifierException
    {
        log.debug("reserve {}", identifier);

        EZIDResponse response;
        try {
            EZIDRequest request = requestFactory.getInstance(loadAuthority(),
                    loadUser(), loadPassword());
            Map<String, String> metadata = crosswalkMetadata(dso);
            metadata.put("_status", "reserved");
            response = request.create(identifier, metadata);
        } catch (IOException | URISyntaxException e) {
            log.error("Identifier '{}' not registered:  {}", identifier, e.getMessage());
            return;
        }

        if (response.isSuccess())
        {
            dso.addMetadata(MD_SCHEMA, DOI_ELEMENT, DOI_QUALIFIER, null, idToDOI(identifier));
            try {
                dso.update();
                context.commit();
                log.info("reserved {}", identifier);
            } catch (SQLException | AuthorizeException ex) {
                throw new IdentifierException("New identifier not stored", ex);
            }
        }
        else
        {
            log.error("Identifier '{}' not registered -- EZID returned: {}",
                    identifier, response.getEZIDStatusValue());
        }
    }
View Full Code Here

            log.error(ex.getMessage());
            throw new IdentifierException("DOI request not sent:  " + ex.getMessage());
        }

        // Send the request
        EZIDResponse response;
        try
        {
            response = request.mint(crosswalkMetadata(dso));
        } catch (IOException | URISyntaxException ex) {
            log.error("Failed to send EZID request:  {}", ex.getMessage());
            throw new IdentifierException("DOI request not sent:  " + ex.getMessage());
        }

        // Good response?
        if (HttpURLConnection.HTTP_CREATED != response.getHttpStatusCode())
            {
                log.error("EZID server responded:  {} {}: {}",
                        new String[] {
                            String.valueOf(response.getHttpStatusCode()),
                            response.getHttpReasonPhrase(),
                            response.getEZIDStatusValue()
                                    });
                throw new IdentifierException("DOI not created:  "
                        + response.getHttpReasonPhrase()
                        + ":  "
                        + response.getEZIDStatusValue());
            }

  // Extract the DOI from the content blob
        if (response.isSuccess())
        {
            String value = response.getEZIDStatusValue();
            int end = value.indexOf('|'); // Following pipe is "shadow ARK"
            if (end < 0)
            {
                end = value.length();
            }
            String doi = value.substring(0, end).trim();
            log.info("Created {}", doi);
            return doi;
        }
        else
        {
            log.error("EZID responded:  {}", response.getEZIDStatusValue());
            throw new IdentifierException("No DOI returned");
        }
    }
View Full Code Here

            {
                remainder.add(id.value);
                continue;
            }

            EZIDResponse response;
            try {
                EZIDRequest request = requestFactory.getInstance(loadAuthority(),
                        loadUser(), loadPassword());
                response = request.delete(DOIToId(id.value));
            } catch (URISyntaxException e) {
                log.error("Bad URI in metadata value:  {}", e.getMessage());
                remainder.add(id.value);
                skipped++;
                continue;
            } catch (IOException e) {
                log.error("Failed request to EZID:  {}", e.getMessage());
                remainder.add(id.value);
                skipped++;
                continue;
            }
            if (!response.isSuccess())
            {
                log.error("Unable to delete {} from DataCite:  {}", id.value,
                        response.getEZIDStatusValue());
                remainder.add(id.value);
                skipped++;
                continue;
            }
            log.info("Deleted {}", id.value);
View Full Code Here

            {
                remainder.add(id.value);
                continue;
            }

            EZIDResponse response;
            try {
                EZIDRequest request = requestFactory.getInstance(loadAuthority(),
                        loadUser(), loadPassword());
                response = request.delete(DOIToId(id.value));
            } catch (URISyntaxException e) {
                log.error("Bad URI in metadata value {}:  {}", id.value, e.getMessage());
                remainder.add(id.value);
                skipped++;
                continue;
            } catch (IOException e) {
                log.error("Failed request to EZID:  {}", e.getMessage());
                remainder.add(id.value);
                skipped++;
                continue;
            }

            if (!response.isSuccess())
            {
                log.error("Unable to delete {} from DataCite:  {}", id.value,
                        response.getEZIDStatusValue());
                remainder.add(id.value);
                skipped++;
                continue;
            }
            log.info("Deleted {}", id.value);
View Full Code Here

TOP

Related Classes of org.dspace.identifier.ezid.EZIDResponse

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.