Class CreativeCommonsServiceImpl

    • Constructor Detail

      • CreativeCommonsServiceImpl

        protected CreativeCommonsServiceImpl()
    • Method Detail

      • afterPropertiesSet

        public void afterPropertiesSet()
                                throws Exception
        Specified by:
        afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
        Throws:
        Exception
      • setLicenseRDF

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

        public void setLicense​(Context context,
                               Item item,
                               InputStream licenseStm,
                               String mimeType)
                        throws SQLException,
                               IOException,
                               AuthorizeException
        Description copied from interface: CreativeCommonsService
        Used by DSpaceMetsIngester
        Specified by:
        setLicense in interface CreativeCommonsService
        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

        public String getLicenseURI​(Item item)
        Returns the stored license uri of the item
        Specified by:
        getLicenseURI in interface CreativeCommonsService
        Parameters:
        item - - The item for which to retrieve the stored license uri
        Returns:
        the stored license uri of the item
      • getLicenseName

        public String getLicenseName​(Item item)
        Returns the stored license name of the item
        Specified by:
        getLicenseName in interface CreativeCommonsService
        Parameters:
        item - - The item for which to retrieve the stored license name
        Returns:
        the stored license name of the item
      • fetchLicenseRDF

        public String fetchLicenseRDF​(org.jdom.Document license)
        Description copied from interface: CreativeCommonsService
        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
        Specified by:
        fetchLicenseRDF in interface CreativeCommonsService
        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
      • setBitstreamFromBytes

        protected void setBitstreamFromBytes​(Context context,
                                             Item item,
                                             Bundle bundle,
                                             String bitstream_name,
                                             BitstreamFormat format,
                                             byte[] bytes)
                                      throws SQLException,
                                             IOException,
                                             AuthorizeException
        This helper method takes some bytes and stores them as a bitstream for an item, under the CC bundle, with the given bitstream name Note: This helper method assumes that the CC bitstreams are short and easily expressed as byte arrays in RAM
        Parameters:
        context - The relevant DSpace Context.
        item - parent item
        bundle - parent bundle
        bitstream_name - bitstream name to set
        format - bitstream format
        bytes - bitstream data
        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.
      • getStringFromBitstream

        protected String getStringFromBitstream​(Context context,
                                                Item item,
                                                String bitstream_name)
                                         throws SQLException,
                                                IOException,
                                                AuthorizeException
        This helper method wraps a String around a byte array returned from the bitstream method further down Note: This helper method assumes that the CC bitstreams are short and easily expressed as byte arrays in RAM
        Parameters:
        context - The relevant DSpace Context.
        item - parent item
        bitstream_name - bitstream name to set
        Returns:
        the bitstream as 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.
      • getBitstream

        protected Bitstream getBitstream​(Item item,
                                         String bitstream_name)
                                  throws SQLException,
                                         IOException,
                                         AuthorizeException
        This helper method retrieves the bytes of a bitstream for an item under the CC bundle, with the given bitstream name
        Parameters:
        item - parent item
        bitstream_name - bitstream name to set
        Returns:
        the bitstream
        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

        public String getCCField​(String fieldId)
        Returns a metadata field handle for given field Id
        Specified by:
        getCCField in interface CreativeCommonsService
        Parameters:
        fieldId - name of the property.
        Returns:
        its value.
      • findAllCCLicenses

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

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

        public CCLicense findOne​(String id,
                                 String language)
        Find the CC License corresponding to the provided ID and provided language
        Specified by:
        findOne in interface CreativeCommonsService
        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

        public 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
        Specified by:
        retrieveLicenseUri in interface CreativeCommonsService
        Parameters:
        licenseId - - the ID of the license
        answerMap - - the answers to the different field questions
        Returns:
        the corresponding license URI
      • retrieveLicenseUri

        public 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
        Specified by:
        retrieveLicenseUri in interface CreativeCommonsService
        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
      • verifyLicenseInformation

        public 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
        Specified by:
        verifyLicenseInformation in interface CreativeCommonsService
        Parameters:
        licenseId - - the ID of the license
        fullAnswerMap - - the answers to the different field questions
        Returns:
        whether the information is valid
      • verifyLicenseInformation

        public 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
        Specified by:
        verifyLicenseInformation in interface CreativeCommonsService
        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
      • retrieveFullAnswerMap

        public 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
        Specified by:
        retrieveFullAnswerMap in interface CreativeCommonsService
        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

        public 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.
        Specified by:
        retrieveFullAnswerMap in interface CreativeCommonsService
        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