mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +00:00
Merge remote-tracking branch 'dspacegithub/main' into coar-notify-7-part-two-merge-main
This commit is contained in:
@@ -21,6 +21,8 @@ import org.apache.commons.cli.CommandLineParser;
|
||||
import org.apache.commons.cli.DefaultParser;
|
||||
import org.apache.commons.cli.Options;
|
||||
import org.apache.commons.cli.ParseException;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.MetadataField;
|
||||
import org.dspace.content.MetadataSchema;
|
||||
@@ -30,8 +32,6 @@ import org.dspace.content.factory.ContentServiceFactory;
|
||||
import org.dspace.content.service.MetadataFieldService;
|
||||
import org.dspace.content.service.MetadataSchemaService;
|
||||
import org.dspace.core.Context;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
@@ -40,9 +40,9 @@ import org.xml.sax.SAXException;
|
||||
/**
|
||||
* @author Richard Jones
|
||||
*
|
||||
* This class takes an xml document as passed in the arguments and
|
||||
* This class takes an XML document as passed in the arguments and
|
||||
* uses it to create metadata elements in the Metadata Registry if
|
||||
* they do not already exist
|
||||
* they do not already exist.
|
||||
*
|
||||
* The format of the XML file is as follows:
|
||||
*
|
||||
@@ -69,7 +69,7 @@ public class MetadataImporter {
|
||||
/**
|
||||
* logging category
|
||||
*/
|
||||
private static final Logger log = LoggerFactory.getLogger(MetadataImporter.class);
|
||||
private static final Logger log = LogManager.getLogger();
|
||||
|
||||
/**
|
||||
* Default constructor
|
||||
@@ -89,6 +89,7 @@ public class MetadataImporter {
|
||||
* @throws SAXException if parser error
|
||||
* @throws NonUniqueMetadataException if duplicate metadata
|
||||
* @throws RegistryImportException if import fails
|
||||
* @throws XPathExpressionException passed through
|
||||
**/
|
||||
public static void main(String[] args)
|
||||
throws ParseException, SQLException, IOException, TransformerException,
|
||||
@@ -125,6 +126,7 @@ public class MetadataImporter {
|
||||
* @throws SAXException if parser error
|
||||
* @throws NonUniqueMetadataException if duplicate metadata
|
||||
* @throws RegistryImportException if import fails
|
||||
* @throws XPathExpressionException passed through
|
||||
*/
|
||||
public static void loadRegistry(String file, boolean forceUpdate)
|
||||
throws SQLException, IOException, TransformerException, ParserConfigurationException, AuthorizeException,
|
||||
@@ -203,7 +205,7 @@ public class MetadataImporter {
|
||||
|
||||
if (s == null) {
|
||||
// Schema does not exist - create
|
||||
log.info("Registering Schema " + name + " (" + namespace + ")");
|
||||
log.info("Registering Schema {}({})", name, namespace);
|
||||
metadataSchemaService.create(context, name, namespace);
|
||||
} else {
|
||||
// Schema exists - if it's the same namespace, allow the type imports to continue
|
||||
@@ -215,7 +217,7 @@ public class MetadataImporter {
|
||||
// It's a different namespace - have we been told to update?
|
||||
if (updateExisting) {
|
||||
// Update the existing schema namespace and continue to type import
|
||||
log.info("Updating Schema " + name + ": New namespace " + namespace);
|
||||
log.info("Updating Schema {}: New namespace {}", name, namespace);
|
||||
s.setNamespace(namespace);
|
||||
metadataSchemaService.update(context, s);
|
||||
} else {
|
||||
@@ -274,7 +276,7 @@ public class MetadataImporter {
|
||||
if (qualifier == null) {
|
||||
fieldName = schema + "." + element;
|
||||
}
|
||||
log.info("Registering metadata field " + fieldName);
|
||||
log.info("Registering metadata field {}", fieldName);
|
||||
MetadataField field = metadataFieldService.create(context, schemaObj, element, qualifier, scopeNote);
|
||||
metadataFieldService.update(context, field);
|
||||
}
|
||||
|
@@ -33,7 +33,8 @@ public class MediaFilterScriptConfiguration<T extends MediaFilterScript> extends
|
||||
options.addOption("v", "verbose", false, "print all extracted text and other details to STDOUT");
|
||||
options.addOption("q", "quiet", false, "do not print anything except in the event of errors.");
|
||||
options.addOption("f", "force", false, "force all bitstreams to be processed");
|
||||
options.addOption("i", "identifier", true, "ONLY process bitstreams belonging to identifier");
|
||||
options.addOption("i", "identifier", true,
|
||||
"ONLY process bitstreams belonging to the provided handle identifier");
|
||||
options.addOption("m", "maximum", true, "process no more than maximum items");
|
||||
options.addOption("h", "help", false, "help");
|
||||
|
||||
|
@@ -132,12 +132,18 @@ public class MediaFilterServiceImpl implements MediaFilterService, InitializingB
|
||||
@Override
|
||||
public void applyFiltersCommunity(Context context, Community community)
|
||||
throws Exception { //only apply filters if community not in skip-list
|
||||
// ensure that the community is attached to the current hibernate session
|
||||
// as we are committing after each item (handles, sub-communties and
|
||||
// collections are lazy attributes)
|
||||
community = context.reloadEntity(community);
|
||||
if (!inSkipList(community.getHandle())) {
|
||||
List<Community> subcommunities = community.getSubcommunities();
|
||||
for (Community subcommunity : subcommunities) {
|
||||
applyFiltersCommunity(context, subcommunity);
|
||||
}
|
||||
|
||||
// ensure that the community is attached to the current hibernate session
|
||||
// as we are committing after each item
|
||||
community = context.reloadEntity(community);
|
||||
List<Collection> collections = community.getCollections();
|
||||
for (Collection collection : collections) {
|
||||
applyFiltersCollection(context, collection);
|
||||
@@ -148,6 +154,9 @@ public class MediaFilterServiceImpl implements MediaFilterService, InitializingB
|
||||
@Override
|
||||
public void applyFiltersCollection(Context context, Collection collection)
|
||||
throws Exception {
|
||||
// ensure that the collection is attached to the current hibernate session
|
||||
// as we are committing after each item (handles are lazy attributes)
|
||||
collection = context.reloadEntity(collection);
|
||||
//only apply filters if collection not in skip-list
|
||||
if (!inSkipList(collection.getHandle())) {
|
||||
Iterator<Item> itemIterator = itemService.findAllByCollection(context, collection);
|
||||
@@ -171,6 +180,8 @@ public class MediaFilterServiceImpl implements MediaFilterService, InitializingB
|
||||
}
|
||||
// clear item objects from context cache and internal cache
|
||||
c.uncacheEntity(currentItem);
|
||||
// commit after each item to release DB resources
|
||||
c.commit();
|
||||
currentItem = null;
|
||||
}
|
||||
}
|
||||
|
@@ -12,6 +12,8 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.cli.ParseException;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.discovery.DiscoverQuery;
|
||||
@@ -23,8 +25,6 @@ import org.dspace.discovery.utils.parameter.QueryBuilderSearchFilter;
|
||||
import org.dspace.scripts.DSpaceRunnable;
|
||||
import org.dspace.sort.SortOption;
|
||||
import org.dspace.utils.DSpace;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Runner responsible to import metadata about authors from OpenAIRE to Solr.
|
||||
@@ -33,13 +33,13 @@ import org.slf4j.LoggerFactory;
|
||||
* with this UUID will be used.
|
||||
* Invocation without any parameter results in massive import, processing all
|
||||
* authors registered in DSpace.
|
||||
*
|
||||
*
|
||||
* @author Alessandro Martelli (alessandro.martelli at 4science.it)
|
||||
*/
|
||||
public class PublicationLoaderRunnable
|
||||
extends DSpaceRunnable<PublicationLoaderScriptConfiguration<PublicationLoaderRunnable>> {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(PublicationLoaderRunnable.class);
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
private PublicationLoader oairePublicationLoader = null;
|
||||
|
||||
@@ -63,9 +63,9 @@ public class PublicationLoaderRunnable
|
||||
|
||||
profile = commandLine.getOptionValue("s");
|
||||
if (profile == null) {
|
||||
LOGGER.info("No argument for -s, process all profile");
|
||||
LOGGER.info("No argument for -s, process all profiles");
|
||||
} else {
|
||||
LOGGER.info("Process eperson item with UUID " + profile);
|
||||
LOGGER.info("Process eperson item with UUID {}", profile);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ public class PublicationLoaderRunnable
|
||||
* the researcher with this UUID will be chosen. If the uuid doesn't match any
|
||||
* researcher, the method returns an empty array list. If uuid is null, all
|
||||
* research will be return.
|
||||
*
|
||||
*
|
||||
* @param profileUUID uuid of the researcher. If null, all researcher will be
|
||||
* returned.
|
||||
* @return the researcher with specified UUID or all researchers
|
||||
@@ -96,10 +96,10 @@ public class PublicationLoaderRunnable
|
||||
private Iterator<Item> getResearchers(String profileUUID) {
|
||||
SearchService searchService = new DSpace().getSingletonService(SearchService.class);
|
||||
DiscoverQueryBuilder queryBuilder = SearchUtils.getQueryBuilder();
|
||||
List<QueryBuilderSearchFilter> filters = new ArrayList<QueryBuilderSearchFilter>();
|
||||
List<QueryBuilderSearchFilter> filters = new ArrayList<>();
|
||||
String query = "*:*";
|
||||
if (profileUUID != null) {
|
||||
query = "search.resourceid:" + profileUUID.toString();
|
||||
query = "search.resourceid:" + profileUUID;
|
||||
}
|
||||
try {
|
||||
DiscoverQuery discoverQuery = queryBuilder.buildQuery(context, null,
|
||||
|
@@ -12,13 +12,13 @@ import java.sql.SQLException;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Date;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.app.util.factory.UtilServiceFactory;
|
||||
import org.dspace.app.util.service.WebAppService;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Represent a DSpace application while it is running. This helps us report
|
||||
@@ -29,11 +29,10 @@ import org.slf4j.LoggerFactory;
|
||||
*/
|
||||
abstract public class AbstractDSpaceWebapp
|
||||
implements DSpaceWebappMXBean {
|
||||
private static final Logger log = LoggerFactory.getLogger(AbstractDSpaceWebapp.class);
|
||||
private static final Logger log = LogManager.getLogger();
|
||||
|
||||
protected final WebAppService webAppService = UtilServiceFactory.getInstance().getWebAppService();
|
||||
|
||||
|
||||
protected String kind;
|
||||
|
||||
protected Date started;
|
||||
|
@@ -16,10 +16,10 @@ import java.util.regex.PatternSyntaxException;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.content.MetadataSchemaEnum;
|
||||
import org.dspace.core.Utils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Class representing a line in an input form.
|
||||
@@ -28,7 +28,7 @@ import org.slf4j.LoggerFactory;
|
||||
*/
|
||||
public class DCInput {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(DCInput.class);
|
||||
private static final Logger log = LogManager.getLogger();
|
||||
|
||||
/**
|
||||
* the DC element name
|
||||
@@ -183,7 +183,7 @@ public class DCInput {
|
||||
}
|
||||
|
||||
//check if the input have a language tag
|
||||
language = Boolean.valueOf(fieldMap.get("language"));
|
||||
language = Boolean.parseBoolean(fieldMap.get("language"));
|
||||
valueLanguageList = new ArrayList<>();
|
||||
if (language) {
|
||||
String languageNameTmp = fieldMap.get("value-pairs-name");
|
||||
@@ -219,7 +219,7 @@ public class DCInput {
|
||||
|| "yes".equalsIgnoreCase(closedVocabularyStr);
|
||||
|
||||
// parsing of the <type-bind> element (using the colon as split separator)
|
||||
typeBind = new ArrayList<String>();
|
||||
typeBind = new ArrayList<>();
|
||||
String typeBindDef = fieldMap.get("type-bind");
|
||||
if (typeBindDef != null && typeBindDef.trim().length() > 0) {
|
||||
String[] types = typeBindDef.split(",");
|
||||
@@ -523,7 +523,7 @@ public class DCInput {
|
||||
* @return true when there is no type restriction or typeName is allowed
|
||||
*/
|
||||
public boolean isAllowedFor(String typeName) {
|
||||
if (typeBind.size() == 0) {
|
||||
if (typeBind.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -15,6 +15,8 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.authenticate.service.AuthenticationService;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.core.Context;
|
||||
@@ -22,8 +24,6 @@ import org.dspace.core.factory.CoreServiceFactory;
|
||||
import org.dspace.eperson.EPerson;
|
||||
import org.dspace.eperson.Group;
|
||||
import org.dspace.eperson.service.EPersonService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
@@ -49,15 +49,14 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
* specified first (in the configuration) thus getting highest priority.
|
||||
*
|
||||
* @author Larry Stone
|
||||
* @version $Revision$
|
||||
* @see AuthenticationMethod
|
||||
*/
|
||||
public class AuthenticationServiceImpl implements AuthenticationService {
|
||||
|
||||
/**
|
||||
* SLF4J logging category
|
||||
* Logging category
|
||||
*/
|
||||
private final Logger log = (Logger) LoggerFactory.getLogger(AuthenticationServiceImpl.class);
|
||||
private final Logger log = LogManager.getLogger();
|
||||
|
||||
@Autowired(required = true)
|
||||
protected EPersonService ePersonService;
|
||||
@@ -121,6 +120,7 @@ public class AuthenticationServiceImpl implements AuthenticationService {
|
||||
return bestRet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateLastActiveDate(Context context) {
|
||||
EPerson me = context.getCurrentUser();
|
||||
if (me != null) {
|
||||
|
@@ -24,6 +24,8 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.authenticate.oidc.OidcClient;
|
||||
import org.dspace.authenticate.oidc.model.OidcTokenResponseDTO;
|
||||
import org.dspace.core.Context;
|
||||
@@ -31,8 +33,6 @@ import org.dspace.eperson.EPerson;
|
||||
import org.dspace.eperson.Group;
|
||||
import org.dspace.eperson.service.EPersonService;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
@@ -51,7 +51,7 @@ public class OidcAuthenticationBean implements AuthenticationMethod {
|
||||
|
||||
private final static String LOGIN_PAGE_URL_FORMAT = "%s?client_id=%s&response_type=code&scope=%s&redirect_uri=%s";
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(OidcAuthenticationBean.class);
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
private static final String OIDC_AUTHENTICATED = "oidc.authenticated";
|
||||
|
||||
@@ -174,7 +174,7 @@ public class OidcAuthenticationBean implements AuthenticationMethod {
|
||||
final Entry<String, String> entry = iterator.next();
|
||||
|
||||
if (isBlank(entry.getValue())) {
|
||||
LOGGER.error(" * {} is missing", entry.getKey());
|
||||
LOGGER.error(" * {} is missing", entry::getKey);
|
||||
}
|
||||
}
|
||||
return "";
|
||||
@@ -183,7 +183,7 @@ public class OidcAuthenticationBean implements AuthenticationMethod {
|
||||
try {
|
||||
return format(LOGIN_PAGE_URL_FORMAT, authorizeUrl, clientId, scopes, encode(redirectUri, "UTF-8"));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
LOGGER.error(e.getMessage(), e);
|
||||
LOGGER.error(e::getMessage, e);
|
||||
return "";
|
||||
}
|
||||
|
||||
|
@@ -23,6 +23,8 @@ import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.eperson.EPerson;
|
||||
@@ -39,8 +41,6 @@ import org.dspace.profile.service.ResearcherProfileService;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.orcid.jaxb.model.v3.release.record.Email;
|
||||
import org.orcid.jaxb.model.v3.release.record.Person;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
@@ -53,7 +53,7 @@ public class OrcidAuthenticationBean implements AuthenticationMethod {
|
||||
|
||||
public static final String ORCID_AUTH_ATTRIBUTE = "orcid-authentication";
|
||||
|
||||
private final static Logger LOGGER = LoggerFactory.getLogger(OrcidAuthenticationBean.class);
|
||||
private final static Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
private final static String LOGIN_PAGE_URL_FORMAT = "%s?client_id=%s&response_type=code&scope=%s&redirect_uri=%s";
|
||||
|
||||
@@ -282,7 +282,8 @@ public class OrcidAuthenticationBean implements AuthenticationMethod {
|
||||
try {
|
||||
return orcidClient.getPerson(token.getAccessToken(), token.getOrcid());
|
||||
} catch (Exception ex) {
|
||||
LOGGER.error("An error occurs retriving the ORCID record with id " + token.getOrcid(), ex);
|
||||
LOGGER.error("An error occurs retriving the ORCID record with id {}",
|
||||
token.getOrcid(), ex);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@@ -18,12 +18,12 @@ import javax.xml.transform.TransformerConfigurationException;
|
||||
import javax.xml.transform.TransformerFactory;
|
||||
import javax.xml.transform.stream.StreamSource;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.core.SelfNamedPlugin;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
import org.jdom2.Namespace;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Configurable XSLT-driven Crosswalk
|
||||
@@ -88,7 +88,7 @@ public abstract class XSLTCrosswalk extends SelfNamedPlugin {
|
||||
/**
|
||||
* log4j category
|
||||
*/
|
||||
private static final Logger LOG = LoggerFactory.getLogger(XSLTCrosswalk.class);
|
||||
private static final Logger LOG = LogManager.getLogger();
|
||||
|
||||
/**
|
||||
* DSpace XML Namespace in JDOM form.
|
||||
@@ -168,8 +168,8 @@ public abstract class XSLTCrosswalk extends SelfNamedPlugin {
|
||||
transformFile.lastModified() > transformLastModified) {
|
||||
try {
|
||||
LOG.debug(
|
||||
(transformer == null ? "Loading {} XSLT stylesheet from {}" : "Reloading {} XSLT stylesheet from " +
|
||||
"{}"),
|
||||
(transformer == null ? "Loading {} XSLT stylesheet from {}"
|
||||
: "Reloading {} XSLT stylesheet from {}"),
|
||||
getPluginInstanceName(), transformFile.toString());
|
||||
|
||||
Source transformSource
|
||||
|
@@ -23,6 +23,8 @@ import javax.xml.transform.Transformer;
|
||||
import javax.xml.transform.TransformerException;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.Collection;
|
||||
import org.dspace.content.Community;
|
||||
@@ -51,8 +53,6 @@ import org.jdom2.output.Format;
|
||||
import org.jdom2.output.XMLOutputter;
|
||||
import org.jdom2.transform.JDOMResult;
|
||||
import org.jdom2.transform.JDOMSource;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Configurable XSLT-driven dissemination Crosswalk
|
||||
@@ -88,7 +88,7 @@ public class XSLTDisseminationCrosswalk
|
||||
/**
|
||||
* log4j category
|
||||
*/
|
||||
private static final Logger LOG = LoggerFactory.getLogger(XSLTDisseminationCrosswalk.class);
|
||||
private static final Logger LOG = LogManager.getLogger();
|
||||
|
||||
/**
|
||||
* DSpace context, will be created if XSLTDisseminationCrosswalk had been started by command-line.
|
||||
@@ -140,12 +140,13 @@ public class XSLTDisseminationCrosswalk
|
||||
// right format for value of "schemaLocation" attribute.
|
||||
schemaLocation = configurationService.getProperty(prefix + "schemaLocation");
|
||||
if (schemaLocation == null) {
|
||||
LOG.warn("No schemaLocation for crosswalk=" + myAlias + ", key=" + prefix + "schemaLocation");
|
||||
LOG.warn("No schemaLocation for crosswalk={}, key={}schemaLocation", myAlias, prefix);
|
||||
} else if (schemaLocation.length() > 0 && schemaLocation.indexOf(' ') < 0) {
|
||||
// sanity check: schemaLocation should have space.
|
||||
LOG.warn("Possible INVALID schemaLocation (no space found) for crosswalk=" +
|
||||
myAlias + ", key=" + prefix + "schemaLocation" +
|
||||
"\n\tCorrect format is \"{namespace} {schema-URL}\"");
|
||||
LOG.warn("Possible INVALID schemaLocation (no space found) for crosswalk={},"
|
||||
+ " key={}schemaLocation"
|
||||
+ "\n\tCorrect format is \"{namespace} {schema-URL}\"",
|
||||
myAlias, prefix);
|
||||
}
|
||||
|
||||
// grovel for namespaces of the form:
|
||||
@@ -172,7 +173,7 @@ public class XSLTDisseminationCrosswalk
|
||||
try {
|
||||
init();
|
||||
} catch (CrosswalkInternalException e) {
|
||||
LOG.error(e.toString());
|
||||
LOG.error(e::toString);
|
||||
}
|
||||
return (Namespace[]) ArrayUtils.clone(namespaces);
|
||||
}
|
||||
@@ -187,7 +188,7 @@ public class XSLTDisseminationCrosswalk
|
||||
try {
|
||||
init();
|
||||
} catch (CrosswalkInternalException e) {
|
||||
LOG.error(e.toString());
|
||||
LOG.error(e::toString);
|
||||
}
|
||||
return schemaLocation;
|
||||
}
|
||||
@@ -220,7 +221,7 @@ public class XSLTDisseminationCrosswalk
|
||||
}
|
||||
|
||||
for (Map.Entry<String, String> parameter : parameters.entrySet()) {
|
||||
LOG.debug("Setting parameter {} to {}", parameter.getKey(), parameter.getValue());
|
||||
LOG.debug("Setting parameter {} to {}", parameter::getKey, parameter::getValue);
|
||||
xform.setParameter(parameter.getKey(), parameter.getValue());
|
||||
}
|
||||
|
||||
@@ -232,7 +233,7 @@ public class XSLTDisseminationCrosswalk
|
||||
root.detach();
|
||||
return root;
|
||||
} catch (TransformerException e) {
|
||||
LOG.error("Got error: " + e.toString());
|
||||
LOG.error("Got error: ()", e::toString);
|
||||
throw new CrosswalkInternalException("XSL translation failed: " + e.toString(), e);
|
||||
}
|
||||
}
|
||||
@@ -278,13 +279,13 @@ public class XSLTDisseminationCrosswalk
|
||||
.map(Element.class::cast).collect(Collectors.toList());
|
||||
return elementList;
|
||||
} catch (TransformerException e) {
|
||||
LOG.error("Got error: " + e.toString());
|
||||
LOG.error("Got error: {}", e::toString);
|
||||
throw new CrosswalkInternalException("XSL translation failed: " + e.toString(), e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine is this crosswalk can dessiminate the given object.
|
||||
* Determine is this crosswalk can disseminate the given object.
|
||||
*
|
||||
* @see DisseminationCrosswalk
|
||||
*/
|
||||
@@ -304,7 +305,7 @@ public class XSLTDisseminationCrosswalk
|
||||
try {
|
||||
init();
|
||||
} catch (CrosswalkInternalException e) {
|
||||
LOG.error(e.toString());
|
||||
LOG.error(e::toString);
|
||||
}
|
||||
return preferList;
|
||||
}
|
||||
@@ -312,7 +313,7 @@ public class XSLTDisseminationCrosswalk
|
||||
/**
|
||||
* Generate an intermediate representation of a DSpace object.
|
||||
*
|
||||
* @param dso The dspace object to build a representation of.
|
||||
* @param dso The DSpace object to build a representation of.
|
||||
* @param dcvs list of metadata
|
||||
* @return element
|
||||
*/
|
||||
@@ -480,9 +481,7 @@ public class XSLTDisseminationCrosswalk
|
||||
if (reason == null) {
|
||||
return value;
|
||||
} else {
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("Filtering out non-XML characters in string, reason=" + reason);
|
||||
}
|
||||
LOG.debug("Filtering out non-XML characters in string, reason={}", reason);
|
||||
StringBuilder result = new StringBuilder(value.length());
|
||||
for (int i = 0; i < value.length(); ++i) {
|
||||
char c = value.charAt(i);
|
||||
@@ -567,11 +566,11 @@ public class XSLTDisseminationCrosswalk
|
||||
System.err.println("=== Stack Trace ===");
|
||||
e.printStackTrace(System.err);
|
||||
System.err.println("=====================");
|
||||
LOG.error("Caught: {}.", e.toString());
|
||||
LOG.error(e.getMessage());
|
||||
LOG.error("Caught: {}.", e::toString);
|
||||
LOG.error(e::getMessage);
|
||||
CharArrayWriter traceWriter = new CharArrayWriter(2048);
|
||||
e.printStackTrace(new PrintWriter(traceWriter));
|
||||
LOG.error(traceWriter.toString());
|
||||
LOG.error(traceWriter::toString);
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
@@ -588,11 +587,11 @@ public class XSLTDisseminationCrosswalk
|
||||
System.err.println("=== Stack Trace ===");
|
||||
e.printStackTrace(System.err);
|
||||
System.err.println("=====================");
|
||||
LOG.error("Caught: {}.", e.toString());
|
||||
LOG.error(e.getMessage());
|
||||
LOG.error("Caught: {}.", e::toString);
|
||||
LOG.error(e::getMessage);
|
||||
CharArrayWriter traceWriter = new CharArrayWriter(2048);
|
||||
e.printStackTrace(new PrintWriter(traceWriter));
|
||||
LOG.error(traceWriter.toString());
|
||||
LOG.error(traceWriter::toString);
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
|
@@ -12,6 +12,7 @@ import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import javax.persistence.Query;
|
||||
import javax.persistence.criteria.CriteriaBuilder;
|
||||
import javax.persistence.criteria.CriteriaQuery;
|
||||
@@ -26,6 +27,7 @@ import org.dspace.content.dao.BitstreamDAO;
|
||||
import org.dspace.core.AbstractHibernateDSODAO;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.core.UUIDIterator;
|
||||
|
||||
/**
|
||||
* Hibernate implementation of the Database Access Object interface class for the Bitstream object.
|
||||
@@ -76,7 +78,7 @@ public class BitstreamDAOImpl extends AbstractHibernateDSODAO<Bitstream> impleme
|
||||
|
||||
@Override
|
||||
public Iterator<Bitstream> findByCommunity(Context context, Community community) throws SQLException {
|
||||
Query query = createQuery(context, "select b from Bitstream b " +
|
||||
Query query = createQuery(context, "select b.id from Bitstream b " +
|
||||
"join b.bundles bitBundles " +
|
||||
"join bitBundles.items item " +
|
||||
"join item.collections itemColl " +
|
||||
@@ -84,40 +86,45 @@ public class BitstreamDAOImpl extends AbstractHibernateDSODAO<Bitstream> impleme
|
||||
"WHERE :community IN community");
|
||||
|
||||
query.setParameter("community", community);
|
||||
|
||||
return iterate(query);
|
||||
@SuppressWarnings("unchecked")
|
||||
List<UUID> uuids = query.getResultList();
|
||||
return new UUIDIterator<Bitstream>(context, uuids, Bitstream.class, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Bitstream> findByCollection(Context context, Collection collection) throws SQLException {
|
||||
Query query = createQuery(context, "select b from Bitstream b " +
|
||||
Query query = createQuery(context, "select b.id from Bitstream b " +
|
||||
"join b.bundles bitBundles " +
|
||||
"join bitBundles.items item " +
|
||||
"join item.collections c " +
|
||||
"WHERE :collection IN c");
|
||||
|
||||
query.setParameter("collection", collection);
|
||||
|
||||
return iterate(query);
|
||||
@SuppressWarnings("unchecked")
|
||||
List<UUID> uuids = query.getResultList();
|
||||
return new UUIDIterator<Bitstream>(context, uuids, Bitstream.class, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Bitstream> findByItem(Context context, Item item) throws SQLException {
|
||||
Query query = createQuery(context, "select b from Bitstream b " +
|
||||
Query query = createQuery(context, "select b.id from Bitstream b " +
|
||||
"join b.bundles bitBundles " +
|
||||
"join bitBundles.items item " +
|
||||
"WHERE :item IN item");
|
||||
|
||||
query.setParameter("item", item);
|
||||
|
||||
return iterate(query);
|
||||
@SuppressWarnings("unchecked")
|
||||
List<UUID> uuids = query.getResultList();
|
||||
return new UUIDIterator<Bitstream>(context, uuids, Bitstream.class, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Bitstream> findByStoreNumber(Context context, Integer storeNumber) throws SQLException {
|
||||
Query query = createQuery(context, "select b from Bitstream b where b.storeNumber = :storeNumber");
|
||||
Query query = createQuery(context, "select b.id from Bitstream b where b.storeNumber = :storeNumber");
|
||||
query.setParameter("storeNumber", storeNumber);
|
||||
return iterate(query);
|
||||
@SuppressWarnings("unchecked")
|
||||
List<UUID> uuids = query.getResultList();
|
||||
return new UUIDIterator<Bitstream>(context, uuids, Bitstream.class, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -36,6 +36,7 @@ import org.dspace.contentreport.QueryOperator;
|
||||
import org.dspace.contentreport.QueryPredicate;
|
||||
import org.dspace.core.AbstractHibernateDSODAO;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.core.UUIDIterator;
|
||||
import org.dspace.eperson.EPerson;
|
||||
import org.dspace.util.JpaCriteriaBuilderKit;
|
||||
|
||||
@@ -54,28 +55,34 @@ public class ItemDAOImpl extends AbstractHibernateDSODAO<Item> implements ItemDA
|
||||
|
||||
@Override
|
||||
public Iterator<Item> findAll(Context context, boolean archived) throws SQLException {
|
||||
Query query = createQuery(context, "FROM Item WHERE inArchive=:in_archive ORDER BY id");
|
||||
Query query = createQuery(context, "SELECT i.id FROM Item i WHERE inArchive=:in_archive ORDER BY id");
|
||||
query.setParameter("in_archive", archived);
|
||||
return iterate(query);
|
||||
@SuppressWarnings("unchecked")
|
||||
List<UUID> uuids = query.getResultList();
|
||||
return new UUIDIterator<Item>(context, uuids, Item.class, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Item> findAll(Context context, boolean archived, int limit, int offset) throws SQLException {
|
||||
Query query = createQuery(context, "FROM Item WHERE inArchive=:in_archive ORDER BY id");
|
||||
Query query = createQuery(context, "SELECT i.id FROM Item i WHERE inArchive=:in_archive ORDER BY id");
|
||||
query.setParameter("in_archive", archived);
|
||||
query.setFirstResult(offset);
|
||||
query.setMaxResults(limit);
|
||||
return iterate(query);
|
||||
@SuppressWarnings("unchecked")
|
||||
List<UUID> uuids = query.getResultList();
|
||||
return new UUIDIterator<Item>(context, uuids, Item.class, this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Iterator<Item> findAll(Context context, boolean archived, boolean withdrawn) throws SQLException {
|
||||
Query query = createQuery(context,
|
||||
"FROM Item WHERE inArchive=:in_archive or withdrawn=:withdrawn ORDER BY id");
|
||||
"SELECT i.id FROM Item i WHERE inArchive=:in_archive or withdrawn=:withdrawn ORDER BY id");
|
||||
query.setParameter("in_archive", archived);
|
||||
query.setParameter("withdrawn", withdrawn);
|
||||
return iterate(query);
|
||||
@SuppressWarnings("unchecked")
|
||||
List<UUID> uuids = query.getResultList();
|
||||
return new UUIDIterator<Item>(context, uuids, Item.class, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -84,12 +91,14 @@ public class ItemDAOImpl extends AbstractHibernateDSODAO<Item> implements ItemDA
|
||||
// It does not include workspace, workflow or template items.
|
||||
Query query = createQuery(
|
||||
context,
|
||||
"SELECT i FROM Item as i " +
|
||||
"SELECT i.id FROM Item as i " +
|
||||
"LEFT JOIN Version as v ON i = v.item " +
|
||||
"WHERE i.inArchive=true or i.withdrawn=true or (i.inArchive=false and v.id IS NOT NULL) " +
|
||||
"ORDER BY i.id"
|
||||
);
|
||||
return iterate(query);
|
||||
@SuppressWarnings("unchecked")
|
||||
List<UUID> uuids = query.getResultList();
|
||||
return new UUIDIterator<Item>(context, uuids, Item.class, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -97,7 +106,7 @@ public class ItemDAOImpl extends AbstractHibernateDSODAO<Item> implements ItemDA
|
||||
boolean withdrawn, boolean discoverable, Date lastModified)
|
||||
throws SQLException {
|
||||
StringBuilder queryStr = new StringBuilder();
|
||||
queryStr.append("SELECT i FROM Item i");
|
||||
queryStr.append("SELECT i.id FROM Item i");
|
||||
queryStr.append(" WHERE (inArchive = :in_archive OR withdrawn = :withdrawn)");
|
||||
queryStr.append(" AND discoverable = :discoverable");
|
||||
|
||||
@@ -113,16 +122,20 @@ public class ItemDAOImpl extends AbstractHibernateDSODAO<Item> implements ItemDA
|
||||
if (lastModified != null) {
|
||||
query.setParameter("last_modified", lastModified, TemporalType.TIMESTAMP);
|
||||
}
|
||||
return iterate(query);
|
||||
@SuppressWarnings("unchecked")
|
||||
List<UUID> uuids = query.getResultList();
|
||||
return new UUIDIterator<Item>(context, uuids, Item.class, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Item> findBySubmitter(Context context, EPerson eperson) throws SQLException {
|
||||
Query query = createQuery(context,
|
||||
"FROM Item WHERE inArchive=:in_archive and submitter=:submitter ORDER BY id");
|
||||
"SELECT i.id FROM Item i WHERE inArchive=:in_archive and submitter=:submitter ORDER BY id");
|
||||
query.setParameter("in_archive", true);
|
||||
query.setParameter("submitter", eperson);
|
||||
return iterate(query);
|
||||
@SuppressWarnings("unchecked")
|
||||
List<UUID> uuids = query.getResultList();
|
||||
return new UUIDIterator<Item>(context, uuids, Item.class, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -131,16 +144,18 @@ public class ItemDAOImpl extends AbstractHibernateDSODAO<Item> implements ItemDA
|
||||
if (!retrieveAllItems) {
|
||||
return findBySubmitter(context, eperson);
|
||||
}
|
||||
Query query = createQuery(context, "FROM Item WHERE submitter=:submitter ORDER BY id");
|
||||
Query query = createQuery(context, "SELECT i.id FROM Item i WHERE submitter=:submitter ORDER BY id");
|
||||
query.setParameter("submitter", eperson);
|
||||
return iterate(query);
|
||||
@SuppressWarnings("unchecked")
|
||||
List<UUID> uuids = query.getResultList();
|
||||
return new UUIDIterator<Item>(context, uuids, Item.class, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Item> findBySubmitter(Context context, EPerson eperson, MetadataField metadataField, int limit)
|
||||
throws SQLException {
|
||||
StringBuilder query = new StringBuilder();
|
||||
query.append("SELECT item FROM Item as item ");
|
||||
query.append("SELECT item.id FROM Item as item ");
|
||||
addMetadataLeftJoin(query, Item.class.getSimpleName().toLowerCase(), Collections.singletonList(metadataField));
|
||||
query.append(" WHERE item.inArchive = :in_archive");
|
||||
query.append(" AND item.submitter =:submitter");
|
||||
@@ -152,13 +167,15 @@ public class ItemDAOImpl extends AbstractHibernateDSODAO<Item> implements ItemDA
|
||||
hibernateQuery.setParameter("in_archive", true);
|
||||
hibernateQuery.setParameter("submitter", eperson);
|
||||
hibernateQuery.setMaxResults(limit);
|
||||
return iterate(hibernateQuery);
|
||||
@SuppressWarnings("unchecked")
|
||||
List<UUID> uuids = hibernateQuery.getResultList();
|
||||
return new UUIDIterator<Item>(context, uuids, Item.class, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Item> findByMetadataField(Context context, MetadataField metadataField, String value,
|
||||
boolean inArchive) throws SQLException {
|
||||
String hqlQueryString = "SELECT item FROM Item as item join item.metadata metadatavalue " +
|
||||
String hqlQueryString = "SELECT item.id FROM Item as item join item.metadata metadatavalue " +
|
||||
"WHERE item.inArchive=:in_archive AND metadatavalue.metadataField = :metadata_field";
|
||||
if (value != null) {
|
||||
hqlQueryString += " AND STR(metadatavalue.value) = :text_value";
|
||||
@@ -170,7 +187,9 @@ public class ItemDAOImpl extends AbstractHibernateDSODAO<Item> implements ItemDA
|
||||
if (value != null) {
|
||||
query.setParameter("text_value", value);
|
||||
}
|
||||
return iterate(query);
|
||||
@SuppressWarnings("unchecked")
|
||||
List<UUID> uuids = query.getResultList();
|
||||
return new UUIDIterator<Item>(context, uuids, Item.class, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -276,20 +295,22 @@ public class ItemDAOImpl extends AbstractHibernateDSODAO<Item> implements ItemDA
|
||||
public Iterator<Item> findByAuthorityValue(Context context, MetadataField metadataField, String authority,
|
||||
boolean inArchive) throws SQLException {
|
||||
Query query = createQuery(context,
|
||||
"SELECT item FROM Item as item join item.metadata metadatavalue " +
|
||||
"SELECT item.id FROM Item as item join item.metadata metadatavalue " +
|
||||
"WHERE item.inArchive=:in_archive AND metadatavalue.metadataField = :metadata_field AND " +
|
||||
"metadatavalue.authority = :authority ORDER BY item.id");
|
||||
query.setParameter("in_archive", inArchive);
|
||||
query.setParameter("metadata_field", metadataField);
|
||||
query.setParameter("authority", authority);
|
||||
return iterate(query);
|
||||
@SuppressWarnings("unchecked")
|
||||
List<UUID> uuids = query.getResultList();
|
||||
return new UUIDIterator<Item>(context, uuids, Item.class, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Item> findArchivedByCollection(Context context, Collection collection, Integer limit,
|
||||
Integer offset) throws SQLException {
|
||||
Query query = createQuery(context,
|
||||
"select i from Item i join i.collections c " +
|
||||
"select i.id from Item i join i.collections c " +
|
||||
"WHERE :collection IN c AND i.inArchive=:in_archive ORDER BY i.id");
|
||||
query.setParameter("collection", collection);
|
||||
query.setParameter("in_archive", true);
|
||||
@@ -299,7 +320,9 @@ public class ItemDAOImpl extends AbstractHibernateDSODAO<Item> implements ItemDA
|
||||
if (limit != null) {
|
||||
query.setMaxResults(limit);
|
||||
}
|
||||
return iterate(query);
|
||||
@SuppressWarnings("unchecked")
|
||||
List<UUID> uuids = query.getResultList();
|
||||
return new UUIDIterator<Item>(context, uuids, Item.class, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -334,17 +357,18 @@ public class ItemDAOImpl extends AbstractHibernateDSODAO<Item> implements ItemDA
|
||||
@Override
|
||||
public Iterator<Item> findAllByCollection(Context context, Collection collection) throws SQLException {
|
||||
Query query = createQuery(context,
|
||||
"select i from Item i join i.collections c WHERE :collection IN c ORDER BY i.id");
|
||||
"select i.id from Item i join i.collections c WHERE :collection IN c ORDER BY i.id");
|
||||
query.setParameter("collection", collection);
|
||||
|
||||
return iterate(query);
|
||||
@SuppressWarnings("unchecked")
|
||||
List<UUID> uuids = query.getResultList();
|
||||
return new UUIDIterator<Item>(context, uuids, Item.class, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Item> findAllByCollection(Context context, Collection collection, Integer limit, Integer offset)
|
||||
throws SQLException {
|
||||
Query query = createQuery(context,
|
||||
"select i from Item i join i.collections c WHERE :collection IN c ORDER BY i.id");
|
||||
"select i.id from Item i join i.collections c WHERE :collection IN c ORDER BY i.id");
|
||||
query.setParameter("collection", collection);
|
||||
|
||||
if (offset != null) {
|
||||
@@ -353,8 +377,9 @@ public class ItemDAOImpl extends AbstractHibernateDSODAO<Item> implements ItemDA
|
||||
if (limit != null) {
|
||||
query.setMaxResults(limit);
|
||||
}
|
||||
|
||||
return iterate(query);
|
||||
@SuppressWarnings("unchecked")
|
||||
List<UUID> uuids = query.getResultList();
|
||||
return new UUIDIterator<Item>(context, uuids, Item.class, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -390,9 +415,11 @@ public class ItemDAOImpl extends AbstractHibernateDSODAO<Item> implements ItemDA
|
||||
public Iterator<Item> findByLastModifiedSince(Context context, Date since)
|
||||
throws SQLException {
|
||||
Query query = createQuery(context,
|
||||
"SELECT i FROM Item i WHERE last_modified > :last_modified ORDER BY id");
|
||||
"SELECT i.id FROM Item i WHERE last_modified > :last_modified ORDER BY id");
|
||||
query.setParameter("last_modified", since, TemporalType.TIMESTAMP);
|
||||
return iterate(query);
|
||||
@SuppressWarnings("unchecked")
|
||||
List<UUID> uuids = query.getResultList();
|
||||
return new UUIDIterator<Item>(context, uuids, Item.class, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -19,6 +19,8 @@ import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
import org.apache.commons.codec.DecoderException;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.Collection;
|
||||
import org.dspace.content.Community;
|
||||
@@ -36,8 +38,6 @@ import org.dspace.eperson.PasswordHash;
|
||||
import org.dspace.eperson.factory.EPersonServiceFactory;
|
||||
import org.dspace.eperson.service.EPersonService;
|
||||
import org.dspace.eperson.service.GroupService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.NamedNodeMap;
|
||||
@@ -51,8 +51,7 @@ import org.xml.sax.SAXException;
|
||||
* @author mwood
|
||||
*/
|
||||
public class RoleIngester implements PackageIngester {
|
||||
private static final Logger log = LoggerFactory
|
||||
.getLogger(RoleIngester.class);
|
||||
private static final Logger log = LogManager.getLogger();
|
||||
|
||||
protected CommunityService communityService = ContentServiceFactory.getInstance().getCommunityService();
|
||||
protected CollectionService collectionService = ContentServiceFactory.getInstance().getCollectionService();
|
||||
@@ -217,10 +216,10 @@ public class RoleIngester implements PackageIngester {
|
||||
// Community or Collection that doesn't currently exist in the
|
||||
// system. So, log a warning & skip it for now.
|
||||
log.warn(
|
||||
"Skipping group named '" + name + "' as it seems to correspond to a Community or Collection that " +
|
||||
"Skipping group named '{}' as it seems to correspond to a Community or Collection that " +
|
||||
"does not exist in the system. " +
|
||||
"If you are performing an AIP restore, you can ignore this warning as the " +
|
||||
"Community/Collection AIP will likely create this group once it is processed.");
|
||||
"Community/Collection AIP will likely create this group once it is processed.", name);
|
||||
continue;
|
||||
}
|
||||
log.debug("Translated group name: {}", name);
|
||||
@@ -307,7 +306,7 @@ public class RoleIngester implements PackageIngester {
|
||||
// Always set the name: parent.createBlop() is guessing
|
||||
groupService.setName(groupObj, name);
|
||||
|
||||
log.info("Created Group {}.", groupObj.getName());
|
||||
log.info("Created Group {}.", groupObj::getName);
|
||||
}
|
||||
|
||||
// Add EPeople to newly created Group
|
||||
|
@@ -8,7 +8,6 @@
|
||||
package org.dspace.contentreport;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.function.BiFunction;
|
||||
import javax.persistence.criteria.CriteriaBuilder;
|
||||
import javax.persistence.criteria.Expression;
|
||||
import javax.persistence.criteria.Path;
|
||||
@@ -21,10 +20,6 @@ import org.dspace.content.MetadataValue;
|
||||
import org.dspace.content.MetadataValue_;
|
||||
import org.dspace.util.DSpacePostgreSQLDialect;
|
||||
import org.dspace.util.JpaCriteriaBuilderKit;
|
||||
import org.hibernate.criterion.Criterion;
|
||||
import org.hibernate.criterion.Property;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
import org.hibernate.type.StandardBasicTypes;
|
||||
|
||||
/**
|
||||
* Operators available for creating predicates to query the
|
||||
@@ -34,52 +29,36 @@ import org.hibernate.type.StandardBasicTypes;
|
||||
public enum QueryOperator {
|
||||
|
||||
EXISTS("exists", true, false,
|
||||
(val, regexClause) -> Property.forName("mv.value").isNotNull(),
|
||||
(val, regexClause, jpaKit) -> jpaKit.criteriaBuilder().isNotNull(jpaKit.root().get(MetadataValue_.VALUE))),
|
||||
DOES_NOT_EXIST("doesnt_exist", true, true,
|
||||
(val, regexClause) -> EXISTS.buildPredicate(val, regexClause),
|
||||
(val, regexClause, jpaKit) -> EXISTS.buildJpaPredicate(val, regexClause, jpaKit)),
|
||||
EQUALS("equals", true, false,
|
||||
(val, regexClause) -> Property.forName("mv.value").eq(val),
|
||||
(val, regexClause, jpaKit) -> jpaKit.criteriaBuilder().equal(jpaKit.root().get(MetadataValue_.VALUE), val)),
|
||||
DOES_NOT_EQUAL("not_equals", true, true,
|
||||
(val, regexClause) -> EQUALS.buildPredicate(val, regexClause),
|
||||
(val, regexClause, jpaKit) -> EQUALS.buildJpaPredicate(val, regexClause, jpaKit)),
|
||||
LIKE("like", true, false,
|
||||
(val, regexClause) -> Property.forName("mv.value").like(val),
|
||||
(val, regexClause, jpaKit) -> jpaKit.criteriaBuilder().like(jpaKit.root().get(MetadataValue_.VALUE), val)),
|
||||
NOT_LIKE("not_like", true, true,
|
||||
(val, regexClause) -> LIKE.buildPredicate(val, regexClause),
|
||||
(val, regexClause, jpaKit) -> LIKE.buildJpaPredicate(val, regexClause, jpaKit)),
|
||||
CONTAINS("contains", true, false,
|
||||
(val, regexClause) -> Property.forName("mv.value").like("%" + val + "%"),
|
||||
(val, regexClause, jpaKit) -> LIKE.buildJpaPredicate("%" + val + "%", regexClause, jpaKit)),
|
||||
DOES_NOT_CONTAIN("doesnt_contain", true, true,
|
||||
(val, regexClause) -> CONTAINS.buildPredicate(val, regexClause),
|
||||
(val, regexClause, jpaKit) -> CONTAINS.buildJpaPredicate(val, regexClause, jpaKit)),
|
||||
MATCHES("matches", false, false,
|
||||
(val, regexClause) -> Restrictions.sqlRestriction(regexClause, val, StandardBasicTypes.STRING),
|
||||
(val, regexClause, jpaKit) -> regexPredicate(val, DSpacePostgreSQLDialect.REGEX_MATCHES, jpaKit)),
|
||||
DOES_NOT_MATCH("doesnt_match", false, false,
|
||||
(val, regexClause) -> Restrictions.not(Restrictions.sqlRestriction(
|
||||
regexClause, val, StandardBasicTypes.STRING)),
|
||||
(val, regexClause, jpaKit) -> regexPredicate(val, DSpacePostgreSQLDialect.REGEX_NOT_MATCHES, jpaKit));
|
||||
|
||||
private final String code;
|
||||
/** Criteria builder for the old Hibernate API */
|
||||
@Deprecated(forRemoval = true)
|
||||
private final BiFunction<String, String, Criterion> criterionBuilder;
|
||||
private final TriFunction<String, String, JpaCriteriaBuilderKit<MetadataValue>, Predicate> predicateBuilder;
|
||||
private final boolean usesRegex;
|
||||
private final boolean negate;
|
||||
|
||||
QueryOperator(String code, boolean usesRegex, boolean negate,
|
||||
BiFunction<String, String, Criterion> criterionBuilder,
|
||||
TriFunction<String, String, JpaCriteriaBuilderKit<MetadataValue>, Predicate> predicateBuilder) {
|
||||
this.code = code;
|
||||
this.usesRegex = usesRegex;
|
||||
this.negate = negate;
|
||||
this.criterionBuilder = criterionBuilder;
|
||||
this.predicateBuilder = predicateBuilder;
|
||||
}
|
||||
|
||||
@@ -96,10 +75,6 @@ public enum QueryOperator {
|
||||
return negate;
|
||||
}
|
||||
|
||||
public Criterion buildPredicate(String val, String regexClause) {
|
||||
return criterionBuilder.apply(val, regexClause);
|
||||
}
|
||||
|
||||
public Predicate buildJpaPredicate(String val, String regexClause, JpaCriteriaBuilderKit<MetadataValue> jpaKit) {
|
||||
return predicateBuilder.apply(val, regexClause, jpaKit);
|
||||
}
|
||||
@@ -112,10 +87,6 @@ public enum QueryOperator {
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
public BiFunction<String, String, Criterion> getCriterionBuilder() {
|
||||
return criterionBuilder;
|
||||
}
|
||||
|
||||
private static Predicate regexPredicate(String val, String regexFunction,
|
||||
JpaCriteriaBuilderKit<MetadataValue> jpaKit) {
|
||||
// Source: https://stackoverflow.com/questions/24995881/use-regular-expressions-in-jpa-criteriabuilder
|
||||
|
@@ -19,12 +19,12 @@ import java.io.OutputStreamWriter;
|
||||
import java.io.PrintWriter;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.core.service.LicenseService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
import org.dspace.services.model.Request;
|
||||
import org.dspace.web.ContextUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Encapsulate the deposit license.
|
||||
@@ -32,7 +32,7 @@ import org.slf4j.LoggerFactory;
|
||||
* @author mhwood
|
||||
*/
|
||||
public class LicenseServiceImpl implements LicenseService {
|
||||
private final Logger log = LoggerFactory.getLogger(LicenseServiceImpl.class);
|
||||
private final Logger log = LogManager.getLogger();
|
||||
|
||||
/**
|
||||
* The default license
|
||||
@@ -53,7 +53,7 @@ public class LicenseServiceImpl implements LicenseService {
|
||||
out.print(newLicense);
|
||||
out.close();
|
||||
} catch (IOException e) {
|
||||
log.warn("license_write: " + e.getLocalizedMessage());
|
||||
log.warn("license_write: {}", e::getLocalizedMessage);
|
||||
}
|
||||
license = newLicense;
|
||||
}
|
||||
@@ -140,7 +140,7 @@ public class LicenseServiceImpl implements LicenseService {
|
||||
br.close();
|
||||
|
||||
} catch (IOException e) {
|
||||
log.error("Can't load license: " + licenseFile.toString(), e);
|
||||
log.error("Can't load license {}: ", licenseFile.toString(), e);
|
||||
|
||||
// FIXME: Maybe something more graceful here, but with the
|
||||
// configuration we can't do anything
|
||||
|
@@ -19,11 +19,11 @@ import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.core.service.NewsService;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
@@ -32,7 +32,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
* @author mhwood
|
||||
*/
|
||||
public class NewsServiceImpl implements NewsService {
|
||||
private final Logger log = LoggerFactory.getLogger(NewsServiceImpl.class);
|
||||
private final Logger log = LogManager.getLogger();
|
||||
|
||||
private List<String> acceptableFilenames;
|
||||
|
||||
@@ -94,7 +94,7 @@ public class NewsServiceImpl implements NewsService {
|
||||
ir.close();
|
||||
fir.close();
|
||||
} catch (IOException e) {
|
||||
log.warn("news_read: " + e.getLocalizedMessage());
|
||||
log.warn("news_read: {}", e::getLocalizedMessage);
|
||||
}
|
||||
|
||||
return text.toString();
|
||||
@@ -117,7 +117,7 @@ public class NewsServiceImpl implements NewsService {
|
||||
out.print(news);
|
||||
out.close();
|
||||
} catch (IOException e) {
|
||||
log.warn("news_write: " + e.getLocalizedMessage());
|
||||
log.warn("news_write: {}", e::getLocalizedMessage);
|
||||
}
|
||||
|
||||
return news;
|
||||
|
63
dspace-api/src/main/java/org/dspace/core/UUIDIterator.java
Normal file
63
dspace-api/src/main/java/org/dspace/core/UUIDIterator.java
Normal file
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
* The contents of this file are subject to the license and copyright
|
||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||
* tree and available online at
|
||||
*
|
||||
* http://www.dspace.org/license/
|
||||
*/
|
||||
package org.dspace.core;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.google.common.collect.AbstractIterator;
|
||||
import org.dspace.content.DSpaceObject;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
* Iterator implementation which allows to iterate over items and commit while
|
||||
* iterating. Using an iterator over previous retrieved UUIDs the iterator doesn't
|
||||
* get invalidated after a commit that would instead close the database ResultSet
|
||||
*
|
||||
* @author Andrea Bollini (andrea.bollini at 4science.com)
|
||||
* @param <T> class type
|
||||
*/
|
||||
public class UUIDIterator<T extends DSpaceObject> extends AbstractIterator<T> {
|
||||
private Class<T> clazz;
|
||||
|
||||
private Iterator<UUID> iterator;
|
||||
|
||||
@Autowired
|
||||
private AbstractHibernateDSODAO<T> dao;
|
||||
|
||||
private Context ctx;
|
||||
|
||||
public UUIDIterator(Context ctx, List<UUID> uuids, Class<T> clazz, AbstractHibernateDSODAO<T> dao)
|
||||
throws SQLException {
|
||||
this.ctx = ctx;
|
||||
this.clazz = clazz;
|
||||
this.dao = dao;
|
||||
this.iterator = uuids.iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected T computeNext() {
|
||||
try {
|
||||
if (iterator.hasNext()) {
|
||||
T item = dao.findByID(ctx, clazz, iterator.next());
|
||||
if (item != null) {
|
||||
return item;
|
||||
} else {
|
||||
return computeNext();
|
||||
}
|
||||
} else {
|
||||
return endOfData();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -19,6 +19,8 @@ import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.Bitstream;
|
||||
import org.dspace.content.Bundle;
|
||||
@@ -29,8 +31,6 @@ import org.dspace.content.service.BitstreamService;
|
||||
import org.dspace.curate.AbstractCurationTask;
|
||||
import org.dspace.curate.Curator;
|
||||
import org.dspace.curate.Suspendable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* ClamScan.java
|
||||
@@ -58,7 +58,7 @@ public class ClamScan extends AbstractCurationTask {
|
||||
protected final String SCAN_FAIL_MESSAGE = "Error encountered using virus service - check setup";
|
||||
protected final String NEW_ITEM_HANDLE = "in workflow";
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(ClamScan.class);
|
||||
private static final Logger log = LogManager.getLogger();
|
||||
|
||||
protected String host = null;
|
||||
protected int port = 0;
|
||||
@@ -100,7 +100,7 @@ public class ClamScan extends AbstractCurationTask {
|
||||
|
||||
try {
|
||||
Bundle bundle = itemService.getBundles(item, "ORIGINAL").get(0);
|
||||
results = new ArrayList<String>();
|
||||
results = new ArrayList<>();
|
||||
for (Bitstream bitstream : bundle.getBitstreams()) {
|
||||
InputStream inputstream = bitstreamService.retrieve(Curator.curationContext(), bitstream);
|
||||
logDebugMessage("Scanning " + bitstream.getName() + " . . . ");
|
||||
@@ -157,7 +157,7 @@ public class ClamScan extends AbstractCurationTask {
|
||||
try {
|
||||
socket.setSoTimeout(timeout);
|
||||
} catch (SocketException e) {
|
||||
log.error("Could not set socket timeout . . . " + timeout + "ms", e);
|
||||
log.error("Could not set socket timeout . . . {}ms", timeout, e);
|
||||
throw (new IOException(e));
|
||||
}
|
||||
try {
|
||||
@@ -293,8 +293,6 @@ public class ClamScan extends AbstractCurationTask {
|
||||
|
||||
|
||||
protected void logDebugMessage(String message) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug(message);
|
||||
}
|
||||
log.debug(message);
|
||||
}
|
||||
}
|
||||
|
@@ -10,11 +10,11 @@ package org.dspace.ctask.test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.content.DSpaceObject;
|
||||
import org.dspace.curate.AbstractCurationTask;
|
||||
import org.dspace.curate.Curator;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Curation task which simply reports its invocation without changing anything.
|
||||
@@ -24,13 +24,13 @@ import org.slf4j.LoggerFactory;
|
||||
*/
|
||||
public class WorkflowReportTest
|
||||
extends AbstractCurationTask {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(WorkflowReportTest.class);
|
||||
private static final Logger LOG = LogManager.getLogger();
|
||||
|
||||
@Override
|
||||
public int perform(DSpaceObject dso)
|
||||
throws IOException {
|
||||
LOG.info("Class {} as task {} received 'perform' for object {}",
|
||||
WorkflowReportTest.class.getSimpleName(), taskId, dso);
|
||||
WorkflowReportTest.class::getSimpleName, () -> taskId, () -> dso);
|
||||
curator.report(String.format(
|
||||
"Class %s as task %s received 'perform' for object %s%n",
|
||||
WorkflowReportTest.class.getSimpleName(), taskId, dso));
|
||||
|
@@ -10,12 +10,12 @@ package org.dspace.ctask.testing;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.content.DSpaceObject;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.curate.AbstractCurationTask;
|
||||
import org.dspace.curate.Curator;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Logs what it was asked to do, samples run parameters and task
|
||||
@@ -32,8 +32,7 @@ import org.slf4j.LoggerFactory;
|
||||
*/
|
||||
public class PropertyParameterTestingTask
|
||||
extends AbstractCurationTask {
|
||||
private static final Logger LOG
|
||||
= LoggerFactory.getLogger(PropertyParameterTestingTask.class);
|
||||
private static final Logger LOG = LogManager.getLogger();
|
||||
|
||||
@Override
|
||||
public void init(Curator curator, String taskId)
|
||||
|
@@ -10,8 +10,8 @@ package org.dspace.curate;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
/**
|
||||
* Write curation report records through the logging framework.
|
||||
@@ -22,7 +22,7 @@ import org.slf4j.LoggerFactory;
|
||||
*/
|
||||
public class LogReporter
|
||||
implements Reporter {
|
||||
private static final Logger LOG = LoggerFactory.getLogger("curation");
|
||||
private static final Logger LOG = LogManager.getLogger("curation");
|
||||
private final StringBuilder buffer = new StringBuilder();
|
||||
|
||||
@Override
|
||||
@@ -31,7 +31,7 @@ public class LogReporter
|
||||
for (int pos = 0; pos < cs.length(); pos++) {
|
||||
char c = cs.charAt(pos);
|
||||
if (c == '\n') {
|
||||
LOG.info(buffer.toString());
|
||||
LOG.info(buffer::toString);
|
||||
buffer.delete(0, buffer.length()); // Clear the buffer
|
||||
} else {
|
||||
buffer.append(c);
|
||||
@@ -56,7 +56,7 @@ public class LogReporter
|
||||
public void close()
|
||||
throws Exception {
|
||||
if (buffer.length() > 0) {
|
||||
LOG.info(buffer.toString());
|
||||
LOG.info(buffer::toString);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -16,10 +16,10 @@ import java.util.Arrays;
|
||||
|
||||
import org.apache.commons.codec.DecoderException;
|
||||
import org.apache.commons.codec.binary.Hex;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* For handling digested secrets (such as passwords).
|
||||
@@ -31,7 +31,7 @@ import org.slf4j.LoggerFactory;
|
||||
* @author mwood
|
||||
*/
|
||||
public class PasswordHash {
|
||||
private static final Logger log = LoggerFactory.getLogger(PasswordHash.class);
|
||||
private static final Logger log = LogManager.getLogger();
|
||||
private static final ConfigurationService config
|
||||
= DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||
private static final Charset UTF_8 = Charset.forName("UTF-8"); // Should always succeed: UTF-8 is required
|
||||
@@ -133,7 +133,7 @@ public class PasswordHash {
|
||||
try {
|
||||
hash = digest(salt, algorithm, password);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
log.error(e.getMessage());
|
||||
log.error(e::getMessage);
|
||||
hash = new byte[] {0};
|
||||
}
|
||||
}
|
||||
@@ -149,7 +149,7 @@ public class PasswordHash {
|
||||
try {
|
||||
candidate = digest(salt, algorithm, secret);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
log.error(e.getMessage());
|
||||
log.error(e::getMessage);
|
||||
return false;
|
||||
}
|
||||
return Arrays.equals(candidate, hash);
|
||||
@@ -225,7 +225,7 @@ public class PasswordHash {
|
||||
if (null == rng) {
|
||||
rng = new SecureRandom();
|
||||
log.info("Initialized a random number stream using {} provided by {}",
|
||||
rng.getAlgorithm(), rng.getProvider());
|
||||
rng::getAlgorithm, rng::getProvider);
|
||||
rngUses = 0;
|
||||
}
|
||||
|
||||
|
@@ -28,6 +28,8 @@ import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.content.MetadataFieldName;
|
||||
import org.dspace.content.dto.MetadataValueDTO;
|
||||
@@ -63,13 +65,11 @@ import org.orcid.jaxb.model.v3.release.record.WorkTitle;
|
||||
import org.orcid.jaxb.model.v3.release.record.summary.WorkGroup;
|
||||
import org.orcid.jaxb.model.v3.release.record.summary.WorkSummary;
|
||||
import org.orcid.jaxb.model.v3.release.record.summary.Works;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
* Implementation of {@link ExternalDataProvider} that search for all the works
|
||||
* of the profile with the given orcid id that hava a source other than DSpace.
|
||||
* of the profile with the given orcid id that have a source other than DSpace.
|
||||
* The id of the external data objects returned by the methods of this class is
|
||||
* the concatenation of the orcid id and the put code associated with the
|
||||
* publication, separated by :: (example 0000-0000-0123-4567::123456)
|
||||
@@ -79,7 +79,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
*/
|
||||
public class OrcidPublicationDataProvider extends AbstractExternalDataProvider {
|
||||
|
||||
private final static Logger LOGGER = LoggerFactory.getLogger(OrcidPublicationDataProvider.class);
|
||||
private final static Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
/**
|
||||
* Examples of valid ORCID IDs:
|
||||
@@ -335,7 +335,8 @@ public class OrcidPublicationDataProvider extends AbstractExternalDataProvider {
|
||||
try {
|
||||
addMetadataValuesFromCitation(externalDataObject, work.getWorkCitation());
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("An error occurs reading the following citation: " + work.getWorkCitation().getCitation(), e);
|
||||
LOGGER.error("An error occurs reading the following citation: {}",
|
||||
work.getWorkCitation().getCitation(), e);
|
||||
}
|
||||
|
||||
return externalDataObject;
|
||||
|
@@ -19,9 +19,9 @@ import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.google.GoogleAnalyticsEvent;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Implementation of {@link GoogleAnalyticsClient}.
|
||||
@@ -31,7 +31,7 @@ import org.slf4j.LoggerFactory;
|
||||
*/
|
||||
public class GoogleAnalyticsClientImpl implements GoogleAnalyticsClient {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(GoogleAnalyticsClientImpl.class);
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
private final String keyPrefix;
|
||||
|
||||
|
@@ -14,6 +14,8 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.DSpaceObject;
|
||||
import org.dspace.content.Item;
|
||||
@@ -30,8 +32,6 @@ import org.dspace.identifier.doi.DOIIdentifierException;
|
||||
import org.dspace.identifier.doi.DOIIdentifierNotApplicableException;
|
||||
import org.dspace.identifier.service.DOIService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
@@ -49,7 +49,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
* @author Kim Shepherd
|
||||
*/
|
||||
public class DOIIdentifierProvider extends FilteredIdentifierProvider {
|
||||
private static final Logger log = LoggerFactory.getLogger(DOIIdentifierProvider.class);
|
||||
private static final Logger log = LogManager.getLogger();
|
||||
|
||||
/**
|
||||
* A DOIConnector connects the DOIIdentifierProvider to the API of the DOI
|
||||
@@ -286,7 +286,7 @@ public class DOIIdentifierProvider extends FilteredIdentifierProvider {
|
||||
try {
|
||||
doiRow = loadOrCreateDOI(context, dso, doi, filter);
|
||||
} catch (SQLException ex) {
|
||||
log.error("Error in databse connection: " + ex.getMessage());
|
||||
log.error("Error in databse connection: {}", ex::getMessage);
|
||||
throw new RuntimeException("Error in database conncetion.", ex);
|
||||
}
|
||||
|
||||
@@ -492,7 +492,7 @@ public class DOIIdentifierProvider extends FilteredIdentifierProvider {
|
||||
|
||||
if (doiService.findDOIByDSpaceObject(context, dso) != null) {
|
||||
// We can skip the filter here since we know the DOI already exists for the item
|
||||
log.debug("updateMetadata: found DOIByDSpaceObject: " +
|
||||
log.debug("updateMetadata: found DOIByDSpaceObject: {}",
|
||||
doiService.findDOIByDSpaceObject(context, dso).getDoi());
|
||||
updateFilter = DSpaceServicesFactory.getInstance().getServiceManager().getServiceByName(
|
||||
"always_true_filter", TrueFilter.class);
|
||||
@@ -501,7 +501,7 @@ public class DOIIdentifierProvider extends FilteredIdentifierProvider {
|
||||
DOI doiRow = loadOrCreateDOI(context, dso, doi, updateFilter);
|
||||
|
||||
if (PENDING.equals(doiRow.getStatus()) || MINTED.equals(doiRow.getStatus())) {
|
||||
log.info("Not updating metadata for PENDING or MINTED doi: " + doi);
|
||||
log.info("Not updating metadata for PENDING or MINTED doi: {}", doi);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -611,8 +611,8 @@ public class DOIIdentifierProvider extends FilteredIdentifierProvider {
|
||||
try {
|
||||
doi = getDOIByObject(context, dso);
|
||||
} catch (SQLException e) {
|
||||
log.error("Error while attemping to retrieve information about a DOI for "
|
||||
+ contentServiceFactory.getDSpaceObjectService(dso).getTypeText(dso) + " with ID " + dso.getID() + ".");
|
||||
log.error("Error while attemping to retrieve information about a DOI for {} with ID {}.",
|
||||
contentServiceFactory.getDSpaceObjectService(dso).getTypeText(dso), dso.getID());
|
||||
throw new RuntimeException("Error while attempting to retrieve " +
|
||||
"information about a DOI for " + contentServiceFactory.getDSpaceObjectService(dso).getTypeText(dso) +
|
||||
" with ID " + dso.getID() + ".", e);
|
||||
@@ -624,7 +624,7 @@ public class DOIIdentifierProvider extends FilteredIdentifierProvider {
|
||||
|
||||
} catch (SQLException e) {
|
||||
log.error("Error while creating new DOI for Object of " +
|
||||
"ResourceType {} with id {}.", dso.getType(), dso.getID());
|
||||
"ResourceType {} with id {}.", dso::getType, dso::getID);
|
||||
throw new RuntimeException("Error while attempting to create a " +
|
||||
"new DOI for " + contentServiceFactory.getDSpaceObjectService(dso).getTypeText(dso) + " with ID " +
|
||||
dso.getID() + ".", e);
|
||||
@@ -709,9 +709,9 @@ public class DOIIdentifierProvider extends FilteredIdentifierProvider {
|
||||
doi = getDOIByObject(context, dso);
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
log.error("Error while attemping to retrieve information about a DOI for " +
|
||||
contentServiceFactory.getDSpaceObjectService(dso).getTypeText(dso) +
|
||||
" with ID " + dso.getID() + ".", ex);
|
||||
log.error("Error while attemping to retrieve information about a DOI for {} with ID {}.",
|
||||
contentServiceFactory.getDSpaceObjectService(dso).getTypeText(dso),
|
||||
dso.getID(), ex);
|
||||
throw new RuntimeException("Error while attempting to retrieve " +
|
||||
"information about a DOI for " + contentServiceFactory.getDSpaceObjectService(dso).getTypeText(dso) +
|
||||
" with ID " + dso.getID() + ".", ex);
|
||||
@@ -726,17 +726,17 @@ public class DOIIdentifierProvider extends FilteredIdentifierProvider {
|
||||
doi = getDOIOutOfObject(dso);
|
||||
}
|
||||
} catch (AuthorizeException ex) {
|
||||
log.error("Error while removing a DOI out of the metadata of an " +
|
||||
contentServiceFactory.getDSpaceObjectService(dso).getTypeText(dso) +
|
||||
" with ID " + dso.getID() + ".", ex);
|
||||
log.error("Error while removing a DOI out of the metadata of an {} with ID {}.",
|
||||
contentServiceFactory.getDSpaceObjectService(dso).getTypeText(dso),
|
||||
dso.getID(), ex);
|
||||
throw new RuntimeException("Error while removing a DOI out of the metadata of an " +
|
||||
contentServiceFactory.getDSpaceObjectService(dso).getTypeText(dso) +
|
||||
" with ID " + dso.getID() + ".", ex);
|
||||
|
||||
} catch (SQLException ex) {
|
||||
log.error("Error while removing a DOI out of the metadata of an " +
|
||||
contentServiceFactory.getDSpaceObjectService(dso).getTypeText(dso) +
|
||||
" with ID " + dso.getID() + ".", ex);
|
||||
log.error("Error while removing a DOI out of the metadata of an {} with ID {}.",
|
||||
contentServiceFactory.getDSpaceObjectService(dso).getTypeText(dso),
|
||||
dso.getID(), ex);
|
||||
throw new RuntimeException("Error while removing a DOI out of the " +
|
||||
"metadata of an " + contentServiceFactory.getDSpaceObjectService(dso).getTypeText(dso) +
|
||||
" with ID " + dso.getID() + ".", ex);
|
||||
@@ -779,8 +779,8 @@ public class DOIIdentifierProvider extends FilteredIdentifierProvider {
|
||||
throw new DOIIdentifierException("Not authorized to delete DOI.",
|
||||
ex, DOIIdentifierException.UNAUTHORIZED_METADATA_MANIPULATION);
|
||||
} catch (SQLException ex) {
|
||||
log.error("SQLException occurred while deleting a DOI out of an item: "
|
||||
+ ex.getMessage());
|
||||
log.error("SQLException occurred while deleting a DOI out of an item: {}",
|
||||
ex::getMessage);
|
||||
throw new RuntimeException("Error while deleting a DOI out of the " +
|
||||
"metadata of an Item " + dso.getID(), ex);
|
||||
}
|
||||
@@ -826,8 +826,9 @@ public class DOIIdentifierProvider extends FilteredIdentifierProvider {
|
||||
DOIIdentifierException.DOI_DOES_NOT_EXIST);
|
||||
}
|
||||
if (!TO_BE_DELETED.equals(doiRow.getStatus())) {
|
||||
log.error("This identifier: {} couldn't be deleted. Delete it first from metadata.",
|
||||
DOI.SCHEME + doiRow.getDoi());
|
||||
log.error("This identifier: " + DOI.SCHEME
|
||||
+ "{} couldn't be deleted. Delete it first from metadata.",
|
||||
doiRow::getDoi);
|
||||
throw new IllegalArgumentException("Couldn't delete this identifier:"
|
||||
+ DOI.SCHEME + doiRow.getDoi()
|
||||
+ ". Delete it first from metadata.");
|
||||
@@ -863,7 +864,7 @@ public class DOIIdentifierProvider extends FilteredIdentifierProvider {
|
||||
}
|
||||
|
||||
if (doiRow.getDSpaceObject() == null) {
|
||||
log.error("Found DOI " + doi + " in database, but no assigned Object could be found.");
|
||||
log.error("Found DOI {} in database, but no assigned Object could be found.", doi);
|
||||
throw new IllegalStateException("Found DOI " + doi +
|
||||
" in database, but no assigned Object could be found.");
|
||||
}
|
||||
@@ -890,8 +891,9 @@ public class DOIIdentifierProvider extends FilteredIdentifierProvider {
|
||||
}
|
||||
|
||||
if (doiRow.getDoi() == null) {
|
||||
log.error("A DOI with an empty doi column was found in the database. DSO-Type: " +
|
||||
contentServiceFactory.getDSpaceObjectService(dso).getTypeText(dso) + ", ID: " + dso.getID() + ".");
|
||||
log.error("A DOI with an empty doi column was found in the database. DSO-Type: {}, ID: {}.",
|
||||
contentServiceFactory.getDSpaceObjectService(dso).getTypeText(dso),
|
||||
dso.getID());
|
||||
throw new IllegalStateException("A DOI with an empty doi column was found in the database. DSO-Type: " +
|
||||
contentServiceFactory.getDSpaceObjectService(dso).getTypeText(dso) + ", ID: " + dso.getID() + ".");
|
||||
}
|
||||
@@ -1134,13 +1136,13 @@ public class DOIIdentifierProvider extends FilteredIdentifierProvider {
|
||||
if (contentServiceFactory.getDSpaceObjectService(dso).getTypeText(dso).equals("ITEM")) {
|
||||
try {
|
||||
boolean result = filter.getResult(context, (Item) dso);
|
||||
log.debug("Result of filter for " + dso.getHandle() + " is " + result);
|
||||
log.debug("Result of filter for {} is {}", dso.getHandle(), result);
|
||||
if (!result) {
|
||||
throw new DOIIdentifierNotApplicableException("Item " + dso.getHandle() +
|
||||
" was evaluated as 'false' by the item filter, not minting");
|
||||
}
|
||||
} catch (LogicalStatementException e) {
|
||||
log.error("Error evaluating item with logical filter: " + e.getLocalizedMessage());
|
||||
log.error("Error evaluating item with logical filter: {}", e::getLocalizedMessage);
|
||||
throw new DOIIdentifierNotApplicableException(e);
|
||||
}
|
||||
} else {
|
||||
|
@@ -13,6 +13,8 @@ import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.DSpaceObject;
|
||||
import org.dspace.content.crosswalk.CrosswalkException;
|
||||
@@ -25,8 +27,6 @@ import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.utils.DSpace;
|
||||
import org.jdom2.Element;
|
||||
import org.jdom2.output.XMLOutputter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Provide XML based metadata crosswalk for EZID Identifier provider module.
|
||||
@@ -36,9 +36,9 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
public class DataCiteXMLCreator {
|
||||
/**
|
||||
* log4j category
|
||||
* logging category
|
||||
*/
|
||||
private static final Logger LOG = LoggerFactory.getLogger(DataCiteXMLCreator.class);
|
||||
private static final Logger LOG = LogManager.getLogger();
|
||||
|
||||
/**
|
||||
* Name of crosswalk to convert metadata into DataCite Metadata Scheme.
|
||||
@@ -70,9 +70,8 @@ public class DataCiteXMLCreator {
|
||||
this.prepareXwalk();
|
||||
|
||||
if (!this.xwalk.canDisseminate(dso)) {
|
||||
LOG.error("Crosswalk " + this.CROSSWALK_NAME
|
||||
+ " cannot disseminate DSO with type " + dso.getType()
|
||||
+ " and ID " + dso.getID() + ".");
|
||||
LOG.error("Crosswalk {} cannot disseminate DSO with type {} and ID {}.",
|
||||
this.CROSSWALK_NAME, dso.getType(), dso.getID());
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -98,8 +97,8 @@ public class DataCiteXMLCreator {
|
||||
try {
|
||||
root = xwalk.disseminateElement(context, dso, parameters);
|
||||
} catch (CrosswalkException | IOException | SQLException | AuthorizeException e) {
|
||||
LOG.error("Exception while crosswalking DSO with type "
|
||||
+ dso.getType() + " and ID " + dso.getID() + ".", e);
|
||||
LOG.error("Exception while crosswalking DSO with type {} and ID {}.",
|
||||
dso.getType(), dso.getID(), e);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@@ -20,6 +20,8 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.DSpaceObject;
|
||||
import org.dspace.content.Item;
|
||||
@@ -32,8 +34,6 @@ import org.dspace.identifier.ezid.EZIDRequest;
|
||||
import org.dspace.identifier.ezid.EZIDRequestFactory;
|
||||
import org.dspace.identifier.ezid.EZIDResponse;
|
||||
import org.dspace.identifier.ezid.Transform;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
@@ -83,7 +83,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
*/
|
||||
public class EZIDIdentifierProvider
|
||||
extends IdentifierProvider {
|
||||
private static final Logger log = LoggerFactory.getLogger(EZIDIdentifierProvider.class);
|
||||
private static final Logger log = LogManager.getLogger();
|
||||
|
||||
// Configuration property names
|
||||
static final String CFG_SHOULDER = "identifier.doi.ezid.shoulder";
|
||||
@@ -184,7 +184,8 @@ public class EZIDIdentifierProvider
|
||||
loadUser(), loadPassword());
|
||||
response = request.create(identifier, crosswalkMetadata(context, object));
|
||||
} catch (IdentifierException | IOException | URISyntaxException e) {
|
||||
log.error("Identifier '{}' not registered: {}", identifier, e.getMessage());
|
||||
log.error("Identifier '{}' not registered: {}",
|
||||
() -> identifier, e::getMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -201,7 +202,7 @@ public class EZIDIdentifierProvider
|
||||
}
|
||||
} else {
|
||||
log.error("Identifier '{}' not registered -- EZID returned: {}",
|
||||
identifier, response.getEZIDStatusValue());
|
||||
() -> identifier, response::getEZIDStatusValue);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -218,7 +219,8 @@ public class EZIDIdentifierProvider
|
||||
metadata.put("_status", "reserved");
|
||||
response = request.create(identifier, metadata);
|
||||
} catch (IOException | URISyntaxException e) {
|
||||
log.error("Identifier '{}' not registered: {}", identifier, e.getMessage());
|
||||
log.error("Identifier '{}' not registered: {}",
|
||||
() -> identifier, e::getMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -233,7 +235,7 @@ public class EZIDIdentifierProvider
|
||||
}
|
||||
} else {
|
||||
log.error("Identifier '{}' not registered -- EZID returned: {}",
|
||||
identifier, response.getEZIDStatusValue());
|
||||
() -> identifier, response::getEZIDStatusValue);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -247,7 +249,7 @@ public class EZIDIdentifierProvider
|
||||
try {
|
||||
request = requestFactory.getInstance(loadAuthority(), loadUser(), loadPassword());
|
||||
} catch (URISyntaxException ex) {
|
||||
log.error(ex.getMessage());
|
||||
log.error(ex::getMessage);
|
||||
throw new IdentifierException("DOI request not sent: " + ex.getMessage());
|
||||
}
|
||||
|
||||
@@ -256,18 +258,16 @@ public class EZIDIdentifierProvider
|
||||
try {
|
||||
response = request.mint(crosswalkMetadata(context, dso));
|
||||
} catch (IOException | URISyntaxException ex) {
|
||||
log.error("Failed to send EZID request: {}", ex.getMessage());
|
||||
log.error("Failed to send EZID request: {}", ex::getMessage);
|
||||
throw new IdentifierException("DOI request not sent: " + ex.getMessage());
|
||||
}
|
||||
|
||||
// Good response?
|
||||
if (HttpURLConnection.HTTP_CREATED != response.getHttpStatusCode()) {
|
||||
log.error("EZID server responded: {} {}: {}",
|
||||
new String[] {
|
||||
String.valueOf(response.getHttpStatusCode()),
|
||||
response.getHttpReasonPhrase(),
|
||||
response.getEZIDStatusValue()
|
||||
});
|
||||
response::getHttpStatusCode,
|
||||
response::getHttpReasonPhrase,
|
||||
response::getEZIDStatusValue);
|
||||
throw new IdentifierException("DOI not created: "
|
||||
+ response.getHttpReasonPhrase()
|
||||
+ ": "
|
||||
@@ -285,7 +285,7 @@ public class EZIDIdentifierProvider
|
||||
log.info("Created {}", doi);
|
||||
return doi;
|
||||
} else {
|
||||
log.error("EZID responded: {}", response.getEZIDStatusValue());
|
||||
log.error("EZID responded: {}", response::getEZIDStatusValue);
|
||||
throw new IdentifierException("No DOI returned");
|
||||
}
|
||||
}
|
||||
@@ -302,7 +302,7 @@ public class EZIDIdentifierProvider
|
||||
MD_SCHEMA, DOI_ELEMENT, DOI_QUALIFIER,
|
||||
idToDOI(identifier));
|
||||
} catch (IdentifierException | SQLException | AuthorizeException | IOException ex) {
|
||||
log.error(ex.getMessage());
|
||||
log.error(ex::getMessage);
|
||||
throw new IdentifierNotResolvableException(ex);
|
||||
}
|
||||
if (!found.hasNext()) {
|
||||
@@ -360,24 +360,24 @@ public class EZIDIdentifierProvider
|
||||
loadUser(), loadPassword());
|
||||
response = request.delete(DOIToId(id.getValue()));
|
||||
} catch (URISyntaxException e) {
|
||||
log.error("Bad URI in metadata value: {}", e.getMessage());
|
||||
log.error("Bad URI in metadata value: {}", e::getMessage);
|
||||
remainder.add(id.getValue());
|
||||
skipped++;
|
||||
continue;
|
||||
} catch (IOException e) {
|
||||
log.error("Failed request to EZID: {}", e.getMessage());
|
||||
log.error("Failed request to EZID: {}", e::getMessage);
|
||||
remainder.add(id.getValue());
|
||||
skipped++;
|
||||
continue;
|
||||
}
|
||||
if (!response.isSuccess()) {
|
||||
log.error("Unable to delete {} from DataCite: {}", id.getValue(),
|
||||
response.getEZIDStatusValue());
|
||||
log.error("Unable to delete {} from DataCite: {}", id::getValue,
|
||||
response::getEZIDStatusValue);
|
||||
remainder.add(id.getValue());
|
||||
skipped++;
|
||||
continue;
|
||||
}
|
||||
log.info("Deleted {}", id.getValue());
|
||||
log.info("Deleted {}", id::getValue);
|
||||
}
|
||||
|
||||
// delete from item
|
||||
@@ -386,7 +386,7 @@ public class EZIDIdentifierProvider
|
||||
dsoService.addMetadata(context, dso, MD_SCHEMA, DOI_ELEMENT, DOI_QUALIFIER, null, remainder);
|
||||
dsoService.update(context, dso);
|
||||
} catch (SQLException | AuthorizeException e) {
|
||||
log.error("Failed to re-add identifiers: {}", e.getMessage());
|
||||
log.error("Failed to re-add identifiers: {}", e::getMessage);
|
||||
}
|
||||
|
||||
if (skipped > 0) {
|
||||
@@ -415,25 +415,25 @@ public class EZIDIdentifierProvider
|
||||
loadUser(), loadPassword());
|
||||
response = request.delete(DOIToId(id.getValue()));
|
||||
} catch (URISyntaxException e) {
|
||||
log.error("Bad URI in metadata value {}: {}", id.getValue(), e.getMessage());
|
||||
log.error("Bad URI in metadata value {}: {}", id::getValue, e::getMessage);
|
||||
remainder.add(id.getValue());
|
||||
skipped++;
|
||||
continue;
|
||||
} catch (IOException e) {
|
||||
log.error("Failed request to EZID: {}", e.getMessage());
|
||||
log.error("Failed request to EZID: {}", e::getMessage);
|
||||
remainder.add(id.getValue());
|
||||
skipped++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!response.isSuccess()) {
|
||||
log.error("Unable to delete {} from DataCite: {}", id.getValue(),
|
||||
response.getEZIDStatusValue());
|
||||
log.error("Unable to delete {} from DataCite: {}", id::getValue,
|
||||
response::getEZIDStatusValue);
|
||||
remainder.add(id.getValue());
|
||||
skipped++;
|
||||
continue;
|
||||
}
|
||||
log.info("Deleted {}", id.getValue());
|
||||
log.info("Deleted {}", id::getValue);
|
||||
}
|
||||
|
||||
// delete from item
|
||||
@@ -442,7 +442,7 @@ public class EZIDIdentifierProvider
|
||||
dsoService.addMetadata(context, dso, MD_SCHEMA, DOI_ELEMENT, DOI_QUALIFIER, null, remainder);
|
||||
dsoService.update(context, dso);
|
||||
} catch (SQLException | AuthorizeException e) {
|
||||
log.error("Failed to re-add identifiers: {}", e.getMessage());
|
||||
log.error("Failed to re-add identifiers: {}", e::getMessage);
|
||||
}
|
||||
|
||||
if (skipped > 0) {
|
||||
@@ -544,12 +544,10 @@ public class EZIDIdentifierProvider
|
||||
mappedValue = xfrm.transform(value.getValue());
|
||||
} catch (Exception ex) {
|
||||
log.error("Unable to transform '{}' from {} to {}: {}",
|
||||
new String[] {
|
||||
value.getValue(),
|
||||
value.toString(),
|
||||
key,
|
||||
ex.getMessage()
|
||||
});
|
||||
value::getValue,
|
||||
value::toString,
|
||||
() -> key,
|
||||
ex::getMessage);
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
|
@@ -33,6 +33,8 @@ import org.apache.http.impl.client.BasicCredentialsProvider;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClientBuilder;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.DSpaceObject;
|
||||
import org.dspace.content.crosswalk.CrosswalkException;
|
||||
@@ -52,8 +54,6 @@ import org.jdom2.filter.ElementFilter;
|
||||
import org.jdom2.input.SAXBuilder;
|
||||
import org.jdom2.output.Format;
|
||||
import org.jdom2.output.XMLOutputter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
@@ -62,7 +62,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
public class DataCiteConnector
|
||||
implements DOIConnector {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(DataCiteConnector.class);
|
||||
private static final Logger log = LogManager.getLogger();
|
||||
|
||||
// Configuration property names
|
||||
static final String CFG_USER = "identifier.doi.user";
|
||||
@@ -356,10 +356,8 @@ public class DataCiteConnector
|
||||
.getDSpaceObjectService(dso);
|
||||
|
||||
if (!this.xwalk.canDisseminate(dso)) {
|
||||
log.error("Crosswalk " + this.CROSSWALK_NAME
|
||||
+ " cannot disseminate DSO with type " + dso.getType()
|
||||
+ " and ID " + dso.getID() + ". Giving up reserving the DOI "
|
||||
+ doi + ".");
|
||||
log.error("Crosswalk {} cannot disseminate DSO with type {} and ID {}. Giving up reserving the DOI {}.",
|
||||
this.CROSSWALK_NAME, dso.getType(), dso.getID(), doi);
|
||||
throw new DOIIdentifierException("Cannot disseminate "
|
||||
+ dSpaceObjectService.getTypeText(dso) + "/" + dso.getID()
|
||||
+ " using crosswalk " + this.CROSSWALK_NAME + ".",
|
||||
@@ -390,18 +388,18 @@ public class DataCiteConnector
|
||||
try {
|
||||
root = xwalk.disseminateElement(context, dso, parameters);
|
||||
} catch (AuthorizeException ae) {
|
||||
log.error("Caught an AuthorizeException while disseminating DSO "
|
||||
+ "with type " + dso.getType() + " and ID " + dso.getID()
|
||||
+ ". Giving up to reserve DOI " + doi + ".", ae);
|
||||
log.error("Caught an AuthorizeException while disseminating DSO"
|
||||
+ " with type {} and ID {}. Giving up to reserve DOI {}.",
|
||||
dso.getType(), dso.getID(), doi, ae);
|
||||
throw new DOIIdentifierException("AuthorizeException occured while "
|
||||
+ "converting " + dSpaceObjectService.getTypeText(dso) + "/" + dso
|
||||
.getID()
|
||||
+ " using crosswalk " + this.CROSSWALK_NAME + ".", ae,
|
||||
DOIIdentifierException.CONVERSION_ERROR);
|
||||
} catch (CrosswalkException ce) {
|
||||
log.error("Caught an CrosswalkException while reserving a DOI ("
|
||||
+ doi + ") for DSO with type " + dso.getType() + " and ID "
|
||||
+ dso.getID() + ". Won't reserve the doi.", ce);
|
||||
log.error("Caught a CrosswalkException while reserving a DOI ({})"
|
||||
+ " for DSO with type {} and ID {}. Won't reserve the doi.",
|
||||
doi, dso.getType(), dso.getID(), ce);
|
||||
throw new DOIIdentifierException("CrosswalkException occured while "
|
||||
+ "converting " + dSpaceObjectService.getTypeText(dso) + "/" + dso
|
||||
.getID()
|
||||
@@ -421,9 +419,8 @@ public class DataCiteConnector
|
||||
} else if (!metadataDOI.equals(doi.substring(DOI.SCHEME.length()))) {
|
||||
log.error("While reserving a DOI, the "
|
||||
+ "crosswalk to generate the metadata used another DOI than "
|
||||
+ "the DOI we're reserving. Cannot reserve DOI " + doi
|
||||
+ " for " + dSpaceObjectService.getTypeText(dso) + " "
|
||||
+ dso.getID() + ".");
|
||||
+ "the DOI we're reserving. Cannot reserve DOI {} for {} {}.",
|
||||
doi, dSpaceObjectService.getTypeText(dso), dso.getID());
|
||||
throw new IllegalStateException("An internal error occured while "
|
||||
+ "generating the metadata. Unable to reserve doi, see logs "
|
||||
+ "for further information.");
|
||||
@@ -440,12 +437,12 @@ public class DataCiteConnector
|
||||
// 400 -> invalid XML
|
||||
case (400): {
|
||||
log.warn("DataCite was unable to understand the XML we send.");
|
||||
log.warn("DataCite Metadata API returned a http status code "
|
||||
+ "400: " + resp.getContent());
|
||||
log.warn("DataCite Metadata API returned a http status code"
|
||||
+ " 400: {}", resp::getContent);
|
||||
Format format = Format.getCompactFormat();
|
||||
format.setEncoding("UTF-8");
|
||||
XMLOutputter xout = new XMLOutputter(format);
|
||||
log.info("We send the following XML:\n" + xout.outputString(root));
|
||||
log.info("We send the following XML:\n{}", xout.outputString(root));
|
||||
throw new DOIIdentifierException("Unable to reserve DOI " + doi
|
||||
+ ". Please inform your administrator or take a look "
|
||||
+ " into the log files.", DOIIdentifierException.BAD_REQUEST);
|
||||
@@ -479,8 +476,8 @@ public class DataCiteConnector
|
||||
resp = this.sendDOIPostRequest(doi,
|
||||
handleService.resolveToURL(context, dso.getHandle()));
|
||||
} catch (SQLException e) {
|
||||
log.error("Caught SQL-Exception while resolving handle to URL: "
|
||||
+ e.getMessage());
|
||||
log.error("Caught SQL-Exception while resolving handle to URL: {}",
|
||||
e::getMessage);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
@@ -492,7 +489,7 @@ public class DataCiteConnector
|
||||
// 400 -> wrong domain, wrong prefix, wrong request body
|
||||
case (400): {
|
||||
log.warn("We send an irregular request to DataCite. While "
|
||||
+ "registering a DOI they told us: " + resp.getContent());
|
||||
+ "registering a DOI they told us: {}", resp::getContent);
|
||||
throw new DOIIdentifierException("Currently we cannot register "
|
||||
+ "DOIs. Please inform the administrator or take a look "
|
||||
+ " in the DSpace log file.",
|
||||
@@ -501,8 +498,8 @@ public class DataCiteConnector
|
||||
// 412 Precondition failed: DOI was not reserved before registration!
|
||||
case (412): {
|
||||
log.error("We tried to register a DOI {} that has not been reserved "
|
||||
+ "before! The registration agency told us: {}.", doi,
|
||||
resp.getContent());
|
||||
+ "before! The registration agency told us: {}.",
|
||||
() -> doi, resp::getContent);
|
||||
throw new DOIIdentifierException("There was an error in handling "
|
||||
+ "of DOIs. The DOI we wanted to register had not been "
|
||||
+ "reserved in advance. Please contact the administrator "
|
||||
@@ -511,7 +508,7 @@ public class DataCiteConnector
|
||||
}
|
||||
// Catch all other http status code in case we forgot one.
|
||||
default: {
|
||||
log.warn("While registration of DOI {}, we got a http status code "
|
||||
log.warn("While registering DOI {}, we got a http status code "
|
||||
+ "{} and the message \"{}\".",
|
||||
doi, Integer.toString(resp.statusCode), resp.getContent());
|
||||
throw new DOIIdentifierException("Unable to parse an answer from "
|
||||
@@ -564,8 +561,8 @@ public class DataCiteConnector
|
||||
try {
|
||||
EntityUtils.consume(reqEntity);
|
||||
} catch (IOException ioe) {
|
||||
log.info("Caught an IOException while releasing a HTTPEntity:"
|
||||
+ ioe.getMessage());
|
||||
log.info("Caught an IOException while releasing a HTTPEntity: {}",
|
||||
ioe::getMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -668,8 +665,8 @@ public class DataCiteConnector
|
||||
try {
|
||||
EntityUtils.consume(reqEntity);
|
||||
} catch (IOException ioe) {
|
||||
log.info("Caught an IOException while releasing an HTTPEntity:"
|
||||
+ ioe.getMessage());
|
||||
log.info("Caught an IOException while releasing an HTTPEntity: {}",
|
||||
ioe::getMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -768,7 +765,7 @@ public class DataCiteConnector
|
||||
// 500 is documented and signals an internal server error
|
||||
case (500): {
|
||||
log.warn("Caught an http status code 500 while managing DOI "
|
||||
+ "{}. Message was: " + content);
|
||||
+ "{}. Message was: {}", doi, content);
|
||||
throw new DOIIdentifierException("DataCite API has an internal error. "
|
||||
+ "It is temporarily impossible to manage DOIs. "
|
||||
+ "Further information can be found in DSpace log file.",
|
||||
@@ -781,7 +778,7 @@ public class DataCiteConnector
|
||||
|
||||
return new DataCiteResponse(statusCode, content);
|
||||
} catch (IOException e) {
|
||||
log.warn("Caught an IOException: " + e.getMessage());
|
||||
log.warn("Caught an IOException: {}", e::getMessage);
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
try {
|
||||
@@ -790,7 +787,7 @@ public class DataCiteConnector
|
||||
EntityUtils.consume(entity);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.warn("Can't release HTTP-Entity: " + e.getMessage());
|
||||
log.warn("Can't release HTTP-Entity: {}", e::getMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -27,10 +27,10 @@ import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.impl.client.BasicCredentialsProvider;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClientBuilder;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.identifier.DOI;
|
||||
import org.dspace.identifier.IdentifierException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* A request to EZID concerning a given (or expected) identifier.
|
||||
@@ -38,7 +38,7 @@ import org.slf4j.LoggerFactory;
|
||||
* @author Mark H. Wood
|
||||
*/
|
||||
public class EZIDRequest {
|
||||
private static final Logger log = LoggerFactory.getLogger(EZIDRequest.class);
|
||||
private static final Logger log = LogManager.getLogger();
|
||||
|
||||
private static final String ID_PATH = "/id/" + DOI.SCHEME;
|
||||
|
||||
@@ -149,7 +149,7 @@ public class EZIDRequest {
|
||||
// GET path
|
||||
HttpGet request;
|
||||
URI uri = new URI(scheme, host, path + ID_PATH + authority + name, null);
|
||||
log.debug("EZID lookup {}", uri.toASCIIString());
|
||||
log.debug("EZID lookup {}", uri::toASCIIString);
|
||||
request = new HttpGet(uri);
|
||||
HttpResponse response = client.execute(request, httpContext);
|
||||
return new EZIDResponse(response);
|
||||
@@ -172,7 +172,7 @@ public class EZIDRequest {
|
||||
// PUT path [+metadata]
|
||||
HttpPut request;
|
||||
URI uri = new URI(scheme, host, path + ID_PATH + authority + '/' + name, null);
|
||||
log.debug("EZID create {}", uri.toASCIIString());
|
||||
log.debug("EZID create {}", uri::toASCIIString);
|
||||
request = new HttpPut(uri);
|
||||
if (null != metadata) {
|
||||
request.setEntity(new StringEntity(formatMetadata(metadata), UTF_8));
|
||||
@@ -196,7 +196,7 @@ public class EZIDRequest {
|
||||
// POST path [+metadata]
|
||||
HttpPost request;
|
||||
URI uri = new URI(scheme, host, path + SHOULDER_PATH + authority, null);
|
||||
log.debug("EZID mint {}", uri.toASCIIString());
|
||||
log.debug("EZID mint {}", uri::toASCIIString);
|
||||
request = new HttpPost(uri);
|
||||
if (null != metadata) {
|
||||
request.setEntity(new StringEntity(formatMetadata(metadata), UTF_8));
|
||||
@@ -225,7 +225,7 @@ public class EZIDRequest {
|
||||
// POST path +metadata
|
||||
HttpPost request;
|
||||
URI uri = new URI(scheme, host, path + ID_PATH + authority + name, null);
|
||||
log.debug("EZID modify {}", uri.toASCIIString());
|
||||
log.debug("EZID modify {}", uri::toASCIIString);
|
||||
request = new HttpPost(uri);
|
||||
request.setEntity(new StringEntity(formatMetadata(metadata), UTF_8));
|
||||
HttpResponse response = client.execute(request, httpContext);
|
||||
@@ -246,7 +246,7 @@ public class EZIDRequest {
|
||||
// DELETE path
|
||||
HttpDelete request;
|
||||
URI uri = new URI(scheme, host, path + ID_PATH + authority + name, null);
|
||||
log.debug("EZID delete {}", uri.toASCIIString());
|
||||
log.debug("EZID delete {}", uri::toASCIIString);
|
||||
request = new HttpDelete(uri);
|
||||
HttpResponse response = client.execute(request, httpContext);
|
||||
return new EZIDResponse(response);
|
||||
|
@@ -19,15 +19,15 @@ import org.apache.http.HttpEntity;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.ParseException;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.identifier.IdentifierException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Decoded response data evoked by a request made to EZID.
|
||||
*/
|
||||
public class EZIDResponse {
|
||||
private static final Logger log = LoggerFactory.getLogger(EZIDResponse.class);
|
||||
private static final Logger log = LogManager.getLogger();
|
||||
|
||||
private static final String UTF_8 = "UTF-8";
|
||||
|
||||
@@ -35,7 +35,7 @@ public class EZIDResponse {
|
||||
|
||||
private final String statusValue;
|
||||
|
||||
private final Map<String, String> attributes = new HashMap<String, String>();
|
||||
private final Map<String, String> attributes = new HashMap<>();
|
||||
|
||||
private final HttpResponse response;
|
||||
|
||||
@@ -49,12 +49,8 @@ public class EZIDResponse {
|
||||
String body;
|
||||
try {
|
||||
body = EntityUtils.toString(responseBody, UTF_8);
|
||||
} catch (IOException ex) {
|
||||
log.error(ex.getMessage());
|
||||
throw new IdentifierException("EZID response not understood: "
|
||||
+ ex.getMessage());
|
||||
} catch (ParseException ex) {
|
||||
log.error(ex.getMessage());
|
||||
} catch (IOException | ParseException ex) {
|
||||
log.error(ex::getMessage);
|
||||
throw new IdentifierException("EZID response not understood: "
|
||||
+ ex.getMessage());
|
||||
}
|
||||
@@ -124,7 +120,7 @@ public class EZIDResponse {
|
||||
* @return all keys found in the response.
|
||||
*/
|
||||
public List<String> getKeys() {
|
||||
List<String> keys = new ArrayList<String>();
|
||||
List<String> keys = new ArrayList<>();
|
||||
for (String key : attributes.keySet()) {
|
||||
keys.add(key);
|
||||
}
|
||||
|
@@ -22,6 +22,8 @@ import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.content.DSpaceObject;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.content.MetadataFieldName;
|
||||
@@ -45,8 +47,6 @@ import org.dspace.orcid.service.OrcidTokenService;
|
||||
import org.dspace.profile.OrcidProfileSyncPreference;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* The consumer to fill the ORCID queue. The addition to the queue is made for
|
||||
@@ -56,7 +56,7 @@ import org.slf4j.LoggerFactory;
|
||||
* be synchronized (based on the preferences set by the user)</li>
|
||||
* <li>are publications/fundings related to profile items linked to orcid (based
|
||||
* on the preferences set by the user)</li>
|
||||
*
|
||||
*
|
||||
* </ul>
|
||||
*
|
||||
* @author Luca Giamminonni (luca.giamminonni at 4science.it)
|
||||
@@ -64,7 +64,7 @@ import org.slf4j.LoggerFactory;
|
||||
*/
|
||||
public class OrcidQueueConsumer implements Consumer {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(OrcidQueueConsumer.class);
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
private OrcidQueueService orcidQueueService;
|
||||
|
||||
@@ -82,7 +82,7 @@ public class OrcidQueueConsumer implements Consumer {
|
||||
|
||||
private RelationshipService relationshipService;
|
||||
|
||||
private List<UUID> alreadyConsumedItems = new ArrayList<>();
|
||||
private final List<UUID> alreadyConsumedItems = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void initialize() throws Exception {
|
||||
@@ -263,7 +263,7 @@ public class OrcidQueueConsumer implements Consumer {
|
||||
|
||||
if (StringUtils.isBlank(putCode)) {
|
||||
LOGGER.warn("The orcid history record with id {} should have a not blank put code",
|
||||
historyRecord.getID());
|
||||
historyRecord::getID);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@@ -18,6 +18,8 @@ import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.content.MetadataValue;
|
||||
import org.dspace.content.Relationship;
|
||||
@@ -44,8 +46,6 @@ import org.orcid.jaxb.model.v3.release.record.Funding;
|
||||
import org.orcid.jaxb.model.v3.release.record.FundingContributor;
|
||||
import org.orcid.jaxb.model.v3.release.record.FundingContributors;
|
||||
import org.orcid.jaxb.model.v3.release.record.FundingTitle;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
@@ -57,7 +57,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
*/
|
||||
public class OrcidFundingFactory implements OrcidEntityFactory {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(OrcidFundingFactory.class);
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
@Autowired
|
||||
private ItemService itemService;
|
||||
|
@@ -19,6 +19,8 @@ import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.commons.lang3.EnumUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.content.MetadataValue;
|
||||
import org.dspace.content.service.ItemService;
|
||||
@@ -42,8 +44,6 @@ import org.orcid.jaxb.model.v3.release.record.ExternalIDs;
|
||||
import org.orcid.jaxb.model.v3.release.record.Work;
|
||||
import org.orcid.jaxb.model.v3.release.record.WorkContributors;
|
||||
import org.orcid.jaxb.model.v3.release.record.WorkTitle;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
@@ -55,7 +55,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
*/
|
||||
public class OrcidWorkFactory implements OrcidEntityFactory {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(OrcidWorkFactory.class);
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
@Autowired
|
||||
private ItemService itemService;
|
||||
@@ -164,7 +164,7 @@ public class OrcidWorkFactory implements OrcidEntityFactory {
|
||||
*/
|
||||
private List<ExternalID> getWorkSelfExternalIds(Context context, Item item) {
|
||||
|
||||
List<ExternalID> selfExternalIds = new ArrayList<ExternalID>();
|
||||
List<ExternalID> selfExternalIds = new ArrayList<>();
|
||||
|
||||
Map<String, String> externalIdentifierFields = fieldMapping.getExternalIdentifierFields();
|
||||
|
||||
|
@@ -20,6 +20,8 @@ import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.commons.cli.ParseException;
|
||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.eperson.EPerson;
|
||||
@@ -36,8 +38,6 @@ import org.dspace.scripts.DSpaceRunnable;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
import org.dspace.utils.DSpace;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Script that perform the bulk synchronization with ORCID registry of all the
|
||||
@@ -48,7 +48,7 @@ import org.slf4j.LoggerFactory;
|
||||
*/
|
||||
public class OrcidBulkPush extends DSpaceRunnable<OrcidBulkPushScriptConfiguration<OrcidBulkPush>> {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(OrcidBulkPush.class);
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
private OrcidQueueService orcidQueueService;
|
||||
|
||||
@@ -63,7 +63,7 @@ public class OrcidBulkPush extends DSpaceRunnable<OrcidBulkPushScriptConfigurati
|
||||
/**
|
||||
* Cache that stores the synchronization mode set for a specific profile item.
|
||||
*/
|
||||
private Map<Item, OrcidSynchronizationMode> synchronizationModeByProfileItem = new HashMap<>();
|
||||
private final Map<Item, OrcidSynchronizationMode> synchronizationModeByProfileItem = new HashMap<>();
|
||||
|
||||
private boolean ignoreMaxAttempts = false;
|
||||
|
||||
|
@@ -24,6 +24,8 @@ import java.util.Optional;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.http.HttpStatus;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.content.MetadataFieldName;
|
||||
import org.dspace.content.MetadataValue;
|
||||
@@ -48,8 +50,6 @@ import org.dspace.orcid.service.OrcidHistoryService;
|
||||
import org.dspace.orcid.service.OrcidProfileSectionFactoryService;
|
||||
import org.dspace.orcid.service.OrcidTokenService;
|
||||
import org.orcid.jaxb.model.v3.release.record.Activity;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
@@ -61,7 +61,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
*/
|
||||
public class OrcidHistoryServiceImpl implements OrcidHistoryService {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(OrcidHistoryServiceImpl.class);
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
@Autowired
|
||||
private OrcidHistoryDAO orcidHistoryDAO;
|
||||
@@ -134,7 +134,7 @@ public class OrcidHistoryServiceImpl implements OrcidHistoryService {
|
||||
|
||||
@Override
|
||||
public Map<Item, String> findLastPutCodes(Context context, Item entity) throws SQLException {
|
||||
Map<Item, String> profileItemAndPutCodeMap = new HashMap<Item, String>();
|
||||
Map<Item, String> profileItemAndPutCodeMap = new HashMap<>();
|
||||
|
||||
List<OrcidHistory> orcidHistoryRecords = findByEntity(context, entity);
|
||||
for (OrcidHistory orcidHistoryRecord : orcidHistoryRecords) {
|
||||
@@ -187,10 +187,12 @@ public class OrcidHistoryServiceImpl implements OrcidHistoryService {
|
||||
} catch (OrcidValidationException ex) {
|
||||
throw ex;
|
||||
} catch (OrcidClientException ex) {
|
||||
LOGGER.error("An error occurs during the orcid synchronization of ORCID queue " + orcidQueue, ex);
|
||||
LOGGER.error("An error occurs during the orcid synchronization of ORCID queue {}",
|
||||
orcidQueue, ex);
|
||||
return createHistoryRecordFromOrcidError(context, orcidQueue, operation, ex);
|
||||
} catch (RuntimeException ex) {
|
||||
LOGGER.warn("An unexpected error occurs during the orcid synchronization of ORCID queue " + orcidQueue, ex);
|
||||
LOGGER.warn("An unexpected error occurs during the orcid synchronization of ORCID queue {}",
|
||||
orcidQueue, ex);
|
||||
return createHistoryRecordFromGenericError(context, orcidQueue, operation, ex);
|
||||
}
|
||||
|
||||
|
@@ -27,6 +27,8 @@ import javax.annotation.PostConstruct;
|
||||
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.app.exception.ResourceAlreadyExistsException;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.authorize.service.AuthorizeService;
|
||||
@@ -53,8 +55,6 @@ import org.dspace.profile.service.AfterResearcherProfileCreationAction;
|
||||
import org.dspace.profile.service.ResearcherProfileService;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.util.UUIDUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
@@ -66,7 +66,7 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public class ResearcherProfileServiceImpl implements ResearcherProfileService {
|
||||
|
||||
private static Logger log = LoggerFactory.getLogger(ResearcherProfileServiceImpl.class);
|
||||
private static final Logger log = LogManager.getLogger();
|
||||
|
||||
@Autowired
|
||||
private ItemService itemService;
|
||||
@@ -310,7 +310,7 @@ public class ResearcherProfileServiceImpl implements ResearcherProfileService {
|
||||
|
||||
if (isNotProfileCollection(collection)) {
|
||||
log.warn("The configured researcher-profile.collection.uuid "
|
||||
+ "has an invalid entity type, expected " + getProfileType());
|
||||
+ "has an invalid entity type, expected {}", this::getProfileType);
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
|
@@ -9,14 +9,14 @@ package org.dspace.qaevent.action;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.content.service.ItemService;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.qaevent.QualityAssuranceAction;
|
||||
import org.dspace.qaevent.service.dto.QAMessageDTO;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
@@ -27,7 +27,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
*/
|
||||
public class QAReinstateRequestAction implements QualityAssuranceAction {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(QAReinstateRequestAction.class);
|
||||
private static final Logger log = LogManager.getLogger();
|
||||
|
||||
@Autowired
|
||||
private ItemService itemService;
|
||||
|
@@ -9,25 +9,25 @@ package org.dspace.qaevent.action;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.content.service.ItemService;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.qaevent.QualityAssuranceAction;
|
||||
import org.dspace.qaevent.service.dto.QAMessageDTO;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
* QAWithdrawnRequestAction is an implementation of the QualityAssuranceAction interface.
|
||||
* It is responsible for applying a correction to withdraw a specified item.
|
||||
*
|
||||
*
|
||||
* @author Mykhaylo Boychuk (mykhaylo.boychuk@4science.com)
|
||||
*/
|
||||
public class QAWithdrawnRequestAction implements QualityAssuranceAction {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(QAWithdrawnRequestAction.class);
|
||||
private static final Logger log = LogManager.getLogger();
|
||||
|
||||
@Autowired
|
||||
private ItemService itemService;
|
||||
|
@@ -78,7 +78,7 @@ import org.springframework.beans.factory.annotation.Qualifier;
|
||||
*/
|
||||
public class QAEventServiceImpl implements QAEventService {
|
||||
|
||||
private static final Logger log = LogManager.getLogger(QAEventServiceImpl.class);
|
||||
private static final Logger log = LogManager.getLogger();
|
||||
|
||||
public static final String QAEVENTS_SOURCES = "qaevents.sources";
|
||||
|
||||
@@ -405,8 +405,8 @@ public class QAEventServiceImpl implements QAEventService {
|
||||
email.addArgument(parsJson(qaEvent.getMessage()));
|
||||
email.send();
|
||||
} catch (Exception e) {
|
||||
log.warn("Error during sending email of Withdrawn/Reinstate request for item with uuid:"
|
||||
+ qaEvent.getTarget(), e);
|
||||
log.warn("Error during sending email of Withdrawn/Reinstate request for item with uuid: {}",
|
||||
qaEvent.getTarget(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -416,7 +416,7 @@ public class QAEventServiceImpl implements QAEventService {
|
||||
JsonNode jsonNode = objectMapper.readTree(jsonString);
|
||||
return jsonNode.get("reason").asText();
|
||||
} catch (Exception e) {
|
||||
log.warn("Unable to parse the JSON:" + jsonString);
|
||||
log.warn("Unable to parse the JSON: {}", jsonString);
|
||||
return jsonString;
|
||||
}
|
||||
}
|
||||
|
@@ -12,19 +12,19 @@ import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.kernel.ServiceManager;
|
||||
import org.dspace.scripts.configuration.ScriptConfiguration;
|
||||
import org.dspace.scripts.service.ScriptService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
* The implementation for the {@link ScriptService}
|
||||
*/
|
||||
public class ScriptServiceImpl implements ScriptService {
|
||||
private static final Logger log = LoggerFactory.getLogger(ScriptServiceImpl.class);
|
||||
private static final Logger log = LogManager.getLogger();
|
||||
|
||||
@Autowired
|
||||
private ServiceManager serviceManager;
|
||||
@@ -48,7 +48,7 @@ public class ScriptServiceImpl implements ScriptService {
|
||||
try {
|
||||
return (DSpaceRunnable) scriptToExecute.getDspaceRunnableClass().getDeclaredConstructor().newInstance();
|
||||
} catch (InvocationTargetException | NoSuchMethodException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
log.error(e::getMessage, e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
@@ -15,12 +15,12 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import com.google.common.net.InetAddresses;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.core.Utils;
|
||||
import org.dspace.service.ClientInfoService;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.statistics.util.IPTable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
@@ -32,16 +32,16 @@ public class ClientInfoServiceImpl implements ClientInfoService {
|
||||
|
||||
private static final String X_FORWARDED_FOR_HEADER = "X-Forwarded-For";
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(ClientInfoServiceImpl.class);
|
||||
private static final Logger log = LogManager.getLogger();
|
||||
|
||||
private Boolean useProxiesEnabled;
|
||||
|
||||
private ConfigurationService configurationService;
|
||||
private final ConfigurationService configurationService;
|
||||
|
||||
/**
|
||||
* Sparse HashTable structure to hold IP address ranges of trusted proxies
|
||||
*/
|
||||
private IPTable trustedProxies;
|
||||
private final IPTable trustedProxies;
|
||||
|
||||
@Autowired(required = true)
|
||||
public ClientInfoServiceImpl(ConfigurationService configurationService) {
|
||||
@@ -84,7 +84,7 @@ public class ClientInfoServiceImpl implements ClientInfoService {
|
||||
public boolean isUseProxiesEnabled() {
|
||||
if (useProxiesEnabled == null) {
|
||||
useProxiesEnabled = configurationService.getBooleanProperty("useProxies", true);
|
||||
log.info("Proxies (useProxies) enabled? " + useProxiesEnabled);
|
||||
log.info("Proxies (useProxies) enabled? {}", useProxiesEnabled);
|
||||
}
|
||||
|
||||
return useProxiesEnabled;
|
||||
@@ -163,6 +163,7 @@ public class ClientInfoServiceImpl implements ClientInfoService {
|
||||
* @param ipAddress IP address to check for
|
||||
* @return true if trusted, false otherwise
|
||||
*/
|
||||
@Override
|
||||
public boolean isRequestFromTrustedProxy(String ipAddress) {
|
||||
try {
|
||||
return trustedProxies != null && trustedProxies.contains(ipAddress);
|
||||
@@ -205,15 +206,15 @@ public class ClientInfoServiceImpl implements ClientInfoService {
|
||||
}
|
||||
|
||||
/**
|
||||
* Anonymize the given IP address by setting the last specified bytes to 0
|
||||
* @param ipAddress the ip address to be anonymize
|
||||
* Anonymize the given IP address by setting the last specified bytes to 0.
|
||||
* @param ipAddress the ip address to be anonymized
|
||||
* @param bytes the number of bytes to be set to 0
|
||||
* @return the modified ip address
|
||||
*/
|
||||
private String anonymizeIpAddress(String ipAddress, int bytes) {
|
||||
|
||||
if (bytes > 4) {
|
||||
log.warn("It is not possible to anonymize " + bytes + " bytes of an IPv4 address.");
|
||||
log.warn("It is not possible to anonymize {} bytes of an IPv4 address.", bytes);
|
||||
return ipAddress;
|
||||
}
|
||||
|
||||
|
@@ -13,8 +13,6 @@ import java.util.Set;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.dspace.statistics.factory.StatisticsServiceFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* SpiderDetector delegates static methods to SpiderDetectorService, which is used to find IP's that are spiders...
|
||||
@@ -26,11 +24,9 @@ import org.slf4j.LoggerFactory;
|
||||
*/
|
||||
public class SpiderDetector {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(SpiderDetector.class);
|
||||
|
||||
//Service where all methods get delegated to, this is instantiated by a spring-bean defined in core-services.xml
|
||||
private static SpiderDetectorService spiderDetectorService = StatisticsServiceFactory.getInstance()
|
||||
.getSpiderDetectorService();
|
||||
private static final SpiderDetectorService spiderDetectorService
|
||||
= StatisticsServiceFactory.getInstance().getSpiderDetectorService();
|
||||
|
||||
/**
|
||||
* Default constructor
|
||||
|
@@ -21,10 +21,10 @@ import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.commons.configuration2.ex.ConversionException;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.service.ClientInfoService;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
@@ -39,18 +39,18 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
*/
|
||||
public class SpiderDetectorServiceImpl implements SpiderDetectorService {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(SpiderDetectorServiceImpl.class);
|
||||
private static final Logger log = LogManager.getLogger();
|
||||
|
||||
private Boolean useCaseInsensitiveMatching;
|
||||
|
||||
private final List<Pattern> agents
|
||||
= Collections.synchronizedList(new ArrayList<Pattern>());
|
||||
= Collections.synchronizedList(new ArrayList<>());
|
||||
|
||||
private final List<Pattern> domains
|
||||
= Collections.synchronizedList(new ArrayList<Pattern>());
|
||||
= Collections.synchronizedList(new ArrayList<>());
|
||||
|
||||
private ConfigurationService configurationService;
|
||||
private ClientInfoService clientInfoService;
|
||||
private final ConfigurationService configurationService;
|
||||
private final ClientInfoService clientInfoService;
|
||||
|
||||
/**
|
||||
* Sparse HashTable structure to hold IP address ranges.
|
||||
@@ -63,6 +63,7 @@ public class SpiderDetectorServiceImpl implements SpiderDetectorService {
|
||||
this.clientInfoService = clientInfoService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPTable getTable() {
|
||||
return table;
|
||||
}
|
||||
@@ -79,6 +80,7 @@ public class SpiderDetectorServiceImpl implements SpiderDetectorService {
|
||||
* @param agent User-Agent header value, or null.
|
||||
* @return true if the client matches any spider characteristics list.
|
||||
*/
|
||||
@Override
|
||||
public boolean isSpider(String clientIP, String proxyIPs, String hostname, String agent) {
|
||||
// See if any agent patterns match
|
||||
if (null != agent) {
|
||||
@@ -144,6 +146,7 @@ public class SpiderDetectorServiceImpl implements SpiderDetectorService {
|
||||
* @return a vector full of patterns
|
||||
* @throws IOException could not happen since we check the file be4 we use it
|
||||
*/
|
||||
@Override
|
||||
public Set<String> readPatterns(File patternFile)
|
||||
throws IOException {
|
||||
Set<String> patterns = new HashSet<>();
|
||||
@@ -191,7 +194,7 @@ public class SpiderDetectorServiceImpl implements SpiderDetectorService {
|
||||
patterns = readPatterns(file);
|
||||
} catch (IOException ex) {
|
||||
log.error("Patterns not read from {}: {}",
|
||||
file.getPath(), ex.getMessage());
|
||||
file::getPath, ex::getMessage);
|
||||
continue;
|
||||
}
|
||||
//If case insensitive matching is enabled, lowercase the patterns so they can be lowercase matched
|
||||
@@ -203,10 +206,10 @@ public class SpiderDetectorServiceImpl implements SpiderDetectorService {
|
||||
}
|
||||
|
||||
|
||||
log.info("Loaded pattern file: {}", file.getPath());
|
||||
log.info("Loaded pattern file: {}", file::getPath);
|
||||
}
|
||||
} else {
|
||||
log.info("No patterns loaded from {}", patternsDir.getPath());
|
||||
log.info("No patterns loaded from {}", patternsDir::getPath);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -216,6 +219,7 @@ public class SpiderDetectorServiceImpl implements SpiderDetectorService {
|
||||
* @param request
|
||||
* @return true|false if the request was detected to be from a spider.
|
||||
*/
|
||||
@Override
|
||||
public boolean isSpider(HttpServletRequest request) {
|
||||
return isSpider(request.getRemoteAddr(),
|
||||
request.getHeader("X-Forwarded-For"),
|
||||
@@ -229,6 +233,7 @@ public class SpiderDetectorServiceImpl implements SpiderDetectorService {
|
||||
* @param ip
|
||||
* @return if is spider IP
|
||||
*/
|
||||
@Override
|
||||
public boolean isSpider(String ip) {
|
||||
if (table == null) {
|
||||
loadSpiderIpAddresses();
|
||||
@@ -248,6 +253,7 @@ public class SpiderDetectorServiceImpl implements SpiderDetectorService {
|
||||
/*
|
||||
* loader to populate the table from files.
|
||||
*/
|
||||
@Override
|
||||
public synchronized void loadSpiderIpAddresses() {
|
||||
|
||||
if (table == null) {
|
||||
|
@@ -14,6 +14,8 @@ import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.transform.TransformerException;
|
||||
import javax.xml.xpath.XPathExpressionException;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.administer.MetadataImporter;
|
||||
import org.dspace.administer.RegistryImportException;
|
||||
import org.dspace.administer.RegistryLoader;
|
||||
@@ -24,8 +26,6 @@ import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
import org.flywaydb.core.api.callback.Callback;
|
||||
import org.flywaydb.core.api.callback.Event;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
/**
|
||||
@@ -52,7 +52,7 @@ public class RegistryUpdater implements Callback {
|
||||
/**
|
||||
* logging category
|
||||
*/
|
||||
private static final Logger log = LoggerFactory.getLogger(RegistryUpdater.class);
|
||||
private static final Logger log = LogManager.getLogger();
|
||||
|
||||
/**
|
||||
* Method to actually update our registries from latest configuration files.
|
||||
|
@@ -14,8 +14,6 @@ import org.dspace.storage.rdbms.DatabaseUtils;
|
||||
import org.dspace.storage.rdbms.migration.MigrationUtils;
|
||||
import org.flywaydb.core.api.migration.BaseJavaMigration;
|
||||
import org.flywaydb.core.api.migration.Context;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* This class automatically migrates your DSpace Database to use the
|
||||
@@ -35,11 +33,6 @@ import org.slf4j.LoggerFactory;
|
||||
*/
|
||||
public class V5_0_2014_11_04__Enable_XMLWorkflow_Migration
|
||||
extends BaseJavaMigration {
|
||||
/**
|
||||
* logging category
|
||||
*/
|
||||
private static final Logger log = LoggerFactory.getLogger(V5_0_2014_11_04__Enable_XMLWorkflow_Migration.class);
|
||||
|
||||
// Size of migration script run
|
||||
Integer migration_file_size = -1;
|
||||
|
||||
|
@@ -15,16 +15,16 @@ import java.io.PrintWriter;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.model.Event;
|
||||
import org.dspace.utils.DSpace;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Serialize {@link UsageEvent} data to a file as Tab delimited. In dspace.cfg
|
||||
* specify the path to the file as the value of
|
||||
* Serialize {@link UsageEvent} data to a file as Tab delimited.
|
||||
* In {@code dspace.cfg} specify the path to the file as the value of
|
||||
* {@code usageEvent.tabFileLogger.file}. If that path is not absolute, it
|
||||
* will be interpreted as relative to the directory named in {@code log.dir}.
|
||||
* If no name is configured, it defaults to "usage-events.tsv". If the file is
|
||||
@@ -38,8 +38,7 @@ public class TabFileUsageEventListener
|
||||
/**
|
||||
* log category.
|
||||
*/
|
||||
private static final Logger errorLog = LoggerFactory
|
||||
.getLogger(TabFileUsageEventListener.class);
|
||||
private static final Logger errorLog = LogManager.getLogger();
|
||||
|
||||
/**
|
||||
* ISO 8601 Basic string format for record timestamps.
|
||||
@@ -77,11 +76,11 @@ public class TabFileUsageEventListener
|
||||
try {
|
||||
eventLog = new PrintWriter(new OutputStreamWriter(
|
||||
new FileOutputStream(logFile, true)));
|
||||
errorLog.debug("Writing to {}", logFile.getAbsolutePath());
|
||||
errorLog.debug("Writing to {}", logFile::getAbsolutePath);
|
||||
} catch (FileNotFoundException e) {
|
||||
errorLog.error("{} cannot open file, will not log events: {}",
|
||||
TabFileUsageEventListener.class.getName(),
|
||||
e.getMessage());
|
||||
TabFileUsageEventListener.class::getName,
|
||||
e::getMessage);
|
||||
throw new IllegalArgumentException("Cannot open event log file", e);
|
||||
}
|
||||
|
||||
@@ -104,9 +103,7 @@ public class TabFileUsageEventListener
|
||||
init();
|
||||
}
|
||||
|
||||
if (errorLog.isDebugEnabled()) {
|
||||
errorLog.debug("got: {}", event.toString());
|
||||
}
|
||||
errorLog.debug("got: {}", event::toString);
|
||||
|
||||
if (!(event instanceof UsageEvent)) {
|
||||
return;
|
||||
|
@@ -14,6 +14,8 @@ import static org.apache.commons.lang3.StringUtils.lowerCase;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.content.Bitstream;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.core.Context;
|
||||
@@ -22,18 +24,16 @@ import org.dspace.discovery.DiscoverResult;
|
||||
import org.dspace.discovery.SearchService;
|
||||
import org.dspace.discovery.SearchServiceException;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* Service class for generation of front-end urls.
|
||||
* Service class for generation of front-end URLs.
|
||||
*/
|
||||
@Component
|
||||
public class FrontendUrlService {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(FrontendUrlService.class);
|
||||
private static final Logger log = LogManager.getLogger();
|
||||
|
||||
@Autowired
|
||||
private ConfigurationService configurationService;
|
||||
@@ -80,7 +80,8 @@ public class FrontendUrlService {
|
||||
}
|
||||
}
|
||||
} catch (SearchServiceException e) {
|
||||
log.error("Failed getting entitytype through solr for item " + item.getID() + ": " + e.getMessage());
|
||||
log.error("Failed getting entitytype through solr for item {}: {}",
|
||||
item::getID, e::getMessage);
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
|
@@ -23,9 +23,9 @@ import java.util.regex.Pattern;
|
||||
import java.util.regex.PatternSyntaxException;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.servicemanager.DSpaceKernelInit;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Attempt to parse date strings in a variety of formats. This uses an external
|
||||
@@ -38,7 +38,7 @@ import org.slf4j.LoggerFactory;
|
||||
* @author mwood
|
||||
*/
|
||||
public class MultiFormatDateParser {
|
||||
private static final Logger log = LoggerFactory.getLogger(MultiFormatDateParser.class);
|
||||
private static final Logger log = LogManager.getLogger();
|
||||
|
||||
/**
|
||||
* A list of rules, each binding a regular expression to a date format.
|
||||
@@ -71,7 +71,7 @@ public class MultiFormatDateParser {
|
||||
pattern = Pattern.compile(rule.getKey(), Pattern.CASE_INSENSITIVE);
|
||||
} catch (PatternSyntaxException ex) {
|
||||
log.error("Skipping format with unparseable pattern '{}'",
|
||||
rule.getKey());
|
||||
rule::getKey);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ public class MultiFormatDateParser {
|
||||
format = new SimpleDateFormat(rule.getValue());
|
||||
} catch (IllegalArgumentException ex) {
|
||||
log.error("Skipping uninterpretable date format '{}'",
|
||||
rule.getValue());
|
||||
rule::getValue);
|
||||
continue;
|
||||
}
|
||||
format.setCalendar(Calendar.getInstance(UTC_ZONE));
|
||||
@@ -107,7 +107,7 @@ public class MultiFormatDateParser {
|
||||
}
|
||||
} catch (ParseException ex) {
|
||||
log.info("Date string '{}' matched pattern '{}' but did not parse: {}",
|
||||
new String[] {dateString, candidate.format.toPattern(), ex.getMessage()});
|
||||
() -> dateString, candidate.format::toPattern, ex::getMessage);
|
||||
continue;
|
||||
}
|
||||
return result;
|
||||
|
@@ -0,0 +1,237 @@
|
||||
/**
|
||||
* The contents of this file are subject to the license and copyright
|
||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||
* tree and available online at
|
||||
*
|
||||
* http://www.dspace.org/license/
|
||||
*/
|
||||
package org.dspace.app.mediafilter;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.dspace.AbstractIntegrationTestWithDatabase;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.builder.BitstreamBuilder;
|
||||
import org.dspace.builder.CollectionBuilder;
|
||||
import org.dspace.builder.CommunityBuilder;
|
||||
import org.dspace.builder.ItemBuilder;
|
||||
import org.dspace.content.Bitstream;
|
||||
import org.dspace.content.Bundle;
|
||||
import org.dspace.content.Collection;
|
||||
import org.dspace.content.Community;
|
||||
import org.dspace.content.DSpaceObject;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.content.factory.ContentServiceFactory;
|
||||
import org.dspace.content.service.BitstreamService;
|
||||
import org.dspace.content.service.ItemService;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Tests of {@link MediaFilterScript}.
|
||||
*
|
||||
* @author Andrea Bollini <andrea.bollini at 4science.com>
|
||||
*/
|
||||
public class MediaFilterIT extends AbstractIntegrationTestWithDatabase {
|
||||
|
||||
private ItemService itemService = ContentServiceFactory.getInstance().getItemService();
|
||||
private BitstreamService bitstreamService = ContentServiceFactory.getInstance().getBitstreamService();
|
||||
protected Community topComm1;
|
||||
protected Community topComm2;
|
||||
protected Community childComm1_1;
|
||||
protected Community childComm1_2;
|
||||
protected Collection col1_1;
|
||||
protected Collection col1_2;
|
||||
protected Collection col1_1_1;
|
||||
protected Collection col1_1_2;
|
||||
protected Collection col1_2_1;
|
||||
protected Collection col1_2_2;
|
||||
protected Collection col2_1;
|
||||
protected Item item1_1_a;
|
||||
protected Item item1_1_b;
|
||||
protected Item item1_2_a;
|
||||
protected Item item1_2_b;
|
||||
protected Item item1_1_1_a;
|
||||
protected Item item1_1_1_b;
|
||||
protected Item item1_1_2_a;
|
||||
protected Item item1_1_2_b;
|
||||
protected Item item1_2_1_a;
|
||||
protected Item item1_2_1_b;
|
||||
protected Item item1_2_2_a;
|
||||
protected Item item1_2_2_b;
|
||||
protected Item item2_1_a;
|
||||
protected Item item2_1_b;
|
||||
|
||||
@Before
|
||||
public void setup() throws IOException, SQLException, AuthorizeException {
|
||||
context.turnOffAuthorisationSystem();
|
||||
topComm1 = CommunityBuilder.createCommunity(context).withName("Parent Community1").build();
|
||||
topComm2 = CommunityBuilder.createCommunity(context).withName("Parent Community2").build();
|
||||
childComm1_1 = CommunityBuilder.createCommunity(context).withName("Child Community1_1")
|
||||
.addParentCommunity(context, topComm1).build();
|
||||
childComm1_2 = CommunityBuilder.createCommunity(context).withName("Child Community1_2")
|
||||
.addParentCommunity(context, topComm1).build();
|
||||
col1_1 = CollectionBuilder.createCollection(context, topComm1).withName("Collection 1_1").build();
|
||||
col1_2 = CollectionBuilder.createCollection(context, topComm1).withName("Collection 1_2").build();
|
||||
col1_1_1 = CollectionBuilder.createCollection(context, childComm1_1).withName("Collection 1_1_1").build();
|
||||
col1_1_2 = CollectionBuilder.createCollection(context, childComm1_1).withName("Collection 1_1_2").build();
|
||||
col1_2_1 = CollectionBuilder.createCollection(context, childComm1_2).withName("Collection 1_1_1").build();
|
||||
col1_2_2 = CollectionBuilder.createCollection(context, childComm1_2).withName("Collection 1_2").build();
|
||||
col2_1 = CollectionBuilder.createCollection(context, topComm2).withName("Collection 2_1").build();
|
||||
|
||||
// Create two items in each collection, one with the test.csv file and one with the test.txt file
|
||||
item1_1_a = ItemBuilder.createItem(context, col1_1).withTitle("Item 1_1_a").withIssueDate("2017-10-17").build();
|
||||
item1_1_b = ItemBuilder.createItem(context, col1_1).withTitle("Item 1_1_b").withIssueDate("2017-10-17").build();
|
||||
item1_1_1_a = ItemBuilder.createItem(context, col1_1_1).withTitle("Item 1_1_1_a").withIssueDate("2017-10-17")
|
||||
.build();
|
||||
item1_1_1_b = ItemBuilder.createItem(context, col1_1_1).withTitle("Item 1_1_1_b").withIssueDate("2017-10-17")
|
||||
.build();
|
||||
item1_1_2_a = ItemBuilder.createItem(context, col1_1_2).withTitle("Item 1_1_2_a").withIssueDate("2017-10-17")
|
||||
.build();
|
||||
item1_1_2_b = ItemBuilder.createItem(context, col1_1_2).withTitle("Item 1_1_2_b").withIssueDate("2017-10-17")
|
||||
.build();
|
||||
item1_2_a = ItemBuilder.createItem(context, col1_2).withTitle("Item 1_2_a").withIssueDate("2017-10-17").build();
|
||||
item1_2_b = ItemBuilder.createItem(context, col1_2).withTitle("Item 1_2_b").withIssueDate("2017-10-17").build();
|
||||
item1_2_1_a = ItemBuilder.createItem(context, col1_2_1).withTitle("Item 1_2_1_a").withIssueDate("2017-10-17")
|
||||
.build();
|
||||
item1_2_1_b = ItemBuilder.createItem(context, col1_2_1).withTitle("Item 1_2_1_b").withIssueDate("2017-10-17")
|
||||
.build();
|
||||
item1_2_2_a = ItemBuilder.createItem(context, col1_2_2).withTitle("Item 1_2_2_a").withIssueDate("2017-10-17")
|
||||
.build();
|
||||
item1_2_2_b = ItemBuilder.createItem(context, col1_2_2).withTitle("Item 1_2_2_b").withIssueDate("2017-10-17")
|
||||
.build();
|
||||
item2_1_a = ItemBuilder.createItem(context, col2_1).withTitle("Item 2_1_a").withIssueDate("2017-10-17").build();
|
||||
item2_1_b = ItemBuilder.createItem(context, col2_1).withTitle("Item 2_1_b").withIssueDate("2017-10-17").build();
|
||||
addBitstream(item1_1_a, "test.csv");
|
||||
addBitstream(item1_1_b, "test.txt");
|
||||
addBitstream(item1_2_a, "test.csv");
|
||||
addBitstream(item1_2_b, "test.txt");
|
||||
addBitstream(item1_1_1_a, "test.csv");
|
||||
addBitstream(item1_1_1_b, "test.txt");
|
||||
addBitstream(item1_1_2_a, "test.csv");
|
||||
addBitstream(item1_1_2_b, "test.txt");
|
||||
addBitstream(item1_2_1_a, "test.csv");
|
||||
addBitstream(item1_2_1_b, "test.txt");
|
||||
addBitstream(item1_2_2_a, "test.csv");
|
||||
addBitstream(item1_2_2_b, "test.txt");
|
||||
addBitstream(item2_1_a, "test.csv");
|
||||
addBitstream(item2_1_b, "test.txt");
|
||||
context.restoreAuthSystemState();
|
||||
}
|
||||
|
||||
private void addBitstream(Item item, String filename) throws SQLException, AuthorizeException, IOException {
|
||||
BitstreamBuilder.createBitstream(context, item, getClass().getResourceAsStream(filename)).withName(filename)
|
||||
.guessFormat().build();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mediaFilterScriptAllItemsTest() throws Exception {
|
||||
performMediaFilterScript(null);
|
||||
Iterator<Item> items = itemService.findAll(context);
|
||||
while (items.hasNext()) {
|
||||
Item item = items.next();
|
||||
checkItemHasBeenProcessed(item);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mediaFilterScriptIdentifiersTest() throws Exception {
|
||||
// process the item 1_1_a and verify that no other items has been processed using the "closer" one
|
||||
performMediaFilterScript(item1_1_a);
|
||||
checkItemHasBeenProcessed(item1_1_a);
|
||||
checkItemHasBeenNotProcessed(item1_1_b);
|
||||
// process the collection 1_1_1 and verify that items in another collection has not been processed
|
||||
performMediaFilterScript(col1_1_1);
|
||||
checkItemHasBeenProcessed(item1_1_1_a);
|
||||
checkItemHasBeenProcessed(item1_1_1_b);
|
||||
checkItemHasBeenNotProcessed(item1_1_2_a);
|
||||
checkItemHasBeenNotProcessed(item1_1_2_b);
|
||||
// process a top community with only collections
|
||||
performMediaFilterScript(topComm2);
|
||||
checkItemHasBeenProcessed(item2_1_a);
|
||||
checkItemHasBeenProcessed(item2_1_b);
|
||||
// verify that the other items have not been processed yet
|
||||
checkItemHasBeenNotProcessed(item1_1_b);
|
||||
checkItemHasBeenNotProcessed(item1_2_a);
|
||||
checkItemHasBeenNotProcessed(item1_2_b);
|
||||
checkItemHasBeenNotProcessed(item1_1_2_a);
|
||||
checkItemHasBeenNotProcessed(item1_1_2_b);
|
||||
checkItemHasBeenNotProcessed(item1_2_1_a);
|
||||
checkItemHasBeenNotProcessed(item1_2_1_b);
|
||||
checkItemHasBeenNotProcessed(item1_2_2_a);
|
||||
checkItemHasBeenNotProcessed(item1_2_2_b);
|
||||
// process a more structured community and verify that all the items at all levels are processed
|
||||
performMediaFilterScript(topComm1);
|
||||
// items that were already processed should stay processed
|
||||
checkItemHasBeenProcessed(item1_1_a);
|
||||
checkItemHasBeenProcessed(item1_1_1_a);
|
||||
checkItemHasBeenProcessed(item1_1_1_b);
|
||||
// residual items should have been processed as well now
|
||||
checkItemHasBeenProcessed(item1_1_b);
|
||||
checkItemHasBeenProcessed(item1_2_a);
|
||||
checkItemHasBeenProcessed(item1_2_b);
|
||||
checkItemHasBeenProcessed(item1_1_2_a);
|
||||
checkItemHasBeenProcessed(item1_1_2_b);
|
||||
checkItemHasBeenProcessed(item1_2_1_a);
|
||||
checkItemHasBeenProcessed(item1_2_1_b);
|
||||
checkItemHasBeenProcessed(item1_2_2_a);
|
||||
checkItemHasBeenProcessed(item1_2_2_b);
|
||||
}
|
||||
|
||||
private void checkItemHasBeenNotProcessed(Item item) throws IOException, SQLException, AuthorizeException {
|
||||
List<Bundle> textBundles = item.getBundles("TEXT");
|
||||
assertTrue("The item " + item.getName() + " should NOT have the TEXT bundle", textBundles.size() == 0);
|
||||
}
|
||||
|
||||
private void checkItemHasBeenProcessed(Item item) throws IOException, SQLException, AuthorizeException {
|
||||
String expectedFileName = StringUtils.endsWith(item.getName(), "_a") ? "test.csv.txt" : "test.txt.txt";
|
||||
String expectedContent = StringUtils.endsWith(item.getName(), "_a") ? "data3,3" : "quick brown fox";
|
||||
List<Bundle> textBundles = item.getBundles("TEXT");
|
||||
assertTrue("The item " + item.getName() + " has NOT the TEXT bundle", textBundles.size() == 1);
|
||||
List<Bitstream> bitstreams = textBundles.get(0).getBitstreams();
|
||||
assertTrue("The item " + item.getName() + " has NOT exactly 1 bitstream in the TEXT bundle",
|
||||
bitstreams.size() == 1);
|
||||
assertTrue("The text bistream in the " + item.getName() + " is NOT named properly [" + expectedFileName + "]",
|
||||
StringUtils.equals(bitstreams.get(0).getName(), expectedFileName));
|
||||
assertTrue("The text bistream in the " + item.getName() + " doesn't contain the proper content ["
|
||||
+ expectedContent + "]", StringUtils.contains(getContent(bitstreams.get(0)), expectedContent));
|
||||
}
|
||||
|
||||
private CharSequence getContent(Bitstream bitstream) throws IOException, SQLException, AuthorizeException {
|
||||
try (InputStream input = bitstreamService.retrieve(context, bitstream)) {
|
||||
return IOUtils.toString(input, "UTF-8");
|
||||
}
|
||||
}
|
||||
|
||||
private void performMediaFilterScript(DSpaceObject dso) throws Exception {
|
||||
if (dso != null) {
|
||||
runDSpaceScript("filter-media", "-i", dso.getHandle());
|
||||
} else {
|
||||
runDSpaceScript("filter-media");
|
||||
}
|
||||
// reload our items to see the changes
|
||||
item1_1_a = context.reloadEntity(item1_1_a);
|
||||
item1_1_b = context.reloadEntity(item1_1_b);
|
||||
item1_2_a = context.reloadEntity(item1_2_a);
|
||||
item1_2_b = context.reloadEntity(item1_2_b);
|
||||
item1_1_1_a = context.reloadEntity(item1_1_1_a);
|
||||
item1_1_1_b = context.reloadEntity(item1_1_1_b);
|
||||
item1_1_2_a = context.reloadEntity(item1_1_2_a);
|
||||
item1_1_2_b = context.reloadEntity(item1_1_2_b);
|
||||
item1_2_1_a = context.reloadEntity(item1_2_1_a);
|
||||
item1_2_1_b = context.reloadEntity(item1_2_1_b);
|
||||
item1_2_2_a = context.reloadEntity(item1_2_2_a);
|
||||
item1_2_2_b = context.reloadEntity(item1_2_2_b);
|
||||
item2_1_a = context.reloadEntity(item2_1_a);
|
||||
item2_1_b = context.reloadEntity(item2_1_b);
|
||||
|
||||
}
|
||||
}
|
@@ -21,6 +21,7 @@ import org.dspace.content.Item;
|
||||
import org.dspace.content.MetadataField;
|
||||
import org.dspace.content.MetadataValue;
|
||||
import org.dspace.content.factory.ContentServiceFactory;
|
||||
import org.dspace.content.service.BitstreamFormatService;
|
||||
import org.dspace.content.service.DSpaceObjectService;
|
||||
import org.dspace.content.service.MetadataValueService;
|
||||
import org.dspace.core.Constants;
|
||||
@@ -168,6 +169,19 @@ public class BitstreamBuilder extends AbstractDSpaceObjectBuilder<Bitstream> {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Guess the bitstream format as during the submission via the
|
||||
* {@link BitstreamFormatService#guessFormat(Context, Bitstream)}
|
||||
*
|
||||
* @return the BitstreamBuilder with the format set according to
|
||||
* {@link BitstreamFormatService#guessFormat(Context, Bitstream)}
|
||||
* @throws SQLException
|
||||
*/
|
||||
public BitstreamBuilder guessFormat() throws SQLException {
|
||||
bitstream.setFormat(context, bitstreamFormatService.guessFormat(context, bitstream));
|
||||
return this;
|
||||
}
|
||||
|
||||
public BitstreamBuilder withFormat(String format) throws SQLException {
|
||||
|
||||
bitstreamService.addMetadata(context, bitstream, "dc", "format", null, null, format);
|
||||
|
@@ -14,6 +14,8 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.AbstractUnitTest;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.Community;
|
||||
@@ -27,8 +29,6 @@ import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Drive the Curator and check results.
|
||||
@@ -37,7 +37,7 @@ import org.slf4j.LoggerFactory;
|
||||
*/
|
||||
public class CuratorReportTest
|
||||
extends AbstractUnitTest {
|
||||
Logger LOG = LoggerFactory.getLogger(CuratorReportTest.class);
|
||||
Logger LOG = LogManager.getLogger();
|
||||
|
||||
public CuratorReportTest() {
|
||||
}
|
||||
|
@@ -28,6 +28,12 @@
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-api</artifactId>
|
||||
<version>${log4j.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Needed to support Spring @Configuration classes (to register servlets/beans with Spring Boot webapp) -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
@@ -421,7 +421,7 @@
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
<version>${spring-boot.version}</version>
|
||||
<version>${spring-boot.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
@@ -433,7 +433,13 @@
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-log4j2</artifactId>
|
||||
<version>${spring-boot.version}</version>
|
||||
<version>${spring-boot.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-api</artifactId>
|
||||
<version>${log4j.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- DSpace dependencies -->
|
||||
|
@@ -36,8 +36,6 @@ import org.dspace.app.rest.utils.ContextUtil;
|
||||
import org.dspace.app.rest.utils.Utils;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.service.ClientInfoService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
@@ -64,8 +62,6 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@RestController
|
||||
public class AuthenticationRestController implements InitializingBean {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(AuthenticationRestController.class);
|
||||
|
||||
@Autowired
|
||||
DiscoverableEndpointsService discoverableEndpointsService;
|
||||
|
||||
|
@@ -14,11 +14,11 @@ import javax.annotation.PostConstruct;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.app.rest.model.AuthnRest;
|
||||
import org.dspace.core.Utils;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.hateoas.Link;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@@ -27,7 +27,7 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* Rest controller that handles redirect after OIDC authentication succeded.
|
||||
* Rest controller that handles redirect after OIDC authentication succeeded.
|
||||
*
|
||||
* @author Luca Giamminonni (luca.giamminonni at 4science.it)
|
||||
*/
|
||||
@@ -35,7 +35,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@RequestMapping(value = "/api/" + AuthnRest.CATEGORY + "/oidc")
|
||||
public class OidcRestController {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(OidcRestController.class);
|
||||
private static final Logger log = LogManager.getLogger();
|
||||
|
||||
@Autowired
|
||||
private ConfigurationService configurationService;
|
||||
@@ -66,11 +66,12 @@ public class OidcRestController {
|
||||
}
|
||||
|
||||
if (StringUtils.equalsAnyIgnoreCase(redirectHostName, allowedHostNames.toArray(new String[0]))) {
|
||||
log.debug("OIDC redirecting to " + redirectUrl);
|
||||
log.debug("OIDC redirecting to {}", redirectUrl);
|
||||
response.sendRedirect(redirectUrl); // lgtm [java/unvalidated-url-redirection]
|
||||
} else {
|
||||
log.error("Invalid OIDC redirectURL=" + redirectUrl +
|
||||
". URL doesn't match hostname of server or UI!");
|
||||
log.error("Invalid OIDC redirectURL={}."
|
||||
+ " URL doesn't match hostname of server or UI!",
|
||||
redirectUrl);
|
||||
response.sendError(HttpServletResponse.SC_BAD_REQUEST,
|
||||
"Invalid redirectURL! Must match server or ui hostname.");
|
||||
}
|
||||
|
@@ -24,8 +24,6 @@ import org.dspace.app.solrdatabaseresync.SolrDatabaseResyncCli;
|
||||
import org.dspace.app.util.DSpaceContextListener;
|
||||
import org.dspace.google.GoogleAsyncEventListener;
|
||||
import org.dspace.utils.servlet.DSpaceWebappServletFilter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.EnableCaching;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@@ -55,8 +53,6 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
@Configuration
|
||||
public class WebApplication {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(WebApplication.class);
|
||||
|
||||
@Autowired
|
||||
private ApplicationConfig configuration;
|
||||
|
||||
|
@@ -11,6 +11,8 @@ import java.sql.SQLException;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.app.rest.authorization.AuthorizationFeature;
|
||||
import org.dspace.app.rest.authorization.AuthorizationFeatureDocumentation;
|
||||
import org.dspace.app.rest.model.BaseObjectRest;
|
||||
@@ -22,8 +24,6 @@ import org.dspace.content.service.ItemService;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.eperson.EPerson;
|
||||
import org.dspace.profile.service.ResearcherProfileService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -43,7 +43,7 @@ public class CanClaimItemFeature implements AuthorizationFeature {
|
||||
|
||||
public static final String NAME = "canClaimItem";
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(CanClaimItemFeature.class);
|
||||
private static final Logger LOG = LogManager.getLogger();
|
||||
|
||||
@Autowired
|
||||
private ItemService itemService;
|
||||
@@ -72,7 +72,8 @@ public class CanClaimItemFeature implements AuthorizationFeature {
|
||||
try {
|
||||
return researcherProfileService.findById(context, context.getCurrentUser().getID()) == null;
|
||||
} catch (SQLException | AuthorizeException e) {
|
||||
LOG.warn("Error while checking if eperson has a ResearcherProfileAssociated: {}", e.getMessage(), e);
|
||||
LOG.warn("Error while checking if eperson has a ResearcherProfileAssociated: {}",
|
||||
e.getMessage(), e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@@ -17,8 +17,6 @@ import javax.servlet.ServletResponse;
|
||||
|
||||
import org.dspace.app.rest.utils.ContextUtil;
|
||||
import org.dspace.core.Context;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* A Servlet Filter whose only role is to clean up open Context objects in
|
||||
@@ -29,8 +27,6 @@ import org.slf4j.LoggerFactory;
|
||||
* @see ContextUtil
|
||||
*/
|
||||
public class DSpaceRequestContextFilter implements Filter {
|
||||
private static final Logger log = LoggerFactory.getLogger(DSpaceRequestContextFilter.class);
|
||||
|
||||
@Override
|
||||
public void init(FilterConfig filterConfig) throws ServletException {
|
||||
//noop
|
||||
|
@@ -18,6 +18,8 @@ import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.app.rest.login.PostLoggedInAction;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.Item;
|
||||
@@ -27,8 +29,6 @@ import org.dspace.core.Context;
|
||||
import org.dspace.eperson.EPerson;
|
||||
import org.dspace.eperson.service.EPersonService;
|
||||
import org.dspace.profile.service.ResearcherProfileService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
@@ -43,7 +43,7 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public class ResearcherProfileAutomaticClaim implements PostLoggedInAction {
|
||||
|
||||
private final static Logger LOGGER = LoggerFactory.getLogger(ResearcherProfileAutomaticClaim.class);
|
||||
private final static Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
@Autowired
|
||||
private ResearcherProfileService researcherProfileService;
|
||||
|
@@ -18,6 +18,8 @@ import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.app.rest.Parameter;
|
||||
import org.dspace.app.rest.SearchRestMethod;
|
||||
import org.dspace.app.rest.authorization.Authorization;
|
||||
@@ -34,8 +36,6 @@ import org.dspace.core.Context;
|
||||
import org.dspace.discovery.SearchServiceException;
|
||||
import org.dspace.eperson.EPerson;
|
||||
import org.dspace.eperson.service.EPersonService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
@@ -52,7 +52,7 @@ import org.springframework.stereotype.Component;
|
||||
@Component(AuthorizationRest.CATEGORY + "." + AuthorizationRest.PLURAL_NAME)
|
||||
public class AuthorizationRestRepository extends DSpaceRestRepository<AuthorizationRest, String> {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(AuthorizationRestRepository.class);
|
||||
private static final Logger log = LogManager.getLogger();
|
||||
|
||||
@Autowired
|
||||
private AuthorizationFeatureService authorizationFeatureService;
|
||||
@@ -79,7 +79,7 @@ public class AuthorizationRestRepository extends DSpaceRestRepository<Authorizat
|
||||
try {
|
||||
featureName = authorizationRestUtil.getFeatureName(id);
|
||||
} catch (IllegalArgumentException e) {
|
||||
log.warn(e.getMessage(), e);
|
||||
log.warn(e::getMessage, e);
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
@@ -87,7 +87,7 @@ public class AuthorizationRestRepository extends DSpaceRestRepository<Authorizat
|
||||
try {
|
||||
object = authorizationRestUtil.getObject(context, id);
|
||||
} catch (IllegalArgumentException e) {
|
||||
log.warn("Object informations not found in the specified id " + id, e);
|
||||
log.warn("Object informations not found in the specified id {}", id, e);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ public class AuthorizationRestRepository extends DSpaceRestRepository<Authorizat
|
||||
try {
|
||||
user = authorizationRestUtil.getEperson(context, id);
|
||||
} catch (IllegalArgumentException e) {
|
||||
log.warn("Invalid eperson informations in the specified id " + id, e);
|
||||
log.warn("Invalid eperson informations in the specified id {}", id, e);
|
||||
return null;
|
||||
}
|
||||
EPerson currUser = context.getCurrentUser();
|
||||
@@ -136,7 +136,7 @@ public class AuthorizationRestRepository extends DSpaceRestRepository<Authorizat
|
||||
/**
|
||||
* It returns the list of matching available authorizations granted to the specified eperson or to the anonymous
|
||||
* user. Only administrators and the user identified by the epersonUuid parameter can access this method
|
||||
*
|
||||
*
|
||||
* @param uri
|
||||
* the uri of the object to check the authorization against
|
||||
* @param epersonUuid
|
||||
@@ -283,7 +283,7 @@ public class AuthorizationRestRepository extends DSpaceRestRepository<Authorizat
|
||||
|
||||
/**
|
||||
* Return the user specified in the request parameter if valid
|
||||
*
|
||||
*
|
||||
* @param context
|
||||
* @param epersonUuid
|
||||
* @return
|
||||
|
@@ -10,6 +10,8 @@ package org.dspace.app.rest.security;
|
||||
import java.io.Serializable;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.app.rest.utils.ContextUtil;
|
||||
import org.dspace.authorize.service.AuthorizeService;
|
||||
import org.dspace.core.Context;
|
||||
@@ -17,8 +19,6 @@ import org.dspace.eperson.EPerson;
|
||||
import org.dspace.eperson.service.EPersonService;
|
||||
import org.dspace.services.RequestService;
|
||||
import org.dspace.services.model.Request;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.annotation.Order;
|
||||
@@ -34,7 +34,7 @@ import org.springframework.stereotype.Component;
|
||||
@Order(value = Ordered.HIGHEST_PRECEDENCE)
|
||||
public class AdminRestPermissionEvaluatorPlugin extends RestObjectPermissionEvaluatorPlugin {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(RestObjectPermissionEvaluatorPlugin.class);
|
||||
private static final Logger log = LogManager.getLogger();
|
||||
|
||||
@Autowired
|
||||
private AuthorizeService authorizeService;
|
||||
@@ -69,7 +69,7 @@ public class AdminRestPermissionEvaluatorPlugin extends RestObjectPermissionEval
|
||||
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
log.error(e::getMessage, e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@@ -11,6 +11,8 @@ import java.io.Serializable;
|
||||
import java.sql.SQLException;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.app.rest.utils.ContextUtil;
|
||||
import org.dspace.authorize.service.AuthorizeService;
|
||||
import org.dspace.content.DSpaceObject;
|
||||
@@ -24,21 +26,19 @@ import org.dspace.eperson.service.EPersonService;
|
||||
import org.dspace.services.RequestService;
|
||||
import org.dspace.services.model.Request;
|
||||
import org.dspace.util.UUIDUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* DSpaceObjectPermissionEvaluatorPlugin will check persmissions based on the DSpace {@link AuthorizeService}.
|
||||
* DSpaceObjectPermissionEvaluatorPlugin will check permissions based on the DSpace {@link AuthorizeService}.
|
||||
* This service will validate if the authenticated user is allowed to perform an action on the given DSpace Object
|
||||
* based on the resource policies attached to that DSpace object.
|
||||
*/
|
||||
@Component
|
||||
public class AuthorizeServicePermissionEvaluatorPlugin extends RestObjectPermissionEvaluatorPlugin {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(AuthorizeServicePermissionEvaluatorPlugin.class);
|
||||
private static final Logger log = LogManager.getLogger();
|
||||
|
||||
@Autowired
|
||||
private AuthorizeService authorizeService;
|
||||
@@ -106,7 +106,7 @@ public class AuthorizeServicePermissionEvaluatorPlugin extends RestObjectPermiss
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
log.error(e::getMessage, e);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@@ -11,6 +11,8 @@ import java.io.Serializable;
|
||||
import java.sql.SQLException;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.app.rest.repository.BitstreamRestRepository;
|
||||
import org.dspace.app.rest.utils.ContextUtil;
|
||||
import org.dspace.app.rest.utils.DSpaceObjectUtils;
|
||||
@@ -24,8 +26,6 @@ import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.services.RequestService;
|
||||
import org.dspace.services.model.Request;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -39,7 +39,7 @@ import org.springframework.stereotype.Component;
|
||||
@Component
|
||||
public class BitstreamMetadataReadPermissionEvaluatorPlugin extends RestObjectPermissionEvaluatorPlugin {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(BitstreamMetadataReadPermissionEvaluatorPlugin.class);
|
||||
private static final Logger log = LogManager.getLogger();
|
||||
|
||||
@Autowired
|
||||
private RequestService requestService;
|
||||
@@ -66,7 +66,7 @@ public class BitstreamMetadataReadPermissionEvaluatorPlugin extends RestObjectPe
|
||||
return this.metadataReadPermissionOnBitstream(context, (Bitstream) dso);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
log.error(e::getMessage, e);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@@ -11,6 +11,8 @@ import java.io.Serializable;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.app.rest.model.ClaimedTaskRest;
|
||||
import org.dspace.app.rest.utils.ContextUtil;
|
||||
import org.dspace.core.Context;
|
||||
@@ -20,8 +22,6 @@ import org.dspace.services.RequestService;
|
||||
import org.dspace.services.model.Request;
|
||||
import org.dspace.xmlworkflow.storedcomponents.ClaimedTask;
|
||||
import org.dspace.xmlworkflow.storedcomponents.service.ClaimedTaskService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -29,13 +29,13 @@ import org.springframework.stereotype.Component;
|
||||
/**
|
||||
* An authenticated user is allowed to interact with a claimed task only if they own it
|
||||
* claim.
|
||||
*
|
||||
*
|
||||
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
||||
*/
|
||||
@Component
|
||||
public class ClaimedTaskRestPermissionEvaluatorPlugin extends RestObjectPermissionEvaluatorPlugin {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(ClaimedTaskRestPermissionEvaluatorPlugin.class);
|
||||
private static final Logger log = LogManager.getLogger();
|
||||
|
||||
@Autowired
|
||||
private RequestService requestService;
|
||||
@@ -74,7 +74,7 @@ public class ClaimedTaskRestPermissionEvaluatorPlugin extends RestObjectPermissi
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
log.error(e::getMessage, e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@@ -10,10 +10,10 @@ package org.dspace.app.rest.security;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.app.rest.utils.ContextUtil;
|
||||
import org.dspace.core.Context;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.web.authentication.logout.LogoutHandler;
|
||||
@@ -28,7 +28,7 @@ import org.springframework.stereotype.Component;
|
||||
@Component
|
||||
public class CustomLogoutHandler implements LogoutHandler {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(CustomLogoutHandler.class);
|
||||
private static final Logger log = LogManager.getLogger();
|
||||
|
||||
@Autowired
|
||||
private RestAuthenticationService restAuthenticationService;
|
||||
@@ -40,6 +40,7 @@ public class CustomLogoutHandler implements LogoutHandler {
|
||||
* @param httpServletResponse
|
||||
* @param authentication
|
||||
*/
|
||||
@Override
|
||||
public void logout(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse,
|
||||
Authentication authentication) {
|
||||
try {
|
||||
|
@@ -12,6 +12,8 @@ import java.sql.SQLException;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.app.rest.utils.ContextUtil;
|
||||
import org.dspace.app.rest.utils.DSpaceObjectUtils;
|
||||
import org.dspace.authorize.service.AuthorizeService;
|
||||
@@ -19,20 +21,19 @@ import org.dspace.content.DSpaceObject;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.services.RequestService;
|
||||
import org.dspace.services.model.Request;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* {@link RestPermissionEvaluatorPlugin} class that evaluate admin permission against a generic DSpace Object
|
||||
*
|
||||
* {@link RestPermissionEvaluatorPlugin} class that evaluate admin permission against a generic DSpace Object.
|
||||
*
|
||||
* @author Mykhaylo Boychuk (4science.it)
|
||||
*/
|
||||
@Component
|
||||
public class DSpaceObjectAdminPermissionEvaluatorPlugin extends RestObjectPermissionEvaluatorPlugin {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(DSpaceObjectAdminPermissionEvaluatorPlugin.class);
|
||||
private static final Logger log = LogManager.getLogger();
|
||||
|
||||
public static final String DSPACE_OBJECT = "dspaceObject";
|
||||
|
||||
@@ -64,7 +65,7 @@ public class DSpaceObjectAdminPermissionEvaluatorPlugin extends RestObjectPermis
|
||||
DSpaceObject dso = dspaceObjectUtil.findDSpaceObject(context, dsoUuid);
|
||||
return authorizeService.isAdmin(context, dso);
|
||||
} catch (SQLException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
log.error(e::getMessage, e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@@ -19,6 +19,8 @@ import javax.annotation.PostConstruct;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.app.rest.login.PostLoggedInAction;
|
||||
import org.dspace.app.rest.utils.ContextUtil;
|
||||
import org.dspace.authenticate.AuthenticationMethod;
|
||||
@@ -28,8 +30,6 @@ import org.dspace.core.Context;
|
||||
import org.dspace.core.LogHelper;
|
||||
import org.dspace.eperson.EPerson;
|
||||
import org.dspace.services.RequestService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.authentication.AuthenticationProvider;
|
||||
import org.springframework.security.authentication.BadCredentialsException;
|
||||
@@ -40,7 +40,7 @@ import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* This class is responsible for authenticating a user via REST
|
||||
* This class is responsible for authenticating a user via REST.
|
||||
*
|
||||
* @author Frederic Van Reet (frederic dot vanreet at atmire dot com)
|
||||
* @author Tom Desair (tom dot desair at atmire dot com)
|
||||
@@ -48,7 +48,7 @@ import org.springframework.stereotype.Component;
|
||||
@Component
|
||||
public class EPersonRestAuthenticationProvider implements AuthenticationProvider {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(EPersonRestAuthenticationProvider.class);
|
||||
private static final Logger log = LogManager.getLogger();
|
||||
|
||||
public static final String MANAGE_ACCESS_GROUP = "MANAGE_ACCESS_GROUP";
|
||||
|
||||
@@ -144,9 +144,8 @@ public class EPersonRestAuthenticationProvider implements AuthenticationProvider
|
||||
}
|
||||
|
||||
} else {
|
||||
log.info(LogHelper.getHeader(newContext, "failed_login", "email="
|
||||
+ name + ", result="
|
||||
+ authenticateResult));
|
||||
log.info(LogHelper.getHeader(newContext, "failed_login",
|
||||
"email={}, result={}"), name, authenticateResult);
|
||||
throw new BadCredentialsException("Login failed");
|
||||
}
|
||||
}
|
||||
@@ -155,7 +154,7 @@ public class EPersonRestAuthenticationProvider implements AuthenticationProvider
|
||||
try {
|
||||
newContext.complete();
|
||||
} catch (SQLException e) {
|
||||
log.error(e.getMessage() + " occurred while trying to close", e);
|
||||
log.error("{} occurred while trying to close", e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -182,7 +181,7 @@ public class EPersonRestAuthenticationProvider implements AuthenticationProvider
|
||||
return new DSpaceAuthentication(ePerson, getGrantedAuthorities(context));
|
||||
|
||||
} else {
|
||||
log.info(LogHelper.getHeader(context, "failed_login", "No eperson with an non-blank e-mail address found"));
|
||||
log.info(LogHelper.getHeader(context, "failed_login", "No eperson with a non-blank e-mail address found"));
|
||||
throw new BadCredentialsException("Login failed");
|
||||
}
|
||||
}
|
||||
|
@@ -14,6 +14,8 @@ import java.util.UUID;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.app.rest.model.patch.Operation;
|
||||
import org.dspace.app.rest.model.patch.Patch;
|
||||
import org.dspace.app.rest.repository.patch.operation.DSpaceObjectMetadataPatchUtils;
|
||||
@@ -27,8 +29,6 @@ import org.dspace.core.Context;
|
||||
import org.dspace.eperson.EPerson;
|
||||
import org.dspace.services.RequestService;
|
||||
import org.dspace.services.model.Request;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -40,7 +40,7 @@ import org.springframework.stereotype.Component;
|
||||
@Component
|
||||
public class EPersonRestPermissionEvaluatorPlugin extends RestObjectPermissionEvaluatorPlugin {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(EPersonRestPermissionEvaluatorPlugin.class);
|
||||
private static final Logger log = LogManager.getLogger();
|
||||
|
||||
@Autowired
|
||||
AuthorizeService authorizeService;
|
||||
@@ -84,7 +84,7 @@ public class EPersonRestPermissionEvaluatorPlugin extends RestObjectPermissionEv
|
||||
return true;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
log.error(e::getMessage, e);
|
||||
}
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ public class EPersonRestPermissionEvaluatorPlugin extends RestObjectPermissionEv
|
||||
Request currentRequest = requestService.getCurrentRequest();
|
||||
if (currentRequest != null) {
|
||||
HttpServletRequest httpServletRequest = currentRequest.getHttpServletRequest();
|
||||
if (operations.size() > 0
|
||||
if (!operations.isEmpty()
|
||||
&& StringUtils.equalsIgnoreCase(operations.get(0).getOp(), PatchOperation.OPERATION_ADD)
|
||||
&& StringUtils.equalsIgnoreCase(operations.get(0).getPath(),
|
||||
EPersonPasswordAddOperation.OPERATION_PASSWORD_CHANGE)
|
||||
|
@@ -11,6 +11,8 @@ import java.io.Serializable;
|
||||
import java.sql.SQLException;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.app.rest.utils.ContextUtil;
|
||||
import org.dspace.app.util.AuthorizeUtil;
|
||||
import org.dspace.authorize.service.AuthorizeService;
|
||||
@@ -22,8 +24,6 @@ import org.dspace.eperson.service.EPersonService;
|
||||
import org.dspace.eperson.service.GroupService;
|
||||
import org.dspace.services.RequestService;
|
||||
import org.dspace.services.model.Request;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -35,7 +35,7 @@ import org.springframework.stereotype.Component;
|
||||
@Component
|
||||
public class GroupRestPermissionEvaluatorPlugin extends RestObjectPermissionEvaluatorPlugin {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(GroupRestPermissionEvaluatorPlugin.class);
|
||||
private static final Logger log = LogManager.getLogger();
|
||||
|
||||
@Autowired
|
||||
private RequestService requestService;
|
||||
@@ -87,7 +87,7 @@ public class GroupRestPermissionEvaluatorPlugin extends RestObjectPermissionEval
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
log.error(e::getMessage, e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@@ -11,6 +11,8 @@ import java.io.Serializable;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.app.rest.utils.ContextUtil;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.content.service.ItemService;
|
||||
@@ -22,21 +24,19 @@ import org.dspace.orcid.service.OrcidHistoryService;
|
||||
import org.dspace.orcid.service.OrcidQueueService;
|
||||
import org.dspace.services.RequestService;
|
||||
import org.dspace.services.model.Request;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* Class that evaluate DELETE and READ permissions
|
||||
*
|
||||
*
|
||||
* @author Mykhaylo Boychuk (mykhaylo.boychuk at 4science.it)
|
||||
*/
|
||||
@Component
|
||||
public class OrcidQueueAndHistoryRestPermissionEvaluatorPlugin extends RestObjectPermissionEvaluatorPlugin {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(OrcidQueueAndHistoryRestPermissionEvaluatorPlugin.class);
|
||||
private static final Logger log = LogManager.getLogger();
|
||||
|
||||
public static final String ORCID_QUEUE = "ORCID_QUEUE";
|
||||
public static final String ORCID_HISTORY = "ORCID_HISTORY";
|
||||
@@ -97,7 +97,7 @@ public class OrcidQueueAndHistoryRestPermissionEvaluatorPlugin extends RestObjec
|
||||
.anyMatch(authority -> currentUser.getID().toString().equals(authority));
|
||||
|
||||
} catch (SQLException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
log.error(e::getMessage, e);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@@ -13,6 +13,8 @@ import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.app.rest.utils.ContextUtil;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.content.MetadataValue;
|
||||
@@ -21,8 +23,6 @@ import org.dspace.core.Context;
|
||||
import org.dspace.eperson.EPerson;
|
||||
import org.dspace.services.RequestService;
|
||||
import org.dspace.services.model.Request;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -36,7 +36,7 @@ import org.springframework.stereotype.Component;
|
||||
@Component
|
||||
public class OrcidQueueSearchRestPermissionEvaluatorPlugin extends RestObjectPermissionEvaluatorPlugin {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(OrcidQueueAndHistoryRestPermissionEvaluatorPlugin.class);
|
||||
private static final Logger log = LogManager.getLogger();
|
||||
|
||||
public static final String ORCID_QUEUE_SEARCH = "ORCID_QUEUE_SEARCH";
|
||||
|
||||
@@ -75,7 +75,7 @@ public class OrcidQueueSearchRestPermissionEvaluatorPlugin extends RestObjectPer
|
||||
return true;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
log.error(e::getMessage, e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@@ -12,6 +12,8 @@ import java.io.Serializable;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.app.rest.model.PoolTaskRest;
|
||||
import org.dspace.app.rest.utils.ContextUtil;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
@@ -23,8 +25,6 @@ import org.dspace.services.model.Request;
|
||||
import org.dspace.xmlworkflow.storedcomponents.PoolTask;
|
||||
import org.dspace.xmlworkflow.storedcomponents.XmlWorkflowItem;
|
||||
import org.dspace.xmlworkflow.storedcomponents.service.PoolTaskService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -37,7 +37,7 @@ import org.springframework.stereotype.Component;
|
||||
@Component
|
||||
public class PoolTaskRestPermissionEvaluatorPlugin extends RestObjectPermissionEvaluatorPlugin {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(PoolTaskRestPermissionEvaluatorPlugin.class);
|
||||
private static final Logger log = LogManager.getLogger();
|
||||
|
||||
@Autowired
|
||||
private RequestService requestService;
|
||||
@@ -79,7 +79,7 @@ public class PoolTaskRestPermissionEvaluatorPlugin extends RestObjectPermissionE
|
||||
return true;
|
||||
}
|
||||
} catch (SQLException | AuthorizeException | IOException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
log.error(e::getMessage, e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@@ -11,6 +11,8 @@ import java.io.Serializable;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.app.rest.model.ProcessRest;
|
||||
import org.dspace.app.rest.utils.ContextUtil;
|
||||
import org.dspace.authorize.service.AuthorizeService;
|
||||
@@ -19,8 +21,6 @@ import org.dspace.scripts.Process;
|
||||
import org.dspace.scripts.service.ProcessService;
|
||||
import org.dspace.services.RequestService;
|
||||
import org.dspace.services.model.Request;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -33,7 +33,7 @@ import org.springframework.stereotype.Component;
|
||||
@Component
|
||||
public class ProcessRestPermissionEvaluatorPlugin extends RestObjectPermissionEvaluatorPlugin {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(ProcessRestPermissionEvaluatorPlugin.class);
|
||||
private static final Logger log = LogManager.getLogger();
|
||||
|
||||
@Autowired
|
||||
private RequestService requestService;
|
||||
@@ -66,7 +66,7 @@ public class ProcessRestPermissionEvaluatorPlugin extends RestObjectPermissionEv
|
||||
return true;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
log.error(e::getMessage, e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@@ -11,6 +11,8 @@ import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.app.rest.model.QAEventRest;
|
||||
import org.dspace.app.rest.utils.ContextUtil;
|
||||
import org.dspace.content.QAEvent;
|
||||
@@ -19,8 +21,6 @@ import org.dspace.qaevent.service.QAEventSecurityService;
|
||||
import org.dspace.qaevent.service.QAEventService;
|
||||
import org.dspace.services.RequestService;
|
||||
import org.dspace.services.model.Request;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -33,7 +33,7 @@ import org.springframework.stereotype.Component;
|
||||
@Component
|
||||
public class QAEventRestPermissionEvaluatorPlugin extends RestObjectPermissionEvaluatorPlugin {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(QAEventRestPermissionEvaluatorPlugin.class);
|
||||
private static final Logger log = LogManager.getLogger();
|
||||
|
||||
@Autowired
|
||||
private QAEventService qaEventService;
|
||||
|
@@ -11,6 +11,8 @@ import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.app.rest.model.QASourceRest;
|
||||
import org.dspace.app.rest.model.QATopicRest;
|
||||
import org.dspace.app.rest.utils.ContextUtil;
|
||||
@@ -19,8 +21,6 @@ import org.dspace.qaevent.QATopic;
|
||||
import org.dspace.qaevent.service.QAEventSecurityService;
|
||||
import org.dspace.services.RequestService;
|
||||
import org.dspace.services.model.Request;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -33,7 +33,7 @@ import org.springframework.stereotype.Component;
|
||||
@Component
|
||||
public class QASourceRestPermissionEvaluatorPlugin extends RestObjectPermissionEvaluatorPlugin {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(QASourceRestPermissionEvaluatorPlugin.class);
|
||||
private static final Logger log = LogManager.getLogger();
|
||||
|
||||
@Autowired
|
||||
private QAEventSecurityService qaEventSecurityService;
|
||||
|
@@ -11,6 +11,8 @@ import java.io.Serializable;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.app.rest.authorization.AuthorizationRestUtil;
|
||||
import org.dspace.app.rest.model.AuthorizationRest;
|
||||
import org.dspace.app.rest.utils.ContextUtil;
|
||||
@@ -19,21 +21,19 @@ import org.dspace.core.Context;
|
||||
import org.dspace.eperson.EPerson;
|
||||
import org.dspace.services.RequestService;
|
||||
import org.dspace.services.model.Request;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* {@link RestPermissionEvaluatorPlugin} class that evaluate READ permissions for an Authorization
|
||||
*
|
||||
*
|
||||
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
||||
*/
|
||||
@Component
|
||||
public class ReadAuthorizationPermissionEvaluatorPlugin extends RestObjectPermissionEvaluatorPlugin {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(ReadAuthorizationPermissionEvaluatorPlugin.class);
|
||||
private static final Logger log = LogManager.getLogger();
|
||||
|
||||
@Autowired
|
||||
AuthorizeService authorizeService;
|
||||
@@ -75,7 +75,7 @@ public class ReadAuthorizationPermissionEvaluatorPlugin extends RestObjectPermis
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
log.error(e::getMessage, e);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@@ -11,6 +11,8 @@ import java.io.Serializable;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.app.rest.model.ResourcePolicyRest;
|
||||
import org.dspace.app.rest.utils.ContextUtil;
|
||||
import org.dspace.authorize.ResourcePolicy;
|
||||
@@ -20,8 +22,6 @@ import org.dspace.content.DSpaceObject;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.services.RequestService;
|
||||
import org.dspace.services.model.Request;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.rest.webmvc.ResourceNotFoundException;
|
||||
import org.springframework.security.core.Authentication;
|
||||
@@ -36,7 +36,7 @@ import org.springframework.stereotype.Component;
|
||||
@Component
|
||||
public class ResourcePolicyAdminPermissionEvalutatorPlugin extends RestObjectPermissionEvaluatorPlugin {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(ResourcePolicyRestPermissionEvaluatorPlugin.class);
|
||||
private static final Logger log = LogManager.getLogger();
|
||||
|
||||
public static final String RESOURCE_POLICY_PATCH = "resourcepolicy";
|
||||
|
||||
@@ -74,7 +74,7 @@ public class ResourcePolicyAdminPermissionEvalutatorPlugin extends RestObjectPer
|
||||
DSpaceObject dso = resourcePolicy.getdSpaceObject();
|
||||
return authorizeService.isAdmin(context, dso);
|
||||
} catch (SQLException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
log.error(e::getMessage, e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@@ -11,6 +11,8 @@ import java.io.Serializable;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.app.rest.model.ResourcePolicyRest;
|
||||
import org.dspace.app.rest.utils.ContextUtil;
|
||||
import org.dspace.authorize.service.AuthorizeService;
|
||||
@@ -20,21 +22,19 @@ import org.dspace.eperson.EPerson;
|
||||
import org.dspace.eperson.service.EPersonService;
|
||||
import org.dspace.services.RequestService;
|
||||
import org.dspace.services.model.Request;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* {@link RestPermissionEvaluatorPlugin} class that evaluate READ, WRITE and DELETE permissions over a ResourcePolicy
|
||||
*
|
||||
* {@link RestPermissionEvaluatorPlugin} class that evaluate READ, WRITE and DELETE permissions over a ResourcePolicy.
|
||||
*
|
||||
* @author Mykhaylo Boychuk (4science.it)
|
||||
*/
|
||||
@Component
|
||||
public class ResourcePolicyRestPermissionEvaluatorPlugin extends RestObjectPermissionEvaluatorPlugin {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(ResourcePolicyRestPermissionEvaluatorPlugin.class);
|
||||
private static final Logger log = LogManager.getLogger();
|
||||
|
||||
@Autowired
|
||||
AuthorizeService authorizeService;
|
||||
@@ -78,7 +78,7 @@ public class ResourcePolicyRestPermissionEvaluatorPlugin extends RestObjectPermi
|
||||
return true;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
log.error(e::getMessage, e);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@@ -16,6 +16,8 @@ import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.app.rest.utils.ContextUtil;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.authorize.factory.AuthorizeServiceFactory;
|
||||
@@ -28,8 +30,6 @@ import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.RequestService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
import org.dspace.util.UUIDUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.security.access.AccessDeniedException;
|
||||
import org.springframework.security.authentication.AuthenticationManager;
|
||||
import org.springframework.security.core.Authentication;
|
||||
@@ -47,21 +47,24 @@ import org.springframework.security.web.authentication.www.BasicAuthenticationFi
|
||||
*/
|
||||
public class StatelessAuthenticationFilter extends BasicAuthenticationFilter {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(StatelessAuthenticationFilter.class);
|
||||
private static final Logger log = LogManager.getLogger();
|
||||
|
||||
private static final String ON_BEHALF_OF_REQUEST_PARAM = "X-On-Behalf-Of";
|
||||
|
||||
private RestAuthenticationService restAuthenticationService;
|
||||
private final RestAuthenticationService restAuthenticationService;
|
||||
|
||||
private EPersonRestAuthenticationProvider authenticationProvider;
|
||||
private final EPersonRestAuthenticationProvider authenticationProvider;
|
||||
|
||||
private RequestService requestService;
|
||||
private final RequestService requestService;
|
||||
|
||||
private AuthorizeService authorizeService = AuthorizeServiceFactory.getInstance().getAuthorizeService();
|
||||
private final AuthorizeService authorizeService
|
||||
= AuthorizeServiceFactory.getInstance().getAuthorizeService();
|
||||
|
||||
private EPersonService ePersonService = EPersonServiceFactory.getInstance().getEPersonService();
|
||||
private final EPersonService ePersonService
|
||||
= EPersonServiceFactory.getInstance().getEPersonService();
|
||||
|
||||
private ConfigurationService configurationService = DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||
private final ConfigurationService configurationService
|
||||
= DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||
|
||||
public StatelessAuthenticationFilter(AuthenticationManager authenticationManager,
|
||||
RestAuthenticationService restAuthenticationService,
|
||||
@@ -124,7 +127,7 @@ public class StatelessAuthenticationFilter extends BasicAuthenticationFilter {
|
||||
// parse the token.
|
||||
EPerson eperson = restAuthenticationService.getAuthenticatedEPerson(request, res, context);
|
||||
if (eperson != null) {
|
||||
log.debug("Found authentication data in request for EPerson {}", eperson.getEmail());
|
||||
log.debug("Found authentication data in request for EPerson {}", eperson::getEmail);
|
||||
//Pass the eperson ID to the request service
|
||||
requestService.setCurrentUserId(eperson.getID());
|
||||
|
||||
@@ -174,7 +177,7 @@ public class StatelessAuthenticationFilter extends BasicAuthenticationFilter {
|
||||
requestService.setCurrentUserId(epersonUuid);
|
||||
context.switchContextUser(onBehalfOfEPerson);
|
||||
log.debug("Found 'on-behalf-of' authentication data in request for EPerson {}",
|
||||
onBehalfOfEPerson.getEmail());
|
||||
onBehalfOfEPerson::getEmail);
|
||||
return new DSpaceAuthentication(onBehalfOfEPerson,
|
||||
authenticationProvider.getGrantedAuthorities(context));
|
||||
} else {
|
||||
|
@@ -13,8 +13,8 @@ import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.security.authentication.AuthenticationManager;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.AuthenticationException;
|
||||
@@ -23,7 +23,7 @@ import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
|
||||
|
||||
/**
|
||||
* This class will filter /api/authn/login requests to try and authenticate them. Keep in mind, this filter runs *after*
|
||||
* StatelessAuthenticationFilter (which looks for authentication data in the request itself). So, in some scenarios
|
||||
* {@link StatelessAuthenticationFilter} (which looks for authentication data in the request itself). So, in some scenarios
|
||||
* (e.g. after a Shibboleth login) the StatelessAuthenticationFilter does the actual authentication, and this Filter
|
||||
* just ensures the auth token (JWT) is sent back in an Authorization header.
|
||||
*
|
||||
@@ -31,7 +31,7 @@ import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
|
||||
* @author Tom Desair (tom dot desair at atmire dot com)
|
||||
*/
|
||||
public class StatelessLoginFilter extends AbstractAuthenticationProcessingFilter {
|
||||
private static final Logger log = LoggerFactory.getLogger(StatelessLoginFilter.class);
|
||||
private static final Logger log = LogManager.getLogger();
|
||||
|
||||
protected AuthenticationManager authenticationManager;
|
||||
|
||||
@@ -97,7 +97,7 @@ public class StatelessLoginFilter extends AbstractAuthenticationProcessingFilter
|
||||
Authentication auth) throws IOException, ServletException {
|
||||
|
||||
DSpaceAuthentication dSpaceAuthentication = (DSpaceAuthentication) auth;
|
||||
log.debug("Authentication successful for EPerson {}", dSpaceAuthentication.getName());
|
||||
log.debug("Authentication successful for EPerson {}", dSpaceAuthentication::getName);
|
||||
restAuthenticationService.addAuthenticationDataForUser(req, res, dSpaceAuthentication, false);
|
||||
}
|
||||
|
||||
|
@@ -17,6 +17,8 @@ import java.sql.SQLException;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.app.rest.utils.ContextUtil;
|
||||
import org.dspace.authorize.service.AuthorizeService;
|
||||
import org.dspace.core.Context;
|
||||
@@ -25,21 +27,19 @@ import org.dspace.eperson.Subscription;
|
||||
import org.dspace.eperson.service.SubscribeService;
|
||||
import org.dspace.services.RequestService;
|
||||
import org.dspace.services.model.Request;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* {@link RestPermissionEvaluatorPlugin} class that evaluate READ, WRITE and DELETE permissions over a Subscription
|
||||
*
|
||||
*
|
||||
* @author Mykhaylo Boychuk (mykhaylo.boychuk at 4science.com)
|
||||
*/
|
||||
@Component
|
||||
public class SubscriptionRestPermissionEvaluatorPlugin extends RestObjectPermissionEvaluatorPlugin {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(SubscriptionRestPermissionEvaluatorPlugin.class);
|
||||
private static final Logger log = LogManager.getLogger();
|
||||
|
||||
@Autowired
|
||||
private RequestService requestService;
|
||||
@@ -76,7 +76,7 @@ public class SubscriptionRestPermissionEvaluatorPlugin extends RestObjectPermiss
|
||||
Subscription subscription = subscribeService.findById(context, Integer.parseInt(targetId.toString()));
|
||||
return Objects.nonNull(subscription) ? currentUser.equals(subscription.getEPerson()) : false;
|
||||
} catch (SQLException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
log.error(e::getMessage, e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@@ -12,6 +12,8 @@ import java.sql.SQLException;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.app.rest.model.TemplateItemRest;
|
||||
import org.dspace.app.rest.utils.ContextUtil;
|
||||
import org.dspace.authorize.service.AuthorizeService;
|
||||
@@ -21,8 +23,6 @@ import org.dspace.core.Context;
|
||||
import org.dspace.eperson.EPerson;
|
||||
import org.dspace.services.RequestService;
|
||||
import org.dspace.services.model.Request;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -35,7 +35,7 @@ import org.springframework.stereotype.Component;
|
||||
@Component
|
||||
public class TemplateItemRestPermissionEvaluatorPlugin extends RestObjectPermissionEvaluatorPlugin {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(TemplateItemRestPermissionEvaluatorPlugin.class);
|
||||
private static final Logger log = LogManager.getLogger();
|
||||
|
||||
@Autowired
|
||||
private RequestService requestService;
|
||||
@@ -76,7 +76,7 @@ public class TemplateItemRestPermissionEvaluatorPlugin extends RestObjectPermiss
|
||||
return true;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
log.error(e::getMessage, e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@@ -13,6 +13,8 @@ import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.app.rest.model.UsageReportRest;
|
||||
import org.dspace.app.rest.utils.ContextUtil;
|
||||
import org.dspace.app.rest.utils.DSpaceObjectUtils;
|
||||
@@ -22,8 +24,6 @@ import org.dspace.core.Context;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.RequestService;
|
||||
import org.dspace.services.model.Request;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -36,7 +36,7 @@ import org.springframework.stereotype.Component;
|
||||
@Component
|
||||
public class UsageReportRestPermissionEvaluatorPlugin extends RestObjectPermissionEvaluatorPlugin {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(UsageReportRestPermissionEvaluatorPlugin.class);
|
||||
private static final Logger log = LogManager.getLogger();
|
||||
|
||||
@Autowired
|
||||
private ConfigurationService configurationService;
|
||||
@@ -95,7 +95,7 @@ public class UsageReportRestPermissionEvaluatorPlugin extends RestObjectPermissi
|
||||
}
|
||||
return authorizeService.authorizeActionBoolean(context, dso, restPermission.getDspaceApiActionId());
|
||||
} catch (SQLException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
log.error(e::getMessage, e);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@@ -11,6 +11,8 @@ import java.io.Serializable;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.app.rest.model.VersionHistoryRest;
|
||||
import org.dspace.app.rest.utils.ContextUtil;
|
||||
import org.dspace.authorize.service.AuthorizeService;
|
||||
@@ -18,8 +20,6 @@ import org.dspace.core.Context;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.RequestService;
|
||||
import org.dspace.services.model.Request;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -31,7 +31,7 @@ import org.springframework.stereotype.Component;
|
||||
@Component
|
||||
public class VersionHistoryRestPermissionEvaluatorPlugin extends RestObjectPermissionEvaluatorPlugin {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(VersionHistoryRestPermissionEvaluatorPlugin.class);
|
||||
private static final Logger log = LogManager.getLogger();
|
||||
|
||||
@Autowired
|
||||
private RequestService requestService;
|
||||
@@ -62,7 +62,7 @@ public class VersionHistoryRestPermissionEvaluatorPlugin extends RestObjectPermi
|
||||
}
|
||||
return true;
|
||||
} catch (SQLException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
log.error(e::getMessage, e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@@ -6,11 +6,14 @@
|
||||
* http://www.dspace.org/license/
|
||||
*/
|
||||
package org.dspace.app.rest.security;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.sql.SQLException;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.app.rest.model.VersionRest;
|
||||
import org.dspace.app.rest.utils.ContextUtil;
|
||||
import org.dspace.authorize.service.AuthorizeService;
|
||||
@@ -19,21 +22,19 @@ import org.dspace.services.RequestService;
|
||||
import org.dspace.services.model.Request;
|
||||
import org.dspace.versioning.Version;
|
||||
import org.dspace.versioning.service.VersioningService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* This class evaluate ADMIN permissions to patch operation over a Version.
|
||||
*
|
||||
*
|
||||
* @author Mykhaylo Boychuk (mykhaylo.boychuk at 4science.it)
|
||||
*/
|
||||
@Component
|
||||
public class VersionRestPatchPermissionEvaluatorPlugin extends RestObjectPermissionEvaluatorPlugin {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(VersionRestPatchPermissionEvaluatorPlugin.class);
|
||||
private static final Logger log = LogManager.getLogger();
|
||||
|
||||
@Autowired
|
||||
private RequestService requestService;
|
||||
@@ -78,7 +79,7 @@ public class VersionRestPatchPermissionEvaluatorPlugin extends RestObjectPermiss
|
||||
return true;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
log.error(e::getMessage, e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@@ -12,6 +12,8 @@ import java.sql.SQLException;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.app.rest.model.VersionRest;
|
||||
import org.dspace.app.rest.utils.ContextUtil;
|
||||
import org.dspace.authorize.service.AuthorizeService;
|
||||
@@ -21,20 +23,18 @@ import org.dspace.services.RequestService;
|
||||
import org.dspace.services.model.Request;
|
||||
import org.dspace.versioning.Version;
|
||||
import org.dspace.versioning.service.VersioningService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* This class acts as a PermissionEvaluator to decide whether a given request to a Versioning endpoint is allowed to
|
||||
* pass through or not
|
||||
* pass through or not.
|
||||
*/
|
||||
@Component
|
||||
public class VersionRestPermissionEvaluatorPlugin extends RestObjectPermissionEvaluatorPlugin {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(VersionRestPermissionEvaluatorPlugin.class);
|
||||
private static final Logger log = LogManager.getLogger();
|
||||
|
||||
@Autowired
|
||||
private RequestService requestService;
|
||||
@@ -77,7 +77,7 @@ public class VersionRestPermissionEvaluatorPlugin extends RestObjectPermissionEv
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
log.error(e::getMessage, e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@@ -12,6 +12,8 @@ import java.io.Serializable;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.app.rest.model.WorkflowItemRest;
|
||||
import org.dspace.app.rest.utils.ContextUtil;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
@@ -25,8 +27,6 @@ import org.dspace.xmlworkflow.storedcomponents.XmlWorkflowItem;
|
||||
import org.dspace.xmlworkflow.storedcomponents.service.ClaimedTaskService;
|
||||
import org.dspace.xmlworkflow.storedcomponents.service.PoolTaskService;
|
||||
import org.dspace.xmlworkflow.storedcomponents.service.XmlWorkflowItemService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -34,13 +34,13 @@ import org.springframework.stereotype.Component;
|
||||
/**
|
||||
* An authenticated user is allowed to interact with workflow item only if they belong to a task that they own or could
|
||||
* claim.
|
||||
*
|
||||
*
|
||||
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
||||
*/
|
||||
@Component
|
||||
public class WorkflowRestPermissionEvaluatorPlugin extends RestObjectPermissionEvaluatorPlugin {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(WorkflowRestPermissionEvaluatorPlugin.class);
|
||||
private static final Logger log = LogManager.getLogger();
|
||||
|
||||
@Autowired
|
||||
private RequestService requestService;
|
||||
@@ -99,7 +99,7 @@ public class WorkflowRestPermissionEvaluatorPlugin extends RestObjectPermissionE
|
||||
}
|
||||
|
||||
} catch (SQLException | AuthorizeException | IOException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
log.error(e::getMessage, e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@@ -11,6 +11,8 @@ import java.io.Serializable;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.app.rest.model.WorkspaceItemRest;
|
||||
import org.dspace.app.rest.utils.ContextUtil;
|
||||
import org.dspace.authorize.service.AuthorizeService;
|
||||
@@ -21,21 +23,19 @@ import org.dspace.eperson.EPerson;
|
||||
import org.dspace.services.RequestService;
|
||||
import org.dspace.services.model.Request;
|
||||
import org.dspace.supervision.service.SupervisionOrderService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* {@link RestPermissionEvaluatorPlugin} class that evaluate READ, WRITE and DELETE permissions over a WorkspaceItem
|
||||
*
|
||||
* {@link RestPermissionEvaluatorPlugin} class that evaluate READ, WRITE and DELETE permissions over a WorkspaceItem.
|
||||
*
|
||||
* @author Mykhaylo Boychuk (mykhaylo.boychuk at 4science.it)
|
||||
*/
|
||||
@Component
|
||||
public class WorkspaceItemRestPermissionEvaluatorPlugin extends RestObjectPermissionEvaluatorPlugin {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(WorkspaceItemRestPermissionEvaluatorPlugin.class);
|
||||
private static final Logger log = LogManager.getLogger();
|
||||
|
||||
@Autowired
|
||||
private RequestService requestService;
|
||||
@@ -100,7 +100,7 @@ public class WorkspaceItemRestPermissionEvaluatorPlugin extends RestObjectPermis
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
log.error(e::getMessage, e);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@@ -12,10 +12,10 @@ import java.text.ParseException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import com.nimbusds.jwt.JWTClaimsSet;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.authenticate.service.AuthenticationService;
|
||||
import org.dspace.core.Context;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -27,15 +27,17 @@ public class AuthenticationMethodClaimProvider implements JWTClaimProvider {
|
||||
|
||||
public static final String AUTHENTICATION_METHOD = "authenticationMethod";
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(AuthenticationMethodClaimProvider.class);
|
||||
private static final Logger log = LogManager.getLogger();
|
||||
|
||||
@Autowired
|
||||
private AuthenticationService authenticationService;
|
||||
|
||||
@Override
|
||||
public String getKey() {
|
||||
return AUTHENTICATION_METHOD;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue(final Context context, final HttpServletRequest request) {
|
||||
if (context.getAuthenticationMethod() != null) {
|
||||
return context.getAuthenticationMethod();
|
||||
@@ -43,12 +45,13 @@ public class AuthenticationMethodClaimProvider implements JWTClaimProvider {
|
||||
return authenticationService.getAuthenticationMethod(context, request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parseClaim(final Context context, final HttpServletRequest request, final JWTClaimsSet jwtClaimsSet)
|
||||
throws SQLException {
|
||||
try {
|
||||
context.setAuthenticationMethod(jwtClaimsSet.getStringClaim(AUTHENTICATION_METHOD));
|
||||
} catch (ParseException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
log.error(e::getMessage, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -33,14 +33,14 @@ import com.nimbusds.jwt.SignedJWT;
|
||||
import com.nimbusds.jwt.util.DateUtils;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.eperson.EPerson;
|
||||
import org.dspace.eperson.service.EPersonService;
|
||||
import org.dspace.service.ClientInfoService;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.AccessDeniedException;
|
||||
import org.springframework.security.crypto.keygen.BytesKeyGenerator;
|
||||
@@ -59,7 +59,7 @@ public abstract class JWTTokenHandler {
|
||||
private static final int MAX_CLOCK_SKEW_SECONDS = 60;
|
||||
private static final String AUTHORIZATION_TOKEN_PARAMETER = "authentication-token";
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(JWTTokenHandler.class);
|
||||
private static final Logger log = LogManager.getLogger();
|
||||
|
||||
@Autowired
|
||||
private List<JWTClaimProvider> jwtClaimProviders;
|
||||
@@ -135,7 +135,7 @@ public abstract class JWTTokenHandler {
|
||||
// As long as the JWT is valid, parse all claims and return the EPerson
|
||||
if (isValidToken(request, signedJWT, jwtClaimsSet, ePerson)) {
|
||||
|
||||
log.debug("Received valid token for username: " + ePerson.getEmail());
|
||||
log.debug("Received valid token for username: {}", ePerson::getEmail);
|
||||
|
||||
for (JWTClaimProvider jwtClaimProvider : jwtClaimProviders) {
|
||||
jwtClaimProvider.parseClaim(context, request, jwtClaimsSet);
|
||||
@@ -143,7 +143,7 @@ public abstract class JWTTokenHandler {
|
||||
|
||||
return ePerson;
|
||||
} else {
|
||||
log.warn(getIpAddress(request) + " tried to use an expired or non-valid token");
|
||||
log.warn("{} tried to use an expired or non-valid token", getIpAddress(request));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -155,7 +155,8 @@ public abstract class JWTTokenHandler {
|
||||
* @param request current Request
|
||||
* @param previousLoginDate date of last login (before this one)
|
||||
* @return string version of signed JWT
|
||||
* @throws JOSEException
|
||||
* @throws JOSEException passed through.
|
||||
* @throws SQLException passed through.
|
||||
*/
|
||||
public String createTokenForEPerson(Context context, HttpServletRequest request, Date previousLoginDate)
|
||||
throws JOSEException, SQLException {
|
||||
|
@@ -18,6 +18,8 @@ import javax.ws.rs.core.HttpHeaders;
|
||||
|
||||
import com.nimbusds.jose.JOSEException;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.app.rest.model.wrapper.AuthenticationToken;
|
||||
import org.dspace.app.rest.security.DSpaceAuthentication;
|
||||
import org.dspace.app.rest.security.RestAuthenticationService;
|
||||
@@ -27,8 +29,6 @@ import org.dspace.authenticate.service.AuthenticationService;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.eperson.EPerson;
|
||||
import org.dspace.eperson.service.EPersonService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
@@ -47,7 +47,7 @@ import org.springframework.stereotype.Component;
|
||||
@Component
|
||||
public class JWTTokenRestAuthenticationServiceImpl implements RestAuthenticationService, InitializingBean {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(RestAuthenticationService.class);
|
||||
private static final Logger log = LogManager.getLogger();
|
||||
private static final String AUTHORIZATION_COOKIE = "Authorization-cookie";
|
||||
private static final String AUTHORIZATION_HEADER = "Authorization";
|
||||
private static final String AUTHORIZATION_TYPE = "Bearer";
|
||||
|
@@ -17,11 +17,11 @@ import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import com.nimbusds.jwt.JWTClaimsSet;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.authenticate.service.AuthenticationService;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.eperson.Group;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -34,17 +34,19 @@ import org.springframework.stereotype.Component;
|
||||
@Component
|
||||
public class SpecialGroupClaimProvider implements JWTClaimProvider {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(SpecialGroupClaimProvider.class);
|
||||
private static final Logger log = LogManager.getLogger();
|
||||
|
||||
public static final String SPECIAL_GROUPS = "sg";
|
||||
|
||||
@Autowired
|
||||
private AuthenticationService authenticationService;
|
||||
|
||||
@Override
|
||||
public String getKey() {
|
||||
return SPECIAL_GROUPS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue(Context context, HttpServletRequest request) {
|
||||
List<Group> groups = new ArrayList<>();
|
||||
try {
|
||||
@@ -57,6 +59,7 @@ public class SpecialGroupClaimProvider implements JWTClaimProvider {
|
||||
return groupIds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parseClaim(Context context, HttpServletRequest request, JWTClaimsSet jwtClaimsSet) {
|
||||
try {
|
||||
List<String> groupIds = jwtClaimsSet.getStringListClaim(SPECIAL_GROUPS);
|
||||
|
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* The contents of this file are subject to the license and copyright
|
||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||
* tree and available online at
|
||||
*
|
||||
* http://www.dspace.org/license/
|
||||
*/
|
||||
/**
|
||||
* DSpace-specific concepts and behaviors to support Spring Security.
|
||||
* These may be used by Spring EL expressions in Spring Security annotations.
|
||||
*
|
||||
* <p>{@code hasPermission} terms are evaluated by
|
||||
* {@link DSpacePermissionEvaluator}, an implementation of Spring's
|
||||
* {@link PermissionEvaluator}. It tests access to specific model objects
|
||||
* (Item, EPerson etc.) using those objects' policies. It is injected with a
|
||||
* collection of {@link RestPermissionEvaluatorPlugin}s which do the work.
|
||||
*
|
||||
* <p>{@code hasAuthority} terms are implemented by {@link GrantedAuthority}
|
||||
* implementations such as {@link EPersonRestAuthenticationProvider}. These
|
||||
* test for authorization properties of the session itself, such as membership
|
||||
* in the site administrators group.
|
||||
*
|
||||
* <p>{@code *PermissionEvaluatorPlugin} classes test permission for specific
|
||||
* types of objects. They implement {@link RestPermissionEvaluatorPlugin}.
|
||||
*
|
||||
* <p>Other classes TBD:
|
||||
* <ul>
|
||||
* <li>*Filter</li>
|
||||
* <li>*Configuration</li>
|
||||
* </ul>
|
||||
*/
|
||||
package org.dspace.app.rest.security;
|
||||
|
||||
import org.springframework.security.access.PermissionEvaluator;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
@@ -17,6 +17,8 @@ import java.util.Objects;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.app.rest.exception.UnprocessableEntityException;
|
||||
import org.dspace.app.rest.model.AccessConditionDTO;
|
||||
import org.dspace.app.rest.model.patch.JsonValueEvaluator;
|
||||
@@ -31,8 +33,6 @@ import org.dspace.submit.model.AccessConditionConfiguration;
|
||||
import org.dspace.submit.model.AccessConditionConfigurationService;
|
||||
import org.dspace.submit.model.AccessConditionOption;
|
||||
import org.dspace.util.TimeHelpers;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
@@ -42,7 +42,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
*/
|
||||
public class AccessConditionReplacePatchOperation extends ReplacePatchOperation<AccessConditionDTO> {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(AccessConditionReplacePatchOperation.class);
|
||||
private static final Logger log = LogManager.getLogger();
|
||||
|
||||
@Autowired
|
||||
private ResourcePolicyService resourcePolicyService;
|
||||
@@ -157,7 +157,7 @@ public class AccessConditionReplacePatchOperation extends ReplacePatchOperation<
|
||||
try {
|
||||
return pattern.parse(date);
|
||||
} catch (ParseException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
log.error(e::getMessage, e);
|
||||
}
|
||||
}
|
||||
throw new UnprocessableEntityException("Provided format of date:" + date + " is not supported!");
|
||||
|
@@ -11,8 +11,6 @@ import org.apache.commons.configuration2.Configuration;
|
||||
import org.apache.commons.configuration2.spring.ConfigurationPropertySource;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.ApplicationContextInitializer;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
|
||||
@@ -29,8 +27,6 @@ import org.springframework.context.ConfigurableApplicationContext;
|
||||
*/
|
||||
public class DSpaceConfigurationInitializer implements ApplicationContextInitializer<ConfigurableApplicationContext> {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(DSpaceConfigurationInitializer.class);
|
||||
|
||||
@Override
|
||||
public void initialize(final ConfigurableApplicationContext applicationContext) {
|
||||
// Load DSpace Configuration service (requires kernel already initialized)
|
||||
|
@@ -12,13 +12,13 @@ import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.kernel.DSpaceKernel;
|
||||
import org.dspace.kernel.DSpaceKernelManager;
|
||||
import org.dspace.servicemanager.DSpaceKernelImpl;
|
||||
import org.dspace.servicemanager.DSpaceKernelInit;
|
||||
import org.dspace.servicemanager.config.DSpaceConfigurationService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.ApplicationContextInitializer;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
@@ -31,7 +31,7 @@ import org.springframework.core.env.ConfigurableEnvironment;
|
||||
*/
|
||||
public class DSpaceKernelInitializer implements ApplicationContextInitializer<ConfigurableApplicationContext> {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(DSpaceKernelInitializer.class);
|
||||
private static final Logger log = LogManager.getLogger();
|
||||
|
||||
private transient DSpaceKernel dspaceKernel;
|
||||
|
||||
@@ -119,6 +119,7 @@ public class DSpaceKernelInitializer implements ApplicationContextInitializer<Co
|
||||
this.kernel = kernel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(final ContextClosedEvent event) {
|
||||
if (this.kernel != null) {
|
||||
this.kernel.destroy();
|
||||
|
@@ -19,9 +19,9 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.tomcat.util.http.FastHttpDateFormat;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
|
||||
/**
|
||||
@@ -32,7 +32,7 @@ import org.springframework.http.HttpHeaders;
|
||||
*/
|
||||
public class HttpHeadersInitializer {
|
||||
|
||||
protected final Logger log = LoggerFactory.getLogger(this.getClass());
|
||||
protected final Logger log = LogManager.getLogger();
|
||||
|
||||
private static final String MULTIPART_BOUNDARY = "MULTIPART_BYTERANGES";
|
||||
private static final String CONTENT_TYPE_MULTITYPE_WITH_BOUNDARY = "multipart/byteranges; boundary=" +
|
||||
|
29
dspace-server-webapp/src/main/javadoc/overview.html
Normal file
29
dspace-server-webapp/src/main/javadoc/overview.html
Normal file
@@ -0,0 +1,29 @@
|
||||
<!--
|
||||
|
||||
The contents of this file are subject to the license and copyright
|
||||
detailed in the LICENSE and NOTICE files at the root of the source
|
||||
tree and available online at
|
||||
|
||||
http://www.dspace.org/license/
|
||||
|
||||
-->
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>The DSpace Web API</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
The REST back-end of DSpace. A front-end program such as
|
||||
<a href='https://github.com/DSpace/dspace-angular/'>dspace-angular</a>
|
||||
can use this to query, fetch and manipulate DSpace objects and related
|
||||
data. The REST layer sits between front-ends and the DSpace business
|
||||
logic (chiefly in {@code dspace-api}).
|
||||
</p>
|
||||
|
||||
<p>Where To Find It:</p>
|
||||
<ul>
|
||||
<li>Endpoint access authorization: {@link org.dspace.app.rest.security}</li>
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
@@ -79,6 +79,11 @@
|
||||
</profiles>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-api</artifactId>
|
||||
<version>${log4j.version}</version>
|
||||
</dependency>
|
||||
<!-- spring service manager -->
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user