mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-14 13:33:08 +00:00
More errorprone warnings. #3061
This commit is contained in:
@@ -81,7 +81,7 @@ public class MetadataImporter {
|
|||||||
* @throws SQLException if database error
|
* @throws SQLException if database error
|
||||||
* @throws IOException if IO error
|
* @throws IOException if IO error
|
||||||
* @throws TransformerException if transformer error
|
* @throws TransformerException if transformer error
|
||||||
* @throws ParserConfigurationException if config error
|
* @throws ParserConfigurationException if configuration error
|
||||||
* @throws AuthorizeException if authorization error
|
* @throws AuthorizeException if authorization error
|
||||||
* @throws SAXException if parser error
|
* @throws SAXException if parser error
|
||||||
* @throws NonUniqueMetadataException if duplicate metadata
|
* @throws NonUniqueMetadataException if duplicate metadata
|
||||||
@@ -91,7 +91,6 @@ public class MetadataImporter {
|
|||||||
throws ParseException, SQLException, IOException, TransformerException,
|
throws ParseException, SQLException, IOException, TransformerException,
|
||||||
ParserConfigurationException, AuthorizeException, SAXException,
|
ParserConfigurationException, AuthorizeException, SAXException,
|
||||||
NonUniqueMetadataException, RegistryImportException {
|
NonUniqueMetadataException, RegistryImportException {
|
||||||
boolean forceUpdate = false;
|
|
||||||
|
|
||||||
// create an options object and populate it
|
// create an options object and populate it
|
||||||
CommandLineParser parser = new DefaultParser();
|
CommandLineParser parser = new DefaultParser();
|
||||||
@@ -100,16 +99,14 @@ public class MetadataImporter {
|
|||||||
options.addOption("u", "update", false, "update an existing schema");
|
options.addOption("u", "update", false, "update an existing schema");
|
||||||
CommandLine line = parser.parse(options, args);
|
CommandLine line = parser.parse(options, args);
|
||||||
|
|
||||||
String file = null;
|
|
||||||
if (line.hasOption('f')) {
|
if (line.hasOption('f')) {
|
||||||
file = line.getOptionValue('f');
|
String file = line.getOptionValue('f');
|
||||||
|
boolean forceUpdate = line.hasOption('u');
|
||||||
|
loadRegistry(file, forceUpdate);
|
||||||
} else {
|
} else {
|
||||||
usage();
|
usage();
|
||||||
System.exit(0);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
forceUpdate = line.hasOption('u');
|
|
||||||
loadRegistry(file, forceUpdate);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -120,7 +117,7 @@ public class MetadataImporter {
|
|||||||
* @throws SQLException if database error
|
* @throws SQLException if database error
|
||||||
* @throws IOException if IO error
|
* @throws IOException if IO error
|
||||||
* @throws TransformerException if transformer error
|
* @throws TransformerException if transformer error
|
||||||
* @throws ParserConfigurationException if config error
|
* @throws ParserConfigurationException if configuration error
|
||||||
* @throws AuthorizeException if authorization error
|
* @throws AuthorizeException if authorization error
|
||||||
* @throws SAXException if parser error
|
* @throws SAXException if parser error
|
||||||
* @throws NonUniqueMetadataException if duplicate metadata
|
* @throws NonUniqueMetadataException if duplicate metadata
|
||||||
@@ -227,7 +224,7 @@ public class MetadataImporter {
|
|||||||
/**
|
/**
|
||||||
* Process a node in the metadata registry XML file. The node must
|
* Process a node in the metadata registry XML file. The node must
|
||||||
* be a "dc-type" node. If the type already exists, then it
|
* be a "dc-type" node. If the type already exists, then it
|
||||||
* will not be reimported
|
* will not be re-imported.
|
||||||
*
|
*
|
||||||
* @param context DSpace context object
|
* @param context DSpace context object
|
||||||
* @param node the node in the DOM tree
|
* @param node the node in the DOM tree
|
||||||
|
@@ -138,7 +138,7 @@ public class DSpaceCSV implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* Create a new instance, reading the lines in from file
|
* Create a new instance, reading the lines in from file
|
||||||
*
|
*
|
||||||
* @param inputStream the inputstream to read from
|
* @param inputStream the input stream to read from
|
||||||
* @param c The DSpace Context
|
* @param c The DSpace Context
|
||||||
* @throws Exception thrown if there is an error reading or processing the file
|
* @throws Exception thrown if there is an error reading or processing the file
|
||||||
*/
|
*/
|
||||||
@@ -159,7 +159,7 @@ public class DSpaceCSV implements Serializable {
|
|||||||
columnCounter++;
|
columnCounter++;
|
||||||
|
|
||||||
// Remove surrounding quotes if there are any
|
// Remove surrounding quotes if there are any
|
||||||
if ((element.startsWith("\"")) && (element.endsWith("\""))) {
|
if (element.startsWith("\"") && element.endsWith("\"")) {
|
||||||
element = element.substring(1, element.length() - 1);
|
element = element.substring(1, element.length() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -334,15 +334,15 @@ public class DSpaceCSV implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* Set the value separator for multiple values stored in one csv value.
|
* Set the value separator for multiple values stored in one csv value.
|
||||||
*
|
*
|
||||||
* Is set in bulkedit.cfg as valueseparator
|
* Is set in {@code bulkedit.cfg} as {@code valueseparator}.
|
||||||
*
|
*
|
||||||
* If not set, defaults to double pipe '||'
|
* If not set, defaults to double pipe '||'.
|
||||||
*/
|
*/
|
||||||
private void setValueSeparator() {
|
private void setValueSeparator() {
|
||||||
// Get the value separator
|
// Get the value separator
|
||||||
valueSeparator = DSpaceServicesFactory.getInstance().getConfigurationService()
|
valueSeparator = DSpaceServicesFactory.getInstance().getConfigurationService()
|
||||||
.getProperty("bulkedit.valueseparator");
|
.getProperty("bulkedit.valueseparator");
|
||||||
if ((valueSeparator != null) && (!"".equals(valueSeparator.trim()))) {
|
if ((valueSeparator != null) && !valueSeparator.trim().isEmpty()) {
|
||||||
valueSeparator = valueSeparator.trim();
|
valueSeparator = valueSeparator.trim();
|
||||||
} else {
|
} else {
|
||||||
valueSeparator = "||";
|
valueSeparator = "||";
|
||||||
@@ -357,7 +357,7 @@ public class DSpaceCSV implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* Set the field separator use to separate fields in the csv.
|
* Set the field separator use to separate fields in the csv.
|
||||||
*
|
*
|
||||||
* Is set in bulkedit.cfg as fieldseparator
|
* Is set in {@code bulkedit.cfg} as {@code fieldseparator}.
|
||||||
*
|
*
|
||||||
* If not set, defaults to comma ','.
|
* If not set, defaults to comma ','.
|
||||||
*
|
*
|
||||||
@@ -368,7 +368,7 @@ public class DSpaceCSV implements Serializable {
|
|||||||
// Get the value separator
|
// Get the value separator
|
||||||
fieldSeparator = DSpaceServicesFactory.getInstance().getConfigurationService()
|
fieldSeparator = DSpaceServicesFactory.getInstance().getConfigurationService()
|
||||||
.getProperty("bulkedit.fieldseparator");
|
.getProperty("bulkedit.fieldseparator");
|
||||||
if ((fieldSeparator != null) && (!"".equals(fieldSeparator.trim()))) {
|
if ((fieldSeparator != null) && !fieldSeparator.trim().isEmpty()) {
|
||||||
fieldSeparator = fieldSeparator.trim();
|
fieldSeparator = fieldSeparator.trim();
|
||||||
if ("tab".equals(fieldSeparator)) {
|
if ("tab".equals(fieldSeparator)) {
|
||||||
fieldSeparator = "\t";
|
fieldSeparator = "\t";
|
||||||
@@ -392,15 +392,15 @@ public class DSpaceCSV implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* Set the authority separator for value with authority data.
|
* Set the authority separator for value with authority data.
|
||||||
*
|
*
|
||||||
* Is set in dspace.cfg as bulkedit.authorityseparator
|
* Is set in {@code dspace.cfg} as {@code bulkedit.authorityseparator}.
|
||||||
*
|
*
|
||||||
* If not set, defaults to double colon '::'
|
* If not set, defaults to double colon '::'.
|
||||||
*/
|
*/
|
||||||
private void setAuthoritySeparator() {
|
private void setAuthoritySeparator() {
|
||||||
// Get the value separator
|
// Get the value separator
|
||||||
authoritySeparator = DSpaceServicesFactory.getInstance().getConfigurationService()
|
authoritySeparator = DSpaceServicesFactory.getInstance().getConfigurationService()
|
||||||
.getProperty("bulkedit.authorityseparator");
|
.getProperty("bulkedit.authorityseparator");
|
||||||
if ((authoritySeparator != null) && (!"".equals(authoritySeparator.trim()))) {
|
if ((authoritySeparator != null) && !authoritySeparator.trim().isEmpty()) {
|
||||||
authoritySeparator = authoritySeparator.trim();
|
authoritySeparator = authoritySeparator.trim();
|
||||||
} else {
|
} else {
|
||||||
authoritySeparator = "::";
|
authoritySeparator = "::";
|
||||||
@@ -505,7 +505,7 @@ public class DSpaceCSV implements Serializable {
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
for (String part : bits) {
|
for (String part : bits) {
|
||||||
int bitcounter = part.length() - part.replaceAll("\"", "").length();
|
int bitcounter = part.length() - part.replaceAll("\"", "").length();
|
||||||
if ((part.startsWith("\"")) && ((!part.endsWith("\"")) || ((bitcounter & 1) == 1))) {
|
if (part.startsWith("\"") && (!part.endsWith("\"") || ((bitcounter & 1) == 1))) {
|
||||||
found = true;
|
found = true;
|
||||||
String add = bits.get(i) + fieldSeparator + bits.get(i + 1);
|
String add = bits.get(i) + fieldSeparator + bits.get(i + 1);
|
||||||
bits.remove(i);
|
bits.remove(i);
|
||||||
@@ -521,7 +521,7 @@ public class DSpaceCSV implements Serializable {
|
|||||||
// Deal with quotes around the elements
|
// Deal with quotes around the elements
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (String part : bits) {
|
for (String part : bits) {
|
||||||
if ((part.startsWith("\"")) && (part.endsWith("\""))) {
|
if (part.startsWith("\"") && part.endsWith("\"")) {
|
||||||
part = part.substring(1, part.length() - 1);
|
part = part.substring(1, part.length() - 1);
|
||||||
bits.set(i, part);
|
bits.set(i, part);
|
||||||
}
|
}
|
||||||
@@ -561,7 +561,7 @@ public class DSpaceCSV implements Serializable {
|
|||||||
for (String part : bits) {
|
for (String part : bits) {
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
// Is this a last empty item?
|
// Is this a last empty item?
|
||||||
if ((last) && (i == headings.size())) {
|
if (last && (i == headings.size())) {
|
||||||
part = "";
|
part = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -574,7 +574,7 @@ public class DSpaceCSV implements Serializable {
|
|||||||
csvLine.add(headings.get(i - 1), null);
|
csvLine.add(headings.get(i - 1), null);
|
||||||
String[] elements = part.split(escapedValueSeparator);
|
String[] elements = part.split(escapedValueSeparator);
|
||||||
for (String element : elements) {
|
for (String element : elements) {
|
||||||
if ((element != null) && (!"".equals(element))) {
|
if ((element != null) && !"".equals(element)) {
|
||||||
csvLine.add(headings.get(i - 1), element);
|
csvLine.add(headings.get(i - 1), element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -626,18 +626,18 @@ public class DSpaceCSV implements Serializable {
|
|||||||
public InputStream getInputStream() {
|
public InputStream getInputStream() {
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
for (String csvLine : getCSVLinesAsStringArray()) {
|
for (String csvLine : getCSVLinesAsStringArray()) {
|
||||||
stringBuilder.append(csvLine + "\n");
|
stringBuilder.append(csvLine).append("\n");
|
||||||
}
|
}
|
||||||
return IOUtils.toInputStream(stringBuilder.toString(), StandardCharsets.UTF_8);
|
return IOUtils.toInputStream(stringBuilder.toString(), StandardCharsets.UTF_8);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is it Ok to export this value? When exportAll is set to false, we don't export
|
* Is it okay to export this value? When exportAll is set to false, we don't export
|
||||||
* some of the metadata elements.
|
* some of the metadata elements.
|
||||||
*
|
*
|
||||||
* The list can be configured via the key ignore-on-export in bulkedit.cfg
|
* The list can be configured via the key ignore-on-export in {@code bulkedit.cfg}.
|
||||||
*
|
*
|
||||||
* @param md The Metadatum to examine
|
* @param md The MetadataField to examine
|
||||||
* @return Whether or not it is OK to export this element
|
* @return Whether or not it is OK to export this element
|
||||||
*/
|
*/
|
||||||
protected boolean okToExport(MetadataField md) {
|
protected boolean okToExport(MetadataField md) {
|
||||||
@@ -646,12 +646,8 @@ public class DSpaceCSV implements Serializable {
|
|||||||
if (md.getQualifier() != null) {
|
if (md.getQualifier() != null) {
|
||||||
key += "." + md.getQualifier();
|
key += "." + md.getQualifier();
|
||||||
}
|
}
|
||||||
if (ignore.get(key) != null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Must be OK, so don't ignore
|
// Must be OK, so don't ignore
|
||||||
return true;
|
return ignore.get(key) == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -120,6 +120,7 @@ class DtoMetadata {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
String s = "\tSchema: " + schema + " Element: " + element;
|
String s = "\tSchema: " + schema + " Element: " + element;
|
||||||
if (qualifier != null) {
|
if (qualifier != null) {
|
||||||
|
@@ -17,6 +17,7 @@ import java.io.IOException;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
@@ -55,7 +56,7 @@ public class ItemArchive {
|
|||||||
protected Transformer transformer = null;
|
protected Transformer transformer = null;
|
||||||
|
|
||||||
protected List<DtoMetadata> dtomList = null;
|
protected List<DtoMetadata> dtomList = null;
|
||||||
protected List<DtoMetadata> undoDtomList = new ArrayList<DtoMetadata>();
|
protected List<DtoMetadata> undoDtomList = new ArrayList<>();
|
||||||
|
|
||||||
protected List<UUID> undoAddContents = new ArrayList<>(); // for undo of add
|
protected List<UUID> undoAddContents = new ArrayList<>(); // for undo of add
|
||||||
|
|
||||||
@@ -325,7 +326,7 @@ public class ItemArchive {
|
|||||||
PrintWriter pw = null;
|
PrintWriter pw = null;
|
||||||
try {
|
try {
|
||||||
File f = new File(dir, ItemUpdate.DELETE_CONTENTS_FILE);
|
File f = new File(dir, ItemUpdate.DELETE_CONTENTS_FILE);
|
||||||
pw = new PrintWriter(new BufferedWriter(new FileWriter(f)));
|
pw = new PrintWriter(new BufferedWriter(new FileWriter(f, StandardCharsets.UTF_8)));
|
||||||
for (UUID i : undoAddContents) {
|
for (UUID i : undoAddContents) {
|
||||||
pw.println(i);
|
pw.println(i);
|
||||||
}
|
}
|
||||||
|
@@ -8,12 +8,13 @@
|
|||||||
package org.dspace.app.sherpa;
|
package org.dspace.app.sherpa;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.LinkedList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.xml.parsers.DocumentBuilder;
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.dspace.app.util.XMLUtils;
|
import org.dspace.app.util.XMLUtils;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
@@ -25,7 +26,7 @@ import org.w3c.dom.Element;
|
|||||||
* @author Andrea Bollini
|
* @author Andrea Bollini
|
||||||
*/
|
*/
|
||||||
public class SHERPAResponse {
|
public class SHERPAResponse {
|
||||||
private static final Logger log = org.apache.logging.log4j.LogManager.getLogger(SHERPAResponse.class);
|
private static final Logger log = LogManager.getLogger(SHERPAResponse.class);
|
||||||
|
|
||||||
private int numHits;
|
private int numHits;
|
||||||
|
|
||||||
@@ -81,7 +82,7 @@ public class SHERPAResponse {
|
|||||||
publishersElement, "publisher");
|
publishersElement, "publisher");
|
||||||
|
|
||||||
if (journalsList != null) {
|
if (journalsList != null) {
|
||||||
journals = new LinkedList<SHERPAJournal>();
|
journals = new ArrayList<>(journalsList.size());
|
||||||
for (Element journalElement : journalsList) {
|
for (Element journalElement : journalsList) {
|
||||||
journals.add(new SHERPAJournal(
|
journals.add(new SHERPAJournal(
|
||||||
XMLUtils.getElementValue(journalElement, "jtitle"),
|
XMLUtils.getElementValue(journalElement, "jtitle"),
|
||||||
@@ -92,7 +93,7 @@ public class SHERPAResponse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (publishersList != null) {
|
if (publishersList != null) {
|
||||||
publishers = new LinkedList<SHERPAPublisher>();
|
publishers = new ArrayList<>(publishersList.size());
|
||||||
for (Element publisherElement : publishersList) {
|
for (Element publisherElement : publishersList) {
|
||||||
Element preprintsElement = XMLUtils.getSingleElement(
|
Element preprintsElement = XMLUtils.getSingleElement(
|
||||||
publisherElement, "preprints");
|
publisherElement, "preprints");
|
||||||
|
@@ -64,10 +64,6 @@ public class CreateStatReport {
|
|||||||
*/
|
*/
|
||||||
private static Context context;
|
private static Context context;
|
||||||
|
|
||||||
/**
|
|
||||||
* the config file from which to configure the analyser
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default constructor
|
* Default constructor
|
||||||
*/
|
*/
|
||||||
@@ -170,22 +166,19 @@ public class CreateStatReport {
|
|||||||
String myLogDir = null;
|
String myLogDir = null;
|
||||||
String myFileTemplate = null;
|
String myFileTemplate = null;
|
||||||
String myConfigFile = null;
|
String myConfigFile = null;
|
||||||
StringBuffer myOutFile = null;
|
|
||||||
Date myStartDate = null;
|
|
||||||
Date myEndDate = null;
|
|
||||||
boolean myLookUp = false;
|
boolean myLookUp = false;
|
||||||
|
|
||||||
Calendar start = new GregorianCalendar(calendar.get(Calendar.YEAR),
|
Calendar start = new GregorianCalendar(calendar.get(Calendar.YEAR),
|
||||||
calendar.get(Calendar.MONTH),
|
calendar.get(Calendar.MONTH),
|
||||||
calendar.getActualMinimum(Calendar.DAY_OF_MONTH));
|
calendar.getActualMinimum(Calendar.DAY_OF_MONTH));
|
||||||
myStartDate = start.getTime();
|
Date myStartDate = start.getTime();
|
||||||
|
|
||||||
Calendar end = new GregorianCalendar(calendar.get(Calendar.YEAR),
|
Calendar end = new GregorianCalendar(calendar.get(Calendar.YEAR),
|
||||||
calendar.get(Calendar.MONTH),
|
calendar.get(Calendar.MONTH),
|
||||||
calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
|
calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
|
||||||
myEndDate = end.getTime();
|
Date myEndDate = end.getTime();
|
||||||
|
|
||||||
myOutFile = new StringBuffer(outputLogDirectory);
|
StringBuilder myOutFile = new StringBuilder(outputLogDirectory);
|
||||||
myOutFile.append(outputPrefix);
|
myOutFile.append(outputPrefix);
|
||||||
myOutFile.append(calendar.get(Calendar.YEAR));
|
myOutFile.append(calendar.get(Calendar.YEAR));
|
||||||
myOutFile.append("-");
|
myOutFile.append("-");
|
||||||
@@ -211,12 +204,11 @@ public class CreateStatReport {
|
|||||||
String myLogDir = null;
|
String myLogDir = null;
|
||||||
String myFileTemplate = null;
|
String myFileTemplate = null;
|
||||||
String myConfigFile = null;
|
String myConfigFile = null;
|
||||||
StringBuffer myOutFile = null;
|
|
||||||
Date myStartDate = null;
|
Date myStartDate = null;
|
||||||
Date myEndDate = null;
|
Date myEndDate = null;
|
||||||
boolean myLookUp = false;
|
boolean myLookUp = false;
|
||||||
|
|
||||||
myOutFile = new StringBuffer(outputLogDirectory);
|
StringBuilder myOutFile = new StringBuilder(outputLogDirectory);
|
||||||
myOutFile.append(outputPrefix);
|
myOutFile.append(outputPrefix);
|
||||||
myOutFile.append(calendar.get(Calendar.YEAR));
|
myOutFile.append(calendar.get(Calendar.YEAR));
|
||||||
myOutFile.append("-");
|
myOutFile.append("-");
|
||||||
@@ -245,9 +237,6 @@ public class CreateStatReport {
|
|||||||
String myLogDir = null;
|
String myLogDir = null;
|
||||||
String myFileTemplate = null;
|
String myFileTemplate = null;
|
||||||
String myConfigFile = null;
|
String myConfigFile = null;
|
||||||
StringBuffer myOutFile = null;
|
|
||||||
Date myStartDate = null;
|
|
||||||
Date myEndDate = null;
|
|
||||||
boolean myLookUp = false;
|
boolean myLookUp = false;
|
||||||
|
|
||||||
Calendar reportEndDate = new GregorianCalendar(calendar.get(Calendar.YEAR),
|
Calendar reportEndDate = new GregorianCalendar(calendar.get(Calendar.YEAR),
|
||||||
@@ -260,14 +249,14 @@ public class CreateStatReport {
|
|||||||
Calendar start = new GregorianCalendar(currentMonth.get(Calendar.YEAR),
|
Calendar start = new GregorianCalendar(currentMonth.get(Calendar.YEAR),
|
||||||
currentMonth.get(Calendar.MONTH),
|
currentMonth.get(Calendar.MONTH),
|
||||||
currentMonth.getActualMinimum(Calendar.DAY_OF_MONTH));
|
currentMonth.getActualMinimum(Calendar.DAY_OF_MONTH));
|
||||||
myStartDate = start.getTime();
|
Date myStartDate = start.getTime();
|
||||||
|
|
||||||
Calendar end = new GregorianCalendar(currentMonth.get(Calendar.YEAR),
|
Calendar end = new GregorianCalendar(currentMonth.get(Calendar.YEAR),
|
||||||
currentMonth.get(Calendar.MONTH),
|
currentMonth.get(Calendar.MONTH),
|
||||||
currentMonth.getActualMaximum(Calendar.DAY_OF_MONTH));
|
currentMonth.getActualMaximum(Calendar.DAY_OF_MONTH));
|
||||||
myEndDate = end.getTime();
|
Date myEndDate = end.getTime();
|
||||||
|
|
||||||
myOutFile = new StringBuffer(outputLogDirectory);
|
StringBuilder myOutFile = new StringBuilder(outputLogDirectory);
|
||||||
myOutFile.append(outputPrefix);
|
myOutFile.append(outputPrefix);
|
||||||
myOutFile.append(currentMonth.get(Calendar.YEAR));
|
myOutFile.append(currentMonth.get(Calendar.YEAR));
|
||||||
myOutFile.append("-");
|
myOutFile.append("-");
|
||||||
@@ -293,11 +282,9 @@ public class CreateStatReport {
|
|||||||
String outputPrefix = "report-general-";
|
String outputPrefix = "report-general-";
|
||||||
|
|
||||||
String myFormat = "html";
|
String myFormat = "html";
|
||||||
StringBuffer myInput = null;
|
|
||||||
StringBuffer myOutput = null;
|
|
||||||
String myMap = null;
|
String myMap = null;
|
||||||
|
|
||||||
myInput = new StringBuffer(outputLogDirectory);
|
StringBuilder myInput = new StringBuilder(outputLogDirectory);
|
||||||
myInput.append(inputPrefix);
|
myInput.append(inputPrefix);
|
||||||
myInput.append(calendar.get(Calendar.YEAR));
|
myInput.append(calendar.get(Calendar.YEAR));
|
||||||
myInput.append("-");
|
myInput.append("-");
|
||||||
@@ -306,7 +293,7 @@ public class CreateStatReport {
|
|||||||
myInput.append(calendar.get(Calendar.DAY_OF_MONTH));
|
myInput.append(calendar.get(Calendar.DAY_OF_MONTH));
|
||||||
myInput.append(outputSuffix);
|
myInput.append(outputSuffix);
|
||||||
|
|
||||||
myOutput = new StringBuffer(outputReportDirectory);
|
StringBuilder myOutput = new StringBuilder(outputReportDirectory);
|
||||||
myOutput.append(outputPrefix);
|
myOutput.append(outputPrefix);
|
||||||
myOutput.append(calendar.get(Calendar.YEAR));
|
myOutput.append(calendar.get(Calendar.YEAR));
|
||||||
myOutput.append("-");
|
myOutput.append("-");
|
||||||
@@ -332,8 +319,6 @@ public class CreateStatReport {
|
|||||||
String outputPrefix = "report-";
|
String outputPrefix = "report-";
|
||||||
|
|
||||||
String myFormat = "html";
|
String myFormat = "html";
|
||||||
StringBuffer myInput = null;
|
|
||||||
StringBuffer myOutput = null;
|
|
||||||
String myMap = null;
|
String myMap = null;
|
||||||
|
|
||||||
Calendar reportEndDate = new GregorianCalendar(calendar.get(Calendar.YEAR),
|
Calendar reportEndDate = new GregorianCalendar(calendar.get(Calendar.YEAR),
|
||||||
@@ -344,14 +329,14 @@ public class CreateStatReport {
|
|||||||
|
|
||||||
while (currentMonth.before(reportEndDate)) {
|
while (currentMonth.before(reportEndDate)) {
|
||||||
|
|
||||||
myInput = new StringBuffer(outputLogDirectory);
|
StringBuilder myInput = new StringBuilder(outputLogDirectory);
|
||||||
myInput.append(inputPrefix);
|
myInput.append(inputPrefix);
|
||||||
myInput.append(currentMonth.get(Calendar.YEAR));
|
myInput.append(currentMonth.get(Calendar.YEAR));
|
||||||
myInput.append("-");
|
myInput.append("-");
|
||||||
myInput.append(currentMonth.get(Calendar.MONTH) + 1);
|
myInput.append(currentMonth.get(Calendar.MONTH) + 1);
|
||||||
myInput.append(outputSuffix);
|
myInput.append(outputSuffix);
|
||||||
|
|
||||||
myOutput = new StringBuffer(outputReportDirectory);
|
StringBuilder myOutput = new StringBuilder(outputReportDirectory);
|
||||||
myOutput.append(outputPrefix);
|
myOutput.append(outputPrefix);
|
||||||
myOutput.append(currentMonth.get(Calendar.YEAR));
|
myOutput.append(currentMonth.get(Calendar.YEAR));
|
||||||
myOutput.append("-");
|
myOutput.append("-");
|
||||||
@@ -376,18 +361,16 @@ public class CreateStatReport {
|
|||||||
String outputPrefix = "report-";
|
String outputPrefix = "report-";
|
||||||
|
|
||||||
String myFormat = "html";
|
String myFormat = "html";
|
||||||
StringBuffer myInput = null;
|
|
||||||
StringBuffer myOutput = null;
|
|
||||||
String myMap = null;
|
String myMap = null;
|
||||||
|
|
||||||
myInput = new StringBuffer(outputLogDirectory);
|
StringBuilder myInput = new StringBuilder(outputLogDirectory);
|
||||||
myInput.append(inputPrefix);
|
myInput.append(inputPrefix);
|
||||||
myInput.append(calendar.get(Calendar.YEAR));
|
myInput.append(calendar.get(Calendar.YEAR));
|
||||||
myInput.append("-");
|
myInput.append("-");
|
||||||
myInput.append(calendar.get(Calendar.MONTH) + 1);
|
myInput.append(calendar.get(Calendar.MONTH) + 1);
|
||||||
myInput.append(outputSuffix);
|
myInput.append(outputSuffix);
|
||||||
|
|
||||||
myOutput = new StringBuffer(outputReportDirectory);
|
StringBuilder myOutput = new StringBuilder(outputReportDirectory);
|
||||||
myOutput.append(outputPrefix);
|
myOutput.append(outputPrefix);
|
||||||
myOutput.append(calendar.get(Calendar.YEAR));
|
myOutput.append(calendar.get(Calendar.YEAR));
|
||||||
myOutput.append("-");
|
myOutput.append("-");
|
||||||
|
@@ -58,6 +58,7 @@ public class WebApp implements ReloadableEntity<Integer> {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Integer getID() {
|
public Integer getID() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
@@ -8,7 +8,6 @@
|
|||||||
package org.dspace.app.util;
|
package org.dspace.app.util;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
@@ -29,13 +28,13 @@ public class XMLUtils {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param dataRoot the starting node
|
* @param dataRoot the starting node
|
||||||
* @param name the name of the subelement to find
|
* @param name the tag name of the child element to find.
|
||||||
* @return the list of all DOM Element with the provided name direct child
|
* @return the list of all DOM Element with the provided name direct child
|
||||||
* of the starting node
|
* of the starting node
|
||||||
*/
|
*/
|
||||||
public static List<Element> getElementList(Element dataRoot, String name) {
|
public static List<Element> getElementList(Element dataRoot, String name) {
|
||||||
NodeList list = dataRoot.getElementsByTagName(name);
|
NodeList list = dataRoot.getElementsByTagName(name);
|
||||||
List<Element> listElements = new ArrayList<Element>();
|
List<Element> listElements = new ArrayList<>();
|
||||||
for (int i = 0; i < list.getLength(); i++) {
|
for (int i = 0; i < list.getLength(); i++) {
|
||||||
Element item = (Element) list.item(i);
|
Element item = (Element) list.item(i);
|
||||||
if (item.getParentNode().equals(dataRoot)) {
|
if (item.getParentNode().equals(dataRoot)) {
|
||||||
@@ -105,7 +104,7 @@ public class XMLUtils {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param rootElement the starting node
|
* @param rootElement the starting node
|
||||||
* @param subElementName the name of the subelement to find
|
* @param subElementName the tag name of the child element to find.
|
||||||
* @return a list of string including all the text contents of the sub
|
* @return a list of string including all the text contents of the sub
|
||||||
* element with the specified name. If there are not sub element
|
* element with the specified name. If there are not sub element
|
||||||
* with the supplied name the method will return null
|
* with the supplied name the method will return null
|
||||||
@@ -121,7 +120,7 @@ public class XMLUtils {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> result = new LinkedList<String>();
|
List<String> result = new ArrayList<>();
|
||||||
for (Element el : subElements) {
|
for (Element el : subElements) {
|
||||||
if (StringUtils.isNotBlank(el.getTextContent())) {
|
if (StringUtils.isNotBlank(el.getTextContent())) {
|
||||||
result.add(el.getTextContent().trim());
|
result.add(el.getTextContent().trim());
|
||||||
@@ -152,7 +151,7 @@ public class XMLUtils {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String[]> result = new LinkedList<String[]>();
|
List<String[]> result = new ArrayList<>();
|
||||||
for (Element el : subElements) {
|
for (Element el : subElements) {
|
||||||
String[] tmp = new String[fieldsName.length];
|
String[] tmp = new String[fieldsName.length];
|
||||||
for (int idx = 0; idx < fieldsName.length; idx++) {
|
for (int idx = 0; idx < fieldsName.length; idx++) {
|
||||||
|
@@ -41,7 +41,6 @@ import org.dspace.services.factory.DSpaceServicesFactory;
|
|||||||
* Basic Auth username and password to the <code>AuthenticationManager</code>.
|
* Basic Auth username and password to the <code>AuthenticationManager</code>.
|
||||||
*
|
*
|
||||||
* @author Larry Stone
|
* @author Larry Stone
|
||||||
* @version $Revision$
|
|
||||||
*/
|
*/
|
||||||
public class PasswordAuthentication
|
public class PasswordAuthentication
|
||||||
implements AuthenticationMethod {
|
implements AuthenticationMethod {
|
||||||
@@ -49,7 +48,7 @@ public class PasswordAuthentication
|
|||||||
/**
|
/**
|
||||||
* log4j category
|
* log4j category
|
||||||
*/
|
*/
|
||||||
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(PasswordAuthentication.class);
|
private static final Logger log = org.apache.logging.log4j.LogManager.getLogger(PasswordAuthentication.class);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -142,7 +141,7 @@ public class PasswordAuthentication
|
|||||||
.toString())) {
|
.toString())) {
|
||||||
String groupName = DSpaceServicesFactory.getInstance().getConfigurationService()
|
String groupName = DSpaceServicesFactory.getInstance().getConfigurationService()
|
||||||
.getProperty("authentication-password.login.specialgroup");
|
.getProperty("authentication-password.login.specialgroup");
|
||||||
if ((groupName != null) && (!groupName.trim().equals(""))) {
|
if ((groupName != null) && !groupName.trim().isEmpty()) {
|
||||||
Group specialGroup = EPersonServiceFactory.getInstance().getGroupService()
|
Group specialGroup = EPersonServiceFactory.getInstance().getGroupService()
|
||||||
.findByName(context, groupName);
|
.findByName(context, groupName);
|
||||||
if (specialGroup == null) {
|
if (specialGroup == null) {
|
||||||
@@ -195,9 +194,8 @@ public class PasswordAuthentication
|
|||||||
HttpServletRequest request)
|
HttpServletRequest request)
|
||||||
throws SQLException {
|
throws SQLException {
|
||||||
if (username != null && password != null) {
|
if (username != null && password != null) {
|
||||||
EPerson eperson = null;
|
|
||||||
log.info(LogManager.getHeader(context, "authenticate", "attempting password auth of user=" + username));
|
log.info(LogManager.getHeader(context, "authenticate", "attempting password auth of user=" + username));
|
||||||
eperson = EPersonServiceFactory.getInstance().getEPersonService()
|
EPerson eperson = EPersonServiceFactory.getInstance().getEPersonService()
|
||||||
.findByEmail(context, username.toLowerCase());
|
.findByEmail(context, username.toLowerCase());
|
||||||
|
|
||||||
if (eperson == null) {
|
if (eperson == null) {
|
||||||
|
@@ -11,7 +11,6 @@ import java.sql.SQLException;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@@ -228,7 +227,7 @@ public class AuthorizeServiceImpl implements AuthorizeService {
|
|||||||
// If authorization was given before and cached
|
// If authorization was given before and cached
|
||||||
Boolean cachedResult = c.getCachedAuthorizationResult(o, action, e);
|
Boolean cachedResult = c.getCachedAuthorizationResult(o, action, e);
|
||||||
if (cachedResult != null) {
|
if (cachedResult != null) {
|
||||||
return cachedResult.booleanValue();
|
return cachedResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
// is eperson set? if not, userToCheck = null (anonymous)
|
// is eperson set? if not, userToCheck = null (anonymous)
|
||||||
@@ -293,7 +292,7 @@ public class AuthorizeServiceImpl implements AuthorizeService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((rp.getGroup() != null)
|
if ((rp.getGroup() != null)
|
||||||
&& (groupService.isMember(c, e, rp.getGroup()))) {
|
&& groupService.isMember(c, e, rp.getGroup())) {
|
||||||
// group was set, and eperson is a member
|
// group was set, and eperson is a member
|
||||||
// of that group
|
// of that group
|
||||||
c.cacheAuthorizedAction(o, action, e, true, rp);
|
c.cacheAuthorizedAction(o, action, e, true, rp);
|
||||||
@@ -351,7 +350,7 @@ public class AuthorizeServiceImpl implements AuthorizeService {
|
|||||||
|
|
||||||
Boolean cachedResult = c.getCachedAuthorizationResult(o, Constants.ADMIN, e);
|
Boolean cachedResult = c.getCachedAuthorizationResult(o, Constants.ADMIN, e);
|
||||||
if (cachedResult != null) {
|
if (cachedResult != null) {
|
||||||
return cachedResult.booleanValue();
|
return cachedResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -368,7 +367,7 @@ public class AuthorizeServiceImpl implements AuthorizeService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((rp.getGroup() != null)
|
if ((rp.getGroup() != null)
|
||||||
&& (groupService.isMember(c, e, rp.getGroup()))) {
|
&& groupService.isMember(c, e, rp.getGroup())) {
|
||||||
// group was set, and eperson is a member
|
// group was set, and eperson is a member
|
||||||
// of that group
|
// of that group
|
||||||
c.cacheAuthorizedAction(o, Constants.ADMIN, e, true, rp);
|
c.cacheAuthorizedAction(o, Constants.ADMIN, e, true, rp);
|
||||||
@@ -428,6 +427,7 @@ public class AuthorizeServiceImpl implements AuthorizeService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isCommunityAdmin(Context c) throws SQLException {
|
public boolean isCommunityAdmin(Context c) throws SQLException {
|
||||||
EPerson e = c.getCurrentUser();
|
EPerson e = c.getCurrentUser();
|
||||||
return isCommunityAdmin(c, e);
|
return isCommunityAdmin(c, e);
|
||||||
@@ -448,6 +448,7 @@ public class AuthorizeServiceImpl implements AuthorizeService {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isCollectionAdmin(Context c) throws SQLException {
|
public boolean isCollectionAdmin(Context c) throws SQLException {
|
||||||
EPerson e = c.getCurrentUser();
|
EPerson e = c.getCurrentUser();
|
||||||
return isCollectionAdmin(c, e);
|
return isCollectionAdmin(c, e);
|
||||||
@@ -527,7 +528,7 @@ public class AuthorizeServiceImpl implements AuthorizeService {
|
|||||||
List<ResourcePolicy> policies = getPolicies(c, src);
|
List<ResourcePolicy> policies = getPolicies(c, src);
|
||||||
|
|
||||||
//Only inherit non-ADMIN policies (since ADMIN policies are automatically inherited)
|
//Only inherit non-ADMIN policies (since ADMIN policies are automatically inherited)
|
||||||
List<ResourcePolicy> nonAdminPolicies = new ArrayList<ResourcePolicy>();
|
List<ResourcePolicy> nonAdminPolicies = new ArrayList<>();
|
||||||
for (ResourcePolicy rp : policies) {
|
for (ResourcePolicy rp : policies) {
|
||||||
if (rp.getAction() != Constants.ADMIN) {
|
if (rp.getAction() != Constants.ADMIN) {
|
||||||
nonAdminPolicies.add(rp);
|
nonAdminPolicies.add(rp);
|
||||||
@@ -550,7 +551,7 @@ public class AuthorizeServiceImpl implements AuthorizeService {
|
|||||||
public void addPolicies(Context c, List<ResourcePolicy> policies, DSpaceObject dest)
|
public void addPolicies(Context c, List<ResourcePolicy> policies, DSpaceObject dest)
|
||||||
throws SQLException, AuthorizeException {
|
throws SQLException, AuthorizeException {
|
||||||
// now add them to the destination object
|
// now add them to the destination object
|
||||||
List<ResourcePolicy> newPolicies = new LinkedList<>();
|
List<ResourcePolicy> newPolicies = new ArrayList<>(policies.size());
|
||||||
|
|
||||||
for (ResourcePolicy srp : policies) {
|
for (ResourcePolicy srp : policies) {
|
||||||
ResourcePolicy rp = resourcePolicyService.create(c);
|
ResourcePolicy rp = resourcePolicyService.create(c);
|
||||||
@@ -625,7 +626,7 @@ public class AuthorizeServiceImpl implements AuthorizeService {
|
|||||||
int actionID) throws java.sql.SQLException {
|
int actionID) throws java.sql.SQLException {
|
||||||
List<ResourcePolicy> policies = getPoliciesActionFilter(c, o, actionID);
|
List<ResourcePolicy> policies = getPoliciesActionFilter(c, o, actionID);
|
||||||
|
|
||||||
List<Group> groups = new ArrayList<Group>();
|
List<Group> groups = new ArrayList<>();
|
||||||
for (ResourcePolicy resourcePolicy : policies) {
|
for (ResourcePolicy resourcePolicy : policies) {
|
||||||
if (resourcePolicy.getGroup() != null && resourcePolicyService.isDateValid(resourcePolicy)) {
|
if (resourcePolicy.getGroup() != null && resourcePolicyService.isDateValid(resourcePolicy)) {
|
||||||
groups.add(resourcePolicy.getGroup());
|
groups.add(resourcePolicy.getGroup());
|
||||||
|
@@ -170,7 +170,7 @@ public class MostRecentChecksum implements Serializable {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (o == null || getClass() != o.getClass()) {
|
if (o == null || !(o instanceof MostRecentChecksum)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -109,7 +109,7 @@ public class ResultsLogger implements ChecksumResultsCollector {
|
|||||||
"unknown"));
|
"unknown"));
|
||||||
LOG.info(msg("new-checksum") + ": " + info.getCurrentChecksum());
|
LOG.info(msg("new-checksum") + ": " + info.getCurrentChecksum());
|
||||||
LOG.info(msg("checksum-comparison-result") + ": "
|
LOG.info(msg("checksum-comparison-result") + ": "
|
||||||
+ (info.getChecksumResult().getResultCode()));
|
+ info.getChecksumResult().getResultCode());
|
||||||
LOG.info("\n\n");
|
LOG.info("\n\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -9,7 +9,7 @@ package org.dspace.content;
|
|||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.LinkedList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.persistence.CollectionTable;
|
import javax.persistence.CollectionTable;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
@@ -111,7 +111,7 @@ public class BitstreamFormat implements Serializable, ReloadableEntity<Integer>
|
|||||||
* {@link org.dspace.content.service.BitstreamFormatService#create(Context)}
|
* {@link org.dspace.content.service.BitstreamFormatService#create(Context)}
|
||||||
*/
|
*/
|
||||||
protected BitstreamFormat() {
|
protected BitstreamFormat() {
|
||||||
fileExtensions = new LinkedList<>();
|
fileExtensions = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -9,7 +9,6 @@ package org.dspace.content;
|
|||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
@@ -138,7 +137,7 @@ public class Bundle extends DSpaceObject implements DSpaceObjectLegacySupport {
|
|||||||
* @return the bitstreams
|
* @return the bitstreams
|
||||||
*/
|
*/
|
||||||
public List<Bitstream> getBitstreams() {
|
public List<Bitstream> getBitstreams() {
|
||||||
List<Bitstream> bitstreamList = new LinkedList<>(this.bitstreams);
|
List<Bitstream> bitstreamList = new ArrayList<>(this.bitstreams);
|
||||||
return bitstreamList;
|
return bitstreamList;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,7 +190,7 @@ public class Bundle extends DSpaceObject implements DSpaceObjectLegacySupport {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if (obj == null) {
|
if (obj == null || !(obj instanceof Bundle)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Class<?> objClass = HibernateProxyHelper.getClassWithoutInitializingProxy(obj);
|
Class<?> objClass = HibernateProxyHelper.getClassWithoutInitializingProxy(obj);
|
||||||
@@ -202,10 +201,7 @@ public class Bundle extends DSpaceObject implements DSpaceObjectLegacySupport {
|
|||||||
if (this.getType() != other.getType()) {
|
if (this.getType() != other.getType()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!this.getID().equals(other.getID())) {
|
return this.getID().equals(other.getID());
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -34,8 +34,8 @@ import org.apache.logging.log4j.Logger;
|
|||||||
* There are four levels of granularity, depending on how much date information
|
* There are four levels of granularity, depending on how much date information
|
||||||
* is available: year, month, day, time.
|
* is available: year, month, day, time.
|
||||||
* <P>
|
* <P>
|
||||||
* Examples: <code>1994-05-03T15:30:24</code>,<code>1995-10-04</code>,
|
* Examples: {@code 1994-05-03T15:30:24}, {@code 1995-10-04},
|
||||||
* <code>2001-10</code>,<code>1975</code>
|
* {@code 2001-10}, {@code 1975}
|
||||||
*
|
*
|
||||||
* @author Robert Tansley
|
* @author Robert Tansley
|
||||||
* @author Larry Stone
|
* @author Larry Stone
|
||||||
@@ -261,7 +261,7 @@ public class DCDate {
|
|||||||
* @return the year
|
* @return the year
|
||||||
*/
|
*/
|
||||||
public int getYear() {
|
public int getYear() {
|
||||||
return (!withinGranularity(DateGran.YEAR)) ? -1 : localCalendar.get(Calendar.YEAR);
|
return !withinGranularity(DateGran.YEAR) ? -1 : localCalendar.get(Calendar.YEAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -270,7 +270,7 @@ public class DCDate {
|
|||||||
* @return the month
|
* @return the month
|
||||||
*/
|
*/
|
||||||
public int getMonth() {
|
public int getMonth() {
|
||||||
return (!withinGranularity(DateGran.MONTH)) ? -1 : localCalendar.get(Calendar.MONTH) + 1;
|
return !withinGranularity(DateGran.MONTH) ? -1 : localCalendar.get(Calendar.MONTH) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -279,7 +279,7 @@ public class DCDate {
|
|||||||
* @return the day
|
* @return the day
|
||||||
*/
|
*/
|
||||||
public int getDay() {
|
public int getDay() {
|
||||||
return (!withinGranularity(DateGran.DAY)) ? -1 : localCalendar.get(Calendar.DAY_OF_MONTH);
|
return !withinGranularity(DateGran.DAY) ? -1 : localCalendar.get(Calendar.DAY_OF_MONTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -288,7 +288,7 @@ public class DCDate {
|
|||||||
* @return the hour
|
* @return the hour
|
||||||
*/
|
*/
|
||||||
public int getHour() {
|
public int getHour() {
|
||||||
return (!withinGranularity(DateGran.TIME)) ? -1 : localCalendar.get(Calendar.HOUR_OF_DAY);
|
return !withinGranularity(DateGran.TIME) ? -1 : localCalendar.get(Calendar.HOUR_OF_DAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -297,7 +297,7 @@ public class DCDate {
|
|||||||
* @return the minute
|
* @return the minute
|
||||||
*/
|
*/
|
||||||
public int getMinute() {
|
public int getMinute() {
|
||||||
return (!withinGranularity(DateGran.TIME)) ? -1 : localCalendar.get(Calendar.MINUTE);
|
return !withinGranularity(DateGran.TIME) ? -1 : localCalendar.get(Calendar.MINUTE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -306,7 +306,7 @@ public class DCDate {
|
|||||||
* @return the second
|
* @return the second
|
||||||
*/
|
*/
|
||||||
public int getSecond() {
|
public int getSecond() {
|
||||||
return (!withinGranularity(DateGran.TIME)) ? -1 : localCalendar.get(Calendar.SECOND);
|
return !withinGranularity(DateGran.TIME) ? -1 : localCalendar.get(Calendar.SECOND);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -315,7 +315,7 @@ public class DCDate {
|
|||||||
* @return the year
|
* @return the year
|
||||||
*/
|
*/
|
||||||
public int getYearUTC() {
|
public int getYearUTC() {
|
||||||
return (!withinGranularity(DateGran.YEAR)) ? -1 : calendar.get(Calendar.YEAR);
|
return !withinGranularity(DateGran.YEAR) ? -1 : calendar.get(Calendar.YEAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -324,7 +324,7 @@ public class DCDate {
|
|||||||
* @return the month
|
* @return the month
|
||||||
*/
|
*/
|
||||||
public int getMonthUTC() {
|
public int getMonthUTC() {
|
||||||
return (!withinGranularity(DateGran.MONTH)) ? -1 : calendar.get(Calendar.MONTH) + 1;
|
return !withinGranularity(DateGran.MONTH) ? -1 : calendar.get(Calendar.MONTH) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -333,7 +333,7 @@ public class DCDate {
|
|||||||
* @return the day
|
* @return the day
|
||||||
*/
|
*/
|
||||||
public int getDayUTC() {
|
public int getDayUTC() {
|
||||||
return (!withinGranularity(DateGran.DAY)) ? -1 : calendar.get(Calendar.DAY_OF_MONTH);
|
return !withinGranularity(DateGran.DAY) ? -1 : calendar.get(Calendar.DAY_OF_MONTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -342,7 +342,7 @@ public class DCDate {
|
|||||||
* @return the hour
|
* @return the hour
|
||||||
*/
|
*/
|
||||||
public int getHourUTC() {
|
public int getHourUTC() {
|
||||||
return (!withinGranularity(DateGran.TIME)) ? -1 : calendar.get(Calendar.HOUR_OF_DAY);
|
return !withinGranularity(DateGran.TIME) ? -1 : calendar.get(Calendar.HOUR_OF_DAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -351,7 +351,7 @@ public class DCDate {
|
|||||||
* @return the minute
|
* @return the minute
|
||||||
*/
|
*/
|
||||||
public int getMinuteUTC() {
|
public int getMinuteUTC() {
|
||||||
return (!withinGranularity(DateGran.TIME)) ? -1 : calendar.get(Calendar.MINUTE);
|
return !withinGranularity(DateGran.TIME) ? -1 : calendar.get(Calendar.MINUTE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -360,10 +360,9 @@ public class DCDate {
|
|||||||
* @return the second
|
* @return the second
|
||||||
*/
|
*/
|
||||||
public int getSecondUTC() {
|
public int getSecondUTC() {
|
||||||
return (!withinGranularity(DateGran.TIME)) ? -1 : calendar.get(Calendar.SECOND);
|
return !withinGranularity(DateGran.TIME) ? -1 : calendar.get(Calendar.SECOND);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the date as a string to put back in the Dublin Core. Use the UTC/GMT calendar version.
|
* Get the date as a string to put back in the Dublin Core. Use the UTC/GMT calendar version.
|
||||||
*
|
*
|
||||||
|
@@ -8,10 +8,9 @@
|
|||||||
package org.dspace.content;
|
package org.dspace.content;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Series and report number, as stored in relation.ispartofseries
|
* Series and report number, as stored in {@code relation.ispartofseries}.
|
||||||
*
|
*
|
||||||
* @author Robert Tansley
|
* @author Robert Tansley
|
||||||
* @version $Id$
|
|
||||||
*/
|
*/
|
||||||
public class DCSeriesNumber {
|
public class DCSeriesNumber {
|
||||||
/**
|
/**
|
||||||
@@ -70,6 +69,7 @@ public class DCSeriesNumber {
|
|||||||
*
|
*
|
||||||
* @return the series and number as they should be stored in the DB
|
* @return the series and number as they should be stored in the DB
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
if (series == null) {
|
if (series == null) {
|
||||||
return (null);
|
return (null);
|
||||||
|
@@ -13,7 +13,6 @@ import java.util.Arrays;
|
|||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
@@ -450,7 +449,7 @@ public abstract class DSpaceObjectServiceImpl<T extends DSpaceObject> implements
|
|||||||
clearMetadata(context, dso, field.schema, field.element, field.qualifier,
|
clearMetadata(context, dso, field.schema, field.element, field.qualifier,
|
||||||
language);
|
language);
|
||||||
|
|
||||||
String newValueLanguage = (Item.ANY.equals(language)) ? null : language;
|
String newValueLanguage = Item.ANY.equals(language) ? null : language;
|
||||||
addMetadata(context, dso, field.schema, field.element, field.qualifier,
|
addMetadata(context, dso, field.schema, field.element, field.qualifier,
|
||||||
newValueLanguage, value);
|
newValueLanguage, value);
|
||||||
dso.setMetadataModified();
|
dso.setMetadataModified();
|
||||||
@@ -595,7 +594,7 @@ public abstract class DSpaceObjectServiceImpl<T extends DSpaceObject> implements
|
|||||||
*/
|
*/
|
||||||
// A map created to store the latest place for each metadata field
|
// A map created to store the latest place for each metadata field
|
||||||
Map<MetadataField, Integer> fieldToLastPlace = new HashMap<>();
|
Map<MetadataField, Integer> fieldToLastPlace = new HashMap<>();
|
||||||
List<MetadataValue> metadataValues = new LinkedList<>();
|
List<MetadataValue> metadataValues;
|
||||||
if (dso.getType() == Constants.ITEM) {
|
if (dso.getType() == Constants.ITEM) {
|
||||||
metadataValues = getMetadata(dso, Item.ANY, Item.ANY, Item.ANY, Item.ANY);
|
metadataValues = getMetadata(dso, Item.ANY, Item.ANY, Item.ANY, Item.ANY);
|
||||||
} else {
|
} else {
|
||||||
@@ -628,7 +627,7 @@ public abstract class DSpaceObjectServiceImpl<T extends DSpaceObject> implements
|
|||||||
String authority = metadataValue.getAuthority();
|
String authority = metadataValue.getAuthority();
|
||||||
String relationshipId = StringUtils.split(authority, "::")[1];
|
String relationshipId = StringUtils.split(authority, "::")[1];
|
||||||
Relationship relationship = relationshipService.find(context, Integer.parseInt(relationshipId));
|
Relationship relationship = relationshipService.find(context, Integer.parseInt(relationshipId));
|
||||||
if (relationship.getLeftItem() == (Item) dso) {
|
if (relationship.getLeftItem().equals((Item) dso)) {
|
||||||
relationship.setLeftPlace(mvPlace);
|
relationship.setLeftPlace(mvPlace);
|
||||||
} else {
|
} else {
|
||||||
relationship.setRightPlace(mvPlace);
|
relationship.setRightPlace(mvPlace);
|
||||||
|
@@ -78,6 +78,7 @@ public class EntityType implements ReloadableEntity<Integer> {
|
|||||||
*
|
*
|
||||||
* @return The ID for this EntityType
|
* @return The ID for this EntityType
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Integer getID() {
|
public Integer getID() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
@@ -87,6 +88,7 @@ public class EntityType implements ReloadableEntity<Integer> {
|
|||||||
* @param obj object to be compared
|
* @param obj object to be compared
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if (!(obj instanceof EntityType)) {
|
if (!(obj instanceof EntityType)) {
|
||||||
return false;
|
return false;
|
||||||
@@ -97,10 +99,7 @@ public class EntityType implements ReloadableEntity<Integer> {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!StringUtils.equals(this.getLabel(), entityType.getLabel())) {
|
return StringUtils.equals(this.getLabel(), entityType.getLabel());
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -218,6 +218,7 @@ public class Relationship implements ReloadableEntity<Integer> {
|
|||||||
* Standard getter for the ID for this Relationship
|
* Standard getter for the ID for this Relationship
|
||||||
* @return The ID of this relationship
|
* @return The ID of this relationship
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Integer getID() {
|
public Integer getID() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
@@ -201,7 +201,7 @@ public class RelationshipType implements ReloadableEntity<Integer> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Standard setter for the leftMinCardinality Integer for this RelationshipType
|
* Standard setter for the leftMinCardinality Integer for this RelationshipType
|
||||||
* @param leftMinCardinality The leftMinCardinality Integer that this RelationshipType should recieve
|
* @param leftMinCardinality The leftMinCardinality Integer that this RelationshipType should receive
|
||||||
*/
|
*/
|
||||||
public void setLeftMinCardinality(Integer leftMinCardinality) {
|
public void setLeftMinCardinality(Integer leftMinCardinality) {
|
||||||
this.leftMinCardinality = leftMinCardinality;
|
this.leftMinCardinality = leftMinCardinality;
|
||||||
@@ -217,7 +217,7 @@ public class RelationshipType implements ReloadableEntity<Integer> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Standard setter for the leftMaxCardinality Integer for this RelationshipType
|
* Standard setter for the leftMaxCardinality Integer for this RelationshipType
|
||||||
* @param leftMaxCardinality The leftMaxCardinality Integer that this RelationshipType should recieve
|
* @param leftMaxCardinality The leftMaxCardinality Integer that this RelationshipType should receive
|
||||||
*/
|
*/
|
||||||
public void setLeftMaxCardinality(Integer leftMaxCardinality) {
|
public void setLeftMaxCardinality(Integer leftMaxCardinality) {
|
||||||
this.leftMaxCardinality = leftMaxCardinality;
|
this.leftMaxCardinality = leftMaxCardinality;
|
||||||
@@ -233,7 +233,7 @@ public class RelationshipType implements ReloadableEntity<Integer> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Standard setter for the rightMinCardinality Integer for this RelationshipType
|
* Standard setter for the rightMinCardinality Integer for this RelationshipType
|
||||||
* @param rightMinCardinality The rightMinCardinality Integer that this RelationshipType should recieve
|
* @param rightMinCardinality The rightMinCardinality Integer that this RelationshipType should receive
|
||||||
*/
|
*/
|
||||||
public void setRightMinCardinality(Integer rightMinCardinality) {
|
public void setRightMinCardinality(Integer rightMinCardinality) {
|
||||||
this.rightMinCardinality = rightMinCardinality;
|
this.rightMinCardinality = rightMinCardinality;
|
||||||
@@ -249,7 +249,7 @@ public class RelationshipType implements ReloadableEntity<Integer> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Standard setter for the rightMaxCardinality Integer for this RelationshipType
|
* Standard setter for the rightMaxCardinality Integer for this RelationshipType
|
||||||
* @param rightMaxCardinality The rightMaxCardinality Integer that this RelationshipType should recieve
|
* @param rightMaxCardinality The rightMaxCardinality Integer that this RelationshipType should receive
|
||||||
*/
|
*/
|
||||||
public void setRightMaxCardinality(Integer rightMaxCardinality) {
|
public void setRightMaxCardinality(Integer rightMaxCardinality) {
|
||||||
this.rightMaxCardinality = rightMaxCardinality;
|
this.rightMaxCardinality = rightMaxCardinality;
|
||||||
@@ -291,6 +291,7 @@ public class RelationshipType implements ReloadableEntity<Integer> {
|
|||||||
* Standard getter for the ID of this RelationshipType
|
* Standard getter for the ID of this RelationshipType
|
||||||
* @return The ID of this RelationshipType
|
* @return The ID of this RelationshipType
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Integer getID() {
|
public Integer getID() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
package org.dspace.content.dao.impl;
|
package org.dspace.content.dao.impl;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.LinkedList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.persistence.Query;
|
import javax.persistence.Query;
|
||||||
import javax.persistence.criteria.CriteriaBuilder;
|
import javax.persistence.criteria.CriteriaBuilder;
|
||||||
@@ -63,7 +63,7 @@ public class MetadataSchemaDAOImpl extends AbstractHibernateDAO<MetadataSchema>
|
|||||||
Root<MetadataSchema> metadataSchemaRoot = criteriaQuery.from(MetadataSchema.class);
|
Root<MetadataSchema> metadataSchemaRoot = criteriaQuery.from(MetadataSchema.class);
|
||||||
criteriaQuery.select(metadataSchemaRoot);
|
criteriaQuery.select(metadataSchemaRoot);
|
||||||
|
|
||||||
List<javax.persistence.criteria.Order> orderList = new LinkedList<>();
|
List<javax.persistence.criteria.Order> orderList = new ArrayList<>();
|
||||||
orderList.add(criteriaBuilder.asc(metadataSchemaRoot.get(MetadataSchema_.id)));
|
orderList.add(criteriaBuilder.asc(metadataSchemaRoot.get(MetadataSchema_.id)));
|
||||||
criteriaQuery.orderBy(orderList);
|
criteriaQuery.orderBy(orderList);
|
||||||
|
|
||||||
|
@@ -19,7 +19,6 @@ import org.apache.logging.log4j.Logger;
|
|||||||
* exceptions. This class is intended for declarations and catch clauses.
|
* exceptions. This class is intended for declarations and catch clauses.
|
||||||
*
|
*
|
||||||
* @author Larry Stone
|
* @author Larry Stone
|
||||||
* @version $Revision$
|
|
||||||
*/
|
*/
|
||||||
public class PackageException extends Exception {
|
public class PackageException extends Exception {
|
||||||
/**
|
/**
|
||||||
@@ -76,10 +75,4 @@ public class PackageException extends Exception {
|
|||||||
log.error(sw.toString());
|
log.error(sw.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
|
||||||
String base = getClass().getName() + ": " + getMessage();
|
|
||||||
return (getCause() == null) ? base :
|
|
||||||
base + ", Reason: " + getCause().toString();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -57,7 +57,7 @@ public class PackageParameters extends Properties {
|
|||||||
} else if (v.length == 1) {
|
} else if (v.length == 1) {
|
||||||
result.setProperty(name, v[0]);
|
result.setProperty(name, v[0]);
|
||||||
} else {
|
} else {
|
||||||
StringBuffer sb = new StringBuffer();
|
StringBuilder sb = new StringBuilder();
|
||||||
for (int i = 0; i < v.length; ++i) {
|
for (int i = 0; i < v.length; ++i) {
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
sb.append(SEPARATOR);
|
sb.append(SEPARATOR);
|
||||||
|
@@ -8,7 +8,6 @@
|
|||||||
package org.dspace.content.virtual;
|
package org.dspace.content.virtual;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
@@ -24,9 +23,7 @@ public class UUIDValue implements VirtualMetadataConfiguration {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getValues(Context context, Item item) throws SQLException {
|
public List<String> getValues(Context context, Item item) throws SQLException {
|
||||||
List<String> list = new LinkedList<>();
|
return List.of(String.valueOf(item.getID()));
|
||||||
list.add(String.valueOf(item.getID()));
|
|
||||||
return list;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -8,13 +8,13 @@
|
|||||||
package org.dspace.core;
|
package org.dspace.core;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayDeque;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.EmptyStackException;
|
import java.util.EmptyStackException;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.Stack;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
@@ -79,13 +79,13 @@ public class Context implements AutoCloseable {
|
|||||||
/**
|
/**
|
||||||
* A stack with the history of authorisation system check modify
|
* A stack with the history of authorisation system check modify
|
||||||
*/
|
*/
|
||||||
private Stack<Boolean> authStateChangeHistory;
|
private ArrayDeque<Boolean> authStateChangeHistory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A stack with the name of the caller class that modify authorisation
|
* A stack with the name of the caller class that modify authorisation
|
||||||
* system check
|
* system check
|
||||||
*/
|
*/
|
||||||
private Stack<String> authStateClassCallHistory;
|
private ArrayDeque<String> authStateClassCallHistory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Group IDs of special groups user is a member of
|
* Group IDs of special groups user is a member of
|
||||||
@@ -115,7 +115,7 @@ public class Context implements AutoCloseable {
|
|||||||
/**
|
/**
|
||||||
* Cache that is only used the context is in READ_ONLY mode
|
* Cache that is only used the context is in READ_ONLY mode
|
||||||
*/
|
*/
|
||||||
private ContextReadOnlyCache readOnlyCache = new ContextReadOnlyCache();
|
private final ContextReadOnlyCache readOnlyCache = new ContextReadOnlyCache();
|
||||||
|
|
||||||
protected EventService eventService;
|
protected EventService eventService;
|
||||||
|
|
||||||
@@ -183,8 +183,8 @@ public class Context implements AutoCloseable {
|
|||||||
|
|
||||||
specialGroups = new ArrayList<>();
|
specialGroups = new ArrayList<>();
|
||||||
|
|
||||||
authStateChangeHistory = new Stack<>();
|
authStateChangeHistory = new ArrayDeque<>();
|
||||||
authStateClassCallHistory = new Stack<>();
|
authStateClassCallHistory = new ArrayDeque<>();
|
||||||
setMode(this.mode);
|
setMode(this.mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -336,7 +336,7 @@ public class Context implements AutoCloseable {
|
|||||||
+ previousCaller));
|
+ previousCaller));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ignoreAuth = previousState.booleanValue();
|
ignoreAuth = previousState;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -488,7 +488,7 @@ public class Context implements AutoCloseable {
|
|||||||
throw new IllegalStateException("Attempt to mutate object in read-only context");
|
throw new IllegalStateException("Attempt to mutate object in read-only context");
|
||||||
}
|
}
|
||||||
if (events == null) {
|
if (events == null) {
|
||||||
events = new LinkedList<Event>();
|
events = new LinkedList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
events.add(event);
|
events.add(event);
|
||||||
@@ -622,11 +622,7 @@ public class Context implements AutoCloseable {
|
|||||||
* @return true if member
|
* @return true if member
|
||||||
*/
|
*/
|
||||||
public boolean inSpecialGroup(UUID groupID) {
|
public boolean inSpecialGroup(UUID groupID) {
|
||||||
if (specialGroups.contains(groupID)) {
|
return specialGroups.contains(groupID);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -636,7 +632,7 @@ public class Context implements AutoCloseable {
|
|||||||
* @throws SQLException if database error
|
* @throws SQLException if database error
|
||||||
*/
|
*/
|
||||||
public List<Group> getSpecialGroups() throws SQLException {
|
public List<Group> getSpecialGroups() throws SQLException {
|
||||||
List<Group> myGroups = new ArrayList<Group>();
|
List<Group> myGroups = new ArrayList<>();
|
||||||
for (UUID groupId : specialGroups) {
|
for (UUID groupId : specialGroups) {
|
||||||
myGroups.add(EPersonServiceFactory.getInstance().getGroupService().find(this, groupId));
|
myGroups.add(EPersonServiceFactory.getInstance().getGroupService().find(this, groupId));
|
||||||
}
|
}
|
||||||
@@ -661,7 +657,7 @@ public class Context implements AutoCloseable {
|
|||||||
|
|
||||||
currentUserPreviousState = currentUser;
|
currentUserPreviousState = currentUser;
|
||||||
specialGroupsPreviousState = specialGroups;
|
specialGroupsPreviousState = specialGroups;
|
||||||
specialGroups = new ArrayList<UUID>();
|
specialGroups = new ArrayList<>();
|
||||||
currentUser = newUser;
|
currentUser = newUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -703,11 +699,13 @@ public class Context implements AutoCloseable {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the size of the cache of all object that have been read from the database so far. A larger number
|
* Returns the size of the cache of all object that have been read from the
|
||||||
* means that more memory is consumed by the cache. This also has a negative impact on the query performance. In
|
* database so far. A larger number means that more memory is consumed by
|
||||||
* that case you should consider uncaching entities when they are no longer needed (see
|
* the cache. This also has a negative impact on the query performance. In
|
||||||
* {@link Context#uncacheEntity(ReloadableEntity)} () uncacheEntity}).
|
* that case you should consider uncaching entities when they are no longer
|
||||||
|
* needed (see {@link Context#uncacheEntity(ReloadableEntity)} () uncacheEntity}).
|
||||||
*
|
*
|
||||||
|
* @return cache size.
|
||||||
* @throws SQLException When connecting to the active cache fails.
|
* @throws SQLException When connecting to the active cache fails.
|
||||||
*/
|
*/
|
||||||
public long getCacheSize() throws SQLException {
|
public long getCacheSize() throws SQLException {
|
||||||
|
@@ -320,11 +320,11 @@ public class I18nUtil {
|
|||||||
fileType = "";
|
fileType = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!("".equals(locale.getCountry()))) {
|
if (!"".equals(locale.getCountry())) {
|
||||||
fileNameLC = fileName + "_" + locale.getLanguage() + "_"
|
fileNameLC = fileName + "_" + locale.getLanguage() + "_"
|
||||||
+ locale.getCountry();
|
+ locale.getCountry();
|
||||||
|
|
||||||
if (!("".equals(locale.getVariant()))) {
|
if (!"".equals(locale.getVariant())) {
|
||||||
fileNameLCV = fileName + "_" + locale.getLanguage() + "_"
|
fileNameLCV = fileName + "_" + locale.getLanguage() + "_"
|
||||||
+ locale.getCountry() + "_" + locale.getVariant();
|
+ locale.getCountry() + "_" + locale.getVariant();
|
||||||
}
|
}
|
||||||
|
@@ -13,16 +13,17 @@ import java.io.File;
|
|||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FileTaskQueue provides a TaskQueue implementation based on flat files
|
* FileTaskQueue provides a TaskQueue implementation based on flat files
|
||||||
* for the queues and semaphores.
|
* for the queues and semaphores.
|
||||||
@@ -30,14 +31,16 @@ import org.dspace.services.factory.DSpaceServicesFactory;
|
|||||||
* @author richardrodgers
|
* @author richardrodgers
|
||||||
*/
|
*/
|
||||||
public class FileTaskQueue implements TaskQueue {
|
public class FileTaskQueue implements TaskQueue {
|
||||||
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(TaskQueue.class);
|
private static final Logger log = LogManager.getLogger(TaskQueue.class);
|
||||||
|
|
||||||
// base directory for curation task queues
|
// base directory for curation task queues
|
||||||
protected String tqDir;
|
protected String tqDir;
|
||||||
|
|
||||||
// ticket for queue readers
|
// ticket for queue readers
|
||||||
protected long readTicket = -1L;
|
protected long readTicket = -1L;
|
||||||
|
|
||||||
// list of queues owned by reader
|
// list of queues owned by reader
|
||||||
protected List<Integer> readList = new ArrayList<Integer>();
|
protected List<Integer> readList = new ArrayList<>();
|
||||||
|
|
||||||
public FileTaskQueue() {
|
public FileTaskQueue() {
|
||||||
tqDir = DSpaceServicesFactory.getInstance().getConfigurationService().getProperty("curate.taskqueue.dir");
|
tqDir = DSpaceServicesFactory.getInstance().getConfigurationService().getProperty("curate.taskqueue.dir");
|
||||||
@@ -72,7 +75,7 @@ public class FileTaskQueue implements TaskQueue {
|
|||||||
BufferedWriter writer = null;
|
BufferedWriter writer = null;
|
||||||
try {
|
try {
|
||||||
File queue = new File(qDir, "queue" + Integer.toString(queueIdx));
|
File queue = new File(qDir, "queue" + Integer.toString(queueIdx));
|
||||||
writer = new BufferedWriter(new FileWriter(queue, true));
|
writer = new BufferedWriter(new FileWriter(queue, StandardCharsets.UTF_8, true));
|
||||||
Iterator<TaskQueueEntry> iter = entrySet.iterator();
|
Iterator<TaskQueueEntry> iter = entrySet.iterator();
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
writer.write(iter.next().toString());
|
writer.write(iter.next().toString());
|
||||||
@@ -96,7 +99,7 @@ public class FileTaskQueue implements TaskQueue {
|
|||||||
@Override
|
@Override
|
||||||
public synchronized Set<TaskQueueEntry> dequeue(String queueName, long ticket)
|
public synchronized Set<TaskQueueEntry> dequeue(String queueName, long ticket)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
Set<TaskQueueEntry> entrySet = new HashSet<TaskQueueEntry>();
|
Set<TaskQueueEntry> entrySet = new HashSet<>();
|
||||||
if (readTicket == -1L) {
|
if (readTicket == -1L) {
|
||||||
// hold the ticket & copy all Ids available, locking queues
|
// hold the ticket & copy all Ids available, locking queues
|
||||||
// stop when no more queues or one found locked
|
// stop when no more queues or one found locked
|
||||||
@@ -113,8 +116,8 @@ public class FileTaskQueue implements TaskQueue {
|
|||||||
// read contents from file
|
// read contents from file
|
||||||
BufferedReader reader = null;
|
BufferedReader reader = null;
|
||||||
try {
|
try {
|
||||||
reader = new BufferedReader(new FileReader(queue));
|
reader = new BufferedReader(new FileReader(queue, StandardCharsets.UTF_8));
|
||||||
String entryStr = null;
|
String entryStr;
|
||||||
while ((entryStr = reader.readLine()) != null) {
|
while ((entryStr = reader.readLine()) != null) {
|
||||||
entryStr = entryStr.trim();
|
entryStr = entryStr.trim();
|
||||||
if (entryStr.length() > 0) {
|
if (entryStr.length() > 0) {
|
||||||
|
@@ -24,7 +24,7 @@ public class ResolvedTask {
|
|||||||
private CurationTask cTask;
|
private CurationTask cTask;
|
||||||
private ScriptedTask sTask;
|
private ScriptedTask sTask;
|
||||||
// local name of task
|
// local name of task
|
||||||
private String taskName;
|
private final String taskName;
|
||||||
// annotation data
|
// annotation data
|
||||||
private boolean distributive = false;
|
private boolean distributive = false;
|
||||||
private boolean mutative = false;
|
private boolean mutative = false;
|
||||||
@@ -76,7 +76,7 @@ public class ResolvedTask {
|
|||||||
* @throws IOException if error
|
* @throws IOException if error
|
||||||
*/
|
*/
|
||||||
public int perform(DSpaceObject dso) throws IOException {
|
public int perform(DSpaceObject dso) throws IOException {
|
||||||
return (unscripted()) ? cTask.perform(dso) : sTask.performDso(dso);
|
return unscripted() ? cTask.perform(dso) : sTask.performDso(dso);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -88,7 +88,7 @@ public class ResolvedTask {
|
|||||||
* @throws IOException if error
|
* @throws IOException if error
|
||||||
*/
|
*/
|
||||||
public int perform(Context ctx, String id) throws IOException {
|
public int perform(Context ctx, String id) throws IOException {
|
||||||
return (unscripted()) ? cTask.perform(ctx, id) : sTask.performId(ctx, id);
|
return unscripted() ? cTask.perform(ctx, id) : sTask.performId(ctx, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -33,9 +33,9 @@ public class DiscoverQuery {
|
|||||||
* Main attributes for the discovery query
|
* Main attributes for the discovery query
|
||||||
**/
|
**/
|
||||||
private String query;
|
private String query;
|
||||||
private List<String> filterQueries;
|
private final List<String> filterQueries;
|
||||||
private List<String> dspaceObjectFilters = new ArrayList<>();
|
private List<String> dspaceObjectFilters = new ArrayList<>();
|
||||||
private List<String> fieldPresentQueries;
|
private final List<String> fieldPresentQueries;
|
||||||
private boolean spellCheck;
|
private boolean spellCheck;
|
||||||
|
|
||||||
private int start = 0;
|
private int start = 0;
|
||||||
@@ -55,36 +55,35 @@ public class DiscoverQuery {
|
|||||||
/**
|
/**
|
||||||
* Attributes required for the faceting of values
|
* Attributes required for the faceting of values
|
||||||
**/
|
**/
|
||||||
private List<DiscoverFacetField> facetFields;
|
private final List<DiscoverFacetField> facetFields;
|
||||||
private List<String> facetQueries;
|
private final List<String> facetQueries;
|
||||||
private int facetLimit = -1;
|
|
||||||
private int facetMinCount = -1;
|
private int facetMinCount = -1;
|
||||||
private int facetOffset = 0;
|
private int facetOffset = 0;
|
||||||
private Map<String, DiscoverHitHighlightingField> hitHighlighting;
|
private final Map<String, DiscoverHitHighlightingField> hitHighlighting;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used when you want to search for a specific field value
|
* Used when you want to search for a specific field value
|
||||||
**/
|
**/
|
||||||
private List<String> searchFields;
|
private final List<String> searchFields;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Misc attributes can be implementation dependent
|
* Misc attributes can be implementation dependent
|
||||||
**/
|
**/
|
||||||
private Map<String, List<String>> properties;
|
private final Map<String, List<String>> properties;
|
||||||
|
|
||||||
private String discoveryConfigurationName;
|
private String discoveryConfigurationName;
|
||||||
|
|
||||||
public DiscoverQuery() {
|
public DiscoverQuery() {
|
||||||
//Initialize all our lists
|
//Initialize all our lists
|
||||||
this.filterQueries = new ArrayList<String>();
|
this.filterQueries = new ArrayList<>();
|
||||||
this.fieldPresentQueries = new ArrayList<String>();
|
this.fieldPresentQueries = new ArrayList<>();
|
||||||
|
|
||||||
this.facetFields = new ArrayList<DiscoverFacetField>();
|
this.facetFields = new ArrayList<>();
|
||||||
this.facetQueries = new ArrayList<String>();
|
this.facetQueries = new ArrayList<>();
|
||||||
this.searchFields = new ArrayList<String>();
|
this.searchFields = new ArrayList<>();
|
||||||
this.hitHighlighting = new HashMap<String, DiscoverHitHighlightingField>();
|
this.hitHighlighting = new HashMap<>();
|
||||||
//Use a linked hashmap since sometimes insertion order might matter
|
//Use a linked hashmap since sometimes insertion order might matter
|
||||||
this.properties = new LinkedHashMap<String, List<String>>();
|
this.properties = new LinkedHashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -309,7 +308,7 @@ public class DiscoverQuery {
|
|||||||
public void addProperty(String property, String value) {
|
public void addProperty(String property, String value) {
|
||||||
List<String> toAddList = properties.get(property);
|
List<String> toAddList = properties.get(property);
|
||||||
if (toAddList == null) {
|
if (toAddList == null) {
|
||||||
toAddList = new ArrayList<String>();
|
toAddList = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
toAddList.add(value);
|
toAddList.add(value);
|
||||||
@@ -322,7 +321,7 @@ public class DiscoverQuery {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<DiscoverHitHighlightingField> getHitHighlightingFields() {
|
public List<DiscoverHitHighlightingField> getHitHighlightingFields() {
|
||||||
return new ArrayList<DiscoverHitHighlightingField>(hitHighlighting.values());
|
return new ArrayList<>(hitHighlighting.values());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addHitHighlightingField(DiscoverHitHighlightingField hitHighlighting) {
|
public void addHitHighlightingField(DiscoverHitHighlightingField hitHighlighting) {
|
||||||
@@ -368,7 +367,7 @@ public class DiscoverQuery {
|
|||||||
|
|
||||||
private List<String> buildFacetQueriesWithGap(int newestYear, int oldestYear, String dateFacet, int gap,
|
private List<String> buildFacetQueriesWithGap(int newestYear, int oldestYear, String dateFacet, int gap,
|
||||||
int topYear, int facetLimit) {
|
int topYear, int facetLimit) {
|
||||||
List<String> facetQueries = new LinkedList<>();
|
List<String> facetQueries = new ArrayList<>();
|
||||||
for (int year = topYear; year > oldestYear && (facetQueries.size() < facetLimit); year -= gap) {
|
for (int year = topYear; year > oldestYear && (facetQueries.size() < facetLimit); year -= gap) {
|
||||||
//Add a filter to remove the last year only if we aren't the last year
|
//Add a filter to remove the last year only if we aren't the last year
|
||||||
int bottomYear = year - gap;
|
int bottomYear = year - gap;
|
||||||
@@ -392,7 +391,7 @@ public class DiscoverQuery {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private int getTopYear(int newestYear, int gap) {
|
private int getTopYear(int newestYear, int gap) {
|
||||||
return (int) (Math.ceil((float) (newestYear) / gap) * gap);
|
return (int) (Math.ceil((float) newestYear / gap) * gap);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -179,6 +179,11 @@ public class FullTextContentStreams extends ContentStreamBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link Enumeration} is implemented because instances of this class are
|
||||||
|
* passed to a JDK class that requires this obsolete type.
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("JdkObsolete")
|
||||||
private static class FullTextEnumeration implements Enumeration<InputStream> {
|
private static class FullTextEnumeration implements Enumeration<InputStream> {
|
||||||
|
|
||||||
private final Iterator<FullTextBitstream> fulltextIterator;
|
private final Iterator<FullTextBitstream> fulltextIterator;
|
||||||
|
@@ -55,7 +55,7 @@ public class SolrServiceFileInfoPlugin implements SolrServiceIndexPlugin {
|
|||||||
document.addField(SOLR_FIELD_NAME_FOR_FILENAMES, bitstream.getName());
|
document.addField(SOLR_FIELD_NAME_FOR_FILENAMES, bitstream.getName());
|
||||||
|
|
||||||
String description = bitstream.getDescription();
|
String description = bitstream.getDescription();
|
||||||
if ((description != null) && (!description.isEmpty())) {
|
if ((description != null) && !description.isEmpty()) {
|
||||||
document.addField(SOLR_FIELD_NAME_FOR_DESCRIPTIONS, description);
|
document.addField(SOLR_FIELD_NAME_FOR_DESCRIPTIONS, description);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -14,10 +14,13 @@ import org.dspace.discovery.IndexableObject;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This class exists in order to provide a default implementation for the equals and hashCode methods.
|
* This class exists in order to provide a default implementation for the equals and hashCode methods.
|
||||||
* Since IndexableObjects can be made multiple times for the same underlying object, we needed a more finetuned
|
* Since IndexableObjects can be made multiple times for the same underlying
|
||||||
* equals and hashcode methods. We're simply checking that the underlying objects are equal and generating the hashcode
|
* object, we needed more finely-tuned {@link equals} and {@link hashCode} methods.
|
||||||
* for the underlying object. This way, we'll always get a proper result when calling equals or hashcode on an
|
* We're simply checking that the underlying objects are equal and returning the
|
||||||
* IndexableObject because it'll depend on the underlying object
|
* hash-code for the underlying object. This way, we'll always get a proper
|
||||||
|
* result when calling {@link equals} or {@link hashCode} on an IndexableObject
|
||||||
|
* because it'll depend on the underlying object.
|
||||||
|
*
|
||||||
* @param <T> Refers to the underlying entity that is linked to this object
|
* @param <T> Refers to the underlying entity that is linked to this object
|
||||||
* @param <PK> The type of ID that this entity uses
|
* @param <PK> The type of ID that this entity uses
|
||||||
*/
|
*/
|
||||||
@@ -30,7 +33,7 @@ public abstract class AbstractIndexableObject<T extends ReloadableEntity<PK>, PK
|
|||||||
if (!(obj instanceof AbstractIndexableObject)) {
|
if (!(obj instanceof AbstractIndexableObject)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
IndexableDSpaceObject other = (IndexableDSpaceObject) obj;
|
AbstractIndexableObject other = (AbstractIndexableObject) obj;
|
||||||
return other.getIndexedObject().equals(getIndexedObject());
|
return other.getIndexedObject().equals(getIndexedObject());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -53,6 +53,7 @@ public class Subscription implements ReloadableEntity<Integer> {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Integer getID() {
|
public Integer getID() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
@@ -8,6 +8,7 @@
|
|||||||
package org.dspace.eperson.dao.impl;
|
package org.dspace.eperson.dao.impl;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.persistence.Query;
|
import javax.persistence.Query;
|
||||||
@@ -97,7 +98,7 @@ public class SubscriptionDAOImpl extends AbstractHibernateDAO<Subscription> impl
|
|||||||
Root<Subscription> subscriptionRoot = criteriaQuery.from(Subscription.class);
|
Root<Subscription> subscriptionRoot = criteriaQuery.from(Subscription.class);
|
||||||
criteriaQuery.select(subscriptionRoot);
|
criteriaQuery.select(subscriptionRoot);
|
||||||
|
|
||||||
List<javax.persistence.criteria.Order> orderList = new LinkedList<>();
|
List<javax.persistence.criteria.Order> orderList = new ArrayList<>(1);
|
||||||
orderList.add(criteriaBuilder.asc(subscriptionRoot.get(Subscription_.ePerson)));
|
orderList.add(criteriaBuilder.asc(subscriptionRoot.get(Subscription_.ePerson)));
|
||||||
criteriaQuery.orderBy(orderList);
|
criteriaQuery.orderBy(orderList);
|
||||||
|
|
||||||
|
@@ -8,6 +8,7 @@
|
|||||||
package org.dspace.external;
|
package org.dspace.external;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
@@ -15,6 +16,7 @@ import org.apache.http.HttpResponse;
|
|||||||
import org.apache.http.client.HttpClient;
|
import org.apache.http.client.HttpClient;
|
||||||
import org.apache.http.client.methods.HttpGet;
|
import org.apache.http.client.methods.HttpGet;
|
||||||
import org.apache.http.impl.client.HttpClientBuilder;
|
import org.apache.http.impl.client.HttpClientBuilder;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -28,9 +30,9 @@ public class OrcidRestConnector {
|
|||||||
/**
|
/**
|
||||||
* log4j logger
|
* log4j logger
|
||||||
*/
|
*/
|
||||||
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(OrcidRestConnector.class);
|
private static final Logger log = LogManager.getLogger(OrcidRestConnector.class);
|
||||||
|
|
||||||
private String url;
|
private final String url;
|
||||||
|
|
||||||
public OrcidRestConnector(String url) {
|
public OrcidRestConnector(String url) {
|
||||||
this.url = url;
|
this.url = url;
|
||||||
@@ -73,7 +75,7 @@ public class OrcidRestConnector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String convertStreamToString(InputStream is) {
|
public static String convertStreamToString(InputStream is) {
|
||||||
Scanner s = new Scanner(is).useDelimiter("\\A");
|
Scanner s = new Scanner(is, StandardCharsets.UTF_8).useDelimiter("\\A");
|
||||||
return s.hasNext() ? s.next() : "";
|
return s.hasNext() ? s.next() : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -7,7 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.dspace.external.model;
|
package org.dspace.external.model;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.dspace.content.dto.MetadataValueDTO;
|
import org.dspace.content.dto.MetadataValueDTO;
|
||||||
@@ -32,7 +32,7 @@ public class ExternalDataObject {
|
|||||||
/**
|
/**
|
||||||
* The list of Metadata values. These our MetadataValueDTO because they won't exist in the DB
|
* The list of Metadata values. These our MetadataValueDTO because they won't exist in the DB
|
||||||
*/
|
*/
|
||||||
private List<MetadataValueDTO> metadata = new LinkedList<>();
|
private List<MetadataValueDTO> metadata = new ArrayList<>();
|
||||||
/**
|
/**
|
||||||
* The display value of the ExternalDataObject
|
* The display value of the ExternalDataObject
|
||||||
*/
|
*/
|
||||||
@@ -87,11 +87,11 @@ public class ExternalDataObject {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This method will add a Metadata value to the list of metadata values
|
* This method will add a Metadata value to the list of metadata values
|
||||||
* @param metadataValueDTO The metadatavalue to be added
|
* @param metadataValueDTO The metadata value to be added.
|
||||||
*/
|
*/
|
||||||
public void addMetadata(MetadataValueDTO metadataValueDTO) {
|
public void addMetadata(MetadataValueDTO metadataValueDTO) {
|
||||||
if (metadata == null) {
|
if (metadata == null) {
|
||||||
metadata = new LinkedList<>();
|
metadata = new ArrayList<>();
|
||||||
}
|
}
|
||||||
metadata.add(metadataValueDTO);
|
metadata.add(metadataValueDTO);
|
||||||
}
|
}
|
||||||
|
@@ -13,7 +13,6 @@ import javax.xml.bind.JAXBContext;
|
|||||||
import javax.xml.bind.JAXBException;
|
import javax.xml.bind.JAXBException;
|
||||||
import javax.xml.bind.Unmarshaller;
|
import javax.xml.bind.Unmarshaller;
|
||||||
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -25,11 +24,6 @@ import org.xml.sax.SAXException;
|
|||||||
*/
|
*/
|
||||||
public abstract class Converter<T> {
|
public abstract class Converter<T> {
|
||||||
|
|
||||||
/**
|
|
||||||
* log4j logger
|
|
||||||
*/
|
|
||||||
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(Converter.class);
|
|
||||||
|
|
||||||
public abstract T convert(InputStream document);
|
public abstract T convert(InputStream document);
|
||||||
|
|
||||||
protected Object unmarshall(InputStream input, Class<?> type) throws SAXException, URISyntaxException {
|
protected Object unmarshall(InputStream input, Class<?> type) throws SAXException, URISyntaxException {
|
||||||
|
@@ -56,6 +56,7 @@ public class HarvestedItem implements ReloadableEntity<Integer> {
|
|||||||
protected HarvestedItem() {
|
protected HarvestedItem() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Integer getID() {
|
public Integer getID() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
@@ -89,7 +90,6 @@ public class HarvestedItem implements ReloadableEntity<Integer> {
|
|||||||
*/
|
*/
|
||||||
public void setOaiID(String itemOaiID) {
|
public void setOaiID(String itemOaiID) {
|
||||||
this.oaiId = itemOaiID;
|
this.oaiId = itemOaiID;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -62,6 +62,7 @@ public class DOI
|
|||||||
protected DOI() {
|
protected DOI() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Integer getID() {
|
public Integer getID() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
package org.dspace.identifier.dao.impl;
|
package org.dspace.identifier.dao.impl;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.LinkedList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.persistence.criteria.CriteriaBuilder;
|
import javax.persistence.criteria.CriteriaBuilder;
|
||||||
import javax.persistence.criteria.CriteriaQuery;
|
import javax.persistence.criteria.CriteriaQuery;
|
||||||
@@ -24,7 +24,7 @@ import org.dspace.identifier.dao.DOIDAO;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Hibernate implementation of the Database Access Object interface class for the DOI object.
|
* Hibernate implementation of the Database Access Object interface class for the DOI object.
|
||||||
* This class is responsible for all database calls for the DOI object and is autowired by spring
|
* This class is responsible for all database calls for the DOI object and is autowired by Spring.
|
||||||
* This class should never be accessed directly.
|
* This class should never be accessed directly.
|
||||||
*
|
*
|
||||||
* @author kevinvandevelde at atmire.com
|
* @author kevinvandevelde at atmire.com
|
||||||
@@ -52,7 +52,7 @@ public class DOIDAOImpl extends AbstractHibernateDAO<DOI> implements DOIDAO {
|
|||||||
Root<DOI> doiRoot = criteriaQuery.from(DOI.class);
|
Root<DOI> doiRoot = criteriaQuery.from(DOI.class);
|
||||||
criteriaQuery.select(doiRoot);
|
criteriaQuery.select(doiRoot);
|
||||||
|
|
||||||
List<Predicate> listToIncludeInOrPredicate = new LinkedList<>();
|
List<Predicate> listToIncludeInOrPredicate = new ArrayList<>(statusToExclude.size() + 1);
|
||||||
|
|
||||||
for (Integer status : statusToExclude) {
|
for (Integer status : statusToExclude) {
|
||||||
listToIncludeInOrPredicate.add(criteriaBuilder.notEqual(doiRoot.get(DOI_.status), status));
|
listToIncludeInOrPredicate.add(criteriaBuilder.notEqual(doiRoot.get(DOI_.status), status));
|
||||||
@@ -75,7 +75,7 @@ public class DOIDAOImpl extends AbstractHibernateDAO<DOI> implements DOIDAO {
|
|||||||
CriteriaQuery criteriaQuery = getCriteriaQuery(criteriaBuilder, DOI.class);
|
CriteriaQuery criteriaQuery = getCriteriaQuery(criteriaBuilder, DOI.class);
|
||||||
Root<DOI> doiRoot = criteriaQuery.from(DOI.class);
|
Root<DOI> doiRoot = criteriaQuery.from(DOI.class);
|
||||||
criteriaQuery.select(doiRoot);
|
criteriaQuery.select(doiRoot);
|
||||||
List<Predicate> orPredicates = new LinkedList<>();
|
List<Predicate> orPredicates = new ArrayList<>(statuses.size());
|
||||||
for (Integer status : statuses) {
|
for (Integer status : statuses) {
|
||||||
orPredicates.add(criteriaBuilder.equal(doiRoot.get(DOI_.status), status));
|
orPredicates.add(criteriaBuilder.equal(doiRoot.get(DOI_.status), status));
|
||||||
}
|
}
|
||||||
@@ -92,13 +92,13 @@ public class DOIDAOImpl extends AbstractHibernateDAO<DOI> implements DOIDAO {
|
|||||||
Root<DOI> doiRoot = criteriaQuery.from(DOI.class);
|
Root<DOI> doiRoot = criteriaQuery.from(DOI.class);
|
||||||
criteriaQuery.select(doiRoot);
|
criteriaQuery.select(doiRoot);
|
||||||
|
|
||||||
List<Predicate> listToIncludeInOrPredicate = new LinkedList<>();
|
List<Predicate> listToIncludeInOrPredicate = new ArrayList<>(excludedStatuses.size());
|
||||||
|
|
||||||
for (Integer status : excludedStatuses) {
|
for (Integer status : excludedStatuses) {
|
||||||
listToIncludeInOrPredicate.add(criteriaBuilder.notEqual(doiRoot.get(DOI_.status), status));
|
listToIncludeInOrPredicate.add(criteriaBuilder.notEqual(doiRoot.get(DOI_.status), status));
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Predicate> listToIncludeInAndPredicate = new LinkedList<>();
|
List<Predicate> listToIncludeInAndPredicate = new ArrayList<>();
|
||||||
|
|
||||||
listToIncludeInAndPredicate.add(criteriaBuilder.like(doiRoot.get(DOI_.doi), doi));
|
listToIncludeInAndPredicate.add(criteriaBuilder.like(doiRoot.get(DOI_.doi), doi));
|
||||||
listToIncludeInAndPredicate.add(criteriaBuilder.or(listToIncludeInOrPredicate.toArray(new Predicate[] {})));
|
listToIncludeInAndPredicate.add(criteriaBuilder.or(listToIncludeInOrPredicate.toArray(new Predicate[] {})));
|
||||||
@@ -107,8 +107,6 @@ public class DOIDAOImpl extends AbstractHibernateDAO<DOI> implements DOIDAO {
|
|||||||
}
|
}
|
||||||
criteriaQuery.where(listToIncludeInAndPredicate.toArray(new Predicate[] {}));
|
criteriaQuery.where(listToIncludeInAndPredicate.toArray(new Predicate[] {}));
|
||||||
return list(context, criteriaQuery, false, DOI.class, -1, -1);
|
return list(context, criteriaQuery, false, DOI.class, -1, -1);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -7,9 +7,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.dspace.importer.external.datamodel;
|
package org.dspace.importer.external.datamodel;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.dspace.importer.external.metadatamapping.MetadatumDTO;
|
import org.dspace.importer.external.metadatamapping.MetadatumDTO;
|
||||||
@@ -38,7 +38,7 @@ public class ImportRecord {
|
|||||||
*/
|
*/
|
||||||
public ImportRecord(List<MetadatumDTO> valueList) {
|
public ImportRecord(List<MetadatumDTO> valueList) {
|
||||||
//don't want to alter the original list. Also now I can control the type of list
|
//don't want to alter the original list. Also now I can control the type of list
|
||||||
this.valueList = new LinkedList<>(valueList);
|
this.valueList = new ArrayList<>(valueList);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -81,7 +81,7 @@ public class ImportRecord {
|
|||||||
* @return the MetadatumDTO's that are related to a given schema/element/qualifier pair/triplet
|
* @return the MetadatumDTO's that are related to a given schema/element/qualifier pair/triplet
|
||||||
*/
|
*/
|
||||||
public Collection<MetadatumDTO> getValue(String schema, String element, String qualifier) {
|
public Collection<MetadatumDTO> getValue(String schema, String element, String qualifier) {
|
||||||
List<MetadatumDTO> values = new LinkedList<MetadatumDTO>();
|
List<MetadatumDTO> values = new ArrayList<MetadatumDTO>();
|
||||||
for (MetadatumDTO value : valueList) {
|
for (MetadatumDTO value : valueList) {
|
||||||
if (value.getSchema().equals(schema) && value.getElement().equals(element)) {
|
if (value.getSchema().equals(schema) && value.getElement().equals(element)) {
|
||||||
if (qualifier == null && value.getQualifier() == null) {
|
if (qualifier == null && value.getQualifier() == null) {
|
||||||
|
@@ -7,18 +7,19 @@
|
|||||||
*/
|
*/
|
||||||
package org.dspace.importer.external.metadatamapping;
|
package org.dspace.importer.external.metadatamapping;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.dspace.importer.external.metadatamapping.contributor.MetadataContributor;
|
import org.dspace.importer.external.metadatamapping.contributor.MetadataContributor;
|
||||||
import org.dspace.importer.external.metadatamapping.transform.MetadataProcessorService;
|
import org.dspace.importer.external.metadatamapping.transform.MetadataProcessorService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract class that implements {@link MetadataFieldMapping}
|
* Abstract class that implements {@link MetadataFieldMapping}.
|
||||||
* This class adds a default implementation for the MetadataFieldMapping methods
|
* This class adds a default implementation for the MetadataFieldMapping methods.
|
||||||
*
|
*
|
||||||
* @author Roeland Dillen (roeland at atmire dot com)
|
* @author Roeland Dillen (roeland at atmire dot com)
|
||||||
*/
|
*/
|
||||||
@@ -30,7 +31,7 @@ public abstract class AbstractMetadataFieldMapping<RecordType>
|
|||||||
/**
|
/**
|
||||||
* log4j logger
|
* log4j logger
|
||||||
*/
|
*/
|
||||||
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(AbstractMetadataFieldMapping.class);
|
private static final Logger log = LogManager.getLogger(AbstractMetadataFieldMapping.class);
|
||||||
|
|
||||||
/* A map containing what processing has to be done on a given metadataFieldConfig.
|
/* A map containing what processing has to be done on a given metadataFieldConfig.
|
||||||
* The processing of a value is used to determine the actual value that will be returned used.
|
* The processing of a value is used to determine the actual value that will be returned used.
|
||||||
@@ -66,6 +67,7 @@ public abstract class AbstractMetadataFieldMapping<RecordType>
|
|||||||
* @param value The value to map to a MetadatumDTO
|
* @param value The value to map to a MetadatumDTO
|
||||||
* @return A metadatumDTO created from the field and value
|
* @return A metadatumDTO created from the field and value
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public MetadatumDTO toDCValue(MetadataFieldConfig field, String value) {
|
public MetadatumDTO toDCValue(MetadataFieldConfig field, String value) {
|
||||||
MetadatumDTO dcValue = new MetadatumDTO();
|
MetadatumDTO dcValue = new MetadatumDTO();
|
||||||
|
|
||||||
@@ -108,14 +110,15 @@ public abstract class AbstractMetadataFieldMapping<RecordType>
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loop over the MetadataContributors and return their concatenated retrieved metadatumDTO objects
|
* Loop over the MetadataContributors and return their concatenated
|
||||||
|
* retrieved metadatumDTO objects.
|
||||||
*
|
*
|
||||||
* @param record Used to retrieve the MetadatumDTO
|
* @param record Used to retrieve the MetadatumDTO
|
||||||
* @return Lit of metadatumDTO
|
* @return Lit of metadatumDTO
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Collection<MetadatumDTO> resultToDCValueMapping(RecordType record) {
|
public Collection<MetadatumDTO> resultToDCValueMapping(RecordType record) {
|
||||||
List<MetadatumDTO> values = new LinkedList<MetadatumDTO>();
|
List<MetadatumDTO> values = new ArrayList<>();
|
||||||
|
|
||||||
for (MetadataContributor<RecordType> query : getMetadataFieldMap().values()) {
|
for (MetadataContributor<RecordType> query : getMetadataFieldMap().values()) {
|
||||||
try {
|
try {
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
package org.dspace.importer.external.metadatamapping;
|
package org.dspace.importer.external.metadatamapping;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A generalised configuration for metadatafields.
|
* A generalised configuration for metadata fields.
|
||||||
* This is used to make the link between values and the actual MetadatumDTO object.
|
* This is used to make the link between values and the actual MetadatumDTO object.
|
||||||
*
|
*
|
||||||
* @author Roeland Dillen (roeland at atmire dot com)
|
* @author Roeland Dillen (roeland at atmire dot com)
|
||||||
@@ -31,7 +31,7 @@ public class MetadataFieldConfig {
|
|||||||
if (this == o) {
|
if (this == o) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (o == null || getClass() != o.getClass()) {
|
if (o == null || !(o instanceof MetadataFieldConfig)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,11 +43,7 @@ public class MetadataFieldConfig {
|
|||||||
if (qualifier != null ? !qualifier.equals(that.qualifier) : that.qualifier != null) {
|
if (qualifier != null ? !qualifier.equals(that.qualifier) : that.qualifier != null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!schema.equals(that.schema)) {
|
return schema.equals(that.schema);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -14,7 +14,8 @@ import org.apache.commons.lang3.StringUtils;
|
|||||||
import org.apache.commons.lang3.builder.HashCodeBuilder;
|
import org.apache.commons.lang3.builder.HashCodeBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class serves as a representation of a command line parameter by holding a String name and a String value
|
* This class serves as a representation of a command line parameter by holding
|
||||||
|
* a String name and a String value.
|
||||||
*/
|
*/
|
||||||
public class DSpaceCommandLineParameter {
|
public class DSpaceCommandLineParameter {
|
||||||
private String name;
|
private String name;
|
||||||
@@ -23,7 +24,7 @@ public class DSpaceCommandLineParameter {
|
|||||||
public static String SEPARATOR = "|||";
|
public static String SEPARATOR = "|||";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This constructor will take a String key and String value and store them in their appriopriate fields
|
* This constructor will take a String key and String value and store them in their appropriate fields.
|
||||||
* @param key The String value to be stored as the name of the parameter
|
* @param key The String value to be stored as the name of the parameter
|
||||||
* @param value The String value to be stored as the value of the parameter
|
* @param value The String value to be stored as the value of the parameter
|
||||||
*/
|
*/
|
||||||
@@ -64,9 +65,10 @@ public class DSpaceCommandLineParameter {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts the DSpaceCommandLineParameter into a String format by concatenating the value and the name String
|
* Converts the DSpaceCommandLineParameter into a String format by concatenating the value and the name String
|
||||||
* values by separating them with a space
|
* values by separating them with a space.
|
||||||
* @return The String representation of a DSpaceCommandlineParameter object
|
* @return The String representation of a DSpaceCommandlineParameter object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
String stringToReturn = "";
|
String stringToReturn = "";
|
||||||
stringToReturn += getName();
|
stringToReturn += getName();
|
||||||
@@ -92,7 +94,7 @@ public class DSpaceCommandLineParameter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Will return a boolean indicating whether the given param is equal to this object
|
* Will return a boolean indicating whether the given parameter is equal to this object.
|
||||||
* @param other The other object
|
* @param other The other object
|
||||||
* @return A boolean indicating equality
|
* @return A boolean indicating equality
|
||||||
*/
|
*/
|
||||||
@@ -101,7 +103,7 @@ public class DSpaceCommandLineParameter {
|
|||||||
if (other == null) {
|
if (other == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (other.getClass() != DSpaceCommandLineParameter.class) {
|
if (!(other instanceof DSpaceCommandLineParameter)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return StringUtils.equals(this.getName(), ((DSpaceCommandLineParameter) other).getName()) && StringUtils
|
return StringUtils.equals(this.getName(), ((DSpaceCommandLineParameter) other).getName()) && StringUtils
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
package org.dspace.scripts;
|
package org.dspace.scripts;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.LinkedList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@@ -37,7 +37,7 @@ public abstract class DSpaceRunnable<T extends ScriptConfiguration> implements R
|
|||||||
protected CommandLine commandLine;
|
protected CommandLine commandLine;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This EPerson identifier variable is the uuid of the eperson that's running the script
|
* This EPerson identifier variable is the UUID of the EPerson that's running the script
|
||||||
*/
|
*/
|
||||||
private UUID epersonIdentifier;
|
private UUID epersonIdentifier;
|
||||||
|
|
||||||
@@ -129,7 +129,7 @@ public abstract class DSpaceRunnable<T extends ScriptConfiguration> implements R
|
|||||||
* @return The list of Strings representing filenames from the options given to the script
|
* @return The list of Strings representing filenames from the options given to the script
|
||||||
*/
|
*/
|
||||||
public List<String> getFileNamesFromInputStreamOptions() {
|
public List<String> getFileNamesFromInputStreamOptions() {
|
||||||
List<String> fileNames = new LinkedList<>();
|
List<String> fileNames = new ArrayList<>();
|
||||||
|
|
||||||
for (Option option : getScriptConfiguration().getOptions().getOptions()) {
|
for (Option option : getScriptConfiguration().getOptions().getOptions()) {
|
||||||
if (option.getType() == InputStream.class &&
|
if (option.getType() == InputStream.class &&
|
||||||
@@ -151,8 +151,8 @@ public abstract class DSpaceRunnable<T extends ScriptConfiguration> implements R
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generic setter for the epersonIdentifier
|
* Generic setter for the epersonIdentifier.
|
||||||
* This EPerson identifier variable is the uuid of the eperson that's running the script
|
* This EPerson identifier variable is the UUID of the EPerson that's running the script.
|
||||||
* @param epersonIdentifier The epersonIdentifier to be set on this DSpaceRunnable
|
* @param epersonIdentifier The epersonIdentifier to be set on this DSpaceRunnable
|
||||||
*/
|
*/
|
||||||
public void setEpersonIdentifier(UUID epersonIdentifier) {
|
public void setEpersonIdentifier(UUID epersonIdentifier) {
|
||||||
|
@@ -7,8 +7,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.dspace.scripts;
|
package org.dspace.scripts;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
@@ -91,6 +91,7 @@ public class Process implements ReloadableEntity<Integer> {
|
|||||||
* This method returns the ID that the Process holds within the Database
|
* This method returns the ID that the Process holds within the Database
|
||||||
* @return The ID that the process holds within the database
|
* @return The ID that the process holds within the database
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Integer getID() {
|
public Integer getID() {
|
||||||
return processId;
|
return processId;
|
||||||
}
|
}
|
||||||
@@ -162,7 +163,8 @@ public class Process implements ReloadableEntity<Integer> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* To get the parameters, use ProcessService.getParameters() to get a parsed list of DSpaceCommandLineParameters
|
* To get the parameters, use ProcessService.getParameters() to get a parsed list of DSpaceCommandLineParameters
|
||||||
* This String representation is the parameter in an unparsed fashion. For example "-c test"
|
* This String representation is the parameter in an unparsed fashion.For example "-c test"
|
||||||
|
* @return the raw parameter string.
|
||||||
*/
|
*/
|
||||||
protected String getParameters() {
|
protected String getParameters() {
|
||||||
return parameters;
|
return parameters;
|
||||||
@@ -179,7 +181,7 @@ public class Process implements ReloadableEntity<Integer> {
|
|||||||
*/
|
*/
|
||||||
public List<Bitstream> getBitstreams() {
|
public List<Bitstream> getBitstreams() {
|
||||||
if (bitstreams == null) {
|
if (bitstreams == null) {
|
||||||
bitstreams = new LinkedList<>();
|
bitstreams = Collections.EMPTY_LIST;
|
||||||
}
|
}
|
||||||
return bitstreams;
|
return bitstreams;
|
||||||
}
|
}
|
||||||
|
@@ -11,7 +11,6 @@ import java.sql.SQLException;
|
|||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
@@ -129,7 +128,7 @@ public class Harvest {
|
|||||||
// several smaller operations (e.g. for OAI resumption tokens.)
|
// several smaller operations (e.g. for OAI resumption tokens.)
|
||||||
discoverQuery.setSortField("search.resourceid", DiscoverQuery.SORT_ORDER.asc);
|
discoverQuery.setSortField("search.resourceid", DiscoverQuery.SORT_ORDER.asc);
|
||||||
|
|
||||||
List<HarvestedItemInfo> infoObjects = new LinkedList<HarvestedItemInfo>();
|
List<HarvestedItemInfo> infoObjects = new ArrayList<>();
|
||||||
|
|
||||||
// Count of items read from the record set that match the selection criteria.
|
// Count of items read from the record set that match the selection criteria.
|
||||||
// Note : Until 'index > offset' the records are not added to the output set.
|
// Note : Until 'index > offset' the records are not added to the output set.
|
||||||
@@ -155,7 +154,7 @@ public class Harvest {
|
|||||||
|
|
||||||
if (collections) {
|
if (collections) {
|
||||||
// Add collections data
|
// Add collections data
|
||||||
fillCollections(context, itemInfo);
|
fillCollections(itemInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (items) {
|
if (items) {
|
||||||
@@ -163,7 +162,7 @@ public class Harvest {
|
|||||||
itemInfo.item = itemService.find(context, itemInfo.itemID);
|
itemInfo.item = itemService.find(context, itemInfo.itemID);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((nonAnon) || (itemInfo.item == null) || (withdrawn && itemInfo.withdrawn)) {
|
if (nonAnon || (itemInfo.item == null) || (withdrawn && itemInfo.withdrawn)) {
|
||||||
index++;
|
index++;
|
||||||
if (index > offset) {
|
if (index > offset) {
|
||||||
infoObjects.add(itemInfo);
|
infoObjects.add(itemInfo);
|
||||||
@@ -221,7 +220,7 @@ public class Harvest {
|
|||||||
|
|
||||||
// Get the sets
|
// Get the sets
|
||||||
if (collections) {
|
if (collections) {
|
||||||
fillCollections(context, itemInfo);
|
fillCollections(itemInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
return itemInfo;
|
return itemInfo;
|
||||||
@@ -234,8 +233,7 @@ public class Harvest {
|
|||||||
* @param itemInfo HarvestedItemInfo object to fill out
|
* @param itemInfo HarvestedItemInfo object to fill out
|
||||||
* @throws SQLException if database error
|
* @throws SQLException if database error
|
||||||
*/
|
*/
|
||||||
private static void fillCollections(Context context,
|
private static void fillCollections(HarvestedItemInfo itemInfo) throws SQLException {
|
||||||
HarvestedItemInfo itemInfo) throws SQLException {
|
|
||||||
// Get the collection Handles from DB
|
// Get the collection Handles from DB
|
||||||
List<Collection> collections = itemInfo.item.getCollections();
|
List<Collection> collections = itemInfo.item.getCollections();
|
||||||
itemInfo.collectionHandles = new ArrayList<>();
|
itemInfo.collectionHandles = new ArrayList<>();
|
||||||
|
@@ -18,6 +18,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import au.com.bytecode.opencsv.CSVWriter;
|
import au.com.bytecode.opencsv.CSVWriter;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
@@ -65,20 +66,20 @@ public class Dataset {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initRowLabels(int rows) {
|
private void initRowLabels(int rows) {
|
||||||
rowLabels = new ArrayList<String>(rows);
|
rowLabels = new ArrayList<>(rows);
|
||||||
rowLabelsAttrs = new ArrayList<Map<String, String>>();
|
rowLabelsAttrs = new ArrayList<>();
|
||||||
for (int i = 0; i < rows; i++) {
|
for (int i = 0; i < rows; i++) {
|
||||||
rowLabels.add("Row " + (i + 1));
|
rowLabels.add("Row " + (i + 1));
|
||||||
rowLabelsAttrs.add(new HashMap<String, String>());
|
rowLabelsAttrs.add(new HashMap<>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initColumnLabels(int nbCols) {
|
private void initColumnLabels(int nbCols) {
|
||||||
colLabels = new ArrayList<String>(nbCols);
|
colLabels = new ArrayList<>(nbCols);
|
||||||
colLabelsAttrs = new ArrayList<Map<String, String>>();
|
colLabelsAttrs = new ArrayList<>();
|
||||||
for (int i = 0; i < nbCols; i++) {
|
for (int i = 0; i < nbCols; i++) {
|
||||||
colLabels.add("Column " + (i + 1));
|
colLabels.add("Column " + (i + 1));
|
||||||
colLabelsAttrs.add(new HashMap<String, String>());
|
colLabelsAttrs.add(new HashMap<>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -232,7 +233,7 @@ public class Dataset {
|
|||||||
|
|
||||||
public ByteArrayOutputStream exportAsCSV() throws IOException {
|
public ByteArrayOutputStream exportAsCSV() throws IOException {
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
CSVWriter ecsvp = new CSVWriter(new OutputStreamWriter(baos), ';');
|
CSVWriter ecsvp = new CSVWriter(new OutputStreamWriter(baos, StandardCharsets.UTF_8), ';');
|
||||||
//Generate the item row
|
//Generate the item row
|
||||||
List<String> colLabels = getColLabels();
|
List<String> colLabels = getColLabels();
|
||||||
colLabels.add(0, "");
|
colLabels.add(0, "");
|
||||||
|
@@ -7,9 +7,10 @@
|
|||||||
*/
|
*/
|
||||||
package org.dspace.statistics;
|
package org.dspace.statistics;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.dspace.eperson.EPerson;
|
import org.dspace.eperson.EPerson;
|
||||||
import org.dspace.services.model.Event;
|
import org.dspace.services.model.Event;
|
||||||
@@ -28,7 +29,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
*/
|
*/
|
||||||
public class SolrLoggerUsageEventListener extends AbstractUsageEventListener {
|
public class SolrLoggerUsageEventListener extends AbstractUsageEventListener {
|
||||||
|
|
||||||
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(SolrLoggerUsageEventListener.class);
|
private static final Logger log = LogManager.getLogger(SolrLoggerUsageEventListener.class);
|
||||||
|
|
||||||
protected SolrLoggerService solrLoggerService;
|
protected SolrLoggerService solrLoggerService;
|
||||||
|
|
||||||
@@ -56,7 +57,7 @@ public class SolrLoggerUsageEventListener extends AbstractUsageEventListener {
|
|||||||
}
|
}
|
||||||
} else if (UsageEvent.Action.SEARCH == ue.getAction()) {
|
} else if (UsageEvent.Action.SEARCH == ue.getAction()) {
|
||||||
UsageSearchEvent usageSearchEvent = (UsageSearchEvent) ue;
|
UsageSearchEvent usageSearchEvent = (UsageSearchEvent) ue;
|
||||||
List<String> queries = new LinkedList<>();
|
List<String> queries = new ArrayList<>();
|
||||||
queries.add(usageSearchEvent.getQuery());
|
queries.add(usageSearchEvent.getQuery());
|
||||||
solrLoggerService.postSearch(usageSearchEvent.getObject(), usageSearchEvent.getRequest(),
|
solrLoggerService.postSearch(usageSearchEvent.getObject(), usageSearchEvent.getRequest(),
|
||||||
currentUser, queries, usageSearchEvent.getPage().getSize(),
|
currentUser, queries, usageSearchEvent.getPage().getSize(),
|
||||||
|
@@ -285,13 +285,8 @@ public class StatisticsDataVisits extends StatisticsData {
|
|||||||
DatasetQuery firsDataset = datasetQueries.get(0);
|
DatasetQuery firsDataset = datasetQueries.get(0);
|
||||||
//Do the first query
|
//Do the first query
|
||||||
|
|
||||||
ObjectCount[] topCounts1 = null;
|
ObjectCount[] topCounts1 =
|
||||||
// if (firsDataset.getQueries().size() == 1) {
|
|
||||||
topCounts1 =
|
|
||||||
queryFacetField(firsDataset, firsDataset.getQueries().get(0).getQuery(), filterQuery, facetMinCount);
|
queryFacetField(firsDataset, firsDataset.getQueries().get(0).getQuery(), filterQuery, facetMinCount);
|
||||||
// } else {
|
|
||||||
// TODO: do this
|
|
||||||
// }
|
|
||||||
// Check if we have more queries that need to be done
|
// Check if we have more queries that need to be done
|
||||||
if (datasetQueries.size() == 2) {
|
if (datasetQueries.size() == 2) {
|
||||||
DatasetQuery secondDataSet = datasetQueries.get(1);
|
DatasetQuery secondDataSet = datasetQueries.get(1);
|
||||||
@@ -313,7 +308,6 @@ public class StatisticsDataVisits extends StatisticsData {
|
|||||||
}
|
}
|
||||||
for (int i = 0; i < topCounts1.length; i++) {
|
for (int i = 0; i < topCounts1.length; i++) {
|
||||||
ObjectCount count1 = topCounts1[i];
|
ObjectCount count1 = topCounts1[i];
|
||||||
ObjectCount[] currentResult = new ObjectCount[topCounts2.length];
|
|
||||||
|
|
||||||
// Make sure we have a dataSet
|
// Make sure we have a dataSet
|
||||||
if (dataset == null) {
|
if (dataset == null) {
|
||||||
@@ -645,7 +639,7 @@ public class StatisticsDataVisits extends StatisticsData {
|
|||||||
// be null if a handle has not yet been assigned. In this case reference the
|
// be null if a handle has not yet been assigned. In this case reference the
|
||||||
// item its internal id. In the last case where the bitstream is not associated
|
// item its internal id. In the last case where the bitstream is not associated
|
||||||
// with an item (such as a community logo) then reference the bitstreamID directly.
|
// with an item (such as a community logo) then reference the bitstreamID directly.
|
||||||
String identifier = null;
|
String identifier;
|
||||||
if (owningItem != null && owningItem.getHandle() != null) {
|
if (owningItem != null && owningItem.getHandle() != null) {
|
||||||
identifier = "handle/" + owningItem.getHandle();
|
identifier = "handle/" + owningItem.getHandle();
|
||||||
} else if (owningItem != null) {
|
} else if (owningItem != null) {
|
||||||
|
@@ -39,11 +39,11 @@ public class ValueConcatenationModifier extends AbstractModifier {
|
|||||||
public Record modify(MutableRecord rec) {
|
public Record modify(MutableRecord rec) {
|
||||||
List<Value> values = rec.getValues(field);
|
List<Value> values = rec.getValues(field);
|
||||||
if (values != null) {
|
if (values != null) {
|
||||||
List<String> converted_values = new ArrayList<String>();
|
List<String> converted_values = new ArrayList<>();
|
||||||
for (Value val : values) {
|
for (Value val : values) {
|
||||||
converted_values.add(val.getAsString());
|
converted_values.add(val.getAsString());
|
||||||
}
|
}
|
||||||
List<Value> final_value = new ArrayList<Value>();
|
List<Value> final_value = new ArrayList<>();
|
||||||
String v = StringUtils.join(converted_values.iterator(), separator
|
String v = StringUtils.join(converted_values.iterator(), separator
|
||||||
+ (whitespaceAfter ? " " : ""));
|
+ (whitespaceAfter ? " " : ""));
|
||||||
final_value.add(new StringValue(v));
|
final_value.add(new StringValue(v));
|
||||||
@@ -89,9 +89,9 @@ public class ValueConcatenationModifier extends AbstractModifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param whiteSpaceAfter the whiteSpaceAfter to set
|
* @param whitespaceAfter the whiteSpaceAfter to set
|
||||||
*/
|
*/
|
||||||
public void setWhitespaceAfter(boolean whiteSpaceAfter) {
|
public void setWhitespaceAfter(boolean whitespaceAfter) {
|
||||||
this.whitespaceAfter = whiteSpaceAfter;
|
this.whitespaceAfter = whitespaceAfter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -30,11 +30,9 @@ public class ItemSubmissionLookupDTO implements Serializable {
|
|||||||
|
|
||||||
private static final String MERGED_PUBLICATION_PROVIDER = "merged";
|
private static final String MERGED_PUBLICATION_PROVIDER = "merged";
|
||||||
|
|
||||||
private static final String UNKNOWN_PROVIDER_STRING = "UNKNOWN-PROVIDER";
|
private final List<Record> publications;
|
||||||
|
|
||||||
private List<Record> publications;
|
private final String uuid;
|
||||||
|
|
||||||
private String uuid;
|
|
||||||
|
|
||||||
public ItemSubmissionLookupDTO(List<Record> publications) {
|
public ItemSubmissionLookupDTO(List<Record> publications) {
|
||||||
this.uuid = UUID.randomUUID().toString();
|
this.uuid = UUID.randomUUID().toString();
|
||||||
@@ -46,7 +44,7 @@ public class ItemSubmissionLookupDTO implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Set<String> getProviders() {
|
public Set<String> getProviders() {
|
||||||
Set<String> orderedProviders = new LinkedHashSet<String>();
|
Set<String> orderedProviders = new LinkedHashSet<>();
|
||||||
for (Record p : publications) {
|
for (Record p : publications) {
|
||||||
orderedProviders.add(SubmissionLookupService.getProviderName(p));
|
orderedProviders.add(SubmissionLookupService.getProviderName(p));
|
||||||
}
|
}
|
||||||
|
@@ -77,6 +77,7 @@ public class Version implements ReloadableEntity<Integer> {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Integer getID() {
|
public Integer getID() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
@@ -20,7 +20,6 @@ import javax.persistence.OrderBy;
|
|||||||
import javax.persistence.SequenceGenerator;
|
import javax.persistence.SequenceGenerator;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.core.ReloadableEntity;
|
import org.dspace.core.ReloadableEntity;
|
||||||
import org.hibernate.proxy.HibernateProxyHelper;
|
import org.hibernate.proxy.HibernateProxyHelper;
|
||||||
@@ -35,8 +34,6 @@ import org.hibernate.proxy.HibernateProxyHelper;
|
|||||||
@Table(name = "versionhistory")
|
@Table(name = "versionhistory")
|
||||||
public class VersionHistory implements ReloadableEntity<Integer> {
|
public class VersionHistory implements ReloadableEntity<Integer> {
|
||||||
|
|
||||||
private static final Logger log = org.apache.logging.log4j.LogManager.getLogger(VersionHistory.class);
|
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@Column(name = "versionhistory_id")
|
@Column(name = "versionhistory_id")
|
||||||
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "versionhistory_seq")
|
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "versionhistory_seq")
|
||||||
@@ -56,6 +53,7 @@ public class VersionHistory implements ReloadableEntity<Integer> {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Integer getID() {
|
public Integer getID() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
@@ -98,11 +96,7 @@ public class VersionHistory implements ReloadableEntity<Integer> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final VersionHistory that = (VersionHistory) o;
|
final VersionHistory that = (VersionHistory) o;
|
||||||
if (!this.getID().equals(that.getID())) {
|
return this.getID().equals(that.getID());
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -27,7 +27,8 @@ public class WorkflowException extends Exception {
|
|||||||
this.reason = reason;
|
this.reason = reason;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
@Override
|
||||||
|
public String getMessage() {
|
||||||
return reason;
|
return reason;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -116,6 +116,7 @@ public class BasicWorkflowItem implements WorkflowItem {
|
|||||||
*
|
*
|
||||||
* @return state
|
* @return state
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public int getState() {
|
public int getState() {
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
@@ -73,6 +73,7 @@ public class TaskListItem implements ReloadableEntity<Integer> {
|
|||||||
this.workflowItem = workflowItem;
|
this.workflowItem = workflowItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Integer getID() {
|
public Integer getID() {
|
||||||
return taskListItemId;
|
return taskListItemId;
|
||||||
}
|
}
|
||||||
|
@@ -30,8 +30,8 @@ import org.dspace.eperson.service.GroupService;
|
|||||||
public class RoleMembers {
|
public class RoleMembers {
|
||||||
|
|
||||||
protected GroupService groupService = EPersonServiceFactory.getInstance().getGroupService();
|
protected GroupService groupService = EPersonServiceFactory.getInstance().getGroupService();
|
||||||
private ArrayList<Group> groups;
|
private final ArrayList<Group> groups;
|
||||||
private ArrayList<EPerson> epersons;
|
private final ArrayList<EPerson> epersons;
|
||||||
|
|
||||||
public RoleMembers() {
|
public RoleMembers() {
|
||||||
this.groups = new ArrayList<>();
|
this.groups = new ArrayList<>();
|
||||||
@@ -55,11 +55,7 @@ public class RoleMembers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void removeEperson(EPerson epersonToRemove) {
|
public void removeEperson(EPerson epersonToRemove) {
|
||||||
for (EPerson eperson : epersons) {
|
epersons.removeIf(eperson -> eperson.equals(epersonToRemove));
|
||||||
if (eperson.equals(epersonToRemove)) {
|
|
||||||
epersons.remove(eperson);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<EPerson> getAllUniqueMembers(Context context) throws SQLException {
|
public ArrayList<EPerson> getAllUniqueMembers(Context context) throws SQLException {
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
package org.dspace.xmlworkflow;
|
package org.dspace.xmlworkflow;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exception for problems with the configuration xml
|
* Exception for problems with the configuration XML.
|
||||||
*
|
*
|
||||||
* @author Bram De Schouwer (bram.deschouwer at dot com)
|
* @author Bram De Schouwer (bram.deschouwer at dot com)
|
||||||
* @author Kevin Van de Velde (kevin at atmire dot com)
|
* @author Kevin Van de Velde (kevin at atmire dot com)
|
||||||
@@ -17,13 +17,14 @@ package org.dspace.xmlworkflow;
|
|||||||
*/
|
*/
|
||||||
public class WorkflowConfigurationException extends Exception {
|
public class WorkflowConfigurationException extends Exception {
|
||||||
|
|
||||||
private String error;
|
private final String error;
|
||||||
|
|
||||||
public WorkflowConfigurationException(String error) {
|
public WorkflowConfigurationException(String error) {
|
||||||
this.error = error;
|
this.error = error;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
@Override
|
||||||
|
public String getMessage() {
|
||||||
return this.error;
|
return this.error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -71,6 +71,7 @@ public class ClaimedTask implements ReloadableEntity<Integer> {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Integer getID() {
|
public Integer getID() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
@@ -91,24 +92,24 @@ public class ClaimedTask implements ReloadableEntity<Integer> {
|
|||||||
return workflowItem;
|
return workflowItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setActionID(String actionID) {
|
public void setActionID(String actionId) {
|
||||||
this.actionId = actionID;
|
this.actionId = actionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getActionID() {
|
public String getActionID() {
|
||||||
return actionId;
|
return actionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStepID(String stepID) {
|
public void setStepID(String stepId) {
|
||||||
this.stepId = stepID;
|
this.stepId = stepId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getStepID() {
|
public String getStepID() {
|
||||||
return stepId;
|
return stepId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setWorkflowID(String workflowID) {
|
public void setWorkflowID(String workflowId) {
|
||||||
this.workflowId = workflowID;
|
this.workflowId = workflowId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getWorkflowID() {
|
public String getWorkflowID() {
|
||||||
|
@@ -91,6 +91,7 @@ public class CollectionRole implements ReloadableEntity<Integer> {
|
|||||||
return group;
|
return group;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Integer getID() {
|
public Integer getID() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
@@ -78,12 +78,13 @@ public class PoolTask implements ReloadableEntity<Integer> {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Integer getID() {
|
public Integer getID() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEperson(EPerson eperson) {
|
public void setEperson(EPerson ePerson) {
|
||||||
this.ePerson = eperson;
|
this.ePerson = ePerson;
|
||||||
}
|
}
|
||||||
|
|
||||||
public EPerson getEperson() {
|
public EPerson getEperson() {
|
||||||
@@ -114,16 +115,16 @@ public class PoolTask implements ReloadableEntity<Integer> {
|
|||||||
return this.workflowItem;
|
return this.workflowItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStepID(String stepID) {
|
public void setStepID(String stepId) {
|
||||||
this.stepId = stepID;
|
this.stepId = stepId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getStepID() {
|
public String getStepID() {
|
||||||
return stepId;
|
return stepId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setActionID(String actionID) {
|
public void setActionID(String actionId) {
|
||||||
this.actionId = actionID;
|
this.actionId = actionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getActionID() {
|
public String getActionID() {
|
||||||
|
@@ -69,7 +69,7 @@ public class WorkflowItemRole implements ReloadableEntity<Integer> {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Integer getID() {
|
public Integer getID() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
@@ -90,8 +90,8 @@ public class WorkflowItemRole implements ReloadableEntity<Integer> {
|
|||||||
return workflowItem;
|
return workflowItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEPerson(EPerson eperson) {
|
public void setEPerson(EPerson ePerson) {
|
||||||
this.ePerson = eperson;
|
this.ePerson = ePerson;
|
||||||
}
|
}
|
||||||
|
|
||||||
public EPerson getEPerson() throws SQLException {
|
public EPerson getEPerson() throws SQLException {
|
||||||
|
@@ -12,6 +12,7 @@ import java.io.FileWriter;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
import java.nio.channels.FileChannel;
|
import java.nio.channels.FileChannel;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.nio.file.StandardOpenOption;
|
import java.nio.file.StandardOpenOption;
|
||||||
|
|
||||||
@@ -118,7 +119,8 @@ public class AbstractIntegrationTest extends AbstractUnitTest {
|
|||||||
*/
|
*/
|
||||||
protected void appendToLocalConfiguration(String textToAppend) {
|
protected void appendToLocalConfiguration(String textToAppend) {
|
||||||
String extraConfPath = getLocalConfigurationFilePath();
|
String extraConfPath = getLocalConfigurationFilePath();
|
||||||
try (Writer output = new BufferedWriter(new FileWriter(extraConfPath, true))) {
|
try (Writer output = new BufferedWriter(
|
||||||
|
new FileWriter(extraConfPath, StandardCharsets.UTF_8, true))) {
|
||||||
output.append("\n");
|
output.append("\n");
|
||||||
output.append(textToAppend);
|
output.append(textToAppend);
|
||||||
output.flush();
|
output.flush();
|
||||||
|
@@ -47,10 +47,12 @@ import org.junit.Test;
|
|||||||
|
|
||||||
public class MetadataImportIT extends AbstractIntegrationTestWithDatabase {
|
public class MetadataImportIT extends AbstractIntegrationTestWithDatabase {
|
||||||
|
|
||||||
private ItemService itemService
|
private final ItemService itemService
|
||||||
= ContentServiceFactory.getInstance().getItemService();
|
= ContentServiceFactory.getInstance().getItemService();
|
||||||
private EPersonService ePersonService = EPersonServiceFactory.getInstance().getEPersonService();
|
private final EPersonService ePersonService
|
||||||
private RelationshipService relationshipService = ContentServiceFactory.getInstance().getRelationshipService();
|
= EPersonServiceFactory.getInstance().getEPersonService();
|
||||||
|
private final RelationshipService relationshipService
|
||||||
|
= ContentServiceFactory.getInstance().getRelationshipService();
|
||||||
|
|
||||||
Collection collection;
|
Collection collection;
|
||||||
|
|
||||||
@@ -119,7 +121,7 @@ public class MetadataImportIT extends AbstractIntegrationTestWithDatabase {
|
|||||||
Item importedItem = findItemByName("Test Import 1");
|
Item importedItem = findItemByName("Test Import 1");
|
||||||
|
|
||||||
|
|
||||||
assertEquals(relationshipService.findByItem(context, importedItem).size(), 1);
|
assertEquals(1, relationshipService.findByItem(context, importedItem).size());
|
||||||
context.turnOffAuthorisationSystem();
|
context.turnOffAuthorisationSystem();
|
||||||
itemService.delete(context, itemService.find(context, importedItem.getID()));
|
itemService.delete(context, itemService.find(context, importedItem.getID()));
|
||||||
context.restoreAuthSystemState();
|
context.restoreAuthSystemState();
|
||||||
@@ -148,7 +150,7 @@ public class MetadataImportIT extends AbstractIntegrationTestWithDatabase {
|
|||||||
Item importedItem = findItemByName("Person1");
|
Item importedItem = findItemByName("Person1");
|
||||||
|
|
||||||
|
|
||||||
assertEquals(relationshipService.findByItem(context, importedItem).size(), 1);
|
assertEquals(1, relationshipService.findByItem(context, importedItem).size());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -56,14 +56,16 @@ public class CSVMetadataImportReferenceIT extends AbstractIntegrationTestWithDat
|
|||||||
//Common collection to utilize for test
|
//Common collection to utilize for test
|
||||||
private Collection col1;
|
private Collection col1;
|
||||||
|
|
||||||
private RelationshipService relationshipService = ContentServiceFactory.getInstance().getRelationshipService();
|
private final RelationshipService relationshipService
|
||||||
private ItemService itemService = ContentServiceFactory.getInstance().getItemService();
|
= ContentServiceFactory.getInstance().getRelationshipService();
|
||||||
|
private final ItemService itemService
|
||||||
|
= ContentServiceFactory.getInstance().getItemService();
|
||||||
|
|
||||||
Community parentCommunity;
|
Community parentCommunity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setup testing enviorment
|
* Setup testing environment.
|
||||||
|
* @throws java.sql.SQLException passed through.
|
||||||
*/
|
*/
|
||||||
@Before
|
@Before
|
||||||
public void setup() throws SQLException {
|
public void setup() throws SQLException {
|
||||||
@@ -80,7 +82,7 @@ public class CSVMetadataImportReferenceIT extends AbstractIntegrationTestWithDat
|
|||||||
EntityType publication = EntityTypeBuilder.createEntityTypeBuilder(context, "Publication").build();
|
EntityType publication = EntityTypeBuilder.createEntityTypeBuilder(context, "Publication").build();
|
||||||
EntityType person = EntityTypeBuilder.createEntityTypeBuilder(context, "Person").build();
|
EntityType person = EntityTypeBuilder.createEntityTypeBuilder(context, "Person").build();
|
||||||
EntityType project = EntityTypeBuilder.createEntityTypeBuilder(context, "Project").build();
|
EntityType project = EntityTypeBuilder.createEntityTypeBuilder(context, "Project").build();
|
||||||
EntityType orgUnit = EntityTypeBuilder.createEntityTypeBuilder(context, "OrgUnit").build();
|
EntityTypeBuilder.createEntityTypeBuilder(context, "OrgUnit").build();
|
||||||
|
|
||||||
RelationshipTypeBuilder
|
RelationshipTypeBuilder
|
||||||
.createRelationshipTypeBuilder(context, publication, person, "isAuthorOfPublication",
|
.createRelationshipTypeBuilder(context, publication, person, "isAuthorOfPublication",
|
||||||
@@ -350,11 +352,12 @@ public class CSVMetadataImportReferenceIT extends AbstractIntegrationTestWithDat
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Test failure when referring to item by non unique metadata in the database.
|
* Test failure when referring to item by non unique metadata in the database.
|
||||||
|
* @throws java.lang.Exception passed through.
|
||||||
*/
|
*/
|
||||||
@Test(expected = MetadataImportException.class)
|
@Test(expected = MetadataImportException.class)
|
||||||
public void testNonUniqueMDRefInDb() throws Exception {
|
public void testNonUniqueMDRefInDb() throws Exception {
|
||||||
context.turnOffAuthorisationSystem();
|
context.turnOffAuthorisationSystem();
|
||||||
Item person = ItemBuilder.createItem(context, col1)
|
ItemBuilder.createItem(context, col1)
|
||||||
.withTitle("Person")
|
.withTitle("Person")
|
||||||
.withIssueDate("2017-10-17")
|
.withIssueDate("2017-10-17")
|
||||||
.withAuthor("Smith, Donald")
|
.withAuthor("Smith, Donald")
|
||||||
@@ -363,7 +366,7 @@ public class CSVMetadataImportReferenceIT extends AbstractIntegrationTestWithDat
|
|||||||
.withRelationshipType("Person")
|
.withRelationshipType("Person")
|
||||||
.withIdentifierOther("1")
|
.withIdentifierOther("1")
|
||||||
.build();
|
.build();
|
||||||
Item person2 = ItemBuilder.createItem(context, col1)
|
ItemBuilder.createItem(context, col1)
|
||||||
.withTitle("Person2")
|
.withTitle("Person2")
|
||||||
.withIssueDate("2017-10-17")
|
.withIssueDate("2017-10-17")
|
||||||
.withAuthor("Smith, John")
|
.withAuthor("Smith, John")
|
||||||
@@ -385,7 +388,7 @@ public class CSVMetadataImportReferenceIT extends AbstractIntegrationTestWithDat
|
|||||||
@Test(expected = MetadataImportException.class)
|
@Test(expected = MetadataImportException.class)
|
||||||
public void testNonUniqueMDRefInBoth() throws Exception {
|
public void testNonUniqueMDRefInBoth() throws Exception {
|
||||||
context.turnOffAuthorisationSystem();
|
context.turnOffAuthorisationSystem();
|
||||||
Item person = ItemBuilder.createItem(context, col1)
|
ItemBuilder.createItem(context, col1)
|
||||||
.withTitle("Person")
|
.withTitle("Person")
|
||||||
.withIssueDate("2017-10-17")
|
.withIssueDate("2017-10-17")
|
||||||
.withAuthor("Smith, Donald")
|
.withAuthor("Smith, Donald")
|
||||||
@@ -402,7 +405,7 @@ public class CSVMetadataImportReferenceIT extends AbstractIntegrationTestWithDat
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test failure when refering to item by metadata that does not exist in the relation column
|
* Test failure when referring to item by metadata that does not exist in the relation column
|
||||||
*/
|
*/
|
||||||
@Test(expected = Exception.class)
|
@Test(expected = Exception.class)
|
||||||
public void testNonExistMdRef() throws Exception {
|
public void testNonExistMdRef() throws Exception {
|
||||||
@@ -413,7 +416,7 @@ public class CSVMetadataImportReferenceIT extends AbstractIntegrationTestWithDat
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test failure when refering to an item in the CSV that hasn't been created yet due to it's order in the CSV
|
* Test failure when referring to an item in the CSV that hasn't been created yet due to it's order in the CSV
|
||||||
*/
|
*/
|
||||||
@Test(expected = Exception.class)
|
@Test(expected = Exception.class)
|
||||||
public void testCSVImportWrongOrder() throws Exception {
|
public void testCSVImportWrongOrder() throws Exception {
|
||||||
@@ -424,7 +427,7 @@ public class CSVMetadataImportReferenceIT extends AbstractIntegrationTestWithDat
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test failure when refering to an item in the CSV that hasn't been created yet due to it's order in the CSV
|
* Test failure when referring to an item in the CSV that hasn't been created yet due to it's order in the CSV
|
||||||
*/
|
*/
|
||||||
@Test(expected = Exception.class)
|
@Test(expected = Exception.class)
|
||||||
public void testCSVImportWrongOrderRowName() throws Exception {
|
public void testCSVImportWrongOrderRowName() throws Exception {
|
||||||
@@ -446,7 +449,7 @@ public class CSVMetadataImportReferenceIT extends AbstractIntegrationTestWithDat
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test relationship validation with invalid relationship definition and with an archived origin referer
|
* Test relationship validation with invalid relationship definition and with an archived origin referrer.
|
||||||
*/
|
*/
|
||||||
@Test(expected = MetadataImportInvalidHeadingException.class)
|
@Test(expected = MetadataImportInvalidHeadingException.class)
|
||||||
public void testInvalidRelationshipArchivedOrigin() throws Exception {
|
public void testInvalidRelationshipArchivedOrigin() throws Exception {
|
||||||
|
@@ -7,8 +7,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.dspace.builder.util;
|
package org.dspace.builder.util;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -51,24 +51,24 @@ public class AbstractBuilderCleanupUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initMap() {
|
private void initMap() {
|
||||||
map.put(RelationshipBuilder.class.getName(), new LinkedList<>());
|
map.put(RelationshipBuilder.class.getName(), new ArrayList<>());
|
||||||
map.put(RelationshipTypeBuilder.class.getName(), new LinkedList<>());
|
map.put(RelationshipTypeBuilder.class.getName(), new ArrayList<>());
|
||||||
map.put(EntityTypeBuilder.class.getName(), new LinkedList<>());
|
map.put(EntityTypeBuilder.class.getName(), new ArrayList<>());
|
||||||
map.put(PoolTaskBuilder.class.getName(), new LinkedList<>());
|
map.put(PoolTaskBuilder.class.getName(), new ArrayList<>());
|
||||||
map.put(WorkflowItemBuilder.class.getName(), new LinkedList<>());
|
map.put(WorkflowItemBuilder.class.getName(), new ArrayList<>());
|
||||||
map.put(WorkspaceItemBuilder.class.getName(), new LinkedList<>());
|
map.put(WorkspaceItemBuilder.class.getName(), new ArrayList<>());
|
||||||
map.put(BitstreamBuilder.class.getName(), new LinkedList<>());
|
map.put(BitstreamBuilder.class.getName(), new ArrayList<>());
|
||||||
map.put(BitstreamFormatBuilder.class.getName(), new LinkedList<>());
|
map.put(BitstreamFormatBuilder.class.getName(), new ArrayList<>());
|
||||||
map.put(ClaimedTaskBuilder.class.getName(), new LinkedList<>());
|
map.put(ClaimedTaskBuilder.class.getName(), new ArrayList<>());
|
||||||
map.put(CollectionBuilder.class.getName(), new LinkedList<>());
|
map.put(CollectionBuilder.class.getName(), new ArrayList<>());
|
||||||
map.put(CommunityBuilder.class.getName(), new LinkedList<>());
|
map.put(CommunityBuilder.class.getName(), new ArrayList<>());
|
||||||
map.put(EPersonBuilder.class.getName(), new LinkedList<>());
|
map.put(EPersonBuilder.class.getName(), new ArrayList<>());
|
||||||
map.put(GroupBuilder.class.getName(), new LinkedList<>());
|
map.put(GroupBuilder.class.getName(), new ArrayList<>());
|
||||||
map.put(ItemBuilder.class.getName(), new LinkedList<>());
|
map.put(ItemBuilder.class.getName(), new ArrayList<>());
|
||||||
map.put(MetadataFieldBuilder.class.getName(), new LinkedList<>());
|
map.put(MetadataFieldBuilder.class.getName(), new ArrayList<>());
|
||||||
map.put(MetadataSchemaBuilder.class.getName(), new LinkedList<>());
|
map.put(MetadataSchemaBuilder.class.getName(), new ArrayList<>());
|
||||||
map.put(SiteBuilder.class.getName(), new LinkedList<>());
|
map.put(SiteBuilder.class.getName(), new ArrayList<>());
|
||||||
map.put(ProcessBuilder.class.getName(), new LinkedList<>());
|
map.put(ProcessBuilder.class.getName(), new ArrayList<>());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -78,7 +78,7 @@ public class AbstractBuilderCleanupUtil {
|
|||||||
* @param abstractBuilder The AbstractBuilder to be added
|
* @param abstractBuilder The AbstractBuilder to be added
|
||||||
*/
|
*/
|
||||||
public void addToMap(AbstractBuilder abstractBuilder) {
|
public void addToMap(AbstractBuilder abstractBuilder) {
|
||||||
map.computeIfAbsent(abstractBuilder.getClass().getName(), k -> new LinkedList<>()).add(abstractBuilder);
|
map.computeIfAbsent(abstractBuilder.getClass().getName(), k -> new ArrayList<>()).add(abstractBuilder);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -40,8 +40,9 @@ public class MetadataFieldNameTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = NullPointerException.class)
|
@Test(expected = NullPointerException.class)
|
||||||
|
@SuppressWarnings("ResultOfObjectAllocationIgnored")
|
||||||
public void testConstructNull() {
|
public void testConstructNull() {
|
||||||
MetadataFieldName instance = new MetadataFieldName("one", null);
|
new MetadataFieldName("one", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -71,7 +72,7 @@ public class MetadataFieldNameTest {
|
|||||||
*/
|
*/
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test(expected = IllegalArgumentException.class)
|
||||||
public void TestParse1() {
|
public void TestParse1() {
|
||||||
String[] results = MetadataFieldName.parse("one");
|
MetadataFieldName.parse("one");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -79,15 +80,16 @@ public class MetadataFieldNameTest {
|
|||||||
*/
|
*/
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test(expected = IllegalArgumentException.class)
|
||||||
public void TestParse0() {
|
public void TestParse0() {
|
||||||
String[] results = MetadataFieldName.parse("");
|
MetadataFieldName.parse("");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test of parse method using an illegal null name.
|
* Test of parse method using an illegal null name.
|
||||||
*/
|
*/
|
||||||
@Test(expected = NullPointerException.class)
|
@Test(expected = NullPointerException.class)
|
||||||
|
@SuppressWarnings("null")
|
||||||
public void TestParseNull() {
|
public void TestParseNull() {
|
||||||
String[] results = MetadataFieldName.parse(null);
|
MetadataFieldName.parse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -13,7 +13,6 @@ import static org.junit.Assert.assertNotNull;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import org.dspace.AbstractDSpaceTest;
|
import org.dspace.AbstractDSpaceTest;
|
||||||
import org.dspace.content.Collection;
|
|
||||||
import org.dspace.core.factory.CoreServiceFactory;
|
import org.dspace.core.factory.CoreServiceFactory;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
@@ -66,6 +65,8 @@ public class DSpaceControlledVocabularyTest extends AbstractDSpaceTest {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Test of getMatches method, of class DSpaceControlledVocabulary.
|
* Test of getMatches method, of class DSpaceControlledVocabulary.
|
||||||
|
* @throws java.io.IOException passed through.
|
||||||
|
* @throws java.lang.ClassNotFoundException passed through.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testGetMatches() throws IOException, ClassNotFoundException {
|
public void testGetMatches() throws IOException, ClassNotFoundException {
|
||||||
@@ -74,9 +75,7 @@ public class DSpaceControlledVocabularyTest extends AbstractDSpaceTest {
|
|||||||
final String PLUGIN_INTERFACE = "org.dspace.content.authority.ChoiceAuthority";
|
final String PLUGIN_INTERFACE = "org.dspace.content.authority.ChoiceAuthority";
|
||||||
|
|
||||||
// Ensure that 'id' attribute is optional
|
// Ensure that 'id' attribute is optional
|
||||||
String field = null; // not used
|
|
||||||
String text = "north 40";
|
String text = "north 40";
|
||||||
Collection collection = null;
|
|
||||||
int start = 0;
|
int start = 0;
|
||||||
int limit = 10;
|
int limit = 10;
|
||||||
String locale = null;
|
String locale = null;
|
||||||
|
@@ -9,8 +9,8 @@ package org.dspace.license;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@ public class MockCCLicenseConnectorServiceImpl extends CCLicenseConnectorService
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<CCLicenseField> createMockLicenseFields(int count, int[] amountOfFieldsAndEnums) {
|
private List<CCLicenseField> createMockLicenseFields(int count, int[] amountOfFieldsAndEnums) {
|
||||||
List<CCLicenseField> ccLicenseFields = new LinkedList<>();
|
List<CCLicenseField> ccLicenseFields = new ArrayList<>(amountOfFieldsAndEnums.length);
|
||||||
for (int index = 0; index < amountOfFieldsAndEnums.length; index++) {
|
for (int index = 0; index < amountOfFieldsAndEnums.length; index++) {
|
||||||
String licenseFieldId = "license" + count + "-field" + index;
|
String licenseFieldId = "license" + count + "-field" + index;
|
||||||
String licenseFieldLabel = "License " + count + " - Field " + index + " - Label";
|
String licenseFieldLabel = "License " + count + " - Field " + index + " - Label";
|
||||||
@@ -70,7 +70,7 @@ public class MockCCLicenseConnectorServiceImpl extends CCLicenseConnectorService
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<CCLicenseFieldEnum> createMockLicenseFields(int count, int index, int amountOfEnums) {
|
private List<CCLicenseFieldEnum> createMockLicenseFields(int count, int index, int amountOfEnums) {
|
||||||
List<CCLicenseFieldEnum> ccLicenseFieldEnumList = new LinkedList<>();
|
List<CCLicenseFieldEnum> ccLicenseFieldEnumList = new ArrayList<>(amountOfEnums);
|
||||||
for (int i = 0; i < amountOfEnums; i++) {
|
for (int i = 0; i < amountOfEnums; i++) {
|
||||||
String enumId = "license" + count + "-field" + index + "-enum" + i;
|
String enumId = "license" + count + "-field" + index + "-enum" + i;
|
||||||
String enumLabel = "License " + count + " - Field " + index + " - Enum " + i + " - Label";
|
String enumLabel = "License " + count + " - Field " + index + " - Enum " + i + " - Label";
|
||||||
|
@@ -65,7 +65,7 @@ import org.junit.Test;
|
|||||||
//@RunWith(MockitoJUnitRunner.class)
|
//@RunWith(MockitoJUnitRunner.class)
|
||||||
public class ITIrusExportUsageEventListener extends AbstractIntegrationTestWithDatabase {
|
public class ITIrusExportUsageEventListener extends AbstractIntegrationTestWithDatabase {
|
||||||
|
|
||||||
private static Logger log = Logger.getLogger(ITIrusExportUsageEventListener.class);
|
private static final Logger log = Logger.getLogger(ITIrusExportUsageEventListener.class);
|
||||||
|
|
||||||
|
|
||||||
protected CommunityService communityService = ContentServiceFactory.getInstance().getCommunityService();
|
protected CommunityService communityService = ContentServiceFactory.getInstance().getCommunityService();
|
||||||
@@ -86,7 +86,7 @@ public class ITIrusExportUsageEventListener extends AbstractIntegrationTestWithD
|
|||||||
.getServiceByName("testProcessedUrls",
|
.getServiceByName("testProcessedUrls",
|
||||||
ArrayList.class);
|
ArrayList.class);
|
||||||
|
|
||||||
private IrusExportUsageEventListener exportUsageEventListener =
|
private final IrusExportUsageEventListener exportUsageEventListener =
|
||||||
DSpaceServicesFactory.getInstance()
|
DSpaceServicesFactory.getInstance()
|
||||||
.getServiceManager()
|
.getServiceManager()
|
||||||
.getServicesByType(IrusExportUsageEventListener.class)
|
.getServicesByType(IrusExportUsageEventListener.class)
|
||||||
@@ -105,9 +105,11 @@ public class ITIrusExportUsageEventListener extends AbstractIntegrationTestWithD
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the test by setting up all objects needed to create a test item
|
* Initializes the test by setting up all objects needed to create a test item.
|
||||||
|
* @throws java.lang.Exception passed through.
|
||||||
*/
|
*/
|
||||||
@Before()
|
@Before()
|
||||||
|
@Override
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
|
|
||||||
@@ -152,11 +154,12 @@ public class ITIrusExportUsageEventListener extends AbstractIntegrationTestWithD
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clean up the created objects
|
* Clean up the created objects.
|
||||||
* Empty the testProcessedUrls used to store succeeded urls
|
* Empty the testProcessedUrls used to store succeeded URLs.
|
||||||
* Empty the database table where the failed urls are logged
|
* Empty the database table where the failed URLs are logged.
|
||||||
*/
|
*/
|
||||||
@After
|
@After
|
||||||
|
@Override
|
||||||
public void destroy() throws Exception {
|
public void destroy() throws Exception {
|
||||||
try {
|
try {
|
||||||
context.turnOffAuthorisationSystem();
|
context.turnOffAuthorisationSystem();
|
||||||
@@ -377,11 +380,13 @@ public class ITIrusExportUsageEventListener extends AbstractIntegrationTestWithD
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Test that an object that is not an Item or Bitstream is not processed
|
* Test that an object that is not an Item or Bitstream is not processed
|
||||||
|
* @throws java.sql.SQLException passed through.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
|
@SuppressWarnings("ResultOfMethodCallIgnored")
|
||||||
public void testReceiveEventOnNonRelevantObject() throws SQLException {
|
public void testReceiveEventOnNonRelevantObject() throws SQLException {
|
||||||
|
|
||||||
HttpServletRequest request = mock(HttpServletRequest.class);
|
mock(HttpServletRequest.class);
|
||||||
|
|
||||||
UsageEvent usageEvent = mock(UsageEvent.class);
|
UsageEvent usageEvent = mock(UsageEvent.class);
|
||||||
when(usageEvent.getObject()).thenReturn(community);
|
when(usageEvent.getObject()).thenReturn(community);
|
||||||
@@ -394,7 +399,6 @@ public class ITIrusExportUsageEventListener extends AbstractIntegrationTestWithD
|
|||||||
|
|
||||||
assertEquals(0, all.size());
|
assertEquals(0, all.size());
|
||||||
assertEquals(0, testProcessedUrls.size());
|
assertEquals(0, testProcessedUrls.size());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -408,11 +412,6 @@ public class ITIrusExportUsageEventListener extends AbstractIntegrationTestWithD
|
|||||||
|
|
||||||
Pattern p = Pattern.compile(regex);
|
Pattern p = Pattern.compile(regex);
|
||||||
|
|
||||||
if (p.matcher(string).matches()) {
|
return p.matcher(string).matches();
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -37,13 +37,13 @@ import org.junit.Test;
|
|||||||
*/
|
*/
|
||||||
public class BitstreamEventProcessorTest extends AbstractIntegrationTestWithDatabase {
|
public class BitstreamEventProcessorTest extends AbstractIntegrationTestWithDatabase {
|
||||||
|
|
||||||
private ConfigurationService configurationService = DSpaceServicesFactory.getInstance().getConfigurationService();
|
private final ConfigurationService configurationService
|
||||||
|
= DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||||
|
|
||||||
private String encodedUrl;
|
private String encodedUrl;
|
||||||
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
|
@Override
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
configurationService.setProperty("irus.statistics.tracker.enabled", true);
|
configurationService.setProperty("irus.statistics.tracker.enabled", true);
|
||||||
|
@@ -15,7 +15,8 @@ import org.apache.commons.lang.StringUtils;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mock OpenUrlService that will ensure that IRUS tracker does need to be contacted in order to test the functionality
|
* Mock OpenUrlService that will ensure that IRUS tracker does need to be
|
||||||
|
* contacted in order to test the functionality.
|
||||||
*/
|
*/
|
||||||
public class MockOpenUrlServiceImpl extends OpenUrlServiceImpl {
|
public class MockOpenUrlServiceImpl extends OpenUrlServiceImpl {
|
||||||
|
|
||||||
@@ -23,13 +24,14 @@ public class MockOpenUrlServiceImpl extends OpenUrlServiceImpl {
|
|||||||
ArrayList testProcessedUrls;
|
ArrayList testProcessedUrls;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a response code to simulate contact to the external url
|
* Returns a response code to simulate contact to the external URL.
|
||||||
* When the url contains "fail", a fail code 500 will be returned
|
* When the URL contains "fail", a fail code 500 will be returned.
|
||||||
* Otherwise the success code 200 will be returned
|
* Otherwise the success code 200 will be returned.
|
||||||
* @param urlStr
|
* @param urlStr
|
||||||
* @return 200 or 500 depending on whether the "fail" keyword is present in the url
|
* @return 200 or 500 depending on whether the "fail" keyword is present in the URL.
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
protected int getResponseCodeFromUrl(final String urlStr) throws IOException {
|
protected int getResponseCodeFromUrl(final String urlStr) throws IOException {
|
||||||
if (StringUtils.contains(urlStr, "fail")) {
|
if (StringUtils.contains(urlStr, "fail")) {
|
||||||
return HttpURLConnection.HTTP_INTERNAL_ERROR;
|
return HttpURLConnection.HTTP_INTERNAL_ERROR;
|
||||||
|
Reference in New Issue
Block a user