From 56b72d75fe6795d8113bc2475ae9546af66f10c8 Mon Sep 17 00:00:00 2001 From: Rene Meier Date: Fri, 18 Oct 2024 19:05:24 +0200 Subject: [PATCH] Upgrade to tommee 9, move to jakarta namespace, add deprecated aristo theme to primefaces, remove incompatible commons-fileupload, upgrade required dependencies. --- .github/workflows/docker-image.yml | 27 +++++++--- Dockerfile | 2 +- MetFragLib/pom.xml | 4 -- .../settings/MetFragGlobalSettings.java | 6 ++- MetFragWeb/pom.xml | 16 ++++-- .../container/AvailableParameters.java | 4 +- .../container/BeanSettingsContainer.java | 6 +-- .../controller/CompareSpectraD3JSBean.java | 14 +++--- .../controller/MetFragLandingBean.java | 10 ++-- .../metfragweb/controller/MetFragWebBean.java | 37 +++++++------- .../metfragweb/datatype/AvailableScore.java | 2 +- .../datatype/CandidateStatistics.java | 2 +- .../metfragweb/datatype/DownloadResource.java | 4 +- .../ViewExpiredExceptionExceptionHandler.java | 16 +++--- ...piredExceptionExceptionHandlerFactory.java | 4 +- .../helper/ProcessCompoundsThreadRunner.java | 2 +- .../helper/UserOutputDataHandler.java | 50 ++++++++++++++----- .../validator/DoubleValueValidator.java | 10 ++-- .../validator/ElementsValidator.java | 10 ++-- .../validator/FormulaValidator.java | 10 ++-- .../validator/PeakListValidator.java | 10 ++-- .../PositiveDoubleValueValidator.java | 10 ++-- .../validator/SearchPPMValidator.java | 12 ++--- .../validator/SmartsExpressionValidator.java | 10 ++-- .../metfragweb/validator/SmartsValidator.java | 10 ++-- MetFragWeb/src/main/webapp/WEB-INF/web.xml | 26 ++++------ pom.xml | 17 ++++--- 27 files changed, 184 insertions(+), 147 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index aa54647a..f73a3fa9 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -2,30 +2,43 @@ name: Docker Image on: push: - branches: [ master ] + branches: + - 'master' + - 'dev' + tags: + - 'v*' jobs: docker: - runs-on: ubuntu-latest steps: + - name: Checkout + uses: actions/checkout@v4 - name: Log in to Docker Hub - uses: docker/login-action@v1 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - name: Extract metadata (tags, labels) for Docker id: meta - uses: docker/metadata-action@v3 + uses: docker/metadata-action@v5 with: images: ipbhalle/metfragweb + tags: | + # tag event + type=ref,event=tag + # set latest tag for main branch and tags + type=raw,value=latest,enable=${{ github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') }} + # set dev tag for dev branch + type=raw,value=dev,enable=${{ github.ref == 'refs/heads/dev'}} - name: Build and push Docker image - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v5 with: - push: true - tags: ipbhalle/metfragweb:latest + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} cache-from: type=registry,ref=ipbhalle/metfragweb:latest cache-to: type=inline diff --git a/Dockerfile b/Dockerfile index 23e144a9..46db9a20 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,7 +14,7 @@ LocalDatabasesFolderForWeb = /vol/file_databases' > /MetFragRelaunched/MetFragWe RUN mvn -Dhttps.protocols=TLSv1.2 -f MetFragRelaunched clean package -pl MetFragLib -pl MetFragWeb -am -DskipTests -FROM tomee:8.0.15 +FROM tomee:9 RUN set -eux; \ apt-get update; \ diff --git a/MetFragLib/pom.xml b/MetFragLib/pom.xml index 007afff3..0df64bd8 100644 --- a/MetFragLib/pom.xml +++ b/MetFragLib/pom.xml @@ -74,10 +74,6 @@ org.apache.logging.log4j log4j-core - - org.apache.logging.log4j - log4j-core - org.openjdk.nashorn nashorn-core diff --git a/MetFragLib/src/main/java/de/ipbhalle/metfraglib/settings/MetFragGlobalSettings.java b/MetFragLib/src/main/java/de/ipbhalle/metfraglib/settings/MetFragGlobalSettings.java index b239362d..cd829f85 100644 --- a/MetFragLib/src/main/java/de/ipbhalle/metfraglib/settings/MetFragGlobalSettings.java +++ b/MetFragLib/src/main/java/de/ipbhalle/metfraglib/settings/MetFragGlobalSettings.java @@ -167,7 +167,8 @@ public static MetFragGlobalSettings readSettings(java.io.File parameterFile, Log * check whether the current parameter has already been defined */ if (setParameters.contains(tmp[0].trim())) { - logger.error(tmp[0].trim() + " was already defined in the parameter file."); + if (logger != null) + logger.error(tmp[0].trim() + " was already defined in the parameter file."); parameterFileReader.close(); throw new Exception(); } @@ -181,7 +182,8 @@ public static MetFragGlobalSettings readSettings(java.io.File parameterFile, Log settings.set(tmp[0].trim(), ParameterDataTypes.getParameter(valueString.trim(), tmp[0].trim())); } catch(Exception e) { - logger.error("Error in parameter file at \"" + line + " \""); + if (logger != null) + logger.error("Error in parameter file at \"" + line + " \""); parameterFileReader.close(); throw new Exception("Error in parameter file at \"" + line + " \""); } diff --git a/MetFragWeb/pom.xml b/MetFragWeb/pom.xml index 50cc87a5..bbf9e3ba 100644 --- a/MetFragWeb/pom.xml +++ b/MetFragWeb/pom.xml @@ -21,7 +21,7 @@ 1.9.13 - tomee8x + tomee9x @@ -54,13 +54,14 @@ org.apache.commons commons-email - - commons-fileupload - commons-fileupload - + + + + org.primefaces primefaces + jakarta jakarta.platform @@ -74,5 +75,10 @@ org.apache.logging.log4j log4j-core + + org.primefaces.themes + aristo + 1.1.0 + diff --git a/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/container/AvailableParameters.java b/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/container/AvailableParameters.java index 191f35ac..dfa65e00 100644 --- a/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/container/AvailableParameters.java +++ b/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/container/AvailableParameters.java @@ -7,8 +7,8 @@ import java.util.Comparator; import java.util.Hashtable; -import javax.faces.model.SelectItem; -import javax.faces.model.SelectItemGroup; +import jakarta.faces.model.SelectItem; +import jakarta.faces.model.SelectItemGroup; import de.ipbhalle.metfraglib.parameter.ClassNames; import de.ipbhalle.metfraglib.parameter.Constants; diff --git a/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/container/BeanSettingsContainer.java b/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/container/BeanSettingsContainer.java index 151858de..0b87bf5c 100644 --- a/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/container/BeanSettingsContainer.java +++ b/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/container/BeanSettingsContainer.java @@ -6,9 +6,9 @@ import java.util.HashMap; import java.util.List; -import javax.faces.context.FacesContext; -import javax.faces.model.SelectItem; -import javax.servlet.ServletContext; +import jakarta.faces.context.FacesContext; +import jakarta.faces.model.SelectItem; +import jakarta.servlet.ServletContext; import org.apache.log4j.Level; import org.primefaces.model.chart.AxisType; diff --git a/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/controller/CompareSpectraD3JSBean.java b/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/controller/CompareSpectraD3JSBean.java index 546ff690..0f7af661 100644 --- a/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/controller/CompareSpectraD3JSBean.java +++ b/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/controller/CompareSpectraD3JSBean.java @@ -4,14 +4,14 @@ import java.io.IOException; import java.util.Random; -import javax.faces.bean.ManagedBean; -import javax.faces.bean.SessionScoped; -import javax.faces.context.FacesContext; -import javax.faces.event.ActionEvent; +import jakarta.faces.bean.ManagedBean; +import jakarta.faces.bean.SessionScoped; +import jakarta.faces.context.FacesContext; +import jakarta.faces.event.ActionEvent; import javax.imageio.ImageIO; -import javax.servlet.ServletContext; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpSession; +import jakarta.servlet.ServletContext; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpSession; import org.apache.commons.io.FileUtils; import org.openscience.cdk.exception.CDKException; diff --git a/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/controller/MetFragLandingBean.java b/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/controller/MetFragLandingBean.java index 6c5fced2..e68d3218 100644 --- a/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/controller/MetFragLandingBean.java +++ b/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/controller/MetFragLandingBean.java @@ -1,15 +1,15 @@ package de.ipbhalle.metfragweb.controller; -import javax.annotation.PostConstruct; -import javax.faces.bean.ManagedBean; -import javax.faces.bean.RequestScoped; -import javax.faces.context.FacesContext; +import jakarta.annotation.PostConstruct; +import jakarta.faces.bean.ManagedBean; +import jakarta.faces.bean.RequestScoped; +import jakarta.faces.context.FacesContext; import de.ipbhalle.metfraglib.parameter.Constants; import de.ipbhalle.metfraglib.parameter.VariableNames; import de.ipbhalle.metfragweb.datatype.Parameter; -import javax.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletRequest; import org.primefaces.PrimeFaces; diff --git a/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/controller/MetFragWebBean.java b/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/controller/MetFragWebBean.java index 6ba6f536..c9934011 100644 --- a/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/controller/MetFragWebBean.java +++ b/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/controller/MetFragWebBean.java @@ -6,17 +6,17 @@ import java.net.UnknownHostException; import java.util.List; -import javax.annotation.PostConstruct; -import javax.faces.application.FacesMessage; -import javax.faces.bean.ManagedBean; -import javax.faces.bean.SessionScoped; -import javax.faces.context.FacesContext; -import javax.faces.event.ActionEvent; -import javax.faces.model.SelectItem; +import jakarta.annotation.PostConstruct; +import jakarta.faces.application.FacesMessage; +import jakarta.faces.bean.ManagedBean; +import jakarta.faces.bean.SessionScoped; +import jakarta.faces.context.FacesContext; +import jakarta.faces.event.ActionEvent; +import jakarta.faces.model.SelectItem; import javax.imageio.ImageIO; -import javax.servlet.ServletContext; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpSession; +import jakarta.servlet.ServletContext; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpSession; import org.apache.commons.io.FileUtils; import org.apache.commons.mail.EmailAttachment; @@ -31,6 +31,7 @@ import org.primefaces.event.organigram.OrganigramNodeSelectEvent; import org.primefaces.model.OrganigramNode; import org.primefaces.model.StreamedContent; +import org.primefaces.model.DefaultStreamedContent; import org.primefaces.model.chart.AxisType; import org.primefaces.model.chart.LineChartModel; import org.primefaces.model.chart.LineChartSeries; @@ -276,7 +277,7 @@ public void parametersUploadListener(org.primefaces.event.FileUploadEvent event) /* * database search settings */ - public java.util.List getAvailableDatabases() { + public java.util.List getAvailableDatabases() { return this.beanSettingsContainer.getAvailableParameters().getDatabases(); } @@ -907,7 +908,7 @@ public void setExcludedElements(String excludedFilterElements) { } //SMARTS inclusion - public java.util.List getAvailableSubstructureSmarts() { + public java.util.List getAvailableSubstructureSmarts() { return this.beanSettingsContainer.getAvailableParameters().getSubstructureSmarts(); } @@ -1069,7 +1070,7 @@ public void setSelectedInformationSmarts(String selectedSmarts) { this.beanSettingsContainer.setSelectedInformationSmarts(selectedSmarts); } - public java.util.List getAvailableSubstructureInformationSmarts() { + public java.util.List getAvailableSubstructureInformationSmarts() { return this.beanSettingsContainer.getAvailableParameters().getSubstructureInformationSmarts(); } @@ -1813,11 +1814,11 @@ private boolean checkScoreSettings() { /* * fragmenter settings */ - public java.util.List getPrecursorModes() { + public java.util.List getPrecursorModes() { return this.beanSettingsContainer.getAvailableParameters().getPrecursorModes(); } - public java.util.List getTreeDepths() { + public java.util.List getTreeDepths() { return this.beanSettingsContainer.getAvailableParameters().getTreeDepths(); } @@ -2013,7 +2014,7 @@ public org.primefaces.model.StreamedContent getDownloadParameters() { try { resource = this.beanSettingsContainer.getUserOutputDataHandler().getDownloadParameters(this.errorMessages, pathToProperties); } catch(Exception e) { - resource = new org.primefaces.model.DefaultStreamedContent(System.in, "application/zip", "MetFragWeb_Parameters.zip"); + resource = DefaultStreamedContent.builder().contentType("application/zip").name("MetFragWeb_Parameters.zip").stream(() -> System.in).build(); } return resource; } @@ -2702,7 +2703,7 @@ public void closeScoresView() { * @return */ public org.primefaces.model.StreamedContent generateCandidateDownloadFile() { - org.primefaces.model.StreamedContent resource = new org.primefaces.model.DefaultStreamedContent(System.in, "application/vnd.ms-excel", "MetFragWeb_Candidate.xls" ); + org.primefaces.model.StreamedContent resource = DefaultStreamedContent.builder().contentType("application/vnd.ms-excel").name("MetFragWeb_Candidate.xls").stream(() -> System.in).build(); try { resource = this.beanSettingsContainer.getUserOutputDataHandler().generatedCandidateDownloadFile(this.currentScoreCandidate, this.beanSettingsContainer.getMetFragSettings()); } catch (Exception e1) { @@ -3005,7 +3006,7 @@ public void viewExpiredListener() { System.out.println("session expired " + this.beanSettingsContainer.getRootSessionFolder()); FacesContext fc = FacesContext.getCurrentInstance(); java.util.Map requestMap = fc.getExternalContext().getRequestMap(); - javax.faces.application.NavigationHandler nav = + jakarta.faces.application.NavigationHandler nav = fc.getApplication().getNavigationHandler(); // Push some useful stuff to the request scope for // use in the page diff --git a/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/datatype/AvailableScore.java b/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/datatype/AvailableScore.java index 66658b3e..59b79d11 100644 --- a/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/datatype/AvailableScore.java +++ b/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/datatype/AvailableScore.java @@ -2,7 +2,7 @@ import java.io.Serializable; -import javax.faces.model.SelectItem; +import jakarta.faces.model.SelectItem; public class AvailableScore extends SelectItem implements Serializable, Comparable { diff --git a/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/datatype/CandidateStatistics.java b/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/datatype/CandidateStatistics.java index b5b68622..82c5f398 100644 --- a/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/datatype/CandidateStatistics.java +++ b/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/datatype/CandidateStatistics.java @@ -2,7 +2,7 @@ import java.util.List; -import javax.faces.model.SelectItem; +import jakarta.faces.model.SelectItem; import org.primefaces.model.chart.AxisType; import org.primefaces.model.chart.LineChartModel; diff --git a/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/datatype/DownloadResource.java b/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/datatype/DownloadResource.java index ecded1e6..ddbd8ff2 100644 --- a/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/datatype/DownloadResource.java +++ b/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/datatype/DownloadResource.java @@ -7,8 +7,8 @@ import java.util.HashMap; import java.util.Map; -import javax.faces.application.Resource; -import javax.faces.context.FacesContext; +import jakarta.faces.application.Resource; +import jakarta.faces.context.FacesContext; public class DownloadResource extends Resource implements java.io.Serializable { diff --git a/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/exception/ViewExpiredExceptionExceptionHandler.java b/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/exception/ViewExpiredExceptionExceptionHandler.java index e2ab2db6..8e550d3f 100644 --- a/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/exception/ViewExpiredExceptionExceptionHandler.java +++ b/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/exception/ViewExpiredExceptionExceptionHandler.java @@ -3,14 +3,14 @@ import java.util.Iterator; import java.util.Map; -import javax.faces.FacesException; -import javax.faces.application.NavigationHandler; -import javax.faces.application.ViewExpiredException; -import javax.faces.context.ExceptionHandler; -import javax.faces.context.ExceptionHandlerWrapper; -import javax.faces.context.FacesContext; -import javax.faces.event.ExceptionQueuedEvent; -import javax.faces.event.ExceptionQueuedEventContext; +import jakarta.faces.FacesException; +import jakarta.faces.application.NavigationHandler; +import jakarta.faces.application.ViewExpiredException; +import jakarta.faces.context.ExceptionHandler; +import jakarta.faces.context.ExceptionHandlerWrapper; +import jakarta.faces.context.FacesContext; +import jakarta.faces.event.ExceptionQueuedEvent; +import jakarta.faces.event.ExceptionQueuedEventContext; import org.primefaces.PrimeFaces; diff --git a/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/exception/ViewExpiredExceptionExceptionHandlerFactory.java b/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/exception/ViewExpiredExceptionExceptionHandlerFactory.java index 9261179a..13c092ea 100644 --- a/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/exception/ViewExpiredExceptionExceptionHandlerFactory.java +++ b/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/exception/ViewExpiredExceptionExceptionHandlerFactory.java @@ -1,7 +1,7 @@ package de.ipbhalle.metfragweb.exception; -import javax.faces.context.ExceptionHandler; -import javax.faces.context.ExceptionHandlerFactory; +import jakarta.faces.context.ExceptionHandler; +import jakarta.faces.context.ExceptionHandlerFactory; import de.ipbhalle.metfragweb.exception.ViewExpiredExceptionExceptionHandler; public class ViewExpiredExceptionExceptionHandlerFactory extends ExceptionHandlerFactory { diff --git a/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/helper/ProcessCompoundsThreadRunner.java b/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/helper/ProcessCompoundsThreadRunner.java index f1b9cdf3..1e041f15 100644 --- a/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/helper/ProcessCompoundsThreadRunner.java +++ b/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/helper/ProcessCompoundsThreadRunner.java @@ -4,7 +4,7 @@ import java.io.IOException; import java.util.ArrayList; -import javax.faces.model.SelectItem; +import jakarta.faces.model.SelectItem; import javax.imageio.ImageIO; import org.apache.commons.io.FileUtils; diff --git a/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/helper/UserOutputDataHandler.java b/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/helper/UserOutputDataHandler.java index 3d56fc6f..b030aeb0 100644 --- a/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/helper/UserOutputDataHandler.java +++ b/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/helper/UserOutputDataHandler.java @@ -1,6 +1,8 @@ package de.ipbhalle.metfragweb.helper; import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; import org.primefaces.model.DefaultStreamedContent; @@ -41,12 +43,12 @@ public UserOutputDataHandler(BeanSettingsContainer beanSettingsContainer) { * @throws Exception */ public org.primefaces.model.StreamedContent generatedCandidateDownloadFile(MetFragResult metfragResult, Settings settings) throws Exception { - org.primefaces.model.StreamedContent resource = new DefaultStreamedContent(System.in, "application/vnd.ms-excel", "MetFragWeb_Candidate.xls" ); + org.primefaces.model.StreamedContent resource = DefaultStreamedContent.builder().contentType("application/vnd.ms-excel").name("MetFragWeb_Candidate.xls").stream(() -> System.in).build(); if(metfragResult == null) { System.out.println("generatedCandidateDownloadFile null"); return resource; } - resource = new DefaultStreamedContent(System.in, "application/vnd.ms-excel", "MetFragWeb_Candidate_" + metfragResult.getIdentifier() + ".xls" ); + resource = DefaultStreamedContent.builder().contentType("application/vnd.ms-excel").name("MetFragWeb_Candidate_" + metfragResult.getIdentifier() + ".xls").stream(() -> System.in).build(); //only main molecule is written to the output Molecule root = metfragResult.getRoot(); @@ -77,8 +79,14 @@ public org.primefaces.model.StreamedContent generatedCandidateDownloadFile(MetFr System.out.println("generating resource"); if(writer.write(scoredCandidateListSingle, "MetFragWeb_Candidate_" + candidate.getIdentifier(), folder.getAbsolutePath(), settings)) { String filePath = folder.getAbsolutePath() + Constants.OS_SPECIFIC_FILE_SEPARATOR + "MetFragWeb_Candidate_" + candidate.getIdentifier() + ".xls"; - resource = new org.primefaces.model.DefaultStreamedContent(new java.io.FileInputStream(new java.io.File(filePath)), "application/vnd.ms-excel", "MetFragWeb_Candidate_" + candidate.getIdentifier() + ".xls"); - } + resource = DefaultStreamedContent.builder().contentType("application/vnd.ms-excel").name("MetFragWeb_Candidate_" + metfragResult.getIdentifier() + ".xls").stream(() -> { + try { + return new FileInputStream(new File(filePath)); + } catch (FileNotFoundException e) { + throw new RuntimeException(e); + } + }).build(); + } else return resource; } catch (Exception e) { e.printStackTrace(); @@ -96,7 +104,7 @@ public org.primefaces.model.StreamedContent generatedCandidateDownloadFile(MetFr * @throws Exception */ public org.primefaces.model.StreamedContent getDownloadParameters(Messages errorMessages, String pathToProperties) throws Exception { - org.primefaces.model.StreamedContent resource = new org.primefaces.model.DefaultStreamedContent(System.in, "application/zip", "MetFragWeb_Parameters.zip"); + org.primefaces.model.StreamedContent resource = DefaultStreamedContent.builder().contentType("application/zip").name("MetFragWeb_Parameters.zip").stream(() -> System.in).build(); //this.deactivateDownloadCandidatesButton(); try { File storeFolder = this.fileStorer.prepareFolder(this.beanSettingsContainer.getRootSessionFolder() + Constants.OS_SPECIFIC_FILE_SEPARATOR + "downloads" + Constants.OS_SPECIFIC_FILE_SEPARATOR + "parameters", errorMessages); @@ -249,7 +257,13 @@ else if(library.equals("kegg")) { inFile.close(); zos.closeEntry(); zos.close(); - resource = new org.primefaces.model.DefaultStreamedContent(new java.io.FileInputStream(new java.io.File(storeFolder.getAbsolutePath() + Constants.OS_SPECIFIC_FILE_SEPARATOR + "MetFragWeb_Parameters.zip")), "application/zip", "MetFragWeb_Parameters.zip"); + resource = DefaultStreamedContent.builder().contentType("application/zip").name("MetFragWeb_Parameters.zip").stream(() -> { + try { + return new FileInputStream(new File((storeFolder.getAbsolutePath() + Constants.OS_SPECIFIC_FILE_SEPARATOR + "MetFragWeb_Parameters.zip"))); + } catch (FileNotFoundException e) { + throw new RuntimeException(e); + } + }).build(); } catch (Exception e) { errorMessages.setMessage("buttonDownloadParametersDatabaseError", "Error when downloading parameters."); errorMessages.removeKey("buttonDownloadParametersFilterError"); @@ -270,8 +284,7 @@ public org.primefaces.model.StreamedContent createCandidatesToDownload(String fo System.out.println("downloadCandidates " + format); IWriter candidateWriter = null; String filePath = ""; - org.primefaces.model.StreamedContent resource = new org.primefaces.model.DefaultStreamedContent(System.in, "text/csv", "MetFragWeb_Candidates." + format); - + org.primefaces.model.StreamedContent resource = DefaultStreamedContent.builder().contentType("text/csv").name("MetFragWeb_Candidates." + format).stream(() -> System.in).build(); try { java.io.File folder = new java.io.File(this.beanSettingsContainer.getRootSessionFolder() + Constants.OS_SPECIFIC_FILE_SEPARATOR + "downloads"); System.out.println("creating folder " + folder.getAbsolutePath()); @@ -295,7 +308,14 @@ public org.primefaces.model.StreamedContent createCandidatesToDownload(String fo } candidateWriter.write(this.beanSettingsContainer.getRetrievedCandidateList(), "MetFragWeb_Candidates", folder.getAbsolutePath()); filePath = folder.getAbsolutePath() + Constants.OS_SPECIFIC_FILE_SEPARATOR + "MetFragWeb_Candidates." + format; - resource = new org.primefaces.model.DefaultStreamedContent(new java.io.FileInputStream(new java.io.File(filePath)), mimetype, "MetFragWeb_Candidates." + format); + String finalFilePath = filePath; + resource = DefaultStreamedContent.builder().contentType(mimetype).name("MetFragWeb_Candidates." + format).stream(() -> { + try { + return new FileInputStream(new File(finalFilePath)); + } catch (FileNotFoundException e) { + throw new RuntimeException(e); + } + }).build(); errorMessages.removeKey("buttonDownloadCompoundsError"); } catch (Exception e) { errorMessages.setMessage("buttonDownloadCompoundsError", "Error when downloading candidates."); @@ -315,8 +335,7 @@ public org.primefaces.model.StreamedContent createResultsToDownload(MetFragResul System.out.println("downloadResults " + format); IWriter candidateWriter = null; String filePath = ""; - org.primefaces.model.StreamedContent resource = new org.primefaces.model.DefaultStreamedContent(System.in, "text/csv", "MetFragWeb_Candidates." + format); - + org.primefaces.model.StreamedContent resource = DefaultStreamedContent.builder().contentType("text/csv").name("MetFragWeb_Candidates." + format).stream(() -> System.in).build(); try { java.io.File folder = new java.io.File(this.beanSettingsContainer.getRootSessionFolder() + Constants.OS_SPECIFIC_FILE_SEPARATOR + "downloads"); System.out.println("creating folder " + folder.getAbsolutePath()); @@ -341,7 +360,14 @@ public org.primefaces.model.StreamedContent createResultsToDownload(MetFragResul candidateWriter.write(metfragResults.getScoredCandidateList(), "MetFragWeb_Results", folder.getAbsolutePath()); filePath = folder.getAbsolutePath() + Constants.OS_SPECIFIC_FILE_SEPARATOR + "MetFragWeb_Results." + format; - resource = new org.primefaces.model.DefaultStreamedContent(new java.io.FileInputStream(new java.io.File(filePath)), mimetype, "MetFragWeb_Candidates." + format); + String finalFilePath = filePath; + resource = DefaultStreamedContent.builder().contentType(mimetype).name("MetFragWeb_Candidates." + format).stream(() -> { + try { + return new FileInputStream(new File(finalFilePath)); + } catch (FileNotFoundException e) { + throw new RuntimeException(e); + } + }).build(); errorMessages.removeKey("buttonDownloadResultsError"); } catch (Exception e) { e.printStackTrace(); diff --git a/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/validator/DoubleValueValidator.java b/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/validator/DoubleValueValidator.java index 3df362f8..1a18dabb 100644 --- a/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/validator/DoubleValueValidator.java +++ b/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/validator/DoubleValueValidator.java @@ -1,10 +1,10 @@ package de.ipbhalle.metfragweb.validator; -import javax.faces.application.FacesMessage; -import javax.faces.component.UIComponent; -import javax.faces.context.FacesContext; -import javax.faces.validator.Validator; -import javax.faces.validator.ValidatorException; +import jakarta.faces.application.FacesMessage; +import jakarta.faces.component.UIComponent; +import jakarta.faces.context.FacesContext; +import jakarta.faces.validator.Validator; +import jakarta.faces.validator.ValidatorException; public class DoubleValueValidator implements Validator { diff --git a/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/validator/ElementsValidator.java b/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/validator/ElementsValidator.java index 5994a7d5..5247554d 100644 --- a/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/validator/ElementsValidator.java +++ b/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/validator/ElementsValidator.java @@ -1,10 +1,10 @@ package de.ipbhalle.metfragweb.validator; -import javax.faces.application.FacesMessage; -import javax.faces.component.UIComponent; -import javax.faces.context.FacesContext; -import javax.faces.validator.Validator; -import javax.faces.validator.ValidatorException; +import jakarta.faces.application.FacesMessage; +import jakarta.faces.component.UIComponent; +import jakarta.faces.context.FacesContext; +import jakarta.faces.validator.Validator; +import jakarta.faces.validator.ValidatorException; import de.ipbhalle.metfraglib.parameter.Constants; diff --git a/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/validator/FormulaValidator.java b/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/validator/FormulaValidator.java index bd1912a0..ba5d134b 100644 --- a/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/validator/FormulaValidator.java +++ b/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/validator/FormulaValidator.java @@ -1,10 +1,10 @@ package de.ipbhalle.metfragweb.validator; -import javax.faces.application.FacesMessage; -import javax.faces.component.UIComponent; -import javax.faces.context.FacesContext; -import javax.faces.validator.Validator; -import javax.faces.validator.ValidatorException; +import jakarta.faces.application.FacesMessage; +import jakarta.faces.component.UIComponent; +import jakarta.faces.context.FacesContext; +import jakarta.faces.validator.Validator; +import jakarta.faces.validator.ValidatorException; import de.ipbhalle.metfraglib.molecularformula.ByteMolecularFormula; diff --git a/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/validator/PeakListValidator.java b/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/validator/PeakListValidator.java index 121bf9ae..3d460a29 100644 --- a/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/validator/PeakListValidator.java +++ b/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/validator/PeakListValidator.java @@ -1,10 +1,10 @@ package de.ipbhalle.metfragweb.validator; -import javax.faces.application.FacesMessage; -import javax.faces.component.UIComponent; -import javax.faces.context.FacesContext; -import javax.faces.validator.Validator; -import javax.faces.validator.ValidatorException; +import jakarta.faces.application.FacesMessage; +import jakarta.faces.component.UIComponent; +import jakarta.faces.context.FacesContext; +import jakarta.faces.validator.Validator; +import jakarta.faces.validator.ValidatorException; import de.ipbhalle.metfraglib.list.DefaultPeakList; import de.ipbhalle.metfraglib.peak.TandemMassPeak; diff --git a/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/validator/PositiveDoubleValueValidator.java b/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/validator/PositiveDoubleValueValidator.java index 70d48f03..5c2f181c 100644 --- a/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/validator/PositiveDoubleValueValidator.java +++ b/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/validator/PositiveDoubleValueValidator.java @@ -1,10 +1,10 @@ package de.ipbhalle.metfragweb.validator; -import javax.faces.application.FacesMessage; -import javax.faces.component.UIComponent; -import javax.faces.context.FacesContext; -import javax.faces.validator.Validator; -import javax.faces.validator.ValidatorException; +import jakarta.faces.application.FacesMessage; +import jakarta.faces.component.UIComponent; +import jakarta.faces.context.FacesContext; +import jakarta.faces.validator.Validator; +import jakarta.faces.validator.ValidatorException; public class PositiveDoubleValueValidator implements Validator { diff --git a/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/validator/SearchPPMValidator.java b/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/validator/SearchPPMValidator.java index 12c3dd49..e2e502ae 100644 --- a/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/validator/SearchPPMValidator.java +++ b/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/validator/SearchPPMValidator.java @@ -1,11 +1,11 @@ package de.ipbhalle.metfragweb.validator; -import javax.faces.application.FacesMessage; -import javax.faces.component.UIComponent; -import javax.faces.component.UIInput; -import javax.faces.context.FacesContext; -import javax.faces.validator.Validator; -import javax.faces.validator.ValidatorException; +import jakarta.faces.application.FacesMessage; +import jakarta.faces.component.UIComponent; +import jakarta.faces.component.UIInput; +import jakarta.faces.context.FacesContext; +import jakarta.faces.validator.Validator; +import jakarta.faces.validator.ValidatorException; public class SearchPPMValidator implements Validator { diff --git a/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/validator/SmartsExpressionValidator.java b/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/validator/SmartsExpressionValidator.java index f740e357..1fe3ed59 100644 --- a/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/validator/SmartsExpressionValidator.java +++ b/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/validator/SmartsExpressionValidator.java @@ -1,10 +1,10 @@ package de.ipbhalle.metfragweb.validator; -import javax.faces.application.FacesMessage; -import javax.faces.component.UIComponent; -import javax.faces.context.FacesContext; -import javax.faces.validator.Validator; -import javax.faces.validator.ValidatorException; +import jakarta.faces.application.FacesMessage; +import jakarta.faces.component.UIComponent; +import jakarta.faces.context.FacesContext; +import jakarta.faces.validator.Validator; +import jakarta.faces.validator.ValidatorException; import javax.script.ScriptEngineManager; import javax.script.ScriptException; diff --git a/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/validator/SmartsValidator.java b/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/validator/SmartsValidator.java index 398321f3..7f1d5bdc 100644 --- a/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/validator/SmartsValidator.java +++ b/MetFragWeb/src/main/java/de/ipbhalle/metfragweb/validator/SmartsValidator.java @@ -1,10 +1,10 @@ package de.ipbhalle.metfragweb.validator; -import javax.faces.application.FacesMessage; -import javax.faces.component.UIComponent; -import javax.faces.context.FacesContext; -import javax.faces.validator.Validator; -import javax.faces.validator.ValidatorException; +import jakarta.faces.application.FacesMessage; +import jakarta.faces.component.UIComponent; +import jakarta.faces.context.FacesContext; +import jakarta.faces.validator.Validator; +import jakarta.faces.validator.ValidatorException; import org.openscience.cdk.DefaultChemObjectBuilder; import org.openscience.cdk.exception.CDKException; diff --git a/MetFragWeb/src/main/webapp/WEB-INF/web.xml b/MetFragWeb/src/main/webapp/WEB-INF/web.xml index 75564589..091a3ccc 100644 --- a/MetFragWeb/src/main/webapp/WEB-INF/web.xml +++ b/MetFragWeb/src/main/webapp/WEB-INF/web.xml @@ -16,21 +16,21 @@ application/xml - javax.faces.FACELETS_BUFFER_SIZE + jakarta.faces.FACELETS_BUFFER_SIZE 65535 State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2 - javax.faces.STATE_SAVING_METHOD + jakarta.faces.STATE_SAVING_METHOD server - javax.servlet.jsp.jstl.fmt.localizationContext + jakarta.servlet.jsp.jstl.fmt.localizationContext resources.application Faces Servlet - javax.faces.webapp.FacesServlet + jakarta.faces.webapp.FacesServlet 1 @@ -45,24 +45,16 @@ com.sun.faces.expressionFactory com.sun.el.ExpressionFactoryImpl - - primefaces.UPLOADER - commons - facelets.SKIP_COMMENTS true - - PrimeFaces FileUpload Filter - org.primefaces.webapp.filter.FileUploadFilter - - - PrimeFaces FileUpload Filter - Faces Servlet - + + primefaces.THEME + aristo + - javax.faces.application.ViewExpiredException + jakarta.faces.application.ViewExpiredException /includes/errorpages/viewExpired.xhtml diff --git a/pom.xml b/pom.xml index b5685fee..9cfd1d99 100644 --- a/pom.xml +++ b/pom.xml @@ -108,27 +108,28 @@ org.omnifaces omnifaces - 3.13 + 4.0 org.apache.commons commons-email 1.5 - - commons-fileupload - commons-fileupload - 1.5 - + + + + + org.primefaces primefaces - 8.0 + 10.0.0 + jakarta jakarta.platform jakarta.jakartaee-api - 8.0.0 + 9.0.0 provided