Skip to content

Commit

Permalink
Merge pull request #436 from 4Science/coar-notify-7-part-two-merge-main
Browse files Browse the repository at this point in the history
Coar notify 7 part two merge main
  • Loading branch information
frabacche authored Mar 1, 2024
2 parents 1bbe119 + 3f8369e commit e65d766
Show file tree
Hide file tree
Showing 114 changed files with 1,120 additions and 693 deletions.
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 @@ public class MetadataImporter {
/**
* 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 @@ private MetadataImporter() { }
* @throws SAXException if parser error
* @throws NonUniqueMetadataException if duplicate metadata
* @throws RegistryImportException if import fails
* @throws XPathExpressionException passed through
**/
public static void main(String[] args)
throws ParseException, SQLException, IOException, TransformerException,
Expand Down Expand Up @@ -125,6 +126,7 @@ public static void main(String[] args)
* @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 @@ private static void loadSchema(Context context, Node node, boolean updateExistin

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 @@ private static void loadSchema(Context context, Node node, boolean updateExistin
// It's a different namespace - have we been told to update?
if (updateExisting) {
// Update the existing schema namespace and continue to type import
log.info("Updating Schema " + name + ": New namespace " + namespace);
log.info("Updating Schema {}: New namespace {}", name, namespace);
s.setNamespace(namespace);
metadataSchemaService.update(context, s);
} else {
Expand Down Expand Up @@ -274,7 +276,7 @@ private static void loadType(Context context, Node node)
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();

private PublicationLoader oairePublicationLoader = null;

Expand All @@ -63,9 +63,9 @@ public void setup() throws ParseException {

profile = commandLine.getOptionValue("s");
if (profile == null) {
LOGGER.info("No argument for -s, process all profile");
LOGGER.info("No argument for -s, process all profiles");
} else {
LOGGER.info("Process eperson item with UUID " + profile);
LOGGER.info("Process eperson item with UUID {}", profile);
}
}

Expand All @@ -87,7 +87,7 @@ public void internalRun() throws Exception {
* 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 @@ public void internalRun() throws Exception {
private Iterator<Item> getResearchers(String profileUUID) {
SearchService searchService = new DSpace().getSingletonService(SearchService.class);
DiscoverQueryBuilder queryBuilder = SearchUtils.getQueryBuilder();
List<QueryBuilderSearchFilter> filters = new ArrayList<QueryBuilderSearchFilter>();
List<QueryBuilderSearchFilter> filters = new ArrayList<>();
String query = "*:*";
if (profileUUID != null) {
query = "search.resourceid:" + profileUUID.toString();
query = "search.resourceid:" + profileUUID;
}
try {
DiscoverQuery discoverQuery = queryBuilder.buildQuery(context, null,
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();

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 @@ public class OidcAuthenticationBean implements AuthenticationMethod {

private final static String LOGIN_PAGE_URL_FORMAT = "%s?client_id=%s&response_type=code&scope=%s&redirect_uri=%s";

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

private static final String OIDC_AUTHENTICATED = "oidc.authenticated";

Expand Down Expand Up @@ -174,7 +174,7 @@ public String loginPageURL(Context context, HttpServletRequest request, HttpServ
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 @@ public String loginPageURL(Context context, HttpServletRequest request, HttpServ
try {
return format(LOGIN_PAGE_URL_FORMAT, authorizeUrl, clientId, scopes, encode(redirectUri, "UTF-8"));
} catch (UnsupportedEncodingException e) {
LOGGER.error(e.getMessage(), e);
LOGGER.error(e::getMessage, e);
return "";
}

Expand Down
Loading

0 comments on commit e65d766

Please sign in to comment.