From: olivier lamy Date: Fri, 26 May 2017 02:04:44 +0000 (+1000) Subject: take of default now jpa, jdo not exists anymore so handle migration X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=4b6131e8bab59139d0558ed6d932d683cdfdbcab;p=archiva.git take of default now jpa, jdo not exists anymore so handle migration Signed-off-by: olivier lamy --- diff --git a/archiva-modules/archiva-base/archiva-configuration/src/main/resources/org/apache/archiva/configuration/default-archiva.xml b/archiva-modules/archiva-base/archiva-configuration/src/main/resources/org/apache/archiva/configuration/default-archiva.xml index 877b6a59b..88beda2e0 100644 --- a/archiva-modules/archiva-base/archiva-configuration/src/main/resources/org/apache/archiva/configuration/default-archiva.xml +++ b/archiva-modules/archiva-base/archiva-configuration/src/main/resources/org/apache/archiva/configuration/default-archiva.xml @@ -144,7 +144,7 @@ - jdo + jpa cached diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/runtime/RedbackRuntimeConfigurationAdmin.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/runtime/RedbackRuntimeConfigurationAdmin.java index 8fae6a66a..c124eacbe 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/runtime/RedbackRuntimeConfigurationAdmin.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/runtime/RedbackRuntimeConfigurationAdmin.java @@ -28,9 +28,9 @@ import org.apache.archiva.admin.model.beans.RedbackRuntimeConfiguration; public interface RedbackRuntimeConfigurationAdmin { - static final String DEFAULT_RBAC_MANAGER_IMPL = "jdo"; + String DEFAULT_RBAC_MANAGER_IMPL = "jpa"; - static final String DEFAULT_USER_MANAGER_IMPL = "jdo"; + String DEFAULT_USER_MANAGER_IMPL = "jpa"; RedbackRuntimeConfiguration getRedbackRuntimeConfiguration() throws RepositoryAdminException; diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/runtime/DefaultRedbackRuntimeConfigurationAdmin.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/runtime/DefaultRedbackRuntimeConfigurationAdmin.java index 3ce727c71..ebd8a64e0 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/runtime/DefaultRedbackRuntimeConfigurationAdmin.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/runtime/DefaultRedbackRuntimeConfigurationAdmin.java @@ -100,6 +100,10 @@ public class DefaultRedbackRuntimeConfigurationAdmin String[] impls = StringUtils.split( userManagerImpl, ',' ); for ( String impl : impls ) { + if (StringUtils.equalsIgnoreCase( "jdo", impl )) + { + impl = DEFAULT_USER_MANAGER_IMPL; + } redbackRuntimeConfiguration.getUserManagerImpls().add( impl ); } } @@ -117,6 +121,10 @@ public class DefaultRedbackRuntimeConfigurationAdmin String[] impls = StringUtils.split( rbacManagerImpls, ',' ); for ( String impl : impls ) { + if (StringUtils.equalsIgnoreCase( "jdo", impl )) + { + impl = DEFAULT_RBAC_MANAGER_IMPL; + } redbackRuntimeConfiguration.getRbacManagerImpls().add( impl ); } } diff --git a/archiva-modules/archiva-web/archiva-web-common/pom.xml b/archiva-modules/archiva-web/archiva-web-common/pom.xml index e44bd69f2..c14197124 100644 --- a/archiva-modules/archiva-web/archiva-web-common/pom.xml +++ b/archiva-modules/archiva-web/archiva-web-common/pom.xml @@ -383,32 +383,6 @@ - - - org.apache.tomcat.embed - tomcat-embed-core - test - - - org.apache.tomcat - tomcat-juli - test - - - org.apache.tomcat.embed - tomcat-embed-logging-juli - test - - - org.apache.tomcat - tomcat-servlet-api - provided - - - org.apache.tomcat - tomcat-jsp-api - test - org.assertj assertj-core diff --git a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaLockedAdminEnvironmentCheck.java b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaLockedAdminEnvironmentCheck.java index 8c1f4d790..045e21de3 100644 --- a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaLockedAdminEnvironmentCheck.java +++ b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaLockedAdminEnvironmentCheck.java @@ -29,6 +29,7 @@ import org.apache.archiva.redback.users.User; import org.apache.archiva.redback.users.UserManager; import org.apache.archiva.redback.users.UserManagerException; import org.apache.archiva.redback.users.UserNotFoundException; +import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.ApplicationContext; @@ -75,12 +76,21 @@ public class ArchivaLockedAdminEnvironmentCheck List userManagerImpls = redbackRuntimeConfigurationAdmin.getRedbackRuntimeConfiguration().getUserManagerImpls(); + List updated = new ArrayList<>( ); userManagers = new ArrayList<>( userManagerImpls.size() ); for ( String beanId : userManagerImpls ) { + // for migration purpose to help users + if ( StringUtils.equalsIgnoreCase( beanId, "jdo" )) + { + log.info( "jdo is not anymore supported we auto update to jpa" ); + beanId = "jpa"; + } + updated.add( beanId ); userManagers.add( applicationContext.getBean( "userManager#" + beanId, UserManager.class ) ); } + redbackRuntimeConfigurationAdmin.getRedbackRuntimeConfiguration().setUserManagerImpls( updated ); } /** diff --git a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaRbacManager.java b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaRbacManager.java index 6b2eb9e8f..a98dc4998 100644 --- a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaRbacManager.java +++ b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaRbacManager.java @@ -31,6 +31,7 @@ import org.apache.archiva.redback.rbac.RbacObjectNotFoundException; import org.apache.archiva.redback.rbac.Resource; import org.apache.archiva.redback.rbac.Role; import org.apache.archiva.redback.rbac.UserAssignment; +import org.apache.commons.lang.StringUtils; import org.springframework.context.ApplicationContext; import org.springframework.stereotype.Service; @@ -111,8 +112,11 @@ public class ArchivaRbacManager for ( String id : rbacManagerIds ) { + if ( StringUtils.equalsIgnoreCase( "jdo", id )) + { + id = RedbackRuntimeConfigurationAdmin.DEFAULT_RBAC_MANAGER_IMPL; + } RBACManager rbacManager = applicationContext.getBean( "rbacManager#" + id, RBACManager.class ); - rbacManagersPerId.put( id, rbacManager ); } diff --git a/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/remotedownload/AbstractDownloadTest.java b/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/remotedownload/AbstractDownloadTest.java index f04148cbd..cf69545b1 100644 --- a/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/remotedownload/AbstractDownloadTest.java +++ b/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/remotedownload/AbstractDownloadTest.java @@ -33,16 +33,18 @@ import org.apache.archiva.rest.api.services.RepositoryGroupService; import org.apache.archiva.rest.api.services.SearchService; import org.apache.archiva.test.utils.ArchivaBlockJUnit4ClassRunner; import org.apache.archiva.webdav.RepositoryServlet; -import org.apache.catalina.Context; -import org.apache.catalina.deploy.ApplicationListener; -import org.apache.catalina.deploy.ApplicationParameter; -import org.apache.catalina.startup.Tomcat; import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang.SystemUtils; import org.apache.cxf.common.util.Base64Utility; import org.apache.cxf.jaxrs.client.JAXRSClientFactory; import org.apache.cxf.jaxrs.client.WebClient; import org.apache.cxf.transport.servlet.CXFServlet; +import org.eclipse.jetty.server.HttpConnectionFactory; import org.eclipse.jetty.server.Server; +import org.eclipse.jetty.server.ServerConnector; +import org.eclipse.jetty.server.session.SessionHandler; +import org.eclipse.jetty.servlet.ServletContextHandler; +import org.eclipse.jetty.servlet.ServletHolder; import org.junit.After; import org.junit.Before; import org.junit.runner.RunWith; @@ -73,7 +75,7 @@ public abstract class AbstractDownloadTest public Server server = null; - public Tomcat tomcat; + ServerConnector serverConnector; public int port; @@ -109,30 +111,24 @@ public abstract class AbstractDownloadTest System.setProperty( "redback.admin.creation.file", "target/auto-admin-creation.properties" ); - tomcat = new Tomcat(); - tomcat.setBaseDir( System.getProperty( "java.io.tmpdir" ) ); - tomcat.setPort( 0 ); + server = new Server(); + serverConnector = new ServerConnector( server, new HttpConnectionFactory() ); + server.addConnector( serverConnector ); - Context context = tomcat.addContext( "", System.getProperty( "java.io.tmpdir" ) ); - - ApplicationParameter applicationParameter = new ApplicationParameter(); - applicationParameter.setName( "contextConfigLocation" ); - applicationParameter.setValue( getSpringConfigLocation() ); - context.addApplicationParameter( applicationParameter ); - - context.addApplicationListener( new ApplicationListener( ContextLoaderListener.class.getName(), false ) ); - - tomcat.addServlet( context, "cxf", new CXFServlet() ); - context.addServletMapping( "/" + getRestServicesPath() + "/*" , "cxf" ); - - tomcat.addServlet( context, "archivarepo", new RepositoryServlet() ); - context.addServletMapping( "/repository/*" , "archivarepo" ); - - tomcat.start(); - - port = tomcat.getConnector().getLocalPort(); + ServletHolder servletHolder = new ServletHolder( new CXFServlet() ); + ServletContextHandler context = new ServletContextHandler( ServletContextHandler.SESSIONS ); + context.setResourceBase( SystemUtils.JAVA_IO_TMPDIR ); + context.setSessionHandler( new SessionHandler() ); + context.addServlet( servletHolder, "/" + getRestServicesPath() + "/*" ); + context.setInitParameter( "contextConfigLocation", getSpringConfigLocation() ); + context.addEventListener( new ContextLoaderListener() ); + ServletHolder servletHolderRepo = new ServletHolder( new RepositoryServlet() ); + context.addServlet( servletHolderRepo, "/repository/*" ); + server.setHandler( context ); + server.start(); + port = serverConnector.getLocalPort(); log.info( "start server on port {}", this.port ); User user = new User(); @@ -158,10 +154,6 @@ public abstract class AbstractDownloadTest { this.server.stop(); } - if (this.tomcat != null) - { - this.tomcat.stop(); - } } @@ -173,7 +165,7 @@ public abstract class AbstractDownloadTest Collections.singletonList( new JacksonJaxbJsonProvider() ) ); WebClient.client( service ).header( "Authorization", authorizationHeader ); - WebClient.client(service).header("Referer","http://localhost:"+port); + WebClient.client( service ).header( "Referer", "http://localhost:" + port ); WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 300000L ); return service; @@ -187,7 +179,7 @@ public abstract class AbstractDownloadTest Collections.singletonList( new JacksonJaxbJsonProvider() ) ); WebClient.client( service ).header( "Authorization", authorizationHeader ); - WebClient.client(service).header("Referer","http://localhost:"+port); + WebClient.client( service ).header( "Referer", "http://localhost:" + port ); WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 300000L ); return service; @@ -201,7 +193,7 @@ public abstract class AbstractDownloadTest Collections.singletonList( new JacksonJaxbJsonProvider() ) ); WebClient.client( service ).header( "Authorization", authorizationHeader ); - WebClient.client(service).header("Referer","http://localhost:"+port); + WebClient.client( service ).header( "Referer", "http://localhost:" + port ); WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 300000L ); return service; @@ -216,7 +208,7 @@ public abstract class AbstractDownloadTest Collections.singletonList( new JacksonJaxbJsonProvider() ) ); WebClient.client( service ).header( "Authorization", authorizationHeader ); - WebClient.client(service).header("Referer","http://localhost:"+port); + WebClient.client( service ).header( "Referer", "http://localhost:" + port ); WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 300000L ); return service; @@ -230,7 +222,7 @@ public abstract class AbstractDownloadTest Collections.singletonList( new JacksonJaxbJsonProvider() ) ); WebClient.client( service ).header( "Authorization", authorizationHeader ); - WebClient.client(service).header("Referer","http://localhost:"+port); + WebClient.client( service ).header( "Referer", "http://localhost:" + port ); WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 300000L ); return service; @@ -244,7 +236,7 @@ public abstract class AbstractDownloadTest Collections.singletonList( new JacksonJaxbJsonProvider() ) ); WebClient.client( service ).header( "Authorization", authorizationHeader ); - WebClient.client(service).header("Referer","http://localhost:"+port); + WebClient.client( service ).header( "Referer", "http://localhost:" + port ); WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 300000L ); return service; @@ -264,7 +256,7 @@ public abstract class AbstractDownloadTest RoleManagementService.class, Collections.singletonList( new JacksonJaxbJsonProvider() ) ); - WebClient.client(service).header("Referer","http://localhost:"+port); + WebClient.client( service ).header( "Referer", "http://localhost:" + port ); // for debuging purpose WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 3000000L ); @@ -282,7 +274,7 @@ public abstract class AbstractDownloadTest JAXRSClientFactory.create( "http://localhost:" + port + "/" + getRestServicesPath() + "/redbackServices/", UserService.class, Collections.singletonList( new JacksonJaxbJsonProvider() ) ); - WebClient.client(service).header("Referer","http://localhost:"+port); + WebClient.client( service ).header( "Referer", "http://localhost:" + port ); // for debuging purpose WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 3000000L ); diff --git a/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/remotedownload/DownloadArtifactsTest.java b/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/remotedownload/DownloadArtifactsTest.java index eae41013f..c8c753aad 100644 --- a/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/remotedownload/DownloadArtifactsTest.java +++ b/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/remotedownload/DownloadArtifactsTest.java @@ -178,7 +178,7 @@ public class DownloadArtifactsTest HttpWagon httpWagon = new HttpWagon(); httpWagon.connect( new Repository( "foo", "http://localhost:" + port ) ); - httpWagon.get( "/repository/internal/junit/junit/4.9/junit-4.9.jar", file ); + httpWagon.get( "repository/internal/junit/junit/4.9/junit-4.9.jar", file ); ZipFile zipFile = new ZipFile( file ); List entries = getZipEntriesNames( zipFile ); diff --git a/pom.xml b/pom.xml index 9b76d6dce..f4f80dd05 100644 --- a/pom.xml +++ b/pom.xml @@ -126,36 +126,6 @@ 1.7.1 test - - org.apache.tomcat.embed - tomcat-embed-core - ${tomcat7Version} - test - - - org.apache.tomcat - tomcat-juli - ${tomcat7Version} - test - - - org.apache.tomcat - tomcat-servlet-api - ${tomcat7Version} - provided - - - org.apache.tomcat - tomcat-jsp-api - ${tomcat7Version} - test - - - org.apache.tomcat.embed - tomcat-embed-logging-juli - ${tomcat7Version} - test - org.apache.jackrabbit jackrabbit-webdav @@ -485,17 +455,6 @@ spring-utils ${redback.spring-utils.version} - - org.apache.archiva.redback.components - spring-jdo2 - 2.2 - - - geronimo-spec - geronimo-spec-jta - - - com.lmax @@ -689,6 +648,11 @@ tomcat-jdbc ${tomcat7Version} + + org.apache.tomcat + tomcat-juli + ${tomcat7Version} + org.apache.commons commons-compress