Class CCLookup


  • public class CCLookup
    extends Object
    A wrapper around Creative Commons REST web services.
    Author:
    Wendy Bossons
    • Constructor Detail

      • CCLookup

        public CCLookup()
        Constructs a new instance with the default web services root.
    • Method Detail

      • getLicenseId

        public String getLicenseId​(String class_label)
        Returns the id for a particular CCLicense label. Returns an empty string if no match is found.
        Parameters:
        class_label - The CCLicense label to find.
        Returns:
        Returns a String containing the License class ID if the label is found; if not found, returns an empty string.
        See Also:
        CCLicense
      • getLicenses

        public Collection<CCLicense> getLicenses​(String language)
        Queries the web service for the available licenses.
        Parameters:
        language - The language to request labels and description strings in.
        Returns:
        Returns a Map of CCLicense objects.
        See Also:
        Map, CCLicense
      • getLicenseFields

        public Collection<CCLicenseField> getLicenseFields​(String license,
                                                           String language)
        Queries the web service for a set of licenseFields for a particular license class.
        Parameters:
        license - A String specifying the CCLicense identifier to retrieve fields for.
        language - the locale string
        Returns:
        A Collection of LicenseField objects.
        See Also:
        CCLicense
      • issue

        public void issue​(String licenseId,
                          Map answers,
                          String lang)
                   throws IOException
        Passes a set of "answers" to the web service and retrieves a license.
        Parameters:
        licenseId - The identifier of the license class being requested.
        answers - A Map containing the answers to the license fields; each key is the identifier of a LicenseField, with the value containing the user-supplied answer.
        lang - The language to request localized elements in.
        Throws:
        IOException - if IO error
        See Also:
        CCLicense, Map
      • issue

        public void issue​(String licenseURI)
                   throws IOException
        Passes a set of "answers" to the web service and retrieves a license.
        Parameters:
        licenseURI - The uri of the license. Note: does not support localization in 1.5 -- not yet
        Throws:
        IOException - if IO error
        See Also:
        CCLicense, Map
      • getLicenseUrl

        public String getLicenseUrl()
        Retrieves the URI for the license issued.
        Returns:
        A String containing the URI for the license issued.
      • getLicenseName

        public String getLicenseName()
        Retrieves the human readable name for the license issued.
        Returns:
        A String containing the license name.
      • getLicenseDocument

        public org.jdom.Document getLicenseDocument()
      • isSuccess

        public boolean isSuccess()
      • getErrorMessage

        public String getErrorMessage()