From 52147ba0576c76c8950c3fa44e86d15b97af15a2 Mon Sep 17 00:00:00 2001 From: olivier lamy Date: Thu, 11 May 2017 21:38:51 +1000 Subject: [PATCH] upgrade to jetty 9.4 for archiva-rest-services module Signed-off-by: olivier lamy --- .../archiva-rest-services/pom.xml | 23 +++------- .../rest/services/DefaultPluginsServices.java | 44 ++++++++++--------- .../src/test/resources/log4j2-test.xml | 11 ++--- .../archiva-web/archiva-security/pom.xml | 2 +- .../archiva-web/archiva-web-common/pom.xml | 7 +-- pom.xml | 7 +-- 6 files changed, 38 insertions(+), 56 deletions(-) diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/pom.xml b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/pom.xml index cc4442230..f77fbc188 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/pom.xml +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/pom.xml @@ -37,6 +37,7 @@ --> jdbc:hsqldb:mem:redback-test org.hsqldb.jdbcDriver + 9.4.5.v20170502 @@ -384,24 +385,14 @@ - org.apache.tomcat.embed - tomcat-embed-core - test - - - org.apache.tomcat - tomcat-juli - test + org.eclipse.jetty + jetty-server + ${jetty.version} - org.apache.tomcat.embed - tomcat-embed-logging-juli - test - - - org.apache.tomcat - tomcat-jsp-api - test + org.eclipse.jetty + jetty-servlet + ${jetty.version} xerces diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultPluginsServices.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultPluginsServices.java index 4cab81d47..208400c83 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultPluginsServices.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultPluginsServices.java @@ -18,26 +18,25 @@ package org.apache.archiva.rest.services; * under the License. */ -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - import org.apache.archiva.rest.api.services.ArchivaRestServiceException; -import org.springframework.stereotype.Service; - -import javax.inject.Inject; - import org.apache.archiva.rest.api.services.PluginsService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.ApplicationContext; import org.springframework.core.io.Resource; +import org.springframework.stereotype.Service; + +import javax.inject.Inject; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; /** * @author Eric Barboni * @since 1.4.0 */ -@Service("pluginsService#rest") +@Service( "pluginsService#rest" ) public class DefaultPluginsServices implements PluginsService { @@ -46,7 +45,7 @@ public class DefaultPluginsServices private List adminFeatures = new ArrayList<>(); - private ApplicationContext appCont; + private ApplicationContext applicationContext; private Logger log = LoggerFactory.getLogger( getClass() ); @@ -56,11 +55,14 @@ public class DefaultPluginsServices public DefaultPluginsServices( ApplicationContext applicationContext ) throws IOException { - this.appCont = applicationContext; + log.debug( "init DefaultPluginsServices" ); + this.applicationContext = applicationContext; // rebuild - feed( repositoryType, "repository" ); - feed( adminFeatures, "features" ); + repositoryType = feed( "repository" ); + log.debug( "feed {}:{}", "repository" , repositoryType); + adminFeatures = feed( "features" ); + log.debug( "feed {}:{}", "features", adminFeatures ); StringBuilder sb = new StringBuilder(); for ( String repoType : repositoryType ) { @@ -81,27 +83,29 @@ public class DefaultPluginsServices } } - private void feed( List repository, String key ) + private List feed( String key ) throws IOException { log.info( "Feeding: {}", key ); - repository.clear(); - Resource[] xmlResources; - - xmlResources = appCont.getResources( "/**/" + key + "/**/main.js" ); + Resource[] xmlResources = applicationContext.getResources( "/**/" + key + "/**/main.js" ); + if (xmlResources == null) + { + return Collections.emptyList(); + } + List repository = new ArrayList<>( xmlResources.length ); for ( Resource rc : xmlResources ) { String tmp = rc.getURL().toString(); tmp = tmp.substring( tmp.lastIndexOf( key ) + key.length() + 1, tmp.length() - 8 ); repository.add( "archiva/admin/" + key + "/" + tmp + "/main" ); } - + return repository; } @Override public String getAdminPlugins() throws ArchivaRestServiceException { - return adminPlugins; + return adminPlugins; } } diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/resources/log4j2-test.xml b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/resources/log4j2-test.xml index a7e013916..4d7c9ab07 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/resources/log4j2-test.xml +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/resources/log4j2-test.xml @@ -19,7 +19,7 @@ --> - + @@ -27,13 +27,10 @@ - - + - - - - + + diff --git a/archiva-modules/archiva-web/archiva-security/pom.xml b/archiva-modules/archiva-web/archiva-security/pom.xml index 66aa53b72..121316247 100644 --- a/archiva-modules/archiva-web/archiva-security/pom.xml +++ b/archiva-modules/archiva-web/archiva-security/pom.xml @@ -47,7 +47,7 @@ javax.servlet - servlet-api + javax.servlet-api provided diff --git a/archiva-modules/archiva-web/archiva-web-common/pom.xml b/archiva-modules/archiva-web/archiva-web-common/pom.xml index 6d9c94c15..e3b113a37 100644 --- a/archiva-modules/archiva-web/archiva-web-common/pom.xml +++ b/archiva-modules/archiva-web/archiva-web-common/pom.xml @@ -185,11 +185,6 @@ org.apache.archiva audit - - javax.servlet - javax.servlet-api - provided - javax.ws.rs javax.ws.rs-api @@ -234,7 +229,7 @@ javax.servlet - servlet-api + javax.servlet-api org.springframework diff --git a/pom.xml b/pom.xml index 554c35e73..53b389a32 100644 --- a/pom.xml +++ b/pom.xml @@ -1200,15 +1200,10 @@ geronimo-jpa_2.0_spec 1.1 - - javax.servlet - servlet-api - 2.5 - javax.servlet javax.servlet-api - 3.0.1 + 3.1.0 org.slf4j -- 2.39.5