mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-14 05:23:14 +00:00
More errorprone warnings. #3061
This commit is contained in:
@@ -81,7 +81,7 @@ public class MetadataImporter {
|
||||
* @throws SQLException if database error
|
||||
* @throws IOException if IO error
|
||||
* @throws TransformerException if transformer error
|
||||
* @throws ParserConfigurationException if config error
|
||||
* @throws ParserConfigurationException if configuration error
|
||||
* @throws AuthorizeException if authorization error
|
||||
* @throws SAXException if parser error
|
||||
* @throws NonUniqueMetadataException if duplicate metadata
|
||||
@@ -91,7 +91,6 @@ public class MetadataImporter {
|
||||
throws ParseException, SQLException, IOException, TransformerException,
|
||||
ParserConfigurationException, AuthorizeException, SAXException,
|
||||
NonUniqueMetadataException, RegistryImportException {
|
||||
boolean forceUpdate = false;
|
||||
|
||||
// create an options object and populate it
|
||||
CommandLineParser parser = new DefaultParser();
|
||||
@@ -100,16 +99,14 @@ public class MetadataImporter {
|
||||
options.addOption("u", "update", false, "update an existing schema");
|
||||
CommandLine line = parser.parse(options, args);
|
||||
|
||||
String file = null;
|
||||
if (line.hasOption('f')) {
|
||||
file = line.getOptionValue('f');
|
||||
String file = line.getOptionValue('f');
|
||||
boolean forceUpdate = line.hasOption('u');
|
||||
loadRegistry(file, forceUpdate);
|
||||
} else {
|
||||
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 IOException if IO error
|
||||
* @throws TransformerException if transformer error
|
||||
* @throws ParserConfigurationException if config error
|
||||
* @throws ParserConfigurationException if configuration error
|
||||
* @throws AuthorizeException if authorization error
|
||||
* @throws SAXException if parser error
|
||||
* @throws NonUniqueMetadataException if duplicate metadata
|
||||
@@ -227,7 +224,7 @@ public class MetadataImporter {
|
||||
/**
|
||||
* Process a node in the metadata registry XML file. The node must
|
||||
* 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 node the node in the DOM tree
|
||||
|
@@ -159,7 +159,7 @@ public class DSpaceCSV implements Serializable {
|
||||
columnCounter++;
|
||||
|
||||
// Remove surrounding quotes if there are any
|
||||
if ((element.startsWith("\"")) && (element.endsWith("\""))) {
|
||||
if (element.startsWith("\"") && element.endsWith("\"")) {
|
||||
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.
|
||||
*
|
||||
* 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() {
|
||||
// Get the value separator
|
||||
valueSeparator = DSpaceServicesFactory.getInstance().getConfigurationService()
|
||||
.getProperty("bulkedit.valueseparator");
|
||||
if ((valueSeparator != null) && (!"".equals(valueSeparator.trim()))) {
|
||||
if ((valueSeparator != null) && !valueSeparator.trim().isEmpty()) {
|
||||
valueSeparator = valueSeparator.trim();
|
||||
} else {
|
||||
valueSeparator = "||";
|
||||
@@ -357,7 +357,7 @@ public class DSpaceCSV implements Serializable {
|
||||
/**
|
||||
* 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 ','.
|
||||
*
|
||||
@@ -368,7 +368,7 @@ public class DSpaceCSV implements Serializable {
|
||||
// Get the value separator
|
||||
fieldSeparator = DSpaceServicesFactory.getInstance().getConfigurationService()
|
||||
.getProperty("bulkedit.fieldseparator");
|
||||
if ((fieldSeparator != null) && (!"".equals(fieldSeparator.trim()))) {
|
||||
if ((fieldSeparator != null) && !fieldSeparator.trim().isEmpty()) {
|
||||
fieldSeparator = fieldSeparator.trim();
|
||||
if ("tab".equals(fieldSeparator)) {
|
||||
fieldSeparator = "\t";
|
||||
@@ -392,15 +392,15 @@ public class DSpaceCSV implements Serializable {
|
||||
/**
|
||||
* 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() {
|
||||
// Get the value separator
|
||||
authoritySeparator = DSpaceServicesFactory.getInstance().getConfigurationService()
|
||||
.getProperty("bulkedit.authorityseparator");
|
||||
if ((authoritySeparator != null) && (!"".equals(authoritySeparator.trim()))) {
|
||||
if ((authoritySeparator != null) && !authoritySeparator.trim().isEmpty()) {
|
||||
authoritySeparator = authoritySeparator.trim();
|
||||
} else {
|
||||
authoritySeparator = "::";
|
||||
@@ -505,7 +505,7 @@ public class DSpaceCSV implements Serializable {
|
||||
int i = 0;
|
||||
for (String part : bits) {
|
||||
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;
|
||||
String add = bits.get(i) + fieldSeparator + bits.get(i + 1);
|
||||
bits.remove(i);
|
||||
@@ -521,7 +521,7 @@ public class DSpaceCSV implements Serializable {
|
||||
// Deal with quotes around the elements
|
||||
int i = 0;
|
||||
for (String part : bits) {
|
||||
if ((part.startsWith("\"")) && (part.endsWith("\""))) {
|
||||
if (part.startsWith("\"") && part.endsWith("\"")) {
|
||||
part = part.substring(1, part.length() - 1);
|
||||
bits.set(i, part);
|
||||
}
|
||||
@@ -561,7 +561,7 @@ public class DSpaceCSV implements Serializable {
|
||||
for (String part : bits) {
|
||||
if (i > 0) {
|
||||
// Is this a last empty item?
|
||||
if ((last) && (i == headings.size())) {
|
||||
if (last && (i == headings.size())) {
|
||||
part = "";
|
||||
}
|
||||
|
||||
@@ -574,7 +574,7 @@ public class DSpaceCSV implements Serializable {
|
||||
csvLine.add(headings.get(i - 1), null);
|
||||
String[] elements = part.split(escapedValueSeparator);
|
||||
for (String element : elements) {
|
||||
if ((element != null) && (!"".equals(element))) {
|
||||
if ((element != null) && !"".equals(element)) {
|
||||
csvLine.add(headings.get(i - 1), element);
|
||||
}
|
||||
}
|
||||
@@ -626,18 +626,18 @@ public class DSpaceCSV implements Serializable {
|
||||
public InputStream getInputStream() {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
for (String csvLine : getCSVLinesAsStringArray()) {
|
||||
stringBuilder.append(csvLine + "\n");
|
||||
stringBuilder.append(csvLine).append("\n");
|
||||
}
|
||||
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.
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
protected boolean okToExport(MetadataField md) {
|
||||
@@ -646,12 +646,8 @@ public class DSpaceCSV implements Serializable {
|
||||
if (md.getQualifier() != null) {
|
||||
key += "." + md.getQualifier();
|
||||
}
|
||||
if (ignore.get(key) != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Must be OK, so don't ignore
|
||||
return true;
|
||||
return ignore.get(key) == null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -120,6 +120,7 @@ class DtoMetadata {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String s = "\tSchema: " + schema + " Element: " + element;
|
||||
if (qualifier != null) {
|
||||
|
@@ -17,6 +17,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
@@ -55,7 +56,7 @@ public class ItemArchive {
|
||||
protected Transformer transformer = 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
|
||||
|
||||
@@ -325,7 +326,7 @@ public class ItemArchive {
|
||||
PrintWriter pw = null;
|
||||
try {
|
||||
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) {
|
||||
pw.println(i);
|
||||
}
|
||||
|
@@ -8,12 +8,13 @@
|
||||
package org.dspace.app.sherpa;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.LinkedList;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.app.util.XMLUtils;
|
||||
import org.w3c.dom.Document;
|
||||
@@ -25,7 +26,7 @@ import org.w3c.dom.Element;
|
||||
* @author Andrea Bollini
|
||||
*/
|
||||
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;
|
||||
|
||||
@@ -81,7 +82,7 @@ public class SHERPAResponse {
|
||||
publishersElement, "publisher");
|
||||
|
||||
if (journalsList != null) {
|
||||
journals = new LinkedList<SHERPAJournal>();
|
||||
journals = new ArrayList<>(journalsList.size());
|
||||
for (Element journalElement : journalsList) {
|
||||
journals.add(new SHERPAJournal(
|
||||
XMLUtils.getElementValue(journalElement, "jtitle"),
|
||||
@@ -92,7 +93,7 @@ public class SHERPAResponse {
|
||||
}
|
||||
|
||||
if (publishersList != null) {
|
||||
publishers = new LinkedList<SHERPAPublisher>();
|
||||
publishers = new ArrayList<>(publishersList.size());
|
||||
for (Element publisherElement : publishersList) {
|
||||
Element preprintsElement = XMLUtils.getSingleElement(
|
||||
publisherElement, "preprints");
|
||||
|
@@ -64,10 +64,6 @@ public class CreateStatReport {
|
||||
*/
|
||||
private static Context context;
|
||||
|
||||
/**
|
||||
* the config file from which to configure the analyser
|
||||
*/
|
||||
|
||||
/**
|
||||
* Default constructor
|
||||
*/
|
||||
@@ -170,22 +166,19 @@ public class CreateStatReport {
|
||||
String myLogDir = null;
|
||||
String myFileTemplate = null;
|
||||
String myConfigFile = null;
|
||||
StringBuffer myOutFile = null;
|
||||
Date myStartDate = null;
|
||||
Date myEndDate = null;
|
||||
boolean myLookUp = false;
|
||||
|
||||
Calendar start = new GregorianCalendar(calendar.get(Calendar.YEAR),
|
||||
calendar.get(Calendar.MONTH),
|
||||
calendar.getActualMinimum(Calendar.DAY_OF_MONTH));
|
||||
myStartDate = start.getTime();
|
||||
Date myStartDate = start.getTime();
|
||||
|
||||
Calendar end = new GregorianCalendar(calendar.get(Calendar.YEAR),
|
||||
calendar.get(Calendar.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(calendar.get(Calendar.YEAR));
|
||||
myOutFile.append("-");
|
||||
@@ -211,12 +204,11 @@ public class CreateStatReport {
|
||||
String myLogDir = null;
|
||||
String myFileTemplate = null;
|
||||
String myConfigFile = null;
|
||||
StringBuffer myOutFile = null;
|
||||
Date myStartDate = null;
|
||||
Date myEndDate = null;
|
||||
boolean myLookUp = false;
|
||||
|
||||
myOutFile = new StringBuffer(outputLogDirectory);
|
||||
StringBuilder myOutFile = new StringBuilder(outputLogDirectory);
|
||||
myOutFile.append(outputPrefix);
|
||||
myOutFile.append(calendar.get(Calendar.YEAR));
|
||||
myOutFile.append("-");
|
||||
@@ -245,9 +237,6 @@ public class CreateStatReport {
|
||||
String myLogDir = null;
|
||||
String myFileTemplate = null;
|
||||
String myConfigFile = null;
|
||||
StringBuffer myOutFile = null;
|
||||
Date myStartDate = null;
|
||||
Date myEndDate = null;
|
||||
boolean myLookUp = false;
|
||||
|
||||
Calendar reportEndDate = new GregorianCalendar(calendar.get(Calendar.YEAR),
|
||||
@@ -260,14 +249,14 @@ public class CreateStatReport {
|
||||
Calendar start = new GregorianCalendar(currentMonth.get(Calendar.YEAR),
|
||||
currentMonth.get(Calendar.MONTH),
|
||||
currentMonth.getActualMinimum(Calendar.DAY_OF_MONTH));
|
||||
myStartDate = start.getTime();
|
||||
Date myStartDate = start.getTime();
|
||||
|
||||
Calendar end = new GregorianCalendar(currentMonth.get(Calendar.YEAR),
|
||||
currentMonth.get(Calendar.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(currentMonth.get(Calendar.YEAR));
|
||||
myOutFile.append("-");
|
||||
@@ -293,11 +282,9 @@ public class CreateStatReport {
|
||||
String outputPrefix = "report-general-";
|
||||
|
||||
String myFormat = "html";
|
||||
StringBuffer myInput = null;
|
||||
StringBuffer myOutput = null;
|
||||
String myMap = null;
|
||||
|
||||
myInput = new StringBuffer(outputLogDirectory);
|
||||
StringBuilder myInput = new StringBuilder(outputLogDirectory);
|
||||
myInput.append(inputPrefix);
|
||||
myInput.append(calendar.get(Calendar.YEAR));
|
||||
myInput.append("-");
|
||||
@@ -306,7 +293,7 @@ public class CreateStatReport {
|
||||
myInput.append(calendar.get(Calendar.DAY_OF_MONTH));
|
||||
myInput.append(outputSuffix);
|
||||
|
||||
myOutput = new StringBuffer(outputReportDirectory);
|
||||
StringBuilder myOutput = new StringBuilder(outputReportDirectory);
|
||||
myOutput.append(outputPrefix);
|
||||
myOutput.append(calendar.get(Calendar.YEAR));
|
||||
myOutput.append("-");
|
||||
@@ -332,8 +319,6 @@ public class CreateStatReport {
|
||||
String outputPrefix = "report-";
|
||||
|
||||
String myFormat = "html";
|
||||
StringBuffer myInput = null;
|
||||
StringBuffer myOutput = null;
|
||||
String myMap = null;
|
||||
|
||||
Calendar reportEndDate = new GregorianCalendar(calendar.get(Calendar.YEAR),
|
||||
@@ -344,14 +329,14 @@ public class CreateStatReport {
|
||||
|
||||
while (currentMonth.before(reportEndDate)) {
|
||||
|
||||
myInput = new StringBuffer(outputLogDirectory);
|
||||
StringBuilder myInput = new StringBuilder(outputLogDirectory);
|
||||
myInput.append(inputPrefix);
|
||||
myInput.append(currentMonth.get(Calendar.YEAR));
|
||||
myInput.append("-");
|
||||
myInput.append(currentMonth.get(Calendar.MONTH) + 1);
|
||||
myInput.append(outputSuffix);
|
||||
|
||||
myOutput = new StringBuffer(outputReportDirectory);
|
||||
StringBuilder myOutput = new StringBuilder(outputReportDirectory);
|
||||
myOutput.append(outputPrefix);
|
||||
myOutput.append(currentMonth.get(Calendar.YEAR));
|
||||
myOutput.append("-");
|
||||
@@ -376,18 +361,16 @@ public class CreateStatReport {
|
||||
String outputPrefix = "report-";
|
||||
|
||||
String myFormat = "html";
|
||||
StringBuffer myInput = null;
|
||||
StringBuffer myOutput = null;
|
||||
String myMap = null;
|
||||
|
||||
myInput = new StringBuffer(outputLogDirectory);
|
||||
StringBuilder myInput = new StringBuilder(outputLogDirectory);
|
||||
myInput.append(inputPrefix);
|
||||
myInput.append(calendar.get(Calendar.YEAR));
|
||||
myInput.append("-");
|
||||
myInput.append(calendar.get(Calendar.MONTH) + 1);
|
||||
myInput.append(outputSuffix);
|
||||
|
||||
myOutput = new StringBuffer(outputReportDirectory);
|
||||
StringBuilder myOutput = new StringBuilder(outputReportDirectory);
|
||||
myOutput.append(outputPrefix);
|
||||
myOutput.append(calendar.get(Calendar.YEAR));
|
||||
myOutput.append("-");
|
||||
|
@@ -58,6 +58,7 @@ public class WebApp implements ReloadableEntity<Integer> {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getID() {
|
||||
return id;
|
||||
}
|
||||
|
@@ -8,7 +8,6 @@
|
||||
package org.dspace.app.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -29,13 +28,13 @@ public class XMLUtils {
|
||||
|
||||
/**
|
||||
* @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
|
||||
* of the starting node
|
||||
*/
|
||||
public static List<Element> getElementList(Element dataRoot, String 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++) {
|
||||
Element item = (Element) list.item(i);
|
||||
if (item.getParentNode().equals(dataRoot)) {
|
||||
@@ -105,7 +104,7 @@ public class XMLUtils {
|
||||
|
||||
/**
|
||||
* @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
|
||||
* element with the specified name. If there are not sub element
|
||||
* with the supplied name the method will return null
|
||||
@@ -121,7 +120,7 @@ public class XMLUtils {
|
||||
return null;
|
||||
}
|
||||
|
||||
List<String> result = new LinkedList<String>();
|
||||
List<String> result = new ArrayList<>();
|
||||
for (Element el : subElements) {
|
||||
if (StringUtils.isNotBlank(el.getTextContent())) {
|
||||
result.add(el.getTextContent().trim());
|
||||
@@ -152,7 +151,7 @@ public class XMLUtils {
|
||||
return null;
|
||||
}
|
||||
|
||||
List<String[]> result = new LinkedList<String[]>();
|
||||
List<String[]> result = new ArrayList<>();
|
||||
for (Element el : subElements) {
|
||||
String[] tmp = new String[fieldsName.length];
|
||||
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>.
|
||||
*
|
||||
* @author Larry Stone
|
||||
* @version $Revision$
|
||||
*/
|
||||
public class PasswordAuthentication
|
||||
implements AuthenticationMethod {
|
||||
@@ -49,7 +48,7 @@ public class PasswordAuthentication
|
||||
/**
|
||||
* 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())) {
|
||||
String groupName = DSpaceServicesFactory.getInstance().getConfigurationService()
|
||||
.getProperty("authentication-password.login.specialgroup");
|
||||
if ((groupName != null) && (!groupName.trim().equals(""))) {
|
||||
if ((groupName != null) && !groupName.trim().isEmpty()) {
|
||||
Group specialGroup = EPersonServiceFactory.getInstance().getGroupService()
|
||||
.findByName(context, groupName);
|
||||
if (specialGroup == null) {
|
||||
@@ -195,9 +194,8 @@ public class PasswordAuthentication
|
||||
HttpServletRequest request)
|
||||
throws SQLException {
|
||||
if (username != null && password != null) {
|
||||
EPerson eperson = null;
|
||||
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());
|
||||
|
||||
if (eperson == null) {
|
||||
|
@@ -11,7 +11,6 @@ import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@@ -228,7 +227,7 @@ public class AuthorizeServiceImpl implements AuthorizeService {
|
||||
// If authorization was given before and cached
|
||||
Boolean cachedResult = c.getCachedAuthorizationResult(o, action, e);
|
||||
if (cachedResult != null) {
|
||||
return cachedResult.booleanValue();
|
||||
return cachedResult;
|
||||
}
|
||||
|
||||
// is eperson set? if not, userToCheck = null (anonymous)
|
||||
@@ -293,7 +292,7 @@ public class AuthorizeServiceImpl implements AuthorizeService {
|
||||
}
|
||||
|
||||
if ((rp.getGroup() != null)
|
||||
&& (groupService.isMember(c, e, rp.getGroup()))) {
|
||||
&& groupService.isMember(c, e, rp.getGroup())) {
|
||||
// group was set, and eperson is a member
|
||||
// of that group
|
||||
c.cacheAuthorizedAction(o, action, e, true, rp);
|
||||
@@ -351,7 +350,7 @@ public class AuthorizeServiceImpl implements AuthorizeService {
|
||||
|
||||
Boolean cachedResult = c.getCachedAuthorizationResult(o, Constants.ADMIN, e);
|
||||
if (cachedResult != null) {
|
||||
return cachedResult.booleanValue();
|
||||
return cachedResult;
|
||||
}
|
||||
|
||||
//
|
||||
@@ -368,7 +367,7 @@ public class AuthorizeServiceImpl implements AuthorizeService {
|
||||
}
|
||||
|
||||
if ((rp.getGroup() != null)
|
||||
&& (groupService.isMember(c, e, rp.getGroup()))) {
|
||||
&& groupService.isMember(c, e, rp.getGroup())) {
|
||||
// group was set, and eperson is a member
|
||||
// of that group
|
||||
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 {
|
||||
EPerson e = c.getCurrentUser();
|
||||
return isCommunityAdmin(c, e);
|
||||
@@ -448,6 +448,7 @@ public class AuthorizeServiceImpl implements AuthorizeService {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollectionAdmin(Context c) throws SQLException {
|
||||
EPerson e = c.getCurrentUser();
|
||||
return isCollectionAdmin(c, e);
|
||||
@@ -527,7 +528,7 @@ public class AuthorizeServiceImpl implements AuthorizeService {
|
||||
List<ResourcePolicy> policies = getPolicies(c, src);
|
||||
|
||||
//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) {
|
||||
if (rp.getAction() != Constants.ADMIN) {
|
||||
nonAdminPolicies.add(rp);
|
||||
@@ -550,7 +551,7 @@ public class AuthorizeServiceImpl implements AuthorizeService {
|
||||
public void addPolicies(Context c, List<ResourcePolicy> policies, DSpaceObject dest)
|
||||
throws SQLException, AuthorizeException {
|
||||
// now add them to the destination object
|
||||
List<ResourcePolicy> newPolicies = new LinkedList<>();
|
||||
List<ResourcePolicy> newPolicies = new ArrayList<>(policies.size());
|
||||
|
||||
for (ResourcePolicy srp : policies) {
|
||||
ResourcePolicy rp = resourcePolicyService.create(c);
|
||||
@@ -625,7 +626,7 @@ public class AuthorizeServiceImpl implements AuthorizeService {
|
||||
int actionID) throws java.sql.SQLException {
|
||||
List<ResourcePolicy> policies = getPoliciesActionFilter(c, o, actionID);
|
||||
|
||||
List<Group> groups = new ArrayList<Group>();
|
||||
List<Group> groups = new ArrayList<>();
|
||||
for (ResourcePolicy resourcePolicy : policies) {
|
||||
if (resourcePolicy.getGroup() != null && resourcePolicyService.isDateValid(resourcePolicy)) {
|
||||
groups.add(resourcePolicy.getGroup());
|
||||
|
@@ -170,7 +170,7 @@ public class MostRecentChecksum implements Serializable {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
if (o == null || !(o instanceof MostRecentChecksum)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@@ -109,7 +109,7 @@ public class ResultsLogger implements ChecksumResultsCollector {
|
||||
"unknown"));
|
||||
LOG.info(msg("new-checksum") + ": " + info.getCurrentChecksum());
|
||||
LOG.info(msg("checksum-comparison-result") + ": "
|
||||
+ (info.getChecksumResult().getResultCode()));
|
||||
+ info.getChecksumResult().getResultCode());
|
||||
LOG.info("\n\n");
|
||||
}
|
||||
}
|
||||
|
@@ -9,7 +9,7 @@ package org.dspace.content;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.sql.SQLException;
|
||||
import java.util.LinkedList;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.persistence.CollectionTable;
|
||||
import javax.persistence.Column;
|
||||
@@ -111,7 +111,7 @@ public class BitstreamFormat implements Serializable, ReloadableEntity<Integer>
|
||||
* {@link org.dspace.content.service.BitstreamFormatService#create(Context)}
|
||||
*/
|
||||
protected BitstreamFormat() {
|
||||
fileExtensions = new LinkedList<>();
|
||||
fileExtensions = new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -9,7 +9,6 @@ package org.dspace.content;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
@@ -138,7 +137,7 @@ public class Bundle extends DSpaceObject implements DSpaceObjectLegacySupport {
|
||||
* @return the bitstreams
|
||||
*/
|
||||
public List<Bitstream> getBitstreams() {
|
||||
List<Bitstream> bitstreamList = new LinkedList<>(this.bitstreams);
|
||||
List<Bitstream> bitstreamList = new ArrayList<>(this.bitstreams);
|
||||
return bitstreamList;
|
||||
}
|
||||
|
||||
@@ -191,7 +190,7 @@ public class Bundle extends DSpaceObject implements DSpaceObjectLegacySupport {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
if (obj == null || !(obj instanceof Bundle)) {
|
||||
return false;
|
||||
}
|
||||
Class<?> objClass = HibernateProxyHelper.getClassWithoutInitializingProxy(obj);
|
||||
@@ -202,10 +201,7 @@ public class Bundle extends DSpaceObject implements DSpaceObjectLegacySupport {
|
||||
if (this.getType() != other.getType()) {
|
||||
return false;
|
||||
}
|
||||
if (!this.getID().equals(other.getID())) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return this.getID().equals(other.getID());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -34,8 +34,8 @@ import org.apache.logging.log4j.Logger;
|
||||
* There are four levels of granularity, depending on how much date information
|
||||
* is available: year, month, day, time.
|
||||
* <P>
|
||||
* Examples: <code>1994-05-03T15:30:24</code>,<code>1995-10-04</code>,
|
||||
* <code>2001-10</code>,<code>1975</code>
|
||||
* Examples: {@code 1994-05-03T15:30:24}, {@code 1995-10-04},
|
||||
* {@code 2001-10}, {@code 1975}
|
||||
*
|
||||
* @author Robert Tansley
|
||||
* @author Larry Stone
|
||||
@@ -261,7 +261,7 @@ public class DCDate {
|
||||
* @return the year
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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.
|
||||
*
|
||||
|
@@ -8,10 +8,9 @@
|
||||
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
|
||||
* @version $Id$
|
||||
*/
|
||||
public class DCSeriesNumber {
|
||||
/**
|
||||
@@ -70,6 +69,7 @@ public class DCSeriesNumber {
|
||||
*
|
||||
* @return the series and number as they should be stored in the DB
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
if (series == null) {
|
||||
return (null);
|
||||
|
@@ -13,7 +13,6 @@ import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
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,
|
||||
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,
|
||||
newValueLanguage, value);
|
||||
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
|
||||
Map<MetadataField, Integer> fieldToLastPlace = new HashMap<>();
|
||||
List<MetadataValue> metadataValues = new LinkedList<>();
|
||||
List<MetadataValue> metadataValues;
|
||||
if (dso.getType() == Constants.ITEM) {
|
||||
metadataValues = getMetadata(dso, Item.ANY, Item.ANY, Item.ANY, Item.ANY);
|
||||
} else {
|
||||
@@ -628,7 +627,7 @@ public abstract class DSpaceObjectServiceImpl<T extends DSpaceObject> implements
|
||||
String authority = metadataValue.getAuthority();
|
||||
String relationshipId = StringUtils.split(authority, "::")[1];
|
||||
Relationship relationship = relationshipService.find(context, Integer.parseInt(relationshipId));
|
||||
if (relationship.getLeftItem() == (Item) dso) {
|
||||
if (relationship.getLeftItem().equals((Item) dso)) {
|
||||
relationship.setLeftPlace(mvPlace);
|
||||
} else {
|
||||
relationship.setRightPlace(mvPlace);
|
||||
|
@@ -78,6 +78,7 @@ public class EntityType implements ReloadableEntity<Integer> {
|
||||
*
|
||||
* @return The ID for this EntityType
|
||||
*/
|
||||
@Override
|
||||
public Integer getID() {
|
||||
return id;
|
||||
}
|
||||
@@ -87,6 +88,7 @@ public class EntityType implements ReloadableEntity<Integer> {
|
||||
* @param obj object to be compared
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof EntityType)) {
|
||||
return false;
|
||||
@@ -97,10 +99,7 @@ public class EntityType implements ReloadableEntity<Integer> {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!StringUtils.equals(this.getLabel(), entityType.getLabel())) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return StringUtils.equals(this.getLabel(), entityType.getLabel());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -218,6 +218,7 @@ public class Relationship implements ReloadableEntity<Integer> {
|
||||
* Standard getter for the ID for this Relationship
|
||||
* @return The ID of this relationship
|
||||
*/
|
||||
@Override
|
||||
public Integer getID() {
|
||||
return id;
|
||||
}
|
||||
|
@@ -201,7 +201,7 @@ public class RelationshipType implements ReloadableEntity<Integer> {
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
this.leftMinCardinality = leftMinCardinality;
|
||||
@@ -217,7 +217,7 @@ public class RelationshipType implements ReloadableEntity<Integer> {
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
this.leftMaxCardinality = leftMaxCardinality;
|
||||
@@ -233,7 +233,7 @@ public class RelationshipType implements ReloadableEntity<Integer> {
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
this.rightMinCardinality = rightMinCardinality;
|
||||
@@ -249,7 +249,7 @@ public class RelationshipType implements ReloadableEntity<Integer> {
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
this.rightMaxCardinality = rightMaxCardinality;
|
||||
@@ -291,6 +291,7 @@ public class RelationshipType implements ReloadableEntity<Integer> {
|
||||
* Standard getter for the ID of this RelationshipType
|
||||
* @return The ID of this RelationshipType
|
||||
*/
|
||||
@Override
|
||||
public Integer getID() {
|
||||
return id;
|
||||
}
|
||||
|
@@ -8,7 +8,7 @@
|
||||
package org.dspace.content.dao.impl;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.LinkedList;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.persistence.Query;
|
||||
import javax.persistence.criteria.CriteriaBuilder;
|
||||
@@ -63,7 +63,7 @@ public class MetadataSchemaDAOImpl extends AbstractHibernateDAO<MetadataSchema>
|
||||
Root<MetadataSchema> metadataSchemaRoot = criteriaQuery.from(MetadataSchema.class);
|
||||
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)));
|
||||
criteriaQuery.orderBy(orderList);
|
||||
|
||||
|
@@ -19,7 +19,6 @@ import org.apache.logging.log4j.Logger;
|
||||
* exceptions. This class is intended for declarations and catch clauses.
|
||||
*
|
||||
* @author Larry Stone
|
||||
* @version $Revision$
|
||||
*/
|
||||
public class PackageException extends Exception {
|
||||
/**
|
||||
@@ -76,10 +75,4 @@ public class PackageException extends Exception {
|
||||
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) {
|
||||
result.setProperty(name, v[0]);
|
||||
} else {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < v.length; ++i) {
|
||||
if (i > 0) {
|
||||
sb.append(SEPARATOR);
|
||||
|
@@ -8,7 +8,6 @@
|
||||
package org.dspace.content.virtual;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.dspace.content.Item;
|
||||
@@ -24,9 +23,7 @@ public class UUIDValue implements VirtualMetadataConfiguration {
|
||||
|
||||
@Override
|
||||
public List<String> getValues(Context context, Item item) throws SQLException {
|
||||
List<String> list = new LinkedList<>();
|
||||
list.add(String.valueOf(item.getID()));
|
||||
return list;
|
||||
return List.of(String.valueOf(item.getID()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -8,13 +8,13 @@
|
||||
package org.dspace.core;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EmptyStackException;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
import java.util.Stack;
|
||||
import java.util.UUID;
|
||||
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
|
||||
*/
|
||||
private Stack<Boolean> authStateChangeHistory;
|
||||
private ArrayDeque<Boolean> authStateChangeHistory;
|
||||
|
||||
/**
|
||||
* A stack with the name of the caller class that modify authorisation
|
||||
* system check
|
||||
*/
|
||||
private Stack<String> authStateClassCallHistory;
|
||||
private ArrayDeque<String> authStateClassCallHistory;
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
private ContextReadOnlyCache readOnlyCache = new ContextReadOnlyCache();
|
||||
private final ContextReadOnlyCache readOnlyCache = new ContextReadOnlyCache();
|
||||
|
||||
protected EventService eventService;
|
||||
|
||||
@@ -183,8 +183,8 @@ public class Context implements AutoCloseable {
|
||||
|
||||
specialGroups = new ArrayList<>();
|
||||
|
||||
authStateChangeHistory = new Stack<>();
|
||||
authStateClassCallHistory = new Stack<>();
|
||||
authStateChangeHistory = new ArrayDeque<>();
|
||||
authStateClassCallHistory = new ArrayDeque<>();
|
||||
setMode(this.mode);
|
||||
}
|
||||
|
||||
@@ -336,7 +336,7 @@ public class Context implements AutoCloseable {
|
||||
+ 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");
|
||||
}
|
||||
if (events == null) {
|
||||
events = new LinkedList<Event>();
|
||||
events = new LinkedList<>();
|
||||
}
|
||||
|
||||
events.add(event);
|
||||
@@ -622,11 +622,7 @@ public class Context implements AutoCloseable {
|
||||
* @return true if member
|
||||
*/
|
||||
public boolean inSpecialGroup(UUID groupID) {
|
||||
if (specialGroups.contains(groupID)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return specialGroups.contains(groupID);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -636,7 +632,7 @@ public class Context implements AutoCloseable {
|
||||
* @throws SQLException if database error
|
||||
*/
|
||||
public List<Group> getSpecialGroups() throws SQLException {
|
||||
List<Group> myGroups = new ArrayList<Group>();
|
||||
List<Group> myGroups = new ArrayList<>();
|
||||
for (UUID groupId : specialGroups) {
|
||||
myGroups.add(EPersonServiceFactory.getInstance().getGroupService().find(this, groupId));
|
||||
}
|
||||
@@ -661,7 +657,7 @@ public class Context implements AutoCloseable {
|
||||
|
||||
currentUserPreviousState = currentUser;
|
||||
specialGroupsPreviousState = specialGroups;
|
||||
specialGroups = new ArrayList<UUID>();
|
||||
specialGroups = new ArrayList<>();
|
||||
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
|
||||
* means that more memory is consumed by the cache. This also has a negative impact on the query performance. In
|
||||
* that case you should consider uncaching entities when they are no longer needed (see
|
||||
* {@link Context#uncacheEntity(ReloadableEntity)} () uncacheEntity}).
|
||||
* Returns the size of the cache of all object that have been read from the
|
||||
* database so far. A larger number means that more memory is consumed by
|
||||
* the cache. This also has a negative impact on the query performance. In
|
||||
* 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.
|
||||
*/
|
||||
public long getCacheSize() throws SQLException {
|
||||
|
@@ -320,11 +320,11 @@ public class I18nUtil {
|
||||
fileType = "";
|
||||
}
|
||||
|
||||
if (!("".equals(locale.getCountry()))) {
|
||||
if (!"".equals(locale.getCountry())) {
|
||||
fileNameLC = fileName + "_" + locale.getLanguage() + "_"
|
||||
+ locale.getCountry();
|
||||
|
||||
if (!("".equals(locale.getVariant()))) {
|
||||
if (!"".equals(locale.getVariant())) {
|
||||
fileNameLCV = fileName + "_" + locale.getLanguage() + "_"
|
||||
+ locale.getCountry() + "_" + locale.getVariant();
|
||||
}
|
||||
|
@@ -13,16 +13,17 @@ import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
|
||||
|
||||
/**
|
||||
* FileTaskQueue provides a TaskQueue implementation based on flat files
|
||||
* for the queues and semaphores.
|
||||
@@ -30,14 +31,16 @@ import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
* @author richardrodgers
|
||||
*/
|
||||
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
|
||||
protected String tqDir;
|
||||
|
||||
// ticket for queue readers
|
||||
protected long readTicket = -1L;
|
||||
|
||||
// list of queues owned by reader
|
||||
protected List<Integer> readList = new ArrayList<Integer>();
|
||||
protected List<Integer> readList = new ArrayList<>();
|
||||
|
||||
public FileTaskQueue() {
|
||||
tqDir = DSpaceServicesFactory.getInstance().getConfigurationService().getProperty("curate.taskqueue.dir");
|
||||
@@ -72,7 +75,7 @@ public class FileTaskQueue implements TaskQueue {
|
||||
BufferedWriter writer = null;
|
||||
try {
|
||||
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();
|
||||
while (iter.hasNext()) {
|
||||
writer.write(iter.next().toString());
|
||||
@@ -96,7 +99,7 @@ public class FileTaskQueue implements TaskQueue {
|
||||
@Override
|
||||
public synchronized Set<TaskQueueEntry> dequeue(String queueName, long ticket)
|
||||
throws IOException {
|
||||
Set<TaskQueueEntry> entrySet = new HashSet<TaskQueueEntry>();
|
||||
Set<TaskQueueEntry> entrySet = new HashSet<>();
|
||||
if (readTicket == -1L) {
|
||||
// hold the ticket & copy all Ids available, locking queues
|
||||
// stop when no more queues or one found locked
|
||||
@@ -113,8 +116,8 @@ public class FileTaskQueue implements TaskQueue {
|
||||
// read contents from file
|
||||
BufferedReader reader = null;
|
||||
try {
|
||||
reader = new BufferedReader(new FileReader(queue));
|
||||
String entryStr = null;
|
||||
reader = new BufferedReader(new FileReader(queue, StandardCharsets.UTF_8));
|
||||
String entryStr;
|
||||
while ((entryStr = reader.readLine()) != null) {
|
||||
entryStr = entryStr.trim();
|
||||
if (entryStr.length() > 0) {
|
||||
|
@@ -24,7 +24,7 @@ public class ResolvedTask {
|
||||
private CurationTask cTask;
|
||||
private ScriptedTask sTask;
|
||||
// local name of task
|
||||
private String taskName;
|
||||
private final String taskName;
|
||||
// annotation data
|
||||
private boolean distributive = false;
|
||||
private boolean mutative = false;
|
||||
@@ -76,7 +76,7 @@ public class ResolvedTask {
|
||||
* @throws IOException if error
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
**/
|
||||
private String query;
|
||||
private List<String> filterQueries;
|
||||
private final List<String> filterQueries;
|
||||
private List<String> dspaceObjectFilters = new ArrayList<>();
|
||||
private List<String> fieldPresentQueries;
|
||||
private final List<String> fieldPresentQueries;
|
||||
private boolean spellCheck;
|
||||
|
||||
private int start = 0;
|
||||
@@ -55,36 +55,35 @@ public class DiscoverQuery {
|
||||
/**
|
||||
* Attributes required for the faceting of values
|
||||
**/
|
||||
private List<DiscoverFacetField> facetFields;
|
||||
private List<String> facetQueries;
|
||||
private int facetLimit = -1;
|
||||
private final List<DiscoverFacetField> facetFields;
|
||||
private final List<String> facetQueries;
|
||||
private int facetMinCount = -1;
|
||||
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
|
||||
**/
|
||||
private List<String> searchFields;
|
||||
private final List<String> searchFields;
|
||||
|
||||
/**
|
||||
* Misc attributes can be implementation dependent
|
||||
**/
|
||||
private Map<String, List<String>> properties;
|
||||
private final Map<String, List<String>> properties;
|
||||
|
||||
private String discoveryConfigurationName;
|
||||
|
||||
public DiscoverQuery() {
|
||||
//Initialize all our lists
|
||||
this.filterQueries = new ArrayList<String>();
|
||||
this.fieldPresentQueries = new ArrayList<String>();
|
||||
this.filterQueries = new ArrayList<>();
|
||||
this.fieldPresentQueries = new ArrayList<>();
|
||||
|
||||
this.facetFields = new ArrayList<DiscoverFacetField>();
|
||||
this.facetQueries = new ArrayList<String>();
|
||||
this.searchFields = new ArrayList<String>();
|
||||
this.hitHighlighting = new HashMap<String, DiscoverHitHighlightingField>();
|
||||
this.facetFields = new ArrayList<>();
|
||||
this.facetQueries = new ArrayList<>();
|
||||
this.searchFields = new ArrayList<>();
|
||||
this.hitHighlighting = new HashMap<>();
|
||||
//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) {
|
||||
List<String> toAddList = properties.get(property);
|
||||
if (toAddList == null) {
|
||||
toAddList = new ArrayList<String>();
|
||||
toAddList = new ArrayList<>();
|
||||
}
|
||||
|
||||
toAddList.add(value);
|
||||
@@ -322,7 +321,7 @@ public class DiscoverQuery {
|
||||
}
|
||||
|
||||
public List<DiscoverHitHighlightingField> getHitHighlightingFields() {
|
||||
return new ArrayList<DiscoverHitHighlightingField>(hitHighlighting.values());
|
||||
return new ArrayList<>(hitHighlighting.values());
|
||||
}
|
||||
|
||||
public void addHitHighlightingField(DiscoverHitHighlightingField hitHighlighting) {
|
||||
@@ -368,7 +367,7 @@ public class DiscoverQuery {
|
||||
|
||||
private List<String> buildFacetQueriesWithGap(int newestYear, int oldestYear, String dateFacet, int gap,
|
||||
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) {
|
||||
//Add a filter to remove the last year only if we aren't the last year
|
||||
int bottomYear = year - gap;
|
||||
@@ -392,7 +391,7 @@ public class DiscoverQuery {
|
||||
}
|
||||
|
||||
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 final Iterator<FullTextBitstream> fulltextIterator;
|
||||
|
@@ -55,7 +55,7 @@ public class SolrServiceFileInfoPlugin implements SolrServiceIndexPlugin {
|
||||
document.addField(SOLR_FIELD_NAME_FOR_FILENAMES, bitstream.getName());
|
||||
|
||||
String description = bitstream.getDescription();
|
||||
if ((description != null) && (!description.isEmpty())) {
|
||||
if ((description != null) && !description.isEmpty()) {
|
||||
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.
|
||||
* Since IndexableObjects can be made multiple times for the same underlying object, we needed a more finetuned
|
||||
* equals and hashcode methods. We're simply checking that the underlying objects are equal and generating the hashcode
|
||||
* for the underlying object. This way, we'll always get a proper result when calling equals or hashcode on an
|
||||
* IndexableObject because it'll depend on the underlying object
|
||||
* Since IndexableObjects can be made multiple times for the same underlying
|
||||
* object, we needed more finely-tuned {@link equals} and {@link hashCode} methods.
|
||||
* We're simply checking that the underlying objects are equal and returning the
|
||||
* 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 <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)) {
|
||||
return false;
|
||||
}
|
||||
IndexableDSpaceObject other = (IndexableDSpaceObject) obj;
|
||||
AbstractIndexableObject other = (AbstractIndexableObject) obj;
|
||||
return other.getIndexedObject().equals(getIndexedObject());
|
||||
}
|
||||
|
||||
|
@@ -53,6 +53,7 @@ public class Subscription implements ReloadableEntity<Integer> {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getID() {
|
||||
return id;
|
||||
}
|
||||
|
@@ -8,6 +8,7 @@
|
||||
package org.dspace.eperson.dao.impl;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import javax.persistence.Query;
|
||||
@@ -97,7 +98,7 @@ public class SubscriptionDAOImpl extends AbstractHibernateDAO<Subscription> impl
|
||||
Root<Subscription> subscriptionRoot = criteriaQuery.from(Subscription.class);
|
||||
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)));
|
||||
criteriaQuery.orderBy(orderList);
|
||||
|
||||
|
@@ -8,6 +8,7 @@
|
||||
package org.dspace.external;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Scanner;
|
||||
|
||||
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.methods.HttpGet;
|
||||
import org.apache.http.impl.client.HttpClientBuilder;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
/**
|
||||
@@ -28,9 +30,9 @@ public class OrcidRestConnector {
|
||||
/**
|
||||
* 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) {
|
||||
this.url = url;
|
||||
@@ -73,7 +75,7 @@ public class OrcidRestConnector {
|
||||
}
|
||||
|
||||
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() : "";
|
||||
}
|
||||
|
||||
|
@@ -7,7 +7,7 @@
|
||||
*/
|
||||
package org.dspace.external.model;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
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
|
||||
*/
|
||||
private List<MetadataValueDTO> metadata = new LinkedList<>();
|
||||
private List<MetadataValueDTO> metadata = new ArrayList<>();
|
||||
/**
|
||||
* 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
|
||||
* @param metadataValueDTO The metadatavalue to be added
|
||||
* @param metadataValueDTO The metadata value to be added.
|
||||
*/
|
||||
public void addMetadata(MetadataValueDTO metadataValueDTO) {
|
||||
if (metadata == null) {
|
||||
metadata = new LinkedList<>();
|
||||
metadata = new ArrayList<>();
|
||||
}
|
||||
metadata.add(metadataValueDTO);
|
||||
}
|
||||
|
@@ -13,7 +13,6 @@ import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.Unmarshaller;
|
||||
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
/**
|
||||
@@ -25,11 +24,6 @@ import org.xml.sax.SAXException;
|
||||
*/
|
||||
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);
|
||||
|
||||
protected Object unmarshall(InputStream input, Class<?> type) throws SAXException, URISyntaxException {
|
||||
|
@@ -56,6 +56,7 @@ public class HarvestedItem implements ReloadableEntity<Integer> {
|
||||
protected HarvestedItem() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getID() {
|
||||
return id;
|
||||
}
|
||||
@@ -89,7 +90,6 @@ public class HarvestedItem implements ReloadableEntity<Integer> {
|
||||
*/
|
||||
public void setOaiID(String itemOaiID) {
|
||||
this.oaiId = itemOaiID;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -62,6 +62,7 @@ public class DOI
|
||||
protected DOI() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getID() {
|
||||
return id;
|
||||
}
|
||||
|
@@ -8,7 +8,7 @@
|
||||
package org.dspace.identifier.dao.impl;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.LinkedList;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.persistence.criteria.CriteriaBuilder;
|
||||
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.
|
||||
* 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.
|
||||
*
|
||||
* @author kevinvandevelde at atmire.com
|
||||
@@ -52,7 +52,7 @@ public class DOIDAOImpl extends AbstractHibernateDAO<DOI> implements DOIDAO {
|
||||
Root<DOI> doiRoot = criteriaQuery.from(DOI.class);
|
||||
criteriaQuery.select(doiRoot);
|
||||
|
||||
List<Predicate> listToIncludeInOrPredicate = new LinkedList<>();
|
||||
List<Predicate> listToIncludeInOrPredicate = new ArrayList<>(statusToExclude.size() + 1);
|
||||
|
||||
for (Integer status : statusToExclude) {
|
||||
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);
|
||||
Root<DOI> doiRoot = criteriaQuery.from(DOI.class);
|
||||
criteriaQuery.select(doiRoot);
|
||||
List<Predicate> orPredicates = new LinkedList<>();
|
||||
List<Predicate> orPredicates = new ArrayList<>(statuses.size());
|
||||
for (Integer status : statuses) {
|
||||
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);
|
||||
criteriaQuery.select(doiRoot);
|
||||
|
||||
List<Predicate> listToIncludeInOrPredicate = new LinkedList<>();
|
||||
List<Predicate> listToIncludeInOrPredicate = new ArrayList<>(excludedStatuses.size());
|
||||
|
||||
for (Integer status : excludedStatuses) {
|
||||
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.or(listToIncludeInOrPredicate.toArray(new Predicate[] {})));
|
||||
@@ -107,8 +107,6 @@ public class DOIDAOImpl extends AbstractHibernateDAO<DOI> implements DOIDAO {
|
||||
}
|
||||
criteriaQuery.where(listToIncludeInAndPredicate.toArray(new Predicate[] {}));
|
||||
return list(context, criteriaQuery, false, DOI.class, -1, -1);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -7,9 +7,9 @@
|
||||
*/
|
||||
package org.dspace.importer.external.datamodel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.dspace.importer.external.metadatamapping.MetadatumDTO;
|
||||
@@ -38,7 +38,7 @@ public class ImportRecord {
|
||||
*/
|
||||
public ImportRecord(List<MetadatumDTO> valueList) {
|
||||
//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
|
||||
*/
|
||||
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) {
|
||||
if (value.getSchema().equals(schema) && value.getElement().equals(element)) {
|
||||
if (qualifier == null && value.getQualifier() == null) {
|
||||
|
@@ -7,18 +7,19 @@
|
||||
*/
|
||||
package org.dspace.importer.external.metadatamapping;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.importer.external.metadatamapping.contributor.MetadataContributor;
|
||||
import org.dspace.importer.external.metadatamapping.transform.MetadataProcessorService;
|
||||
|
||||
/**
|
||||
* Abstract class that implements {@link MetadataFieldMapping}
|
||||
* This class adds a default implementation for the MetadataFieldMapping methods
|
||||
* Abstract class that implements {@link MetadataFieldMapping}.
|
||||
* This class adds a default implementation for the MetadataFieldMapping methods.
|
||||
*
|
||||
* @author Roeland Dillen (roeland at atmire dot com)
|
||||
*/
|
||||
@@ -30,7 +31,7 @@ public abstract class AbstractMetadataFieldMapping<RecordType>
|
||||
/**
|
||||
* 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.
|
||||
* 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
|
||||
* @return A metadatumDTO created from the field and value
|
||||
*/
|
||||
@Override
|
||||
public MetadatumDTO toDCValue(MetadataFieldConfig field, String value) {
|
||||
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
|
||||
* @return Lit of metadatumDTO
|
||||
*/
|
||||
@Override
|
||||
public Collection<MetadatumDTO> resultToDCValueMapping(RecordType record) {
|
||||
List<MetadatumDTO> values = new LinkedList<MetadatumDTO>();
|
||||
List<MetadatumDTO> values = new ArrayList<>();
|
||||
|
||||
for (MetadataContributor<RecordType> query : getMetadataFieldMap().values()) {
|
||||
try {
|
||||
|
@@ -31,7 +31,7 @@ public class MetadataFieldConfig {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
if (o == null || !(o instanceof MetadataFieldConfig)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -43,11 +43,7 @@ public class MetadataFieldConfig {
|
||||
if (qualifier != null ? !qualifier.equals(that.qualifier) : that.qualifier != null) {
|
||||
return false;
|
||||
}
|
||||
if (!schema.equals(that.schema)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return schema.equals(that.schema);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -14,7 +14,8 @@ import org.apache.commons.lang3.StringUtils;
|
||||
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 {
|
||||
private String name;
|
||||
@@ -23,7 +24,7 @@ public class DSpaceCommandLineParameter {
|
||||
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 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
|
||||
* values by separating them with a space
|
||||
* values by separating them with a space.
|
||||
* @return The String representation of a DSpaceCommandlineParameter object
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
String stringToReturn = "";
|
||||
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
|
||||
* @return A boolean indicating equality
|
||||
*/
|
||||
@@ -101,7 +103,7 @@ public class DSpaceCommandLineParameter {
|
||||
if (other == null) {
|
||||
return false;
|
||||
}
|
||||
if (other.getClass() != DSpaceCommandLineParameter.class) {
|
||||
if (!(other instanceof DSpaceCommandLineParameter)) {
|
||||
return false;
|
||||
}
|
||||
return StringUtils.equals(this.getName(), ((DSpaceCommandLineParameter) other).getName()) && StringUtils
|
||||
|
@@ -8,7 +8,7 @@
|
||||
package org.dspace.scripts;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.LinkedList;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@@ -37,7 +37,7 @@ public abstract class DSpaceRunnable<T extends ScriptConfiguration> implements R
|
||||
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;
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
public List<String> getFileNamesFromInputStreamOptions() {
|
||||
List<String> fileNames = new LinkedList<>();
|
||||
List<String> fileNames = new ArrayList<>();
|
||||
|
||||
for (Option option : getScriptConfiguration().getOptions().getOptions()) {
|
||||
if (option.getType() == InputStream.class &&
|
||||
@@ -151,8 +151,8 @@ public abstract class DSpaceRunnable<T extends ScriptConfiguration> implements R
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic setter for the epersonIdentifier
|
||||
* This EPerson identifier variable is the uuid of the eperson that's running the script
|
||||
* Generic setter for the epersonIdentifier.
|
||||
* 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
|
||||
*/
|
||||
public void setEpersonIdentifier(UUID epersonIdentifier) {
|
||||
|
@@ -7,8 +7,8 @@
|
||||
*/
|
||||
package org.dspace.scripts;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import javax.persistence.Column;
|
||||
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
|
||||
* @return The ID that the process holds within the database
|
||||
*/
|
||||
@Override
|
||||
public Integer getID() {
|
||||
return processId;
|
||||
}
|
||||
@@ -163,6 +164,7 @@ public class Process implements ReloadableEntity<Integer> {
|
||||
/**
|
||||
* 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"
|
||||
* @return the raw parameter string.
|
||||
*/
|
||||
protected String getParameters() {
|
||||
return parameters;
|
||||
@@ -179,7 +181,7 @@ public class Process implements ReloadableEntity<Integer> {
|
||||
*/
|
||||
public List<Bitstream> getBitstreams() {
|
||||
if (bitstreams == null) {
|
||||
bitstreams = new LinkedList<>();
|
||||
bitstreams = Collections.EMPTY_LIST;
|
||||
}
|
||||
return bitstreams;
|
||||
}
|
||||
|
@@ -11,7 +11,6 @@ import java.sql.SQLException;
|
||||
import java.text.ParseException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@@ -129,7 +128,7 @@ public class Harvest {
|
||||
// several smaller operations (e.g. for OAI resumption tokens.)
|
||||
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.
|
||||
// Note : Until 'index > offset' the records are not added to the output set.
|
||||
@@ -155,7 +154,7 @@ public class Harvest {
|
||||
|
||||
if (collections) {
|
||||
// Add collections data
|
||||
fillCollections(context, itemInfo);
|
||||
fillCollections(itemInfo);
|
||||
}
|
||||
|
||||
if (items) {
|
||||
@@ -163,7 +162,7 @@ public class Harvest {
|
||||
itemInfo.item = itemService.find(context, itemInfo.itemID);
|
||||
}
|
||||
|
||||
if ((nonAnon) || (itemInfo.item == null) || (withdrawn && itemInfo.withdrawn)) {
|
||||
if (nonAnon || (itemInfo.item == null) || (withdrawn && itemInfo.withdrawn)) {
|
||||
index++;
|
||||
if (index > offset) {
|
||||
infoObjects.add(itemInfo);
|
||||
@@ -221,7 +220,7 @@ public class Harvest {
|
||||
|
||||
// Get the sets
|
||||
if (collections) {
|
||||
fillCollections(context, itemInfo);
|
||||
fillCollections(itemInfo);
|
||||
}
|
||||
|
||||
return itemInfo;
|
||||
@@ -234,8 +233,7 @@ public class Harvest {
|
||||
* @param itemInfo HarvestedItemInfo object to fill out
|
||||
* @throws SQLException if database error
|
||||
*/
|
||||
private static void fillCollections(Context context,
|
||||
HarvestedItemInfo itemInfo) throws SQLException {
|
||||
private static void fillCollections(HarvestedItemInfo itemInfo) throws SQLException {
|
||||
// Get the collection Handles from DB
|
||||
List<Collection> collections = itemInfo.item.getCollections();
|
||||
itemInfo.collectionHandles = new ArrayList<>();
|
||||
|
@@ -18,6 +18,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import au.com.bytecode.opencsv.CSVWriter;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
@@ -65,20 +66,20 @@ public class Dataset {
|
||||
}
|
||||
|
||||
private void initRowLabels(int rows) {
|
||||
rowLabels = new ArrayList<String>(rows);
|
||||
rowLabelsAttrs = new ArrayList<Map<String, String>>();
|
||||
rowLabels = new ArrayList<>(rows);
|
||||
rowLabelsAttrs = new ArrayList<>();
|
||||
for (int i = 0; i < rows; i++) {
|
||||
rowLabels.add("Row " + (i + 1));
|
||||
rowLabelsAttrs.add(new HashMap<String, String>());
|
||||
rowLabelsAttrs.add(new HashMap<>());
|
||||
}
|
||||
}
|
||||
|
||||
private void initColumnLabels(int nbCols) {
|
||||
colLabels = new ArrayList<String>(nbCols);
|
||||
colLabelsAttrs = new ArrayList<Map<String, String>>();
|
||||
colLabels = new ArrayList<>(nbCols);
|
||||
colLabelsAttrs = new ArrayList<>();
|
||||
for (int i = 0; i < nbCols; i++) {
|
||||
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 {
|
||||
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
|
||||
List<String> colLabels = getColLabels();
|
||||
colLabels.add(0, "");
|
||||
|
@@ -7,9 +7,10 @@
|
||||
*/
|
||||
package org.dspace.statistics;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.eperson.EPerson;
|
||||
import org.dspace.services.model.Event;
|
||||
@@ -28,7 +29,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
*/
|
||||
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;
|
||||
|
||||
@@ -56,7 +57,7 @@ public class SolrLoggerUsageEventListener extends AbstractUsageEventListener {
|
||||
}
|
||||
} else if (UsageEvent.Action.SEARCH == ue.getAction()) {
|
||||
UsageSearchEvent usageSearchEvent = (UsageSearchEvent) ue;
|
||||
List<String> queries = new LinkedList<>();
|
||||
List<String> queries = new ArrayList<>();
|
||||
queries.add(usageSearchEvent.getQuery());
|
||||
solrLoggerService.postSearch(usageSearchEvent.getObject(), usageSearchEvent.getRequest(),
|
||||
currentUser, queries, usageSearchEvent.getPage().getSize(),
|
||||
|
@@ -285,13 +285,8 @@ public class StatisticsDataVisits extends StatisticsData {
|
||||
DatasetQuery firsDataset = datasetQueries.get(0);
|
||||
//Do the first query
|
||||
|
||||
ObjectCount[] topCounts1 = null;
|
||||
// if (firsDataset.getQueries().size() == 1) {
|
||||
topCounts1 =
|
||||
ObjectCount[] topCounts1 =
|
||||
queryFacetField(firsDataset, firsDataset.getQueries().get(0).getQuery(), filterQuery, facetMinCount);
|
||||
// } else {
|
||||
// TODO: do this
|
||||
// }
|
||||
// Check if we have more queries that need to be done
|
||||
if (datasetQueries.size() == 2) {
|
||||
DatasetQuery secondDataSet = datasetQueries.get(1);
|
||||
@@ -313,7 +308,6 @@ public class StatisticsDataVisits extends StatisticsData {
|
||||
}
|
||||
for (int i = 0; i < topCounts1.length; i++) {
|
||||
ObjectCount count1 = topCounts1[i];
|
||||
ObjectCount[] currentResult = new ObjectCount[topCounts2.length];
|
||||
|
||||
// Make sure we have a dataSet
|
||||
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
|
||||
// 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.
|
||||
String identifier = null;
|
||||
String identifier;
|
||||
if (owningItem != null && owningItem.getHandle() != null) {
|
||||
identifier = "handle/" + owningItem.getHandle();
|
||||
} else if (owningItem != null) {
|
||||
|
@@ -39,11 +39,11 @@ public class ValueConcatenationModifier extends AbstractModifier {
|
||||
public Record modify(MutableRecord rec) {
|
||||
List<Value> values = rec.getValues(field);
|
||||
if (values != null) {
|
||||
List<String> converted_values = new ArrayList<String>();
|
||||
List<String> converted_values = new ArrayList<>();
|
||||
for (Value val : values) {
|
||||
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
|
||||
+ (whitespaceAfter ? " " : ""));
|
||||
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) {
|
||||
this.whitespaceAfter = whiteSpaceAfter;
|
||||
public void setWhitespaceAfter(boolean 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 UNKNOWN_PROVIDER_STRING = "UNKNOWN-PROVIDER";
|
||||
private final List<Record> publications;
|
||||
|
||||
private List<Record> publications;
|
||||
|
||||
private String uuid;
|
||||
private final String uuid;
|
||||
|
||||
public ItemSubmissionLookupDTO(List<Record> publications) {
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
@@ -46,7 +44,7 @@ public class ItemSubmissionLookupDTO implements Serializable {
|
||||
}
|
||||
|
||||
public Set<String> getProviders() {
|
||||
Set<String> orderedProviders = new LinkedHashSet<String>();
|
||||
Set<String> orderedProviders = new LinkedHashSet<>();
|
||||
for (Record p : publications) {
|
||||
orderedProviders.add(SubmissionLookupService.getProviderName(p));
|
||||
}
|
||||
|
@@ -77,6 +77,7 @@ public class Version implements ReloadableEntity<Integer> {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getID() {
|
||||
return id;
|
||||
}
|
||||
|
@@ -20,7 +20,6 @@ import javax.persistence.OrderBy;
|
||||
import javax.persistence.SequenceGenerator;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.core.ReloadableEntity;
|
||||
import org.hibernate.proxy.HibernateProxyHelper;
|
||||
@@ -35,8 +34,6 @@ import org.hibernate.proxy.HibernateProxyHelper;
|
||||
@Table(name = "versionhistory")
|
||||
public class VersionHistory implements ReloadableEntity<Integer> {
|
||||
|
||||
private static final Logger log = org.apache.logging.log4j.LogManager.getLogger(VersionHistory.class);
|
||||
|
||||
@Id
|
||||
@Column(name = "versionhistory_id")
|
||||
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "versionhistory_seq")
|
||||
@@ -56,6 +53,7 @@ public class VersionHistory implements ReloadableEntity<Integer> {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getID() {
|
||||
return id;
|
||||
}
|
||||
@@ -98,11 +96,7 @@ public class VersionHistory implements ReloadableEntity<Integer> {
|
||||
}
|
||||
|
||||
final VersionHistory that = (VersionHistory) o;
|
||||
if (!this.getID().equals(that.getID())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return this.getID().equals(that.getID());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -27,7 +27,8 @@ public class WorkflowException extends Exception {
|
||||
this.reason = reason;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return reason;
|
||||
}
|
||||
}
|
||||
|
@@ -116,6 +116,7 @@ public class BasicWorkflowItem implements WorkflowItem {
|
||||
*
|
||||
* @return state
|
||||
*/
|
||||
@Override
|
||||
public int getState() {
|
||||
return state;
|
||||
}
|
||||
|
@@ -73,6 +73,7 @@ public class TaskListItem implements ReloadableEntity<Integer> {
|
||||
this.workflowItem = workflowItem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getID() {
|
||||
return taskListItemId;
|
||||
}
|
||||
|
@@ -30,8 +30,8 @@ import org.dspace.eperson.service.GroupService;
|
||||
public class RoleMembers {
|
||||
|
||||
protected GroupService groupService = EPersonServiceFactory.getInstance().getGroupService();
|
||||
private ArrayList<Group> groups;
|
||||
private ArrayList<EPerson> epersons;
|
||||
private final ArrayList<Group> groups;
|
||||
private final ArrayList<EPerson> epersons;
|
||||
|
||||
public RoleMembers() {
|
||||
this.groups = new ArrayList<>();
|
||||
@@ -55,11 +55,7 @@ public class RoleMembers {
|
||||
}
|
||||
|
||||
public void removeEperson(EPerson epersonToRemove) {
|
||||
for (EPerson eperson : epersons) {
|
||||
if (eperson.equals(epersonToRemove)) {
|
||||
epersons.remove(eperson);
|
||||
}
|
||||
}
|
||||
epersons.removeIf(eperson -> eperson.equals(epersonToRemove));
|
||||
}
|
||||
|
||||
public ArrayList<EPerson> getAllUniqueMembers(Context context) throws SQLException {
|
||||
|
@@ -8,7 +8,7 @@
|
||||
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 Kevin Van de Velde (kevin at atmire dot com)
|
||||
@@ -17,13 +17,14 @@ package org.dspace.xmlworkflow;
|
||||
*/
|
||||
public class WorkflowConfigurationException extends Exception {
|
||||
|
||||
private String error;
|
||||
private final String error;
|
||||
|
||||
public WorkflowConfigurationException(String error) {
|
||||
this.error = error;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return this.error;
|
||||
}
|
||||
|
||||
|
@@ -71,6 +71,7 @@ public class ClaimedTask implements ReloadableEntity<Integer> {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getID() {
|
||||
return id;
|
||||
}
|
||||
@@ -91,24 +92,24 @@ public class ClaimedTask implements ReloadableEntity<Integer> {
|
||||
return workflowItem;
|
||||
}
|
||||
|
||||
public void setActionID(String actionID) {
|
||||
this.actionId = actionID;
|
||||
public void setActionID(String actionId) {
|
||||
this.actionId = actionId;
|
||||
}
|
||||
|
||||
public String getActionID() {
|
||||
return actionId;
|
||||
}
|
||||
|
||||
public void setStepID(String stepID) {
|
||||
this.stepId = stepID;
|
||||
public void setStepID(String stepId) {
|
||||
this.stepId = stepId;
|
||||
}
|
||||
|
||||
public String getStepID() {
|
||||
return stepId;
|
||||
}
|
||||
|
||||
public void setWorkflowID(String workflowID) {
|
||||
this.workflowId = workflowID;
|
||||
public void setWorkflowID(String workflowId) {
|
||||
this.workflowId = workflowId;
|
||||
}
|
||||
|
||||
public String getWorkflowID() {
|
||||
|
@@ -91,6 +91,7 @@ public class CollectionRole implements ReloadableEntity<Integer> {
|
||||
return group;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getID() {
|
||||
return id;
|
||||
}
|
||||
|
@@ -78,12 +78,13 @@ public class PoolTask implements ReloadableEntity<Integer> {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getID() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setEperson(EPerson eperson) {
|
||||
this.ePerson = eperson;
|
||||
public void setEperson(EPerson ePerson) {
|
||||
this.ePerson = ePerson;
|
||||
}
|
||||
|
||||
public EPerson getEperson() {
|
||||
@@ -114,16 +115,16 @@ public class PoolTask implements ReloadableEntity<Integer> {
|
||||
return this.workflowItem;
|
||||
}
|
||||
|
||||
public void setStepID(String stepID) {
|
||||
this.stepId = stepID;
|
||||
public void setStepID(String stepId) {
|
||||
this.stepId = stepId;
|
||||
}
|
||||
|
||||
public String getStepID() {
|
||||
return stepId;
|
||||
}
|
||||
|
||||
public void setActionID(String actionID) {
|
||||
this.actionId = actionID;
|
||||
public void setActionID(String actionId) {
|
||||
this.actionId = actionId;
|
||||
}
|
||||
|
||||
public String getActionID() {
|
||||
|
@@ -69,7 +69,7 @@ public class WorkflowItemRole implements ReloadableEntity<Integer> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Integer getID() {
|
||||
return id;
|
||||
}
|
||||
@@ -90,8 +90,8 @@ public class WorkflowItemRole implements ReloadableEntity<Integer> {
|
||||
return workflowItem;
|
||||
}
|
||||
|
||||
public void setEPerson(EPerson eperson) {
|
||||
this.ePerson = eperson;
|
||||
public void setEPerson(EPerson ePerson) {
|
||||
this.ePerson = ePerson;
|
||||
}
|
||||
|
||||
public EPerson getEPerson() throws SQLException {
|
||||
|
@@ -12,6 +12,7 @@ import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.StandardOpenOption;
|
||||
|
||||
@@ -118,7 +119,8 @@ public class AbstractIntegrationTest extends AbstractUnitTest {
|
||||
*/
|
||||
protected void appendToLocalConfiguration(String textToAppend) {
|
||||
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(textToAppend);
|
||||
output.flush();
|
||||
|
@@ -47,10 +47,12 @@ import org.junit.Test;
|
||||
|
||||
public class MetadataImportIT extends AbstractIntegrationTestWithDatabase {
|
||||
|
||||
private ItemService itemService
|
||||
private final ItemService itemService
|
||||
= ContentServiceFactory.getInstance().getItemService();
|
||||
private EPersonService ePersonService = EPersonServiceFactory.getInstance().getEPersonService();
|
||||
private RelationshipService relationshipService = ContentServiceFactory.getInstance().getRelationshipService();
|
||||
private final EPersonService ePersonService
|
||||
= EPersonServiceFactory.getInstance().getEPersonService();
|
||||
private final RelationshipService relationshipService
|
||||
= ContentServiceFactory.getInstance().getRelationshipService();
|
||||
|
||||
Collection collection;
|
||||
|
||||
@@ -119,7 +121,7 @@ public class MetadataImportIT extends AbstractIntegrationTestWithDatabase {
|
||||
Item importedItem = findItemByName("Test Import 1");
|
||||
|
||||
|
||||
assertEquals(relationshipService.findByItem(context, importedItem).size(), 1);
|
||||
assertEquals(1, relationshipService.findByItem(context, importedItem).size());
|
||||
context.turnOffAuthorisationSystem();
|
||||
itemService.delete(context, itemService.find(context, importedItem.getID()));
|
||||
context.restoreAuthSystemState();
|
||||
@@ -148,7 +150,7 @@ public class MetadataImportIT extends AbstractIntegrationTestWithDatabase {
|
||||
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
|
||||
private Collection col1;
|
||||
|
||||
private RelationshipService relationshipService = ContentServiceFactory.getInstance().getRelationshipService();
|
||||
private ItemService itemService = ContentServiceFactory.getInstance().getItemService();
|
||||
|
||||
private final RelationshipService relationshipService
|
||||
= ContentServiceFactory.getInstance().getRelationshipService();
|
||||
private final ItemService itemService
|
||||
= ContentServiceFactory.getInstance().getItemService();
|
||||
|
||||
Community parentCommunity;
|
||||
|
||||
/**
|
||||
* Setup testing enviorment
|
||||
* Setup testing environment.
|
||||
* @throws java.sql.SQLException passed through.
|
||||
*/
|
||||
@Before
|
||||
public void setup() throws SQLException {
|
||||
@@ -80,7 +82,7 @@ public class CSVMetadataImportReferenceIT extends AbstractIntegrationTestWithDat
|
||||
EntityType publication = EntityTypeBuilder.createEntityTypeBuilder(context, "Publication").build();
|
||||
EntityType person = EntityTypeBuilder.createEntityTypeBuilder(context, "Person").build();
|
||||
EntityType project = EntityTypeBuilder.createEntityTypeBuilder(context, "Project").build();
|
||||
EntityType orgUnit = EntityTypeBuilder.createEntityTypeBuilder(context, "OrgUnit").build();
|
||||
EntityTypeBuilder.createEntityTypeBuilder(context, "OrgUnit").build();
|
||||
|
||||
RelationshipTypeBuilder
|
||||
.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.
|
||||
* @throws java.lang.Exception passed through.
|
||||
*/
|
||||
@Test(expected = MetadataImportException.class)
|
||||
public void testNonUniqueMDRefInDb() throws Exception {
|
||||
context.turnOffAuthorisationSystem();
|
||||
Item person = ItemBuilder.createItem(context, col1)
|
||||
ItemBuilder.createItem(context, col1)
|
||||
.withTitle("Person")
|
||||
.withIssueDate("2017-10-17")
|
||||
.withAuthor("Smith, Donald")
|
||||
@@ -363,7 +366,7 @@ public class CSVMetadataImportReferenceIT extends AbstractIntegrationTestWithDat
|
||||
.withRelationshipType("Person")
|
||||
.withIdentifierOther("1")
|
||||
.build();
|
||||
Item person2 = ItemBuilder.createItem(context, col1)
|
||||
ItemBuilder.createItem(context, col1)
|
||||
.withTitle("Person2")
|
||||
.withIssueDate("2017-10-17")
|
||||
.withAuthor("Smith, John")
|
||||
@@ -385,7 +388,7 @@ public class CSVMetadataImportReferenceIT extends AbstractIntegrationTestWithDat
|
||||
@Test(expected = MetadataImportException.class)
|
||||
public void testNonUniqueMDRefInBoth() throws Exception {
|
||||
context.turnOffAuthorisationSystem();
|
||||
Item person = ItemBuilder.createItem(context, col1)
|
||||
ItemBuilder.createItem(context, col1)
|
||||
.withTitle("Person")
|
||||
.withIssueDate("2017-10-17")
|
||||
.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)
|
||||
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)
|
||||
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)
|
||||
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)
|
||||
public void testInvalidRelationshipArchivedOrigin() throws Exception {
|
||||
|
@@ -7,8 +7,8 @@
|
||||
*/
|
||||
package org.dspace.builder.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -51,24 +51,24 @@ public class AbstractBuilderCleanupUtil {
|
||||
}
|
||||
|
||||
private void initMap() {
|
||||
map.put(RelationshipBuilder.class.getName(), new LinkedList<>());
|
||||
map.put(RelationshipTypeBuilder.class.getName(), new LinkedList<>());
|
||||
map.put(EntityTypeBuilder.class.getName(), new LinkedList<>());
|
||||
map.put(PoolTaskBuilder.class.getName(), new LinkedList<>());
|
||||
map.put(WorkflowItemBuilder.class.getName(), new LinkedList<>());
|
||||
map.put(WorkspaceItemBuilder.class.getName(), new LinkedList<>());
|
||||
map.put(BitstreamBuilder.class.getName(), new LinkedList<>());
|
||||
map.put(BitstreamFormatBuilder.class.getName(), new LinkedList<>());
|
||||
map.put(ClaimedTaskBuilder.class.getName(), new LinkedList<>());
|
||||
map.put(CollectionBuilder.class.getName(), new LinkedList<>());
|
||||
map.put(CommunityBuilder.class.getName(), new LinkedList<>());
|
||||
map.put(EPersonBuilder.class.getName(), new LinkedList<>());
|
||||
map.put(GroupBuilder.class.getName(), new LinkedList<>());
|
||||
map.put(ItemBuilder.class.getName(), new LinkedList<>());
|
||||
map.put(MetadataFieldBuilder.class.getName(), new LinkedList<>());
|
||||
map.put(MetadataSchemaBuilder.class.getName(), new LinkedList<>());
|
||||
map.put(SiteBuilder.class.getName(), new LinkedList<>());
|
||||
map.put(ProcessBuilder.class.getName(), new LinkedList<>());
|
||||
map.put(RelationshipBuilder.class.getName(), new ArrayList<>());
|
||||
map.put(RelationshipTypeBuilder.class.getName(), new ArrayList<>());
|
||||
map.put(EntityTypeBuilder.class.getName(), new ArrayList<>());
|
||||
map.put(PoolTaskBuilder.class.getName(), new ArrayList<>());
|
||||
map.put(WorkflowItemBuilder.class.getName(), new ArrayList<>());
|
||||
map.put(WorkspaceItemBuilder.class.getName(), new ArrayList<>());
|
||||
map.put(BitstreamBuilder.class.getName(), new ArrayList<>());
|
||||
map.put(BitstreamFormatBuilder.class.getName(), new ArrayList<>());
|
||||
map.put(ClaimedTaskBuilder.class.getName(), new ArrayList<>());
|
||||
map.put(CollectionBuilder.class.getName(), new ArrayList<>());
|
||||
map.put(CommunityBuilder.class.getName(), new ArrayList<>());
|
||||
map.put(EPersonBuilder.class.getName(), new ArrayList<>());
|
||||
map.put(GroupBuilder.class.getName(), new ArrayList<>());
|
||||
map.put(ItemBuilder.class.getName(), new ArrayList<>());
|
||||
map.put(MetadataFieldBuilder.class.getName(), new ArrayList<>());
|
||||
map.put(MetadataSchemaBuilder.class.getName(), new ArrayList<>());
|
||||
map.put(SiteBuilder.class.getName(), new ArrayList<>());
|
||||
map.put(ProcessBuilder.class.getName(), new ArrayList<>());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -78,7 +78,7 @@ public class AbstractBuilderCleanupUtil {
|
||||
* @param abstractBuilder The AbstractBuilder to be added
|
||||
*/
|
||||
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)
|
||||
@SuppressWarnings("ResultOfObjectAllocationIgnored")
|
||||
public void testConstructNull() {
|
||||
MetadataFieldName instance = new MetadataFieldName("one", null);
|
||||
new MetadataFieldName("one", null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -71,7 +72,7 @@ public class MetadataFieldNameTest {
|
||||
*/
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void TestParse1() {
|
||||
String[] results = MetadataFieldName.parse("one");
|
||||
MetadataFieldName.parse("one");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -79,15 +80,16 @@ public class MetadataFieldNameTest {
|
||||
*/
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void TestParse0() {
|
||||
String[] results = MetadataFieldName.parse("");
|
||||
MetadataFieldName.parse("");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of parse method using an illegal null name.
|
||||
*/
|
||||
@Test(expected = NullPointerException.class)
|
||||
@SuppressWarnings("null")
|
||||
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 org.dspace.AbstractDSpaceTest;
|
||||
import org.dspace.content.Collection;
|
||||
import org.dspace.core.factory.CoreServiceFactory;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
@@ -66,6 +65,8 @@ public class DSpaceControlledVocabularyTest extends AbstractDSpaceTest {
|
||||
|
||||
/**
|
||||
* Test of getMatches method, of class DSpaceControlledVocabulary.
|
||||
* @throws java.io.IOException passed through.
|
||||
* @throws java.lang.ClassNotFoundException passed through.
|
||||
*/
|
||||
@Test
|
||||
public void testGetMatches() throws IOException, ClassNotFoundException {
|
||||
@@ -74,9 +75,7 @@ public class DSpaceControlledVocabularyTest extends AbstractDSpaceTest {
|
||||
final String PLUGIN_INTERFACE = "org.dspace.content.authority.ChoiceAuthority";
|
||||
|
||||
// Ensure that 'id' attribute is optional
|
||||
String field = null; // not used
|
||||
String text = "north 40";
|
||||
Collection collection = null;
|
||||
int start = 0;
|
||||
int limit = 10;
|
||||
String locale = null;
|
||||
|
@@ -9,8 +9,8 @@ package org.dspace.license;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -51,7 +51,7 @@ public class MockCCLicenseConnectorServiceImpl extends CCLicenseConnectorService
|
||||
}
|
||||
|
||||
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++) {
|
||||
String licenseFieldId = "license" + count + "-field" + index;
|
||||
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) {
|
||||
List<CCLicenseFieldEnum> ccLicenseFieldEnumList = new LinkedList<>();
|
||||
List<CCLicenseFieldEnum> ccLicenseFieldEnumList = new ArrayList<>(amountOfEnums);
|
||||
for (int i = 0; i < amountOfEnums; i++) {
|
||||
String enumId = "license" + count + "-field" + index + "-enum" + i;
|
||||
String enumLabel = "License " + count + " - Field " + index + " - Enum " + i + " - Label";
|
||||
|
@@ -65,7 +65,7 @@ import org.junit.Test;
|
||||
//@RunWith(MockitoJUnitRunner.class)
|
||||
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();
|
||||
@@ -86,7 +86,7 @@ public class ITIrusExportUsageEventListener extends AbstractIntegrationTestWithD
|
||||
.getServiceByName("testProcessedUrls",
|
||||
ArrayList.class);
|
||||
|
||||
private IrusExportUsageEventListener exportUsageEventListener =
|
||||
private final IrusExportUsageEventListener exportUsageEventListener =
|
||||
DSpaceServicesFactory.getInstance()
|
||||
.getServiceManager()
|
||||
.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()
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
@@ -152,11 +154,12 @@ public class ITIrusExportUsageEventListener extends AbstractIntegrationTestWithD
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean up the created objects
|
||||
* Empty the testProcessedUrls used to store succeeded urls
|
||||
* Empty the database table where the failed urls are logged
|
||||
* Clean up the created objects.
|
||||
* Empty the testProcessedUrls used to store succeeded URLs.
|
||||
* Empty the database table where the failed URLs are logged.
|
||||
*/
|
||||
@After
|
||||
@Override
|
||||
public void destroy() throws Exception {
|
||||
try {
|
||||
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
|
||||
* @throws java.sql.SQLException passed through.
|
||||
*/
|
||||
@Test
|
||||
@SuppressWarnings("ResultOfMethodCallIgnored")
|
||||
public void testReceiveEventOnNonRelevantObject() throws SQLException {
|
||||
|
||||
HttpServletRequest request = mock(HttpServletRequest.class);
|
||||
mock(HttpServletRequest.class);
|
||||
|
||||
UsageEvent usageEvent = mock(UsageEvent.class);
|
||||
when(usageEvent.getObject()).thenReturn(community);
|
||||
@@ -394,7 +399,6 @@ public class ITIrusExportUsageEventListener extends AbstractIntegrationTestWithD
|
||||
|
||||
assertEquals(0, all.size());
|
||||
assertEquals(0, testProcessedUrls.size());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -408,11 +412,6 @@ public class ITIrusExportUsageEventListener extends AbstractIntegrationTestWithD
|
||||
|
||||
Pattern p = Pattern.compile(regex);
|
||||
|
||||
if (p.matcher(string).matches()) {
|
||||
return true;
|
||||
return p.matcher(string).matches();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -37,13 +37,13 @@ import org.junit.Test;
|
||||
*/
|
||||
public class BitstreamEventProcessorTest extends AbstractIntegrationTestWithDatabase {
|
||||
|
||||
private ConfigurationService configurationService = DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||
|
||||
private final ConfigurationService configurationService
|
||||
= DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||
|
||||
private String encodedUrl;
|
||||
|
||||
|
||||
@Before
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
configurationService.setProperty("irus.statistics.tracker.enabled", true);
|
||||
|
@@ -15,7 +15,8 @@ import org.apache.commons.lang.StringUtils;
|
||||
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 {
|
||||
|
||||
@@ -23,13 +24,14 @@ public class MockOpenUrlServiceImpl extends OpenUrlServiceImpl {
|
||||
ArrayList testProcessedUrls;
|
||||
|
||||
/**
|
||||
* Returns a response code to simulate contact to the external url
|
||||
* When the url contains "fail", a fail code 500 will be returned
|
||||
* Otherwise the success code 200 will be returned
|
||||
* Returns a response code to simulate contact to the external URL.
|
||||
* When the URL contains "fail", a fail code 500 will be returned.
|
||||
* Otherwise the success code 200 will be returned.
|
||||
* @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
|
||||
*/
|
||||
@Override
|
||||
protected int getResponseCodeFromUrl(final String urlStr) throws IOException {
|
||||
if (StringUtils.contains(urlStr, "fail")) {
|
||||
return HttpURLConnection.HTTP_INTERNAL_ERROR;
|
||||
|
Reference in New Issue
Block a user