Package org.dspace.license
Class CreativeCommonsServiceImpl
- java.lang.Object
-
- org.dspace.license.CreativeCommonsServiceImpl
-
- All Implemented Interfaces:
CreativeCommonsService,org.springframework.beans.factory.InitializingBean
public class CreativeCommonsServiceImpl extends Object implements CreativeCommonsService, org.springframework.beans.factory.InitializingBean
-
-
Field Summary
Fields Modifier and Type Field Description protected BitstreamFormatServicebitstreamFormatServiceprotected BitstreamServicebitstreamServiceprotected static StringBSN_LICENSE_RDFprotected static StringBSN_LICENSE_TEXTDeprecated.to make uniform JSPUI and XMLUI approach the bitstream with the license in the textual format it is no longer stored (see https://jira.duraspace.org/browse/DS-2604)protected static StringBSN_LICENSE_URLDeprecated.use the metadata retrieved atCreativeCommonsService.getCCField(String)(see https://jira .duraspace.org/browse/DS-2604)protected BundleServicebundleServiceprotected static StringCC_BS_SOURCEThe Bundle Nameprotected ConfigurationServiceconfigurationServiceprotected ItemServiceitemServiceprotected Templatestemplates-
Fields inherited from interface org.dspace.license.service.CreativeCommonsService
CC_BUNDLE_NAME
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedCreativeCommonsServiceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidafterPropertiesSet()StringfetchLicenseRDF(org.jdom.Document license)Apply same transformation on the document to retrieve only the most relevant part of the document passed as parameter.protected BitstreamgetBitstream(Item item, String bitstream_name)This helper method retrieves the bytes of a bitstream for an item under the CC bundle, with the given bitstream nameprotected byte[]getBytesFromBitstream(Context context, Item item, String bitstream_name)protected BundlegetCcBundle(Context context, Item item)LicenseMetadataValuegetCCField(String fieldId)Returns a metadata field handle for given field IdStringgetLicenseRDF(Context context, Item item)BitstreamgetLicenseRdfBitstream(Item item)Get Creative Commons license RDF, returning Bitstream object.BitstreamgetLicenseTextBitstream(Item item)Deprecated.StringgetLicenseURL(Context context, Item item)protected StringgetStringFromBitstream(Context context, Item item, String bitstream_name)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 RAMbooleanhasLicense(Context context, Item item)booleanisEnabled()Simple accessor for enabling of CCvoidremoveLicense(Context context, Item item)voidremoveLicense(Context context, LicenseMetadataValue uriField, LicenseMetadataValue nameField, Item item)Remove license information, delete also the bitstreamprotected voidsetBitstreamFromBytes(Context context, Item item, Bundle bundle, String bitstream_name, BitstreamFormat format, byte[] bytes)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 RAMvoidsetLicense(Context context, Item item, InputStream licenseStm, String mimeType)Used by DSpaceMetsIngestervoidsetLicenseRDF(Context context, Item item, String licenseRdf)setLicenseRDF CC Web Service method for setting the RDF bitstream
-
-
-
Field Detail
-
CC_BS_SOURCE
protected static final String CC_BS_SOURCE
The Bundle Name- See Also:
- Constant Field Values
-
BSN_LICENSE_URL
@Deprecated protected static final String BSN_LICENSE_URL
Deprecated.use the metadata retrieved atCreativeCommonsService.getCCField(String)(see https://jira .duraspace.org/browse/DS-2604)Some BitStream Names (BSN)- See Also:
- Constant Field Values
-
BSN_LICENSE_TEXT
@Deprecated protected static final String BSN_LICENSE_TEXT
Deprecated.to make uniform JSPUI and XMLUI approach the bitstream with the license in the textual format it is no longer stored (see https://jira.duraspace.org/browse/DS-2604)- See Also:
- Constant Field Values
-
BSN_LICENSE_RDF
protected static final String BSN_LICENSE_RDF
- See Also:
- Constant Field Values
-
templates
protected Templates templates
-
bitstreamService
@Autowired(required=true) protected BitstreamService bitstreamService
-
bitstreamFormatService
@Autowired(required=true) protected BitstreamFormatService bitstreamFormatService
-
bundleService
@Autowired(required=true) protected BundleService bundleService
-
itemService
@Autowired(required=true) protected ItemService itemService
-
configurationService
protected ConfigurationService configurationService
-
-
Method Detail
-
afterPropertiesSet
public void afterPropertiesSet() throws Exception- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean- Throws:
Exception
-
isEnabled
public boolean isEnabled()
Description copied from interface:CreativeCommonsServiceSimple accessor for enabling of CC- Specified by:
isEnabledin interfaceCreativeCommonsService- Returns:
- is CC enabled?
-
getCcBundle
protected Bundle getCcBundle(Context context, Item item) throws SQLException, AuthorizeException, IOException
-
setLicenseRDF
public void setLicenseRDF(Context context, Item item, String licenseRdf) throws SQLException, IOException, AuthorizeException
Description copied from interface:CreativeCommonsServicesetLicenseRDF CC Web Service method for setting the RDF bitstream- Specified by:
setLicenseRDFin interfaceCreativeCommonsService- 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:CreativeCommonsServiceUsed by DSpaceMetsIngester- Specified by:
setLicensein interfaceCreativeCommonsService- 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
-
removeLicense
public void removeLicense(Context context, Item item) throws SQLException, IOException, AuthorizeException
- Specified by:
removeLicensein interfaceCreativeCommonsService- Throws:
SQLExceptionIOExceptionAuthorizeException
-
hasLicense
public boolean hasLicense(Context context, Item item) throws SQLException, IOException
- Specified by:
hasLicensein interfaceCreativeCommonsService- Throws:
SQLExceptionIOException
-
getLicenseRDF
public String getLicenseRDF(Context context, Item item) throws SQLException, IOException, AuthorizeException
- Specified by:
getLicenseRDFin interfaceCreativeCommonsService- Throws:
SQLExceptionIOExceptionAuthorizeException
-
getLicenseRdfBitstream
public Bitstream getLicenseRdfBitstream(Item item) throws SQLException, IOException, AuthorizeException
Description copied from interface:CreativeCommonsServiceGet Creative Commons license RDF, returning Bitstream object.- Specified by:
getLicenseRdfBitstreamin interfaceCreativeCommonsService- Parameters:
item- bitstream's parent item- Returns:
- bitstream or null.
- 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.
-
getLicenseTextBitstream
@Deprecated public Bitstream getLicenseTextBitstream(Item item) throws SQLException, IOException, AuthorizeException
Deprecated.Description copied from interface:CreativeCommonsServiceGet Creative Commons license Text, returning Bitstream object.- Specified by:
getLicenseTextBitstreamin interfaceCreativeCommonsService- Parameters:
item- bitstream's parent item- Returns:
- bitstream or null.
- 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.
-
getLicenseURL
public String getLicenseURL(Context context, Item item) throws SQLException, IOException, AuthorizeException
- Specified by:
getLicenseURLin interfaceCreativeCommonsService- Throws:
SQLExceptionIOExceptionAuthorizeException
-
fetchLicenseRDF
public String fetchLicenseRDF(org.jdom.Document license)
Description copied from interface:CreativeCommonsServiceApply 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:
fetchLicenseRDFin interfaceCreativeCommonsService- 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 itembundle- parent bundlebitstream_name- bitstream name to setformat- bitstream formatbytes- 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 itembitstream_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 itembitstream_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.
-
getBytesFromBitstream
protected byte[] getBytesFromBitstream(Context context, Item item, String bitstream_name) throws SQLException, IOException, AuthorizeException
-
getCCField
public LicenseMetadataValue getCCField(String fieldId)
Returns a metadata field handle for given field Id- Specified by:
getCCFieldin interfaceCreativeCommonsService- Parameters:
fieldId- name of the property.- Returns:
- its value.
-
removeLicense
public void removeLicense(Context context, LicenseMetadataValue uriField, LicenseMetadataValue nameField, Item item) throws AuthorizeException, IOException, SQLException
Description copied from interface:CreativeCommonsServiceRemove license information, delete also the bitstream- Specified by:
removeLicensein interfaceCreativeCommonsService- Parameters:
context- - DSpace ContexturiField- - the metadata field for license urinameField- - the metadata field for license nameitem- - 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.
-
-