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