]> source.dussan.org Git - archiva.git/commitdiff
take of default now jpa, jdo not exists anymore so handle migration
authorolivier lamy <olamy@apache.org>
Fri, 26 May 2017 02:04:44 +0000 (12:04 +1000)
committerolivier lamy <olamy@apache.org>
Fri, 26 May 2017 02:04:44 +0000 (12:04 +1000)
Signed-off-by: olivier lamy <olamy@apache.org>
archiva-modules/archiva-base/archiva-configuration/src/main/resources/org/apache/archiva/configuration/default-archiva.xml
archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/runtime/RedbackRuntimeConfigurationAdmin.java
archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/runtime/DefaultRedbackRuntimeConfigurationAdmin.java
archiva-modules/archiva-web/archiva-web-common/pom.xml
archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaLockedAdminEnvironmentCheck.java
archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaRbacManager.java
archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/remotedownload/AbstractDownloadTest.java
archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/remotedownload/DownloadArtifactsTest.java
pom.xml

index 877b6a59bbb7d4ec5c7fb2c83ebcdfcee5c4c14c..88beda2e01be1cd93d05a0444c15f26b34e5b67f 100644 (file)
 
   <redbackRuntimeConfiguration>
     <userManagerImpls>
-      <userManagerImpl>jdo</userManagerImpl>
+      <userManagerImpl>jpa</userManagerImpl>
     </userManagerImpls>
     <rbacManagerImpls>
       <rbacManagerImpl>cached</rbacManagerImpl>
index 8fae6a66ad219e5b915ea033d41ff48d2a650113..c124eacbe9c05a79d4936d86a9f1f4ac3eb951fd 100644 (file)
@@ -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;
index 3ce727c712aa830443e8ba6262469d23f1af273e..ebd8a64e0a98e4c95cb28e5b2642f1b76ea7cbbf 100644 (file)
@@ -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 );
                     }
                 }
index e44bd69f2643c1865bbf7dfef2ef90607cb81004..c14197124c604b162bb86c3786db82f89fca8ee7 100644 (file)
         </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>
index 8c1f4d79085d6b5e654e1c949996cd4bc22073e4..045e21de3dbb1bde352a167db520f60811fabf28 100644 (file)
@@ -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 );
     }
 
     /**
index 6b2eb9e8fb9692b801cdec4e2b173d31cee83d6b..a98dc4998a96ad263dd6d39c7011c8602a717624 100644 (file)
@@ -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 );
             }
 
index f04148cbd00bf8c5932a19a331ac50ef3c970791..cf69545b1ca92276c39220bbdab3ffda83638df4 100644 (file)
@@ -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 );
index eae41013f9dda95eb6a00b66e3244f28a9384e0c..c8c753aad1923b2a3f81ecf7d66700f6dd2bb8c3 100644 (file)
@@ -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 );
diff --git a/pom.xml b/pom.xml
index 9b76d6dce003b9de2a2dc5e869bb26a695467329..f4f80dd05f3f70267cad8991856aa2621e732f5c 100644 (file)
--- a/pom.xml
+++ b/pom.xml
         <version>1.7.1</version>
         <scope>test</scope>
       </dependency>
-      <dependency>
-        <groupId>org.apache.tomcat.embed</groupId>
-        <artifactId>tomcat-embed-core</artifactId>
-        <version>${tomcat7Version}</version>
-        <scope>test</scope>
-      </dependency>
-      <dependency>
-        <groupId>org.apache.tomcat</groupId>
-        <artifactId>tomcat-juli</artifactId>
-        <version>${tomcat7Version}</version>
-        <scope>test</scope>
-      </dependency>
-      <dependency>
-        <groupId>org.apache.tomcat</groupId>
-        <artifactId>tomcat-servlet-api</artifactId>
-        <version>${tomcat7Version}</version>
-        <scope>provided</scope>
-      </dependency>
-      <dependency>
-        <groupId>org.apache.tomcat</groupId>
-        <artifactId>tomcat-jsp-api</artifactId>
-        <version>${tomcat7Version}</version>
-        <scope>test</scope>
-      </dependency>
-      <dependency>
-        <groupId>org.apache.tomcat.embed</groupId>
-        <artifactId>tomcat-embed-logging-juli</artifactId>
-        <version>${tomcat7Version}</version>
-        <scope>test</scope>
-      </dependency>
       <dependency>
         <groupId>org.apache.jackrabbit</groupId>
         <artifactId>jackrabbit-webdav</artifactId>
         <artifactId>spring-utils</artifactId>
         <version>${redback.spring-utils.version}</version>
       </dependency>
-      <dependency>
-        <groupId>org.apache.archiva.redback.components</groupId>
-        <artifactId>spring-jdo2</artifactId>
-        <version>2.2</version>
-        <exclusions>
-          <exclusion>
-            <groupId>geronimo-spec</groupId>
-            <artifactId>geronimo-spec-jta</artifactId>
-          </exclusion>
-        </exclusions>
-      </dependency>
 
       <dependency>
         <groupId>com.lmax</groupId>
         <artifactId>tomcat-jdbc</artifactId>
         <version>${tomcat7Version}</version>
       </dependency>
+      <dependency>
+        <groupId>org.apache.tomcat</groupId>
+        <artifactId>tomcat-juli</artifactId>
+        <version>${tomcat7Version}</version>
+      </dependency>
       <dependency>
         <groupId>org.apache.commons</groupId>
         <artifactId>commons-compress</artifactId>