mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-16 14:33:09 +00:00
Remove Xalan direct dependency. Migrate code to Javax.xml.xpath parsing tools
This commit is contained in:
@@ -530,14 +530,6 @@
|
|||||||
<groupId>org.apache.pdfbox</groupId>
|
<groupId>org.apache.pdfbox</groupId>
|
||||||
<artifactId>fontbox</artifactId>
|
<artifactId>fontbox</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>xalan</groupId>
|
|
||||||
<artifactId>xalan</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>xerces</groupId>
|
|
||||||
<artifactId>xercesImpl</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.ibm.icu</groupId>
|
<groupId>com.ibm.icu</groupId>
|
||||||
<artifactId>icu4j</artifactId>
|
<artifactId>icu4j</artifactId>
|
||||||
|
@@ -11,13 +11,16 @@ import java.io.IOException;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
import javax.xml.transform.TransformerException;
|
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.CommandLine;
|
||||||
import org.apache.commons.cli.CommandLineParser;
|
import org.apache.commons.cli.CommandLineParser;
|
||||||
import org.apache.commons.cli.DefaultParser;
|
import org.apache.commons.cli.DefaultParser;
|
||||||
import org.apache.commons.cli.Options;
|
import org.apache.commons.cli.Options;
|
||||||
import org.apache.commons.cli.ParseException;
|
import org.apache.commons.cli.ParseException;
|
||||||
import org.apache.xpath.XPathAPI;
|
|
||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
import org.dspace.content.MetadataField;
|
import org.dspace.content.MetadataField;
|
||||||
import org.dspace.content.MetadataSchema;
|
import org.dspace.content.MetadataSchema;
|
||||||
@@ -90,7 +93,7 @@ public class MetadataImporter {
|
|||||||
public static void main(String[] args)
|
public static void main(String[] args)
|
||||||
throws ParseException, SQLException, IOException, TransformerException,
|
throws ParseException, SQLException, IOException, TransformerException,
|
||||||
ParserConfigurationException, AuthorizeException, SAXException,
|
ParserConfigurationException, AuthorizeException, SAXException,
|
||||||
NonUniqueMetadataException, RegistryImportException {
|
NonUniqueMetadataException, RegistryImportException, XPathExpressionException {
|
||||||
|
|
||||||
// create an options object and populate it
|
// create an options object and populate it
|
||||||
CommandLineParser parser = new DefaultParser();
|
CommandLineParser parser = new DefaultParser();
|
||||||
@@ -124,8 +127,8 @@ public class MetadataImporter {
|
|||||||
* @throws RegistryImportException if import fails
|
* @throws RegistryImportException if import fails
|
||||||
*/
|
*/
|
||||||
public static void loadRegistry(String file, boolean forceUpdate)
|
public static void loadRegistry(String file, boolean forceUpdate)
|
||||||
throws SQLException, IOException, TransformerException, ParserConfigurationException,
|
throws SQLException, IOException, TransformerException, ParserConfigurationException, AuthorizeException,
|
||||||
AuthorizeException, SAXException, NonUniqueMetadataException, RegistryImportException {
|
SAXException, NonUniqueMetadataException, RegistryImportException, XPathExpressionException {
|
||||||
Context context = null;
|
Context context = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -137,7 +140,9 @@ public class MetadataImporter {
|
|||||||
Document document = RegistryImporter.loadXML(file);
|
Document document = RegistryImporter.loadXML(file);
|
||||||
|
|
||||||
// Get the nodes corresponding to types
|
// 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
|
// Add each one as a new format to the registry
|
||||||
for (int i = 0; i < schemaNodes.getLength(); i++) {
|
for (int i = 0; i < schemaNodes.getLength(); i++) {
|
||||||
@@ -146,7 +151,8 @@ public class MetadataImporter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get the nodes corresponding to types
|
// 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
|
// Add each one as a new format to the registry
|
||||||
for (int i = 0; i < typeNodes.getLength(); i++) {
|
for (int i = 0; i < typeNodes.getLength(); i++) {
|
||||||
@@ -178,8 +184,8 @@ public class MetadataImporter {
|
|||||||
* @throws RegistryImportException if import fails
|
* @throws RegistryImportException if import fails
|
||||||
*/
|
*/
|
||||||
private static void loadSchema(Context context, Node node, boolean updateExisting)
|
private static void loadSchema(Context context, Node node, boolean updateExisting)
|
||||||
throws SQLException, IOException, TransformerException,
|
throws SQLException, AuthorizeException, NonUniqueMetadataException, RegistryImportException,
|
||||||
AuthorizeException, NonUniqueMetadataException, RegistryImportException {
|
XPathExpressionException {
|
||||||
// Get the values
|
// Get the values
|
||||||
String name = RegistryImporter.getElementData(node, "name");
|
String name = RegistryImporter.getElementData(node, "name");
|
||||||
String namespace = RegistryImporter.getElementData(node, "namespace");
|
String namespace = RegistryImporter.getElementData(node, "namespace");
|
||||||
@@ -236,8 +242,8 @@ public class MetadataImporter {
|
|||||||
* @throws RegistryImportException if import fails
|
* @throws RegistryImportException if import fails
|
||||||
*/
|
*/
|
||||||
private static void loadType(Context context, Node node)
|
private static void loadType(Context context, Node node)
|
||||||
throws SQLException, IOException, TransformerException,
|
throws SQLException, IOException, AuthorizeException, NonUniqueMetadataException, RegistryImportException,
|
||||||
AuthorizeException, NonUniqueMetadataException, RegistryImportException {
|
XPathExpressionException {
|
||||||
// Get the values
|
// Get the values
|
||||||
String schema = RegistryImporter.getElementData(node, "schema");
|
String schema = RegistryImporter.getElementData(node, "schema");
|
||||||
String element = RegistryImporter.getElementData(node, "element");
|
String element = RegistryImporter.getElementData(node, "element");
|
||||||
|
@@ -13,8 +13,11 @@ import javax.xml.parsers.DocumentBuilder;
|
|||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
import javax.xml.transform.TransformerException;
|
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.Document;
|
||||||
import org.w3c.dom.Node;
|
import org.w3c.dom.Node;
|
||||||
import org.w3c.dom.NodeList;
|
import org.w3c.dom.NodeList;
|
||||||
@@ -72,9 +75,10 @@ public class RegistryImporter {
|
|||||||
* @throws TransformerException if error
|
* @throws TransformerException if error
|
||||||
*/
|
*/
|
||||||
public static String getElementData(Node parentElement, String childName)
|
public static String getElementData(Node parentElement, String childName)
|
||||||
throws TransformerException {
|
throws XPathExpressionException {
|
||||||
// Grab the child node
|
// 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) {
|
if (childNode == null) {
|
||||||
// No child node, so no values
|
// No child node, so no values
|
||||||
@@ -115,9 +119,10 @@ public class RegistryImporter {
|
|||||||
* @throws TransformerException if error
|
* @throws TransformerException if error
|
||||||
*/
|
*/
|
||||||
public static String[] getRepeatedElementData(Node parentElement,
|
public static String[] getRepeatedElementData(Node parentElement,
|
||||||
String childName) throws TransformerException {
|
String childName) throws XPathExpressionException {
|
||||||
// Grab the child node
|
// 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()];
|
String[] data = new String[childNodes.getLength()];
|
||||||
|
|
||||||
|
@@ -16,9 +16,12 @@ import javax.xml.parsers.DocumentBuilder;
|
|||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
import javax.xml.transform.TransformerException;
|
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.logging.log4j.Logger;
|
||||||
import org.apache.xpath.XPathAPI;
|
|
||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
import org.dspace.content.BitstreamFormat;
|
import org.dspace.content.BitstreamFormat;
|
||||||
import org.dspace.content.factory.ContentServiceFactory;
|
import org.dspace.content.factory.ContentServiceFactory;
|
||||||
@@ -122,12 +125,13 @@ public class RegistryLoader {
|
|||||||
*/
|
*/
|
||||||
public static void loadBitstreamFormats(Context context, String filename)
|
public static void loadBitstreamFormats(Context context, String filename)
|
||||||
throws SQLException, IOException, ParserConfigurationException,
|
throws SQLException, IOException, ParserConfigurationException,
|
||||||
SAXException, TransformerException, AuthorizeException {
|
SAXException, TransformerException, AuthorizeException, XPathExpressionException {
|
||||||
Document document = loadXML(filename);
|
Document document = loadXML(filename);
|
||||||
|
|
||||||
// Get the nodes corresponding to formats
|
// Get the nodes corresponding to formats
|
||||||
NodeList typeNodes = XPathAPI.selectNodeList(document,
|
XPath xPath = XPathFactory.newInstance().newXPath();
|
||||||
"dspace-bitstream-types/bitstream-type");
|
NodeList typeNodes = (NodeList) xPath.compile("dspace-bitstream-types/bitstream-type")
|
||||||
|
.evaluate(document, XPathConstants.NODESET);
|
||||||
|
|
||||||
// Add each one as a new format to the registry
|
// Add each one as a new format to the registry
|
||||||
for (int i = 0; i < typeNodes.getLength(); i++) {
|
for (int i = 0; i < typeNodes.getLength(); i++) {
|
||||||
@@ -151,8 +155,7 @@ public class RegistryLoader {
|
|||||||
* @throws AuthorizeException if authorization error
|
* @throws AuthorizeException if authorization error
|
||||||
*/
|
*/
|
||||||
private static void loadFormat(Context context, Node node)
|
private static void loadFormat(Context context, Node node)
|
||||||
throws SQLException, IOException, TransformerException,
|
throws SQLException, AuthorizeException, XPathExpressionException {
|
||||||
AuthorizeException {
|
|
||||||
// Get the values
|
// Get the values
|
||||||
String mimeType = getElementData(node, "mimetype");
|
String mimeType = getElementData(node, "mimetype");
|
||||||
String shortDesc = getElementData(node, "short_description");
|
String shortDesc = getElementData(node, "short_description");
|
||||||
@@ -231,9 +234,10 @@ public class RegistryLoader {
|
|||||||
* @throws TransformerException if transformer error
|
* @throws TransformerException if transformer error
|
||||||
*/
|
*/
|
||||||
private static String getElementData(Node parentElement, String childName)
|
private static String getElementData(Node parentElement, String childName)
|
||||||
throws TransformerException {
|
throws XPathExpressionException {
|
||||||
// Grab the child node
|
// 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) {
|
if (childNode == null) {
|
||||||
// No child node, so no values
|
// No child node, so no values
|
||||||
@@ -274,9 +278,10 @@ public class RegistryLoader {
|
|||||||
* @throws TransformerException if transformer error
|
* @throws TransformerException if transformer error
|
||||||
*/
|
*/
|
||||||
private static String[] getRepeatedElementData(Node parentElement,
|
private static String[] getRepeatedElementData(Node parentElement,
|
||||||
String childName) throws TransformerException {
|
String childName) throws XPathExpressionException {
|
||||||
// Grab the child node
|
// 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()];
|
String[] data = new String[childNodes.getLength()];
|
||||||
|
|
||||||
|
@@ -30,6 +30,10 @@ import javax.xml.parsers.DocumentBuilder;
|
|||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
import javax.xml.transform.TransformerException;
|
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.CommandLine;
|
||||||
import org.apache.commons.cli.CommandLineParser;
|
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.Option;
|
||||||
import org.apache.commons.cli.Options;
|
import org.apache.commons.cli.Options;
|
||||||
import org.apache.commons.cli.ParseException;
|
import org.apache.commons.cli.ParseException;
|
||||||
import org.apache.xpath.XPathAPI;
|
|
||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
import org.dspace.content.Collection;
|
import org.dspace.content.Collection;
|
||||||
import org.dspace.content.Community;
|
import org.dspace.content.Community;
|
||||||
@@ -137,8 +140,8 @@ public class StructBuilder {
|
|||||||
* @throws TransformerException if the input document is invalid.
|
* @throws TransformerException if the input document is invalid.
|
||||||
*/
|
*/
|
||||||
public static void main(String[] argv)
|
public static void main(String[] argv)
|
||||||
throws ParserConfigurationException, SQLException,
|
throws ParserConfigurationException, SQLException,
|
||||||
FileNotFoundException, IOException, TransformerException {
|
IOException, TransformerException, XPathExpressionException {
|
||||||
// Define command line options.
|
// Define command line options.
|
||||||
Options options = new Options();
|
Options options = new Options();
|
||||||
|
|
||||||
@@ -240,7 +243,7 @@ public class StructBuilder {
|
|||||||
* @throws SQLException
|
* @throws SQLException
|
||||||
*/
|
*/
|
||||||
static void importStructure(Context context, InputStream input, OutputStream output)
|
static void importStructure(Context context, InputStream input, OutputStream output)
|
||||||
throws IOException, ParserConfigurationException, SQLException, TransformerException {
|
throws IOException, ParserConfigurationException, SQLException, TransformerException, XPathExpressionException {
|
||||||
|
|
||||||
// load the XML
|
// load the XML
|
||||||
Document document = null;
|
Document document = null;
|
||||||
@@ -258,13 +261,15 @@ public class StructBuilder {
|
|||||||
// is properly structured.
|
// is properly structured.
|
||||||
try {
|
try {
|
||||||
validate(document);
|
validate(document);
|
||||||
} catch (TransformerException ex) {
|
} catch (XPathExpressionException ex) {
|
||||||
System.err.format("The input document is invalid: %s%n", ex.getMessage());
|
System.err.format("The input document is invalid: %s%n", ex.getMessage());
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for 'identifier' attributes -- possibly output by this class.
|
// 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) {
|
if (identifierNodes.getLength() > 0) {
|
||||||
System.err.println("The input document has 'identifier' attributes, which will be ignored.");
|
System.err.println("The input document has 'identifier' attributes, which will be ignored.");
|
||||||
}
|
}
|
||||||
@@ -287,7 +292,8 @@ public class StructBuilder {
|
|||||||
Element[] elements = new Element[]{};
|
Element[] elements = new Element[]{};
|
||||||
try {
|
try {
|
||||||
// get the top level community list
|
// 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
|
// run the import starting with the top level communities
|
||||||
elements = handleCommunities(context, first, null);
|
elements = handleCommunities(context, first, null);
|
||||||
@@ -456,14 +462,16 @@ public class StructBuilder {
|
|||||||
* @throws TransformerException if transformer error
|
* @throws TransformerException if transformer error
|
||||||
*/
|
*/
|
||||||
private static void validate(org.w3c.dom.Document document)
|
private static void validate(org.w3c.dom.Document document)
|
||||||
throws TransformerException {
|
throws XPathExpressionException {
|
||||||
StringBuilder err = new StringBuilder();
|
StringBuilder err = new StringBuilder();
|
||||||
boolean trip = false;
|
boolean trip = false;
|
||||||
|
|
||||||
err.append("The following errors were encountered parsing the source XML.\n");
|
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");
|
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) {
|
if (first.getLength() == 0) {
|
||||||
err.append("-There are no top level communities in the source document.");
|
err.append("-There are no top level communities in the source document.");
|
||||||
System.out.println(err.toString());
|
System.out.println(err.toString());
|
||||||
@@ -493,14 +501,15 @@ public class StructBuilder {
|
|||||||
* no errors.
|
* no errors.
|
||||||
*/
|
*/
|
||||||
private static String validateCommunities(NodeList communities, int level)
|
private static String validateCommunities(NodeList communities, int level)
|
||||||
throws TransformerException {
|
throws XPathExpressionException {
|
||||||
StringBuilder err = new StringBuilder();
|
StringBuilder err = new StringBuilder();
|
||||||
boolean trip = false;
|
boolean trip = false;
|
||||||
String errs = null;
|
String errs = null;
|
||||||
|
XPath xPath = XPathFactory.newInstance().newXPath();
|
||||||
|
|
||||||
for (int i = 0; i < communities.getLength(); i++) {
|
for (int i = 0; i < communities.getLength(); i++) {
|
||||||
Node n = communities.item(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) {
|
if (name.getLength() != 1) {
|
||||||
String pos = Integer.toString(i + 1);
|
String pos = Integer.toString(i + 1);
|
||||||
err.append("-The level ").append(level)
|
err.append("-The level ").append(level)
|
||||||
@@ -510,7 +519,7 @@ public class StructBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate sub communities
|
// 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);
|
String comErrs = validateCommunities(subCommunities, level + 1);
|
||||||
if (comErrs != null) {
|
if (comErrs != null) {
|
||||||
err.append(comErrs);
|
err.append(comErrs);
|
||||||
@@ -518,7 +527,7 @@ public class StructBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate collections
|
// validate collections
|
||||||
NodeList collections = XPathAPI.selectNodeList(n, "collection");
|
NodeList collections = (NodeList) xPath.compile("collection").evaluate(n, XPathConstants.NODESET);
|
||||||
String colErrs = validateCollections(collections, level + 1);
|
String colErrs = validateCollections(collections, level + 1);
|
||||||
if (colErrs != null) {
|
if (colErrs != null) {
|
||||||
err.append(colErrs);
|
err.append(colErrs);
|
||||||
@@ -542,14 +551,15 @@ public class StructBuilder {
|
|||||||
* @return the errors to be generated by the calling method, or null if none
|
* @return the errors to be generated by the calling method, or null if none
|
||||||
*/
|
*/
|
||||||
private static String validateCollections(NodeList collections, int level)
|
private static String validateCollections(NodeList collections, int level)
|
||||||
throws TransformerException {
|
throws XPathExpressionException {
|
||||||
StringBuilder err = new StringBuilder();
|
StringBuilder err = new StringBuilder();
|
||||||
boolean trip = false;
|
boolean trip = false;
|
||||||
String errs = null;
|
String errs = null;
|
||||||
|
XPath xPath = XPathFactory.newInstance().newXPath();
|
||||||
|
|
||||||
for (int i = 0; i < collections.getLength(); i++) {
|
for (int i = 0; i < collections.getLength(); i++) {
|
||||||
Node n = collections.item(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) {
|
if (name.getLength() != 1) {
|
||||||
String pos = Integer.toString(i + 1);
|
String pos = Integer.toString(i + 1);
|
||||||
err.append("-The level ").append(level)
|
err.append("-The level ").append(level)
|
||||||
@@ -613,8 +623,9 @@ public class StructBuilder {
|
|||||||
* created communities (e.g. the handles they have been assigned)
|
* created communities (e.g. the handles they have been assigned)
|
||||||
*/
|
*/
|
||||||
private static Element[] handleCommunities(Context context, NodeList communities, Community parent)
|
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()];
|
Element[] elements = new Element[communities.getLength()];
|
||||||
|
XPath xPath = XPathFactory.newInstance().newXPath();
|
||||||
|
|
||||||
for (int i = 0; i < communities.getLength(); i++) {
|
for (int i = 0; i < communities.getLength(); i++) {
|
||||||
Community community;
|
Community community;
|
||||||
@@ -634,7 +645,7 @@ public class StructBuilder {
|
|||||||
// now update the metadata
|
// now update the metadata
|
||||||
Node tn = communities.item(i);
|
Node tn = communities.item(i);
|
||||||
for (Map.Entry<String, MetadataFieldName> entry : communityMap.entrySet()) {
|
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) {
|
if (nl.getLength() == 1) {
|
||||||
communityService.setMetadataSingleValue(context, community,
|
communityService.setMetadataSingleValue(context, community,
|
||||||
entry.getValue(), null, getStringValue(nl.item(0)));
|
entry.getValue(), null, getStringValue(nl.item(0)));
|
||||||
@@ -700,11 +711,11 @@ public class StructBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// handle sub communities
|
// 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);
|
Element[] subCommunityElements = handleCommunities(context, subCommunities, community);
|
||||||
|
|
||||||
// handle collections
|
// handle collections
|
||||||
NodeList collections = XPathAPI.selectNodeList(tn, "collection");
|
NodeList collections = (NodeList) xPath.compile("collection").evaluate(tn, XPathConstants.NODESET);
|
||||||
Element[] collectionElements = handleCollections(context, collections, community);
|
Element[] collectionElements = handleCollections(context, collections, community);
|
||||||
|
|
||||||
int j;
|
int j;
|
||||||
@@ -731,8 +742,9 @@ public class StructBuilder {
|
|||||||
* created collections (e.g. the handle)
|
* created collections (e.g. the handle)
|
||||||
*/
|
*/
|
||||||
private static Element[] handleCollections(Context context, NodeList collections, Community parent)
|
private static Element[] handleCollections(Context context, NodeList collections, Community parent)
|
||||||
throws TransformerException, SQLException, AuthorizeException {
|
throws SQLException, AuthorizeException, XPathExpressionException {
|
||||||
Element[] elements = new Element[collections.getLength()];
|
Element[] elements = new Element[collections.getLength()];
|
||||||
|
XPath xPath = XPathFactory.newInstance().newXPath();
|
||||||
|
|
||||||
for (int i = 0; i < collections.getLength(); i++) {
|
for (int i = 0; i < collections.getLength(); i++) {
|
||||||
Element element = new Element("collection");
|
Element element = new Element("collection");
|
||||||
@@ -745,7 +757,7 @@ public class StructBuilder {
|
|||||||
// import the rest of the metadata
|
// import the rest of the metadata
|
||||||
Node tn = collections.item(i);
|
Node tn = collections.item(i);
|
||||||
for (Map.Entry<String, MetadataFieldName> entry : collectionMap.entrySet()) {
|
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) {
|
if (nl.getLength() == 1) {
|
||||||
collectionService.setMetadataSingleValue(context, collection,
|
collectionService.setMetadataSingleValue(context, collection,
|
||||||
entry.getValue(), null, getStringValue(nl.item(0)));
|
entry.getValue(), null, getStringValue(nl.item(0)));
|
||||||
|
@@ -51,6 +51,10 @@ import javax.xml.parsers.DocumentBuilder;
|
|||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
import javax.xml.transform.TransformerException;
|
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.collections4.ComparatorUtils;
|
||||||
import org.apache.commons.io.FileDeleteStrategy;
|
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.StringUtils;
|
||||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.apache.xpath.XPathAPI;
|
|
||||||
import org.dspace.app.itemimport.service.ItemImportService;
|
import org.dspace.app.itemimport.service.ItemImportService;
|
||||||
import org.dspace.app.util.LocalSchemaFilenameFilter;
|
import org.dspace.app.util.LocalSchemaFilenameFilter;
|
||||||
import org.dspace.app.util.RelationshipUtils;
|
import org.dspace.app.util.RelationshipUtils;
|
||||||
@@ -863,7 +866,7 @@ public class ItemImportServiceImpl implements ItemImportService, InitializingBea
|
|||||||
// Load all metadata schemas into the item.
|
// Load all metadata schemas into the item.
|
||||||
protected void loadMetadata(Context c, Item myitem, String path)
|
protected void loadMetadata(Context c, Item myitem, String path)
|
||||||
throws SQLException, IOException, ParserConfigurationException,
|
throws SQLException, IOException, ParserConfigurationException,
|
||||||
SAXException, TransformerException, AuthorizeException {
|
SAXException, TransformerException, AuthorizeException, XPathExpressionException {
|
||||||
// Load the dublin core metadata
|
// Load the dublin core metadata
|
||||||
loadDublinCore(c, myitem, path + "dublin_core.xml");
|
loadDublinCore(c, myitem, path + "dublin_core.xml");
|
||||||
|
|
||||||
@@ -877,14 +880,15 @@ public class ItemImportServiceImpl implements ItemImportService, InitializingBea
|
|||||||
|
|
||||||
protected void loadDublinCore(Context c, Item myitem, String filename)
|
protected void loadDublinCore(Context c, Item myitem, String filename)
|
||||||
throws SQLException, IOException, ParserConfigurationException,
|
throws SQLException, IOException, ParserConfigurationException,
|
||||||
SAXException, TransformerException, AuthorizeException {
|
SAXException, TransformerException, AuthorizeException, XPathExpressionException {
|
||||||
Document document = loadXML(filename);
|
Document document = loadXML(filename);
|
||||||
|
|
||||||
// Get the schema, for backward compatibility we will default to the
|
// Get the schema, for backward compatibility we will default to the
|
||||||
// dublin core schema if the schema name is not available in the import
|
// dublin core schema if the schema name is not available in the import
|
||||||
// file
|
// file
|
||||||
String schema;
|
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(
|
Node schemaAttr = metadata.item(0).getAttributes().getNamedItem(
|
||||||
"schema");
|
"schema");
|
||||||
if (schemaAttr == null) {
|
if (schemaAttr == null) {
|
||||||
@@ -894,8 +898,7 @@ public class ItemImportServiceImpl implements ItemImportService, InitializingBea
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get the nodes corresponding to formats
|
// Get the nodes corresponding to formats
|
||||||
NodeList dcNodes = XPathAPI.selectNodeList(document,
|
NodeList dcNodes = (NodeList) xPath.compile("/dublin_core/dcvalue").evaluate(document, XPathConstants.NODESET);
|
||||||
"/dublin_core/dcvalue");
|
|
||||||
|
|
||||||
if (!isQuiet) {
|
if (!isQuiet) {
|
||||||
System.out.println("\tLoading dublin core from " + filename);
|
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.TransformerException;
|
||||||
import javax.xml.transform.dom.DOMSource;
|
import javax.xml.transform.dom.DOMSource;
|
||||||
import javax.xml.transform.stream.StreamResult;
|
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.commons.lang3.StringUtils;
|
||||||
import org.apache.xpath.XPathAPI;
|
|
||||||
import org.dspace.authorize.AuthorizeException;
|
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.content.MetadataField;
|
import org.dspace.content.MetadataField;
|
||||||
import org.dspace.content.MetadataSchema;
|
import org.dspace.content.MetadataSchema;
|
||||||
@@ -170,24 +172,21 @@ public class MetadataUtilities {
|
|||||||
* @param docBuilder DocumentBuilder
|
* @param docBuilder DocumentBuilder
|
||||||
* @param is - InputStream of dublin_core.xml
|
* @param is - InputStream of dublin_core.xml
|
||||||
* @return list of DtoMetadata representing the metadata fields relating to an Item
|
* @return list of DtoMetadata representing the metadata fields relating to an Item
|
||||||
* @throws SQLException if database error
|
|
||||||
* @throws IOException if IO error
|
* @throws IOException if IO error
|
||||||
* @throws ParserConfigurationException if parser config error
|
* @throws ParserConfigurationException if parser config error
|
||||||
* @throws SAXException if XML 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)
|
public static List<DtoMetadata> loadDublinCore(DocumentBuilder docBuilder, InputStream is)
|
||||||
throws SQLException, IOException, ParserConfigurationException,
|
throws IOException, XPathExpressionException, SAXException {
|
||||||
SAXException, TransformerException, AuthorizeException {
|
|
||||||
Document document = docBuilder.parse(is);
|
Document document = docBuilder.parse(is);
|
||||||
|
|
||||||
List<DtoMetadata> dtomList = new ArrayList<DtoMetadata>();
|
List<DtoMetadata> dtomList = new ArrayList<DtoMetadata>();
|
||||||
|
|
||||||
// Get the schema, for backward compatibility we will default to the
|
// 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
|
// dublin core schema if the schema name is not available in the import file
|
||||||
String schema = null;
|
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");
|
Node schemaAttr = metadata.item(0).getAttributes().getNamedItem("schema");
|
||||||
if (schemaAttr == null) {
|
if (schemaAttr == null) {
|
||||||
schema = MetadataSchemaEnum.DC.getName();
|
schema = MetadataSchemaEnum.DC.getName();
|
||||||
@@ -196,7 +195,7 @@ public class MetadataUtilities {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get the nodes corresponding to formats
|
// 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++) {
|
for (int i = 0; i < dcNodes.getLength(); i++) {
|
||||||
Node n = dcNodes.item(i);
|
Node n = dcNodes.item(i);
|
||||||
|
@@ -14,11 +14,12 @@ import java.util.Iterator;
|
|||||||
import javax.xml.parsers.DocumentBuilder;
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
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.XPathExpressionException;
|
||||||
|
import javax.xml.xpath.XPathFactory;
|
||||||
|
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.apache.xpath.XPathAPI;
|
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
import org.w3c.dom.Node;
|
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 xml The starting context (a Node or a Document, for example).
|
||||||
* @param NodeListXPath xpath
|
* @param nodeListXPath xpath
|
||||||
* @return A Node matches the NodeListXPath
|
* @return A Node matches the NodeListXPath
|
||||||
* null if nothing matches the NodeListXPath
|
* null if nothing matches the NodeListXPath
|
||||||
* @throws XPathExpressionException if xpath error
|
* @throws XPathExpressionException if xpath error
|
||||||
*/
|
*/
|
||||||
public static Node getNode(Node xml, String NodeListXPath) throws XPathExpressionException {
|
public static Node getNode(Node xml, String nodeListXPath) throws XPathExpressionException {
|
||||||
Node result = null;
|
XPath xPath = XPathFactory.newInstance().newXPath();
|
||||||
try {
|
return (Node) xPath.compile(nodeListXPath).evaluate(xml, XPathConstants.NODE);
|
||||||
result = XPathAPI.selectSingleNode(xml, NodeListXPath);
|
|
||||||
} catch (TransformerException e) {
|
|
||||||
log.error("Error", e);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param xml The starting context (a Node or a Document, for example).
|
* @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
|
* @return A NodeList containing the nodes that match the NodeListXPath
|
||||||
* null if nothing matches the NodeListXPath
|
* null if nothing matches the NodeListXPath
|
||||||
* @throws XPathExpressionException if xpath error
|
* @throws XPathExpressionException if xpath error
|
||||||
*/
|
*/
|
||||||
public static NodeList getNodeList(Node xml, String NodeListXPath) throws XPathExpressionException {
|
public static NodeList getNodeList(Node xml, String nodeListXPath) throws XPathExpressionException {
|
||||||
NodeList nodeList = null;
|
XPath xPath = XPathFactory.newInstance().newXPath();
|
||||||
try {
|
return (NodeList) xPath.compile(nodeListXPath).evaluate(xml, XPathConstants.NODESET);
|
||||||
nodeList = XPathAPI.selectNodeList(xml, NodeListXPath);
|
|
||||||
} catch (TransformerException e) {
|
|
||||||
log.error("Error", e);
|
|
||||||
}
|
|
||||||
return nodeList;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Iterator<Node> getNodeListIterator(Node xml, String NodeListXPath) throws XPathExpressionException {
|
public static Iterator<Node> getNodeListIterator(Node xml, String NodeListXPath) throws XPathExpressionException {
|
||||||
|
@@ -134,7 +134,7 @@ public abstract class XSLTCrosswalk extends SelfNamedPlugin {
|
|||||||
* We need to force this, because some dependency elsewhere interferes.
|
* We need to force this, because some dependency elsewhere interferes.
|
||||||
*/
|
*/
|
||||||
private static final String TRANSFORMER_FACTORY_CLASS
|
private static final String TRANSFORMER_FACTORY_CLASS
|
||||||
= "com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl";
|
= "org.apache.xalan.processor.TransformerFactoryImpl";
|
||||||
|
|
||||||
private Transformer transformer = null;
|
private Transformer transformer = null;
|
||||||
private File transformFile = null;
|
private File transformFile = null;
|
||||||
|
@@ -12,6 +12,7 @@ import java.io.IOException;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
import javax.xml.transform.TransformerException;
|
import javax.xml.transform.TransformerException;
|
||||||
|
import javax.xml.xpath.XPathExpressionException;
|
||||||
|
|
||||||
import org.dspace.administer.MetadataImporter;
|
import org.dspace.administer.MetadataImporter;
|
||||||
import org.dspace.administer.RegistryImportException;
|
import org.dspace.administer.RegistryImportException;
|
||||||
@@ -89,7 +90,7 @@ public class RegistryUpdater implements Callback {
|
|||||||
} catch (IOException | SQLException | ParserConfigurationException
|
} catch (IOException | SQLException | ParserConfigurationException
|
||||||
| TransformerException | RegistryImportException
|
| TransformerException | RegistryImportException
|
||||||
| AuthorizeException | NonUniqueMetadataException
|
| AuthorizeException | NonUniqueMetadataException
|
||||||
| SAXException e) {
|
| SAXException | XPathExpressionException e) {
|
||||||
log.error("Error attempting to update Bitstream Format and/or Metadata Registries", e);
|
log.error("Error attempting to update Bitstream Format and/or Metadata Registries", e);
|
||||||
throw new RuntimeException("Error attempting to update Bitstream Format and/or Metadata Registries", e);
|
throw new RuntimeException("Error attempting to update Bitstream Format and/or Metadata Registries", e);
|
||||||
} finally {
|
} finally {
|
||||||
|
@@ -15,8 +15,11 @@ import javax.xml.parsers.DocumentBuilder;
|
|||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
import javax.xml.transform.TransformerException;
|
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.dspace.services.ConfigurationService;
|
import org.dspace.services.ConfigurationService;
|
||||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
@@ -56,7 +59,7 @@ public class ControlledVocabulary {
|
|||||||
* TODO: add some caching !
|
* TODO: add some caching !
|
||||||
*/
|
*/
|
||||||
public static ControlledVocabulary loadVocabulary(String fileName)
|
public static ControlledVocabulary loadVocabulary(String fileName)
|
||||||
throws IOException, SAXException, ParserConfigurationException, TransformerException {
|
throws IOException, SAXException, ParserConfigurationException, XPathExpressionException {
|
||||||
StringBuilder filePath = new StringBuilder();
|
StringBuilder filePath = new StringBuilder();
|
||||||
ConfigurationService configurationService
|
ConfigurationService configurationService
|
||||||
= DSpaceServicesFactory.getInstance().getConfigurationService();
|
= DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||||
@@ -70,7 +73,9 @@ public class ControlledVocabulary {
|
|||||||
if (controlledVocFile.exists()) {
|
if (controlledVocFile.exists()) {
|
||||||
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
|
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
|
||||||
Document document = builder.parse(controlledVocFile);
|
Document document = builder.parse(controlledVocFile);
|
||||||
return loadVocabularyNode(XPathAPI.selectSingleNode(document, "node"), "");
|
XPath xPath = XPathFactory.newInstance().newXPath();
|
||||||
|
Node node = (Node) xPath.compile("node").evaluate(document, XPathConstants.NODE);
|
||||||
|
return loadVocabularyNode(node, "");
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -85,7 +90,8 @@ public class ControlledVocabulary {
|
|||||||
* @return a vocabulary node with all its children
|
* @return a vocabulary node with all its children
|
||||||
* @throws TransformerException should something go wrong with loading the xml
|
* @throws TransformerException should something go wrong with loading the xml
|
||||||
*/
|
*/
|
||||||
private static ControlledVocabulary loadVocabularyNode(Node node, String initialValue) throws TransformerException {
|
private static ControlledVocabulary loadVocabularyNode(Node node, String initialValue)
|
||||||
|
throws XPathExpressionException {
|
||||||
Node idNode = node.getAttributes().getNamedItem("id");
|
Node idNode = node.getAttributes().getNamedItem("id");
|
||||||
String id = null;
|
String id = null;
|
||||||
if (idNode != null) {
|
if (idNode != null) {
|
||||||
@@ -102,7 +108,9 @@ public class ControlledVocabulary {
|
|||||||
} else {
|
} else {
|
||||||
value = label;
|
value = label;
|
||||||
}
|
}
|
||||||
NodeList subNodes = XPathAPI.selectNodeList(node, "isComposedBy/node");
|
XPath xPath = XPathFactory.newInstance().newXPath();
|
||||||
|
NodeList subNodes = (NodeList) xPath.compile("isComposedBy/node").evaluate(node,
|
||||||
|
XPathConstants.NODESET);
|
||||||
|
|
||||||
List<ControlledVocabulary> subVocabularies = new ArrayList<>(subNodes.getLength());
|
List<ControlledVocabulary> subVocabularies = new ArrayList<>(subNodes.getLength());
|
||||||
for (int i = 0; i < subNodes.getLength(); i++) {
|
for (int i = 0; i < subNodes.getLength(); i++) {
|
||||||
|
@@ -82,10 +82,6 @@
|
|||||||
<groupId>org.mockito</groupId>
|
<groupId>org.mockito</groupId>
|
||||||
<artifactId>mockito-all</artifactId>
|
<artifactId>mockito-all</artifactId>
|
||||||
</exclusion>
|
</exclusion>
|
||||||
<exclusion>
|
|
||||||
<groupId>xml-apis</groupId>
|
|
||||||
<artifactId>xml-apis</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<groupId>org.apache.commons</groupId>
|
<groupId>org.apache.commons</groupId>
|
||||||
<artifactId>commons-lang3</artifactId>
|
<artifactId>commons-lang3</artifactId>
|
||||||
|
@@ -61,10 +61,6 @@
|
|||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
<artifactId>slf4j-api</artifactId>
|
<artifactId>slf4j-api</artifactId>
|
||||||
</exclusion>
|
</exclusion>
|
||||||
<exclusion>
|
|
||||||
<groupId>xml-apis</groupId>
|
|
||||||
<artifactId>xml-apis</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
@@ -127,7 +123,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>xom</groupId>
|
<groupId>xom</groupId>
|
||||||
<artifactId>xom</artifactId>
|
<artifactId>xom</artifactId>
|
||||||
<version>1.2.5</version>
|
<version>1.3.7</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-io</groupId>
|
<groupId>commons-io</groupId>
|
||||||
|
7
pom.xml
7
pom.xml
@@ -1542,16 +1542,13 @@
|
|||||||
<artifactId>fontbox</artifactId>
|
<artifactId>fontbox</artifactId>
|
||||||
<version>${pdfbox-version}</version>
|
<version>${pdfbox-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<!-- Tika and Jena disagree on version of Xerces to use. Select latest -->
|
||||||
<groupId>xalan</groupId>
|
|
||||||
<artifactId>xalan</artifactId>
|
|
||||||
<version>2.7.0</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>xerces</groupId>
|
<groupId>xerces</groupId>
|
||||||
<artifactId>xercesImpl</artifactId>
|
<artifactId>xercesImpl</artifactId>
|
||||||
<version>2.12.2</version>
|
<version>2.12.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- SWORDv1 and SWORDv2 modules both pull in various versions of xml-apis. Select latest version -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>xml-apis</groupId>
|
<groupId>xml-apis</groupId>
|
||||||
<artifactId>xml-apis</artifactId>
|
<artifactId>xml-apis</artifactId>
|
||||||
|
Reference in New Issue
Block a user