diff options
author | olivier lamy <olamy@apache.org> | 2017-05-26 12:04:44 +1000 |
---|---|---|
committer | olivier lamy <olamy@apache.org> | 2017-05-26 12:04:44 +1000 |
commit | 4b6131e8bab59139d0558ed6d932d683cdfdbcab (patch) | |
tree | 451890a6fdedde364915d05828ee21ebe327bbba /archiva-modules | |
parent | b77921b7c0f544e16e605b55348923cc027a122b (diff) | |
download | archiva-4b6131e8bab59139d0558ed6d932d683cdfdbcab.tar.gz archiva-4b6131e8bab59139d0558ed6d932d683cdfdbcab.zip |
take of default now jpa, jdo not exists anymore so handle migration
Signed-off-by: olivier lamy <olamy@apache.org>
Diffstat (limited to 'archiva-modules')
8 files changed, 57 insertions, 69 deletions
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 @@ <redbackRuntimeConfiguration> <userManagerImpls> - <userManagerImpl>jdo</userManagerImpl> + <userManagerImpl>jpa</userManagerImpl> </userManagerImpls> <rbacManagerImpls> <rbacManagerImpl>cached</rbacManagerImpl> 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 @@ </exclusion> </exclusions> </dependency> - - <dependency> - <groupId>org.apache.tomcat.embed</groupId> - <artifactId>tomcat-embed-core</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.tomcat</groupId> - <artifactId>tomcat-juli</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.tomcat.embed</groupId> - <artifactId>tomcat-embed-logging-juli</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.tomcat</groupId> - <artifactId>tomcat-servlet-api</artifactId> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.apache.tomcat</groupId> - <artifactId>tomcat-jsp-api</artifactId> - <scope>test</scope> - </dependency> <dependency> <groupId>org.assertj</groupId> <artifactId>assertj-core</artifactId> 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<String> userManagerImpls = redbackRuntimeConfigurationAdmin.getRedbackRuntimeConfiguration().getUserManagerImpls(); + List<String> 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<String> entries = getZipEntriesNames( zipFile ); |