diff --git a/mir-module/src/main/java/org/mycore/mir/orcid/MIROrcidServlet.java b/mir-module/src/main/java/org/mycore/mir/orcid/MIROrcidServlet.java index 947b9a2ea8..35761b242d 100644 --- a/mir-module/src/main/java/org/mycore/mir/orcid/MIROrcidServlet.java +++ b/mir-module/src/main/java/org/mycore/mir/orcid/MIROrcidServlet.java @@ -1,8 +1,9 @@ package org.mycore.mir.orcid; import java.io.IOException; -import java.io.UnsupportedEncodingException; import java.net.MalformedURLException; +import java.net.URI; +import java.net.URISyntaxException; import java.net.URL; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; @@ -55,10 +56,10 @@ public class MIROrcidServlet extends MCRServlet { private static final String SEARCH_ORCID_XPATH = "/search:search/search:result/common:orcid-identifier/common:path"; private static List getPersonList(String query) - throws MalformedURLException, UnsupportedEncodingException { - String encodedQuery = URLEncoder.encode(query, "UTF-8"); + throws MalformedURLException, URISyntaxException { + String encodedQuery = URLEncoder.encode(query, StandardCharsets.UTF_8); - URL url = new URL(ORCID_REQUEST_BASE + "search/?q=" + encodedQuery + "&rows=" + ORCID_FETCH_SIZE * 2); + URL url = new URI(ORCID_REQUEST_BASE + "search/?q=" + encodedQuery + "&rows=" + ORCID_FETCH_SIZE * 2).toURL(); try { Document document = new SAXBuilder().build(url); @@ -88,7 +89,7 @@ private static List getOrcidsFromDocument(Document document) { private static MIROrcidPersonEntry getEntry(String orcid) { try { - URL url = new URL(ORCID_REQUEST_BASE + orcid + "/personal-details"); + URL url = new URI(ORCID_REQUEST_BASE + orcid + "/personal-details").toURL(); Document document = new SAXBuilder().build(url); Element element = document.getRootElement(); @@ -105,7 +106,7 @@ private static MIROrcidPersonEntry getEntry(String orcid) { } return new MIROrcidPersonEntry(givenName.getTextTrim(), familyName.getTextTrim(), ORCID_URL + orcid); - } catch (JDOMException | IOException e) { + } catch (JDOMException | IOException | URISyntaxException e) { throw new MCRException(e); } } diff --git a/mir-module/src/main/java/org/mycore/mir/sherpa/MCRSherpaProxyResource.java b/mir-module/src/main/java/org/mycore/mir/sherpa/MCRSherpaProxyResource.java index 7607c44016..1f9fc142cd 100644 --- a/mir-module/src/main/java/org/mycore/mir/sherpa/MCRSherpaProxyResource.java +++ b/mir-module/src/main/java/org/mycore/mir/sherpa/MCRSherpaProxyResource.java @@ -22,6 +22,8 @@ import java.io.IOException; import java.io.InputStream; import java.net.MalformedURLException; +import java.net.URI; +import java.net.URISyntaxException; import java.net.URL; import java.util.Optional; @@ -64,17 +66,15 @@ public Response retrieve(@PathParam("type") String type, @QueryParam("filter") S urlStr+="&filter="+filter; } try { - URL url = new URL(urlStr); - try(InputStream is = url.openStream()){ - try(ByteArrayOutputStream bos = new ByteArrayOutputStream()){ - is.transferTo(bos); - return Response.ok(bos.toByteArray()).build(); - } + URL url = new URI(urlStr).toURL(); + try (InputStream is = url.openStream(); ByteArrayOutputStream bos = new ByteArrayOutputStream()) { + is.transferTo(bos); + return Response.ok(bos.toByteArray()).build(); } catch (IOException e) { LOGGER.error("Error while performing request!", e); return Response.serverError().build(); } - } catch (MalformedURLException e) { + } catch (MalformedURLException | URISyntaxException e) { LOGGER.error("Error while building URL " + urlStr, e); return Response.serverError().build(); } diff --git a/mir-module/src/main/java/org/mycore/mir/validation/MIRValidationHelper.java b/mir-module/src/main/java/org/mycore/mir/validation/MIRValidationHelper.java index 57be4e8ec7..abfd94235e 100644 --- a/mir-module/src/main/java/org/mycore/mir/validation/MIRValidationHelper.java +++ b/mir-module/src/main/java/org/mycore/mir/validation/MIRValidationHelper.java @@ -2,6 +2,8 @@ import java.io.IOException; import java.net.HttpURLConnection; +import java.net.URI; +import java.net.URISyntaxException; import java.net.URL; import org.apache.logging.log4j.LogManager; @@ -30,7 +32,7 @@ public static String validateSDNB(String sdnb) { public static boolean validatePPN(String ppn) { String database = MCRConfiguration2.getString("MIR.PPN.DatabaseList").orElse("gvk"); try { - URL url = new URL("http://uri.gbv.de/document/" + database + ":ppn:" + ppn); + URL url = new URI("http://uri.gbv.de/document/" + database + ":ppn:" + ppn).toURL(); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod("GET"); connection.connect(); @@ -38,8 +40,8 @@ public static boolean validatePPN(String ppn) { if (resCode == 200 || resCode == 302) { return true; } - } catch (IOException e) { - LogManager.getLogger().error("IOException while validating PPN.", e); + } catch (IOException | URISyntaxException e) { + LogManager.getLogger().error("Exception while validating PPN.", e); } return false; } diff --git a/mir-module/src/main/resources/xsl/metadata/mir-abstract.xsl b/mir-module/src/main/resources/xsl/metadata/mir-abstract.xsl index f40ae77c57..42f8f3b8e1 100644 --- a/mir-module/src/main/resources/xsl/metadata/mir-abstract.xsl +++ b/mir-module/src/main/resources/xsl/metadata/mir-abstract.xsl @@ -338,7 +338,7 @@ + select="document(concat('solr:q=',encoder:encode($query), '&rows=1000&sort=mods.part.order.', $objectID, '%20desc,mods.dateIssued%20desc,%20mods.dateIssued.host%20desc,', $modsPart, '%20desc,%20mods.title.main%20desc&group=true&group.limit=1000&group.field=mods.yearIssued'))/response/lst[@name='grouped']/lst[@name='mods.yearIssued']" /> diff --git a/mir-wizard/src/main/java/org/mycore/mir/wizard/command/MIRWizardDownloadDBLib.java b/mir-wizard/src/main/java/org/mycore/mir/wizard/command/MIRWizardDownloadDBLib.java index ea45e46e09..de8f4e0756 100644 --- a/mir-wizard/src/main/java/org/mycore/mir/wizard/command/MIRWizardDownloadDBLib.java +++ b/mir-wizard/src/main/java/org/mycore/mir/wizard/command/MIRWizardDownloadDBLib.java @@ -23,7 +23,7 @@ package org.mycore.mir.wizard.command; import java.io.File; -import java.net.URL; +import java.net.URI; import org.apache.commons.io.FileUtils; import org.apache.commons.io.FilenameUtils; @@ -63,7 +63,7 @@ public void doExecute() { File file = new File(libDir + File.separator + fname); try { - FileUtils.copyURLToFile(new URL(url), file); + FileUtils.copyURLToFile(new URI(url).toURL(), file); MCRConfigurationDirSetup.loadExternalLibs(); success = true; diff --git a/pom.xml b/pom.xml index 34a6a11646..b3dc645641 100644 --- a/pom.xml +++ b/pom.xml @@ -334,12 +334,6 @@ ${tomcat.version} tar.gz - - - com.sun.activation - jakarta.activation - - ${project.build.directory}/catalina-base