From 740b7eb402507f4d6753809a83aad79d0e87828f Mon Sep 17 00:00:00 2001 From: maxnth Date: Tue, 3 Dec 2024 18:10:16 +0100 Subject: [PATCH 1/3] upgrade to Spring 6, Jakarta and Java 21 --- pom.xml | 81 +++++++++---------- .../uniwue/web/config/MvcConfiguration.java | 19 ++--- .../uniwue/web/controller/DataController.java | 4 +- .../uniwue/web/controller/FileController.java | 18 ++--- .../web/controller/LibraryController.java | 6 +- .../controller/SegmentationController.java | 8 +- .../web/controller/ViewerController.java | 5 +- .../de/uniwue/web/io/FilePathManager.java | 2 +- .../webapp/WEB-INF/tags/base/baseMenu.tag | 2 +- .../webapp/WEB-INF/tags/batchSegmentModal.tag | 4 +- src/main/webapp/WEB-INF/tags/contextmenu.tag | 4 +- .../WEB-INF/tags/keyboardShortcutModal.tag | 2 +- src/main/webapp/WEB-INF/tags/menuDropdown.tag | 2 +- src/main/webapp/WEB-INF/tags/menuIcon.tag | 4 +- .../webapp/WEB-INF/tags/menuIconCategory.tag | 2 +- .../webapp/WEB-INF/tags/metadataModal.tag | 2 +- .../webapp/WEB-INF/tags/regionSettings.tag | 8 +- .../webapp/WEB-INF/tags/settingsModal.tag | 2 +- src/main/webapp/WEB-INF/tags/sidebarLines.tag | 2 +- .../webapp/WEB-INF/tags/sidebarNavigation.tag | 6 +- .../WEB-INF/tags/sidebarSegmentation.tag | 2 +- src/main/webapp/WEB-INF/tags/sidebarText.tag | 2 +- .../WEB-INF/tags/virtualKeyboardAdd.tag | 4 +- .../tags/virtualKeyboardPresetModal.tag | 4 +- src/main/webapp/WEB-INF/views/editor.jsp | 2 +- src/main/webapp/WEB-INF/views/error.jsp | 2 +- src/main/webapp/WEB-INF/views/lib.jsp | 2 +- src/main/webapp/WEB-INF/web.xml | 10 +-- 28 files changed, 99 insertions(+), 112 deletions(-) diff --git a/pom.xml b/pom.xml index 7256f9ba..abe3ad32 100644 --- a/pom.xml +++ b/pom.xml @@ -13,9 +13,9 @@ https://github.com/OCR4all/LAREX - 1.2 - 1.8 - 5.2.24.RELEASE + 3.0.0 + 21 + 6.1.14 3.2.8 1.5.6 2.1.0-alpha1 @@ -23,57 +23,55 @@ - - jstl - jstl - 1.2 + jakarta.servlet.jsp.jstl + jakarta.servlet.jsp.jstl-api + ${jstl.version} - - - org.springframework - spring-core - ${spring.version} + org.glassfish.web + jakarta.servlet.jsp.jstl + 3.0.1 + org.springframework - spring-web + spring-context ${spring.version} - org.springframework - spring-context + spring-web ${spring.version} - org.springframework spring-webmvc ${spring.version} + org.springframework - spring-orm + spring-test ${spring.version} jar - compile + test + ch.qos.logback logback-classic ${logback.version} - + org.slf4j slf4j-api ${log.sl4j.version} - + @@ -87,14 +85,6 @@ 1.4.0 - - org.springframework - spring-test - ${spring.version} - jar - test - - cglib @@ -103,35 +93,36 @@ runtime - - javax.servlet - javax.servlet-api - 4.0.1 + jakarta.servlet + jakarta.servlet-api + 6.1.0 provided + - javax.servlet.jsp - javax.servlet.jsp-api - 2.3.3 - provided + jakarta.annotation + jakarta.annotation-api + 3.0.0 + + com.fasterxml.jackson.core jackson-core - 2.13.0 + 2.18.2 com.fasterxml.jackson.core jackson-databind - 2.13.4.2 + 2.18.2 org.openpnp opencv - 4.6.0-0 + 4.9.0-0 @@ -169,11 +160,6 @@ Maths 1.5b - - javax.annotation - javax.annotation-api - 1.3.2 - org.locationtech.jts @@ -200,6 +186,11 @@ Internal project repository file://${basedir}/src/lib/repository + + maven_central + Maven Central + https://repo.maven.apache.org/maven2/ + @@ -235,4 +226,4 @@ - \ No newline at end of file + diff --git a/src/main/java/de/uniwue/web/config/MvcConfiguration.java b/src/main/java/de/uniwue/web/config/MvcConfiguration.java index 00bd3573..642108a8 100644 --- a/src/main/java/de/uniwue/web/config/MvcConfiguration.java +++ b/src/main/java/de/uniwue/web/config/MvcConfiguration.java @@ -6,7 +6,7 @@ import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.http.CacheControl; -import org.springframework.web.multipart.commons.CommonsMultipartResolver; +import org.springframework.web.multipart.support.StandardServletMultipartResolver; import org.springframework.web.servlet.ViewResolver; import org.springframework.web.servlet.config.annotation.EnableWebMvc; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; @@ -15,7 +15,7 @@ /** * Basic MVC Configuration for the folder configuration and system library. - * + * */ @Configuration @ComponentScan(basePackages = "com.web") @@ -23,13 +23,12 @@ public class MvcConfiguration implements WebMvcConfigurer { /* - * System library for openCV + * System library for openCV */ static { - nu.pattern.OpenCV.loadShared(); - System.loadLibrary(org.opencv.core.Core.NATIVE_LIBRARY_NAME); + nu.pattern.OpenCV.loadLocally(); } - + @Bean public ViewResolver getViewResolver() { InternalResourceViewResolver resolver = new InternalResourceViewResolver(); @@ -39,12 +38,10 @@ public ViewResolver getViewResolver() { } @Bean(name = "multipartResolver") - public CommonsMultipartResolver createMultipartResolver() { - CommonsMultipartResolver resolver=new CommonsMultipartResolver(); - resolver.setDefaultEncoding("utf-8"); - return resolver; + public StandardServletMultipartResolver createMultipartResolver() { + return new StandardServletMultipartResolver(); } - + @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { registry.addResourceHandler("/resources/**").addResourceLocations("/resources/") diff --git a/src/main/java/de/uniwue/web/controller/DataController.java b/src/main/java/de/uniwue/web/controller/DataController.java index c4a6db8c..3fa0596a 100644 --- a/src/main/java/de/uniwue/web/controller/DataController.java +++ b/src/main/java/de/uniwue/web/controller/DataController.java @@ -8,10 +8,10 @@ import java.util.Collection; import java.util.List; -import javax.annotation.PostConstruct; -import javax.servlet.ServletContext; +import jakarta.servlet.ServletContext; import de.uniwue.web.communication.BatchLoadRequest; +import jakarta.annotation.PostConstruct; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Controller; diff --git a/src/main/java/de/uniwue/web/controller/FileController.java b/src/main/java/de/uniwue/web/controller/FileController.java index 3b2889ed..40e75ed2 100644 --- a/src/main/java/de/uniwue/web/controller/FileController.java +++ b/src/main/java/de/uniwue/web/controller/FileController.java @@ -8,11 +8,11 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; -import javax.annotation.PostConstruct; +import jakarta.annotation.PostConstruct; import javax.imageio.ImageIO; -import javax.servlet.ServletContext; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; +import jakarta.servlet.ServletContext; +import jakarta.servlet.http.HttpServletResponse; +import jakarta.servlet.http.HttpSession; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerFactory; @@ -42,7 +42,6 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.multipart.MultipartFile; -import org.springframework.web.multipart.commons.CommonsMultipartFile; import org.w3c.dom.Document; import de.uniwue.algorithm.data.MemoryCleaner; @@ -109,11 +108,10 @@ private void init() { public ResponseEntity getImage(@PathVariable("imageEnc") final String imageEnc, @RequestParam(value = "resize", defaultValue = "false") boolean doResize) throws IOException { try { - File imageFile; byte[] imageBytes = null; String image = java.net.URLDecoder.decode(imageEnc, StandardCharsets.UTF_8.name()).replaceAll("‡","/"); - if(image.startsWith("\"")) { image = image.substring(1); } + image = image.replaceFirst("^\"", "").replaceFirst("\"$", ""); if(fileManager.checkFlat()) { // Find file with image name final File directory = new File(fileManager.getLocalBooksPath() + File.separator); @@ -202,11 +200,11 @@ public ResponseEntity getImage(@PathVariable("imageEnc") final String im * */ @RequestMapping(value = "file/upload/annotations", method = RequestMethod.POST, headers = "Accept=*/*") - public @ResponseBody PageAnnotations uploadSegmentation(@RequestParam("file") CommonsMultipartFile multipart, + public @ResponseBody PageAnnotations uploadSegmentation(@RequestParam("file") MultipartFile multipart, @RequestParam("pageNr") int pageNr, @RequestParam("bookID") int bookID, @RequestParam("xmlName") String xmlName) throws IOException { - multipart.getFileItem().getName(); + multipart.getName(); File file = new File(xmlName); FileUtils.writeByteArrayToFile(file, multipart.getBytes()); FileUtils.writeByteArrayToFile(file, multipart.getBytes()); @@ -411,7 +409,7 @@ private File getXMLFilePath(String xmlName, Integer bookid){ if(!savedir.endsWith(File.separator)) { savedir += File.separator; } return new File(savedir + xmlName); } else { - logger.error("Warning: Save dir {} not set. File {} could not been saved.", + logger.error("Warning: Save dir {} not set. File {} could not been saved.", savedir, xmlName); } } else { diff --git a/src/main/java/de/uniwue/web/controller/LibraryController.java b/src/main/java/de/uniwue/web/controller/LibraryController.java index 8a8af688..30625862 100644 --- a/src/main/java/de/uniwue/web/controller/LibraryController.java +++ b/src/main/java/de/uniwue/web/controller/LibraryController.java @@ -4,13 +4,13 @@ import java.nio.charset.StandardCharsets; import java.util.*; -import javax.annotation.PostConstruct; -import javax.servlet.ServletContext; +import jakarta.servlet.ServletContext; import de.uniwue.web.communication.DirectRequest; import de.uniwue.web.config.Constants; import de.uniwue.web.io.MetsReader; +import jakarta.annotation.PostConstruct; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -177,7 +177,7 @@ public String home(Model model) throws IOException { } return directRequest; } - + /** * returns each imagePath in given directory * respecting the SubExtensionFilter set in properties diff --git a/src/main/java/de/uniwue/web/controller/SegmentationController.java b/src/main/java/de/uniwue/web/controller/SegmentationController.java index 4d994861..747ca5e8 100644 --- a/src/main/java/de/uniwue/web/controller/SegmentationController.java +++ b/src/main/java/de/uniwue/web/controller/SegmentationController.java @@ -4,10 +4,10 @@ import java.util.ArrayList; import java.util.List; -import javax.annotation.PostConstruct; -import javax.servlet.ServletContext; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; +import jakarta.annotation.PostConstruct; +import jakarta.servlet.ServletContext; +import jakarta.servlet.http.HttpServletResponse; +import jakarta.servlet.http.HttpSession; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; diff --git a/src/main/java/de/uniwue/web/controller/ViewerController.java b/src/main/java/de/uniwue/web/controller/ViewerController.java index eb337590..0fbf0db5 100644 --- a/src/main/java/de/uniwue/web/controller/ViewerController.java +++ b/src/main/java/de/uniwue/web/controller/ViewerController.java @@ -6,8 +6,7 @@ import java.nio.file.Files; import java.util.*; -import javax.annotation.PostConstruct; -import javax.servlet.ServletContext; +import jakarta.servlet.ServletContext; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.databind.ObjectMapper; @@ -30,6 +29,8 @@ import de.uniwue.web.io.FilePathManager; import de.uniwue.web.model.Book; +import jakarta.annotation.PostConstruct; + /** * Communication Controller to handle requests for the main viewer/editor. * Handles requests about displaying book scans and segmentations. diff --git a/src/main/java/de/uniwue/web/io/FilePathManager.java b/src/main/java/de/uniwue/web/io/FilePathManager.java index 6b979c6e..b692ab85 100644 --- a/src/main/java/de/uniwue/web/io/FilePathManager.java +++ b/src/main/java/de/uniwue/web/io/FilePathManager.java @@ -4,7 +4,7 @@ import java.util.List; import java.util.Map; -import javax.servlet.ServletContext; +import jakarta.servlet.ServletContext; import de.uniwue.web.communication.DirectRequest; import org.springframework.context.annotation.Scope; diff --git a/src/main/webapp/WEB-INF/tags/base/baseMenu.tag b/src/main/webapp/WEB-INF/tags/base/baseMenu.tag index d08206d4..d3e4ac77 100644 --- a/src/main/webapp/WEB-INF/tags/base/baseMenu.tag +++ b/src/main/webapp/WEB-INF/tags/base/baseMenu.tag @@ -1,5 +1,5 @@ <%@tag description="Menu Icon" pageEncoding="UTF-8"%> -<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> +<%@ taglib uri="jakarta.tags.core" prefix="c" %> <%@ taglib prefix="t" tagdir="/WEB-INF/tags"%>
diff --git a/src/main/webapp/WEB-INF/tags/batchSegmentModal.tag b/src/main/webapp/WEB-INF/tags/batchSegmentModal.tag index d04255fe..d71baa20 100644 --- a/src/main/webapp/WEB-INF/tags/batchSegmentModal.tag +++ b/src/main/webapp/WEB-INF/tags/batchSegmentModal.tag @@ -1,5 +1,5 @@ <%@tag description="Main Body Tag" pageEncoding="UTF-8" %> -<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> +<%@ taglib uri="jakarta.tags.core" prefix="c" %> <%@ taglib prefix="t" tagdir="/WEB-INF/tags" %>
- \ No newline at end of file + diff --git a/src/main/webapp/WEB-INF/tags/contextmenu.tag b/src/main/webapp/WEB-INF/tags/contextmenu.tag index ffcb5d0a..ecbced6d 100644 --- a/src/main/webapp/WEB-INF/tags/contextmenu.tag +++ b/src/main/webapp/WEB-INF/tags/contextmenu.tag @@ -1,5 +1,5 @@ <%@tag description="Main Body Tag" pageEncoding="UTF-8"%> -<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> +<%@ taglib uri="jakarta.tags.core" prefix="c" %>
@@ -46,4 +46,4 @@
- \ No newline at end of file + diff --git a/src/main/webapp/WEB-INF/tags/keyboardShortcutModal.tag b/src/main/webapp/WEB-INF/tags/keyboardShortcutModal.tag index 5829cdb7..ad42b7a1 100644 --- a/src/main/webapp/WEB-INF/tags/keyboardShortcutModal.tag +++ b/src/main/webapp/WEB-INF/tags/keyboardShortcutModal.tag @@ -1,5 +1,5 @@ <%@tag description="Tag for changing and displaying the settings of a region" pageEncoding="UTF-8"%> -<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> +<%@ taglib uri="jakarta.tags.core" prefix="c" %>