mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-15 05:53:08 +00:00
Merge branch 'main' into feature-relationship-versioning-contribution
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.dspace</groupId>
|
||||
<artifactId>dspace-api</artifactId>
|
||||
@@ -12,7 +14,7 @@
|
||||
<parent>
|
||||
<groupId>org.dspace</groupId>
|
||||
<artifactId>dspace-parent</artifactId>
|
||||
<version>7.2</version>
|
||||
<version>7.3-SNAPSHOT</version>
|
||||
<relativePath>..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -335,16 +337,29 @@
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-ehcache</artifactId>
|
||||
<exclusions>
|
||||
<!-- Newer version pulled in via Jersey below -->
|
||||
<exclusion>
|
||||
<groupId>org.javassist</groupId>
|
||||
<artifactId>javassist</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
<artifactId>hibernate-core</artifactId>
|
||||
<exclusions>
|
||||
<!-- Newer version pulled in via Jersey below -->
|
||||
<exclusion>
|
||||
<groupId>org.javassist</groupId>
|
||||
<artifactId>javassist</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-jcache</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.ehcache</groupId>
|
||||
<artifactId>ehcache</artifactId>
|
||||
<version>${ehcache.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
@@ -358,7 +373,7 @@
|
||||
<dependency>
|
||||
<groupId>org.hibernate.javax.persistence</groupId>
|
||||
<artifactId>hibernate-jpa-2.1-api</artifactId>
|
||||
<version>1.0.0.Final</version>
|
||||
<version>1.0.2.Final</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@@ -379,7 +394,7 @@
|
||||
<groupId>org.ow2.asm</groupId>
|
||||
<artifactId>asm-commons</artifactId>
|
||||
</exclusion>
|
||||
<!-- Newer version of Bouncycastle brought in via solr-cell -->
|
||||
<!-- Newer version of Bouncycastle brought in via Tika -->
|
||||
<exclusion>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcpkix-jdk15on</artifactId>
|
||||
@@ -505,7 +520,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jdom</groupId>
|
||||
<artifactId>jdom</artifactId>
|
||||
<artifactId>jdom2</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.pdfbox</groupId>
|
||||
@@ -515,18 +530,6 @@
|
||||
<groupId>org.apache.pdfbox</groupId>
|
||||
<artifactId>fontbox</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-scratchpad</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>xalan</groupId>
|
||||
<artifactId>xalan</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>xerces</groupId>
|
||||
<artifactId>xercesImpl</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.ibm.icu</groupId>
|
||||
<artifactId>icu4j</artifactId>
|
||||
@@ -566,9 +569,12 @@
|
||||
</dependency>
|
||||
<!-- Used for RSS / ATOM syndication feeds -->
|
||||
<dependency>
|
||||
<groupId>org.rometools</groupId>
|
||||
<groupId>com.rometools</groupId>
|
||||
<artifactId>rome</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.rometools</groupId>
|
||||
<artifactId>rome-modules</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jbibtex</groupId>
|
||||
@@ -579,28 +585,22 @@
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpcore</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpmime</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SolrJ is used to communicate with Solr throughout the dspace-api -->
|
||||
<dependency>
|
||||
<groupId>org.apache.solr</groupId>
|
||||
<artifactId>solr-solrj</artifactId>
|
||||
<version>${solr.client.version}</version>
|
||||
<exclusions>
|
||||
<!-- Newer Jetty version brought in via Parent POM -->
|
||||
<exclusion>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-http</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-io</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-util</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<!-- Solr Core is needed for Integration Tests (to run a MockSolrServer) -->
|
||||
<!-- Solr Core is only needed for Integration Tests (to run a MockSolrServer) -->
|
||||
<!-- The following Solr / Lucene dependencies also support integration tests -->
|
||||
<dependency>
|
||||
<groupId>org.apache.solr</groupId>
|
||||
@@ -628,39 +628,10 @@
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.solr</groupId>
|
||||
<artifactId>solr-cell</artifactId>
|
||||
<exclusions>
|
||||
<!-- Newer version brought in by opencsv -->
|
||||
<exclusion>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-text</artifactId>
|
||||
</exclusion>
|
||||
<!-- Newer Jetty version brought in via Parent POM -->
|
||||
<exclusion>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-http</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-io</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-util</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.lucene</groupId>
|
||||
<artifactId>lucene-core</artifactId>
|
||||
</dependency>
|
||||
<!-- Used for full-text indexing with Solr -->
|
||||
<dependency>
|
||||
<groupId>org.apache.tika</groupId>
|
||||
<artifactId>tika-parsers</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.lucene</groupId>
|
||||
<artifactId>lucene-analyzers-icu</artifactId>
|
||||
@@ -676,9 +647,15 @@
|
||||
<artifactId>lucene-analyzers-stempel</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Tika is used to extract full text from documents in order to index in Solr -->
|
||||
<dependency>
|
||||
<groupId>org.apache.xmlbeans</groupId>
|
||||
<artifactId>xmlbeans</artifactId>
|
||||
<groupId>org.apache.tika</groupId>
|
||||
<artifactId>tika-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.tika</groupId>
|
||||
<artifactId>tika-parsers-standard-package</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@@ -702,13 +679,6 @@
|
||||
<version>1.1.1</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Gson: Java to Json conversion -->
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
@@ -736,7 +706,7 @@
|
||||
<dependency>
|
||||
<groupId>org.flywaydb</groupId>
|
||||
<artifactId>flyway-core</artifactId>
|
||||
<version>6.5.7</version>
|
||||
<version>8.4.4</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Google Analytics -->
|
||||
@@ -792,44 +762,6 @@
|
||||
<artifactId>jaxb-runtime</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Apache Axiom -->
|
||||
<dependency>
|
||||
<groupId>org.apache.ws.commons.axiom</groupId>
|
||||
<artifactId>axiom-impl</artifactId>
|
||||
<version>${axiom.version}</version>
|
||||
<exclusions>
|
||||
<!-- Exclude Geronimo as it is NOT necessary when using javax.activation (which we use)
|
||||
See: https://ws.apache.org/axiom/userguide/ch04.html#d0e732 -->
|
||||
<exclusion>
|
||||
<groupId>org.apache.geronimo.specs</groupId>
|
||||
<artifactId>*</artifactId>
|
||||
</exclusion>
|
||||
<!-- Exclude Woodstox, as later version provided by Solr dependencies -->
|
||||
<exclusion>
|
||||
<groupId>org.codehaus.woodstox</groupId>
|
||||
<artifactId>woodstox-core-asl</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.ws.commons.axiom</groupId>
|
||||
<artifactId>axiom-api</artifactId>
|
||||
<version>${axiom.version}</version>
|
||||
<exclusions>
|
||||
<!-- Exclude Geronimo as it is NOT necessary when using javax.activation (which we use)
|
||||
See: https://ws.apache.org/axiom/userguide/ch04.html#d0e732 -->
|
||||
<exclusion>
|
||||
<groupId>org.apache.geronimo.specs</groupId>
|
||||
<artifactId>*</artifactId>
|
||||
</exclusion>
|
||||
<!-- Exclude Woodstox, as later version provided by Solr dependencies -->
|
||||
<exclusion>
|
||||
<groupId>org.codehaus.woodstox</groupId>
|
||||
<artifactId>woodstox-core-asl</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<!-- Jersey / JAX-RS client (javax.ws.rs.*) dependencies needed to integrate with external sources/services -->
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.core</groupId>
|
||||
@@ -885,6 +817,14 @@
|
||||
<version>20180130</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Useful for testing command-line tools -->
|
||||
<dependency>
|
||||
<groupId>com.github.stefanbirkner</groupId>
|
||||
<artifactId>system-rules</artifactId>
|
||||
<version>1.19.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Used for Solr core export/import -->
|
||||
<dependency>
|
||||
<groupId>com.opencsv</groupId>
|
||||
@@ -896,7 +836,6 @@
|
||||
<dependency>
|
||||
<groupId>org.apache.velocity</groupId>
|
||||
<artifactId>velocity-engine-core</artifactId>
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@@ -918,13 +857,6 @@
|
||||
<version>2.0.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.stefanbirkner</groupId>
|
||||
<artifactId>system-rules</artifactId>
|
||||
<version>1.19.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mock-server</groupId>
|
||||
<artifactId>mockserver-junit-rule</artifactId>
|
||||
@@ -971,7 +903,7 @@
|
||||
<dependency>
|
||||
<groupId>org.apache.velocity</groupId>
|
||||
<artifactId>velocity-engine-core</artifactId>
|
||||
<version>2.2</version>
|
||||
<version>2.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.xmlunit</groupId>
|
||||
|
@@ -11,13 +11,16 @@ import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.transform.TransformerException;
|
||||
import javax.xml.xpath.XPath;
|
||||
import javax.xml.xpath.XPathConstants;
|
||||
import javax.xml.xpath.XPathExpressionException;
|
||||
import javax.xml.xpath.XPathFactory;
|
||||
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
import org.apache.commons.cli.CommandLineParser;
|
||||
import org.apache.commons.cli.DefaultParser;
|
||||
import org.apache.commons.cli.Options;
|
||||
import org.apache.commons.cli.ParseException;
|
||||
import org.apache.xpath.XPathAPI;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.MetadataField;
|
||||
import org.dspace.content.MetadataSchema;
|
||||
@@ -90,7 +93,7 @@ public class MetadataImporter {
|
||||
public static void main(String[] args)
|
||||
throws ParseException, SQLException, IOException, TransformerException,
|
||||
ParserConfigurationException, AuthorizeException, SAXException,
|
||||
NonUniqueMetadataException, RegistryImportException {
|
||||
NonUniqueMetadataException, RegistryImportException, XPathExpressionException {
|
||||
|
||||
// create an options object and populate it
|
||||
CommandLineParser parser = new DefaultParser();
|
||||
@@ -124,8 +127,8 @@ public class MetadataImporter {
|
||||
* @throws RegistryImportException if import fails
|
||||
*/
|
||||
public static void loadRegistry(String file, boolean forceUpdate)
|
||||
throws SQLException, IOException, TransformerException, ParserConfigurationException,
|
||||
AuthorizeException, SAXException, NonUniqueMetadataException, RegistryImportException {
|
||||
throws SQLException, IOException, TransformerException, ParserConfigurationException, AuthorizeException,
|
||||
SAXException, NonUniqueMetadataException, RegistryImportException, XPathExpressionException {
|
||||
Context context = null;
|
||||
|
||||
try {
|
||||
@@ -137,7 +140,9 @@ public class MetadataImporter {
|
||||
Document document = RegistryImporter.loadXML(file);
|
||||
|
||||
// Get the nodes corresponding to types
|
||||
NodeList schemaNodes = XPathAPI.selectNodeList(document, "/dspace-dc-types/dc-schema");
|
||||
XPath xPath = XPathFactory.newInstance().newXPath();
|
||||
NodeList schemaNodes = (NodeList) xPath.compile("/dspace-dc-types/dc-schema")
|
||||
.evaluate(document, XPathConstants.NODESET);
|
||||
|
||||
// Add each one as a new format to the registry
|
||||
for (int i = 0; i < schemaNodes.getLength(); i++) {
|
||||
@@ -146,7 +151,8 @@ public class MetadataImporter {
|
||||
}
|
||||
|
||||
// Get the nodes corresponding to types
|
||||
NodeList typeNodes = XPathAPI.selectNodeList(document, "/dspace-dc-types/dc-type");
|
||||
NodeList typeNodes = (NodeList) xPath.compile("/dspace-dc-types/dc-type")
|
||||
.evaluate(document, XPathConstants.NODESET);
|
||||
|
||||
// Add each one as a new format to the registry
|
||||
for (int i = 0; i < typeNodes.getLength(); i++) {
|
||||
@@ -178,8 +184,8 @@ public class MetadataImporter {
|
||||
* @throws RegistryImportException if import fails
|
||||
*/
|
||||
private static void loadSchema(Context context, Node node, boolean updateExisting)
|
||||
throws SQLException, IOException, TransformerException,
|
||||
AuthorizeException, NonUniqueMetadataException, RegistryImportException {
|
||||
throws SQLException, AuthorizeException, NonUniqueMetadataException, RegistryImportException,
|
||||
XPathExpressionException {
|
||||
// Get the values
|
||||
String name = RegistryImporter.getElementData(node, "name");
|
||||
String namespace = RegistryImporter.getElementData(node, "namespace");
|
||||
@@ -236,8 +242,8 @@ public class MetadataImporter {
|
||||
* @throws RegistryImportException if import fails
|
||||
*/
|
||||
private static void loadType(Context context, Node node)
|
||||
throws SQLException, IOException, TransformerException,
|
||||
AuthorizeException, NonUniqueMetadataException, RegistryImportException {
|
||||
throws SQLException, IOException, AuthorizeException, NonUniqueMetadataException, RegistryImportException,
|
||||
XPathExpressionException {
|
||||
// Get the values
|
||||
String schema = RegistryImporter.getElementData(node, "schema");
|
||||
String element = RegistryImporter.getElementData(node, "element");
|
||||
|
@@ -13,8 +13,11 @@ import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.transform.TransformerException;
|
||||
import javax.xml.xpath.XPath;
|
||||
import javax.xml.xpath.XPathConstants;
|
||||
import javax.xml.xpath.XPathExpressionException;
|
||||
import javax.xml.xpath.XPathFactory;
|
||||
|
||||
import org.apache.xpath.XPathAPI;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
@@ -72,9 +75,10 @@ public class RegistryImporter {
|
||||
* @throws TransformerException if error
|
||||
*/
|
||||
public static String getElementData(Node parentElement, String childName)
|
||||
throws TransformerException {
|
||||
throws XPathExpressionException {
|
||||
// Grab the child node
|
||||
Node childNode = XPathAPI.selectSingleNode(parentElement, childName);
|
||||
XPath xPath = XPathFactory.newInstance().newXPath();
|
||||
Node childNode = (Node) xPath.compile(childName).evaluate(parentElement, XPathConstants.NODE);
|
||||
|
||||
if (childNode == null) {
|
||||
// No child node, so no values
|
||||
@@ -115,9 +119,10 @@ public class RegistryImporter {
|
||||
* @throws TransformerException if error
|
||||
*/
|
||||
public static String[] getRepeatedElementData(Node parentElement,
|
||||
String childName) throws TransformerException {
|
||||
String childName) throws XPathExpressionException {
|
||||
// Grab the child node
|
||||
NodeList childNodes = XPathAPI.selectNodeList(parentElement, childName);
|
||||
XPath xPath = XPathFactory.newInstance().newXPath();
|
||||
NodeList childNodes = (NodeList) xPath.compile(childName).evaluate(parentElement, XPathConstants.NODESET);
|
||||
|
||||
String[] data = new String[childNodes.getLength()];
|
||||
|
||||
|
@@ -16,9 +16,12 @@ import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.transform.TransformerException;
|
||||
import javax.xml.xpath.XPath;
|
||||
import javax.xml.xpath.XPathConstants;
|
||||
import javax.xml.xpath.XPathExpressionException;
|
||||
import javax.xml.xpath.XPathFactory;
|
||||
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.xpath.XPathAPI;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.BitstreamFormat;
|
||||
import org.dspace.content.factory.ContentServiceFactory;
|
||||
@@ -122,12 +125,13 @@ public class RegistryLoader {
|
||||
*/
|
||||
public static void loadBitstreamFormats(Context context, String filename)
|
||||
throws SQLException, IOException, ParserConfigurationException,
|
||||
SAXException, TransformerException, AuthorizeException {
|
||||
SAXException, TransformerException, AuthorizeException, XPathExpressionException {
|
||||
Document document = loadXML(filename);
|
||||
|
||||
// Get the nodes corresponding to formats
|
||||
NodeList typeNodes = XPathAPI.selectNodeList(document,
|
||||
"dspace-bitstream-types/bitstream-type");
|
||||
XPath xPath = XPathFactory.newInstance().newXPath();
|
||||
NodeList typeNodes = (NodeList) xPath.compile("dspace-bitstream-types/bitstream-type")
|
||||
.evaluate(document, XPathConstants.NODESET);
|
||||
|
||||
// Add each one as a new format to the registry
|
||||
for (int i = 0; i < typeNodes.getLength(); i++) {
|
||||
@@ -151,8 +155,7 @@ public class RegistryLoader {
|
||||
* @throws AuthorizeException if authorization error
|
||||
*/
|
||||
private static void loadFormat(Context context, Node node)
|
||||
throws SQLException, IOException, TransformerException,
|
||||
AuthorizeException {
|
||||
throws SQLException, AuthorizeException, XPathExpressionException {
|
||||
// Get the values
|
||||
String mimeType = getElementData(node, "mimetype");
|
||||
String shortDesc = getElementData(node, "short_description");
|
||||
@@ -231,9 +234,10 @@ public class RegistryLoader {
|
||||
* @throws TransformerException if transformer error
|
||||
*/
|
||||
private static String getElementData(Node parentElement, String childName)
|
||||
throws TransformerException {
|
||||
throws XPathExpressionException {
|
||||
// Grab the child node
|
||||
Node childNode = XPathAPI.selectSingleNode(parentElement, childName);
|
||||
XPath xPath = XPathFactory.newInstance().newXPath();
|
||||
Node childNode = (Node) xPath.compile(childName).evaluate(parentElement, XPathConstants.NODE);
|
||||
|
||||
if (childNode == null) {
|
||||
// No child node, so no values
|
||||
@@ -274,9 +278,10 @@ public class RegistryLoader {
|
||||
* @throws TransformerException if transformer error
|
||||
*/
|
||||
private static String[] getRepeatedElementData(Node parentElement,
|
||||
String childName) throws TransformerException {
|
||||
String childName) throws XPathExpressionException {
|
||||
// Grab the child node
|
||||
NodeList childNodes = XPathAPI.selectNodeList(parentElement, childName);
|
||||
XPath xPath = XPathFactory.newInstance().newXPath();
|
||||
NodeList childNodes = (NodeList) xPath.compile(childName).evaluate(parentElement, XPathConstants.NODESET);
|
||||
|
||||
String[] data = new String[childNodes.getLength()];
|
||||
|
||||
|
@@ -30,6 +30,10 @@ import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.transform.TransformerException;
|
||||
import javax.xml.xpath.XPath;
|
||||
import javax.xml.xpath.XPathConstants;
|
||||
import javax.xml.xpath.XPathExpressionException;
|
||||
import javax.xml.xpath.XPathFactory;
|
||||
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
import org.apache.commons.cli.CommandLineParser;
|
||||
@@ -38,7 +42,6 @@ import org.apache.commons.cli.HelpFormatter;
|
||||
import org.apache.commons.cli.Option;
|
||||
import org.apache.commons.cli.Options;
|
||||
import org.apache.commons.cli.ParseException;
|
||||
import org.apache.xpath.XPathAPI;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.Collection;
|
||||
import org.dspace.content.Community;
|
||||
@@ -52,9 +55,9 @@ import org.dspace.content.service.CommunityService;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.eperson.factory.EPersonServiceFactory;
|
||||
import org.dspace.eperson.service.EPersonService;
|
||||
import org.jdom.Element;
|
||||
import org.jdom.output.Format;
|
||||
import org.jdom.output.XMLOutputter;
|
||||
import org.jdom2.Element;
|
||||
import org.jdom2.output.Format;
|
||||
import org.jdom2.output.XMLOutputter;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
@@ -137,8 +140,8 @@ public class StructBuilder {
|
||||
* @throws TransformerException if the input document is invalid.
|
||||
*/
|
||||
public static void main(String[] argv)
|
||||
throws ParserConfigurationException, SQLException,
|
||||
FileNotFoundException, IOException, TransformerException {
|
||||
throws ParserConfigurationException, SQLException,
|
||||
IOException, TransformerException, XPathExpressionException {
|
||||
// Define command line options.
|
||||
Options options = new Options();
|
||||
|
||||
@@ -240,7 +243,7 @@ public class StructBuilder {
|
||||
* @throws SQLException
|
||||
*/
|
||||
static void importStructure(Context context, InputStream input, OutputStream output)
|
||||
throws IOException, ParserConfigurationException, SQLException, TransformerException {
|
||||
throws IOException, ParserConfigurationException, SQLException, TransformerException, XPathExpressionException {
|
||||
|
||||
// load the XML
|
||||
Document document = null;
|
||||
@@ -258,13 +261,15 @@ public class StructBuilder {
|
||||
// is properly structured.
|
||||
try {
|
||||
validate(document);
|
||||
} catch (TransformerException ex) {
|
||||
} catch (XPathExpressionException ex) {
|
||||
System.err.format("The input document is invalid: %s%n", ex.getMessage());
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
// Check for 'identifier' attributes -- possibly output by this class.
|
||||
NodeList identifierNodes = XPathAPI.selectNodeList(document, "//*[@identifier]");
|
||||
XPath xPath = XPathFactory.newInstance().newXPath();
|
||||
NodeList identifierNodes = (NodeList) xPath.compile("//*[@identifier]")
|
||||
.evaluate(document, XPathConstants.NODESET);
|
||||
if (identifierNodes.getLength() > 0) {
|
||||
System.err.println("The input document has 'identifier' attributes, which will be ignored.");
|
||||
}
|
||||
@@ -287,7 +292,8 @@ public class StructBuilder {
|
||||
Element[] elements = new Element[]{};
|
||||
try {
|
||||
// get the top level community list
|
||||
NodeList first = XPathAPI.selectNodeList(document, "/import_structure/community");
|
||||
NodeList first = (NodeList) xPath.compile("/import_structure/community")
|
||||
.evaluate(document, XPathConstants.NODESET);
|
||||
|
||||
// run the import starting with the top level communities
|
||||
elements = handleCommunities(context, first, null);
|
||||
@@ -307,7 +313,7 @@ public class StructBuilder {
|
||||
}
|
||||
|
||||
// finally write the string into the output file.
|
||||
final org.jdom.Document xmlOutput = new org.jdom.Document(root);
|
||||
final org.jdom2.Document xmlOutput = new org.jdom2.Document(root);
|
||||
try {
|
||||
new XMLOutputter().output(xmlOutput, output);
|
||||
} catch (IOException e) {
|
||||
@@ -411,7 +417,7 @@ public class StructBuilder {
|
||||
}
|
||||
|
||||
// Now write the structure out.
|
||||
org.jdom.Document xmlOutput = new org.jdom.Document(rootElement);
|
||||
org.jdom2.Document xmlOutput = new org.jdom2.Document(rootElement);
|
||||
try {
|
||||
XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat());
|
||||
outputter.output(xmlOutput, output);
|
||||
@@ -456,14 +462,16 @@ public class StructBuilder {
|
||||
* @throws TransformerException if transformer error
|
||||
*/
|
||||
private static void validate(org.w3c.dom.Document document)
|
||||
throws TransformerException {
|
||||
throws XPathExpressionException {
|
||||
StringBuilder err = new StringBuilder();
|
||||
boolean trip = false;
|
||||
|
||||
err.append("The following errors were encountered parsing the source XML.\n");
|
||||
err.append("No changes have been made to the DSpace instance.\n\n");
|
||||
|
||||
NodeList first = XPathAPI.selectNodeList(document, "/import_structure/community");
|
||||
XPath xPath = XPathFactory.newInstance().newXPath();
|
||||
NodeList first = (NodeList) xPath.compile("/import_structure/community")
|
||||
.evaluate(document, XPathConstants.NODESET);
|
||||
if (first.getLength() == 0) {
|
||||
err.append("-There are no top level communities in the source document.");
|
||||
System.out.println(err.toString());
|
||||
@@ -493,14 +501,15 @@ public class StructBuilder {
|
||||
* no errors.
|
||||
*/
|
||||
private static String validateCommunities(NodeList communities, int level)
|
||||
throws TransformerException {
|
||||
throws XPathExpressionException {
|
||||
StringBuilder err = new StringBuilder();
|
||||
boolean trip = false;
|
||||
String errs = null;
|
||||
XPath xPath = XPathFactory.newInstance().newXPath();
|
||||
|
||||
for (int i = 0; i < communities.getLength(); i++) {
|
||||
Node n = communities.item(i);
|
||||
NodeList name = XPathAPI.selectNodeList(n, "name");
|
||||
NodeList name = (NodeList) xPath.compile("name").evaluate(n, XPathConstants.NODESET);
|
||||
if (name.getLength() != 1) {
|
||||
String pos = Integer.toString(i + 1);
|
||||
err.append("-The level ").append(level)
|
||||
@@ -510,7 +519,7 @@ public class StructBuilder {
|
||||
}
|
||||
|
||||
// validate sub communities
|
||||
NodeList subCommunities = XPathAPI.selectNodeList(n, "community");
|
||||
NodeList subCommunities = (NodeList) xPath.compile("community").evaluate(n, XPathConstants.NODESET);
|
||||
String comErrs = validateCommunities(subCommunities, level + 1);
|
||||
if (comErrs != null) {
|
||||
err.append(comErrs);
|
||||
@@ -518,7 +527,7 @@ public class StructBuilder {
|
||||
}
|
||||
|
||||
// validate collections
|
||||
NodeList collections = XPathAPI.selectNodeList(n, "collection");
|
||||
NodeList collections = (NodeList) xPath.compile("collection").evaluate(n, XPathConstants.NODESET);
|
||||
String colErrs = validateCollections(collections, level + 1);
|
||||
if (colErrs != null) {
|
||||
err.append(colErrs);
|
||||
@@ -542,14 +551,15 @@ public class StructBuilder {
|
||||
* @return the errors to be generated by the calling method, or null if none
|
||||
*/
|
||||
private static String validateCollections(NodeList collections, int level)
|
||||
throws TransformerException {
|
||||
throws XPathExpressionException {
|
||||
StringBuilder err = new StringBuilder();
|
||||
boolean trip = false;
|
||||
String errs = null;
|
||||
XPath xPath = XPathFactory.newInstance().newXPath();
|
||||
|
||||
for (int i = 0; i < collections.getLength(); i++) {
|
||||
Node n = collections.item(i);
|
||||
NodeList name = XPathAPI.selectNodeList(n, "name");
|
||||
NodeList name = (NodeList) xPath.compile("name").evaluate(n, XPathConstants.NODESET);
|
||||
if (name.getLength() != 1) {
|
||||
String pos = Integer.toString(i + 1);
|
||||
err.append("-The level ").append(level)
|
||||
@@ -613,8 +623,9 @@ public class StructBuilder {
|
||||
* created communities (e.g. the handles they have been assigned)
|
||||
*/
|
||||
private static Element[] handleCommunities(Context context, NodeList communities, Community parent)
|
||||
throws TransformerException, SQLException, AuthorizeException {
|
||||
throws TransformerException, SQLException, AuthorizeException, XPathExpressionException {
|
||||
Element[] elements = new Element[communities.getLength()];
|
||||
XPath xPath = XPathFactory.newInstance().newXPath();
|
||||
|
||||
for (int i = 0; i < communities.getLength(); i++) {
|
||||
Community community;
|
||||
@@ -634,7 +645,7 @@ public class StructBuilder {
|
||||
// now update the metadata
|
||||
Node tn = communities.item(i);
|
||||
for (Map.Entry<String, MetadataFieldName> entry : communityMap.entrySet()) {
|
||||
NodeList nl = XPathAPI.selectNodeList(tn, entry.getKey());
|
||||
NodeList nl = (NodeList) xPath.compile(entry.getKey()).evaluate(tn, XPathConstants.NODESET);
|
||||
if (nl.getLength() == 1) {
|
||||
communityService.setMetadataSingleValue(context, community,
|
||||
entry.getValue(), null, getStringValue(nl.item(0)));
|
||||
@@ -700,11 +711,11 @@ public class StructBuilder {
|
||||
}
|
||||
|
||||
// handle sub communities
|
||||
NodeList subCommunities = XPathAPI.selectNodeList(tn, "community");
|
||||
NodeList subCommunities = (NodeList) xPath.compile("community").evaluate(tn, XPathConstants.NODESET);
|
||||
Element[] subCommunityElements = handleCommunities(context, subCommunities, community);
|
||||
|
||||
// handle collections
|
||||
NodeList collections = XPathAPI.selectNodeList(tn, "collection");
|
||||
NodeList collections = (NodeList) xPath.compile("collection").evaluate(tn, XPathConstants.NODESET);
|
||||
Element[] collectionElements = handleCollections(context, collections, community);
|
||||
|
||||
int j;
|
||||
@@ -731,8 +742,9 @@ public class StructBuilder {
|
||||
* created collections (e.g. the handle)
|
||||
*/
|
||||
private static Element[] handleCollections(Context context, NodeList collections, Community parent)
|
||||
throws TransformerException, SQLException, AuthorizeException {
|
||||
throws SQLException, AuthorizeException, XPathExpressionException {
|
||||
Element[] elements = new Element[collections.getLength()];
|
||||
XPath xPath = XPathFactory.newInstance().newXPath();
|
||||
|
||||
for (int i = 0; i < collections.getLength(); i++) {
|
||||
Element element = new Element("collection");
|
||||
@@ -745,7 +757,7 @@ public class StructBuilder {
|
||||
// import the rest of the metadata
|
||||
Node tn = collections.item(i);
|
||||
for (Map.Entry<String, MetadataFieldName> entry : collectionMap.entrySet()) {
|
||||
NodeList nl = XPathAPI.selectNodeList(tn, entry.getKey());
|
||||
NodeList nl = (NodeList) xPath.compile(entry.getKey()).evaluate(tn, XPathConstants.NODESET);
|
||||
if (nl.getLength() == 1) {
|
||||
collectionService.setMetadataSingleValue(context, collection,
|
||||
entry.getValue(), null, getStringValue(nl.item(0)));
|
||||
|
@@ -41,10 +41,8 @@ public class MetadataDeletionScriptConfiguration<T extends MetadataDeletion> ext
|
||||
Options options = new Options();
|
||||
|
||||
options.addOption("m", "metadata", true, "metadata field name");
|
||||
options.getOption("m").setType(String.class);
|
||||
|
||||
options.addOption("l", "list", false, "lists the metadata fields that can be deleted");
|
||||
options.getOption("l").setType(boolean.class);
|
||||
|
||||
super.options = options;
|
||||
}
|
||||
|
@@ -54,12 +54,9 @@ public class MetadataExportScriptConfiguration<T extends MetadataExport> extends
|
||||
Options options = new Options();
|
||||
|
||||
options.addOption("i", "id", true, "ID or handle of thing to export (item, collection, or community)");
|
||||
options.getOption("i").setType(String.class);
|
||||
options.addOption("a", "all", false,
|
||||
"include all metadata fields that are not normally changed (e.g. provenance)");
|
||||
options.getOption("a").setType(boolean.class);
|
||||
options.addOption("h", "help", false, "help");
|
||||
options.getOption("h").setType(boolean.class);
|
||||
|
||||
|
||||
super.options = options;
|
||||
|
@@ -19,7 +19,6 @@ public class MetadataImportCliScriptConfiguration extends MetadataImportScriptCo
|
||||
public Options getOptions() {
|
||||
Options options = super.getOptions();
|
||||
options.addOption("e", "email", true, "email address or user id of user (required if adding new items)");
|
||||
options.getOption("e").setType(String.class);
|
||||
options.getOption("e").setRequired(true);
|
||||
super.options = options;
|
||||
return options;
|
||||
|
@@ -59,20 +59,14 @@ public class MetadataImportScriptConfiguration<T extends MetadataImport> extends
|
||||
options.getOption("f").setRequired(true);
|
||||
options.addOption("s", "silent", false,
|
||||
"silent operation - doesn't request confirmation of changes USE WITH CAUTION");
|
||||
options.getOption("s").setType(boolean.class);
|
||||
options.addOption("w", "workflow", false, "workflow - when adding new items, use collection workflow");
|
||||
options.getOption("w").setType(boolean.class);
|
||||
options.addOption("n", "notify", false,
|
||||
"notify - when adding new items using a workflow, send notification emails");
|
||||
options.getOption("n").setType(boolean.class);
|
||||
options.addOption("v", "validate-only", false,
|
||||
"validate - just validate the csv, don't run the import");
|
||||
options.getOption("v").setType(boolean.class);
|
||||
options.addOption("t", "template", false,
|
||||
"template - when adding new items, use the collection template (if it exists)");
|
||||
options.getOption("t").setType(boolean.class);
|
||||
options.addOption("h", "help", false, "help");
|
||||
options.getOption("h").setType(boolean.class);
|
||||
|
||||
super.options = options;
|
||||
}
|
||||
|
@@ -43,22 +43,14 @@ public class HarvestScriptConfiguration<T extends Harvest> extends ScriptConfigu
|
||||
public Options getOptions() {
|
||||
Options options = new Options();
|
||||
options.addOption("p", "purge", false, "delete all items in the collection");
|
||||
options.getOption("p").setType(boolean.class);
|
||||
options.addOption("r", "run", false, "run the standard harvest procedure");
|
||||
options.getOption("r").setType(boolean.class);
|
||||
options.addOption("g", "ping", false, "test the OAI server and set");
|
||||
options.getOption("g").setType(boolean.class);
|
||||
options.addOption("s", "setup", false, "Set the collection up for harvesting");
|
||||
options.getOption("s").setType(boolean.class);
|
||||
options.addOption("S", "start", false, "start the harvest loop");
|
||||
options.getOption("S").setType(boolean.class);
|
||||
options.addOption("R", "reset", false, "reset harvest status on all collections");
|
||||
options.getOption("R").setType(boolean.class);
|
||||
options.addOption("P", "purgeCollections", false, "purge all harvestable collections");
|
||||
options.getOption("P").setType(boolean.class);
|
||||
options.addOption("o", "reimport", false, "reimport all items in the collection, " +
|
||||
"this is equivalent to -p -r, purging all items in a collection and reimporting them");
|
||||
options.getOption("o").setType(boolean.class);
|
||||
options.addOption("c", "collection", true,
|
||||
"harvesting collection (handle or id)");
|
||||
options.addOption("t", "type", true,
|
||||
@@ -72,7 +64,6 @@ public class HarvestScriptConfiguration<T extends Harvest> extends ScriptConfigu
|
||||
"crosswalk in dspace.cfg");
|
||||
|
||||
options.addOption("h", "help", false, "help");
|
||||
options.getOption("h").setType(boolean.class);
|
||||
|
||||
return options;
|
||||
}
|
||||
|
@@ -51,6 +51,10 @@ import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.transform.TransformerException;
|
||||
import javax.xml.xpath.XPath;
|
||||
import javax.xml.xpath.XPathConstants;
|
||||
import javax.xml.xpath.XPathExpressionException;
|
||||
import javax.xml.xpath.XPathFactory;
|
||||
|
||||
import org.apache.commons.collections4.ComparatorUtils;
|
||||
import org.apache.commons.io.FileDeleteStrategy;
|
||||
@@ -59,7 +63,6 @@ import org.apache.commons.lang3.RandomStringUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.xpath.XPathAPI;
|
||||
import org.dspace.app.itemimport.service.ItemImportService;
|
||||
import org.dspace.app.util.LocalSchemaFilenameFilter;
|
||||
import org.dspace.app.util.RelationshipUtils;
|
||||
@@ -861,7 +864,7 @@ public class ItemImportServiceImpl implements ItemImportService, InitializingBea
|
||||
// Load all metadata schemas into the item.
|
||||
protected void loadMetadata(Context c, Item myitem, String path)
|
||||
throws SQLException, IOException, ParserConfigurationException,
|
||||
SAXException, TransformerException, AuthorizeException {
|
||||
SAXException, TransformerException, AuthorizeException, XPathExpressionException {
|
||||
// Load the dublin core metadata
|
||||
loadDublinCore(c, myitem, path + "dublin_core.xml");
|
||||
|
||||
@@ -875,14 +878,15 @@ public class ItemImportServiceImpl implements ItemImportService, InitializingBea
|
||||
|
||||
protected void loadDublinCore(Context c, Item myitem, String filename)
|
||||
throws SQLException, IOException, ParserConfigurationException,
|
||||
SAXException, TransformerException, AuthorizeException {
|
||||
SAXException, TransformerException, AuthorizeException, XPathExpressionException {
|
||||
Document document = loadXML(filename);
|
||||
|
||||
// Get the schema, for backward compatibility we will default to the
|
||||
// dublin core schema if the schema name is not available in the import
|
||||
// file
|
||||
String schema;
|
||||
NodeList metadata = XPathAPI.selectNodeList(document, "/dublin_core");
|
||||
XPath xPath = XPathFactory.newInstance().newXPath();
|
||||
NodeList metadata = (NodeList) xPath.compile("/dublin_core").evaluate(document, XPathConstants.NODESET);
|
||||
Node schemaAttr = metadata.item(0).getAttributes().getNamedItem(
|
||||
"schema");
|
||||
if (schemaAttr == null) {
|
||||
@@ -892,8 +896,7 @@ public class ItemImportServiceImpl implements ItemImportService, InitializingBea
|
||||
}
|
||||
|
||||
// Get the nodes corresponding to formats
|
||||
NodeList dcNodes = XPathAPI.selectNodeList(document,
|
||||
"/dublin_core/dcvalue");
|
||||
NodeList dcNodes = (NodeList) xPath.compile("/dublin_core/dcvalue").evaluate(document, XPathConstants.NODESET);
|
||||
|
||||
if (!isQuiet) {
|
||||
System.out.println("\tLoading dublin core from " + filename);
|
||||
|
@@ -27,10 +27,12 @@ import javax.xml.transform.TransformerConfigurationException;
|
||||
import javax.xml.transform.TransformerException;
|
||||
import javax.xml.transform.dom.DOMSource;
|
||||
import javax.xml.transform.stream.StreamResult;
|
||||
import javax.xml.xpath.XPath;
|
||||
import javax.xml.xpath.XPathConstants;
|
||||
import javax.xml.xpath.XPathExpressionException;
|
||||
import javax.xml.xpath.XPathFactory;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.xpath.XPathAPI;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.content.MetadataField;
|
||||
import org.dspace.content.MetadataSchema;
|
||||
@@ -170,24 +172,21 @@ public class MetadataUtilities {
|
||||
* @param docBuilder DocumentBuilder
|
||||
* @param is - InputStream of dublin_core.xml
|
||||
* @return list of DtoMetadata representing the metadata fields relating to an Item
|
||||
* @throws SQLException if database error
|
||||
* @throws IOException if IO error
|
||||
* @throws ParserConfigurationException if parser config error
|
||||
* @throws SAXException if XML error
|
||||
* @throws TransformerException if transformer error
|
||||
* @throws AuthorizeException if authorization error
|
||||
*/
|
||||
public static List<DtoMetadata> loadDublinCore(DocumentBuilder docBuilder, InputStream is)
|
||||
throws SQLException, IOException, ParserConfigurationException,
|
||||
SAXException, TransformerException, AuthorizeException {
|
||||
throws IOException, XPathExpressionException, SAXException {
|
||||
Document document = docBuilder.parse(is);
|
||||
|
||||
List<DtoMetadata> dtomList = new ArrayList<DtoMetadata>();
|
||||
|
||||
// Get the schema, for backward compatibility we will default to the
|
||||
// dublin core schema if the schema name is not available in the import file
|
||||
String schema = null;
|
||||
NodeList metadata = XPathAPI.selectNodeList(document, "/dublin_core");
|
||||
String schema;
|
||||
XPath xPath = XPathFactory.newInstance().newXPath();
|
||||
NodeList metadata = (NodeList) xPath.compile("/dublin_core").evaluate(document, XPathConstants.NODESET);
|
||||
Node schemaAttr = metadata.item(0).getAttributes().getNamedItem("schema");
|
||||
if (schemaAttr == null) {
|
||||
schema = MetadataSchemaEnum.DC.getName();
|
||||
@@ -196,7 +195,7 @@ public class MetadataUtilities {
|
||||
}
|
||||
|
||||
// Get the nodes corresponding to formats
|
||||
NodeList dcNodes = XPathAPI.selectNodeList(document, "/dublin_core/dcvalue");
|
||||
NodeList dcNodes = (NodeList) xPath.compile("/dublin_core/dcvalue").evaluate(document, XPathConstants.NODESET);
|
||||
|
||||
for (int i = 0; i < dcNodes.getLength(); i++) {
|
||||
Node n = dcNodes.item(i);
|
||||
|
@@ -16,7 +16,7 @@ import java.io.StreamTokenizer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.jdom.Document;
|
||||
import org.jdom2.Document;
|
||||
|
||||
/**
|
||||
* @author mwood
|
||||
|
@@ -29,9 +29,9 @@ import org.dspace.scripts.service.ScriptService;
|
||||
import org.dspace.servicemanager.DSpaceKernelImpl;
|
||||
import org.dspace.servicemanager.DSpaceKernelInit;
|
||||
import org.dspace.services.RequestService;
|
||||
import org.jdom.Document;
|
||||
import org.jdom.Element;
|
||||
import org.jdom.input.SAXBuilder;
|
||||
import org.jdom2.Document;
|
||||
import org.jdom2.Element;
|
||||
import org.jdom2.input.SAXBuilder;
|
||||
|
||||
/**
|
||||
* A DSpace script launcher.
|
||||
|
@@ -1,99 +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/
|
||||
*/
|
||||
package org.dspace.app.mediafilter;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.poi.POITextExtractor;
|
||||
import org.apache.poi.extractor.ExtractorFactory;
|
||||
import org.apache.poi.hssf.extractor.ExcelExtractor;
|
||||
import org.apache.poi.xssf.extractor.XSSFExcelExtractor;
|
||||
import org.dspace.content.Item;
|
||||
|
||||
/*
|
||||
* ExcelFilter
|
||||
*
|
||||
* Entries you must add to dspace.cfg:
|
||||
*
|
||||
* filter.plugins = blah, \
|
||||
* Excel Text Extractor
|
||||
*
|
||||
* plugin.named.org.dspace.app.mediafilter.FormatFilter = \
|
||||
* blah = blah, \
|
||||
* org.dspace.app.mediafilter.ExcelFilter = Excel Text Extractor
|
||||
*
|
||||
* #Configure each filter's input Formats
|
||||
* filter.org.dspace.app.mediafilter.ExcelFilter.inputFormats = Microsoft Excel, Microsoft Excel XML
|
||||
*
|
||||
*/
|
||||
public class ExcelFilter extends MediaFilter {
|
||||
|
||||
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(ExcelFilter.class);
|
||||
|
||||
public String getFilteredName(String oldFilename) {
|
||||
return oldFilename + ".txt";
|
||||
}
|
||||
|
||||
/**
|
||||
* @return String bundle name
|
||||
*/
|
||||
public String getBundleName() {
|
||||
return "TEXT";
|
||||
}
|
||||
|
||||
/**
|
||||
* @return String bitstream format
|
||||
*/
|
||||
public String getFormatString() {
|
||||
return "Text";
|
||||
}
|
||||
|
||||
/**
|
||||
* @return String description
|
||||
*/
|
||||
public String getDescription() {
|
||||
return "Extracted text";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param item item
|
||||
* @param source source input stream
|
||||
* @param verbose verbose mode
|
||||
* @return InputStream the resulting input stream
|
||||
* @throws Exception if error
|
||||
*/
|
||||
@Override
|
||||
public InputStream getDestinationStream(Item item, InputStream source, boolean verbose)
|
||||
throws Exception {
|
||||
String extractedText = null;
|
||||
|
||||
try {
|
||||
POITextExtractor theExtractor = ExtractorFactory.createExtractor(source);
|
||||
if (theExtractor instanceof ExcelExtractor) {
|
||||
// for xls file
|
||||
extractedText = (theExtractor).getText();
|
||||
} else if (theExtractor instanceof XSSFExcelExtractor) {
|
||||
// for xlsx file
|
||||
extractedText = (theExtractor).getText();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("Error filtering bitstream: " + e.getMessage(), e);
|
||||
throw e;
|
||||
}
|
||||
|
||||
if (extractedText != null) {
|
||||
// generate an input stream with the extracted text
|
||||
return IOUtils.toInputStream(extractedText, StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
@@ -1,82 +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/
|
||||
*/
|
||||
package org.dspace.app.mediafilter;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import javax.swing.text.Document;
|
||||
import javax.swing.text.html.HTMLEditorKit;
|
||||
|
||||
import org.dspace.content.Item;
|
||||
|
||||
/*
|
||||
*
|
||||
* to do: helpful error messages - can't find mediafilter.cfg - can't
|
||||
* instantiate filter - bitstream format doesn't exist
|
||||
*
|
||||
*/
|
||||
public class HTMLFilter extends MediaFilter {
|
||||
|
||||
@Override
|
||||
public String getFilteredName(String oldFilename) {
|
||||
return oldFilename + ".txt";
|
||||
}
|
||||
|
||||
/**
|
||||
* @return String bundle name
|
||||
*/
|
||||
@Override
|
||||
public String getBundleName() {
|
||||
return "TEXT";
|
||||
}
|
||||
|
||||
/**
|
||||
* @return String bitstream format
|
||||
*/
|
||||
@Override
|
||||
public String getFormatString() {
|
||||
return "Text";
|
||||
}
|
||||
|
||||
/**
|
||||
* @return String description
|
||||
*/
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Extracted text";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param currentItem item
|
||||
* @param source source input stream
|
||||
* @param verbose verbose mode
|
||||
* @return InputStream the resulting input stream
|
||||
* @throws Exception if error
|
||||
*/
|
||||
@Override
|
||||
public InputStream getDestinationStream(Item currentItem, InputStream source, boolean verbose)
|
||||
throws Exception {
|
||||
// try and read the document - set to ignore character set directive,
|
||||
// assuming that the input stream is already set properly (I hope)
|
||||
HTMLEditorKit kit = new HTMLEditorKit();
|
||||
Document doc = kit.createDefaultDocument();
|
||||
|
||||
doc.putProperty("IgnoreCharsetDirective", Boolean.TRUE);
|
||||
|
||||
kit.read(source, doc, 0);
|
||||
|
||||
String extractedText = doc.getText(0, doc.getLength());
|
||||
|
||||
// generate an input stream with the extracted text
|
||||
byte[] textBytes = extractedText.getBytes(StandardCharsets.UTF_8);
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(textBytes);
|
||||
|
||||
return bais;
|
||||
}
|
||||
}
|
@@ -50,15 +50,11 @@ public class MediaFilterScriptConfiguration<T extends MediaFilterScript> extends
|
||||
public Options getOptions() {
|
||||
Options options = new Options();
|
||||
options.addOption("v", "verbose", false, "print all extracted text and other details to STDOUT");
|
||||
options.getOption("v").setType(boolean.class);
|
||||
options.addOption("q", "quiet", false, "do not print anything except in the event of errors.");
|
||||
options.getOption("q").setType(boolean.class);
|
||||
options.addOption("f", "force", false, "force all bitstreams to be processed");
|
||||
options.getOption("f").setType(boolean.class);
|
||||
options.addOption("i", "identifier", true, "ONLY process bitstreams belonging to identifier");
|
||||
options.addOption("m", "maximum", true, "process no more than maximum items");
|
||||
options.addOption("h", "help", false, "help");
|
||||
options.getOption("h").setType(boolean.class);
|
||||
|
||||
Option pluginOption = Option.builder("p")
|
||||
.longOpt("plugins")
|
||||
|
@@ -1,137 +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/
|
||||
*/
|
||||
package org.dspace.app.mediafilter;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.Writer;
|
||||
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.pdfbox.pdmodel.PDDocument;
|
||||
import org.apache.pdfbox.pdmodel.encryption.InvalidPasswordException;
|
||||
import org.apache.pdfbox.text.PDFTextStripper;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
|
||||
/*
|
||||
*
|
||||
* to do: helpful error messages - can't find mediafilter.cfg - can't
|
||||
* instantiate filter - bitstream format doesn't exist
|
||||
*
|
||||
*/
|
||||
public class PDFFilter extends MediaFilter {
|
||||
|
||||
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(PDFFilter.class);
|
||||
|
||||
@Override
|
||||
public String getFilteredName(String oldFilename) {
|
||||
return oldFilename + ".txt";
|
||||
}
|
||||
|
||||
/**
|
||||
* @return String bundle name
|
||||
*/
|
||||
@Override
|
||||
public String getBundleName() {
|
||||
return "TEXT";
|
||||
}
|
||||
|
||||
/**
|
||||
* @return String bitstreamformat
|
||||
*/
|
||||
@Override
|
||||
public String getFormatString() {
|
||||
return "Text";
|
||||
}
|
||||
|
||||
/**
|
||||
* @return String description
|
||||
*/
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Extracted text";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param currentItem item
|
||||
* @param source source input stream
|
||||
* @param verbose verbose mode
|
||||
* @return InputStream the resulting input stream
|
||||
* @throws Exception if error
|
||||
*/
|
||||
@Override
|
||||
public InputStream getDestinationStream(Item currentItem, InputStream source, boolean verbose)
|
||||
throws Exception {
|
||||
ConfigurationService configurationService
|
||||
= DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||
try {
|
||||
boolean useTemporaryFile = configurationService.getBooleanProperty("pdffilter.largepdfs", false);
|
||||
|
||||
// get input stream from bitstream
|
||||
// pass to filter, get string back
|
||||
PDFTextStripper pts = new PDFTextStripper();
|
||||
pts.setSortByPosition(true);
|
||||
PDDocument pdfDoc = null;
|
||||
Writer writer = null;
|
||||
File tempTextFile = null;
|
||||
ByteArrayOutputStream byteStream = null;
|
||||
|
||||
if (useTemporaryFile) {
|
||||
tempTextFile = File.createTempFile("dspacepdfextract" + source.hashCode(), ".txt");
|
||||
tempTextFile.deleteOnExit();
|
||||
writer = new OutputStreamWriter(new FileOutputStream(tempTextFile));
|
||||
} else {
|
||||
byteStream = new ByteArrayOutputStream();
|
||||
writer = new OutputStreamWriter(byteStream);
|
||||
}
|
||||
|
||||
try {
|
||||
pdfDoc = PDDocument.load(source);
|
||||
pts.writeText(pdfDoc, writer);
|
||||
} catch (InvalidPasswordException ex) {
|
||||
log.error("PDF is encrypted. Cannot extract text (item: {})",
|
||||
() -> currentItem.getHandle());
|
||||
return null;
|
||||
} finally {
|
||||
try {
|
||||
if (pdfDoc != null) {
|
||||
pdfDoc.close();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("Error closing PDF file: " + e.getMessage(), e);
|
||||
}
|
||||
|
||||
try {
|
||||
writer.close();
|
||||
} catch (Exception e) {
|
||||
log.error("Error closing temporary extract file: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
if (useTemporaryFile) {
|
||||
return new FileInputStream(tempTextFile);
|
||||
} else {
|
||||
byte[] bytes = byteStream.toByteArray();
|
||||
return new ByteArrayInputStream(bytes);
|
||||
}
|
||||
} catch (OutOfMemoryError oome) {
|
||||
log.error("Error parsing PDF document " + oome.getMessage(), oome);
|
||||
if (!configurationService.getBooleanProperty("pdffilter.skiponmemoryexception", false)) {
|
||||
throw oome;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
@@ -1,72 +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/
|
||||
*/
|
||||
package org.dspace.app.mediafilter;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import org.apache.poi.POITextExtractor;
|
||||
import org.apache.poi.extractor.ExtractorFactory;
|
||||
import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
|
||||
import org.apache.xmlbeans.XmlException;
|
||||
import org.dspace.content.Item;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Extract flat text from Microsoft Word documents (.doc, .docx).
|
||||
*/
|
||||
public class PoiWordFilter
|
||||
extends MediaFilter {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(PoiWordFilter.class);
|
||||
|
||||
@Override
|
||||
public String getFilteredName(String oldFilename) {
|
||||
return oldFilename + ".txt";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBundleName() {
|
||||
return "TEXT";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFormatString() {
|
||||
return "Text";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Extracted text";
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getDestinationStream(Item currentItem, InputStream source, boolean verbose)
|
||||
throws Exception {
|
||||
String text;
|
||||
try {
|
||||
// get input stream from bitstream, pass to filter, get string back
|
||||
POITextExtractor extractor = ExtractorFactory.createExtractor(source);
|
||||
text = extractor.getText();
|
||||
} catch (IOException | OpenXML4JException | XmlException e) {
|
||||
System.err.format("Invalid File Format: %s%n", e.getMessage());
|
||||
LOG.error("Unable to parse the bitstream: ", e);
|
||||
throw e;
|
||||
}
|
||||
|
||||
// if verbose flag is set, print out extracted text to STDOUT
|
||||
if (verbose) {
|
||||
System.out.println(text);
|
||||
}
|
||||
|
||||
// return the extracted text as a stream.
|
||||
return new ByteArrayInputStream(text.getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
}
|
@@ -1,113 +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/
|
||||
*/
|
||||
package org.dspace.app.mediafilter;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.poi.POITextExtractor;
|
||||
import org.apache.poi.extractor.ExtractorFactory;
|
||||
import org.apache.poi.hslf.extractor.PowerPointExtractor;
|
||||
import org.apache.poi.xslf.extractor.XSLFPowerPointExtractor;
|
||||
import org.dspace.content.Item;
|
||||
|
||||
/*
|
||||
* TODO: Allow user to configure extraction of only text or only notes
|
||||
*
|
||||
*/
|
||||
public class PowerPointFilter extends MediaFilter {
|
||||
|
||||
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(PowerPointFilter.class);
|
||||
|
||||
@Override
|
||||
public String getFilteredName(String oldFilename) {
|
||||
return oldFilename + ".txt";
|
||||
}
|
||||
|
||||
/**
|
||||
* @return String bundle name
|
||||
*/
|
||||
@Override
|
||||
public String getBundleName() {
|
||||
return "TEXT";
|
||||
}
|
||||
|
||||
/**
|
||||
* @return String bitstream format
|
||||
*
|
||||
* TODO: Check that this is correct
|
||||
*/
|
||||
@Override
|
||||
public String getFormatString() {
|
||||
return "Text";
|
||||
}
|
||||
|
||||
/**
|
||||
* @return String description
|
||||
*/
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Extracted text";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param currentItem item
|
||||
* @param source source input stream
|
||||
* @param verbose verbose mode
|
||||
* @return InputStream the resulting input stream
|
||||
* @throws Exception if error
|
||||
*/
|
||||
@Override
|
||||
public InputStream getDestinationStream(Item currentItem, InputStream source, boolean verbose)
|
||||
throws Exception {
|
||||
|
||||
try {
|
||||
|
||||
String extractedText = null;
|
||||
new ExtractorFactory();
|
||||
POITextExtractor pptExtractor = ExtractorFactory
|
||||
.createExtractor(source);
|
||||
|
||||
// PowerPoint XML files and legacy format PowerPoint files
|
||||
// require different classes and APIs for text extraction
|
||||
|
||||
// If this is a PowerPoint XML file, extract accordingly
|
||||
if (pptExtractor instanceof XSLFPowerPointExtractor) {
|
||||
|
||||
// The true method arguments indicate that text from
|
||||
// the slides and the notes is desired
|
||||
extractedText = ((XSLFPowerPointExtractor) pptExtractor)
|
||||
.getText(true, true);
|
||||
} else if (pptExtractor instanceof PowerPointExtractor) { // Legacy PowerPoint files
|
||||
|
||||
extractedText = ((PowerPointExtractor) pptExtractor).getText()
|
||||
+ " " + ((PowerPointExtractor) pptExtractor).getNotes();
|
||||
|
||||
}
|
||||
if (extractedText != null) {
|
||||
// if verbose flag is set, print out extracted text
|
||||
// to STDOUT
|
||||
if (verbose) {
|
||||
System.out.println(extractedText);
|
||||
}
|
||||
|
||||
// generate an input stream with the extracted text
|
||||
byte[] textBytes = extractedText.getBytes();
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(textBytes);
|
||||
|
||||
return bais;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("Error filtering bitstream: " + e.getMessage(), e);
|
||||
throw e;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
@@ -0,0 +1,183 @@
|
||||
/**
|
||||
* 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.mediafilter;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.tika.Tika;
|
||||
import org.apache.tika.exception.TikaException;
|
||||
import org.apache.tika.metadata.Metadata;
|
||||
import org.apache.tika.parser.AutoDetectParser;
|
||||
import org.apache.tika.sax.BodyContentHandler;
|
||||
import org.apache.tika.sax.ContentHandlerDecorator;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
/**
|
||||
* Text Extraction media filter which uses Apache Tika to extract text from a large number of file formats (including
|
||||
* all Microsoft formats, PDF, HTML, Text, etc). For a more complete list of file formats supported by Tika see the
|
||||
* Tika documentation: https://tika.apache.org/2.3.0/formats.html
|
||||
*/
|
||||
public class TikaTextExtractionFilter
|
||||
extends MediaFilter {
|
||||
private final static Logger log = LogManager.getLogger();
|
||||
|
||||
@Override
|
||||
public String getFilteredName(String oldFilename) {
|
||||
return oldFilename + ".txt";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBundleName() {
|
||||
return "TEXT";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFormatString() {
|
||||
return "Text";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Extracted text";
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getDestinationStream(Item currentItem, InputStream source, boolean verbose)
|
||||
throws Exception {
|
||||
ConfigurationService configurationService = DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||
boolean useTemporaryFile = configurationService.getBooleanProperty("textextractor.use-temp-file", false);
|
||||
|
||||
if (useTemporaryFile) {
|
||||
// Extract text out of source file using a temp file, returning results as InputStream
|
||||
return extractUsingTempFile(source, verbose);
|
||||
}
|
||||
|
||||
// Not using temporary file. We'll use Tika's default in-memory parsing.
|
||||
// Get maximum characters to extract. Default is 100,000 chars, which is also Tika's default setting.
|
||||
String extractedText;
|
||||
int maxChars = configurationService.getIntProperty("textextractor.max-chars", 100000);
|
||||
try {
|
||||
// Use Tika to extract text from input. Tika will automatically detect the file type.
|
||||
Tika tika = new Tika();
|
||||
tika.setMaxStringLength(maxChars); // Tell Tika the maximum number of characters to extract
|
||||
extractedText = tika.parseToString(source);
|
||||
} catch (IOException e) {
|
||||
System.err.format("Unable to extract text from bitstream in Item %s%n", currentItem.getID().toString());
|
||||
e.printStackTrace();
|
||||
log.error("Unable to extract text from bitstream in Item {}", currentItem.getID().toString(), e);
|
||||
throw e;
|
||||
} catch (OutOfMemoryError oe) {
|
||||
System.err.format("OutOfMemoryError occurred when extracting text from bitstream in Item %s. " +
|
||||
"You may wish to enable 'textextractor.use-temp-file'.%n", currentItem.getID().toString());
|
||||
oe.printStackTrace();
|
||||
log.error("OutOfMemoryError occurred when extracting text from bitstream in Item {}. " +
|
||||
"You may wish to enable 'textextractor.use-temp-file'.", currentItem.getID().toString(), oe);
|
||||
throw oe;
|
||||
}
|
||||
|
||||
if (StringUtils.isNotEmpty(extractedText)) {
|
||||
// if verbose flag is set, print out extracted text to STDOUT
|
||||
if (verbose) {
|
||||
System.out.println("(Verbose mode) Extracted text:");
|
||||
System.out.println(extractedText);
|
||||
}
|
||||
|
||||
// return the extracted text as a UTF-8 stream.
|
||||
return new ByteArrayInputStream(extractedText.getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts the text out of a given source InputStream, using a temporary file. This decreases the amount of memory
|
||||
* necessary for text extraction, but can be slower as it requires writing extracted text to a temporary file.
|
||||
* @param source source InputStream
|
||||
* @param verbose verbose mode enabled/disabled
|
||||
* @return InputStream for temporary file containing extracted text
|
||||
* @throws IOException
|
||||
* @throws SAXException
|
||||
* @throws TikaException
|
||||
*/
|
||||
private InputStream extractUsingTempFile(InputStream source, boolean verbose)
|
||||
throws IOException, TikaException, SAXException {
|
||||
File tempExtractedTextFile = File.createTempFile("dspacetextextract" + source.hashCode(), ".txt");
|
||||
|
||||
if (verbose) {
|
||||
System.out.println("(Verbose mode) Extracted text was written to temporary file at " +
|
||||
tempExtractedTextFile.getAbsolutePath());
|
||||
} else {
|
||||
tempExtractedTextFile.deleteOnExit();
|
||||
}
|
||||
|
||||
// Open temp file for writing
|
||||
try (FileWriter writer = new FileWriter(tempExtractedTextFile, StandardCharsets.UTF_8)) {
|
||||
// Initialize a custom ContentHandlerDecorator which is a BodyContentHandler.
|
||||
// This mimics the behavior of Tika().parseToString(), which only extracts text from the body of the file.
|
||||
// This custom Handler writes any extracted text to the temp file.
|
||||
ContentHandlerDecorator handler = new BodyContentHandler(new ContentHandlerDecorator() {
|
||||
/**
|
||||
* Write all extracted characters directly to the temp file.
|
||||
*/
|
||||
@Override
|
||||
public void characters(char[] ch, int start, int length) throws SAXException {
|
||||
try {
|
||||
writer.append(new String(ch), start, length);
|
||||
} catch (IOException e) {
|
||||
String errorMsg = String.format("Could not append to temporary file at %s " +
|
||||
"when performing text extraction",
|
||||
tempExtractedTextFile.getAbsolutePath());
|
||||
log.error(errorMsg, e);
|
||||
throw new SAXException(errorMsg, e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write all ignorable whitespace directly to the temp file.
|
||||
* This mimics the behaviour of Tika().parseToString() which extracts ignorableWhitespace characters
|
||||
* (like blank lines, indentations, etc.), so that we get the same extracted text either way.
|
||||
*/
|
||||
@Override
|
||||
public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException {
|
||||
try {
|
||||
writer.append(new String(ch), start, length);
|
||||
} catch (IOException e) {
|
||||
String errorMsg = String.format("Could not append to temporary file at %s " +
|
||||
"when performing text extraction",
|
||||
tempExtractedTextFile.getAbsolutePath());
|
||||
log.error(errorMsg, e);
|
||||
throw new SAXException(errorMsg, e);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
AutoDetectParser parser = new AutoDetectParser();
|
||||
Metadata metadata = new Metadata();
|
||||
// parse our source InputStream using the above custom handler
|
||||
parser.parse(source, handler, metadata);
|
||||
}
|
||||
|
||||
// At this point, all extracted text is written to our temp file. So, return a FileInputStream for that file
|
||||
return new FileInputStream(tempExtractedTextFile);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@@ -1,58 +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/
|
||||
*/
|
||||
|
||||
package org.dspace.app.util;
|
||||
|
||||
import net.sf.ehcache.Cache;
|
||||
import net.sf.ehcache.CacheManager;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.servicemanager.DSpaceKernelImpl;
|
||||
import org.dspace.servicemanager.DSpaceKernelInit;
|
||||
import org.dspace.services.CachingService;
|
||||
|
||||
/**
|
||||
* List all EhCache CacheManager and Cache instances.
|
||||
*
|
||||
* <p>This is a debugging tool, not used in the daily operation of DSpace.
|
||||
* Just run it from the installed instance using
|
||||
* {@code bin/dspace dsrun org.dspace.app.util.CacheSnooper}
|
||||
* to check that the cache configuration is what you expect it to be,
|
||||
* given your configuration.
|
||||
*
|
||||
* <p>This was created to prove a specific cache configuration patch,
|
||||
* but I leave it here in the hope that it may be useful to others.
|
||||
*
|
||||
* @author Mark H. Wood <mwood@iupui.edu>
|
||||
*/
|
||||
public class CacheSnooper {
|
||||
private CacheSnooper() { }
|
||||
|
||||
public static void main(String[] argv) {
|
||||
// Ensure that the DSpace kernel is started.
|
||||
DSpaceKernelImpl kernel = DSpaceKernelInit.getKernel(null);
|
||||
|
||||
// Ensure that the services cache manager is started.
|
||||
CachingService serviceCaches = kernel.getServiceManager()
|
||||
.getServiceByName(null, CachingService.class);
|
||||
|
||||
// Ensure that the database layer is started.
|
||||
Context ctx = new Context();
|
||||
|
||||
// List those caches!
|
||||
for (CacheManager manager : CacheManager.ALL_CACHE_MANAGERS) {
|
||||
System.out.format("CacheManager: %s%n", manager);
|
||||
for (String cacheName : manager.getCacheNames()) {
|
||||
Cache cache = manager.getCache(cacheName);
|
||||
System.out.format(" Cache: '%s'; maxHeap: %d; maxDisk: %d%n",
|
||||
cacheName,
|
||||
cache.getCacheConfiguration().getMaxEntriesLocalHeap(),
|
||||
cache.getCacheConfiguration().getMaxEntriesLocalDisk());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -37,6 +37,7 @@ public class Configuration {
|
||||
* <li>{@code --property name} prints the value of the DSpace configuration
|
||||
* property {@code name} to the standard output.</li>
|
||||
* <li>{@code --raw} suppresses parameter substitution in the output.</li>
|
||||
* <li>{@code --first} print only the first of multiple values.</li>
|
||||
* <li>{@code --help} describes these options.</li>
|
||||
* </ul>
|
||||
* If the property does not exist, nothing is written.
|
||||
@@ -51,6 +52,8 @@ public class Configuration {
|
||||
"optional name of the module in which 'property' exists");
|
||||
options.addOption("r", "raw", false,
|
||||
"do not do property substitution on the value");
|
||||
options.addOption("f", "first", false,
|
||||
"display only the first value of an array property");
|
||||
options.addOption("?", "Get help");
|
||||
options.addOption("h", "help", false, "Get help");
|
||||
|
||||
@@ -90,19 +93,36 @@ public class Configuration {
|
||||
propNameBuilder.append(cmd.getOptionValue('p'));
|
||||
String propName = propNameBuilder.toString();
|
||||
|
||||
// Print the property's value, if it exists
|
||||
// Print the property's value(s), if it exists
|
||||
ConfigurationService cfg = DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||
if (!cfg.hasProperty(propName)) {
|
||||
System.out.println();
|
||||
} else {
|
||||
String val;
|
||||
if (cmd.hasOption('r')) {
|
||||
val = cfg.getPropertyValue(propName).toString();
|
||||
// Print "raw" values (without property substitutions)
|
||||
Object rawValue = cfg.getPropertyValue(propName);
|
||||
if (rawValue.getClass().isArray()) {
|
||||
for (Object value : (Object[]) rawValue) {
|
||||
System.out.println(value.toString());
|
||||
if (cmd.hasOption('f')) {
|
||||
break; // If --first print only one value
|
||||
}
|
||||
}
|
||||
} else { // Not an array
|
||||
System.out.println(rawValue.toString());
|
||||
}
|
||||
} else {
|
||||
val = cfg.getProperty(propName);
|
||||
// Print values with property substitutions
|
||||
String[] values = cfg.getArrayProperty(propName);
|
||||
for (String value : values) {
|
||||
System.out.println(value);
|
||||
if (cmd.hasOption('f')) {
|
||||
break; // If --first print only one value
|
||||
}
|
||||
}
|
||||
}
|
||||
System.out.println(val);
|
||||
}
|
||||
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
|
@@ -86,8 +86,10 @@ public class GoogleBitstreamComparator implements Comparator<Bitstream> {
|
||||
if (priority1 > priority2) {
|
||||
return 1;
|
||||
} else if (priority1 == priority2) {
|
||||
if (b1.getSizeBytes() <= b2.getSizeBytes()) {
|
||||
if (b1.getSizeBytes() < b2.getSizeBytes()) {
|
||||
return 1;
|
||||
} else if (b1.getSizeBytes() == b2.getSizeBytes()) {
|
||||
return 0;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
|
@@ -42,7 +42,7 @@ import org.dspace.core.Context;
|
||||
import org.dspace.handle.factory.HandleServiceFactory;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
import org.jdom.Element;
|
||||
import org.jdom2.Element;
|
||||
|
||||
/**
|
||||
* Configuration and mapping for Google Scholar output metadata
|
||||
|
@@ -16,10 +16,10 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.sun.syndication.feed.module.opensearch.OpenSearchModule;
|
||||
import com.sun.syndication.feed.module.opensearch.entity.OSQuery;
|
||||
import com.sun.syndication.feed.module.opensearch.impl.OpenSearchModuleImpl;
|
||||
import com.sun.syndication.io.FeedException;
|
||||
import com.rometools.modules.opensearch.OpenSearchModule;
|
||||
import com.rometools.modules.opensearch.entity.OSQuery;
|
||||
import com.rometools.modules.opensearch.impl.OpenSearchModuleImpl;
|
||||
import com.rometools.rome.io.FeedException;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.app.util.service.OpenSearchService;
|
||||
import org.dspace.content.DSpaceObject;
|
||||
@@ -29,11 +29,11 @@ import org.dspace.discovery.IndexableObject;
|
||||
import org.dspace.handle.service.HandleService;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
import org.jdom.Element;
|
||||
import org.jdom.JDOMException;
|
||||
import org.jdom.Namespace;
|
||||
import org.jdom.output.DOMOutputter;
|
||||
import org.jdom.output.XMLOutputter;
|
||||
import org.jdom2.Element;
|
||||
import org.jdom2.JDOMException;
|
||||
import org.jdom2.Namespace;
|
||||
import org.jdom2.output.DOMOutputter;
|
||||
import org.jdom2.output.XMLOutputter;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
@@ -192,7 +192,7 @@ public class OpenSearchServiceImpl implements OpenSearchService {
|
||||
* @param scope - null for the entire repository, or a collection/community handle
|
||||
* @return Service Document
|
||||
*/
|
||||
protected org.jdom.Document getServiceDocument(String scope) {
|
||||
protected org.jdom2.Document getServiceDocument(String scope) {
|
||||
ConfigurationService config = DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||
|
||||
Namespace ns = Namespace.getNamespace(osNs);
|
||||
@@ -245,7 +245,7 @@ public class OpenSearchServiceImpl implements OpenSearchService {
|
||||
url.setAttribute("template", template.toString());
|
||||
root.addContent(url);
|
||||
}
|
||||
return new org.jdom.Document(root);
|
||||
return new org.jdom2.Document(root);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -255,7 +255,7 @@ public class OpenSearchServiceImpl implements OpenSearchService {
|
||||
* @return W3C Document object
|
||||
* @throws IOException if IO error
|
||||
*/
|
||||
protected Document jDomToW3(org.jdom.Document jdomDoc) throws IOException {
|
||||
protected Document jDomToW3(org.jdom2.Document jdomDoc) throws IOException {
|
||||
DOMOutputter domOut = new DOMOutputter();
|
||||
try {
|
||||
return domOut.output(jdomDoc);
|
||||
|
@@ -15,26 +15,26 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import com.sun.syndication.feed.module.DCModule;
|
||||
import com.sun.syndication.feed.module.DCModuleImpl;
|
||||
import com.sun.syndication.feed.module.Module;
|
||||
import com.sun.syndication.feed.module.itunes.EntryInformation;
|
||||
import com.sun.syndication.feed.module.itunes.EntryInformationImpl;
|
||||
import com.sun.syndication.feed.module.itunes.types.Duration;
|
||||
import com.sun.syndication.feed.synd.SyndContent;
|
||||
import com.sun.syndication.feed.synd.SyndContentImpl;
|
||||
import com.sun.syndication.feed.synd.SyndEnclosure;
|
||||
import com.sun.syndication.feed.synd.SyndEnclosureImpl;
|
||||
import com.sun.syndication.feed.synd.SyndEntry;
|
||||
import com.sun.syndication.feed.synd.SyndEntryImpl;
|
||||
import com.sun.syndication.feed.synd.SyndFeed;
|
||||
import com.sun.syndication.feed.synd.SyndFeedImpl;
|
||||
import com.sun.syndication.feed.synd.SyndImage;
|
||||
import com.sun.syndication.feed.synd.SyndImageImpl;
|
||||
import com.sun.syndication.feed.synd.SyndPerson;
|
||||
import com.sun.syndication.feed.synd.SyndPersonImpl;
|
||||
import com.sun.syndication.io.FeedException;
|
||||
import com.sun.syndication.io.SyndFeedOutput;
|
||||
import com.rometools.modules.itunes.EntryInformation;
|
||||
import com.rometools.modules.itunes.EntryInformationImpl;
|
||||
import com.rometools.modules.itunes.types.Duration;
|
||||
import com.rometools.rome.feed.module.DCModule;
|
||||
import com.rometools.rome.feed.module.DCModuleImpl;
|
||||
import com.rometools.rome.feed.module.Module;
|
||||
import com.rometools.rome.feed.synd.SyndContent;
|
||||
import com.rometools.rome.feed.synd.SyndContentImpl;
|
||||
import com.rometools.rome.feed.synd.SyndEnclosure;
|
||||
import com.rometools.rome.feed.synd.SyndEnclosureImpl;
|
||||
import com.rometools.rome.feed.synd.SyndEntry;
|
||||
import com.rometools.rome.feed.synd.SyndEntryImpl;
|
||||
import com.rometools.rome.feed.synd.SyndFeed;
|
||||
import com.rometools.rome.feed.synd.SyndFeedImpl;
|
||||
import com.rometools.rome.feed.synd.SyndImage;
|
||||
import com.rometools.rome.feed.synd.SyndImageImpl;
|
||||
import com.rometools.rome.feed.synd.SyndPerson;
|
||||
import com.rometools.rome.feed.synd.SyndPersonImpl;
|
||||
import com.rometools.rome.io.FeedException;
|
||||
import com.rometools.rome.io.SyndFeedOutput;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
@@ -20,7 +20,6 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
@@ -290,20 +289,13 @@ public class ShibAuthentication implements AuthenticationMethod {
|
||||
try {
|
||||
// User has not successfuly authenticated via shibboleth.
|
||||
if (request == null ||
|
||||
context.getCurrentUser() == null ||
|
||||
request.getSession().getAttribute("shib.authenticated") == null) {
|
||||
context.getCurrentUser() == null) {
|
||||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
|
||||
// If we have already calculated the special groups then return them.
|
||||
if (request.getSession().getAttribute("shib.specialgroup") != null) {
|
||||
if (context.getSpecialGroups().size() > 0 ) {
|
||||
log.debug("Returning cached special groups.");
|
||||
List<UUID> sessionGroupIds = (List<UUID>) request.getSession().getAttribute("shib.specialgroup");
|
||||
List<Group> result = new ArrayList<>();
|
||||
for (UUID uuid : sessionGroupIds) {
|
||||
result.add(groupService.find(context, uuid));
|
||||
}
|
||||
return result;
|
||||
return context.getSpecialGroups();
|
||||
}
|
||||
|
||||
log.debug("Starting to determine special groups");
|
||||
@@ -396,16 +388,8 @@ public class ShibAuthentication implements AuthenticationMethod {
|
||||
|
||||
log.info("Added current EPerson to special groups: " + groups);
|
||||
|
||||
List<UUID> groupIds = new ArrayList<>();
|
||||
for (Group group : groups) {
|
||||
groupIds.add(group.getID());
|
||||
}
|
||||
|
||||
// Cache the special groups, so we don't have to recalculate them again
|
||||
// for this session.
|
||||
request.setAttribute("shib.specialgroup", groupIds);
|
||||
|
||||
return new ArrayList<>(groups);
|
||||
|
||||
} catch (Throwable t) {
|
||||
log.error("Unable to validate any sepcial groups this user may belong too because of an exception.", t);
|
||||
return Collections.EMPTY_LIST;
|
||||
|
@@ -21,7 +21,8 @@ import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.impl.client.HttpClientBuilder;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.authority.AuthorityValue;
|
||||
import org.dspace.authority.SolrAuthorityInterface;
|
||||
import org.dspace.external.OrcidRestConnector;
|
||||
@@ -40,7 +41,7 @@ import org.orcid.jaxb.model.v3.release.search.Result;
|
||||
*/
|
||||
public class Orcidv3SolrAuthorityImpl implements SolrAuthorityInterface {
|
||||
|
||||
private static Logger log = Logger.getLogger(Orcidv3SolrAuthorityImpl.class);
|
||||
private final static Logger log = LogManager.getLogger();
|
||||
|
||||
private OrcidRestConnector orcidRestConnector;
|
||||
private String OAUTHUrl;
|
||||
|
@@ -14,11 +14,12 @@ import java.util.Iterator;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.transform.TransformerException;
|
||||
import javax.xml.xpath.XPath;
|
||||
import javax.xml.xpath.XPathConstants;
|
||||
import javax.xml.xpath.XPathExpressionException;
|
||||
import javax.xml.xpath.XPathFactory;
|
||||
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.xpath.XPathAPI;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
@@ -62,36 +63,26 @@ public class XMLUtils {
|
||||
|
||||
/**
|
||||
* @param xml The starting context (a Node or a Document, for example).
|
||||
* @param NodeListXPath xpath
|
||||
* @param nodeListXPath xpath
|
||||
* @return A Node matches the NodeListXPath
|
||||
* null if nothing matches the NodeListXPath
|
||||
* @throws XPathExpressionException if xpath error
|
||||
*/
|
||||
public static Node getNode(Node xml, String NodeListXPath) throws XPathExpressionException {
|
||||
Node result = null;
|
||||
try {
|
||||
result = XPathAPI.selectSingleNode(xml, NodeListXPath);
|
||||
} catch (TransformerException e) {
|
||||
log.error("Error", e);
|
||||
}
|
||||
return result;
|
||||
public static Node getNode(Node xml, String nodeListXPath) throws XPathExpressionException {
|
||||
XPath xPath = XPathFactory.newInstance().newXPath();
|
||||
return (Node) xPath.compile(nodeListXPath).evaluate(xml, XPathConstants.NODE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param xml The starting context (a Node or a Document, for example).
|
||||
* @param NodeListXPath xpath
|
||||
* @param nodeListXPath xpath
|
||||
* @return A NodeList containing the nodes that match the NodeListXPath
|
||||
* null if nothing matches the NodeListXPath
|
||||
* @throws XPathExpressionException if xpath error
|
||||
*/
|
||||
public static NodeList getNodeList(Node xml, String NodeListXPath) throws XPathExpressionException {
|
||||
NodeList nodeList = null;
|
||||
try {
|
||||
nodeList = XPathAPI.selectNodeList(xml, NodeListXPath);
|
||||
} catch (TransformerException e) {
|
||||
log.error("Error", e);
|
||||
}
|
||||
return nodeList;
|
||||
public static NodeList getNodeList(Node xml, String nodeListXPath) throws XPathExpressionException {
|
||||
XPath xPath = XPathFactory.newInstance().newXPath();
|
||||
return (NodeList) xPath.compile(nodeListXPath).evaluate(xml, XPathConstants.NODESET);
|
||||
}
|
||||
|
||||
public static Iterator<Node> getNodeListIterator(Node xml, String NodeListXPath) throws XPathExpressionException {
|
||||
|
@@ -93,7 +93,7 @@ public class ResourcePolicy implements ReloadableEntity<Integer> {
|
||||
private String rptype;
|
||||
|
||||
@Lob
|
||||
@Type(type = "org.hibernate.type.MaterializedClobType")
|
||||
@Type(type = "org.dspace.storage.rdbms.hibernate.DatabaseAwareLobType")
|
||||
@Column(name = "rpdescription")
|
||||
private String rpdescription;
|
||||
|
||||
|
@@ -11,6 +11,7 @@ import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.content.Collection;
|
||||
import org.dspace.content.Community;
|
||||
@@ -202,6 +203,8 @@ public class BrowseEngine {
|
||||
// get the table name that we are going to be getting our data from
|
||||
dao.setTable(browseIndex.getTableName());
|
||||
|
||||
dao.setStartsWith(StringUtils.lowerCase(scope.getStartsWith()));
|
||||
|
||||
// tell the browse query whether we are ascending or descending on the value
|
||||
dao.setAscending(scope.isAscending());
|
||||
|
||||
@@ -248,9 +251,6 @@ public class BrowseEngine {
|
||||
}
|
||||
}
|
||||
|
||||
// this is the total number of results in answer to the query
|
||||
int total = getTotalResults();
|
||||
|
||||
// assemble the ORDER BY clause
|
||||
String orderBy = browseIndex.getSortField(scope.isSecondLevel());
|
||||
if (scope.getSortBy() > 0) {
|
||||
@@ -258,6 +258,9 @@ public class BrowseEngine {
|
||||
}
|
||||
dao.setOrderField(orderBy);
|
||||
|
||||
// this is the total number of results in answer to the query
|
||||
int total = getTotalResults();
|
||||
|
||||
int offset = scope.getOffset();
|
||||
String rawFocusValue = null;
|
||||
if (offset < 1 && (scope.hasJumpToItem() || scope.hasJumpToValue() || scope.hasStartsWith())) {
|
||||
@@ -269,9 +272,6 @@ public class BrowseEngine {
|
||||
String focusValue = normalizeJumpToValue(rawFocusValue);
|
||||
|
||||
log.debug("browsing using focus: " + focusValue);
|
||||
|
||||
// Convert the focus value into an offset
|
||||
offset = getOffsetForValue(focusValue);
|
||||
}
|
||||
|
||||
dao.setOffset(offset);
|
||||
@@ -684,13 +684,11 @@ public class BrowseEngine {
|
||||
// our count, storing them locally to reinstate later
|
||||
String focusField = dao.getJumpToField();
|
||||
String focusValue = dao.getJumpToValue();
|
||||
String orderField = dao.getOrderField();
|
||||
int limit = dao.getLimit();
|
||||
int offset = dao.getOffset();
|
||||
|
||||
dao.setJumpToField(null);
|
||||
dao.setJumpToValue(null);
|
||||
dao.setOrderField(null);
|
||||
dao.setLimit(-1);
|
||||
dao.setOffset(-1);
|
||||
|
||||
@@ -700,7 +698,6 @@ public class BrowseEngine {
|
||||
// now put back the values we removed for this method
|
||||
dao.setJumpToField(focusField);
|
||||
dao.setJumpToValue(focusValue);
|
||||
dao.setOrderField(orderField);
|
||||
dao.setLimit(limit);
|
||||
dao.setOffset(offset);
|
||||
dao.setCountValues(null);
|
||||
|
@@ -205,6 +205,9 @@ public class SolrBrowseDAO implements BrowseDAO {
|
||||
} else if (valuePartial) {
|
||||
query.addFilterQueries("{!field f=" + facetField + "_partial}" + value);
|
||||
}
|
||||
if (StringUtils.isNotBlank(startsWith) && orderField != null) {
|
||||
query.addFilterQueries("bi_" + orderField + "_sort:" + startsWith + "*");
|
||||
}
|
||||
// filter on item to be sure to don't include any other object
|
||||
// indexed in the Discovery Search core
|
||||
query.addFilterQueries("search.resourcetype:" + IndexableItem.TYPE);
|
||||
|
@@ -243,67 +243,64 @@ public abstract class DSpaceObjectServiceImpl<T extends DSpaceObject> implements
|
||||
|
||||
boolean authorityControlled = metadataAuthorityService.isAuthorityControlled(metadataField);
|
||||
boolean authorityRequired = metadataAuthorityService.isAuthorityRequired(metadataField);
|
||||
List<MetadataValue> newMetadata = new ArrayList<>(values.size());
|
||||
List<MetadataValue> newMetadata = new ArrayList<>();
|
||||
// We will not verify that they are valid entries in the registry
|
||||
// until update() is called.
|
||||
for (int i = 0; i < values.size(); i++) {
|
||||
|
||||
if (authorities != null && authorities.size() >= i) {
|
||||
if (StringUtils.startsWith(authorities.get(i), Constants.VIRTUAL_AUTHORITY_PREFIX)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
MetadataValue metadataValue = metadataValueService.create(context, dso, metadataField);
|
||||
newMetadata.add(metadataValue);
|
||||
|
||||
metadataValue.setPlace(placeSupplier.get());
|
||||
|
||||
metadataValue.setLanguage(lang == null ? null : lang.trim());
|
||||
|
||||
// Logic to set Authority and Confidence:
|
||||
// - normalize an empty string for authority to NULL.
|
||||
// - if authority key is present, use given confidence or NOVALUE if not given
|
||||
// - otherwise, preserve confidence if meaningful value was given since it may document a failed
|
||||
// authority lookup
|
||||
// - CF_UNSET signifies no authority nor meaningful confidence.
|
||||
// - it's possible to have empty authority & CF_ACCEPTED if e.g. user deletes authority key
|
||||
if (authorityControlled) {
|
||||
if (authorities != null && authorities.get(i) != null && authorities.get(i).length() > 0) {
|
||||
metadataValue.setAuthority(authorities.get(i));
|
||||
metadataValue.setConfidence(confidences == null ? Choices.CF_NOVALUE : confidences.get(i));
|
||||
} else {
|
||||
metadataValue.setAuthority(null);
|
||||
metadataValue.setConfidence(confidences == null ? Choices.CF_UNSET : confidences.get(i));
|
||||
}
|
||||
// authority sanity check: if authority is required, was it supplied?
|
||||
// XXX FIXME? can't throw a "real" exception here without changing all the callers to expect it, so
|
||||
// use a runtime exception
|
||||
if (authorityRequired && (metadataValue.getAuthority() == null || metadataValue.getAuthority()
|
||||
.length() == 0)) {
|
||||
throw new IllegalArgumentException("The metadata field \"" + metadataField
|
||||
.toString() + "\" requires an authority key but none was provided. Value=\"" + values
|
||||
.get(i) + "\"");
|
||||
}
|
||||
}
|
||||
if (values.get(i) != null) {
|
||||
if (authorities != null && authorities.size() >= i) {
|
||||
if (StringUtils.startsWith(authorities.get(i), Constants.VIRTUAL_AUTHORITY_PREFIX)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
MetadataValue metadataValue = metadataValueService.create(context, dso, metadataField);
|
||||
newMetadata.add(metadataValue);
|
||||
|
||||
metadataValue.setPlace(placeSupplier.get());
|
||||
|
||||
metadataValue.setLanguage(lang == null ? null : lang.trim());
|
||||
|
||||
// Logic to set Authority and Confidence:
|
||||
// - normalize an empty string for authority to NULL.
|
||||
// - if authority key is present, use given confidence or NOVALUE if not given
|
||||
// - otherwise, preserve confidence if meaningful value was given since it may document a failed
|
||||
// authority lookup
|
||||
// - CF_UNSET signifies no authority nor meaningful confidence.
|
||||
// - it's possible to have empty authority & CF_ACCEPTED if e.g. user deletes authority key
|
||||
if (authorityControlled) {
|
||||
if (authorities != null && authorities.get(i) != null && authorities.get(i).length() > 0) {
|
||||
metadataValue.setAuthority(authorities.get(i));
|
||||
metadataValue.setConfidence(confidences == null ? Choices.CF_NOVALUE : confidences.get(i));
|
||||
} else {
|
||||
metadataValue.setAuthority(null);
|
||||
metadataValue.setConfidence(confidences == null ? Choices.CF_UNSET : confidences.get(i));
|
||||
}
|
||||
// authority sanity check: if authority is required, was it supplied?
|
||||
// XXX FIXME? can't throw a "real" exception here without changing all the callers to expect it, so
|
||||
// use a runtime exception
|
||||
if (authorityRequired && (metadataValue.getAuthority() == null || metadataValue.getAuthority()
|
||||
.length() == 0)) {
|
||||
throw new IllegalArgumentException("The metadata field \"" + metadataField
|
||||
.toString() + "\" requires an authority key but none was provided. Value=\"" + values
|
||||
.get(i) + "\"");
|
||||
}
|
||||
}
|
||||
// remove control unicode char
|
||||
String temp = values.get(i).trim();
|
||||
char[] dcvalue = temp.toCharArray();
|
||||
for (int charPos = 0; charPos < dcvalue.length; charPos++) {
|
||||
if (Character.isISOControl(dcvalue[charPos]) &&
|
||||
!String.valueOf(dcvalue[charPos]).equals("\u0009") &&
|
||||
!String.valueOf(dcvalue[charPos]).equals("\n") &&
|
||||
!String.valueOf(dcvalue[charPos]).equals("\r")) {
|
||||
!String.valueOf(dcvalue[charPos]).equals("\u0009") &&
|
||||
!String.valueOf(dcvalue[charPos]).equals("\n") &&
|
||||
!String.valueOf(dcvalue[charPos]).equals("\r")) {
|
||||
dcvalue[charPos] = ' ';
|
||||
}
|
||||
}
|
||||
metadataValue.setValue(String.valueOf(dcvalue));
|
||||
} else {
|
||||
metadataValue.setValue(null);
|
||||
}
|
||||
//An update here isn't needed, this is persited upon the merge of the owning object
|
||||
//An update here isn't needed, this is persited upon the merge of the owning object
|
||||
// metadataValueService.update(context, metadataValue);
|
||||
dso.addDetails(metadataField.toString());
|
||||
dso.addDetails(metadataField.toString());
|
||||
}
|
||||
}
|
||||
setMetadataModified(dso);
|
||||
return newMetadata;
|
||||
|
@@ -911,6 +911,12 @@ public class ItemServiceImpl extends DSpaceObjectServiceImpl<Item> implements It
|
||||
@Override
|
||||
public void move(Context context, Item item, Collection from, Collection to)
|
||||
throws SQLException, AuthorizeException, IOException {
|
||||
|
||||
// If the two collections are the same, do nothing.
|
||||
if (from.equals(to)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Use the normal move method, and default to not inherit permissions
|
||||
this.move(context, item, from, to, false);
|
||||
}
|
||||
|
@@ -59,7 +59,7 @@ public class MetadataValue implements ReloadableEntity<Integer> {
|
||||
* The value of the field
|
||||
*/
|
||||
@Lob
|
||||
@Type(type = "org.hibernate.type.MaterializedClobType")
|
||||
@Type(type = "org.dspace.storage.rdbms.hibernate.DatabaseAwareLobType")
|
||||
@Column(name = "text_value")
|
||||
private String value;
|
||||
|
||||
|
@@ -14,8 +14,8 @@ import java.util.List;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.DSpaceObject;
|
||||
import org.dspace.core.Context;
|
||||
import org.jdom.Element;
|
||||
import org.jdom.Namespace;
|
||||
import org.jdom2.Element;
|
||||
import org.jdom2.Namespace;
|
||||
|
||||
/**
|
||||
* Crosswalk descriptive metadata to and from DIM (DSpace Intermediate
|
||||
|
@@ -40,8 +40,8 @@ import org.dspace.handle.factory.HandleServiceFactory;
|
||||
import org.dspace.handle.service.HandleService;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
import org.jdom.Element;
|
||||
import org.jdom.Namespace;
|
||||
import org.jdom2.Element;
|
||||
import org.jdom2.Namespace;
|
||||
|
||||
/**
|
||||
* Crosswalk of technical metadata for DSpace AIP. This is
|
||||
|
@@ -23,8 +23,8 @@ import org.dspace.content.factory.ContentServiceFactory;
|
||||
import org.dspace.content.service.ItemService;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.jdom.Element;
|
||||
import org.jdom.Namespace;
|
||||
import org.jdom2.Element;
|
||||
import org.jdom2.Namespace;
|
||||
|
||||
/**
|
||||
* DIM dissemination crosswalk
|
||||
|
@@ -19,8 +19,8 @@ import org.dspace.content.factory.ContentServiceFactory;
|
||||
import org.dspace.content.service.ItemService;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.jdom.Element;
|
||||
import org.jdom.Namespace;
|
||||
import org.jdom2.Element;
|
||||
import org.jdom2.Namespace;
|
||||
|
||||
/**
|
||||
* DIM ingestion crosswalk
|
||||
|
@@ -14,8 +14,8 @@ import java.util.List;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.DSpaceObject;
|
||||
import org.dspace.core.Context;
|
||||
import org.jdom.Element;
|
||||
import org.jdom.Namespace;
|
||||
import org.jdom2.Element;
|
||||
import org.jdom2.Namespace;
|
||||
|
||||
/**
|
||||
* Dissemination Crosswalk plugin -- translate DSpace native
|
||||
|
@@ -14,7 +14,7 @@ import java.util.List;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.DSpaceObject;
|
||||
import org.dspace.core.Context;
|
||||
import org.jdom.Element;
|
||||
import org.jdom2.Element;
|
||||
|
||||
/**
|
||||
* Ingestion Crosswalk plugin -- translate an external metadata format
|
||||
|
@@ -24,11 +24,11 @@ import org.dspace.core.Context;
|
||||
import org.dspace.core.factory.CoreServiceFactory;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
import org.jdom.Document;
|
||||
import org.jdom.Element;
|
||||
import org.jdom.JDOMException;
|
||||
import org.jdom.Namespace;
|
||||
import org.jdom.input.SAXBuilder;
|
||||
import org.jdom2.Document;
|
||||
import org.jdom2.Element;
|
||||
import org.jdom2.JDOMException;
|
||||
import org.jdom2.Namespace;
|
||||
import org.jdom2.input.SAXBuilder;
|
||||
|
||||
/**
|
||||
* METS dissemination crosswalk
|
||||
|
@@ -35,8 +35,8 @@ import org.dspace.eperson.Group;
|
||||
import org.dspace.eperson.factory.EPersonServiceFactory;
|
||||
import org.dspace.eperson.service.EPersonService;
|
||||
import org.dspace.eperson.service.GroupService;
|
||||
import org.jdom.Element;
|
||||
import org.jdom.Namespace;
|
||||
import org.jdom2.Element;
|
||||
import org.jdom2.Namespace;
|
||||
|
||||
/**
|
||||
* METSRights Ingestion and Dissemination Crosswalk
|
||||
|
@@ -15,7 +15,6 @@ import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
@@ -42,16 +41,18 @@ import org.dspace.handle.factory.HandleServiceFactory;
|
||||
import org.dspace.handle.service.HandleService;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
import org.jdom.Attribute;
|
||||
import org.jdom.Document;
|
||||
import org.jdom.Element;
|
||||
import org.jdom.JDOMException;
|
||||
import org.jdom.Namespace;
|
||||
import org.jdom.Text;
|
||||
import org.jdom.Verifier;
|
||||
import org.jdom.input.SAXBuilder;
|
||||
import org.jdom.output.XMLOutputter;
|
||||
import org.jdom.xpath.XPath;
|
||||
import org.jdom2.Attribute;
|
||||
import org.jdom2.Document;
|
||||
import org.jdom2.Element;
|
||||
import org.jdom2.JDOMException;
|
||||
import org.jdom2.Namespace;
|
||||
import org.jdom2.Text;
|
||||
import org.jdom2.Verifier;
|
||||
import org.jdom2.filter.Filters;
|
||||
import org.jdom2.input.SAXBuilder;
|
||||
import org.jdom2.output.XMLOutputter;
|
||||
import org.jdom2.xpath.XPathExpression;
|
||||
import org.jdom2.xpath.XPathFactory;
|
||||
|
||||
/**
|
||||
* Configurable MODS Crosswalk
|
||||
@@ -156,7 +157,7 @@ public class MODSDisseminationCrosswalk extends SelfNamedPlugin
|
||||
static class modsTriple {
|
||||
public String qdc = null;
|
||||
public Element xml = null;
|
||||
public XPath xpath = null;
|
||||
public XPathExpression xpath = null;
|
||||
|
||||
/**
|
||||
* Initialize from text versions of QDC, XML and XPath.
|
||||
@@ -171,9 +172,9 @@ public class MODSDisseminationCrosswalk extends SelfNamedPlugin
|
||||
final String postlog = "</mods>";
|
||||
try {
|
||||
result.qdc = qdc;
|
||||
result.xpath = XPath.newInstance(xpath);
|
||||
result.xpath.addNamespace(MODS_NS.getPrefix(), MODS_NS.getURI());
|
||||
result.xpath.addNamespace(XLINK_NS);
|
||||
result.xpath =
|
||||
XPathFactory.instance()
|
||||
.compile(xpath, Filters.fpassthrough(), null, MODS_NS, XLINK_NS);
|
||||
Document d = builder.build(new StringReader(prolog + xml + postlog));
|
||||
result.xml = (Element) d.getRootElement().getContent(0);
|
||||
} catch (JDOMException | IOException je) {
|
||||
@@ -295,6 +296,7 @@ public class MODSDisseminationCrosswalk extends SelfNamedPlugin
|
||||
* @throws IOException if IO error
|
||||
* @throws SQLException if database error
|
||||
* @throws AuthorizeException if authorization error
|
||||
* @return List of Elements
|
||||
*/
|
||||
@Override
|
||||
public List<Element> disseminateList(Context context, DSpaceObject dso)
|
||||
@@ -352,37 +354,29 @@ public class MODSDisseminationCrosswalk extends SelfNamedPlugin
|
||||
if (trip == null) {
|
||||
log.warn("WARNING: " + getPluginInstanceName() + ": No MODS mapping for \"" + qdc + "\"");
|
||||
} else {
|
||||
try {
|
||||
Element me = (Element) trip.xml.clone();
|
||||
if (addSchema) {
|
||||
me.setAttribute("schemaLocation", schemaLocation, XSI_NS);
|
||||
}
|
||||
Iterator ni = trip.xpath.selectNodes(me).iterator();
|
||||
if (!ni.hasNext()) {
|
||||
log.warn("XPath \"" + trip.xpath.getXPath() +
|
||||
"\" found no elements in \"" +
|
||||
outputUgly.outputString(me) +
|
||||
"\", qdc=" + qdc);
|
||||
}
|
||||
while (ni.hasNext()) {
|
||||
Object what = ni.next();
|
||||
if (what instanceof Element) {
|
||||
((Element) what).setText(checkedString(value));
|
||||
} else if (what instanceof Attribute) {
|
||||
((Attribute) what).setValue(checkedString(value));
|
||||
} else if (what instanceof Text) {
|
||||
((Text) what).setText(checkedString(value));
|
||||
} else {
|
||||
log.warn("Got unknown object from XPath, class=" + what.getClass().getName());
|
||||
}
|
||||
}
|
||||
result.add(me);
|
||||
} catch (JDOMException je) {
|
||||
log.error("Error following XPath in modsTriple: context=" +
|
||||
outputUgly.outputString(trip.xml) +
|
||||
", xpath=" + trip.xpath.getXPath() + ", exception=" +
|
||||
je.toString());
|
||||
Element me = (Element) trip.xml.clone();
|
||||
if (addSchema) {
|
||||
me.setAttribute("schemaLocation", schemaLocation, XSI_NS);
|
||||
}
|
||||
List<Object> matches = trip.xpath.evaluate(me);
|
||||
if (matches.isEmpty()) {
|
||||
log.warn("XPath \"" + trip.xpath.getExpression() +
|
||||
"\" found no elements in \"" +
|
||||
outputUgly.outputString(me) +
|
||||
"\", qdc=" + qdc);
|
||||
}
|
||||
for (Object match: matches) {
|
||||
if (match instanceof Element) {
|
||||
((Element) match).setText(checkedString(value));
|
||||
} else if (match instanceof Attribute) {
|
||||
((Attribute) match).setValue(checkedString(value));
|
||||
} else if (match instanceof Text) {
|
||||
((Text) match).setText(checkedString(value));
|
||||
} else {
|
||||
log.warn("Got unknown object from XPath, class=" + match.getClass().getName());
|
||||
}
|
||||
}
|
||||
result.add(me);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
@@ -15,9 +15,9 @@ import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.DSpaceObject;
|
||||
import org.dspace.core.Context;
|
||||
import org.jdom.Element;
|
||||
import org.jdom.output.Format;
|
||||
import org.jdom.output.XMLOutputter;
|
||||
import org.jdom2.Element;
|
||||
import org.jdom2.output.Format;
|
||||
import org.jdom2.output.XMLOutputter;
|
||||
|
||||
/**
|
||||
* "Null" ingestion crosswalk
|
||||
|
@@ -20,8 +20,8 @@ import org.dspace.content.factory.ContentServiceFactory;
|
||||
import org.dspace.content.service.ItemService;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.jdom.Element;
|
||||
import org.jdom.Namespace;
|
||||
import org.jdom2.Element;
|
||||
import org.jdom2.Namespace;
|
||||
|
||||
/**
|
||||
* DIM ingestion crosswalk
|
||||
|
@@ -31,8 +31,8 @@ import org.dspace.core.Context;
|
||||
import org.dspace.core.Utils;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
import org.jdom.Element;
|
||||
import org.jdom.Namespace;
|
||||
import org.jdom2.Element;
|
||||
import org.jdom2.Namespace;
|
||||
|
||||
/**
|
||||
* ORE dissemination crosswalk
|
||||
|
@@ -34,12 +34,13 @@ import org.dspace.content.service.BundleService;
|
||||
import org.dspace.content.service.ItemService;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.jdom.Attribute;
|
||||
import org.jdom.Document;
|
||||
import org.jdom.Element;
|
||||
import org.jdom.JDOMException;
|
||||
import org.jdom.Namespace;
|
||||
import org.jdom.xpath.XPath;
|
||||
import org.jdom2.Attribute;
|
||||
import org.jdom2.Document;
|
||||
import org.jdom2.Element;
|
||||
import org.jdom2.Namespace;
|
||||
import org.jdom2.filter.Filters;
|
||||
import org.jdom2.xpath.XPathExpression;
|
||||
import org.jdom2.xpath.XPathFactory;
|
||||
|
||||
/**
|
||||
* ORE ingestion crosswalk
|
||||
@@ -113,23 +114,21 @@ public class OREIngestionCrosswalk
|
||||
Document doc = new Document();
|
||||
doc.addContent(root.detach());
|
||||
|
||||
XPath xpathLinks;
|
||||
List<Element> aggregatedResources;
|
||||
String entryId;
|
||||
try {
|
||||
xpathLinks = XPath.newInstance("/atom:entry/atom:link[@rel=\"" + ORE_NS.getURI() + "aggregates" + "\"]");
|
||||
xpathLinks.addNamespace(ATOM_NS);
|
||||
aggregatedResources = xpathLinks.selectNodes(doc);
|
||||
XPathExpression<Element> xpathLinks =
|
||||
XPathFactory.instance()
|
||||
.compile("/atom:entry/atom:link[@rel=\"" + ORE_NS.getURI() + "aggregates" + "\"]",
|
||||
Filters.element(), null, ATOM_NS);
|
||||
aggregatedResources = xpathLinks.evaluate(doc);
|
||||
|
||||
xpathLinks = XPath.newInstance("/atom:entry/atom:link[@rel='alternate']/@href");
|
||||
xpathLinks.addNamespace(ATOM_NS);
|
||||
entryId = ((Attribute) xpathLinks.selectSingleNode(doc)).getValue();
|
||||
} catch (JDOMException e) {
|
||||
throw new CrosswalkException("JDOM exception occurred while ingesting the ORE", e);
|
||||
}
|
||||
XPathExpression<Attribute> xpathAltHref =
|
||||
XPathFactory.instance()
|
||||
.compile("/atom:entry/atom:link[@rel='alternate']/@href",
|
||||
Filters.attribute(), null, ATOM_NS);
|
||||
entryId = xpathAltHref.evaluateFirst(doc).getValue();
|
||||
|
||||
// Next for each resource, create a bitstream
|
||||
XPath xpathDesc;
|
||||
NumberFormat nf = NumberFormat.getInstance();
|
||||
nf.setGroupingUsed(false);
|
||||
nf.setMinimumIntegerDigits(4);
|
||||
@@ -140,16 +139,12 @@ public class OREIngestionCrosswalk
|
||||
|
||||
String bundleName;
|
||||
Element desc = null;
|
||||
try {
|
||||
xpathDesc = XPath.newInstance(
|
||||
"/atom:entry/oreatom:triples/rdf:Description[@rdf:about=\"" + this.encodeForURL(href) + "\"][1]");
|
||||
xpathDesc.addNamespace(ATOM_NS);
|
||||
xpathDesc.addNamespace(ORE_ATOM);
|
||||
xpathDesc.addNamespace(RDF_NS);
|
||||
desc = (Element) xpathDesc.selectSingleNode(doc);
|
||||
} catch (JDOMException e) {
|
||||
log.warn("Could not find description for {}", href, e);
|
||||
}
|
||||
XPathExpression<Element> xpathDesc =
|
||||
XPathFactory.instance()
|
||||
.compile("/atom:entry/oreatom:triples/rdf:Description[@rdf:about=\"" +
|
||||
this.encodeForURL(href) + "\"][1]",
|
||||
Filters.element(), null, ATOM_NS, ORE_ATOM, RDF_NS);
|
||||
desc = xpathDesc.evaluateFirst(doc);
|
||||
|
||||
if (desc != null && desc.getChild("type", RDF_NS).getAttributeValue("resource", RDF_NS)
|
||||
.equals(DS_NS.getURI() + "DSpaceBitstream")) {
|
||||
|
@@ -30,8 +30,8 @@ import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
import org.jdom.Element;
|
||||
import org.jdom.Namespace;
|
||||
import org.jdom2.Element;
|
||||
import org.jdom2.Namespace;
|
||||
|
||||
/**
|
||||
* PREMIS Crosswalk
|
||||
|
@@ -14,7 +14,7 @@ import java.util.Map;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.DSpaceObject;
|
||||
import org.dspace.core.Context;
|
||||
import org.jdom.Element;
|
||||
import org.jdom2.Element;
|
||||
|
||||
/**
|
||||
* Translate DSpace native metadata into an external XML format, with parameters.
|
||||
|
@@ -36,10 +36,10 @@ import org.dspace.core.Context;
|
||||
import org.dspace.core.SelfNamedPlugin;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
import org.jdom.Document;
|
||||
import org.jdom.Element;
|
||||
import org.jdom.Namespace;
|
||||
import org.jdom.input.SAXBuilder;
|
||||
import org.jdom2.Document;
|
||||
import org.jdom2.Element;
|
||||
import org.jdom2.Namespace;
|
||||
import org.jdom2.input.SAXBuilder;
|
||||
|
||||
/**
|
||||
* Configurable QDC Crosswalk
|
||||
@@ -290,7 +290,7 @@ public class QDCCrosswalk extends SelfNamedPlugin
|
||||
qdc2element.put(qdc, element);
|
||||
element2qdc.put(makeQualifiedTagName(element), qdc);
|
||||
log.debug("Building Maps: qdc=\"" + qdc + "\", element=\"" + element.toString() + "\"");
|
||||
} catch (org.jdom.JDOMException je) {
|
||||
} catch (org.jdom2.JDOMException je) {
|
||||
throw new CrosswalkInternalException(
|
||||
"Failed parsing XML fragment in properties file: \"" + prolog + val + postlog + "\": " + je
|
||||
.toString(), je);
|
||||
@@ -326,6 +326,7 @@ public class QDCCrosswalk extends SelfNamedPlugin
|
||||
* @throws IOException if IO error
|
||||
* @throws SQLException if database error
|
||||
* @throws AuthorizeException if authorization error
|
||||
* @return List of Elements
|
||||
*/
|
||||
@Override
|
||||
public List<Element> disseminateList(Context context, DSpaceObject dso)
|
||||
|
@@ -26,12 +26,12 @@ import org.dspace.core.factory.CoreServiceFactory;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
import org.dspace.workflow.WorkflowException;
|
||||
import org.jdom.Document;
|
||||
import org.jdom.Element;
|
||||
import org.jdom.JDOMException;
|
||||
import org.jdom.Namespace;
|
||||
import org.jdom.input.SAXBuilder;
|
||||
import org.jdom.output.XMLOutputter;
|
||||
import org.jdom2.Document;
|
||||
import org.jdom2.Element;
|
||||
import org.jdom2.JDOMException;
|
||||
import org.jdom2.Namespace;
|
||||
import org.jdom2.input.SAXBuilder;
|
||||
import org.jdom2.output.XMLOutputter;
|
||||
|
||||
/**
|
||||
* Role Crosswalk
|
||||
|
@@ -24,8 +24,8 @@ import org.dspace.content.service.ItemService;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.core.SelfNamedPlugin;
|
||||
import org.jdom.Element;
|
||||
import org.jdom.Namespace;
|
||||
import org.jdom2.Element;
|
||||
import org.jdom2.Namespace;
|
||||
|
||||
/**
|
||||
* Disseminator for Simple Dublin Core metadata in XML format.
|
||||
@@ -84,6 +84,7 @@ public class SimpleDCDisseminationCrosswalk extends SelfNamedPlugin
|
||||
* @throws IOException if IO error
|
||||
* @throws SQLException if database error
|
||||
* @throws AuthorizeException if authorization error
|
||||
* @return List of Elements
|
||||
*/
|
||||
@Override
|
||||
public List<Element> disseminateList(Context context, DSpaceObject dso)
|
||||
|
@@ -34,9 +34,9 @@ import org.dspace.core.Context;
|
||||
import org.dspace.core.SelfNamedPlugin;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
import org.jdom.Element;
|
||||
import org.jdom.Namespace;
|
||||
import org.jdom.Verifier;
|
||||
import org.jdom2.Element;
|
||||
import org.jdom2.Namespace;
|
||||
import org.jdom2.Verifier;
|
||||
|
||||
/**
|
||||
* Crosswalk for creating appropriate <meta> elements to appear in the
|
||||
@@ -178,6 +178,7 @@ public class XHTMLHeadDisseminationCrosswalk
|
||||
* @throws IOException if IO error
|
||||
* @throws SQLException if database error
|
||||
* @throws AuthorizeException if authorization error
|
||||
* @return List of Elements
|
||||
*/
|
||||
@Override
|
||||
public List<Element> disseminateList(Context context, DSpaceObject dso) throws CrosswalkException,
|
||||
|
@@ -21,7 +21,7 @@ import javax.xml.transform.stream.StreamSource;
|
||||
import org.dspace.core.SelfNamedPlugin;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
import org.jdom.Namespace;
|
||||
import org.jdom2.Namespace;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -130,12 +130,6 @@ public abstract class XSLTCrosswalk extends SelfNamedPlugin {
|
||||
return aliasList.toArray(new String[aliasList.size()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* We need to force this, because some dependency elsewhere interferes.
|
||||
*/
|
||||
private static final String TRANSFORMER_FACTORY_CLASS
|
||||
= "com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl";
|
||||
|
||||
private Transformer transformer = null;
|
||||
private File transformFile = null;
|
||||
private long transformLastModified = 0;
|
||||
@@ -181,8 +175,7 @@ public abstract class XSLTCrosswalk extends SelfNamedPlugin {
|
||||
Source transformSource
|
||||
= new StreamSource(new FileInputStream(transformFile));
|
||||
TransformerFactory transformerFactory
|
||||
= TransformerFactory.newInstance(
|
||||
TRANSFORMER_FACTORY_CLASS, null);
|
||||
= TransformerFactory.newInstance();
|
||||
transformer = transformerFactory.newTransformer(transformSource);
|
||||
transformLastModified = transformFile.lastModified();
|
||||
} catch (TransformerConfigurationException | FileNotFoundException e) {
|
||||
|
@@ -18,6 +18,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.xml.transform.Transformer;
|
||||
import javax.xml.transform.TransformerException;
|
||||
|
||||
@@ -41,14 +42,15 @@ import org.dspace.core.factory.CoreServiceFactory;
|
||||
import org.dspace.handle.factory.HandleServiceFactory;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
import org.jdom.Document;
|
||||
import org.jdom.Element;
|
||||
import org.jdom.Namespace;
|
||||
import org.jdom.Verifier;
|
||||
import org.jdom.output.Format;
|
||||
import org.jdom.output.XMLOutputter;
|
||||
import org.jdom.transform.JDOMResult;
|
||||
import org.jdom.transform.JDOMSource;
|
||||
import org.jdom2.Content;
|
||||
import org.jdom2.Document;
|
||||
import org.jdom2.Element;
|
||||
import org.jdom2.Namespace;
|
||||
import org.jdom2.Verifier;
|
||||
import org.jdom2.output.Format;
|
||||
import org.jdom2.output.XMLOutputter;
|
||||
import org.jdom2.transform.JDOMResult;
|
||||
import org.jdom2.transform.JDOMSource;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -244,6 +246,7 @@ public class XSLTDisseminationCrosswalk
|
||||
* @throws SQLException if database error
|
||||
* @throws AuthorizeException if authorization error
|
||||
* @see DisseminationCrosswalk
|
||||
* @return List of Elements
|
||||
*/
|
||||
@Override
|
||||
public List<Element> disseminateList(Context context, DSpaceObject dso)
|
||||
@@ -268,7 +271,12 @@ public class XSLTDisseminationCrosswalk
|
||||
try {
|
||||
JDOMResult result = new JDOMResult();
|
||||
xform.transform(new JDOMSource(createDIM(dso).getChildren()), result);
|
||||
return result.getResult();
|
||||
List<Content> contentList = result.getResult();
|
||||
// Transform List<Content> into List<Element>
|
||||
List<Element> elementList = contentList.stream()
|
||||
.filter(obj -> obj instanceof Element)
|
||||
.map(Element.class::cast).collect(Collectors.toList());
|
||||
return elementList;
|
||||
} catch (TransformerException e) {
|
||||
LOG.error("Got error: " + e.toString());
|
||||
throw new CrosswalkInternalException("XSL translation failed: " + e.toString(), e);
|
||||
|
@@ -12,6 +12,7 @@ import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.xml.transform.Transformer;
|
||||
import javax.xml.transform.TransformerException;
|
||||
|
||||
@@ -34,13 +35,14 @@ import org.dspace.content.service.ItemService;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.core.factory.CoreServiceFactory;
|
||||
import org.jdom.Document;
|
||||
import org.jdom.Element;
|
||||
import org.jdom.input.SAXBuilder;
|
||||
import org.jdom.output.Format;
|
||||
import org.jdom.output.XMLOutputter;
|
||||
import org.jdom.transform.JDOMResult;
|
||||
import org.jdom.transform.JDOMSource;
|
||||
import org.jdom2.Content;
|
||||
import org.jdom2.Document;
|
||||
import org.jdom2.Element;
|
||||
import org.jdom2.input.SAXBuilder;
|
||||
import org.jdom2.output.Format;
|
||||
import org.jdom2.output.XMLOutputter;
|
||||
import org.jdom2.transform.JDOMResult;
|
||||
import org.jdom2.transform.JDOMSource;
|
||||
|
||||
/**
|
||||
* Configurable XSLT-driven ingestion Crosswalk
|
||||
@@ -141,7 +143,12 @@ public class XSLTIngestionCrosswalk
|
||||
try {
|
||||
JDOMResult result = new JDOMResult();
|
||||
xform.transform(new JDOMSource(metadata), result);
|
||||
ingestDIM(context, dso, result.getResult(), createMissingMetadataFields);
|
||||
List<Content> contentList = result.getResult();
|
||||
// Transform List<Content> into List<Element>
|
||||
List<Element> elementList = contentList.stream()
|
||||
.filter(obj -> obj instanceof Element)
|
||||
.map(Element.class::cast).collect(Collectors.toList());
|
||||
ingestDIM(context, dso, elementList, createMissingMetadataFields);
|
||||
} catch (TransformerException e) {
|
||||
log.error("Got error: " + e.toString());
|
||||
throw new CrosswalkInternalException("XSL Transformation failed: " + e.toString(), e);
|
||||
|
@@ -7,7 +7,8 @@
|
||||
*/
|
||||
package org.dspace.content.logic;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.core.Context;
|
||||
|
||||
@@ -21,7 +22,7 @@ import org.dspace.core.Context;
|
||||
*/
|
||||
public class DefaultFilter implements Filter {
|
||||
private LogicalStatement statement;
|
||||
private static Logger log = Logger.getLogger(Filter.class);
|
||||
private final static Logger log = LogManager.getLogger();
|
||||
|
||||
/**
|
||||
* Set statement from Spring configuration in item-filters.xml
|
||||
|
@@ -10,7 +10,8 @@ package org.dspace.content.logic.condition;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.content.Collection;
|
||||
import org.dspace.content.Community;
|
||||
import org.dspace.content.DSpaceObject;
|
||||
@@ -26,7 +27,7 @@ import org.dspace.core.Context;
|
||||
* @version $Revision$
|
||||
*/
|
||||
public class InCommunityCondition extends AbstractCondition {
|
||||
private static Logger log = Logger.getLogger(InCommunityCondition.class);
|
||||
private final static Logger log = LogManager.getLogger();
|
||||
|
||||
/**
|
||||
* Return true if item is in one of the specified collections
|
||||
|
@@ -7,7 +7,8 @@
|
||||
*/
|
||||
package org.dspace.content.logic.condition;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.content.logic.LogicalStatementException;
|
||||
import org.dspace.core.Context;
|
||||
@@ -19,7 +20,7 @@ import org.dspace.core.Context;
|
||||
* @version $Revision$
|
||||
*/
|
||||
public class IsWithdrawnCondition extends AbstractCondition {
|
||||
private static Logger log = Logger.getLogger(IsWithdrawnCondition.class);
|
||||
private final static Logger log = LogManager.getLogger();
|
||||
|
||||
/**
|
||||
* Return true if item is withdrawn
|
||||
|
@@ -11,7 +11,8 @@ import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.content.MetadataValue;
|
||||
import org.dspace.content.logic.LogicalStatementException;
|
||||
@@ -26,7 +27,7 @@ import org.dspace.core.Context;
|
||||
*/
|
||||
public class MetadataValueMatchCondition extends AbstractCondition {
|
||||
|
||||
private static Logger log = Logger.getLogger(MetadataValueMatchCondition.class);
|
||||
private final static Logger log = LogManager.getLogger();
|
||||
|
||||
/**
|
||||
* Return true if any value for a specified field in the item matches a specified regex pattern
|
||||
|
@@ -11,7 +11,8 @@ import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.content.MetadataValue;
|
||||
import org.dspace.content.logic.LogicalStatementException;
|
||||
@@ -26,7 +27,7 @@ import org.dspace.core.Context;
|
||||
*/
|
||||
public class MetadataValuesMatchCondition extends AbstractCondition {
|
||||
|
||||
private static Logger log = Logger.getLogger(MetadataValuesMatchCondition.class);
|
||||
private final static Logger log = LogManager.getLogger();
|
||||
|
||||
/**
|
||||
* Return true if any value for a specified field in the item matches any of the specified regex patterns
|
||||
|
@@ -10,7 +10,8 @@ package org.dspace.content.logic.condition;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.authorize.ResourcePolicy;
|
||||
import org.dspace.authorize.factory.AuthorizeServiceFactory;
|
||||
import org.dspace.authorize.service.AuthorizeService;
|
||||
@@ -27,7 +28,7 @@ import org.dspace.core.Context;
|
||||
* @version $Revision$
|
||||
*/
|
||||
public class ReadableByGroupCondition extends AbstractCondition {
|
||||
private static Logger log = Logger.getLogger(ReadableByGroupCondition.class);
|
||||
private final static Logger log = LogManager.getLogger();
|
||||
|
||||
// Authorize service
|
||||
AuthorizeService authorizeService = AuthorizeServiceFactory.getInstance().getAuthorizeService();
|
||||
|
@@ -83,10 +83,10 @@ 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.jdom.Element;
|
||||
import org.jdom.Namespace;
|
||||
import org.jdom.output.Format;
|
||||
import org.jdom.output.XMLOutputter;
|
||||
import org.jdom2.Element;
|
||||
import org.jdom2.Namespace;
|
||||
import org.jdom2.output.Format;
|
||||
import org.jdom2.output.XMLOutputter;
|
||||
|
||||
/**
|
||||
* Base class for disseminator of
|
||||
|
@@ -51,7 +51,7 @@ import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
import org.dspace.workflow.WorkflowException;
|
||||
import org.dspace.workflow.factory.WorkflowServiceFactory;
|
||||
import org.jdom.Element;
|
||||
import org.jdom2.Element;
|
||||
|
||||
/**
|
||||
* Base class for package ingester of METS (Metadata Encoding and Transmission
|
||||
|
@@ -20,7 +20,7 @@ import org.dspace.content.crosswalk.CrosswalkException;
|
||||
import org.dspace.content.crosswalk.MetadataValidationException;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.jdom.Element;
|
||||
import org.jdom2.Element;
|
||||
|
||||
/**
|
||||
* Subclass of the METS packager framework to ingest a DSpace
|
||||
|
@@ -23,7 +23,7 @@ import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.core.factory.CoreServiceFactory;
|
||||
import org.dspace.core.service.PluginService;
|
||||
import org.jdom.Element;
|
||||
import org.jdom2.Element;
|
||||
|
||||
/**
|
||||
* Packager plugin to ingest a
|
||||
|
@@ -35,15 +35,17 @@ import org.dspace.core.Context;
|
||||
import org.dspace.core.factory.CoreServiceFactory;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
import org.jdom.Content;
|
||||
import org.jdom.Document;
|
||||
import org.jdom.Element;
|
||||
import org.jdom.JDOMException;
|
||||
import org.jdom.Namespace;
|
||||
import org.jdom.input.SAXBuilder;
|
||||
import org.jdom.output.Format;
|
||||
import org.jdom.output.XMLOutputter;
|
||||
import org.jdom.xpath.XPath;
|
||||
import org.jdom2.Content;
|
||||
import org.jdom2.Document;
|
||||
import org.jdom2.Element;
|
||||
import org.jdom2.JDOMException;
|
||||
import org.jdom2.Namespace;
|
||||
import org.jdom2.filter.Filters;
|
||||
import org.jdom2.input.SAXBuilder;
|
||||
import org.jdom2.output.Format;
|
||||
import org.jdom2.output.XMLOutputter;
|
||||
import org.jdom2.xpath.XPathExpression;
|
||||
import org.jdom2.xpath.XPathFactory;
|
||||
|
||||
/**
|
||||
* <P>
|
||||
@@ -382,15 +384,12 @@ public class METSManifest {
|
||||
public List getMdFiles()
|
||||
throws MetadataValidationException {
|
||||
if (mdFiles == null) {
|
||||
try {
|
||||
// Use a special namespace with known prefix
|
||||
// so we get the right prefix.
|
||||
XPath xpath = XPath.newInstance("descendant::mets:mdRef");
|
||||
xpath.addNamespace(metsNS);
|
||||
mdFiles = xpath.selectNodes(mets);
|
||||
} catch (JDOMException je) {
|
||||
throw new MetadataValidationException("Failed while searching for mdRef elements in manifest: ", je);
|
||||
}
|
||||
// Use a special namespace with known prefix
|
||||
// so we get the right prefix.
|
||||
XPathExpression<Element> xpath =
|
||||
XPathFactory.instance()
|
||||
.compile("descendant::mets:mdRef", Filters.element(), null, metsNS);
|
||||
mdFiles = xpath.evaluate(mets);
|
||||
}
|
||||
return mdFiles;
|
||||
}
|
||||
@@ -414,25 +413,22 @@ public class METSManifest {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
XPath xpath = XPath.newInstance(
|
||||
"mets:fileSec/mets:fileGrp[@USE=\"CONTENT\"]/mets:file[@GROUPID=\"" + groupID + "\"]");
|
||||
xpath.addNamespace(metsNS);
|
||||
List oFiles = xpath.selectNodes(mets);
|
||||
if (oFiles.size() > 0) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Got ORIGINAL file for derived=" + file.toString());
|
||||
}
|
||||
Element flocat = ((Element) oFiles.get(0)).getChild("FLocat", metsNS);
|
||||
if (flocat != null) {
|
||||
return flocat.getAttributeValue("href", xlinkNS);
|
||||
}
|
||||
XPathExpression<Element> xpath =
|
||||
XPathFactory.instance()
|
||||
.compile(
|
||||
"mets:fileSec/mets:fileGrp[@USE=\"CONTENT\"]/mets:file[@GROUPID=\"" + groupID + "\"]",
|
||||
Filters.element(), null, metsNS);
|
||||
List<Element> oFiles = xpath.evaluate(mets);
|
||||
if (oFiles.size() > 0) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Got ORIGINAL file for derived=" + file.toString());
|
||||
}
|
||||
Element flocat = oFiles.get(0).getChild("FLocat", metsNS);
|
||||
if (flocat != null) {
|
||||
return flocat.getAttributeValue("href", xlinkNS);
|
||||
}
|
||||
return null;
|
||||
} catch (JDOMException je) {
|
||||
log.warn("Got exception on XPATH looking for Original file, " + je.toString());
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// translate bundle name from METS to DSpace; METS may be "CONTENT"
|
||||
@@ -888,20 +884,16 @@ public class METSManifest {
|
||||
// use only when path varies each time you call it.
|
||||
protected Element getElementByXPath(String path, boolean nullOk)
|
||||
throws MetadataValidationException {
|
||||
try {
|
||||
XPath xpath = XPath.newInstance(path);
|
||||
xpath.addNamespace(metsNS);
|
||||
xpath.addNamespace(xlinkNS);
|
||||
Object result = xpath.selectSingleNode(mets);
|
||||
if (result == null && nullOk) {
|
||||
return null;
|
||||
} else if (result instanceof Element) {
|
||||
return (Element) result;
|
||||
} else {
|
||||
throw new MetadataValidationException("METSManifest: Failed to resolve XPath, path=\"" + path + "\"");
|
||||
}
|
||||
} catch (JDOMException je) {
|
||||
throw new MetadataValidationException("METSManifest: Failed to resolve XPath, path=\"" + path + "\"", je);
|
||||
XPathExpression<Element> xpath =
|
||||
XPathFactory.instance()
|
||||
.compile(path, Filters.element(), null, metsNS, xlinkNS);
|
||||
Element result = xpath.evaluateFirst(mets);
|
||||
if (result == null && nullOk) {
|
||||
return null;
|
||||
} else if (result == null && !nullOk) {
|
||||
throw new MetadataValidationException("METSManifest: Failed to resolve XPath, path=\"" + path + "\"");
|
||||
} else {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -35,7 +35,7 @@ import org.dspace.eperson.PasswordHash;
|
||||
import org.dspace.eperson.factory.EPersonServiceFactory;
|
||||
import org.dspace.eperson.service.EPersonService;
|
||||
import org.dspace.eperson.service.GroupService;
|
||||
import org.jdom.Namespace;
|
||||
import org.jdom2.Namespace;
|
||||
|
||||
/**
|
||||
* Plugin to export all Group and EPerson objects in XML, perhaps for reloading.
|
||||
|
@@ -152,14 +152,14 @@ public class Email {
|
||||
private static final String RESOURCE_REPOSITORY_NAME = "Email";
|
||||
private static final Properties VELOCITY_PROPERTIES = new Properties();
|
||||
static {
|
||||
VELOCITY_PROPERTIES.put(Velocity.RESOURCE_LOADER, "string");
|
||||
VELOCITY_PROPERTIES.put("string.resource.loader.description",
|
||||
VELOCITY_PROPERTIES.put(Velocity.RESOURCE_LOADERS, "string");
|
||||
VELOCITY_PROPERTIES.put("resource.loader.string.description",
|
||||
"Velocity StringResource loader");
|
||||
VELOCITY_PROPERTIES.put("string.resource.loader.class",
|
||||
VELOCITY_PROPERTIES.put("resource.loader.string.class",
|
||||
StringResourceLoader.class.getName());
|
||||
VELOCITY_PROPERTIES.put("string.resource.loader.repository.name",
|
||||
VELOCITY_PROPERTIES.put("resource.loader.string.repository.name",
|
||||
RESOURCE_REPOSITORY_NAME);
|
||||
VELOCITY_PROPERTIES.put("string.resource.loader.repository.static",
|
||||
VELOCITY_PROPERTIES.put("resource.loader.string.repository.static",
|
||||
"false");
|
||||
}
|
||||
|
||||
|
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
package org.dspace.curate;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.sql.SQLException;
|
||||
@@ -154,7 +155,8 @@ public class CitationPage extends AbstractCurationTask {
|
||||
try {
|
||||
//Create the cited document
|
||||
InputStream citedInputStream =
|
||||
citationDocument.makeCitedDocument(Curator.curationContext(), bitstream).getLeft();
|
||||
new ByteArrayInputStream(
|
||||
citationDocument.makeCitedDocument(Curator.curationContext(), bitstream).getLeft());
|
||||
//Add the cited document to the approiate bundle
|
||||
this.addCitedPageToItem(citedInputStream, bundle, pBundle,
|
||||
dBundle, displayMap, item, bitstream);
|
||||
|
@@ -19,7 +19,6 @@ public class CurationCliScriptConfiguration extends CurationScriptConfiguration<
|
||||
public Options getOptions() {
|
||||
options = super.getOptions();
|
||||
options.addOption("e", "eperson", true, "email address of curating eperson");
|
||||
options.getOption("e").setType(String.class);
|
||||
options.getOption("e").setRequired(true);
|
||||
return options;
|
||||
}
|
||||
|
@@ -74,25 +74,17 @@ public enum IndexClientOptions {
|
||||
|
||||
options
|
||||
.addOption("r", "remove", true, "remove an Item, Collection or Community from index based on its handle");
|
||||
options.getOption("r").setType(String.class);
|
||||
options.addOption("i", "index", true,
|
||||
"add or update an Item, Collection or Community based on its handle or uuid");
|
||||
options.getOption("i").setType(boolean.class);
|
||||
options.addOption("c", "clean", false,
|
||||
"clean existing index removing any documents that no longer exist in the db");
|
||||
options.getOption("c").setType(boolean.class);
|
||||
options.addOption("d", "delete", false,
|
||||
"delete all records from existing index");
|
||||
options.getOption("d").setType(boolean.class);
|
||||
options.addOption("b", "build", false, "(re)build index, wiping out current one if it exists");
|
||||
options.getOption("b").setType(boolean.class);
|
||||
options.addOption("s", "spellchecker", false, "Rebuild the spellchecker, can be combined with -b and -f.");
|
||||
options.getOption("s").setType(boolean.class);
|
||||
options.addOption("f", "force", false,
|
||||
"if updating existing index, force each handle to be reindexed even if uptodate");
|
||||
options.getOption("f").setType(boolean.class);
|
||||
options.addOption("h", "help", false, "print this help message");
|
||||
options.getOption("h").setType(boolean.class);
|
||||
return options;
|
||||
}
|
||||
}
|
||||
|
@@ -95,7 +95,6 @@ public abstract class IndexFactoryImpl<T extends IndexableObject, S> implements
|
||||
100000);
|
||||
|
||||
// Use Tika's Text parser as the streams are always from the TEXT bundle (i.e. already extracted text)
|
||||
// TODO: We may wish to consider using Tika to extract the text in the future.
|
||||
TextAndCSVParser tikaParser = new TextAndCSVParser();
|
||||
BodyContentHandler tikaHandler = new BodyContentHandler(charLimit);
|
||||
Metadata tikaMetadata = new Metadata();
|
||||
|
@@ -8,7 +8,6 @@
|
||||
package org.dspace.disseminate;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -297,7 +296,7 @@ public class CitationDocumentServiceImpl implements CitationDocumentService, Ini
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<InputStream, Long> makeCitedDocument(Context context, Bitstream bitstream)
|
||||
public Pair<byte[], Long> makeCitedDocument(Context context, Bitstream bitstream)
|
||||
throws IOException, SQLException, AuthorizeException {
|
||||
PDDocument document = new PDDocument();
|
||||
PDDocument sourceDocument = new PDDocument();
|
||||
@@ -318,7 +317,7 @@ public class CitationDocumentServiceImpl implements CitationDocumentService, Ini
|
||||
document.save(out);
|
||||
|
||||
byte[] data = out.toByteArray();
|
||||
return Pair.of(new ByteArrayInputStream(data), Long.valueOf(data.length));
|
||||
return Pair.of(data, Long.valueOf(data.length));
|
||||
}
|
||||
|
||||
} finally {
|
||||
|
@@ -8,7 +8,6 @@
|
||||
package org.dspace.disseminate.service;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
@@ -84,7 +83,7 @@ public interface CitationDocumentService {
|
||||
* @throws SQLException if database error
|
||||
* @throws AuthorizeException if authorization error
|
||||
*/
|
||||
public Pair<InputStream, Long> makeCitedDocument(Context context, Bitstream bitstream)
|
||||
public Pair<byte[], Long> makeCitedDocument(Context context, Bitstream bitstream)
|
||||
throws IOException, SQLException, AuthorizeException;
|
||||
|
||||
/**
|
||||
|
@@ -7,10 +7,12 @@
|
||||
*/
|
||||
package org.dspace.eperson;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
import javax.mail.MessagingException;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
@@ -30,16 +32,17 @@ import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
* Recommended filter: EPerson+Create
|
||||
*
|
||||
* @author Stuart Lewis
|
||||
* @version $Revision$
|
||||
*/
|
||||
public class EPersonConsumer implements Consumer {
|
||||
/**
|
||||
* log4j logger
|
||||
*/
|
||||
private static final Logger log = org.apache.logging.log4j.LogManager.getLogger(EPersonConsumer.class);
|
||||
private static final Logger log
|
||||
= org.apache.logging.log4j.LogManager.getLogger(EPersonConsumer.class);
|
||||
|
||||
protected EPersonService ePersonService
|
||||
= EPersonServiceFactory.getInstance().getEPersonService();
|
||||
|
||||
protected ConfigurationService configurationService
|
||||
= DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||
|
||||
@@ -74,6 +77,7 @@ public class EPersonConsumer implements Consumer {
|
||||
if (et == Event.CREATE) {
|
||||
// Notify of new user registration
|
||||
String notifyRecipient = configurationService.getProperty("registration.notify");
|
||||
EPerson eperson = ePersonService.find(context, id);
|
||||
if (notifyRecipient == null) {
|
||||
notifyRecipient = "";
|
||||
}
|
||||
@@ -81,7 +85,6 @@ public class EPersonConsumer implements Consumer {
|
||||
|
||||
if (!notifyRecipient.equals("")) {
|
||||
try {
|
||||
EPerson eperson = ePersonService.find(context, id);
|
||||
Email adminEmail = Email
|
||||
.getEmail(I18nUtil.getEmailFilename(context.getCurrentLocale(), "registration_notify"));
|
||||
adminEmail.addRecipient(notifyRecipient);
|
||||
@@ -103,6 +106,26 @@ public class EPersonConsumer implements Consumer {
|
||||
"error_emailing_administrator", ""), me);
|
||||
}
|
||||
}
|
||||
|
||||
// If enabled, send a "welcome" message to the new EPerson.
|
||||
if (configurationService.getBooleanProperty("mail.welcome.enabled", false)) {
|
||||
String addressee = eperson.getEmail();
|
||||
if (StringUtils.isNotBlank(addressee)) {
|
||||
log.debug("Sending welcome email to {}", addressee);
|
||||
try {
|
||||
Email message = Email.getEmail(
|
||||
I18nUtil.getEmailFilename(context.getCurrentLocale(), "welcome"));
|
||||
message.addRecipient(addressee);
|
||||
message.send();
|
||||
} catch (IOException | MessagingException ex) {
|
||||
log.warn("Welcome message not sent to {}: {}",
|
||||
addressee, ex.getMessage());
|
||||
}
|
||||
} else {
|
||||
log.warn("Welcome message not sent to EPerson {} because it has no email address.",
|
||||
eperson.getID().toString());
|
||||
}
|
||||
}
|
||||
} else if (et == Event.DELETE) {
|
||||
// TODO: Implement this if required
|
||||
}
|
||||
|
@@ -201,7 +201,7 @@ public class Group extends DSpaceObject implements DSpaceObjectLegacySupport {
|
||||
void setName(String name) throws SQLException {
|
||||
if (!StringUtils.equals(this.name, name) && !isPermanent()) {
|
||||
this.name = name;
|
||||
groupsChanged = true;
|
||||
setMetadataModified();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -31,7 +31,8 @@ import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.content.factory.ContentServiceFactory;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
@@ -55,7 +56,7 @@ public class GoogleAsyncEventListener extends AbstractUsageEventListener {
|
||||
// 20 is the event max set by the GA API
|
||||
private static final int GA_MAX_EVENTS = 20;
|
||||
private static final String ANALYTICS_BATCH_ENDPOINT = "https://www.google-analytics.com/batch";
|
||||
private static Logger log = Logger.getLogger(GoogleAsyncEventListener.class);
|
||||
private final static Logger log = LogManager.getLogger();
|
||||
private static String analyticsKey;
|
||||
private static CloseableHttpClient httpclient;
|
||||
private static Buffer buffer;
|
||||
|
@@ -29,10 +29,10 @@ import org.dspace.harvest.dao.HarvestedCollectionDAO;
|
||||
import org.dspace.harvest.service.HarvestedCollectionService;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
import org.jdom.Document;
|
||||
import org.jdom.Element;
|
||||
import org.jdom.Namespace;
|
||||
import org.jdom.input.DOMBuilder;
|
||||
import org.jdom2.Document;
|
||||
import org.jdom2.Element;
|
||||
import org.jdom2.Namespace;
|
||||
import org.jdom2.input.DOMBuilder;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.w3c.dom.DOMException;
|
||||
import org.xml.sax.SAXException;
|
||||
|
@@ -70,11 +70,11 @@ import org.dspace.harvest.service.HarvestedCollectionService;
|
||||
import org.dspace.harvest.service.HarvestedItemService;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
import org.jdom.Document;
|
||||
import org.jdom.Element;
|
||||
import org.jdom.Namespace;
|
||||
import org.jdom.input.DOMBuilder;
|
||||
import org.jdom.output.XMLOutputter;
|
||||
import org.jdom2.Document;
|
||||
import org.jdom2.Element;
|
||||
import org.jdom2.Namespace;
|
||||
import org.jdom2.input.DOMBuilder;
|
||||
import org.jdom2.output.XMLOutputter;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
|
||||
|
@@ -34,8 +34,6 @@ public class DOI
|
||||
implements Identifier, ReloadableEntity<Integer> {
|
||||
public static final String SCHEME = "doi:";
|
||||
|
||||
public static final String RESOLVER = "http://dx.doi.org";
|
||||
|
||||
@Id
|
||||
@Column(name = "doi_id")
|
||||
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "doi_seq")
|
||||
|
@@ -1028,7 +1028,7 @@ public class DOIIdentifierProvider extends FilteredIdentifierProvider {
|
||||
Item item = (Item) dso;
|
||||
|
||||
List<MetadataValue> metadata = itemService.getMetadata(item, MD_SCHEMA, DOI_ELEMENT, DOI_QUALIFIER, null);
|
||||
String leftPart = DOI.RESOLVER + SLASH + getPrefix() + SLASH + getNamespaceSeparator();
|
||||
String leftPart = doiService.getResolver() + SLASH + getPrefix() + SLASH + getNamespaceSeparator();
|
||||
for (MetadataValue id : metadata) {
|
||||
if (id.getValue().startsWith(leftPart)) {
|
||||
return doiService.DOIFromExternalFormat(id.getValue());
|
||||
|
@@ -17,11 +17,13 @@ import org.dspace.core.Context;
|
||||
import org.dspace.identifier.dao.DOIDAO;
|
||||
import org.dspace.identifier.doi.DOIIdentifierException;
|
||||
import org.dspace.identifier.service.DOIService;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
* Service implementation for the DOI object.
|
||||
* This class is responsible for all business logic calls for the DOI object and is autowired by spring.
|
||||
* Service implementation for the {@link DOI} object.
|
||||
* This class is responsible for all business logic calls for the DOI object
|
||||
* and is autowired by Spring.
|
||||
* This class should never be accessed directly.
|
||||
*
|
||||
* @author kevinvandevelde at atmire.com
|
||||
@@ -31,6 +33,16 @@ public class DOIServiceImpl implements DOIService {
|
||||
@Autowired(required = true)
|
||||
protected DOIDAO doiDAO;
|
||||
|
||||
@Autowired(required = true)
|
||||
protected ConfigurationService configurationService;
|
||||
|
||||
private static final Pattern DOI_URL_PATTERN
|
||||
= Pattern.compile("http(s)?://([a-z0-9-.]+)?doi.org(?<path>/.*)",
|
||||
Pattern.CASE_INSENSITIVE);
|
||||
private static final String DOI_URL_PATTERN_PATH_GROUP = "path";
|
||||
|
||||
private static final String RESOLVER_DEFAULT = "https://doi.org";
|
||||
|
||||
protected DOIServiceImpl() {
|
||||
|
||||
}
|
||||
@@ -66,25 +78,46 @@ public class DOIServiceImpl implements DOIService {
|
||||
if (null == identifier) {
|
||||
throw new IllegalArgumentException("Identifier is null.", new NullPointerException());
|
||||
}
|
||||
|
||||
if (identifier.isEmpty()) {
|
||||
throw new IllegalArgumentException("Cannot format an empty identifier.");
|
||||
}
|
||||
if (identifier.startsWith(DOI.SCHEME)) {
|
||||
return DOI.RESOLVER + "/" + identifier.substring(DOI.SCHEME.length());
|
||||
|
||||
String resolver = getResolver();
|
||||
|
||||
if (identifier.startsWith(DOI.SCHEME)) { // doi:something
|
||||
StringBuilder result = new StringBuilder(resolver);
|
||||
if (!resolver.endsWith("/")) {
|
||||
result.append('/');
|
||||
}
|
||||
result.append(identifier.substring(DOI.SCHEME.length()));
|
||||
return result.toString();
|
||||
}
|
||||
if (identifier.startsWith("10.") && identifier.contains("/")) {
|
||||
return DOI.RESOLVER + "/" + identifier;
|
||||
|
||||
if (identifier.startsWith("10.") && identifier.contains("/")) { // 10.something
|
||||
StringBuilder result = new StringBuilder(resolver);
|
||||
if (!resolver.endsWith("/")) {
|
||||
result.append('/');
|
||||
}
|
||||
result.append(identifier);
|
||||
return result.toString();
|
||||
}
|
||||
if (identifier.startsWith(DOI.RESOLVER + "/10.")) {
|
||||
|
||||
if (identifier.startsWith(resolver + "/10.")) { // https://doi.org/10.something
|
||||
return identifier;
|
||||
}
|
||||
|
||||
Matcher matcher = DOI_URL_PATTERN.matcher(identifier);
|
||||
if (matcher.matches()) { // various old URL forms
|
||||
return resolver + matcher.group(DOI_URL_PATTERN_PATH_GROUP);
|
||||
}
|
||||
|
||||
throw new IdentifierException(identifier + "does not seem to be a DOI.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String DOIFromExternalFormat(String identifier) throws DOIIdentifierException {
|
||||
Pattern pattern = Pattern.compile("^" + DOI.RESOLVER + "/+(10\\..*)$");
|
||||
Pattern pattern = Pattern.compile("^" + getResolver() + "/+(10\\..*)$");
|
||||
Matcher matcher = pattern.matcher(identifier);
|
||||
if (matcher.find()) {
|
||||
return DOI.SCHEME + matcher.group(1);
|
||||
@@ -99,18 +132,29 @@ public class DOIServiceImpl implements DOIService {
|
||||
if (null == identifier) {
|
||||
throw new IllegalArgumentException("Identifier is null.", new NullPointerException());
|
||||
}
|
||||
if (identifier.startsWith(DOI.SCHEME)) {
|
||||
return identifier;
|
||||
}
|
||||
|
||||
if (identifier.isEmpty()) {
|
||||
throw new IllegalArgumentException("Cannot format an empty identifier.");
|
||||
}
|
||||
if (identifier.startsWith("10.") && identifier.contains("/")) {
|
||||
|
||||
if (identifier.startsWith(DOI.SCHEME)) { // doi:something
|
||||
return identifier;
|
||||
}
|
||||
|
||||
if (identifier.startsWith("10.") && identifier.contains("/")) { // 10.something
|
||||
return DOI.SCHEME + identifier;
|
||||
}
|
||||
if (identifier.startsWith(DOI.RESOLVER + "/10.")) {
|
||||
return DOI.SCHEME + identifier.substring(18);
|
||||
|
||||
String resolver = getResolver();
|
||||
if (identifier.startsWith(resolver + "/10.")) { //https://doi.org/10.something
|
||||
return DOI.SCHEME + identifier.substring(resolver.length());
|
||||
}
|
||||
|
||||
Matcher matcher = DOI_URL_PATTERN.matcher(identifier);
|
||||
if (matcher.matches()) { // various old URL forms
|
||||
return DOI.SCHEME + matcher.group(DOI_URL_PATTERN_PATH_GROUP).substring(1);
|
||||
}
|
||||
|
||||
throw new DOIIdentifierException(identifier + "does not seem to be a DOI.",
|
||||
DOIIdentifierException.UNRECOGNIZED);
|
||||
}
|
||||
@@ -126,4 +170,14 @@ public class DOIServiceImpl implements DOIService {
|
||||
throws SQLException {
|
||||
return doiDAO.findSimilarNotInState(context, doiPattern, statuses, dsoIsNotNull);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getResolver() {
|
||||
String resolver = configurationService.getProperty("identifier.doi.resolver",
|
||||
RESOLVER_DEFAULT);
|
||||
if (resolver.endsWith("/")) {
|
||||
resolver = resolver.substring(0, resolver.length() - 1);
|
||||
}
|
||||
return resolver;
|
||||
}
|
||||
}
|
||||
|
@@ -23,8 +23,8 @@ import org.dspace.core.factory.CoreServiceFactory;
|
||||
import org.dspace.handle.factory.HandleServiceFactory;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.utils.DSpace;
|
||||
import org.jdom.Element;
|
||||
import org.jdom.output.XMLOutputter;
|
||||
import org.jdom2.Element;
|
||||
import org.jdom2.output.XMLOutputter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@@ -45,13 +45,13 @@ import org.dspace.core.factory.CoreServiceFactory;
|
||||
import org.dspace.handle.service.HandleService;
|
||||
import org.dspace.identifier.DOI;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.jdom.Document;
|
||||
import org.jdom.Element;
|
||||
import org.jdom.JDOMException;
|
||||
import org.jdom.filter.ElementFilter;
|
||||
import org.jdom.input.SAXBuilder;
|
||||
import org.jdom.output.Format;
|
||||
import org.jdom.output.XMLOutputter;
|
||||
import org.jdom2.Document;
|
||||
import org.jdom2.Element;
|
||||
import org.jdom2.JDOMException;
|
||||
import org.jdom2.filter.ElementFilter;
|
||||
import org.jdom2.input.SAXBuilder;
|
||||
import org.jdom2.output.Format;
|
||||
import org.jdom2.output.XMLOutputter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@@ -17,26 +17,65 @@ import org.dspace.identifier.IdentifierException;
|
||||
import org.dspace.identifier.doi.DOIIdentifierException;
|
||||
|
||||
/**
|
||||
* Service interface class for the DOI object.
|
||||
* The implementation of this class is responsible for all business logic calls for the DOI object and is autowired
|
||||
* by spring
|
||||
* Service interface class for the {@link DOI} object.
|
||||
* The implementation of this class is responsible for all business logic calls
|
||||
* for the {@link DOI} object and is autowired by Spring.
|
||||
*
|
||||
* @author kevinvandevelde at atmire.com
|
||||
*/
|
||||
public interface DOIService {
|
||||
|
||||
/**
|
||||
* Update a DOI in storage.
|
||||
*
|
||||
* @param context current DSpace session.
|
||||
* @param doi the DOI to persist.
|
||||
* @throws SQLException passed through.
|
||||
*/
|
||||
public void update(Context context, DOI doi) throws SQLException;
|
||||
|
||||
/**
|
||||
* Create a new DOI in storage.
|
||||
*
|
||||
* @param context current DSpace session.
|
||||
* @return the new DOI.
|
||||
* @throws SQLException passed through.
|
||||
*/
|
||||
public DOI create(Context context) throws SQLException;
|
||||
|
||||
/**
|
||||
* Find a specific DOI in storage.
|
||||
*
|
||||
* @param context current DSpace session.
|
||||
* @param doi string representation of the DOI.
|
||||
* @return the DOI object found.
|
||||
* @throws SQLException passed through, can mean none found.
|
||||
*/
|
||||
public DOI findByDoi(Context context, String doi) throws SQLException;
|
||||
|
||||
/**
|
||||
* Find the DOI assigned to a given DSpace Object.
|
||||
*
|
||||
* @param context current DSpace session.
|
||||
* @param dso The DSpace Object.
|
||||
* @return the DSO's DOI.
|
||||
* @throws SQLException passed through.
|
||||
*/
|
||||
public DOI findDOIByDSpaceObject(Context context, DSpaceObject dso) throws SQLException;
|
||||
|
||||
/**
|
||||
* Find the DOI assigned to a given DSpace Object, unless it has one of a
|
||||
* given set of statuses.
|
||||
*
|
||||
* @param context current DSpace context.
|
||||
* @param dso the DSpace Object.
|
||||
* @param statusToExclude uninteresting statuses.
|
||||
* @return the DSO's DOI.
|
||||
* @throws SQLException passed through.
|
||||
*/
|
||||
public DOI findDOIByDSpaceObject(Context context, DSpaceObject dso, List<Integer> statusToExclude)
|
||||
throws SQLException;
|
||||
|
||||
|
||||
/**
|
||||
* This method helps to convert a DOI into a URL. It takes DOIs in one of
|
||||
* the following formats and returns it as URL (f.e.
|
||||
@@ -49,12 +88,18 @@ public interface DOIService {
|
||||
*
|
||||
* @param identifier A DOI that should be returned in external form.
|
||||
* @return A String containing a URL to the official DOI resolver.
|
||||
* @throws IllegalArgumentException If identifier is null or an empty String.
|
||||
* @throws org.dspace.identifier.IdentifierException If identifier could not be recognized as valid DOI.
|
||||
* @throws IllegalArgumentException If identifier is null or an empty String.
|
||||
* @throws IdentifierException If identifier could not be recognized as valid DOI.
|
||||
*/
|
||||
public String DOIToExternalForm(String identifier)
|
||||
throws IdentifierException;
|
||||
|
||||
/**
|
||||
* Convert an HTTP DOI URL (https://doi.org/10.something) to a "doi:" URI.
|
||||
* @param identifier HTTP URL
|
||||
* @return DOI URI
|
||||
* @throws DOIIdentifierException if {@link identifier} is not recognizable.
|
||||
*/
|
||||
public String DOIFromExternalFormat(String identifier)
|
||||
throws DOIIdentifierException;
|
||||
|
||||
@@ -64,16 +109,24 @@ public interface DOIService {
|
||||
* @param identifier Identifier to format, following format are accepted:
|
||||
* f.e. 10.123/456, doi:10.123/456, http://dx.doi.org/10.123/456.
|
||||
* @return Given Identifier with DOI-Scheme, f.e. doi:10.123/456.
|
||||
* @throws IllegalArgumentException If identifier is empty or null.
|
||||
* @throws org.dspace.identifier.doi.DOIIdentifierException If DOI could not be recognized.
|
||||
* @throws IllegalArgumentException If identifier is empty or null.
|
||||
* @throws DOIIdentifierException If DOI could not be recognized.
|
||||
*/
|
||||
public String formatIdentifier(String identifier)
|
||||
throws DOIIdentifierException;
|
||||
|
||||
/**
|
||||
* Find all DOIs that have one of a given set of statuses.
|
||||
* @param context current DSpace session.
|
||||
* @param statuses desired statuses.
|
||||
* @return all DOIs having any of the given statuses.
|
||||
* @throws SQLException passed through.
|
||||
*/
|
||||
public List<DOI> getDOIsByStatus(Context context, List<Integer> statuses) throws SQLException;
|
||||
|
||||
/**
|
||||
* Find all DOIs that are similar to the specified pattern ant not in the specified states.
|
||||
* Find all DOIs that are similar to the specified pattern and not in the
|
||||
* specified states.
|
||||
*
|
||||
* @param context DSpace context
|
||||
* @param doiPattern The pattern, e.g. "10.5072/123.%"
|
||||
@@ -85,4 +138,11 @@ public interface DOIService {
|
||||
public List<DOI> getSimilarDOIsNotInState(Context context, String doiPattern, List<Integer> statuses,
|
||||
boolean dsoIsNotNull)
|
||||
throws SQLException;
|
||||
|
||||
/**
|
||||
* Get the URL stem of the DOI resolver, e.g. "https://doi.org/".
|
||||
*
|
||||
* @return URL to the DOI resolver.
|
||||
*/
|
||||
public String getResolver();
|
||||
}
|
||||
|
@@ -23,7 +23,7 @@ public class CanvasCacheEvictService {
|
||||
CacheManager cacheManager;
|
||||
|
||||
public void evictSingleCacheValue(String cacheKey) {
|
||||
Objects.requireNonNull(cacheManager.getCache(CACHE_NAME)).evict(cacheKey);
|
||||
Objects.requireNonNull(cacheManager.getCache(CACHE_NAME)).evictIfPresent(cacheKey);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -26,11 +26,11 @@ public class ManifestsCacheEvictService {
|
||||
CacheManager cacheManager;
|
||||
|
||||
public void evictSingleCacheValue(String cacheKey) {
|
||||
Objects.requireNonNull(cacheManager.getCache(CACHE_NAME)).evict(cacheKey);
|
||||
Objects.requireNonNull(cacheManager.getCache(CACHE_NAME)).evictIfPresent(cacheKey);
|
||||
}
|
||||
|
||||
public void evictAllCacheValues() {
|
||||
Objects.requireNonNull(cacheManager.getCache(CACHE_NAME)).clear();
|
||||
Objects.requireNonNull(cacheManager.getCache(CACHE_NAME)).invalidate();
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -9,10 +9,10 @@ package org.dspace.importer.external.arxiv.metadatamapping.contributor;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.apache.axiom.om.OMElement;
|
||||
import org.dspace.importer.external.metadatamapping.MetadatumDTO;
|
||||
import org.dspace.importer.external.metadatamapping.contributor.MetadataContributor;
|
||||
import org.dspace.importer.external.metadatamapping.contributor.SimpleXpathMetadatumContributor;
|
||||
import org.jdom2.Element;
|
||||
|
||||
/**
|
||||
* Arxiv specific implementation of {@link MetadataContributor}
|
||||
@@ -32,7 +32,7 @@ public class ArXivIdMetadataContributor extends SimpleXpathMetadatumContributor
|
||||
* @return a collection of import records. Only the identifier of the found records may be put in the record.
|
||||
*/
|
||||
@Override
|
||||
public Collection<MetadatumDTO> contributeMetadata(OMElement t) {
|
||||
public Collection<MetadatumDTO> contributeMetadata(Element t) {
|
||||
Collection<MetadatumDTO> values = super.contributeMetadata(t);
|
||||
parseValue(values);
|
||||
return values;
|
||||
|
@@ -7,8 +7,10 @@
|
||||
*/
|
||||
package org.dspace.importer.external.arxiv.service;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Callable;
|
||||
@@ -20,10 +22,6 @@ import javax.ws.rs.client.WebTarget;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
import org.apache.axiom.om.OMElement;
|
||||
import org.apache.axiom.om.OMXMLBuilderFactory;
|
||||
import org.apache.axiom.om.OMXMLParserWrapper;
|
||||
import org.apache.axiom.om.xpath.AXIOMXPath;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.importer.external.datamodel.ImportRecord;
|
||||
@@ -31,7 +29,14 @@ import org.dspace.importer.external.datamodel.Query;
|
||||
import org.dspace.importer.external.exception.MetadataSourceException;
|
||||
import org.dspace.importer.external.service.AbstractImportMetadataSourceService;
|
||||
import org.dspace.importer.external.service.components.QuerySource;
|
||||
import org.jaxen.JaxenException;
|
||||
import org.jdom2.Document;
|
||||
import org.jdom2.Element;
|
||||
import org.jdom2.JDOMException;
|
||||
import org.jdom2.Namespace;
|
||||
import org.jdom2.filter.Filters;
|
||||
import org.jdom2.input.SAXBuilder;
|
||||
import org.jdom2.xpath.XPathExpression;
|
||||
import org.jdom2.xpath.XPathFactory;
|
||||
|
||||
/**
|
||||
* Implements a data source for querying ArXiv
|
||||
@@ -39,7 +44,7 @@ import org.jaxen.JaxenException;
|
||||
* @author Pasquale Cavallo (pasquale.cavallo at 4Science dot it)
|
||||
*
|
||||
*/
|
||||
public class ArXivImportMetadataSourceServiceImpl extends AbstractImportMetadataSourceService<OMElement>
|
||||
public class ArXivImportMetadataSourceServiceImpl extends AbstractImportMetadataSourceService<Element>
|
||||
implements QuerySource {
|
||||
|
||||
private WebTarget webTarget;
|
||||
@@ -213,15 +218,20 @@ public class ArXivImportMetadataSourceServiceImpl extends AbstractImportMetadata
|
||||
Response response = invocationBuilder.get();
|
||||
if (response.getStatus() == 200) {
|
||||
String responseString = response.readEntity(String.class);
|
||||
OMXMLParserWrapper records = OMXMLBuilderFactory.createOMBuilder(new StringReader(responseString));
|
||||
OMElement element = records.getDocumentElement();
|
||||
AXIOMXPath xpath = null;
|
||||
|
||||
SAXBuilder saxBuilder = new SAXBuilder();
|
||||
Document document = saxBuilder.build(new StringReader(responseString));
|
||||
Element root = document.getRootElement();
|
||||
|
||||
List namespaces = Arrays.asList(Namespace.getNamespace("opensearch",
|
||||
"http://a9.com/-/spec/opensearch/1.1/"));
|
||||
XPathExpression<Element> xpath =
|
||||
XPathFactory.instance().compile("opensearch:totalResults", Filters.element(), null, namespaces);
|
||||
|
||||
Element count = xpath.evaluateFirst(root);
|
||||
try {
|
||||
xpath = new AXIOMXPath("opensearch:totalResults");
|
||||
xpath.addNamespace("opensearch", "http://a9.com/-/spec/opensearch/1.1/");
|
||||
OMElement count = (OMElement) xpath.selectSingleNode(element);
|
||||
return Integer.parseInt(count.getText());
|
||||
} catch (JaxenException e) {
|
||||
} catch (NumberFormatException e) {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
@@ -274,8 +284,8 @@ public class ArXivImportMetadataSourceServiceImpl extends AbstractImportMetadata
|
||||
Response response = invocationBuilder.get();
|
||||
if (response.getStatus() == 200) {
|
||||
String responseString = response.readEntity(String.class);
|
||||
List<OMElement> omElements = splitToRecords(responseString);
|
||||
for (OMElement record : omElements) {
|
||||
List<Element> elements = splitToRecords(responseString);
|
||||
for (Element record : elements) {
|
||||
results.add(transformSourceRecords(record));
|
||||
}
|
||||
return results;
|
||||
@@ -321,8 +331,8 @@ public class ArXivImportMetadataSourceServiceImpl extends AbstractImportMetadata
|
||||
Response response = invocationBuilder.get();
|
||||
if (response.getStatus() == 200) {
|
||||
String responseString = response.readEntity(String.class);
|
||||
List<OMElement> omElements = splitToRecords(responseString);
|
||||
for (OMElement record : omElements) {
|
||||
List<Element> elements = splitToRecords(responseString);
|
||||
for (Element record : elements) {
|
||||
results.add(transformSourceRecords(record));
|
||||
}
|
||||
return results;
|
||||
@@ -359,8 +369,8 @@ public class ArXivImportMetadataSourceServiceImpl extends AbstractImportMetadata
|
||||
Response response = invocationBuilder.get();
|
||||
if (response.getStatus() == 200) {
|
||||
String responseString = response.readEntity(String.class);
|
||||
List<OMElement> omElements = splitToRecords(responseString);
|
||||
for (OMElement record : omElements) {
|
||||
List<Element> elements = splitToRecords(responseString);
|
||||
for (Element record : elements) {
|
||||
results.add(transformSourceRecords(record));
|
||||
}
|
||||
return results;
|
||||
@@ -387,16 +397,21 @@ public class ArXivImportMetadataSourceServiceImpl extends AbstractImportMetadata
|
||||
}
|
||||
}
|
||||
|
||||
private List<OMElement> splitToRecords(String recordsSrc) {
|
||||
OMXMLParserWrapper records = OMXMLBuilderFactory.createOMBuilder(new StringReader(recordsSrc));
|
||||
OMElement element = records.getDocumentElement();
|
||||
AXIOMXPath xpath = null;
|
||||
private List<Element> splitToRecords(String recordsSrc) {
|
||||
|
||||
try {
|
||||
xpath = new AXIOMXPath("ns:entry");
|
||||
xpath.addNamespace("ns", "http://www.w3.org/2005/Atom");
|
||||
List<OMElement> recordsList = xpath.selectNodes(element);
|
||||
SAXBuilder saxBuilder = new SAXBuilder();
|
||||
Document document = saxBuilder.build(new StringReader(recordsSrc));
|
||||
Element root = document.getRootElement();
|
||||
|
||||
List namespaces = Arrays.asList(Namespace.getNamespace("ns",
|
||||
"http://www.w3.org/2005/Atom"));
|
||||
XPathExpression<Element> xpath =
|
||||
XPathFactory.instance().compile("ns:entry", Filters.element(), null, namespaces);
|
||||
|
||||
List<Element> recordsList = xpath.evaluate(root);
|
||||
return recordsList;
|
||||
} catch (JaxenException e) {
|
||||
} catch (JDOMException | IOException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@@ -7,33 +7,36 @@
|
||||
*/
|
||||
package org.dspace.importer.external.metadatamapping.contributor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.apache.axiom.om.OMAttribute;
|
||||
import org.apache.axiom.om.OMElement;
|
||||
import org.apache.axiom.om.OMText;
|
||||
import org.apache.axiom.om.xpath.AXIOMXPath;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.importer.external.metadatamapping.MetadataFieldConfig;
|
||||
import org.dspace.importer.external.metadatamapping.MetadataFieldMapping;
|
||||
import org.dspace.importer.external.metadatamapping.MetadatumDTO;
|
||||
import org.jaxen.JaxenException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.jdom2.Attribute;
|
||||
import org.jdom2.Element;
|
||||
import org.jdom2.Namespace;
|
||||
import org.jdom2.Text;
|
||||
import org.jdom2.filter.Filters;
|
||||
import org.jdom2.xpath.XPathExpression;
|
||||
import org.jdom2.xpath.XPathFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
* Metadata contributor that takes an axiom OMElement and turns it into a metadatum
|
||||
* Metadata contributor that takes a JDOM Element and turns it into a metadatum
|
||||
*
|
||||
* @author Roeland Dillen (roeland at atmire dot com)
|
||||
*/
|
||||
public class SimpleXpathMetadatumContributor implements MetadataContributor<OMElement> {
|
||||
public class SimpleXpathMetadatumContributor implements MetadataContributor<Element> {
|
||||
private MetadataFieldConfig field;
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(SimpleXpathMetadatumContributor.class);
|
||||
private static final Logger log
|
||||
= org.apache.logging.log4j.LogManager.getLogger();
|
||||
|
||||
/**
|
||||
* Return prefixToNamespaceMapping
|
||||
@@ -44,14 +47,14 @@ public class SimpleXpathMetadatumContributor implements MetadataContributor<OMEl
|
||||
return prefixToNamespaceMapping;
|
||||
}
|
||||
|
||||
private MetadataFieldMapping<OMElement, MetadataContributor<OMElement>> metadataFieldMapping;
|
||||
private MetadataFieldMapping<Element, MetadataContributor<Element>> metadataFieldMapping;
|
||||
|
||||
/**
|
||||
* Return metadataFieldMapping
|
||||
*
|
||||
* @return MetadataFieldMapping
|
||||
*/
|
||||
public MetadataFieldMapping<OMElement, MetadataContributor<OMElement>> getMetadataFieldMapping() {
|
||||
public MetadataFieldMapping<Element, MetadataContributor<Element>> getMetadataFieldMapping() {
|
||||
return metadataFieldMapping;
|
||||
}
|
||||
|
||||
@@ -62,7 +65,7 @@ public class SimpleXpathMetadatumContributor implements MetadataContributor<OMEl
|
||||
*/
|
||||
@Override
|
||||
public void setMetadataFieldMapping(
|
||||
MetadataFieldMapping<OMElement, MetadataContributor<OMElement>> metadataFieldMapping) {
|
||||
MetadataFieldMapping<Element, MetadataContributor<Element>> metadataFieldMapping) {
|
||||
this.metadataFieldMapping = metadataFieldMapping;
|
||||
}
|
||||
|
||||
@@ -140,36 +143,35 @@ public class SimpleXpathMetadatumContributor implements MetadataContributor<OMEl
|
||||
* Depending on the retrieved node (using the query), different types of values will be added to the MetadatumDTO
|
||||
* list
|
||||
*
|
||||
* @param t A class to retrieve metadata from.
|
||||
* @param t An element to retrieve metadata from.
|
||||
* @return a collection of import records. Only the identifier of the found records may be put in the record.
|
||||
*/
|
||||
@Override
|
||||
public Collection<MetadatumDTO> contributeMetadata(OMElement t) {
|
||||
public Collection<MetadatumDTO> contributeMetadata(Element t) {
|
||||
List<MetadatumDTO> values = new LinkedList<>();
|
||||
try {
|
||||
AXIOMXPath xpath = new AXIOMXPath(query);
|
||||
for (String ns : prefixToNamespaceMapping.keySet()) {
|
||||
xpath.addNamespace(prefixToNamespaceMapping.get(ns), ns);
|
||||
}
|
||||
List<Object> nodes = xpath.selectNodes(t);
|
||||
for (Object el : nodes) {
|
||||
if (el instanceof OMElement) {
|
||||
values.add(metadataFieldMapping.toDCValue(field, ((OMElement) el).getText()));
|
||||
} else if (el instanceof OMAttribute) {
|
||||
values.add(metadataFieldMapping.toDCValue(field, ((OMAttribute) el).getAttributeValue()));
|
||||
} else if (el instanceof String) {
|
||||
values.add(metadataFieldMapping.toDCValue(field, (String) el));
|
||||
} else if (el instanceof OMText) {
|
||||
values.add(metadataFieldMapping.toDCValue(field, ((OMText) el).getText()));
|
||||
} else {
|
||||
log.error("node of type: " + el.getClass());
|
||||
}
|
||||
}
|
||||
return values;
|
||||
} catch (JaxenException e) {
|
||||
log.error(query, e);
|
||||
throw new RuntimeException(e);
|
||||
|
||||
List<Namespace> namespaces = new ArrayList<>();
|
||||
for (String ns : prefixToNamespaceMapping.keySet()) {
|
||||
namespaces.add(Namespace.getNamespace(prefixToNamespaceMapping.get(ns), ns));
|
||||
}
|
||||
|
||||
XPathExpression<Object> xpath =
|
||||
XPathFactory.instance().compile(query, Filters.fpassthrough(), null, namespaces);
|
||||
|
||||
List<Object> nodes = xpath.evaluate(t);
|
||||
for (Object el : nodes) {
|
||||
if (el instanceof Element) {
|
||||
values.add(metadataFieldMapping.toDCValue(field, ((Element) el).getText()));
|
||||
} else if (el instanceof Attribute) {
|
||||
values.add(metadataFieldMapping.toDCValue(field, ((Attribute) el).getValue()));
|
||||
} else if (el instanceof String) {
|
||||
values.add(metadataFieldMapping.toDCValue(field, (String) el));
|
||||
} else if (el instanceof Text) {
|
||||
values.add(metadataFieldMapping.toDCValue(field, ((Text) el).getText()));
|
||||
} else {
|
||||
log.error("Encountered unsupported XML node of type: {}. Skipped that node.", el.getClass());
|
||||
}
|
||||
}
|
||||
return values;
|
||||
}
|
||||
}
|
||||
|
@@ -25,10 +25,6 @@ import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
import com.google.common.io.CharStreams;
|
||||
import org.apache.axiom.om.OMElement;
|
||||
import org.apache.axiom.om.OMXMLBuilderFactory;
|
||||
import org.apache.axiom.om.OMXMLParserWrapper;
|
||||
import org.apache.axiom.om.xpath.AXIOMXPath;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.importer.external.datamodel.ImportRecord;
|
||||
import org.dspace.importer.external.datamodel.Query;
|
||||
@@ -38,7 +34,13 @@ import org.dspace.importer.external.exception.MetadataSourceException;
|
||||
import org.dspace.importer.external.service.AbstractImportMetadataSourceService;
|
||||
import org.dspace.importer.external.service.components.FileSource;
|
||||
import org.dspace.importer.external.service.components.QuerySource;
|
||||
import org.jaxen.JaxenException;
|
||||
import org.jdom2.Document;
|
||||
import org.jdom2.Element;
|
||||
import org.jdom2.JDOMException;
|
||||
import org.jdom2.filter.Filters;
|
||||
import org.jdom2.input.SAXBuilder;
|
||||
import org.jdom2.xpath.XPathExpression;
|
||||
import org.jdom2.xpath.XPathFactory;
|
||||
|
||||
/**
|
||||
* Implements a data source for querying PubMed Central
|
||||
@@ -46,7 +48,7 @@ import org.jaxen.JaxenException;
|
||||
* @author Roeland Dillen (roeland at atmire dot com)
|
||||
* @author Pasquale Cavallo (pasquale.cavallo at 4science dot it)
|
||||
*/
|
||||
public class PubmedImportMetadataSourceServiceImpl extends AbstractImportMetadataSourceService<OMElement>
|
||||
public class PubmedImportMetadataSourceServiceImpl extends AbstractImportMetadataSourceService<Element>
|
||||
implements QuerySource, FileSource {
|
||||
|
||||
private String baseAddress;
|
||||
@@ -59,7 +61,7 @@ public class PubmedImportMetadataSourceServiceImpl extends AbstractImportMetadat
|
||||
/**
|
||||
* Set the file extensions supported by this metadata service
|
||||
*
|
||||
* @param supportedExtensionsthe file extensions (xml,txt,...) supported by this service
|
||||
* @param supportedExtensions the file extensions (xml,txt,...) supported by this service
|
||||
*/
|
||||
public void setSupportedExtensions(List<String> supportedExtensions) {
|
||||
this.supportedExtensions = supportedExtensions;
|
||||
@@ -243,17 +245,21 @@ public class PubmedImportMetadataSourceServiceImpl extends AbstractImportMetadat
|
||||
|
||||
|
||||
private String getSingleElementValue(String src, String elementName) {
|
||||
OMXMLParserWrapper records = OMXMLBuilderFactory.createOMBuilder(new StringReader(src));
|
||||
OMElement element = records.getDocumentElement();
|
||||
AXIOMXPath xpath = null;
|
||||
String value = null;
|
||||
|
||||
try {
|
||||
xpath = new AXIOMXPath("//" + elementName);
|
||||
List<OMElement> recordsList = xpath.selectNodes(element);
|
||||
if (!recordsList.isEmpty()) {
|
||||
value = recordsList.get(0).getText();
|
||||
SAXBuilder saxBuilder = new SAXBuilder();
|
||||
Document document = saxBuilder.build(new StringReader(src));
|
||||
Element root = document.getRootElement();
|
||||
|
||||
XPathExpression<Element> xpath =
|
||||
XPathFactory.instance().compile("//" + elementName, Filters.element());
|
||||
|
||||
Element record = xpath.evaluateFirst(root);
|
||||
if (record != null) {
|
||||
value = record.getText();
|
||||
}
|
||||
} catch (JaxenException e) {
|
||||
} catch (JDOMException | IOException e) {
|
||||
value = null;
|
||||
}
|
||||
return value;
|
||||
@@ -314,9 +320,9 @@ public class PubmedImportMetadataSourceServiceImpl extends AbstractImportMetadat
|
||||
invocationBuilder = getRecordsTarget.request(MediaType.TEXT_PLAIN_TYPE);
|
||||
response = invocationBuilder.get();
|
||||
|
||||
List<OMElement> omElements = splitToRecords(response.readEntity(String.class));
|
||||
List<Element> elements = splitToRecords(response.readEntity(String.class));
|
||||
|
||||
for (OMElement record : omElements) {
|
||||
for (Element record : elements) {
|
||||
records.add(transformSourceRecords(record));
|
||||
}
|
||||
|
||||
@@ -324,15 +330,18 @@ public class PubmedImportMetadataSourceServiceImpl extends AbstractImportMetadat
|
||||
}
|
||||
}
|
||||
|
||||
private List<OMElement> splitToRecords(String recordsSrc) {
|
||||
OMXMLParserWrapper records = OMXMLBuilderFactory.createOMBuilder(new StringReader(recordsSrc));
|
||||
OMElement element = records.getDocumentElement();
|
||||
AXIOMXPath xpath = null;
|
||||
private List<Element> splitToRecords(String recordsSrc) {
|
||||
try {
|
||||
xpath = new AXIOMXPath("//PubmedArticle");
|
||||
List<OMElement> recordsList = xpath.selectNodes(element);
|
||||
SAXBuilder saxBuilder = new SAXBuilder();
|
||||
Document document = saxBuilder.build(new StringReader(recordsSrc));
|
||||
Element root = document.getRootElement();
|
||||
|
||||
XPathExpression<Element> xpath =
|
||||
XPathFactory.instance().compile("//PubmedArticle", Filters.element());
|
||||
|
||||
List<Element> recordsList = xpath.evaluate(root);
|
||||
return recordsList;
|
||||
} catch (JaxenException e) {
|
||||
} catch (JDOMException | IOException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -362,13 +371,13 @@ public class PubmedImportMetadataSourceServiceImpl extends AbstractImportMetadat
|
||||
|
||||
Response response = invocationBuilder.get();
|
||||
|
||||
List<OMElement> omElements = splitToRecords(response.readEntity(String.class));
|
||||
List<Element> elements = splitToRecords(response.readEntity(String.class));
|
||||
|
||||
if (omElements.size() == 0) {
|
||||
if (elements.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return transformSourceRecords(omElements.get(0));
|
||||
return transformSourceRecords(elements.get(0));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -441,8 +450,8 @@ public class PubmedImportMetadataSourceServiceImpl extends AbstractImportMetadat
|
||||
|
||||
private List<ImportRecord> parseXMLString(String xml) {
|
||||
List<ImportRecord> records = new LinkedList<ImportRecord>();
|
||||
List<OMElement> omElements = splitToRecords(xml);
|
||||
for (OMElement record : omElements) {
|
||||
List<Element> elements = splitToRecords(xml);
|
||||
for (Element record : elements) {
|
||||
records.add(transformSourceRecords(record));
|
||||
}
|
||||
return records;
|
||||
|
@@ -10,7 +10,7 @@ package org.dspace.license;
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jdom.Document;
|
||||
import org.jdom2.Document;
|
||||
|
||||
/**
|
||||
* Service interface class for the Creative commons license connector service.
|
||||
|
@@ -32,13 +32,14 @@ import org.apache.http.impl.client.HttpClientBuilder;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.jaxen.JaxenException;
|
||||
import org.jaxen.jdom.JDOMXPath;
|
||||
import org.jdom.Attribute;
|
||||
import org.jdom.Document;
|
||||
import org.jdom.Element;
|
||||
import org.jdom.JDOMException;
|
||||
import org.jdom.input.SAXBuilder;
|
||||
import org.jdom2.Attribute;
|
||||
import org.jdom2.Document;
|
||||
import org.jdom2.Element;
|
||||
import org.jdom2.JDOMException;
|
||||
import org.jdom2.filter.Filters;
|
||||
import org.jdom2.input.SAXBuilder;
|
||||
import org.jdom2.xpath.XPathExpression;
|
||||
import org.jdom2.xpath.XPathFactory;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.xml.sax.InputSource;
|
||||
@@ -96,7 +97,7 @@ public class CCLicenseConnectorServiceImpl implements CCLicenseConnectorService,
|
||||
List<String> licenses;
|
||||
try (CloseableHttpResponse response = client.execute(httpGet)) {
|
||||
licenses = retrieveLicenses(response);
|
||||
} catch (JDOMException | JaxenException | IOException e) {
|
||||
} catch (JDOMException | IOException e) {
|
||||
log.error("Error while retrieving the license details using url: " + uri, e);
|
||||
licenses = Collections.emptyList();
|
||||
}
|
||||
@@ -110,7 +111,7 @@ public class CCLicenseConnectorServiceImpl implements CCLicenseConnectorService,
|
||||
try (CloseableHttpResponse response = client.execute(licenseHttpGet)) {
|
||||
CCLicense ccLicense = retrieveLicenseObject(license, response);
|
||||
ccLicenses.put(ccLicense.getLicenseId(), ccLicense);
|
||||
} catch (JaxenException | JDOMException | IOException e) {
|
||||
} catch (JDOMException | IOException e) {
|
||||
log.error("Error while retrieving the license details using url: " + licenseUri, e);
|
||||
}
|
||||
}
|
||||
@@ -125,25 +126,23 @@ public class CCLicenseConnectorServiceImpl implements CCLicenseConnectorService,
|
||||
* @param response The response from the API
|
||||
* @return a list of license identifiers for which details need to be retrieved
|
||||
* @throws IOException
|
||||
* @throws JaxenException
|
||||
* @throws JDOMException
|
||||
*/
|
||||
private List<String> retrieveLicenses(CloseableHttpResponse response)
|
||||
throws IOException, JaxenException, JDOMException {
|
||||
throws IOException, JDOMException {
|
||||
|
||||
List<String> domains = new LinkedList<>();
|
||||
String[] excludedLicenses = configurationService.getArrayProperty("cc.license.classfilter");
|
||||
|
||||
|
||||
String responseString = EntityUtils.toString(response.getEntity());
|
||||
JDOMXPath licenseClassXpath = new JDOMXPath("//licenses/license");
|
||||
|
||||
XPathExpression<Element> licenseClassXpath =
|
||||
XPathFactory.instance().compile("//licenses/license", Filters.element());
|
||||
|
||||
try (StringReader stringReader = new StringReader(responseString)) {
|
||||
InputSource is = new InputSource(stringReader);
|
||||
org.jdom.Document classDoc = this.parser.build(is);
|
||||
org.jdom2.Document classDoc = this.parser.build(is);
|
||||
|
||||
List<Element> elements = licenseClassXpath.selectNodes(classDoc);
|
||||
List<Element> elements = licenseClassXpath.evaluate(classDoc);
|
||||
for (Element element : elements) {
|
||||
String licenseId = getSingleNodeValue(element, "@id");
|
||||
if (StringUtils.isNotBlank(licenseId) && !ArrayUtils.contains(excludedLicenses, licenseId)) {
|
||||
@@ -163,30 +162,29 @@ public class CCLicenseConnectorServiceImpl implements CCLicenseConnectorService,
|
||||
* @param response for a specific CC License response
|
||||
* @return the corresponding CC License Object
|
||||
* @throws IOException
|
||||
* @throws JaxenException
|
||||
* @throws JDOMException
|
||||
*/
|
||||
private CCLicense retrieveLicenseObject(final String licenseId, CloseableHttpResponse response)
|
||||
throws IOException, JaxenException, JDOMException {
|
||||
throws IOException, JDOMException {
|
||||
|
||||
String responseString = EntityUtils.toString(response.getEntity());
|
||||
|
||||
|
||||
JDOMXPath licenseClassXpath = new JDOMXPath("//licenseclass");
|
||||
JDOMXPath licenseFieldXpath = new JDOMXPath("field");
|
||||
|
||||
XPathExpression<Object> licenseClassXpath =
|
||||
XPathFactory.instance().compile("//licenseclass", Filters.fpassthrough());
|
||||
XPathExpression<Element> licenseFieldXpath =
|
||||
XPathFactory.instance().compile("field", Filters.element());
|
||||
|
||||
try (StringReader stringReader = new StringReader(responseString)) {
|
||||
InputSource is = new InputSource(stringReader);
|
||||
|
||||
org.jdom.Document classDoc = this.parser.build(is);
|
||||
org.jdom2.Document classDoc = this.parser.build(is);
|
||||
|
||||
Object element = licenseClassXpath.selectSingleNode(classDoc);
|
||||
Object element = licenseClassXpath.evaluateFirst(classDoc);
|
||||
String licenseLabel = getSingleNodeValue(element, "label");
|
||||
|
||||
List<CCLicenseField> ccLicenseFields = new LinkedList<>();
|
||||
|
||||
List<Element> licenseFields = licenseFieldXpath.selectNodes(element);
|
||||
List<Element> licenseFields = licenseFieldXpath.evaluate(element);
|
||||
for (Element licenseField : licenseFields) {
|
||||
CCLicenseField ccLicenseField = parseLicenseField(licenseField);
|
||||
ccLicenseFields.add(ccLicenseField);
|
||||
@@ -196,13 +194,14 @@ public class CCLicenseConnectorServiceImpl implements CCLicenseConnectorService,
|
||||
}
|
||||
}
|
||||
|
||||
private CCLicenseField parseLicenseField(final Element licenseField) throws JaxenException {
|
||||
private CCLicenseField parseLicenseField(final Element licenseField) {
|
||||
String id = getSingleNodeValue(licenseField, "@id");
|
||||
String label = getSingleNodeValue(licenseField, "label");
|
||||
String description = getSingleNodeValue(licenseField, "description");
|
||||
|
||||
JDOMXPath enumXpath = new JDOMXPath("enum");
|
||||
List<Element> enums = enumXpath.selectNodes(licenseField);
|
||||
XPathExpression<Element> enumXpath =
|
||||
XPathFactory.instance().compile("enum", Filters.element());
|
||||
List<Element> enums = enumXpath.evaluate(licenseField);
|
||||
|
||||
List<CCLicenseFieldEnum> ccLicenseFieldEnumList = new LinkedList<>();
|
||||
|
||||
@@ -215,7 +214,7 @@ public class CCLicenseConnectorServiceImpl implements CCLicenseConnectorService,
|
||||
|
||||
}
|
||||
|
||||
private CCLicenseFieldEnum parseEnum(final Element enumElement) throws JaxenException {
|
||||
private CCLicenseFieldEnum parseEnum(final Element enumElement) {
|
||||
String id = getSingleNodeValue(enumElement, "@id");
|
||||
String label = getSingleNodeValue(enumElement, "label");
|
||||
String description = getSingleNodeValue(enumElement, "description");
|
||||
@@ -236,9 +235,10 @@ public class CCLicenseConnectorServiceImpl implements CCLicenseConnectorService,
|
||||
}
|
||||
}
|
||||
|
||||
private String getSingleNodeValue(final Object t, String query) throws JaxenException {
|
||||
JDOMXPath xpath = new JDOMXPath(query);
|
||||
Object singleNode = xpath.selectSingleNode(t);
|
||||
private String getSingleNodeValue(final Object t, String query) {
|
||||
XPathExpression xpath =
|
||||
XPathFactory.instance().compile(query, Filters.fpassthrough());
|
||||
Object singleNode = xpath.evaluateFirst(t);
|
||||
|
||||
return getNodeValue(singleNode);
|
||||
}
|
||||
@@ -273,7 +273,7 @@ public class CCLicenseConnectorServiceImpl implements CCLicenseConnectorService,
|
||||
|
||||
try (CloseableHttpResponse response = client.execute(httpPost)) {
|
||||
return retrieveLicenseUri(response);
|
||||
} catch (JDOMException | JaxenException | IOException e) {
|
||||
} catch (JDOMException | IOException e) {
|
||||
log.error("Error while retrieving the license uri for license : " + licenseId + " with answers "
|
||||
+ answerMap.toString(), e);
|
||||
}
|
||||
@@ -286,21 +286,20 @@ public class CCLicenseConnectorServiceImpl implements CCLicenseConnectorService,
|
||||
* @param response for a specific CC License URI response
|
||||
* @return the corresponding CC License URI as a string
|
||||
* @throws IOException
|
||||
* @throws JaxenException
|
||||
* @throws JDOMException
|
||||
*/
|
||||
private String retrieveLicenseUri(final CloseableHttpResponse response)
|
||||
throws IOException, JaxenException, JDOMException {
|
||||
throws IOException, JDOMException {
|
||||
|
||||
String responseString = EntityUtils.toString(response.getEntity());
|
||||
JDOMXPath licenseClassXpath = new JDOMXPath("//result/license-uri");
|
||||
|
||||
XPathExpression<Object> licenseClassXpath =
|
||||
XPathFactory.instance().compile("//result/license-uri", Filters.fpassthrough());
|
||||
|
||||
try (StringReader stringReader = new StringReader(responseString)) {
|
||||
InputSource is = new InputSource(stringReader);
|
||||
org.jdom.Document classDoc = this.parser.build(is);
|
||||
org.jdom2.Document classDoc = this.parser.build(is);
|
||||
|
||||
Object node = licenseClassXpath.selectSingleNode(classDoc);
|
||||
Object node = licenseClassXpath.evaluateFirst(classDoc);
|
||||
String nodeValue = getNodeValue(node);
|
||||
|
||||
if (StringUtils.isNotBlank(nodeValue)) {
|
||||
@@ -364,12 +363,7 @@ public class CCLicenseConnectorServiceImpl implements CCLicenseConnectorService,
|
||||
* @return the license name
|
||||
*/
|
||||
public String retrieveLicenseName(final Document doc) {
|
||||
try {
|
||||
return getSingleNodeValue(doc, "//result/license-name");
|
||||
} catch (JaxenException e) {
|
||||
log.error("Error while retrieving the license name from the license document", e);
|
||||
}
|
||||
return null;
|
||||
return getSingleNodeValue(doc, "//result/license-name");
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -40,8 +40,8 @@ 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.jdom2.Document;
|
||||
import org.jdom2.transform.JDOMSource;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
|
@@ -18,7 +18,7 @@ import org.dspace.content.Bitstream;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.license.CCLicense;
|
||||
import org.jdom.Document;
|
||||
import org.jdom2.Document;
|
||||
|
||||
/**
|
||||
* Service interface class for the Creative commons licensing.
|
||||
|
@@ -286,51 +286,54 @@ public class RDFConsumer implements Consumer {
|
||||
@Override
|
||||
public void end(Context ctx) throws Exception {
|
||||
log.debug("Started processing of queued events.");
|
||||
// create a new context, to be sure to work as anonymous user
|
||||
// we don't want to store private data in a triplestore with public
|
||||
// SPARQL endpoint.
|
||||
ctx = new Context(Context.Mode.READ_ONLY);
|
||||
if (toDelete == null) {
|
||||
log.debug("Deletion queue does not exists, creating empty queue.");
|
||||
this.toDelete = new LinkedList<>();
|
||||
}
|
||||
if (toConvert != null) {
|
||||
log.debug("Starting conversion of DSpaceObjects.");
|
||||
// store the context mode, set context read only for performance reasons, and restore the old mode
|
||||
Context.Mode oldMode = ctx.getCurrentMode();
|
||||
try {
|
||||
ctx.setMode(Context.Mode.READ_ONLY);
|
||||
if (toDelete == null) {
|
||||
log.debug("Deletion queue does not exists, creating empty queue.");
|
||||
this.toDelete = new LinkedList<>();
|
||||
}
|
||||
if (toConvert != null) {
|
||||
log.debug("Starting conversion of DSpaceObjects.");
|
||||
while (true) {
|
||||
DSOIdentifier id;
|
||||
try {
|
||||
id = toConvert.removeFirst();
|
||||
} catch (NoSuchElementException ex) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (toDelete.contains(id)) {
|
||||
log.debug("Skipping " + Constants.typeText[id.type] + " "
|
||||
+ id.id.toString() + " as it is marked for "
|
||||
+ "deletion as well.");
|
||||
continue;
|
||||
}
|
||||
log.debug("Converting " + Constants.typeText[id.type] + " "
|
||||
+ id.id.toString() + ".");
|
||||
convert(ctx, id);
|
||||
}
|
||||
log.debug("Conversion ended.");
|
||||
}
|
||||
log.debug("Starting to delete data from the triple store...");
|
||||
while (true) {
|
||||
DSOIdentifier id;
|
||||
try {
|
||||
id = toConvert.removeFirst();
|
||||
id = toDelete.removeFirst();
|
||||
} catch (NoSuchElementException ex) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (toDelete.contains(id)) {
|
||||
log.debug("Skipping " + Constants.typeText[id.type] + " "
|
||||
+ id.id.toString() + " as it is marked for "
|
||||
+ "deletion as well.");
|
||||
continue;
|
||||
}
|
||||
log.debug("Converting " + Constants.typeText[id.type] + " "
|
||||
log.debug("Going to delete data from " +
|
||||
Constants.typeText[id.type] + " "
|
||||
+ id.id.toString() + ".");
|
||||
convert(ctx, id);
|
||||
delete(ctx, id);
|
||||
}
|
||||
log.debug("Conversion ended.");
|
||||
} finally {
|
||||
// restore context mode
|
||||
ctx.setMode(oldMode);
|
||||
}
|
||||
log.debug("Starting to delete data from the triple store...");
|
||||
while (true) {
|
||||
DSOIdentifier id;
|
||||
try {
|
||||
id = toDelete.removeFirst();
|
||||
} catch (NoSuchElementException ex) {
|
||||
break;
|
||||
}
|
||||
|
||||
log.debug("Going to delete data from " +
|
||||
Constants.typeText[id.type] + " "
|
||||
+ id.id.toString() + ".");
|
||||
delete(ctx, id);
|
||||
}
|
||||
ctx.abort();
|
||||
log.debug("Deletion finished.");
|
||||
}
|
||||
|
||||
|
@@ -1,70 +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/
|
||||
*/
|
||||
package org.dspace.statistics;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
/**
|
||||
* A neutral data object to hold data for statistics.
|
||||
*/
|
||||
public class DataTermsFacet {
|
||||
private List<TermsFacet> terms;
|
||||
|
||||
public DataTermsFacet() {
|
||||
terms = new ArrayList<TermsFacet>();
|
||||
}
|
||||
|
||||
public void addTermFacet(TermsFacet termsFacet) {
|
||||
terms.add(termsFacet);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render this data object into JSON format.
|
||||
*
|
||||
* An example of the output could be of the format:
|
||||
* [{"term":"247166","count":10},{"term":"247168","count":6}]
|
||||
*
|
||||
* @return JSON-formatted data.
|
||||
*/
|
||||
public String toJson() {
|
||||
Gson gson = new Gson();
|
||||
return gson.toJson(terms);
|
||||
}
|
||||
|
||||
|
||||
public static class TermsFacet {
|
||||
private String term;
|
||||
private Integer count;
|
||||
|
||||
public TermsFacet(String term, Integer count) {
|
||||
setTerm(term);
|
||||
setCount(count);
|
||||
}
|
||||
|
||||
public String getTerm() {
|
||||
return term;
|
||||
}
|
||||
|
||||
public void setTerm(String term) {
|
||||
this.term = term;
|
||||
}
|
||||
|
||||
public Integer getCount() {
|
||||
return count;
|
||||
}
|
||||
|
||||
public void setCount(Integer count) {
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user