DS-2604 port from XMLUI to JSPUI the approach to reach the Creative Commons service (via REST API)

This commit is contained in:
Luigi Andrea Pascarelli
2016-09-22 15:28:15 +02:00
parent 4e1cad0109
commit 9086a1ecf2
16 changed files with 509 additions and 488 deletions

View File

@@ -22,7 +22,10 @@ import java.util.Map;
import java.util.NoSuchElementException;
import org.apache.log4j.Logger;
import org.dspace.license.factory.LicenseServiceFactory;
import org.dspace.license.service.CreativeCommonsService;
import org.dspace.services.ConfigurationService;
import org.dspace.services.factory.DSpaceServicesFactory;
import org.jaxen.JaxenException;
import org.jaxen.jdom.JDOMXPath;
import org.jdom.Attribute;
@@ -30,10 +33,6 @@ import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;
import org.jdom.output.XMLOutputter;
import org.dspace.services.ConfigurationService;
import org.dspace.services.factory.DSpaceServicesFactory;
/**
@@ -58,7 +57,9 @@ public class CCLookup {
private SAXBuilder parser = new SAXBuilder();
private List<CCLicense> licenses = new ArrayList<CCLicense>();
private List<CCLicenseField> licenseFields = new ArrayList<CCLicenseField>();
protected CreativeCommonsService creativeCommonsService = LicenseServiceFactory.getInstance().getCreativeCommonsService();
/**
* Constructs a new instance with the default web services root.
*
@@ -406,26 +407,14 @@ public class CCLookup {
public String getRdf()
throws IOException {
String myString = null;
java.io.ByteArrayOutputStream outputstream = new java.io.ByteArrayOutputStream();
String result = "";
try {
outputstream.write("<result>\n".getBytes());
JDOMXPath xpathRdf = new JDOMXPath("//result/rdf");
JDOMXPath xpathLicenseRdf = new JDOMXPath("//result/licenserdf");
XMLOutputter xmloutputter = new XMLOutputter();
Element rdfParent = ((Element)xpathRdf.selectSingleNode(this.license_doc));
xmloutputter.output(rdfParent, outputstream);
Element licenseRdfParent = ((Element)xpathLicenseRdf.selectSingleNode(this.license_doc));
outputstream.write("\n".getBytes());
xmloutputter.output(licenseRdfParent, outputstream);
outputstream.write("\n</result>\n".getBytes());
result = creativeCommonsService.fetchLicenseRDF(license_doc);
} catch (Exception e) {
log.warn("An error occurred getting the rdf . . ." + e.getMessage() );
setSuccess(false);
} finally {
outputstream.close();
return outputstream.toString();
}
}
return result;
}
public boolean isSuccess() {

View File

@@ -7,9 +7,11 @@
*/
package org.dspace.license;
import java.io.*;
import java.net.URL;
import java.net.URLConnection;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringWriter;
import java.sql.SQLException;
import java.util.List;
@@ -35,6 +37,10 @@ import org.dspace.core.ConfigurationManager;
import org.dspace.core.Context;
import org.dspace.core.Utils;
import org.dspace.license.service.CreativeCommonsService;
import org.dspace.services.ConfigurationService;
import org.dspace.services.factory.DSpaceServicesFactory;
import org.jdom.Document;
import org.jdom.transform.JDOMSource;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
@@ -52,8 +58,10 @@ public class CreativeCommonsServiceImpl implements CreativeCommonsService, Initi
/**
* Some BitStream Names (BSN)
*/
@Deprecated
protected static final String BSN_LICENSE_URL = "license_url";
@Deprecated
protected static final String BSN_LICENSE_TEXT = "license_text";
protected static final String BSN_LICENSE_RDF = "license_rdf";
@@ -68,10 +76,12 @@ public class CreativeCommonsServiceImpl implements CreativeCommonsService, Initi
protected BundleService bundleService;
@Autowired(required = true)
protected ItemService itemService;
protected ConfigurationService configurationService = DSpaceServicesFactory.getInstance().getConfigurationService();
protected CreativeCommonsServiceImpl()
{
}
@Override
@@ -79,8 +89,8 @@ public class CreativeCommonsServiceImpl implements CreativeCommonsService, Initi
{
// if defined, set a proxy server for http requests to Creative
// Commons site
String proxyHost = ConfigurationManager.getProperty("http.proxy.host");
String proxyPort = ConfigurationManager.getProperty("http.proxy.port");
String proxyHost = configurationService.getProperty("http.proxy.host");
String proxyPort = configurationService.getProperty("http.proxy.port");
if (StringUtils.isNotBlank(proxyHost) && StringUtils.isNotBlank(proxyPort))
{
@@ -134,37 +144,6 @@ public class CreativeCommonsServiceImpl implements CreativeCommonsService, Initi
setBitstreamFromBytes(context, item, bundle, BSN_LICENSE_RDF, bs_rdf_format, licenseRdf.getBytes());
}
@Override
public void setLicense(Context context, Item item,
String cc_license_url) throws SQLException, IOException,
AuthorizeException
{
Bundle bundle = getCcBundle(context, item);
// get some more information
String license_text = fetchLicenseText(cc_license_url);
String license_rdf = fetchLicenseRDF(cc_license_url);
// set the formats
BitstreamFormat bs_url_format = bitstreamFormatService.findByShortDescription(
context, "License");
BitstreamFormat bs_text_format = bitstreamFormatService.findByShortDescription(
context, "CC License");
BitstreamFormat bs_rdf_format = bitstreamFormatService.findByShortDescription(
context, "RDF XML");
// set the URL bitstream
setBitstreamFromBytes(context, item, bundle, BSN_LICENSE_URL, bs_url_format,
cc_license_url.getBytes());
// set the license text bitstream
setBitstreamFromBytes(context, item, bundle, BSN_LICENSE_TEXT, bs_text_format,
license_text.getBytes());
// set the RDF bitstream
setBitstreamFromBytes(context, item, bundle, BSN_LICENSE_RDF, bs_rdf_format,
license_rdf.getBytes());
}
@Override
public void setLicense(Context context, Item item,
@@ -223,8 +202,7 @@ public class CreativeCommonsServiceImpl implements CreativeCommonsService, Initi
// verify it has correct contents
try
{
if ((getLicenseURL(context, item) == null) || (getLicenseText(context, item) == null)
|| (getLicenseRDF(context, item) == null))
if ((getLicenseURL(context, item) == null))
{
return false;
}
@@ -237,20 +215,6 @@ public class CreativeCommonsServiceImpl implements CreativeCommonsService, Initi
return true;
}
@Override
public String getLicenseURL(Context context, Item item) throws SQLException,
IOException, AuthorizeException
{
return getStringFromBitstream(context, item, BSN_LICENSE_URL);
}
@Override
public String getLicenseText(Context context, Item item) throws SQLException,
IOException, AuthorizeException
{
return getStringFromBitstream(context, item, BSN_LICENSE_TEXT);
}
@Override
public String getLicenseRDF(Context context, Item item) throws SQLException,
IOException, AuthorizeException
@@ -265,6 +229,7 @@ public class CreativeCommonsServiceImpl implements CreativeCommonsService, Initi
return getBitstream(item, BSN_LICENSE_RDF);
}
@Deprecated
@Override
public Bitstream getLicenseTextBitstream(Item item) throws SQLException,
IOException, AuthorizeException
@@ -273,39 +238,25 @@ public class CreativeCommonsServiceImpl implements CreativeCommonsService, Initi
}
@Override
public String fetchLicenseRdf(String ccResult) {
StringWriter result = new StringWriter();
try {
InputStream inputstream = new ByteArrayInputStream(ccResult.getBytes("UTF-8"));
templates.newTransformer().transform(new StreamSource(inputstream), new StreamResult(result));
} catch (TransformerException te) {
throw new RuntimeException("Transformer exception " + te.getMessage(), te);
} catch (IOException ioe) {
throw new RuntimeException("IOexception " + ioe.getCause().toString(), ioe);
} finally {
return result.getBuffer().toString();
}
}
public String getLicenseURL(Context context, Item item) throws SQLException, IOException, AuthorizeException {
String licenseUri = getCCField("uri").ccItemValue(item);
if (StringUtils.isNotBlank(licenseUri)) {
return licenseUri;
}
//backward compatibility
return getStringFromBitstream(context, item, BSN_LICENSE_URL);
}
@Override
public String fetchLicenseText(String license_url)
{
String text_url = license_url;
byte[] urlBytes = fetchURL(text_url);
return (urlBytes != null) ? new String(urlBytes) : "";
}
@Override
public String fetchLicenseRDF(String license_url)
public String fetchLicenseRDF(Document license)
{
StringWriter result = new StringWriter();
try
{
templates.newTransformer().transform(
new StreamSource(license_url + "rdf"),
new JDOMSource(license),
new StreamResult(result)
);
}
@@ -408,40 +359,32 @@ public class CreativeCommonsServiceImpl implements CreativeCommonsService, Initi
return baos.toByteArray();
}
/**
* Fetch the contents of a URL
*/
protected byte[] fetchURL(String url_string)
{
try
{
String line = "";
URL url = new URL(url_string);
URLConnection connection = url.openConnection();
InputStream inputStream = connection.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
StringBuilder sb = new StringBuilder();
while ((line = reader.readLine()) != null)
{
sb.append(line);
}
return sb.toString().getBytes();
}
catch (Exception exc)
{
log.error(exc.getMessage());
return null;
}
}
/**
* Returns a metadata field handle for given field Id
*/
@Override
public LicenseMetadataValue getCCField(String fieldId)
{
return new LicenseMetadataValue(ConfigurationManager.getProperty("cc.license." + fieldId));
return new LicenseMetadataValue(configurationService.getProperty("cc.license." + fieldId));
}
@Override
public void removeLicense(Context context, LicenseMetadataValue uriField,
LicenseMetadataValue nameField, Item item) throws AuthorizeException, IOException, SQLException {
// only remove any previous licenses
String licenseUri = uriField.ccItemValue(item);
if (licenseUri != null) {
uriField.removeItemValue(context, item, licenseUri);
if (configurationService.getBooleanProperty("cc.submit.setname"))
{
String licenseName = nameField.keyedItemValue(item, licenseUri);
nameField.removeItemValue(context, item, licenseName);
}
if (configurationService.getBooleanProperty("cc.submit.addbitstream"))
{
removeLicense(context, item);
}
}
}
}

View File

@@ -12,6 +12,7 @@ import org.dspace.content.Bitstream;
import org.dspace.content.Item;
import org.dspace.core.Context;
import org.dspace.license.LicenseMetadataValue;
import org.jdom.Document;
import java.io.IOException;
import java.io.InputStream;
@@ -39,12 +40,6 @@ public interface CreativeCommonsService {
*/
public void setLicenseRDF(Context context, Item item, String licenseRdf) throws SQLException, IOException, AuthorizeException;
/**
* This is a bit of the "do-the-right-thing" method for CC stuff in an item
*/
public void setLicense(Context context, Item item,
String cc_license_url) throws SQLException, IOException,
AuthorizeException;
/**
* Used by DSpaceMetsIngester
@@ -72,9 +67,6 @@ public interface CreativeCommonsService {
public String getLicenseURL(Context context, Item item) throws SQLException,
IOException, AuthorizeException;
public String getLicenseText(Context context, Item item) throws SQLException,
IOException, AuthorizeException;
public String getLicenseRDF(Context context, Item item) throws SQLException,
IOException, AuthorizeException;
@@ -87,27 +79,20 @@ public interface CreativeCommonsService {
/**
* Get Creative Commons license Text, returning Bitstream object.
* @Deprecated
* @return bitstream or null.
*/
public Bitstream getLicenseTextBitstream(Item item) throws SQLException,
IOException, AuthorizeException;
public String fetchLicenseRdf(String ccResult);
/**
*
* The next two methods are old CC.
* Remains until prev. usages are eliminated.
* @Deprecated
*
*/
/**
* Get a few license-specific properties. We expect these to be cached at
* least per server run.
*/
public String fetchLicenseText(String license_url);
public String fetchLicenseRDF(String license_url);
public LicenseMetadataValue getCCField(String fieldId);
public String fetchLicenseRDF(Document license);
public void removeLicense(Context context, LicenseMetadataValue uriField,
LicenseMetadataValue nameField, Item item) throws AuthorizeException, IOException, SQLException;
}

View File

@@ -14,7 +14,6 @@ import org.apache.commons.lang3.*;
import javax.servlet.http.HttpSession;
import org.apache.log4j.Logger;
import org.dspace.app.util.SubmissionInfo;
import org.dspace.app.util.Util;
import org.dspace.authorize.AuthorizeException;
@@ -102,11 +101,6 @@ public class CCLicenseStep extends AbstractProcessingStep
session.setAttribute("inProgress", "TRUE");
// check what submit button was pressed in User Interface
String buttonPressed = Util.getSubmitButton(request, NEXT_BUTTON);
if ("submit_grant".equalsIgnoreCase(buttonPressed)
|| "submit_no_cc".equalsIgnoreCase(buttonPressed))
{
return processCC(context, request, response, subInfo);
}
String choiceButton = Util.getSubmitButton(request, SELECT_CHANGE);
Enumeration e = request.getParameterNames();
String isFieldRequired = "FALSE";
@@ -124,27 +118,10 @@ public class CCLicenseStep extends AbstractProcessingStep
{
Item item = subInfo.getSubmissionItem().getItem();
LicenseMetadataValue uriField = creativeCommonsService.getCCField("uri");
LicenseMetadataValue nameField = creativeCommonsService.getCCField("name");
String licenseUri = uriField.ccItemValue(item);
if (licenseUri != null)
//if (CreativeCommons.hasLicense(item, "dc", "rights", "uri", Item.ANY)
// && !CreativeCommons.getRightsURI(item, "dc", "rights", "uri", Item.ANY).equals(""))
{
//CreativeCommons.setItemMetadata(item, licenseURI, "dc", "rights", "uri", ConfigurationManager.getProperty("default.locale"));
uriField.removeItemValue(context, item, licenseUri);
if (configurationService.getBooleanProperty("cc.submit.setname"))
{
String licenseName = nameField.keyedItemValue(item, licenseUri);
nameField.removeItemValue(context, item, licenseName);
//CreativeCommons.setItemMetadata(item, CreativeCommons.getRightsName(item, "dc", "rights", null, Item.ANY), "dc", "rights", null, configurationService.getProperty("default.locale"));
}
if (configurationService.getBooleanProperty("cc.submit.addBitstream"))
{
creativeCommonsService.removeLicense(context, item);
}
removeRequiredAttributes(session);
itemService.update(context, item);
context.dispatchEvents();
}
return STATUS_COMPLETE;
}
@@ -154,7 +131,7 @@ public class CCLicenseStep extends AbstractProcessingStep
}
if (buttonPressed.equals(NEXT_BUTTON) || buttonPressed.equals(CANCEL_BUTTON) )
{
return processCCWS(context, request, response, subInfo);
return processCC(context, request, response, subInfo);
}
else
{
@@ -164,54 +141,6 @@ public class CCLicenseStep extends AbstractProcessingStep
}
}
/**
* Process the input from the CC license page
*
* @param context
* current DSpace context
* @param request
* current servlet request object
* @param response
* current servlet response object
* @param subInfo
* submission info object
*
* @return Status or error flag which will be processed by
* doPostProcessing() below! (if STATUS_COMPLETE or 0 is returned,
* no errors occurred!)
*/
protected int processCC(Context context, HttpServletRequest request,
HttpServletResponse response, SubmissionInfo subInfo)
throws ServletException, IOException, SQLException,
AuthorizeException
{
String buttonPressed = Util.getSubmitButton(request, NEXT_BUTTON);
// RLR hack - need to distinguish between progress bar real submission
// (if cc_license_url exists, then users has accepted the CC License)
String ccLicenseUrl = request.getParameter("cc_license_url");
if (buttonPressed.equals("submit_no_cc"))
{
// Skipping the CC license - remove any existing license selection
creativeCommonsService.removeLicense(context, subInfo.getSubmissionItem()
.getItem());
}
else if ((ccLicenseUrl != null) && (ccLicenseUrl.length() > 0))
{
Item item = subInfo.getSubmissionItem().getItem();
// save the CC license
creativeCommonsService.setLicense(context, item, ccLicenseUrl);
}
// commit changes
context.dispatchEvents();
// completed without errors
return STATUS_COMPLETE;
}
/**
* Process the input from the CC license page using CC Web service
@@ -230,7 +159,7 @@ public class CCLicenseStep extends AbstractProcessingStep
* doPostProcessing() below! (if STATUS_COMPLETE or 0 is returned,
* no errors occurred!)
*/
protected int processCCWS(Context context, HttpServletRequest request,
protected int processCC(Context context, HttpServletRequest request,
HttpServletResponse response, SubmissionInfo subInfo)
throws ServletException, IOException, SQLException,
AuthorizeException {
@@ -251,34 +180,25 @@ public class CCLicenseStep extends AbstractProcessingStep
LicenseMetadataValue nameField = creativeCommonsService.getCCField("name");
ccLookup.issue(licenseclass, map, configurationService.getProperty("cc.license.locale"));
Item item = subInfo.getSubmissionItem().getItem();
if (licenseclass.equals("xmlui.Submission.submit.CCLicenseStep.no_license"))
if (licenseclass.equals("webui.Submission.submit.CCLicenseStep.no_license"))
{
// only remove any previous licenses
String licenseUri = uriField.ccItemValue(item);
if (licenseUri != null) {
uriField.removeItemValue(context, item, licenseUri);
if (configurationService.getBooleanProperty("cc.submit.setname"))
{
String licenseName = nameField.keyedItemValue(item, licenseUri);
nameField.removeItemValue(context, item, licenseName);
}
if (configurationService.getBooleanProperty("cc.submit.addBitstream"))
{
creativeCommonsService.removeLicense(context, item);
}
itemService.update(context, item);
context.dispatchEvents();
removeRequiredAttributes(session);
}
creativeCommonsService.removeLicense(context, uriField, nameField, item);
itemService.update(context, item);
context.dispatchEvents();
removeRequiredAttributes(session);
return STATUS_COMPLETE;
}
else if (StringUtils.isBlank(licenseclass) || licenseclass.equals("xmlui.Submission.submit.CCLicenseStep.select_change"))
else if (StringUtils.isBlank(licenseclass) || licenseclass.equals("webui.Submission.submit.CCLicenseStep.select_change"))
{
removeRequiredAttributes(session);
return STATUS_COMPLETE;
}
else if (ccLookup.isSuccess())
{
creativeCommonsService.removeLicense(context, uriField, nameField, item);
uriField.addItemValue(context, item, ccLookup.getLicenseUrl());
if (configurationService.getBooleanProperty("cc.submit.addbitstream")) {
creativeCommonsService.setLicenseRDF(context, item, ccLookup.getRdf());
@@ -286,7 +206,8 @@ public class CCLicenseStep extends AbstractProcessingStep
if (configurationService.getBooleanProperty("cc.submit.setname")) {
nameField.addItemValue(context, item, ccLookup.getLicenseName());
}
itemService.update(context, item);
itemService.update(context, item);
context.dispatchEvents();
removeRequiredAttributes(session);
session.removeAttribute("inProgress");
@@ -303,7 +224,8 @@ public class CCLicenseStep extends AbstractProcessingStep
}
return STATUS_COMPLETE;
}
private void removeRequiredAttributes(HttpSession session) {
session.removeAttribute("ccError");
session.removeAttribute("isFieldRequired");

View File

@@ -1006,15 +1006,15 @@ jsp.submit.complete.info = Your submissio
jsp.submit.complete.again = Submit another item to the same collection
jsp.submit.complete.link = Go to My DSpace
jsp.submit.complete.title = Submission Complete!
jsp.submit.creative-commons.choice1 = Press the 'Next' button below to <em>keep</em> the license previously chosen.
jsp.submit.creative-commons.choice2 = Press the 'Skip Creative Commons' button below to <em>remove</em> the current choice, and forego a Creative Commons license.
jsp.submit.creative-commons.choice3 = Complete the selection process below to <em>replace</em> the current choice.
jsp.submit.creative-commons.heading = Submit: Use a Creative Commons License
jsp.submit.creative-commons.info1 = You have already chosen a Creative Commons license and added it to this item. You may:
jsp.submit.creative-commons.info2 = To license your Item under Creative Commons, follow the instructions below. You will be given an opportunity to review your selection. Follow the 'proceed' link to add the license. If you wish to omit a Creative Commons license, press the 'Skip Creative Commons' button.
jsp.submit.creative-commons.info3 = Your browser must support IFrames to use this feature
jsp.submit.creative-commons.skip.button = Skip Creative Commons &gt;
jsp.submit.creative-commons.info1 = If you wish, you may add a <a href="http://creativecommons.org/">Creative Commons</a> License to your item. <strong>Creative Commons licenses govern what people who read your work may then do with it.</strong></message>
jsp.submit.creative-commons.title = Use a Creative Commons License
jsp.submit.creative-commons.license = License Type
jsp.submit.creative-commons.select_change = Select or modify your license ...
jsp.submit.creative-commons.no_license = No Creative Commons License
jsp.submit.creative-commons.license.current = Current license
jsp.submit.edit-bitstream-access.title = Edit Bitstream Access
jsp.submit.edit-bitstream-access.heading = Edit Bitstream Access
jsp.submit.edit-bitstream-access.save.button = Save

View File

@@ -9,40 +9,42 @@
-->
<xsl:stylesheet version="1.1"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:old-cc="http://web.resource.org/cc/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
exclude-result-prefixes="old-cc">
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:cc="http://creativecommons.org/ns#"
xmlns:old-cc="http://web.resource.org/cc/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
exclude-result-prefixes="old-cc">
<xsl:output method="xml" indent="yes"/>
<!-- process incoming RDF, copy everything add our own statements for cc:Work -->
<xsl:template match="/rdf:RDF">
<rdf:RDF>
<xsl:copy-of select="@*"/>
<xsl:apply-templates select="cc:License"/>
</rdf:RDF>
</xsl:template>
<xsl:output method="xml" indent="yes" />
<!-- handle License element -->
<xsl:template match="cc:License">
<cc:Work rdf:about="">
<cc:license rdf:resource="{@rdf:about}"/>
</cc:Work>
<cc:License>
<xsl:copy-of select="@*"/>
<xsl:apply-templates select="node()"/>
</cc:License>
</xsl:template>
<!--
Identity transform
-->
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="/">
<xsl:apply-templates select="result/rdf/rdf:RDF" />
</xsl:template>
<!-- process incoming RDF, copy everything add our own statements for cc:Work -->
<xsl:template match="result/rdf/rdf:RDF">
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:cc="http://creativecommons.org/ns#">
<xsl:copy-of select="@*" />
<xsl:apply-templates select="cc:License" />
</rdf:RDF>
</xsl:template>
<!-- handle License element -->
<xsl:template match="cc:License">
<cc:Work rdf:about="">
<cc:license rdf:resource="{@rdf:about}" />
</cc:Work>
<cc:License>
<xsl:copy-of select="@*" />
<xsl:apply-templates select="node()" />
</cc:License>
</xsl:template>
<!-- Identity transform -->
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*" />
</xsl:copy>
</xsl:template>
</xsl:stylesheet>

View File

@@ -0,0 +1,77 @@
/**
* The contents of this file are subject to the license and copyright
* detailed in the LICENSE and NOTICE files at the root of the source
* tree and available online at
*
* http://www.dspace.org/license/
*/
package org.dspace.app.webui.json;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.dspace.authorize.AuthorizeException;
import org.dspace.core.ConfigurationManager;
import org.dspace.core.Context;
import org.dspace.license.CCLicenseField;
import org.dspace.license.CCLookup;
import org.dspace.services.ConfigurationService;
import org.dspace.services.factory.DSpaceServicesFactory;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
/**
* @author Luigi Andrea Pascarelli
*/
public class CreativeCommonsJSONRequest extends JSONRequest {
private static Logger log = Logger.getLogger(CreativeCommonsJSONRequest.class);
protected ConfigurationService configurationService = DSpaceServicesFactory.getInstance().getConfigurationService();
@Override
public void doJSONRequest(Context context, HttpServletRequest req, HttpServletResponse resp)
throws AuthorizeException, IOException {
Gson json = new Gson();
String selectedLicense = req.getParameter("license");
List<CCLicenseField> dto = new ArrayList<CCLicenseField>();
if (StringUtils.isNotBlank(selectedLicense)) {
CCLookup cclookup = new CCLookup();
String ccLocale = configurationService.getProperty("cc.license.locale");
/** Default locale to 'en' */
ccLocale = (StringUtils.isNotBlank(ccLocale)) ? ccLocale : "en";
// output the license fields chooser for the license class type
if (cclookup.getLicenseFields(selectedLicense, ccLocale) == null) {
// do nothing
} else {
Collection<CCLicenseField> outerIterator = cclookup.getLicenseFields(selectedLicense, ccLocale);
for(CCLicenseField cclicensefield : outerIterator) {
if (cclicensefield.getId().equals("jurisdiction"))
continue;
dto.add(cclicensefield);
}
}
}
JsonElement tree = json.toJsonTree(dto);
JsonObject jo = new JsonObject();
jo.add("result", tree);
resp.getWriter().write(jo.toString());
}
}

View File

@@ -7,7 +7,28 @@
*/
package org.dspace.app.webui.servlet.admin;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.UUID;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.fileupload.FileUploadBase.FileSizeLimitExceededException;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.dspace.app.util.AuthorizeUtil;
import org.dspace.app.util.Util;
@@ -16,25 +37,35 @@ import org.dspace.app.webui.util.FileUploadRequest;
import org.dspace.app.webui.util.JSPManager;
import org.dspace.app.webui.util.UIUtil;
import org.dspace.authorize.AuthorizeException;
import org.dspace.content.*;
import org.dspace.content.Bitstream;
import org.dspace.content.BitstreamFormat;
import org.dspace.content.Bundle;
import org.dspace.content.Collection;
import org.dspace.content.DSpaceObject;
import org.dspace.content.Item;
import org.dspace.content.MetadataField;
import org.dspace.content.MetadataSchema;
import org.dspace.content.authority.Choices;
import org.dspace.content.factory.ContentServiceFactory;
import org.dspace.content.service.*;
import org.dspace.content.service.BitstreamFormatService;
import org.dspace.content.service.BitstreamService;
import org.dspace.content.service.BundleService;
import org.dspace.content.service.CollectionService;
import org.dspace.content.service.ItemService;
import org.dspace.content.service.MetadataFieldService;
import org.dspace.content.service.MetadataSchemaService;
import org.dspace.core.Constants;
import org.dspace.core.Context;
import org.dspace.core.LogManager;
import org.dspace.handle.factory.HandleServiceFactory;
import org.dspace.handle.service.HandleService;
import org.dspace.license.CCLicense;
import org.dspace.license.CCLookup;
import org.dspace.license.LicenseMetadataValue;
import org.dspace.license.factory.LicenseServiceFactory;
import org.dspace.license.service.CreativeCommonsService;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.sql.SQLException;
import java.util.*;
import org.dspace.services.ConfigurationService;
import org.dspace.services.factory.DSpaceServicesFactory;
/**
* Servlet for editing and deleting (expunging) items
@@ -76,6 +107,9 @@ public class EditItemServlet extends DSpaceServlet
/** User confirms withdrawal of item */
public static final int PUBLICIZE = 11;
/** User updates Creative Commons License */
public static final int UPDATE_CC = 12;
/** JSP to upload bitstream */
protected static final String UPLOAD_BITSTREAM_JSP = "/tools/upload-bitstream.jsp";
@@ -110,6 +144,8 @@ public class EditItemServlet extends DSpaceServlet
private final transient CreativeCommonsService creativeCommonsService
= LicenseServiceFactory.getInstance().getCreativeCommonsService();
protected ConfigurationService configurationService = DSpaceServicesFactory.getInstance().getConfigurationService();
@Override
protected void doDSGet(Context context, HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException,
@@ -207,6 +243,13 @@ public class EditItemServlet extends DSpaceServlet
Item item = itemService.find(context, UIUtil.getUUIDParameter(request,
"item_id"));
if (request.getParameter("submit_cancel_cc") != null)
{
showEditForm(context, request, response, item);
return;
}
String handle = handleService.findHandle(context, item);
// now check to see if person can edit item
@@ -357,6 +400,54 @@ public class EditItemServlet extends DSpaceServlet
break;
case UPDATE_CC:
Map<String, String> map = new HashMap<String, String>();
String licenseclass = (request.getParameter("licenseclass_chooser") != null) ? request.getParameter("licenseclass_chooser") : "";
String jurisdiction = (configurationService.getProperty("cc.license.jurisdiction") != null) ? configurationService.getProperty("cc.license.jurisdiction") : "";
if (licenseclass.equals("standard")) {
map.put("commercial", request.getParameter("commercial_chooser"));
map.put("derivatives", request.getParameter("derivatives_chooser"));
} else if (licenseclass.equals("recombo")) {
map.put("sampling", request.getParameter("sampling_chooser"));
}
map.put("jurisdiction", jurisdiction);
CCLookup ccLookup = new CCLookup();
LicenseMetadataValue uriField = creativeCommonsService.getCCField("uri");
LicenseMetadataValue nameField = creativeCommonsService.getCCField("name");
ccLookup.issue(licenseclass, map, configurationService.getProperty("cc.license.locale"));
if (licenseclass.equals("webui.Submission.submit.CCLicenseStep.no_license"))
{
creativeCommonsService.removeLicense(context, uriField, nameField, item);
itemService.update(context, item);
context.dispatchEvents();
}
else if (licenseclass.equals("webui.Submission.submit.CCLicenseStep.select_change")) {
//none
}
else if (ccLookup.isSuccess())
{
creativeCommonsService.removeLicense(context, uriField, nameField, item);
uriField.addItemValue(context, item, ccLookup.getLicenseUrl());
if (configurationService.getBooleanProperty("cc.submit.addbitstream")) {
creativeCommonsService.setLicenseRDF(context, item, ccLookup.getRdf());
}
if (configurationService.getBooleanProperty("cc.submit.setname")) {
nameField.addItemValue(context, item, ccLookup.getLicenseName());
}
itemService.update(context, item);
context.dispatchEvents();
}
showEditForm(context, request, response, item);
context.complete();
break;
default:
// Erm... weird action value received.
@@ -407,19 +498,6 @@ public class EditItemServlet extends DSpaceServlet
HttpServletResponse response, Item item) throws ServletException,
IOException, SQLException, AuthorizeException
{
if ( request.getParameter("cc_license_url") != null )
{
// check authorization
AuthorizeUtil.authorizeManageCCLicense(context, item);
// turn off auth system to allow replace also to user that can't
// remove/add bitstream to the item
context.turnOffAuthorisationSystem();
// set or replace existing CC license
creativeCommonsService.setLicense(context, item,
request.getParameter("cc_license_url"));
context.restoreAuthSystemState();
}
// Get the handle, if any
String handle = handleService.findHandle(context, item);
@@ -553,6 +631,9 @@ public class EditItemServlet extends DSpaceServlet
request.setAttribute("dc.types", types);
request.setAttribute("metadataFields", metadataFields);
if(response.isCommitted()) {
return;
}
JSPManager.showJSP(request, response, "/tools/edit-item-form.jsp");
}
@@ -791,6 +872,19 @@ public class EditItemServlet extends DSpaceServlet
{
// Show cc-edit page
request.setAttribute("item", item);
boolean exists = creativeCommonsService.hasLicense(context, item);
request.setAttribute("cclicense.exists", Boolean.valueOf(exists));
String ccLocale = configurationService.getProperty("cc.license.locale");
/** Default locale to 'en' */
ccLocale = (StringUtils.isNotBlank(ccLocale)) ? ccLocale : "en";
request.setAttribute("cclicense.locale", ccLocale);
CCLookup cclookup = new CCLookup();
java.util.Collection<CCLicense> collectionLicenses = cclookup.getLicenses(ccLocale);
request.setAttribute("cclicense.licenses", collectionLicenses);
JSPManager
.showJSP(request, response, "/tools/creative-commons-edit.jsp");
}

View File

@@ -9,11 +9,13 @@ package org.dspace.app.webui.submit.step;
import java.io.IOException;
import java.sql.SQLException;
import java.util.Collection;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.dspace.app.util.SubmissionInfo;
import org.dspace.app.util.Util;
@@ -28,8 +30,12 @@ import org.dspace.content.factory.ContentServiceFactory;
import org.dspace.content.service.WorkspaceItemService;
import org.dspace.core.Context;
import org.dspace.core.LogManager;
import org.dspace.license.CCLicense;
import org.dspace.license.CCLookup;
import org.dspace.license.factory.LicenseServiceFactory;
import org.dspace.license.service.CreativeCommonsService;
import org.dspace.services.ConfigurationService;
import org.dspace.services.factory.DSpaceServicesFactory;
import org.dspace.submit.step.LicenseStep;
/**
@@ -78,6 +84,8 @@ public class JSPCCLicenseStep extends JSPStep
private CreativeCommonsService creativeCommonsService;
protected ConfigurationService configurationService = DSpaceServicesFactory.getInstance().getConfigurationService();
public JSPCCLicenseStep() {
workspaceItemService = ContentServiceFactory.getInstance().getWorkspaceItemService();
creativeCommonsService = LicenseServiceFactory.getInstance().getCreativeCommonsService();
@@ -116,6 +124,15 @@ public class JSPCCLicenseStep extends JSPStep
boolean exists = creativeCommonsService.hasLicense(context, item);
request.setAttribute("cclicense.exists", Boolean.valueOf(exists));
String ccLocale = configurationService.getProperty("cc.license.locale");
/** Default locale to 'en' */
ccLocale = (StringUtils.isNotBlank(ccLocale)) ? ccLocale : "en";
request.setAttribute("cclicense.locale", ccLocale);
CCLookup cclookup = new CCLookup();
Collection<CCLicense> collectionLicenses = cclookup.getLicenses(ccLocale);
request.setAttribute("cclicense.licenses", collectionLicenses);
JSPStepManager.showJSP(request, response, subInfo, CC_LICENSE_JSP);
}

View File

@@ -1,29 +0,0 @@
<%--
The contents of this file are subject to the license and copyright
detailed in the LICENSE and NOTICE files at the root of the source
tree and available online at
http://www.dspace.org/license/
--%>
<%--
-
- Attributes to pass in:
- license_url - the CC license URL
--%>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib uri="http://www.dspace.org/dspace-tags.tld" prefix="dspace" %>
<%
request.setAttribute("LanguageSwitch", "hide");
String cc_license_url = (String) request.getParameter("license_url");
%>
<script type="text/javascript">
the_form = parent.document.getElementById("license_form");
the_form.cc_license_url.value = "<%= cc_license_url %>";
parent.document.getElementById("submit_grant").click();
</script>

View File

@@ -1,64 +0,0 @@
/**
* The contents of this file are subject to the license and copyright
* detailed in the LICENSE and NOTICE files at the root of the source
* tree and available online at
*
* http://www.dspace.org/license/
*/
body {
margin:0px;
background:white;
margin-top:5px;
margin-bottom:5px;
font-family:verdana;
color:#333;
}
#main {
border-left:1px solid #D0D0D0;
border-right:1px solid #D0D0D0;
border-bottom:1px solid #D0D0D0;
border-top:1px solid #D0D0D0;
background:#fff;
margin-left:50px;
margin-right:50px;
}
/* Looks like you have to specify the width of #menu
or IE5 Mac stretches it all the way across the div, and
Opera streches it halfway. */
#main #menu {
border-left:1px dotted #ccc;
/* border-bottom:1px solid #000;*/
float:right;
width:230px;
background:white;
margin:0px 0px 10px 10px;
}
td, h3, p,h1,pre {
margin:0px 20px 20px 20px;
font-size:11px;
line-height:140%;
}
.header {
padding-left: 10px;
padding-top:30px;
}
.nav {
padding-left:10px;
padding-bottom:10px;
font-size:11px;
margin-bottom:16px;
}
#menu p {
font-size:11px;
}
.dent {
margin-left:64px;
}

View File

@@ -27,6 +27,8 @@
<%@ page import="org.dspace.license.CreativeCommonsServiceImpl" %>
<%@ page import="org.dspace.core.ConfigurationManager" %>
<%@ page import="org.dspace.license.factory.LicenseServiceFactory" %>
<%@ page import="org.dspace.license.CCLicense"%>
<%@ page import="java.util.Collection"%>
<%@ taglib uri="http://www.dspace.org/dspace-tags.tld" prefix="dspace" %>
@@ -39,28 +41,15 @@
//get submission information object
SubmissionInfo subInfo = SubmissionController.getSubmissionInfo(context, request);
String reqURL = request.getRequestURL().toString();
int firstIndex = reqURL.indexOf("://") + 3;
int secondIndex = reqURL.indexOf("/", firstIndex);
String baseURL = reqURL.substring(0, secondIndex) + request.getContextPath();
String ssURL = baseURL + "/submit/creative-commons.css";
String exitURL = baseURL + "/submit/cc-license.jsp?license_url=[license_url]";
Boolean lExists = (Boolean)request.getAttribute("cclicense.exists");
boolean licenseExists = (lExists == null ? false : lExists.booleanValue());
String jurisdiction = ConfigurationManager.getProperty("cc.license.jurisdiction");
if ((jurisdiction != null) && (!"".equals(jurisdiction)))
{
jurisdiction = "&amp;jurisdiction=" + jurisdiction.trim();
}
else
{
jurisdiction = "";
}
Collection<CCLicense> cclicenses = (Collection<CCLicense>)request.getAttribute("cclicense.licenses");
String licenseURL = "";
if(licenseExists)
licenseURL = LicenseServiceFactory.getInstance().getCreativeCommonsService().getLicenseURL(context, subInfo.getSubmissionItem().getItem());
%>
<dspace:layout style="submission"
@@ -76,41 +65,37 @@
<%-- <h1>Submit: Use a Creative Commons License</h1> --%>
<h1><fmt:message key="jsp.submit.creative-commons.heading"/></h1>
<%
if (licenseExists)
{
%>
<%-- <p>You have already chosen a Creative Commons license and added it to this item.
You may:</p> --%>
<p class="help-block"><fmt:message key="jsp.submit.creative-commons.info1"/></p>
<%-- <ul>
<li>Press the 'Next' button below to <em>keep</em> the license previously chosen.</li>
<li>Press the 'Skip Creative Commons' button below to <em>remove</em> the current choice, and forego a Creative Commons license.</li>
<li>Complete the selection process below to <em>replace</em> the current choice.</li>
</ul> --%>
<ul class="alert alert-info">
<li><fmt:message key="jsp.submit.creative-commons.choice1"/></li>
<li><fmt:message key="jsp.submit.creative-commons.choice2"/></li>
<li><fmt:message key="jsp.submit.creative-commons.choice3"/></li>
</ul>
<%
}
else
{
%>
<%-- <p>To license your Item under Creative Commons, follow the instructions below. You will be given an opportunity to review your selection.
Follow the 'proceed' link to add the license. If you wish to omit a Creative Commons license, press the 'Skip Creative Commons' button.</p> --%>
<p><fmt:message key="jsp.submit.creative-commons.info2"/></p>
<%
}
%>
<%-- <iframe src="http://creativecommons.org/license/?partner=dspace&stylesheet=<%= java.net.URLEncoder.encode(ssURL) %>&exit_url=<%= java.net.URLEncoder.encode(exitURL) %>" width="100%" height="540">Your browser must support IFrames to use this feature
</iframe> --%>
<iframe src="https://creativecommons.org/choose/?partner=dspace&amp;stylesheet=<%= java.net.URLEncoder.encode(ssURL, "UTF-8") %>&amp;exit_url=<%= java.net.URLEncoder.encode(exitURL, "UTF-8") %><%= jurisdiction %>" width="100%" height="540"><fmt:message key="jsp.submit.creative-commons.info3"/>
</iframe>
<%-- Hidden fields needed for SubmissionController servlet to know which step is next--%>
<div class="row">
<label class="col-md-2"><fmt:message key="jsp.submit.creative-commons.license"/></label>
<span class="col-md-8">
<select name="licenseclass_chooser" id="licenseclass_chooser" class="form-control">
<option
value="webui.Submission.submit.CCLicenseStep.select_change"><fmt:message key="jsp.submit.creative-commons.select_change"/></option>
<% if(cclicenses!=null) {
for(CCLicense cclicense : cclicenses) { %>
<option
value="<%= cclicense.getLicenseId()%>"><%= cclicense.getLicenseName()%></option>
<% }
}%>
<option
value="webui.Submission.submit.CCLicenseStep.no_license"><fmt:message key="jsp.submit.creative-commons.no_license"/></option>
</select>
</span>
</div>
<% if(licenseExists) { %>
<div class="row" id="current_creativecommons">
<label class="col-md-2"><fmt:message key="jsp.submit.creative-commons.license.current"/></label>
<span class="col-md-8">
<a href="<%=licenseURL %>"><%=licenseURL %></a>
</span>
</div>
<% } %>
<div style="display:none;" id="creativecommons_response">
</div>
<br/>
<%-- Hidden fields needed for SubmissionController servlet to know which step is next--%>
<%= SubmissionController.getSubmissionParameters(context, request) %>
<input type="hidden" name="cc_license_url" value="<%=licenseURL %>" />
@@ -127,15 +112,41 @@
<% } %>
<input class="btn btn-default col-md-<%= 12 / numButton %>" type="submit" name="<%=AbstractProcessingStep.CANCEL_BUTTON%>" value="<fmt:message key="jsp.submit.general.cancel-or-save.button"/>"/>
<input class="btn btn-warning col-md-<%= 12 / numButton %>" type="submit" name="submit_no_cc" value="<fmt:message key="jsp.submit.creative-commons.skip.button"/>"/>
<%
if (licenseExists)
{
%>
<input class="btn btn-primary col-md-<%= 12 / numButton %>" type="submit" name="<%=AbstractProcessingStep.NEXT_BUTTON%>" value="<fmt:message key="jsp.submit.general.next"/>" />
<%
}
%>
</div>
</form>
<script type="text/javascript">
<!--
jQuery("#licenseclass_chooser").change(function() {
var make_id = jQuery(this).find(":selected").val();
var request = jQuery.ajax({
type: 'GET',
url: '<%=request.getContextPath()%>/json/creativecommons?license=' + make_id
});
request.done(function(data){
jQuery("#creativecommons_response").empty();
var result = data.result;
for (var i = 0; i < result.length; i++) {
var id = result[i].id;
var label = result[i].label;
var description = result[i].description;
var htmlCC = " <div class='form-group'><span class='help-block' title='"+description+"'>"+label+"&nbsp;<i class='glyphicon glyphicon-info-sign'></i></span>"
var typefield = result[i].type;
if(typefield=="enum") {
jQuery.each(result[i].fieldEnum, function(key, value) {
htmlCC += "<label class='radio-inline' for='"+id+"-"+key+"'>";
htmlCC += "<input placeholder='"+value+"' type='radio' id='"+id+"-"+key+"' name='"+id+"_chooser' value='"+key+"' required/>"+value+ "</label>";
});
}
htmlCC += "</div>";
jQuery("#creativecommons_response").append(htmlCC);
}
jQuery("#current_creativecommons").hide();
jQuery("#creativecommons_response").show();
});
});
//-->
</script>
</dspace:layout>

View File

@@ -18,32 +18,28 @@
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ page import="org.dspace.app.util.SubmissionInfo" %>
<%@page import="org.dspace.app.webui.servlet.admin.EditItemServlet"%>
<%@ page import="org.dspace.content.Item" %>
<%@ page import="org.dspace.license.CreativeCommonsServiceImpl" %>
<%@ page import="org.dspace.core.ConfigurationManager" %>
<%@ page import="org.dspace.license.factory.LicenseServiceFactory" %>
<%@ page import="org.dspace.license.CCLicense"%>
<%@ page import="java.util.Collection"%>
<%@ taglib uri="http://www.dspace.org/dspace-tags.tld" prefix="dspace" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%
Item item = (Item) request.getAttribute("item");
String reqURL = request.getRequestURL().toString();
int firstIndex = reqURL.indexOf("://") + 3;
int secondIndex = reqURL.indexOf("/", firstIndex);
String baseURL = reqURL.substring(0, secondIndex) + request.getContextPath();
String ssURL = baseURL + "/submit/creative-commons.css";
// Use the submit process' cc-license component
String exitURL = baseURL + "/submit/cc-license.jsp?license_url=[license_url]";
Boolean lExists = (Boolean) request.getAttribute("cclicense.exists");
boolean licenseExists = (lExists == null ? false : lExists.booleanValue());
String jurisdiction = ConfigurationManager.getProperty("webui.submit.cc-jurisdiction");
if ((jurisdiction != null) && (!"".equals(jurisdiction)))
{
jurisdiction = "&amp;jurisdiction=" + jurisdiction.trim();
}
else
{
jurisdiction = "";
}
Collection<CCLicense> cclicenses = (Collection<CCLicense>) request.getAttribute("cclicense.licenses");
String licenseURL = "";
if (licenseExists)
licenseURL = LicenseServiceFactory.getInstance().getCreativeCommonsService().getLicenseURL(context, subInfo.getSubmissionItem().getItem());
%>
<dspace:layout navbar="admin"
@@ -55,14 +51,88 @@
<tr>
<td>
<h1><fmt:message key="jsp.tools.creative-commons-edit.heading1"/></h1>
<form name="ccform" id="license_form" action="" method="get">
<iframe src="https://creativecommons.org/choose/?partner=dspace&amp;stylesheet=<%= java.net.URLEncoder.encode(ssURL, "UTF-8") %>&amp;exit_url=<%= java.net.URLEncoder.encode(exitURL, "UTF-8") %><%= jurisdiction %>" width="100%" height="540">Your browser must support IFrames to use this feature
</iframe>
<form name="ccform" id="license_form" action="" method="post">
<input type="hidden" name="item_id" value='<%=request.getParameter("item_id")%>' />
<input type="hidden" name="cc_license_url" value="" />
</form>
</td>
<div class="row">
<label class="col-md-2"><fmt:message
key="jsp.submit.creative-commons.license" /></label> <span
class="col-md-8"> <select name="licenseclass_chooser"
id="licenseclass_chooser" class="form-control">
<option
value="webui.Submission.submit.CCLicenseStep.select_change"><fmt:message
key="jsp.submit.creative-commons.select_change" /></option>
<%
if (cclicenses != null) {
for (CCLicense cclicense : cclicenses) {
%>
<option value="<%=cclicense.getLicenseId()%>"><%=cclicense.getLicenseName()%></option>
<%
}
}
%>
<option value="webui.Submission.submit.CCLicenseStep.no_license"><fmt:message
key="jsp.submit.creative-commons.no_license" /></option>
</select>
</span>
</div>
<%
if (licenseExists) {
%>
<div class="row" id="current_creativecommons">
<label class="col-md-2"><fmt:message
key="jsp.submit.creative-commons.license.current" /></label> <span
class="col-md-8"> <a href="<%=licenseURL%>"><%=licenseURL%></a>
</span>
</div>
<%
}
%>
<div style="display: none;" id="creativecommons_response"></div>
<br />
<input type="hidden" name="item_id" value='<%=request.getParameter("item_id")%>'/>
<input type="hidden" name="cc_license_url" value="<%=licenseURL%>" />
<input type="hidden" name="action" value="<%= EditItemServlet.UPDATE_CC %>"/>
<input class="btn btn-default" type="submit" name="submit_cancel_cc" value="<fmt:message key="jsp.tools.general.cancel"/>" />
<input class="btn btn-primary" type="submit" name="submit_change_cc" value="<fmt:message key="jsp.tools.general.update"/>" />
</form>
</td>
</tr>
</table>
<script type="text/javascript">
<!--
jQuery("#licenseclass_chooser").change(function() {
var make_id = jQuery(this).find(":selected").val();
var request = jQuery.ajax({
type: 'GET',
url: '<%=request.getContextPath()%>/json/creativecommons?license=' + make_id
});
request.done(function(data){
jQuery("#creativecommons_response").empty();
var result = data.result;
for (var i = 0; i < result.length; i++) {
var id = result[i].id;
var label = result[i].label;
var description = result[i].description;
var htmlCC = " <div class='form-group'><span class='help-block' title='"+description+"'>"+label+"&nbsp;<i class='glyphicon glyphicon-info-sign'></i></span>"
var typefield = result[i].type;
if(typefield=="enum") {
jQuery.each(result[i].fieldEnum, function(key, value) {
htmlCC += "<label class='radio-inline' for='"+id+"-"+key+"'>";
htmlCC += "<input placeholder='"+value+"' type='radio' id='"+id+"-"+key+"' name='"+id+"_chooser' value='"+key+"' required/>"+value+ "</label>";
});
}
htmlCC += "</div>";
jQuery("#creativecommons_response").append(htmlCC);
}
jQuery("#current_creativecommons").hide();
jQuery("#creativecommons_response").show();
});
});
//-->
</script>
</dspace:layout>

View File

@@ -697,7 +697,7 @@
List<Bundle> ccBundle = ContentServiceFactory.getInstance().getItemService().getBundles(item, "CC-LICENSE");
s = ccBundle.size() > 0 ? LocaleSupport.getLocalizedMessage(pageContext, "jsp.tools.edit-item-form.replacecc.button") : LocaleSupport.getLocalizedMessage(pageContext, "jsp.tools.edit-item-form.addcc.button");
%>
<input class="btn btn-success col-md-2" type="submit" name="submit_addcc" value="<%= s %>" />
<input class="btn btn-success col-md-3" type="submit" name="submit_addcc" value="<%= s %>" />
<input type="hidden" name="handle" value="<%= ConfigurationManager.getProperty("handle.prefix") %>"/>
<input type="hidden" name="item_id" value="<%= item.getID() %>"/>

View File

@@ -71,8 +71,8 @@ public class CCLicenseStep extends AbstractSubmissionStep
protected static final Message T_license =
message("xmlui.Submission.submit.CCLicenseStep.license");
protected static final Message T_submit_remove = message("xmlui.Submission.submit.CCLicenseStep.submit_remove");
protected static final Message T_no_license = message("xmlui.Submission.submit.CCLicenseStep.no_license");
protected static final Message T_select_change = message("xmlui.Submission.submit.CCLicenseStep.select_change");
protected static final Message T_no_license = message("webui.Submission.submit.CCLicenseStep.no_license","xmlui.Submission.submit.CCLicenseStep.no_license");
protected static final Message T_select_change = message("webui.Submission.submit.CCLicenseStep.select_change","xmlui.Submission.submit.CCLicenseStep.select_change");
protected static final Message T_save_changes = message("xmlui.Submission.submit.CCLicenseStep.save_changes");
protected static final Message T_ccws_error = message("xmlui.Submission.submit.CCLicenseStep.ccws_error");

View File

@@ -815,12 +815,12 @@ webui.submit.blocktheses = false
cc.api.rooturl = http://api.creativecommons.org/rest/1.5
# Metadata field to hold CC license URI of selected license
# NB: XMLUI presentation code expects 'dc.rights.uri' to hold CC data. If you change
# this to another field, please consult documentation on how to update UI configuration
# NB: DSpace (both JSPUI and XMLUI) presentation code expects 'dc.rights.uri' to hold CC data. If you change
# this to another field, please consult documentation on how to update UI configuration
cc.license.uri = dc.rights.uri
# Metadata field to hold CC license name of selected license (if defined)
# NB: XMLUI presentation code expects 'dc.rights' to hold CC data. If you change
# NB: DSpace (both JSPUI and XMLUI) presentation code expects 'dc.rights' to hold CC data. If you change
# this to another field, please consult documentation on how to update UI configuration
cc.license.name = dc.rights
@@ -830,6 +830,9 @@ cc.submit.setname = true
# Store license bitstream (RDF license text) during web submission
cc.submit.addbitstream = true
# ONLY JSPUI, enable Creative Commons admin
webui.submit.enable-cc = false
# A list of license classes that should be excluded from selection process
# class names - comma-separated list - must exactly match what service returns.
# At time of implementation, these are:
@@ -1222,7 +1225,8 @@ plugin.named.org.dspace.app.webui.json.JSONRequest = \
org.dspace.app.webui.discovery.DiscoveryJSONRequest = discovery,\
org.dspace.app.webui.json.SubmissionLookupJSONRequest = submissionLookup,\
org.dspace.app.webui.json.UploadProgressJSON = uploadProgress,\
org.dspace.app.webui.handle.HandleJSONResolver = hdlresolver
org.dspace.app.webui.handle.HandleJSONResolver = hdlresolver,\
org.dspace.app.webui.json.CreativeCommonsJSONRequest = creativecommons
### i18n - Locales / Language ####
# Default Locale