Class SHERPAService

java.lang.Object
org.dspace.app.sherpa.SHERPAService

public class SHERPAService extends Object
SHERPAService is responsible for making the HTTP call to the SHERPA v2 API for SHERPASubmitService. Note, this service is ported from DSpace 6 for the ability to search policies by ISSN There are also new DataProvider implementations provided for use as 'external sources' of journal and publisher data
Author:
Kim Shepherd
See Also:
  • Constructor Details

    • SHERPAService

      public SHERPAService()
  • Method Details

    • searchByJournalISSN

      @Cacheable(key="#query", condition="#query != null", cacheNames="sherpa.searchByJournalISSN") public SHERPAResponse searchByJournalISSN(String query)
      Search the SHERPA v2 API for a journal policy data using the supplied ISSN. If the API key is missing, or the HTTP response is non-OK or does not complete successfully, a simple error response will be returned. Otherwise, the response body will be passed to SHERPAResponse for parsing as JSON and the final result returned to the calling method
      Parameters:
      query - ISSN string to pass in an "issn equals" API query
      Returns:
      SHERPAResponse containing an error or journal policies
    • performPublisherRequest

      public SHERPAPublisherResponse performPublisherRequest(String type, String field, String predicate, String value, int start, int limit)
      Perform an API request to the SHERPA v2 API - this could be a search or a get for any entity type but the return object here must be a SHERPAPublisherResponse not the journal-centric SHERPAResponse For more information about the type, field and predicate arguments, see the SHERPA v2 API documentation
      Parameters:
      type - entity type eg "publisher"
      field - field eg "issn" or "title"
      predicate - predicate eg "equals" or "contains-word"
      value - the actual value to search for (eg an ISSN or partial title)
      start - start / offset of search results
      limit - maximum search results to return
      Returns:
      SHERPAPublisherResponse object
    • performRequest

      public SHERPAResponse performRequest(String type, String field, String predicate, String value, int start, int limit)
      Perform an API request to the SHERPA v2 API - this could be a search or a get for any entity type For more information about the type, field and predicate arguments, see the SHERPA v2 API documentation
      Parameters:
      type - entity type eg "publication" or "publisher"
      field - field eg "issn" or "title"
      predicate - predicate eg "equals" or "contains-word"
      value - the actual value to search for (eg an ISSN or partial title)
      start - start / offset of search results
      limit - maximum search results to return
      Returns:
      SHERPAResponse object
    • constructHttpGet

      public org.apache.http.client.methods.HttpGet constructHttpGet(String type, String field, String predicate, String value) throws URISyntaxException
      Construct HTTP GET object for a "field,predicate,value" query with default start, limit eg. "title","contains-word","Lancet" or "issn","equals","1234-1234"
      Parameters:
      field - the field (issn, title, etc)
      predicate - the predicate (contains-word, equals, etc - see API docs)
      value - the query value itself
      Returns:
      HttpGet method which can then be executed by the client
      Throws:
      URISyntaxException - if the URL build fails
    • constructHttpGet

      public org.apache.http.client.methods.HttpGet constructHttpGet(String type, String field, String predicate, String value, int start, int limit) throws URISyntaxException
      Construct HTTP GET object for a "field,predicate,value" query eg. "title","contains-word","Lancet" or "issn","equals","1234-1234"
      Parameters:
      field - the field (issn, title, etc)
      predicate - the predicate (contains-word, equals, etc - see API docs)
      value - the query value itself
      start - row offset
      limit - number of results to return
      Returns:
      HttpGet object to be executed by the client
      Throws:
      URISyntaxException
    • prepareQuery

      public URI prepareQuery(String query, String endpoint, String apiKey) throws URISyntaxException
      Prepare the API query for execution by the HTTP client
      Parameters:
      query - ISSN query string
      endpoint - API endpoint (base URL)
      apiKey - API key parameter
      Returns:
      URI object
      Throws:
      URISyntaxException
    • setMaxNumberOfTries

      public void setMaxNumberOfTries(int maxNumberOfTries)
    • setSleepBetweenTimeouts

      public void setSleepBetweenTimeouts(long sleepBetweenTimeouts)
    • setTimeout

      public void setTimeout(int timeout)