Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coar notify 7 part two merge main #436

Merged
merged 25 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
2227d14
DURACOM-225 add IT for the media filter script
abollini Jan 20, 2024
4dd3120
DURACOM-225 commit after each item to release DB resources
abollini Jan 20, 2024
729e389
DURACOM-225 porting of the uuid iterator implementation from dspace-c…
abollini Jan 20, 2024
29fa737
DURACOM-225 fix lazy initialization traversing comms/colls
abollini Jan 20, 2024
cb94956
Remove SLF4J from dspace-services.
mwoodiupui Feb 12, 2024
55979e4
Remove SLF4J from dspace-api.
mwoodiupui Feb 12, 2024
dea8a79
Remove SLF4J from dspace-server-webapp.
mwoodiupui Feb 13, 2024
4b85d54
Fix warnings about incorrect Checkstyle configuration element.
mwoodiupui Feb 13, 2024
75a5b1c
Begin package-level documentation.
mwoodiupui Feb 13, 2024
7aad97c
Shorten lines to satisfy Checkstyle.
mwoodiupui Feb 13, 2024
72823cb
Fix license headers.
mwoodiupui Feb 13, 2024
92fa4aa
Add missing Log4J dependency declarations.
mwoodiupui Feb 14, 2024
b51a092
Merge branch 'main' of https://github.com/DSpace/DSpace into DURACOM-225
abollini Feb 17, 2024
1966bfb
DURACOM-225 fix compilation error due to recent merge
abollini Feb 17, 2024
9890fa3
Remove erroneous copyright.
mwoodiupui Feb 29, 2024
92c0592
Merge remote-tracking branch 'upstream/main' into noslf4j
mwoodiupui Feb 29, 2024
b79f6e1
Remove some new SLF4J uses that crept in.
mwoodiupui Feb 29, 2024
6fbf8d9
Merge pull request #9218 from 4Science/coar-notify-7
tdonohue Feb 29, 2024
a2249de
Merge remote-tracking branch 'upstream/main' into noslf4j
mwoodiupui Feb 29, 2024
63cf153
Merge pull request #9324 from mwoodiupui/noslf4j
tdonohue Feb 29, 2024
529c495
Removed deprecated Hibernate-specific code in QueryPredicate (#9381)
jeffmorin Feb 29, 2024
5b76b17
Merge pull request #9273 from abollini/DURACOM-225
tdonohue Feb 29, 2024
507d61a
Merge remote-tracking branch 'dspacegithub/main' into coar-notify-7-p…
frabacche Mar 1, 2024
17e470b
coar-notify-7-part-two-merge-main LDNMessageEntityRest plural_name
frabacche Mar 1, 2024
3f8369e
coar-notify-7-part-two-merge-main LDNMessageRestRepository plural_name
frabacche Mar 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import org.apache.commons.cli.DefaultParser;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.dspace.authorize.AuthorizeException;
import org.dspace.content.MetadataField;
import org.dspace.content.MetadataSchema;
Expand All @@ -30,8 +32,6 @@
import org.dspace.content.service.MetadataFieldService;
import org.dspace.content.service.MetadataSchemaService;
import org.dspace.core.Context;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
Expand All @@ -40,9 +40,9 @@
/**
* @author Richard Jones
*
* This class takes an xml document as passed in the arguments and
* This class takes an XML document as passed in the arguments and
* uses it to create metadata elements in the Metadata Registry if
* they do not already exist
* they do not already exist.
*
* The format of the XML file is as follows:
*
Expand All @@ -69,7 +69,7 @@
/**
* logging category
*/
private static final Logger log = LoggerFactory.getLogger(MetadataImporter.class);
private static final Logger log = LogManager.getLogger();

/**
* Default constructor
Expand All @@ -89,6 +89,7 @@
* @throws SAXException if parser error
* @throws NonUniqueMetadataException if duplicate metadata
* @throws RegistryImportException if import fails
* @throws XPathExpressionException passed through
**/
public static void main(String[] args)
throws ParseException, SQLException, IOException, TransformerException,
Expand Down Expand Up @@ -125,6 +126,7 @@
* @throws SAXException if parser error
* @throws NonUniqueMetadataException if duplicate metadata
* @throws RegistryImportException if import fails
* @throws XPathExpressionException passed through
*/
public static void loadRegistry(String file, boolean forceUpdate)
throws SQLException, IOException, TransformerException, ParserConfigurationException, AuthorizeException,
Expand Down Expand Up @@ -203,7 +205,7 @@

if (s == null) {
// Schema does not exist - create
log.info("Registering Schema " + name + " (" + namespace + ")");
log.info("Registering Schema {}({})", name, namespace);
metadataSchemaService.create(context, name, namespace);
} else {
// Schema exists - if it's the same namespace, allow the type imports to continue
Expand All @@ -215,7 +217,7 @@
// It's a different namespace - have we been told to update?
if (updateExisting) {
// Update the existing schema namespace and continue to type import
log.info("Updating Schema " + name + ": New namespace " + namespace);
log.info("Updating Schema {}: New namespace {}", name, namespace);

Check warning on line 220 in dspace-api/src/main/java/org/dspace/administer/MetadataImporter.java

View check run for this annotation

Codecov / codecov/patch

dspace-api/src/main/java/org/dspace/administer/MetadataImporter.java#L220

Added line #L220 was not covered by tests
s.setNamespace(namespace);
metadataSchemaService.update(context, s);
} else {
Expand Down Expand Up @@ -274,7 +276,7 @@
if (qualifier == null) {
fieldName = schema + "." + element;
}
log.info("Registering metadata field " + fieldName);
log.info("Registering metadata field {}", fieldName);
MetadataField field = metadataFieldService.create(context, schemaObj, element, qualifier, scopeNote);
metadataFieldService.update(context, field);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ public Options getOptions() {
options.addOption("v", "verbose", false, "print all extracted text and other details to STDOUT");
options.addOption("q", "quiet", false, "do not print anything except in the event of errors.");
options.addOption("f", "force", false, "force all bitstreams to be processed");
options.addOption("i", "identifier", true, "ONLY process bitstreams belonging to identifier");
options.addOption("i", "identifier", true,
"ONLY process bitstreams belonging to the provided handle identifier");
options.addOption("m", "maximum", true, "process no more than maximum items");
options.addOption("h", "help", false, "help");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,18 @@ public void applyFiltersAllItems(Context context) throws Exception {
@Override
public void applyFiltersCommunity(Context context, Community community)
throws Exception { //only apply filters if community not in skip-list
// ensure that the community is attached to the current hibernate session
// as we are committing after each item (handles, sub-communties and
// collections are lazy attributes)
community = context.reloadEntity(community);
if (!inSkipList(community.getHandle())) {
List<Community> subcommunities = community.getSubcommunities();
for (Community subcommunity : subcommunities) {
applyFiltersCommunity(context, subcommunity);
}

// ensure that the community is attached to the current hibernate session
// as we are committing after each item
community = context.reloadEntity(community);
List<Collection> collections = community.getCollections();
for (Collection collection : collections) {
applyFiltersCollection(context, collection);
Expand All @@ -148,6 +154,9 @@ public void applyFiltersCommunity(Context context, Community community)
@Override
public void applyFiltersCollection(Context context, Collection collection)
throws Exception {
// ensure that the collection is attached to the current hibernate session
// as we are committing after each item (handles are lazy attributes)
collection = context.reloadEntity(collection);
//only apply filters if collection not in skip-list
if (!inSkipList(collection.getHandle())) {
Iterator<Item> itemIterator = itemService.findAllByCollection(context, collection);
Expand All @@ -171,6 +180,8 @@ public void applyFiltersItem(Context c, Item item) throws Exception {
}
// clear item objects from context cache and internal cache
c.uncacheEntity(currentItem);
// commit after each item to release DB resources
c.commit();
currentItem = null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import java.util.List;

import org.apache.commons.cli.ParseException;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.dspace.content.Item;
import org.dspace.core.Context;
import org.dspace.discovery.DiscoverQuery;
Expand All @@ -23,8 +25,6 @@
import org.dspace.scripts.DSpaceRunnable;
import org.dspace.sort.SortOption;
import org.dspace.utils.DSpace;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Runner responsible to import metadata about authors from OpenAIRE to Solr.
Expand All @@ -33,13 +33,13 @@
* with this UUID will be used.
* Invocation without any parameter results in massive import, processing all
* authors registered in DSpace.
*
*
* @author Alessandro Martelli (alessandro.martelli at 4science.it)
*/
public class PublicationLoaderRunnable
extends DSpaceRunnable<PublicationLoaderScriptConfiguration<PublicationLoaderRunnable>> {

private static final Logger LOGGER = LoggerFactory.getLogger(PublicationLoaderRunnable.class);
private static final Logger LOGGER = LogManager.getLogger();

Check warning on line 42 in dspace-api/src/main/java/org/dspace/app/suggestion/openaire/PublicationLoaderRunnable.java

View check run for this annotation

Codecov / codecov/patch

dspace-api/src/main/java/org/dspace/app/suggestion/openaire/PublicationLoaderRunnable.java#L42

Added line #L42 was not covered by tests

private PublicationLoader oairePublicationLoader = null;

Expand All @@ -63,9 +63,9 @@

profile = commandLine.getOptionValue("s");
if (profile == null) {
LOGGER.info("No argument for -s, process all profile");
LOGGER.info("No argument for -s, process all profiles");

Check warning on line 66 in dspace-api/src/main/java/org/dspace/app/suggestion/openaire/PublicationLoaderRunnable.java

View check run for this annotation

Codecov / codecov/patch

dspace-api/src/main/java/org/dspace/app/suggestion/openaire/PublicationLoaderRunnable.java#L66

Added line #L66 was not covered by tests
} else {
LOGGER.info("Process eperson item with UUID " + profile);
LOGGER.info("Process eperson item with UUID {}", profile);

Check warning on line 68 in dspace-api/src/main/java/org/dspace/app/suggestion/openaire/PublicationLoaderRunnable.java

View check run for this annotation

Codecov / codecov/patch

dspace-api/src/main/java/org/dspace/app/suggestion/openaire/PublicationLoaderRunnable.java#L68

Added line #L68 was not covered by tests
}
}

Expand All @@ -87,7 +87,7 @@
* the researcher with this UUID will be chosen. If the uuid doesn't match any
* researcher, the method returns an empty array list. If uuid is null, all
* research will be return.
*
*
* @param profileUUID uuid of the researcher. If null, all researcher will be
* returned.
* @return the researcher with specified UUID or all researchers
Expand All @@ -96,10 +96,10 @@
private Iterator<Item> getResearchers(String profileUUID) {
SearchService searchService = new DSpace().getSingletonService(SearchService.class);
DiscoverQueryBuilder queryBuilder = SearchUtils.getQueryBuilder();
List<QueryBuilderSearchFilter> filters = new ArrayList<QueryBuilderSearchFilter>();
List<QueryBuilderSearchFilter> filters = new ArrayList<>();

Check warning on line 99 in dspace-api/src/main/java/org/dspace/app/suggestion/openaire/PublicationLoaderRunnable.java

View check run for this annotation

Codecov / codecov/patch

dspace-api/src/main/java/org/dspace/app/suggestion/openaire/PublicationLoaderRunnable.java#L99

Added line #L99 was not covered by tests
String query = "*:*";
if (profileUUID != null) {
query = "search.resourceid:" + profileUUID.toString();
query = "search.resourceid:" + profileUUID;

Check warning on line 102 in dspace-api/src/main/java/org/dspace/app/suggestion/openaire/PublicationLoaderRunnable.java

View check run for this annotation

Codecov / codecov/patch

dspace-api/src/main/java/org/dspace/app/suggestion/openaire/PublicationLoaderRunnable.java#L102

Added line #L102 was not covered by tests
}
try {
DiscoverQuery discoverQuery = queryBuilder.buildQuery(context, null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
import java.sql.Timestamp;
import java.util.Date;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.dspace.app.util.factory.UtilServiceFactory;
import org.dspace.app.util.service.WebAppService;
import org.dspace.core.Context;
import org.dspace.services.ConfigurationService;
import org.dspace.services.factory.DSpaceServicesFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Represent a DSpace application while it is running. This helps us report
Expand All @@ -29,11 +29,10 @@
*/
abstract public class AbstractDSpaceWebapp
implements DSpaceWebappMXBean {
private static final Logger log = LoggerFactory.getLogger(AbstractDSpaceWebapp.class);
private static final Logger log = LogManager.getLogger();

Check warning on line 32 in dspace-api/src/main/java/org/dspace/app/util/AbstractDSpaceWebapp.java

View check run for this annotation

Codecov / codecov/patch

dspace-api/src/main/java/org/dspace/app/util/AbstractDSpaceWebapp.java#L32

Added line #L32 was not covered by tests

protected final WebAppService webAppService = UtilServiceFactory.getInstance().getWebAppService();


protected String kind;

protected Date started;
Expand Down
12 changes: 6 additions & 6 deletions dspace-api/src/main/java/org/dspace/app/util/DCInput.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
import javax.annotation.Nullable;

import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.dspace.content.MetadataSchemaEnum;
import org.dspace.core.Utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Class representing a line in an input form.
Expand All @@ -28,7 +28,7 @@
*/
public class DCInput {

private static final Logger log = LoggerFactory.getLogger(DCInput.class);
private static final Logger log = LogManager.getLogger();

/**
* the DC element name
Expand Down Expand Up @@ -183,7 +183,7 @@ public DCInput(Map<String, String> fieldMap, Map<String, List<String>> listMap)
}

//check if the input have a language tag
language = Boolean.valueOf(fieldMap.get("language"));
language = Boolean.parseBoolean(fieldMap.get("language"));
valueLanguageList = new ArrayList<>();
if (language) {
String languageNameTmp = fieldMap.get("value-pairs-name");
Expand Down Expand Up @@ -219,7 +219,7 @@ public DCInput(Map<String, String> fieldMap, Map<String, List<String>> listMap)
|| "yes".equalsIgnoreCase(closedVocabularyStr);

// parsing of the <type-bind> element (using the colon as split separator)
typeBind = new ArrayList<String>();
typeBind = new ArrayList<>();
String typeBindDef = fieldMap.get("type-bind");
if (typeBindDef != null && typeBindDef.trim().length() > 0) {
String[] types = typeBindDef.split(",");
Expand Down Expand Up @@ -523,7 +523,7 @@ public boolean isClosedVocabulary() {
* @return true when there is no type restriction or typeName is allowed
*/
public boolean isAllowedFor(String typeName) {
if (typeBind.size() == 0) {
if (typeBind.isEmpty()) {
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
import java.util.List;
import javax.servlet.http.HttpServletRequest;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.dspace.authenticate.service.AuthenticationService;
import org.dspace.authorize.AuthorizeException;
import org.dspace.core.Context;
import org.dspace.core.factory.CoreServiceFactory;
import org.dspace.eperson.EPerson;
import org.dspace.eperson.Group;
import org.dspace.eperson.service.EPersonService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

/**
Expand All @@ -49,15 +49,14 @@
* specified first (in the configuration) thus getting highest priority.
*
* @author Larry Stone
* @version $Revision$
* @see AuthenticationMethod
*/
public class AuthenticationServiceImpl implements AuthenticationService {

/**
* SLF4J logging category
* Logging category
*/
private final Logger log = (Logger) LoggerFactory.getLogger(AuthenticationServiceImpl.class);
private final Logger log = LogManager.getLogger();

@Autowired(required = true)
protected EPersonService ePersonService;
Expand Down Expand Up @@ -121,6 +120,7 @@ protected int authenticateInternal(Context context,
return bestRet;
}

@Override
public void updateLastActiveDate(Context context) {
EPerson me = context.getCurrentUser();
if (me != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.dspace.authenticate.oidc.OidcClient;
import org.dspace.authenticate.oidc.model.OidcTokenResponseDTO;
import org.dspace.core.Context;
import org.dspace.eperson.EPerson;
import org.dspace.eperson.Group;
import org.dspace.eperson.service.EPersonService;
import org.dspace.services.ConfigurationService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

/**
Expand All @@ -51,7 +51,7 @@

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";

Expand Down Expand Up @@ -174,7 +174,7 @@
final Entry<String, String> entry = iterator.next();

if (isBlank(entry.getValue())) {
LOGGER.error(" * {} is missing", entry.getKey());
LOGGER.error(" * {} is missing", entry::getKey);
}
}
return "";
Expand All @@ -183,7 +183,7 @@
try {
return format(LOGIN_PAGE_URL_FORMAT, authorizeUrl, clientId, scopes, encode(redirectUri, "UTF-8"));
} catch (UnsupportedEncodingException e) {
LOGGER.error(e.getMessage(), e);
LOGGER.error(e::getMessage, e);

Check warning on line 186 in dspace-api/src/main/java/org/dspace/authenticate/OidcAuthenticationBean.java

View check run for this annotation

Codecov / codecov/patch

dspace-api/src/main/java/org/dspace/authenticate/OidcAuthenticationBean.java#L186

Added line #L186 was not covered by tests
return "";
}

Expand Down
Loading
Loading