Interface CreativeCommonsService

  • All Known Implementing Classes:
    CreativeCommonsServiceImpl

    public interface CreativeCommonsService
    Service interface class for the Creative commons licensing. The implementation of this class is responsible for all business logic calls for the Creative commons licensing and is autowired by spring
    Author:
    kevinvandevelde at atmire.com
    • Method Detail

      • setLicenseRDF

        void setLicenseRDF​(Context context,
                           Item item,
                           String licenseRdf)
                    throws SQLException,
                           IOException,
                           AuthorizeException
        setLicenseRDF CC Web Service method for setting the RDF bitstream
        Parameters:
        context - The relevant DSpace Context.
        item - The item to set license on.
        licenseRdf - license RDF string
        Throws:
        IOException - A general class of exceptions produced by failed or interrupted I/O operations.
        SQLException - An exception that provides information on a database access error or other errors.
        AuthorizeException - Exception indicating the current user of the context does not have permission to perform a particular action.
      • setLicense

        void setLicense​(Context context,
                        Item item,
                        InputStream licenseStm,
                        String mimeType)
                 throws SQLException,
                        IOException,
                        AuthorizeException
        Used by DSpaceMetsIngester
        Parameters:
        context - The relevant DSpace Context.
        item - The item to set license on.
        licenseStm - InputStream with the license text.
        mimeType - License text file MIME type ("text/xml", "text/rdf" or generic)
        Throws:
        SQLException - if database error An exception that provides information on a database access error or other errors.
        IOException - if IO error A general class of exceptions produced by failed or interrupted I/O operations.
        AuthorizeException - if authorization error Exception indicating the current user of the context does not have permission to perform a particular action. * // PATCHED 12/01 FROM JIRA re: mimetypes for CCLicense and License RDF wjb
      • getLicenseURI

        String getLicenseURI​(Item item)
        Returns the stored license uri of the item
        Parameters:
        item - - The item for which to retrieve the stored license uri
        Returns:
        the stored license uri of the item
      • getLicenseName

        String getLicenseName​(Item item)
        Returns the stored license name of the item
        Parameters:
        item - - The item for which to retrieve the stored license name
        Returns:
        the stored license name of the item
      • getLicenseRdfBitstream

        Bitstream getLicenseRdfBitstream​(Item item)
                                  throws SQLException,
                                         IOException,
                                         AuthorizeException
        Get Creative Commons license RDF, returning Bitstream object.
        Parameters:
        item - bitstream's parent item
        Returns:
        bitstream or null.
        Throws:
        IOException - A general class of exceptions produced by failed or interrupted I/O operations.
        SQLException - An exception that provides information on a database access error or other errors.
        AuthorizeException - Exception indicating the current user of the context does not have permission to perform a particular action.
      • getLicenseTextBitstream

        @Deprecated
        Bitstream getLicenseTextBitstream​(Item item)
                                   throws SQLException,
                                          IOException,
                                          AuthorizeException
        Deprecated.
        the bitstream with the license in the textual format it is no longer stored (see https://jira.duraspace.org/browse/DS-2604)
        Get Creative Commons license Text, returning Bitstream object.
        Parameters:
        item - bitstream's parent item
        Returns:
        bitstream or null.
        Throws:
        IOException - A general class of exceptions produced by failed or interrupted I/O operations.
        SQLException - An exception that provides information on a database access error or other errors.
        AuthorizeException - Exception indicating the current user of the context does not have permission to perform a particular action.
      • getCCField

        String getCCField​(String fieldId)
        Get a few license-specific properties. We expect these to be cached at least per server run.
        Parameters:
        fieldId - name of the property.
        Returns:
        its value.
      • fetchLicenseRDF

        String fetchLicenseRDF​(org.jdom.Document license)
        Apply same transformation on the document to retrieve only the most relevant part of the document passed as parameter. If no transformation is needed then take in consideration to empty the CreativeCommons.xml
        Parameters:
        license - - an element that could be contains as part of your content the license rdf
        Returns:
        the document license in textual format after the transformation
      • removeLicense

        void removeLicense​(Context context,
                           Item item)
                    throws AuthorizeException,
                           IOException,
                           SQLException
        Remove license information, delete also the bitstream
        Parameters:
        context - - DSpace Context
        item - - the item
        Throws:
        AuthorizeException - Exception indicating the current user of the context does not have permission to perform a particular action.
        IOException - A general class of exceptions produced by failed or interrupted I/O operations.
        SQLException - An exception that provides information on a database access error or other errors.
      • findAllCCLicenses

        List<CCLicense> findAllCCLicenses()
        Find all CC Licenses using the default language found in the configuration
        Returns:
        A list of available CC Licenses
      • findAllCCLicenses

        List<CCLicense> findAllCCLicenses​(String language)
        Find all CC Licenses for the provided language
        Parameters:
        language - - the language for which to find the CC Licenses
        Returns:
        A list of available CC Licenses for the provided language
      • findOne

        CCLicense findOne​(String id)
        Find the CC License corresponding to the provided ID using the default language found in the configuration
        Parameters:
        id - - the ID of the license to be found
        Returns:
        the corresponding license if found or null when not found
      • findOne

        CCLicense findOne​(String id,
                          String language)
        Find the CC License corresponding to the provided ID and provided language
        Parameters:
        id - - the ID of the license to be found
        language - - the language for which to find the CC License
        Returns:
        the corresponding license if found or null when not found
      • retrieveLicenseUri

        String retrieveLicenseUri​(String licenseId,
                                  Map<String,​String> answerMap)
        Retrieve the CC License URI for the provided license ID, based on the provided answers, using the default language found in the configuration
        Parameters:
        licenseId - - the ID of the license
        answerMap - - the answers to the different field questions
        Returns:
        the corresponding license URI
      • retrieveLicenseUri

        String retrieveLicenseUri​(String licenseId,
                                  String language,
                                  Map<String,​String> answerMap)
        Retrieve the CC License URI for the provided license ID and language based on the provided answers
        Parameters:
        licenseId - - the ID of the license
        language - - the language for which to find the CC License URI
        answerMap - - the answers to the different field questions
        Returns:
        the corresponding license URI
      • retrieveFullAnswerMap

        Map<String,​String> retrieveFullAnswerMap​(String licenseId,
                                                       Map<String,​String> answerMap)
        Retrieve the full answer map containing empty values when an answer for a field was not provided in the answerMap, using the default language found in the configuration
        Parameters:
        licenseId - - the ID of the license
        answerMap - - the answers to the different field questions
        Returns:
        the answerMap supplemented with all other license fields with a blank answer
      • retrieveFullAnswerMap

        Map<String,​String> retrieveFullAnswerMap​(String licenseId,
                                                       String language,
                                                       Map<String,​String> answerMap)
        Retrieve the full answer map for a provided language, containing empty values when an answer for a field was not provided in the answerMap.
        Parameters:
        licenseId - - the ID of the license
        language - - the language for which to retrieve the full answerMap
        answerMap - - the answers to the different field questions
        Returns:
        the answerMap supplemented with all other license fields with a blank answer for the provided language
      • verifyLicenseInformation

        boolean verifyLicenseInformation​(String licenseId,
                                         Map<String,​String> fullAnswerMap)
        Verify whether the answer map contains a valid response to all field questions and no answers that don't have a corresponding question in the license, using the default language found in the config to check the license
        Parameters:
        licenseId - - the ID of the license
        fullAnswerMap - - the answers to the different field questions
        Returns:
        whether the information is valid
      • verifyLicenseInformation

        boolean verifyLicenseInformation​(String licenseId,
                                         String language,
                                         Map<String,​String> fullAnswerMap)
        Verify whether the answer map contains a valid response to all field questions and no answers that don't have a corresponding question in the license, using the provided language to check the license
        Parameters:
        licenseId - - the ID of the license
        language - - the language for which to retrieve the full answerMap
        fullAnswerMap - - the answers to the different field questions
        Returns:
        whether the information is valid
      • updateLicense

        boolean updateLicense​(Context context,
                              String licenseUri,
                              Item item)
                       throws AuthorizeException,
                              SQLException
        Update the license of the item with a new one based on the provided license URI
        Parameters:
        context - - The relevant DSpace context
        licenseUri - - The license URI to be used in the update
        item - - The item for which to update the license
        Returns:
        true when the update was successful, false when not
        Throws:
        AuthorizeException
        SQLException