diff options
author | Olivier Lamy <olamy@apache.org> | 2011-06-07 16:44:27 +0000 |
---|---|---|
committer | Olivier Lamy <olamy@apache.org> | 2011-06-07 16:44:27 +0000 |
commit | 9c55823b96a84a67cd17157e8938601de4de86db (patch) | |
tree | 09cb5f81e2175d24b90f419982188df60689269e | |
parent | 532dd24896a775c933becf9d287a65ba2962fd6d (diff) | |
download | archiva-9c55823b96a84a67cd17157e8938601de4de86db.tar.gz archiva-9c55823b96a84a67cd17157e8938601de4de86db.zip |
fix main compilation in webapp module
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1133091 13f79535-47bb-0310-9956-ffa450edef68
8 files changed, 53 insertions, 89 deletions
diff --git a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/AbstractProxyTestCase.java b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/AbstractProxyTestCase.java index a9cb3e06d..476a9b4fc 100644 --- a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/AbstractProxyTestCase.java +++ b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/AbstractProxyTestCase.java @@ -21,7 +21,6 @@ package org.apache.maven.archiva.proxy; import junit.framework.TestCase; import org.apache.archiva.common.plexusbridge.PlexusSisuBridge; -import org.apache.commons.io.FileUtils; import org.apache.commons.lang.ArrayUtils; import org.apache.commons.lang.StringUtils; import org.apache.maven.archiva.configuration.ArchivaConfiguration; @@ -36,6 +35,7 @@ import org.apache.maven.archiva.policies.ReleasesPolicy; import org.apache.maven.archiva.policies.SnapshotsPolicy; import org.apache.maven.archiva.repository.ManagedRepositoryContent; import org.apache.maven.wagon.Wagon; +import org.codehaus.plexus.util.FileUtils; import org.easymock.ArgumentsMatcher; import org.easymock.MockControl; import org.junit.Before; @@ -303,8 +303,8 @@ public abstract class AbstractProxyTestCase actualFile.getCanonicalPath() ); assertEquals( "Check file path matches.", expectedFile.getAbsolutePath(), actualFile.getAbsolutePath() ); - String expectedContents = FileUtils.readFileToString( sourceFile, null ); - String actualContents = FileUtils.readFileToString( actualFile, null ); + String expectedContents = org.apache.commons.io.FileUtils.readFileToString( sourceFile, null ); + String actualContents = org.apache.commons.io.FileUtils.readFileToString( actualFile, null ); assertEquals( "Check file contents.", expectedContents, actualContents ); } @@ -322,7 +322,7 @@ public abstract class AbstractProxyTestCase return; } - Collection<File> tmpFiles = FileUtils.listFiles( workingDir, new String[]{ "tmp" }, false ); + Collection<File> tmpFiles = org.apache.commons.io.FileUtils.listFiles( workingDir, new String[]{ "tmp" }, false ); if ( !tmpFiles.isEmpty() ) { StringBuffer emsg = new StringBuffer(); @@ -369,7 +369,7 @@ public abstract class AbstractProxyTestCase { destination = destination.getParentFile(); - FileUtils.copyFile( file, new File( destination, file.getName() ), false ); + org.apache.commons.io.FileUtils.copyFile( file, new File( destination, file.getName() ), false ); // TODO: Change when there is a FileUtils.copyFileToDirectory(file, destination, boolean) option //FileUtils.copyFileToDirectory( file, destination ); } diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/AddManagedRepositoryAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/AddManagedRepositoryAction.java index 7e71ec527..8634ba176 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/AddManagedRepositoryAction.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/AddManagedRepositoryAction.java @@ -22,14 +22,14 @@ package org.apache.maven.archiva.web.action.admin.repositories; import com.opensymphony.xwork2.Preparable; import com.opensymphony.xwork2.Validateable; import org.apache.archiva.audit.AuditEvent; +import org.apache.commons.lang.StringUtils; import org.apache.maven.archiva.configuration.Configuration; import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; import org.codehaus.plexus.redback.role.RoleManagerException; -import org.codehaus.plexus.scheduler.CronExpressionValidator; +import org.codehaus.redback.components.scheduler.CronExpressionValidator; import java.io.File; import java.io.IOException; -import org.apache.commons.lang.StringUtils; /** * AddManagedRepositoryAction diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/EditManagedRepositoryAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/EditManagedRepositoryAction.java index 9d3be5500..aa5b54527 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/EditManagedRepositoryAction.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/EditManagedRepositoryAction.java @@ -29,7 +29,7 @@ import org.apache.commons.lang.StringUtils; import org.apache.maven.archiva.configuration.Configuration; import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; import org.codehaus.plexus.redback.role.RoleManagerException; -import org.codehaus.plexus.scheduler.CronExpressionValidator; +import org.codehaus.redback.components.scheduler.CronExpressionValidator; import java.io.File; import java.io.IOException; diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/rss/RssFeedServlet.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/rss/RssFeedServlet.java index 7ccbacc18..2dbb22fe8 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/rss/RssFeedServlet.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/rss/RssFeedServlet.java @@ -44,23 +44,22 @@ import org.codehaus.plexus.redback.policy.MustChangePasswordException; import org.codehaus.plexus.redback.system.SecuritySession; import org.codehaus.plexus.redback.users.UserManager; import org.codehaus.plexus.redback.users.UserNotFoundException; -import org.codehaus.plexus.spring.PlexusToSpringUtils; import org.codehaus.redback.integration.filter.authentication.HttpAuthenticator; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; /** * Servlet for handling rss feed requests. @@ -95,15 +94,11 @@ public class RssFeedServlet { super.init( servletConfig ); wac = WebApplicationContextUtils.getRequiredWebApplicationContext( servletConfig.getServletContext() ); - userRepositories = (UserRepositories) wac.getBean( PlexusToSpringUtils.buildSpringId( - UserRepositories.class.getName() ) ); - servletAuth = (ServletAuthenticator) wac.getBean( PlexusToSpringUtils.buildSpringId( - ServletAuthenticator.class.getName() ) ); - httpAuth = (HttpAuthenticator) wac.getBean( PlexusToSpringUtils.buildSpringId( HttpAuthenticator.ROLE, - "basic" ) ); + userRepositories = wac.getBean( UserRepositories.class ); + servletAuth = wac.getBean( ServletAuthenticator.class ); + httpAuth = wac.getBean( "httpAuthenticator#basic", HttpAuthenticator.class ); // TODO: what if there are other types? - repositorySessionFactory = (RepositorySessionFactory) wac.getBean( PlexusToSpringUtils.buildSpringId( - RepositorySessionFactory.class.getName() ) ); + repositorySessionFactory = wac.getBean( RepositorySessionFactory.class ); } public void doGet( HttpServletRequest req, HttpServletResponse res ) @@ -140,16 +135,14 @@ public class RssFeedServlet if ( repoId != null ) { // new artifacts in repo feed request - processor = (RssFeedProcessor) wac.getBean( PlexusToSpringUtils.buildSpringId( - RssFeedProcessor.class.getName(), "new-artifacts" ) ); + processor = wac.getBean( "rssFeedProcessor#new-artifacts", RssFeedProcessor.class ); map.put( RssFeedProcessor.KEY_REPO_ID, repoId ); } else if ( ( groupId != null ) && ( artifactId != null ) ) { // TODO: this only works for guest - we could pass in the list of repos // new versions of artifact feed request - processor = (RssFeedProcessor) wac.getBean( PlexusToSpringUtils.buildSpringId( - RssFeedProcessor.class.getName(), "new-versions" ) ); + processor = wac.getBean( "rssFeedProcessor#new-versions", RssFeedProcessor.class ); map.put( RssFeedProcessor.KEY_GROUP_ID, groupId ); map.put( RssFeedProcessor.KEY_ARTIFACT_ID, artifactId ); } diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/startup/ArchivaStartup.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/startup/ArchivaStartup.java index 067e7ef48..75ae5db72 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/startup/ArchivaStartup.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/startup/ArchivaStartup.java @@ -19,17 +19,12 @@ package org.apache.maven.archiva.web.startup; * under the License. */ -import org.apache.archiva.scheduler.ArchivaTaskScheduler; import org.apache.archiva.scheduler.repository.RepositoryArchivaTaskScheduler; import org.apache.maven.archiva.common.ArchivaException; -import org.codehaus.plexus.personality.plexus.lifecycle.phase.StoppingException; -import org.codehaus.plexus.scheduler.DefaultScheduler; -import org.codehaus.plexus.spring.PlexusToSpringUtils; -import org.codehaus.plexus.spring.PlexusWebApplicationContext; import org.codehaus.plexus.taskqueue.Task; -import org.codehaus.plexus.taskqueue.execution.TaskQueueExecutor; import org.codehaus.plexus.taskqueue.execution.ThreadedTaskQueueExecutor; -import org.springframework.context.support.ClassPathXmlApplicationContext; +import org.codehaus.redback.components.scheduler.DefaultScheduler; +import org.quartz.SchedulerException; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils; @@ -56,20 +51,16 @@ public class ArchivaStartup public void contextInitialized( ServletContextEvent contextEvent ) { - WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext( - contextEvent.getServletContext() ); + WebApplicationContext wac = + WebApplicationContextUtils.getRequiredWebApplicationContext( contextEvent.getServletContext() ); - SecuritySynchronization securitySync = (SecuritySynchronization) wac.getBean( PlexusToSpringUtils.buildSpringId( - SecuritySynchronization.class ) ); + SecuritySynchronization securitySync = wac.getBean( SecuritySynchronization.class ); - repositoryTaskScheduler = (RepositoryArchivaTaskScheduler) wac.getBean( PlexusToSpringUtils.buildSpringId( - ArchivaTaskScheduler.class, "repository" ) ); + repositoryTaskScheduler = wac.getBean( "archivaTaskScheduler#repository", RepositoryArchivaTaskScheduler.class ); - tqeRepoScanning = (ThreadedTaskQueueExecutor) wac.getBean( PlexusToSpringUtils.buildSpringId( - TaskQueueExecutor.class, "repository-scanning" ) ); + tqeRepoScanning = wac.getBean( "taskQueueExecutor#repository-scanning", ThreadedTaskQueueExecutor.class ); - tqeIndexing = (ThreadedTaskQueueExecutor) wac.getBean( PlexusToSpringUtils.buildSpringId( - TaskQueueExecutor.class, "indexing" ) ); + tqeIndexing = wac.getBean( "taskQueueExecutor#indexing", ThreadedTaskQueueExecutor.class ); try { @@ -85,14 +76,18 @@ public class ArchivaStartup public void contextDestroyed( ServletContextEvent contextEvent ) { - WebApplicationContext applicationContext = WebApplicationContextUtils.getRequiredWebApplicationContext( - contextEvent.getServletContext() ); + WebApplicationContext applicationContext = + WebApplicationContextUtils.getRequiredWebApplicationContext( contextEvent.getServletContext() ); + + // TODO check this stop + + /* if ( applicationContext != null && applicationContext instanceof ClassPathXmlApplicationContext ) { ( (ClassPathXmlApplicationContext) applicationContext ).close(); - } + } */ - if ( applicationContext != null && applicationContext instanceof PlexusWebApplicationContext ) + if ( applicationContext != null ) //&& applicationContext instanceof PlexusWebApplicationContext ) { // stop task queue executors stopTaskQueueExecutor( tqeDbScanning ); @@ -106,7 +101,7 @@ public class ArchivaStartup { repositoryTaskScheduler.stop(); } - catch ( StoppingException e ) + catch ( SchedulerException e ) { e.printStackTrace(); } @@ -127,7 +122,9 @@ public class ArchivaStartup } // close the application context - ( (PlexusWebApplicationContext) applicationContext ).close(); + //applicationContext.close(); + // TODO fix close call + //applicationContext. } } diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/tags/DependencyTreeTag.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/tags/DependencyTreeTag.java index a8abb570f..bb29ba0aa 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/tags/DependencyTreeTag.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/tags/DependencyTreeTag.java @@ -19,6 +19,7 @@ package org.apache.maven.archiva.web.tags; * under the License. */ +import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.IteratorUtils; import org.apache.commons.lang.StringUtils; @@ -112,9 +113,9 @@ public class DependencyTreeTag DependencyTree deptree; try { - deptree = (DependencyTree) PlexusTagUtil.lookup( pageContext, DependencyTree.class.getName() ); + deptree = (DependencyTree) PlexusTagUtil.lookup( pageContext, DependencyTree.class ); } - catch ( ComponentLookupException e ) + catch ( PlexusSisuBridgeException e ) { throw new JspException( "Unable to lookup DependencyTree: " + e.getMessage(), e ); } diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/tags/PlexusTagUtil.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/tags/PlexusTagUtil.java index 5b3062e90..0eaf6b5df 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/tags/PlexusTagUtil.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/tags/PlexusTagUtil.java @@ -19,63 +19,36 @@ package org.apache.maven.archiva.web.tags; * under the License. */ -import org.codehaus.plexus.PlexusConstants; -import org.codehaus.plexus.PlexusContainer; -import org.codehaus.plexus.component.repository.exception.ComponentLookupException; +import org.apache.archiva.common.plexusbridge.PlexusSisuBridge; +import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException; +import org.springframework.web.context.WebApplicationContext; +import org.springframework.web.context.support.WebApplicationContextUtils; import javax.servlet.ServletContext; import javax.servlet.jsp.PageContext; /** - * PlexusTagUtil + * PlexusTagUtil * * @version $Id$ */ public class PlexusTagUtil { public static Object lookup( PageContext pageContext, Class<?> clazz ) - throws ComponentLookupException + throws PlexusSisuBridgeException { return getContainer( pageContext ).lookup( clazz ); } - public static Object lookup( PageContext pageContext, String role ) - throws ComponentLookupException - { - return getContainer( pageContext ).lookup( role ); - } - - public static Object lookup( PageContext pageContext, Class<?> clazz, String hint ) - throws ComponentLookupException - { - return getContainer( pageContext ).lookup( clazz, hint ); - } - - public static Object lookup( PageContext pageContext, String role, String hint ) - throws ComponentLookupException - { - return getContainer( pageContext ).lookup( role, hint ); - } - - public static PlexusContainer getContainer( PageContext pageContext ) - throws ComponentLookupException + private static PlexusSisuBridge getContainer( PageContext pageContext ) { ServletContext servletContext = pageContext.getServletContext(); - PlexusContainer xworkContainer = (PlexusContainer) servletContext.getAttribute( "webwork.plexus.container" ); + WebApplicationContext webApplicationContext = + WebApplicationContextUtils.getRequiredWebApplicationContext( pageContext.getServletContext() ); - if ( xworkContainer != null ) - { - servletContext.setAttribute( PlexusConstants.PLEXUS_KEY, xworkContainer ); + return webApplicationContext.getBean( PlexusSisuBridge.class ); - return xworkContainer; - } - PlexusContainer container = (PlexusContainer) servletContext.getAttribute( PlexusConstants.PLEXUS_KEY ); - if ( container == null ) - { - throw new ComponentLookupException( "PlexusContainer is null." ); - } - return container; } } diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/validator/CronExpressionValidator.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/validator/CronExpressionValidator.java index f8cce8d4a..8524d3d8c 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/validator/CronExpressionValidator.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/validator/CronExpressionValidator.java @@ -34,8 +34,8 @@ public class CronExpressionValidator { String cron = (String) getFieldValue( "cron", obj ); - org.codehaus.plexus.scheduler.CronExpressionValidator cronExpressionValidator = - new org.codehaus.plexus.scheduler.CronExpressionValidator(); + org.codehaus.redback.components.scheduler.CronExpressionValidator cronExpressionValidator = + new org.codehaus.redback.components.scheduler.CronExpressionValidator(); ValidatorContext ctxt = getValidatorContext(); if ( !cronExpressionValidator.validate( String.valueOf( cron ) ) ) |