From 44c1d0df37f9c091bb023a806a2afd8628328694 Mon Sep 17 00:00:00 2001 From: Sebastian Hofmann Date: Fri, 7 Oct 2022 14:19:03 +0200 Subject: [PATCH] Fixed CI=true build --- ubo-common/pom.xml | 37 ++-- .../main/java/org/mycore/ubo/BatchEditor.java | 163 ------------------ .../java/org/mycore/ubo/DozBibCommands.java | 10 +- .../org/mycore/ubo/DozBibGNDCommands.java | 3 +- .../ubo/dedup/DeDupCriteriaBuilder.java | 3 +- .../org/mycore/ubo/importer/ImportJob.java | 3 +- .../importer/scopus/PaginatedScopusQuery.java | 4 +- .../scopus/ScopusAffiliationQuery.java | 4 +- .../ubo/importer/scopus/ScopusImporter.java | 6 +- .../ubo/importer/scopus/ScopusQuery.java | 3 +- .../ubo/importer/scopus/ScopusUpdater.java | 12 +- .../mycore/ubo/ldap/LDAPAuthenticator.java | 3 +- .../mycore/ubo/ldap/picker/LDAPService.java | 4 +- .../ubo/login/LDAPAuthenticationHandler.java | 2 +- .../java/org/mycore/ubo/lsf/LSFService.java | 5 +- .../ubo/matcher/MCRUserMatcherLDAP.java | 5 +- .../ubo/matcher/MCRUserMatcherUtils.java | 3 +- .../config/ubo-common/mycore.properties | 2 - ubo-webapp/pom.xml | 9 +- 19 files changed, 71 insertions(+), 210 deletions(-) delete mode 100644 ubo-common/src/main/java/org/mycore/ubo/BatchEditor.java diff --git a/ubo-common/pom.xml b/ubo-common/pom.xml index c9848078e..2331afbeb 100644 --- a/ubo-common/pom.xml +++ b/ubo-common/pom.xml @@ -144,24 +144,6 @@ jakarta.xml.bind jakarta.xml.bind-api - - jaxen - jaxen - - - jdom - jdom2 - - - xom - xom - - - xml-apis - xml-apis - - - net.sf.saxon Saxon-HE @@ -252,6 +234,25 @@ commons-discovery runtime + + jaxen + jaxen + runtime + + + jdom + jdom2 + + + xom + xom + + + xml-apis + xml-apis + + + org.apache.logging.log4j log4j-core diff --git a/ubo-common/src/main/java/org/mycore/ubo/BatchEditor.java b/ubo-common/src/main/java/org/mycore/ubo/BatchEditor.java deleted file mode 100644 index dfedfe9eb..000000000 --- a/ubo-common/src/main/java/org/mycore/ubo/BatchEditor.java +++ /dev/null @@ -1,163 +0,0 @@ -package org.mycore.ubo; - -import java.io.IOException; -import java.text.MessageFormat; -import java.util.Collection; -import java.util.List; - -import org.jaxen.JaxenException; -import org.jdom2.Document; -import org.jdom2.Element; -import org.jdom2.Namespace; -import org.jdom2.filter.Filter; -import org.jdom2.filter.Filters; -import org.jdom2.xpath.XPathExpression; -import org.jdom2.xpath.XPathFactory; -import org.mycore.access.MCRAccessException; -import org.mycore.common.MCRConstants; -import org.mycore.common.MCRPersistenceException; -import org.mycore.common.config.MCRConfiguration2; -import org.mycore.common.content.MCRJDOMContent; -import org.mycore.common.xml.MCRNodeBuilder; -import org.mycore.datamodel.metadata.MCRMetadataManager; -import org.mycore.datamodel.metadata.MCRObject; -import org.mycore.datamodel.metadata.MCRObjectID; -import org.mycore.frontend.cli.MCRAbstractCommands; -import org.mycore.frontend.cli.annotation.MCRCommand; -import org.mycore.frontend.cli.annotation.MCRCommandGroup; - -/** - * Commands to batch add/remove/replace values - * like identifiers, categories, tags, flags etc. within XML. - * Supported fields are completely configurable using XPath expressions. - * - * @author Frank L\u00FCtzenkirchen - */ -@MCRCommandGroup(name = "Batch Editor") -public class BatchEditor extends MCRAbstractCommands { - - private static final Collection NS = MCRConstants.getStandardNamespaces(); - - private static final Filter FE = Filters.element(); - - private static final String CFG_PREFIX = "UBO.BatchEditor."; - - private static final String CFG_PREFIX_BASE = CFG_PREFIX + "BaseLevel."; - - private static final String CFG_SUFFIX_REMOVE = ".Path2Remove"; - - private static final String CFG_SUFFIX_ADD = ".Path2Add"; - - private static enum Action { - ADD, ADD_IF, REMOVE, REMOVE_IF, REPLACE - } - - @MCRCommand(syntax = "edit {0} at {1} add {2} {3}", - help = "Edit XML elements in object {0} at level {1} in object {1}, add field {2} with value {3}", - order = 2) - public static void batchAdd(String oid, String level, String field, String value) - throws JaxenException, MCRPersistenceException, MCRAccessException, IOException { - edit(oid, level, Action.ADD, field, value, null, null); - } - - @MCRCommand(syntax = "edit {0} at {1} if {2} {3} add {4} {5}", - help = "Edit XML elements in object {0} at level {1}, if there is a field {2} with value {3}, add field {4} with value {5}", - order = 1) - public static void batchAddIf(String oid, String level, String fieldIf, String valueIf, String field2Add, - String value2Add) - throws JaxenException, MCRPersistenceException, MCRAccessException, IOException { - edit(oid, level, Action.ADD_IF, fieldIf, valueIf, field2Add, value2Add); - } - - @MCRCommand(syntax = "edit {0} at {1} remove {2} {3}", - help = "Edit XML elements at in object {0} at level {1}, remove field {2} where value is {3}", - order = 2) - public static void batchRemove(String oid, String level, String field, String value) - throws MCRPersistenceException, MCRAccessException, JaxenException, IOException { - edit(oid, level, Action.REMOVE, field, value, null, null); - } - - @MCRCommand(syntax = "edit {0} at {1} if {2} {3} remove {4} {5}", - help = "Edit XML elements in object {0} at level {1}, if there is a field {2} with value {3}, remove field {4} where value is {5}", - order = 1) - public static void batchRemoveIf(String oid, String level, String fieldIf, String valueIf, String field2Rem, - String value2Rem) - throws MCRPersistenceException, MCRAccessException, JaxenException, IOException { - edit(oid, level, Action.REMOVE_IF, fieldIf, valueIf, field2Rem, value2Rem); - } - - @MCRCommand(syntax = "edit {0} at {1} replace {2} {3} with {4} {5}", - help = "Edit XML elements in object {0} at level {1}, replace field {2} value {3} by field {4} with value {5}", - order = 1) - public static void batchReplace(String oid, String level, String oldField, String oldValue, String newField, - String newValue) - throws JaxenException, MCRPersistenceException, MCRAccessException, IOException { - edit(oid, level, Action.REPLACE, oldField, oldValue, newField, newValue); - } - - public static void edit(String oid, String level, Action a, String field1, String value1, String field2, - String value2) - throws JaxenException, MCRPersistenceException, MCRAccessException, IOException { - Document xmlOld = getObjectXML(oid); - Document xmlNew = xmlOld.clone(); - - for (Element base : getlevelElements(xmlNew, level)) { - if (a == Action.ADD) { - add(base, field1, value1); - } else if (a == Action.REMOVE) { - find(base, field1, value1).forEach(e -> e.detach()); - } else if (a == Action.REPLACE) { - List found = find(base, field1, value1); - found.forEach(e -> e.detach()); - if (!found.isEmpty()) { - add(base, field2, value2); - } - } else if (a == Action.ADD_IF) { - if (!find(base, field1, value1).isEmpty()) { - add(base, field2, value2); - } - } else if (a == Action.REMOVE_IF) { - if (!find(base, field1, value1).isEmpty()) { - find(base, field2, value2).forEach(e -> e.detach()); - } - } - } - - saveIfModified(xmlOld, xmlNew); - } - - private static Document getObjectXML(String objectID) { - MCRObjectID oid = MCRObjectID.getInstance(objectID); - MCRObject obj = MCRMetadataManager.retrieveMCRObject(oid); - return obj.createXML(); - } - - private static void saveIfModified(Document xmlOld, Document xmlNew) throws MCRAccessException, IOException { - String oldData = new MCRJDOMContent(xmlOld).asString(); - String newData = new MCRJDOMContent(xmlNew).asString(); - if (!oldData.equals(newData)) { - MCRObject obj = new MCRObject(xmlNew); - MCRMetadataManager.update(obj); - } - } - - private static List getlevelElements(Document xml, String level) { - String path = MCRConfiguration2.getString(CFG_PREFIX_BASE + level).get(); - XPathExpression xPath = XPathFactory.instance().compile(path, FE, null, NS); - return xPath.evaluate(xml); - } - - private static void add(Element base, String field, String value) throws JaxenException { - String path = MCRConfiguration2.getString(CFG_PREFIX + field + CFG_SUFFIX_ADD).get(); - path = MessageFormat.format(path, value); - new MCRNodeBuilder().buildNode(path, null, base); - } - - private static List find(Element base, String field, String value) { - String path = MCRConfiguration2.getString(CFG_PREFIX + field + CFG_SUFFIX_REMOVE).get(); - path = MessageFormat.format(path, value); - XPathExpression fPath = XPathFactory.instance().compile(path, FE, null, NS); - List selected = fPath.evaluate(base); - return selected; - } -} diff --git a/ubo-common/src/main/java/org/mycore/ubo/DozBibCommands.java b/ubo-common/src/main/java/org/mycore/ubo/DozBibCommands.java index fcd5cc97a..280c17ef6 100644 --- a/ubo-common/src/main/java/org/mycore/ubo/DozBibCommands.java +++ b/ubo-common/src/main/java/org/mycore/ubo/DozBibCommands.java @@ -19,6 +19,7 @@ import java.util.Date; import java.util.Iterator; import java.util.List; +import java.util.Locale; import java.util.zip.Deflater; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; @@ -91,7 +92,7 @@ public DozBibCommands() { /** Exports all entries as MODS dump to a zipped xml file in the given directory */ public static void exportMODS(String dir) throws Exception { - DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); + DateFormat df = new SimpleDateFormat("yyyy-MM-dd", Locale.ROOT); Date now = new Date(); String date = df.format(now); String fileName = "export-" + date + ".zip"; @@ -197,18 +198,19 @@ public static void migrate2mcrobject() throws Exception { public static void importMODSCollection(String fileName) throws Exception { File file = new File(fileName); if (!file.isFile()) { - throw new MCRException(MessageFormat.format("File {0} is not a file.", file.getAbsolutePath())); + throw new MCRException(String.format(Locale.ROOT, "File %s is not a file.", file.getAbsolutePath())); } SAXBuilder s = new SAXBuilder(XMLReaders.NONVALIDATING, null, null); Document doc = s.build(file); MCRXMLHelper.validate(doc, MCRMODSCommands.MODS_V3_XSD_URI); Element root = doc.getRootElement(); if (!root.getNamespace().equals(MCRConstants.MODS_NAMESPACE)) { - throw new MCRException(MessageFormat.format("File {0} is not a MODS document.", file.getAbsolutePath())); + throw new MCRException( + String.format(Locale.ROOT, "File %s is not a MODS document.", file.getAbsolutePath())); } if (!root.getName().equals("modsCollection")) { throw new MCRException( - MessageFormat.format("File {0} does not contain a mods:modsCollection.", file.getAbsolutePath())); + String.format(Locale.ROOT, "File %s does not contain a mods:modsCollection.", file.getAbsolutePath())); } for (Element mods : root.getChildren("mods", MCRConstants.MODS_NAMESPACE)) { MCRMODSWrapper wrapper = new MCRMODSWrapper(); diff --git a/ubo-common/src/main/java/org/mycore/ubo/DozBibGNDCommands.java b/ubo-common/src/main/java/org/mycore/ubo/DozBibGNDCommands.java index 535f4b53b..4d9433940 100644 --- a/ubo-common/src/main/java/org/mycore/ubo/DozBibGNDCommands.java +++ b/ubo-common/src/main/java/org/mycore/ubo/DozBibGNDCommands.java @@ -16,6 +16,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Set; @@ -396,6 +397,6 @@ private String getContributorName(Element contributor) { } private String normalizeTitle(String title) { - return title.toLowerCase().replaceAll("[^a-z]+", ""); + return title.toLowerCase(Locale.ROOT).replaceAll("[^a-z]+", ""); } } diff --git a/ubo-common/src/main/java/org/mycore/ubo/dedup/DeDupCriteriaBuilder.java b/ubo-common/src/main/java/org/mycore/ubo/dedup/DeDupCriteriaBuilder.java index cb3871f14..c792b9e4e 100644 --- a/ubo-common/src/main/java/org/mycore/ubo/dedup/DeDupCriteriaBuilder.java +++ b/ubo-common/src/main/java/org/mycore/ubo/dedup/DeDupCriteriaBuilder.java @@ -15,6 +15,7 @@ import java.util.HashSet; import java.util.Iterator; import java.util.List; +import java.util.Locale; import java.util.Set; import org.jdom2.Document; @@ -194,7 +195,7 @@ public DeDupCriterion buildFromTitleAuthor(String title, String author) { * Accents, umlauts, case are normalized. Punctuation and non-alphabetic/non-digit characters are removed. */ public static String normalizeText(String text) { - text = text.toLowerCase(); + text = text.toLowerCase(Locale.ROOT); text = new MCRHyphenNormalizer().normalize(text).replace("-", " "); text = Normalizer.normalize(text, Form.NFD).replaceAll("\\p{M}", ""); // canonical decomposition, then remove accents text = text.replace("ue", "u").replace("oe", "o").replace("ae", "a").replace("ß", "s").replace("ss", "s"); diff --git a/ubo-common/src/main/java/org/mycore/ubo/importer/ImportJob.java b/ubo-common/src/main/java/org/mycore/ubo/importer/ImportJob.java index 0779d0442..edf696e89 100644 --- a/ubo-common/src/main/java/org/mycore/ubo/importer/ImportJob.java +++ b/ubo-common/src/main/java/org/mycore/ubo/importer/ImportJob.java @@ -14,6 +14,7 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; +import java.util.Locale; import java.util.concurrent.TimeUnit; import org.apache.logging.log4j.LogManager; @@ -43,7 +44,7 @@ public abstract class ImportJob { private static final Logger LOGGER = LogManager.getLogger(ImportJob.class); - private static final SimpleDateFormat ID_BUILDER = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + private static final SimpleDateFormat ID_BUILDER = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.ROOT); private static final String PROJECT_ID = MCRConfiguration2.getString("UBO.projectid.default").get(); diff --git a/ubo-common/src/main/java/org/mycore/ubo/importer/scopus/PaginatedScopusQuery.java b/ubo-common/src/main/java/org/mycore/ubo/importer/scopus/PaginatedScopusQuery.java index e9748a5c1..57ebfb6a0 100644 --- a/ubo-common/src/main/java/org/mycore/ubo/importer/scopus/PaginatedScopusQuery.java +++ b/ubo-common/src/main/java/org/mycore/ubo/importer/scopus/PaginatedScopusQuery.java @@ -25,6 +25,7 @@ import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; +import java.util.Locale; import org.jdom2.Document; import org.jdom2.Element; @@ -60,7 +61,8 @@ private URL buildQueryURL() throws MalformedURLException { private URL buildQueryURL(int start) throws MalformedURLException { String encodedQuery = URLEncoder.encode(getQuery(), StandardCharsets.UTF_8); - String queryString = String.format(QUERY_PATTERN, encodedQuery, API_KEY, INST_TOKEN, getCount(), start); + String queryString + = String.format(Locale.ROOT, QUERY_PATTERN, encodedQuery, API_KEY, INST_TOKEN, getCount(), start); return new URL(API_URL + queryString); } diff --git a/ubo-common/src/main/java/org/mycore/ubo/importer/scopus/ScopusAffiliationQuery.java b/ubo-common/src/main/java/org/mycore/ubo/importer/scopus/ScopusAffiliationQuery.java index 5bebd6450..ec2d55f0b 100644 --- a/ubo-common/src/main/java/org/mycore/ubo/importer/scopus/ScopusAffiliationQuery.java +++ b/ubo-common/src/main/java/org/mycore/ubo/importer/scopus/ScopusAffiliationQuery.java @@ -4,6 +4,7 @@ import java.net.MalformedURLException; import java.net.URL; import java.util.List; +import java.util.Locale; import java.util.function.Consumer; import java.util.stream.Collectors; @@ -59,7 +60,8 @@ public ScopusAffiliationQuery(String affiliation){ } protected URL buildAffiliationQuery() throws MalformedURLException { - String queryString = String.format(AFFILIATION_QUERY_PATTERN, getAffiliation(), API_KEY, INST_TOKEN,getCount(), getStart()); + String queryString = String.format(Locale.ROOT, AFFILIATION_QUERY_PATTERN, getAffiliation(), API_KEY, + INST_TOKEN, getCount(), getStart()); return new URL(API_URL + queryString); } diff --git a/ubo-common/src/main/java/org/mycore/ubo/importer/scopus/ScopusImporter.java b/ubo-common/src/main/java/org/mycore/ubo/importer/scopus/ScopusImporter.java index 91bb03fef..14d3c2023 100644 --- a/ubo-common/src/main/java/org/mycore/ubo/importer/scopus/ScopusImporter.java +++ b/ubo-common/src/main/java/org/mycore/ubo/importer/scopus/ScopusImporter.java @@ -6,6 +6,7 @@ import java.util.Date; import java.util.HashMap; import java.util.List; +import java.util.Locale; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -99,7 +100,7 @@ private boolean isAlreadyStored(String scopusID) { } private Element retrieveAndConvertPublication(String externalID) { - String uri = MessageFormat.format(IMPORT_URI, externalID); + String uri = new MessageFormat(IMPORT_URI, Locale.ROOT).format(externalID); return MCRURIResolver.instance().resolve(uri); } @@ -107,7 +108,8 @@ private Element retrieveAndConvertPublication(String externalID) { private static boolean shouldIgnore(Element publication) { return !publication.getDescendants(new ElementFilter("genre", MCRConstants.MODS_NAMESPACE)).hasNext(); } - private final static SimpleDateFormat ID_BUILDER = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + + private final static SimpleDateFormat ID_BUILDER = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.ROOT); private MCRObject buildMCRObject(Element publicationXML) { MCRObject obj = new MCRObject(new Document(publicationXML)); diff --git a/ubo-common/src/main/java/org/mycore/ubo/importer/scopus/ScopusQuery.java b/ubo-common/src/main/java/org/mycore/ubo/importer/scopus/ScopusQuery.java index d57d92169..0d9c85030 100644 --- a/ubo-common/src/main/java/org/mycore/ubo/importer/scopus/ScopusQuery.java +++ b/ubo-common/src/main/java/org/mycore/ubo/importer/scopus/ScopusQuery.java @@ -6,6 +6,7 @@ import java.net.URLEncoder; import java.nio.charset.StandardCharsets; import java.util.List; +import java.util.Locale; import org.jdom2.Document; import org.jdom2.JDOMException; @@ -43,7 +44,7 @@ public ScopusQuery(String query, int count) throws MalformedURLException { private URL buildQueryURL() throws MalformedURLException { String encodedQuery = URLEncoder.encode(getQuery(), StandardCharsets.UTF_8); - String queryString = String.format(QUERY_PATTERN, encodedQuery, API_KEY, INST_TOKEN, getCount()); + String queryString = String.format(Locale.ROOT, QUERY_PATTERN, encodedQuery, API_KEY, INST_TOKEN, getCount()); return new URL(API_URL + queryString); } diff --git a/ubo-common/src/main/java/org/mycore/ubo/importer/scopus/ScopusUpdater.java b/ubo-common/src/main/java/org/mycore/ubo/importer/scopus/ScopusUpdater.java index b8a0e8851..00aa5bf3a 100644 --- a/ubo-common/src/main/java/org/mycore/ubo/importer/scopus/ScopusUpdater.java +++ b/ubo-common/src/main/java/org/mycore/ubo/importer/scopus/ScopusUpdater.java @@ -2,10 +2,16 @@ import java.net.URLEncoder; import java.nio.charset.StandardCharsets; +import java.time.Instant; +import java.time.MonthDay; +import java.time.temporal.TemporalAmount; +import java.time.temporal.TemporalUnit; import java.util.Arrays; import java.util.Calendar; import java.util.GregorianCalendar; import java.util.List; +import java.util.Locale; +import java.util.TimeZone; import java.util.stream.Collectors; public class ScopusUpdater { @@ -42,13 +48,13 @@ public static void update(String affiliationIDs, int daysOffset, int count) private static String buildAffiliationCondition(String affiliationIDs) { return Arrays.stream(affiliationIDs.split(",")) - .map(a -> String.format("AF-ID(%1s)", a.trim())) + .map(a -> String.format(Locale.ROOT, "AF-ID(%1s)", a.trim())) .collect(Collectors.joining(" OR ", "(", ")")); } private static String buildDateCondition(int daysOffset) { - GregorianCalendar day = new GregorianCalendar(); + GregorianCalendar day = new GregorianCalendar(TimeZone.getDefault(), Locale.ROOT); day.add(Calendar.DATE, -daysOffset); - return String.format("orig-load-date aft %1$tY%1$tm%1$td", day); + return String.format(Locale.ROOT, "orig-load-date aft %1$tY%1$tm%1$td", day); } } diff --git a/ubo-common/src/main/java/org/mycore/ubo/ldap/LDAPAuthenticator.java b/ubo-common/src/main/java/org/mycore/ubo/ldap/LDAPAuthenticator.java index e3af39abd..efe82d570 100644 --- a/ubo-common/src/main/java/org/mycore/ubo/ldap/LDAPAuthenticator.java +++ b/ubo-common/src/main/java/org/mycore/ubo/ldap/LDAPAuthenticator.java @@ -1,6 +1,7 @@ package org.mycore.ubo.ldap; import java.util.Hashtable; +import java.util.Locale; import javax.naming.AuthenticationException; import javax.naming.Context; @@ -110,7 +111,7 @@ private LdapContext getLDAPContext(String uid, String credentials, String dn) th try { Hashtable env = (Hashtable) (ldapEnvironment.clone()); if (uid != null && !uid.isBlank() && credentials != null && !credentials.isBlank()) { - env.put(Context.SECURITY_PRINCIPAL, String.format(dn, uid)); + env.put(Context.SECURITY_PRINCIPAL, String.format(Locale.ROOT, dn, uid)); env.put(Context.SECURITY_CREDENTIALS, credentials); } diff --git a/ubo-common/src/main/java/org/mycore/ubo/ldap/picker/LDAPService.java b/ubo-common/src/main/java/org/mycore/ubo/ldap/picker/LDAPService.java index d2f3c2832..984a7d81a 100644 --- a/ubo-common/src/main/java/org/mycore/ubo/ldap/picker/LDAPService.java +++ b/ubo-common/src/main/java/org/mycore/ubo/ldap/picker/LDAPService.java @@ -5,6 +5,7 @@ import java.util.Comparator; import java.util.HashMap; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -170,7 +171,8 @@ public Element searchPerson(Map paramMap) { // but we dont want that in our results-xml, we have to remove it mcrAttributeName.replace("id_", ""); String attributeValue = mcrAttribute.getValue(); - person.addContent(new Element(mcrAttributeName.toLowerCase()).setText(attributeValue.trim())); + person + .addContent(new Element(mcrAttributeName.toLowerCase(Locale.ROOT)).setText(attributeValue.trim())); } // when converting LDAP attributes to MCRUserAttributes, any non-configured attributes might get lost // at this point we want to make sure, that the first- and lastname get delivered diff --git a/ubo-common/src/main/java/org/mycore/ubo/login/LDAPAuthenticationHandler.java b/ubo-common/src/main/java/org/mycore/ubo/login/LDAPAuthenticationHandler.java index 4b2f55fdb..36321cee7 100644 --- a/ubo-common/src/main/java/org/mycore/ubo/login/LDAPAuthenticationHandler.java +++ b/ubo-common/src/main/java/org/mycore/ubo/login/LDAPAuthenticationHandler.java @@ -125,7 +125,7 @@ public MCRUser authenticate(String uid, String pwd) throws Exception { */ private List searchUserInLDAP(LdapContext ctx, MCRUser user) throws NamingException { String uid = user.getUserName(); - String principal = String.format(baseDN, uid); + String principal = String.format(Locale.ROOT, baseDN, uid); String filter = String.format(Locale.ROOT, uidFilter, uid); return new LDAPSearcher().search(ctx, principal, filter); diff --git a/ubo-common/src/main/java/org/mycore/ubo/lsf/LSFService.java b/ubo-common/src/main/java/org/mycore/ubo/lsf/LSFService.java index fd84334ef..798d25857 100644 --- a/ubo-common/src/main/java/org/mycore/ubo/lsf/LSFService.java +++ b/ubo-common/src/main/java/org/mycore/ubo/lsf/LSFService.java @@ -19,6 +19,7 @@ import java.util.HashSet; import java.util.Iterator; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Set; import java.util.stream.Collectors; @@ -313,7 +314,7 @@ private void lookup(String lastName, Map results) { continue; } - person.addContent(new Element(name.toLowerCase()).setText(value.trim())); + person.addContent(new Element(name.toLowerCase(Locale.ROOT)).setText(value.trim())); } if (person.getContentSize() > 0) { @@ -370,7 +371,7 @@ private boolean matches(String[] firstNameParts, String[] candidateNameParts) { } private String[] getNormalizedNameParts(String text) { - text = text.toLowerCase(); + text = text.toLowerCase(Locale.ROOT); text = new MCRHyphenNormalizer().normalize(text).replace("-", " "); text = Normalizer.normalize(text, Form.NFD).replaceAll("\\p{M}", ""); // canonical decomposition, then remove accents text = text.replace("ue", "u").replace("oe", "o").replace("ae", "a").replace("ß", "s").replace("ss", "s"); diff --git a/ubo-common/src/main/java/org/mycore/ubo/matcher/MCRUserMatcherLDAP.java b/ubo-common/src/main/java/org/mycore/ubo/matcher/MCRUserMatcherLDAP.java index c603930ed..f3d4b2a7a 100644 --- a/ubo-common/src/main/java/org/mycore/ubo/matcher/MCRUserMatcherLDAP.java +++ b/ubo-common/src/main/java/org/mycore/ubo/matcher/MCRUserMatcherLDAP.java @@ -7,6 +7,7 @@ import java.util.Collection; import java.util.HashMap; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.SortedSet; import java.util.TreeSet; @@ -514,14 +515,14 @@ private String createLDAPSearchFilter(Multimap ldapAttributes, S forms.add(Normalizer.normalize(value, Normalizer.Form.NFD).replaceAll("\\p{M}", "")); } return forms.stream(); - }).map(f -> String.format(innerTemplate, attributeName, f)) + }).map(f -> String.format(Locale.ROOT, innerTemplate, attributeName, f)) .forEach(searchFilterInner::append); if (extendedAttributes) { searchFilterInner.append(")"); } } - return String.format(searchFilterBaseTemplate, searchFilterInner); + return String.format(Locale.ROOT, searchFilterBaseTemplate, searchFilterInner); } /** diff --git a/ubo-common/src/main/java/org/mycore/ubo/matcher/MCRUserMatcherUtils.java b/ubo-common/src/main/java/org/mycore/ubo/matcher/MCRUserMatcherUtils.java index a85cb8668..1ef9a9e99 100644 --- a/ubo-common/src/main/java/org/mycore/ubo/matcher/MCRUserMatcherUtils.java +++ b/ubo-common/src/main/java/org/mycore/ubo/matcher/MCRUserMatcherUtils.java @@ -5,6 +5,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.SortedSet; @@ -136,7 +137,7 @@ private static String getUserNameFromModsNameElement(Element modsNameElement) { String userName = ""; if((givenNameElem != null) && (familyNameElem != null)) { - userName = (givenNameElem.getText() + "_" + familyNameElem.getText()).toLowerCase(); + userName = (givenNameElem.getText() + "_" + familyNameElem.getText()).toLowerCase(Locale.ROOT); } return userName; diff --git a/ubo-common/src/main/resources/config/ubo-common/mycore.properties b/ubo-common/src/main/resources/config/ubo-common/mycore.properties index 615bed4a2..b29bc9c76 100644 --- a/ubo-common/src/main/resources/config/ubo-common/mycore.properties +++ b/ubo-common/src/main/resources/config/ubo-common/mycore.properties @@ -827,8 +827,6 @@ MCR.MODS.Merger.genre=org.mycore.mods.merger.MCRUniqueMerger ###################################################################### # MyCoRe command line interface configuration -MCR.CLI.Classes.Internal.BatchEditor=org.mycore.ubo.BatchEditor - MCR.BatchEditor.BaseLevel.object=/mycoreobject MCR.BatchEditor.BaseLevel.publication=/mycoreobject/metadata/def.modsContainer/modsContainer/mods:mods MCR.BatchEditor.BaseLevel.person=/mycoreobject/metadata/def.modsContainer/modsContainer/mods:mods//mods:name[@type="personal"] diff --git a/ubo-webapp/pom.xml b/ubo-webapp/pom.xml index 24ff9525e..f8151ff00 100644 --- a/ubo-webapp/pom.xml +++ b/ubo-webapp/pom.xml @@ -68,15 +68,16 @@ - - org.mycore.ubo - ubo-common - org.mycore mycore-ocfl runtime + + org.mycore.ubo + ubo-common + runtime +