diff --git a/dspace-api/pom.xml b/dspace-api/pom.xml
index c7a952c75b8..8e0ffe97784 100644
--- a/dspace-api/pom.xml
+++ b/dspace-api/pom.xml
@@ -771,5 +771,16 @@
com.fasterxml.jackson.jaxrs
jackson-jaxrs-json-provider
+
+
+
+ net.sf.jasperreports
+ jasperreports
+
+
+
+ net.sf.jasperreports
+ jasperreports-fonts
+
diff --git a/dspace-api/src/main/java/org/dspace/content/LicenseUtils.java b/dspace-api/src/main/java/org/dspace/content/LicenseUtils.java
index 38f2e2ae2ed..99ab28fad0c 100644
--- a/dspace-api/src/main/java/org/dspace/content/LicenseUtils.java
+++ b/dspace-api/src/main/java/org/dspace/content/LicenseUtils.java
@@ -8,17 +8,31 @@
package org.dspace.content;
import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.sql.SQLException;
+import java.util.Date;
import java.util.Formatter;
+import java.util.HashMap;
+import java.util.List;
import java.util.Locale;
import java.util.Map;
+import org.apache.log4j.Logger;
import org.dspace.authorize.AuthorizeException;
+import org.dspace.authorize.AuthorizeManager;
import org.dspace.content.license.FormattableArgument;
+import org.dspace.core.ConfigurationManager;
import org.dspace.core.Context;
import org.dspace.eperson.EPerson;
+import net.sf.jasperreports.engine.JREmptyDataSource;
+import net.sf.jasperreports.engine.JasperCompileManager;
+import net.sf.jasperreports.engine.JasperExportManager;
+import net.sf.jasperreports.engine.JasperFillManager;
+import net.sf.jasperreports.engine.JasperPrint;
+import net.sf.jasperreports.engine.JasperReport;
+
/**
* Utility class to manage generation and storing of the license text that the
* submitter has to grant/granted for archiving the item
@@ -28,6 +42,8 @@
*/
public class LicenseUtils
{
+ private static Logger log = Logger.getLogger(LicenseUtils.class);
+
/**
* Return the text of the license that the user has granted/must grant
* before for submit the item. The license text is build using the template
@@ -144,4 +160,85 @@ public static void grantLicense(Context context, Item item,
b.update();
}
+ public static void getLicensePDF(Context context, Item item, String choiceLicense) {
+ String reportName = ConfigurationManager.getProperty("jasper", choiceLicense);
+ String reportFolderPath = ConfigurationManager.getProperty("jasper","report.folder");
+ String reportExtension = ConfigurationManager.getProperty("jasper","report.extension");
+ String reportPath = reportFolderPath+reportName+reportExtension;
+ try {
+ fill(context, item, reportPath,reportName);
+ } catch (SQLException e) {
+ log.error(e.getMessage(),e);
+ }
+
+
+ }
+
+ private static void fill(Context context, Item item, String reportPath, String reportName) throws SQLException {
+ HashMap reportMap = new HashMap();
+ String key = "";
+ String value = "";
+ EPerson ep = item.getSubmitter();
+ List listEPMetadata = ep.getMetadata();
+ Metadatum[] listItemMetadata = item.getMetadataWithoutPlaceholder(Item.ANY, Item.ANY, Item.ANY, Item.ANY);
+ for (Metadatum m: listItemMetadata) {
+ key = m.getField().replace('.', '_');
+ String oldValue = (String) reportMap.get(key);
+ value = m.value;
+ if (oldValue != null) {
+ value = oldValue+", "+value;
+ }
+ reportMap.put(key, value);
+ }
+ for (Metadatum m: listEPMetadata) {
+ key = m.getField().replace('.', '_');
+ String oldValue = (String) reportMap.get(key);
+ value = m.value;
+ if (oldValue != null) {
+ value = oldValue+", "+value;
+ }
+ reportMap.put(key, value);
+ }
+ String logo = ConfigurationManager.getProperty("jasper","parameter.logo");
+ String pathLogoImage = ConfigurationManager.getProperty("jasper","parameter.logo.path");
+ String submitterEmail = ConfigurationManager.getProperty("jasper","parameter.submitter.email");
+ String submitterFullName = ConfigurationManager.getProperty("jasper","parameter.submitter.fullname");
+ String currentDateLabel = ConfigurationManager.getProperty("jasper","parameter.current.date");
+
+ reportMap.put(logo, pathLogoImage);
+ String email = item.getSubmitter().getEmail();
+ String fullname = item.getSubmitter().getFullName();
+ Date date = new Date();
+ String currentDate = date.toString();
+ reportMap.put(submitterEmail, email);
+ reportMap.put(submitterFullName, fullname);
+ reportMap.put(currentDateLabel, currentDate);
+ try {
+ // Give the path of report jrxml file path for complie.
+ JasperReport jasperReport = JasperCompileManager.compileReport(reportPath);
+ //pass data HashMap with compiled jrxml file and a empty data source .
+ JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, reportMap,new JREmptyDataSource() );
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ JasperExportManager.exportReportToPdfStream(jasperPrint, baos);
+ ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
+ Bitstream b = item.createSingleBitstream(bais, "LICENSE");
+ // Now set the format and name of the bitstream
+ b.setName("license.pdf");
+ b.setSource("Written by org.dspace.content.LicenseUtils");
+
+ // Find the License format
+ BitstreamFormat bf = BitstreamFormat.findByShortDescription(context,
+ "License PDF");
+ b.setFormat(bf);
+ b.update();
+ context.turnOffAuthorisationSystem();
+ // grant access to the license to the submitter
+ AuthorizeManager.addPolicy(context, b, org.dspace.core.Constants.READ, context.getCurrentUser());
+ context.restoreAuthSystemState();
+ } catch (Exception e) {
+ log.error(e.getMessage(),e);
+ throw new RuntimeException(e.getMessage(), e);
+ }
+ }
}
diff --git a/dspace-api/src/main/java/org/dspace/submit/step/LicenseStep.java b/dspace-api/src/main/java/org/dspace/submit/step/LicenseStep.java
index 6144c474566..5c6bfe22eda 100644
--- a/dspace-api/src/main/java/org/dspace/submit/step/LicenseStep.java
+++ b/dspace-api/src/main/java/org/dspace/submit/step/LicenseStep.java
@@ -9,6 +9,9 @@
import java.io.IOException;
import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
@@ -21,6 +24,7 @@
import org.dspace.authorize.AuthorizeException;
import org.dspace.content.Item;
import org.dspace.content.LicenseUtils;
+import org.dspace.core.ConfigurationManager;
import org.dspace.core.Context;
import org.dspace.core.LogManager;
import org.dspace.eperson.EPerson;
@@ -118,24 +122,37 @@ else if (buttonPressed.equals(NEXT_BUTTON))
&& (buttonPressed.equals("submit_grant") || buttonPressed
.equals(NEXT_BUTTON)))
{
- // License granted
- log.info(LogManager.getHeader(context, "accept_license",
- subInfo.getSubmissionLogInfo()));
-
- // Add the license to the item
- Item item = subInfo.getSubmissionItem().getItem();
- EPerson submitter = context.getCurrentUser();
-
- // remove any existing DSpace license (just in case the user
- // accepted it previously)
- item.removeDSpaceLicense();
-
- String license = LicenseUtils.getLicenseText(context
- .getCurrentLocale(), subInfo.getSubmissionItem()
- .getCollection(), item, submitter);
-
- LicenseUtils.grantLicense(context, item, license);
-
+
+ String typeMetadata = ConfigurationManager.getProperty("license.articles.metadata");
+ String type = subInfo.getSubmissionItem().getItem().getMetadata(typeMetadata);
+ String[] articleType = ConfigurationManager.getProperty("license.articles.value").split(",");
+ List list = new ArrayList();
+ list = Arrays.asList(articleType);
+ if (list.contains(type))
+ {
+ // License granted
+ log.info(LogManager.getHeader(context, "accept_license",
+ subInfo.getSubmissionLogInfo()));
+
+ // Add the license to the item
+ Item item = subInfo.getSubmissionItem().getItem();
+ EPerson submitter = context.getCurrentUser();
+
+ // remove any existing DSpace license (just in case the user
+ // accepted it previously)
+ item.removeDSpaceLicense();
+
+ String license = LicenseUtils.getLicenseText(context
+ .getCurrentLocale(), subInfo.getSubmissionItem()
+ .getCollection(), item, submitter);
+
+ LicenseUtils.grantLicense(context, item, license);
+ }else {
+ String choiceLicense = request.getParameter("license_chooser");
+ Item item = subInfo.getSubmissionItem().getItem();
+ Item item2 = item.getWrapper();
+ LicenseUtils.getLicensePDF(context, item2, choiceLicense);
+ }
// commit changes
context.commit();
}
@@ -173,13 +190,9 @@ public int getNumberOfPages(HttpServletRequest request,
return 1;
}
-
-
@Override
- public void doClear(SubmissionInfo subInfo) throws ServletException,
- IOException, SQLException, AuthorizeException
- {
- // NOOP
- }
-
+ public void doClear(SubmissionInfo subInfo) throws SQLException, AuthorizeException, IOException {
+ Item item = subInfo.getSubmissionItem().getItem();
+ item.removeLicenses();
+ }
}
diff --git a/dspace-api/src/main/resources/Messages.properties b/dspace-api/src/main/resources/Messages.properties
index 3a9db77ea25..7da4f86ddca 100644
--- a/dspace-api/src/main/resources/Messages.properties
+++ b/dspace-api/src/main/resources/Messages.properties
@@ -1044,10 +1044,16 @@ jsp.submit.creative-commons.info1 = If you wish, y
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.select_change = Select this voice for select German Copyright law
jsp.submit.creative-commons.no_license = No Creative Commons License
jsp.submit.creative-commons.license.current = Current license
+jsp.submit.license.1 = Master Thesis
+jsp.submit.license.2 = Gold and Green OpenAccess Publications
+jsp.submit.license.3 = Dissertation Habilitation
+jsp.submit.license.retrodigitalization = Retrodigitalization
+jsp.submit.show-license.template-instruction = Please select the type of license appropriate for your submission according to the University definition. The system will generate a pre-filled PDF for you downloadable from the next page to be sent to the Library
+
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
@@ -5117,6 +5123,8 @@ error.ec.product.sale = You can not select Ano
error.ec.product.price = You can not insert price if sale value is free
error.ec.product.not.price = You must insert price if sale value is not free
+license.download = You can download a pre-filled copy of the license from here. Please return it signed to the Library
+
jsp.layout.navbar-admin.sitestatistics= Site Statistics
jsp.layout.navbar-admin.loginstatistics= Login Statistics
jsp.layout.navbar-admin.workflowstatistics= Workflow Statistics
@@ -5268,4 +5276,5 @@ jsp.layout.detail.info.about.feature = If you interested in "Add Fulltext" or "I
jsp.itemlisttag.fulltext.button = Add fulltext
jsp.itemlisttag.createnewversion.button = Create new version
jsp.itemlisttag.interestedinopenaccess.button = Interested in green
open access?
-jsp.itemlisttag.edititem.button = Edit Item
\ No newline at end of file
+jsp.itemlisttag.edititem.button = Edit Item
+
diff --git a/dspace-jspui/src/main/webapp/submit/complete.jsp b/dspace-jspui/src/main/webapp/submit/complete.jsp
index 5ae9c8ba36d..f4f375fe11a 100644
--- a/dspace-jspui/src/main/webapp/submit/complete.jsp
+++ b/dspace-jspui/src/main/webapp/submit/complete.jsp
@@ -22,6 +22,8 @@
<%@ page import="org.dspace.app.util.SubmissionInfo" %>
<%@ page import="org.dspace.content.InProgressSubmission" %>
<%@ page import="org.dspace.content.Collection"%>
+<%@ page import="org.dspace.content.Bundle"%>
+<%@ page import="org.dspace.content.Bitstream"%>
<%@ taglib uri="http://www.dspace.org/dspace-tags.tld" prefix="dspace" %>
@@ -37,6 +39,17 @@
//get collection
Collection collection = subInfo.getSubmissionItem().getCollection();
+
+ Bundle[] licenseBnds = subInfo.getSubmissionItem().getItem().getBundles("LICENSE");
+ Bundle licenseBnd = null;
+ if (licenseBnds != null && licenseBnds.length > 0){
+ licenseBnd = licenseBnds[0];
+ }
+ Bitstream l = null;
+ if (licenseBnd != null) {
+ l = licenseBnd.getBitstreamByName("license.pdf");
+ }
+
%>
@@ -52,7 +65,12 @@
notification as soon as your submission has become a part of the collection,
or if for some reason there is a problem with your submission. You can also
check on the status of your submission by going to the My DSpace page.
--%>
-
+
+
+ <% if (l != null) { %>
+ <%= request.getContextPath() %>/retrieve/<%= l.getID() %>
+ <% } %>
+
diff --git a/dspace-jspui/src/main/webapp/submit/show-license.jsp b/dspace-jspui/src/main/webapp/submit/show-license.jsp
index 7e31131f4bf..3c6416a4a46 100644
--- a/dspace-jspui/src/main/webapp/submit/show-license.jsp
+++ b/dspace-jspui/src/main/webapp/submit/show-license.jsp
@@ -14,6 +14,13 @@
- license - the license text to display
--%>
+<%@page import="org.dspace.eperson.Group"%>
+<%@page import="org.dspace.eperson.EPerson"%>
+<%@page import="org.apache.commons.lang.StringUtils"%>
+<%@page import="java.util.Arrays"%>
+<%@page import="java.util.List"%>
+<%@page import="java.util.ArrayList"%>
+<%@page import="org.dspace.core.ConfigurationManager"%>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt"
@@ -28,6 +35,20 @@
<%@ taglib uri="http://www.dspace.org/dspace-tags.tld" prefix="dspace" %>
+
+
<%
request.setAttribute("LanguageSwitch", "hide");
@@ -36,7 +57,7 @@
//get submission information object
SubmissionInfo subInfo = SubmissionController.getSubmissionInfo(context, request);
-
+
String license = (String) request.getAttribute("license");
%>
@@ -45,31 +66,99 @@
navbar="off"
titlekey="jsp.submit.show-license.title"
nocache="true">
-
+
+
diff --git a/dspace/config/dspace.cfg b/dspace/config/dspace.cfg
index c2bc4bf31e6..6bebaa824df 100644
--- a/dspace/config/dspace.cfg
+++ b/dspace/config/dspace.cfg
@@ -2652,3 +2652,9 @@ cookies.policy.enabled = ${cookies.policy.enabled}
# * doi
# * other
webui.submission.list-identifiers = handle,doi,other
+
+# Name of the dspace group allowed to use the option 5 in the license step, retrodigitalization
+license.library = Library
+
+license.articles.metadata = dc.type
+license.articles.value = articlecollection, article
diff --git a/dspace/config/modules/jasper.cfg b/dspace/config/modules/jasper.cfg
new file mode 100644
index 00000000000..4e103c88ccc
--- /dev/null
+++ b/dspace/config/modules/jasper.cfg
@@ -0,0 +1,13 @@
+jsp.submit.license.1 = masterthesis
+jsp.submit.license.2 = publications
+jsp.submit.license.3 = dissertation
+
+report.folder = ${dspace.dir}/etc/report/
+report.extension = .jrxml
+
+parameter.logo = logo
+parameter.submitter.email = submitter_email
+parameter.submitter.fullname = submitter_fullname
+parameter.current.date = current_date
+
+parameter.logo.path = ${dspace.dir}/etc/report/logo.jpg
diff --git a/dspace/config/registries/bitstream-formats.xml b/dspace/config/registries/bitstream-formats.xml
index 46e64871ad9..62964328547 100644
--- a/dspace/config/registries/bitstream-formats.xml
+++ b/dspace/config/registries/bitstream-formats.xml
@@ -55,7 +55,18 @@
1
true
+
+
+
+ application/pdf; charset=utf-8
+ License PDF
+ Item-specific license agreed upon to submission
+ 1
+ true
+
+
+
text/html; charset=utf-8
diff --git a/dspace/etc/report/dissertation.jrxml b/dspace/etc/report/dissertation.jrxml
new file mode 100644
index 00000000000..e2203fedc4f
--- /dev/null
+++ b/dspace/etc/report/dissertation.jrxml
@@ -0,0 +1,297 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dspace/etc/report/logo.jpg b/dspace/etc/report/logo.jpg
new file mode 100755
index 00000000000..e256d5370ab
Binary files /dev/null and b/dspace/etc/report/logo.jpg differ
diff --git a/dspace/etc/report/masterthesis.jrxml b/dspace/etc/report/masterthesis.jrxml
new file mode 100644
index 00000000000..1528d900fde
--- /dev/null
+++ b/dspace/etc/report/masterthesis.jrxml
@@ -0,0 +1,298 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dspace/etc/report/publications.jrxml b/dspace/etc/report/publications.jrxml
new file mode 100644
index 00000000000..ec45019ce8a
--- /dev/null
+++ b/dspace/etc/report/publications.jrxml
@@ -0,0 +1,583 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/pom.xml b/pom.xml
index a81ec639103..be317ff1398 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1715,7 +1715,17 @@
${project.version}
jar
-
+
+ net.sf.jasperreports
+ jasperreports
+ 6.4.0
+
+
+
+ net.sf.jasperreports
+ jasperreports-fonts
+ 6.0.0
+