]> source.dussan.org Git - archiva.git/commitdiff
remove unnecessary component definitions
authorBrett Porter <brett@apache.org>
Wed, 9 Apr 2008 15:31:57 +0000 (15:31 +0000)
committerBrett Porter <brett@apache.org>
Wed, 9 Apr 2008 15:31:57 +0000 (15:31 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@646403 13f79535-47bb-0310-9956-ffa450edef68

39 files changed:
archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/FileTypes.java
archiva-modules/archiva-base/archiva-consumers/archiva-database-consumers/src/main/java/org/apache/maven/archiva/consumers/database/ProjectModelToDatabaseConsumer.java
archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/DependencyGraphFactory.java
archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/tasks/FlagCyclicEdgesTask.java
archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/tasks/FlagExcludedEdgesTask.java
archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/tasks/PopulateDependencyManagementTask.java
archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/tasks/PopulateGraphMasterTask.java
archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/tasks/ReduceEnabledEdgesTask.java
archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/tasks/ReduceScopeTask.java
archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/tasks/ReduceTransitiveEdgesTask.java
archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/tasks/RefineConflictsTask.java
archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/tasks/ResolveGraphTask.java
archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/tasks/UpdateScopesTask.java
archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/functors/IndexExistsPredicate.java
archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/AbstractDefaultRepositoryContent.java
archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/DefaultPathParser.java
archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/LegacyPathParser.java
archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/ManagedDefaultRepositoryContent.java
archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/ManagedLegacyRepositoryContent.java
archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/RemoteLegacyRepositoryContent.java
archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/RepositoryRequest.java
archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/ProjectModelResolverFactory.java
archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/readers/ProjectModel300Reader.java
archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/readers/ProjectModel400Reader.java
archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/resolvers/ProjectModelResolverStack.java
archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/writers/ProjectModel400Writer.java
archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/project/writers/ProjectModel400WriterTest.java
archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/jdo/JdoProjectModelDAOTest.java
archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/ArchivaUser.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/BrowseAction.java
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/SearchAction.java
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/ShowArtifactAction.java
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/UploadAction.java
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/repository/ProxiedDavServer.java
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/startup/ArchivaStartup.java
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/startup/Banner.java
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/tags/CopyPasteSnippet.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/tags/CopyPasteSnippetTag.java
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/util/ArchivaXworkUser.java

index 07bcc1b9a6a0251362754ed89c5b92d1de0f3c10..66be709b6b4d422848c7d35b66143249aa257171 100644 (file)
@@ -19,6 +19,14 @@ package org.apache.maven.archiva.configuration;
  * under the License.
  */
 
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.collections.Predicate;
 import org.apache.commons.configuration.CombinedConfiguration;
@@ -32,16 +40,6 @@ import org.codehaus.plexus.registry.RegistryException;
 import org.codehaus.plexus.registry.RegistryListener;
 import org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry;
 import org.codehaus.plexus.util.SelectorUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
 
 /**
  * FileTypes 
@@ -54,8 +52,6 @@ import java.util.Map;
 public class FileTypes
     implements Initializable, RegistryListener
 {
-    private Logger log = LoggerFactory.getLogger(FileTypes.class);
-    
     public static final String ARTIFACTS = "artifacts";
 
     public static final String AUTO_REMOVE = "auto-remove";
@@ -174,6 +170,8 @@ public class FileTypes
         throws InitializationException
     {
         // TODO: why is this done by hand?
+        
+        // TODO: ideally, this would be instantiated by configuration instead, and not need to be a component
 
         String errMsg = "Unable to load default archiva configuration for FileTypes: ";
 
index 97b2d1f47fbdab6447f28a80432a67636e52e514..58e1dd9cce52df003d212f223406ca07ddd0240f 100644 (file)
@@ -44,6 +44,8 @@ import org.apache.maven.archiva.repository.project.ProjectModelException;
 import org.apache.maven.archiva.repository.project.ProjectModelFilter;
 import org.apache.maven.archiva.repository.project.ProjectModelReader;
 import org.apache.maven.archiva.repository.project.filters.EffectiveProjectModelFilter;
+import org.apache.maven.archiva.repository.project.readers.ProjectModel300Reader;
+import org.apache.maven.archiva.repository.project.readers.ProjectModel400Reader;
 import org.codehaus.plexus.cache.Cache;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -83,16 +85,6 @@ public class ProjectModelToDatabaseConsumer
      */
     private RepositoryContentFactory repositoryFactory;
 
-    /**
-     * @plexus.requirement role-hint="model400"
-     */
-    private ProjectModelReader project400Reader;
-
-    /**
-     * @plexus.requirement role-hint="model300"
-     */
-    private ProjectModelReader project300Reader;
-
     /**
      * @plexus.requirement role-hint="expression"
      */
@@ -153,11 +145,15 @@ public class ProjectModelToDatabaseConsumer
 
         ManagedRepositoryContent repo = getRepository( artifact );
         File artifactFile = repo.toFile( artifact );
-        ProjectModelReader reader = project400Reader;
-
+        
+        ProjectModelReader reader;
         if ( repo instanceof ManagedLegacyRepositoryContent )
         {
-            reader = project300Reader;
+            reader = new ProjectModel300Reader();
+        }
+        else
+        {
+            reader = new ProjectModel400Reader();
         }
 
         try
index 66d3066ea754de61ef86d16dddc207b2a459d807..3b20c858edd0b64e58f38c2eea073dffe8544152 100644 (file)
@@ -46,8 +46,6 @@ import java.util.List;
  *
  * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
  * @version $Id$
- * 
- * @plexus.component role="org.apache.maven.archiva.dependency.DependencyGraphFactory"
  */
 public class DependencyGraphFactory
 {
index 6e3d89f430a045ddf3fa96b384752b2ba3eac5e1..bc54dffe3342ea1ec1cecaeceec6b0f3d29a8f10 100644 (file)
@@ -29,11 +29,6 @@ import org.apache.maven.archiva.dependency.graph.walk.WalkDepthFirstSearch;
  *
  * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
  * @version $Id$
- * 
- * @plexus.component 
- *      role="org.apache.maven.archiva.dependency.graph.GraphTask"
- *      role-hint="flag-cyclic-edges"
- *      instantiation-strategy="per-lookup"
  */
 public class FlagCyclicEdgesTask
     implements GraphTask
index e7d5586de78b9eb557cab74b357880b99712a43b..34a64467a351a29c28ccfdcb222b6501bfef7887 100644 (file)
@@ -29,11 +29,6 @@ import org.apache.maven.archiva.dependency.graph.walk.WalkDepthFirstSearch;
  *
  * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
  * @version $Id$
- * 
- * @plexus.component 
- *      role="org.apache.maven.archiva.dependency.graph.GraphTask"
- *      role-hint="flag-excluded-edges"
- *      instantiation-strategy="per-lookup"
  */
 public class FlagExcludedEdgesTask
     implements GraphTask
index 60dba3750506c0e5c3621d7a93ebdd07f730f379..33dc107b019a90619f7448334b6c2d6fdfce7b0a 100644 (file)
@@ -30,11 +30,6 @@ import org.apache.maven.archiva.dependency.graph.walk.WalkDepthFirstSearch;
  *
  * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
  * @version $Id$
- * 
- * @plexus.component 
- *      role="org.apache.maven.archiva.dependency.graph.GraphTask"
- *      role-hint="populate-dependency-management"
- *      instantiation-strategy="per-lookup"
  */
 public class PopulateDependencyManagementTask
     implements GraphTask, PotentialCyclicEdgeProducer
index 8a93fa30f466226f1400e0781e424b9aa0b427cd..300c74e4f2da24523c4c4b5c5067f30c42110bdf 100644 (file)
@@ -32,11 +32,6 @@ import org.apache.maven.archiva.dependency.graph.walk.WalkDepthFirstSearch;
  *
  * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
  * @version $Id$
- * 
- * @plexus.component 
- *      role="org.apache.maven.archiva.dependency.graph.GraphTask"
- *      role-hint="populate-graph"
- *      instantiation-strategy="per-lookup"
  */
 public class PopulateGraphMasterTask
     implements GraphTask
index 1845b836448a5dab2c3a6766daa64755d889147c..aca1504f9cab6447f0187c67bee045db62a34df8 100644 (file)
@@ -30,11 +30,6 @@ import org.apache.maven.archiva.dependency.graph.walk.WalkDepthFirstSearch;
  *
  * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
  * @version $Id$
- * 
- * @plexus.component 
- *      role="org.apache.maven.archiva.dependency.graph.GraphTask"
- *      role-hint="reduce-enabled-edges"
- *      instantiation-strategy="per-lookup"
  */
 public class ReduceEnabledEdgesTask
     implements GraphTask
index 5b77c9990e6a05354d5a9efcd6bdde437590a575..5a35eafffce0f65af711ac0413bb9ee944f9ff64 100644 (file)
@@ -29,11 +29,6 @@ import org.apache.maven.archiva.dependency.graph.walk.WalkDepthFirstSearch;
  *
  * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
  * @version $Id$
- * 
- * @plexus.component 
- *      role="org.apache.maven.archiva.dependency.graph.GraphTask"
- *      role-hint="reduce-scope"
- *      instantiation-strategy="per-lookup"
  */
 public class ReduceScopeTask
     implements GraphTask
index d65d2096a195a2e2e6e2c75b8eca5b0b71d8adc8..061af5abd2e56654ce791df5eec3662b2c44542a 100644 (file)
@@ -29,11 +29,6 @@ import org.apache.maven.archiva.dependency.graph.walk.WalkBreadthFirstSearch;
  *
  * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
  * @version $Id$
- * 
- * @plexus.component 
- *      role="org.apache.maven.archiva.dependency.graph.GraphTask"
- *      role-hint="reduce-transitive-edges"
- *      instantiation-strategy="per-lookup"
  */
 public class ReduceTransitiveEdgesTask
     implements GraphTask
index b9bb3d9a0cc8a898911b00ef30c319058714d248..cc55539f9760106ec5d6a4c5709bd8e471e1e1db 100644 (file)
@@ -42,11 +42,6 @@ import java.util.Map.Entry;
  *
  * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
  * @version $Id$
- * 
- * @plexus.component 
- *      role="org.apache.maven.archiva.dependency.graph.GraphTask"
- *      role-hint="refine-conflicts"
- *      instantiation-strategy="per-lookup"
  */
 public class RefineConflictsTask
     implements GraphTask, PotentialCyclicEdgeProducer
index ebe7841096507e39f6f0e61d4c6dba6c56ab59d8..9888d00bad581333892100223dd638c12dc04389 100644 (file)
@@ -34,11 +34,6 @@ import org.apache.maven.archiva.model.VersionedReference;
  *
  * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
  * @version $Id$
- * 
- * @plexus.component 
- *      role="org.apache.maven.archiva.dependency.graph.GraphTask"
- *      role-hint="resolve-graph"
- *      instantiation-strategy="per-lookup"
  */
 public class ResolveGraphTask
     implements GraphTask, PotentialCyclicEdgeProducer
index a01548a9f9a8a0b27c43ce4a3f1def7b79c5499d..fc340ec6292277fea51aa9f0d6b942066bdf1e25 100644 (file)
@@ -30,11 +30,6 @@ import org.apache.maven.archiva.dependency.graph.walk.WalkDepthFirstSearch;
  *
  * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
  * @version $Id$
- * 
- * @plexus.component 
- *      role="org.apache.maven.archiva.dependency.graph.GraphTask"
- *      role-hint="update-scopes"
- *      instantiation-strategy="per-lookup"
  */
 public class UpdateScopesTask
     implements GraphTask
index 1dcf17c691a1ab3e87245ef52ddf000ac67f87d6..11848fbd3c577b53004d5e9acf1127f70854bef5 100644 (file)
@@ -30,10 +30,6 @@ import org.slf4j.LoggerFactory;
  *
  * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
  * @version $Id$
- * 
- * @plexus.component 
- *      role="org.apache.commons.collections.Predicate" 
- *      role-hint="index-exists"
  */
 public class IndexExistsPredicate
     implements Predicate
index 920cf8ed5bf9349d6ff6a82442ac50b5f6c92905..7ee03d16a10a60f0993a9c5a8cc315b87adc34d4 100644 (file)
@@ -43,10 +43,7 @@ public abstract class AbstractDefaultRepositoryContent
 
     protected static final char ARTIFACT_SEPARATOR = '-';
 
-    /**
-     * @plexus.requirement role-hint="default"
-     */
-    private PathParser defaultPathParser;
+    private PathParser defaultPathParser = new DefaultPathParser();
 
     public ArtifactReference toArtifactReference( String path )
         throws LayoutException
index 7c14233ba5f029a72c3e57757ea06826d0d9b517..a6674c31ec37fa87da943b4d7cc341c83597d97d 100644 (file)
@@ -29,8 +29,6 @@ import org.apache.maven.archiva.repository.layout.LayoutException;
  *
  * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
  * @version $Id$
- *
- * @plexus.component role="org.apache.maven.archiva.repository.content.PathParser" role-hint="default"
  */
 public class DefaultPathParser implements PathParser
 {
index 2d2baa97d4e12143e5c024028cbf420cbdfbe192..99a8de4d6d1b634e3c20217e7bfc3b3406a1dc18 100644 (file)
@@ -43,6 +43,7 @@ public class LegacyPathParser
     private static final String INVALID_ARTIFACT_PATH = "Invalid path to Artifact: ";
 
     /**
+     * @todo pass these in on construction instead, since this can't be long lived (no config listener), then no need to be a component
      * @plexus.requirement
      */
     protected ArchivaConfiguration configuration;
index 21a75c2782851f27fa7900f3b5f6f2f7ead9a578..53bfc1bcbb401e6fd07d24f64972cf11d6b3d812 100644 (file)
@@ -42,6 +42,8 @@ import java.util.Set;
  * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
  * @version $Id$
  * 
+ * @todo no need to be a component when filetypes is not
+ * 
  * @plexus.component 
  *      role="org.apache.maven.archiva.repository.ManagedRepositoryContent"
  *      role-hint="default"
index 40d3ff117d4f8d2e0d545ecadc88522bfbe3d499..6b59d86f3bb353f7943d63a6f6028427fcfcba77 100644 (file)
@@ -42,6 +42,8 @@ import java.util.Set;
  * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
  * @version $Id$
  * 
+ * @todo no need to be a component when filetypes, legacy path parser is not
+ * 
  * @plexus.component 
  *      role="org.apache.maven.archiva.repository.ManagedRepositoryContent"
  *      role-hint="legacy"
index da45d43ec38744f47e96ff3ca7893dc35d3b7484..13be1f0fe378d44e2014f458f174a2030008b6d5 100644 (file)
@@ -31,6 +31,8 @@ import org.apache.maven.archiva.repository.layout.LayoutException;
  * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
  * @version $Id$
  * 
+ * @todo no need to be a component once legacy path parser is not
+ * 
  * @plexus.component 
  *      role="org.apache.maven.archiva.repository.RemoteRepositoryContent"
  *      role-hint="legacy"
index 6d28d12f24c30423c782288d342e7166363cbdaf..fd9a278f1333786651eaa483ea10f3b58476efdb 100644 (file)
@@ -34,25 +34,14 @@ import org.apache.maven.archiva.repository.metadata.MetadataTools;
  * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
  * @version $Id$
  *
+ * @todo no need to be a component once legacy path parser is not
+ *
  * @plexus.component
  *      role="org.apache.maven.archiva.repository.content.RepositoryRequest"
  */
 public class RepositoryRequest
 {
-    /**
-     * @plexus.requirement
-     */
-    private FileTypes filetypes;
-
-    /**
-     * @plexus.requirement
-     */
-    private ArchivaConfiguration archivaConfiguration;
-
-    /**
-     * @plexus.requirement role-hint="default"
-     */
-    private PathParser defaultPathParser;
+    private PathParser defaultPathParser = new DefaultPathParser();
 
     /**
      * @plexus.requirement role-hint="legacy"
index df7bd0fa2e29b4e979418c92c27c309b7fc65541..870cbcbbe69b60b9dc6a9e34054e41e350c99487 100644 (file)
@@ -28,6 +28,8 @@ import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
 import org.apache.maven.archiva.repository.ManagedRepositoryContent;
 import org.apache.maven.archiva.repository.RepositoryContentFactory;
 import org.apache.maven.archiva.repository.RepositoryException;
+import org.apache.maven.archiva.repository.project.readers.ProjectModel300Reader;
+import org.apache.maven.archiva.repository.project.readers.ProjectModel400Reader;
 import org.apache.maven.archiva.repository.project.resolvers.ManagedRepositoryProjectResolver;
 import org.apache.maven.archiva.repository.project.resolvers.NopProjectResolver;
 import org.apache.maven.archiva.repository.project.resolvers.ProjectModelResolverStack;
@@ -60,16 +62,6 @@ public class ProjectModelResolverFactory
      */
     private RepositoryContentFactory repositoryFactory;
 
-    /**
-     * @plexus.requirement role-hint="model400"
-     */
-    private ProjectModelReader project400Reader;
-
-    /**
-     * @plexus.requirement role-hint="model300"
-     */
-    private ProjectModelReader project300Reader;
-    
     private ProjectModelResolverStack currentResolverStack = new ProjectModelResolverStack();
 
     public void afterConfigurationChange( Registry registry, String propertyName, Object propertyValue )
@@ -101,11 +93,15 @@ public class ProjectModelResolverFactory
         throws RepositoryException
     {
         ManagedRepositoryContent repoContent = repositoryFactory.getManagedRepositoryContent( repo.getId() );
-        ProjectModelReader reader = project400Reader;
-
+        
+        ProjectModelReader reader;
         if ( StringUtils.equals( "legacy", repo.getLayout() ) )
         {
-            reader = project300Reader;
+            reader = new ProjectModel300Reader();
+        }
+        else
+        {
+            reader = new ProjectModel400Reader();
         }
 
         return new ManagedRepositoryProjectResolver( repoContent, reader );
index 18cef92d6c653ec2a4e984789316b3870e964350..95aa27c6c8a830e961b9c1adcc18317796d45c9d 100644 (file)
@@ -47,10 +47,6 @@ import java.util.Properties;
  *
  * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
  * @version $Id$
- * 
- * @plexus.component 
- *      role="org.apache.maven.archiva.repository.project.ProjectModelReader"
- *      role-hint="model300"
  */
 public class ProjectModel300Reader
     implements ProjectModelReader
index f619275d261ac9861338b9ec4fc16d749ae58cee..38509be26623b47e607a4c1c8ecbc65c5b603526 100644 (file)
@@ -51,10 +51,6 @@ import java.util.Properties;
  *
  * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
  * @version $Id$
- *
- * @plexus.component
- *      role="org.apache.maven.archiva.repository.project.ProjectModelReader"
- *      role-hint="model400"
  */
 public class ProjectModel400Reader
     implements ProjectModelReader
index 459d905061660e015e4c7de6a0a0e247b530c041..f7da1c9fbbe808552838a8c027279318e7116c17 100644 (file)
@@ -35,8 +35,6 @@ import java.util.List;
  *
  * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
  * @version $Id$
- * 
- * @plexus.component role="org.apache.maven.archiva.repository.project.resolvers.ProjectModelResolverStack"
  */
 public class ProjectModelResolverStack
 {
index be23449a329c02c689c9c342b3d291a705431450..a5955e346ec438442519220eaf1f7d52b19dea8e 100644 (file)
@@ -58,10 +58,6 @@ import java.util.List;
  *
  * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
  * @version $Id$
- * 
- * @plexus.component 
- *      role="org.apache.maven.archiva.repository.project.ProjectModelWriter"
- *      role-hint="model400"
  */
 public class ProjectModel400Writer
     implements ProjectModelWriter
index efecd84f1a41fded5e16d5e2cb2e2ff898926f0a..4ce21b8c87dd49bfdca8822c7f181ebe45bb7071 100644 (file)
@@ -52,7 +52,7 @@ public class ProjectModel400WriterTest
     {
         super.setUp();
 
-        modelWriter = (ProjectModelWriter) lookup( ProjectModelWriter.class, "model400" );
+        modelWriter = new ProjectModel400Writer();
     }
 
     public void testSimpleWrite()
index 17c935cf71993ce055bfdc8ab2171ffdadcdc332..e9a79a377679fe26448d0d223c7d7a8e86095a1f 100644 (file)
@@ -25,6 +25,7 @@ import org.apache.maven.archiva.database.AbstractArchivaDatabaseTestCase;
 import org.apache.maven.archiva.database.ProjectModelDAO;
 import org.apache.maven.archiva.model.ArchivaProjectModel;
 import org.apache.maven.archiva.repository.project.ProjectModelReader;
+import org.apache.maven.archiva.repository.project.readers.ProjectModel400Reader;
 
 import java.io.File;
 import java.util.ArrayList;
@@ -109,7 +110,7 @@ public class JdoProjectModelDAOTest
 
         ProjectModelDAO projectDao = dao.getProjectModelDAO();
 
-        ProjectModelReader modelReader = (ProjectModelReader) lookup( ProjectModelReader.class, "model400" );
+        ProjectModelReader modelReader = new ProjectModel400Reader();
 
         File pomFile = getTestFile( "src/test/resources/projects/maven-shared-jar-1.0-SNAPSHOT.pom" );
 
diff --git a/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/ArchivaUser.java b/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/ArchivaUser.java
deleted file mode 100644 (file)
index da63a88..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-package org.apache.maven.archiva.security;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * ArchivaUser- interface to access the active principal. 
- *
- * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
- * @version $Id$
- */
-public interface ArchivaUser
-{
-    /**
-     * Get the active principal from the security system.
-     * 
-     * @return the active principal. (if not authenticated, the guest principal is returned)
-     */
-    public String getActivePrincipal();
-}
index 2bc0422314906274cd69d5e0c0131d6e3dae998e..09ab2d3dfb37d582a11ad3d9204b06831041b7a9 100644 (file)
@@ -19,20 +19,20 @@ package org.apache.maven.archiva.web.action;
  * under the License.
  */
 
+import java.util.Collections;
+import java.util.List;
+
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang.StringUtils;
 import org.apache.maven.archiva.database.browsing.BrowsingResults;
 import org.apache.maven.archiva.database.browsing.RepositoryBrowsing;
 import org.apache.maven.archiva.security.AccessDeniedException;
 import org.apache.maven.archiva.security.ArchivaSecurityException;
-import org.apache.maven.archiva.security.ArchivaUser;
 import org.apache.maven.archiva.security.PrincipalNotFoundException;
 import org.apache.maven.archiva.security.UserRepositories;
+import org.apache.maven.archiva.web.util.ArchivaXworkUser;
 import org.codehaus.plexus.xwork.action.PlexusActionSupport;
 
-import java.util.Collections;
-import java.util.List;
-
 /**
  * Browse the repository.
  *
@@ -54,11 +54,6 @@ public class BrowseAction
      */
     private UserRepositories userRepositories;
     
-    /**
-     * @plexus.requirement role-hint="xwork"
-     */
-    private ArchivaUser archivaUser;
-
     private BrowsingResults results;
 
     private String groupId;
@@ -126,7 +121,7 @@ public class BrowseAction
     
     private String getPrincipal()
     {
-        return archivaUser.getActivePrincipal();
+        return ArchivaXworkUser.getActivePrincipal();
     }
     
     private List<String> getObservableRepos()
index 2785f7414eca76165df58aac4aa69924f3f9164f..fbce024a407c9654bb4ef26fd82f34b28a48f67b 100644 (file)
@@ -19,6 +19,10 @@ package org.apache.maven.archiva.web.action;
  * under the License.
  */
 
+import java.net.MalformedURLException;
+import java.util.Collections;
+import java.util.List;
+
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang.StringUtils;
 import org.apache.maven.archiva.database.ArchivaDAO;
@@ -31,15 +35,11 @@ import org.apache.maven.archiva.indexer.search.SearchResultLimits;
 import org.apache.maven.archiva.indexer.search.SearchResults;
 import org.apache.maven.archiva.security.AccessDeniedException;
 import org.apache.maven.archiva.security.ArchivaSecurityException;
-import org.apache.maven.archiva.security.ArchivaUser;
 import org.apache.maven.archiva.security.PrincipalNotFoundException;
 import org.apache.maven.archiva.security.UserRepositories;
+import org.apache.maven.archiva.web.util.ArchivaXworkUser;
 import org.codehaus.plexus.xwork.action.PlexusActionSupport;
 
-import java.net.MalformedURLException;
-import java.util.Collections;
-import java.util.List;
-
 /**
  * Search all indexed fields by the given criteria.
  *
@@ -73,11 +73,6 @@ public class SearchAction
      */
     private UserRepositories userRepositories;
     
-    /**
-     * @plexus.requirement role-hint="xwork"
-     */
-    private ArchivaUser archivaUser;
-
     private static final String RESULTS = "results";
 
     private static final String ARTIFACT = "artifact";
@@ -160,7 +155,7 @@ public class SearchAction
     
     private String getPrincipal()
     {
-        return archivaUser.getActivePrincipal();
+        return ArchivaXworkUser.getActivePrincipal();
     }
     
     private List<String> getObservableRepos()
index faaa8261d22213cb6548be0c694ca8d1df66397a..8f5fab1bed559eacb4043ecd7461665aa7ff15b4 100644 (file)
@@ -19,7 +19,8 @@ package org.apache.maven.archiva.web.action;
  * under the License.
  */
 
-import com.opensymphony.xwork.Validateable;
+import java.util.Collections;
+import java.util.List;
 
 import org.apache.commons.lang.StringUtils;
 import org.apache.maven.archiva.database.ArchivaDatabaseException;
@@ -28,13 +29,12 @@ import org.apache.maven.archiva.database.browsing.RepositoryBrowsing;
 import org.apache.maven.archiva.model.ArchivaProjectModel;
 import org.apache.maven.archiva.security.AccessDeniedException;
 import org.apache.maven.archiva.security.ArchivaSecurityException;
-import org.apache.maven.archiva.security.ArchivaUser;
 import org.apache.maven.archiva.security.PrincipalNotFoundException;
 import org.apache.maven.archiva.security.UserRepositories;
+import org.apache.maven.archiva.web.util.ArchivaXworkUser;
 import org.codehaus.plexus.xwork.action.PlexusActionSupport;
 
-import java.util.Collections;
-import java.util.List;
+import com.opensymphony.xwork.Validateable;
 
 /**
  * Browse the repository.
@@ -58,11 +58,6 @@ public class ShowArtifactAction
      */
     private UserRepositories userRepositories;
     
-    /**
-     * @plexus.requirement role-hint="xwork"
-     */
-    private ArchivaUser archivaUser;
-
     /* .\ Input Parameters \.________________________________________ */
 
     private String groupId;
@@ -178,7 +173,7 @@ public class ShowArtifactAction
     
     private String getPrincipal()
     {
-        return archivaUser.getActivePrincipal();
+        return ArchivaXworkUser.getActivePrincipal();
     }
     
     private List<String> getObservableRepos()
index 8df8f8e2ee92ba9d23b4411041fad9ff58abd0c6..26b7800d8b206dec54c02ac91707998fa0cf5369 100644 (file)
@@ -19,7 +19,15 @@ package org.apache.maven.archiva.web.action;
  * under the License.
  */
 
-import org.codehaus.plexus.xwork.action.PlexusActionSupport;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collections;
+import java.util.List;
+
 import org.apache.maven.archiva.common.utils.Checksums;
 import org.apache.maven.archiva.common.utils.VersionComparator;
 import org.apache.maven.archiva.common.utils.VersionUtil;
@@ -38,23 +46,16 @@ import org.apache.maven.archiva.repository.metadata.RepositoryMetadataReader;
 import org.apache.maven.archiva.repository.metadata.RepositoryMetadataWriter;
 import org.apache.maven.archiva.repository.project.ProjectModelException;
 import org.apache.maven.archiva.repository.project.ProjectModelWriter;
+import org.apache.maven.archiva.repository.project.writers.ProjectModel400Writer;
 import org.apache.maven.archiva.security.ArchivaSecurityException;
-import org.apache.maven.archiva.security.ArchivaUser;
 import org.apache.maven.archiva.security.PrincipalNotFoundException;
 import org.apache.maven.archiva.security.UserRepositories;
+import org.apache.maven.archiva.web.util.ArchivaXworkUser;
+import org.codehaus.plexus.xwork.action.PlexusActionSupport;
 
 import com.opensymphony.xwork.Preparable;
 import com.opensymphony.xwork.Validateable;
 
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Collections;
-import java.util.List;
-
 /**
  * Upload an artifact using Jakarta file upload in webwork. If set by the user a pom will also be generated. Metadata
  * will also be updated if one exists, otherwise it would be created.
@@ -122,11 +123,6 @@ public class UploadAction
      */
     private List<String> managedRepoIdList;
 
-    /**
-     * @plexus.requirement role-hint="xwork"
-     */
-    private ArchivaUser archivaUser;
-
     /**
      * @plexus.requirement
      */
@@ -142,10 +138,7 @@ public class UploadAction
      */
     private RepositoryContentFactory repositoryFactory;
 
-    /**
-     * @plexus.requirement role-hint="model400"
-     */
-    private ProjectModelWriter pomWriter;
+    private ProjectModelWriter pomWriter = new ProjectModel400Writer();
     
     /**
      * @plexus.requirement
@@ -334,7 +327,7 @@ public class UploadAction
 
     private String getPrincipal()
     {
-        return archivaUser.getActivePrincipal();
+        return ArchivaXworkUser.getActivePrincipal();
     }
 
     private void copyFile( File targetPath, String artifactFilename )
index da8b31f5c90a6c9e23e3e6f744b470ea4071407e..32168b7f5f722badb8c3b9df03405262f0037948 100644 (file)
@@ -19,6 +19,18 @@ package org.apache.maven.archiva.web.repository;
  * under the License.
  */
 
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletResponse;
+
 import org.apache.maven.archiva.common.utils.PathUtil;
 import org.apache.maven.archiva.model.ArtifactReference;
 import org.apache.maven.archiva.model.ProjectReference;
@@ -36,7 +48,7 @@ import org.apache.maven.archiva.repository.content.RepositoryRequest;
 import org.apache.maven.archiva.repository.layout.LayoutException;
 import org.apache.maven.archiva.repository.metadata.MetadataTools;
 import org.apache.maven.archiva.repository.metadata.RepositoryMetadataException;
-import org.apache.maven.archiva.security.ArchivaUser;
+import org.apache.maven.archiva.web.util.ArchivaXworkUser;
 import org.apache.maven.archiva.webdav.AbstractDavServerComponent;
 import org.apache.maven.archiva.webdav.DavServerComponent;
 import org.apache.maven.archiva.webdav.DavServerException;
@@ -49,17 +61,6 @@ import org.apache.maven.model.Relocation;
 import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
 import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
 
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletResponse;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.List;
-
 /**
  * ProxiedDavServer
  * 
@@ -102,11 +103,6 @@ public class ProxiedDavServer
      */
     private MetadataTools metadataTools;
 
-    /**
-     * @plexus.requirement role-hint="xwork"
-     */
-    private ArchivaUser archivaUser;
-
     private ManagedRepositoryContent managedRepository;
 
     public String getPrefix()
@@ -576,7 +572,7 @@ public class ProxiedDavServer
 
     private void triggerAuditEvent( DavServerRequest request, String resource, String action )
     {
-        triggerAuditEvent( archivaUser.getActivePrincipal(), getRemoteIP( request ), resource,
+        triggerAuditEvent( ArchivaXworkUser.getActivePrincipal(), getRemoteIP( request ), resource,
             action );
     }
 
index 82113ed76b0c872314f75adde91d07546af81c2a..a3e058080910ebcfaf03d5d14073246a8568b03c 100644 (file)
@@ -54,7 +54,7 @@ public class ArchivaStartup
         ArchivaTaskScheduler taskScheduler = (ArchivaTaskScheduler) wac.getBean(PlexusToSpringUtils.buildSpringId(ArchivaTaskScheduler.class));
         TaskQueueExecutor databaseUpdateQueue = (TaskQueueExecutor) wac.getBean(PlexusToSpringUtils.buildSpringId(TaskQueueExecutor.class, "database-update"));
         TaskQueueExecutor repositoryScanningQueue = (TaskQueueExecutor) wac.getBean(PlexusToSpringUtils.buildSpringId(TaskQueueExecutor.class, "repository-scanning"));
-        Banner banner = (Banner) wac.getBean(PlexusToSpringUtils.buildSpringId(Banner.class));
+        Banner banner = new Banner();
 
         try
         {
index 76a5223ee4d1f5f893edc0f4446b892e900d9123..fb5cd2b5489ef8bb1f8a16183906afdd8b65ec5d 100644 (file)
@@ -31,10 +31,6 @@ import org.slf4j.LoggerFactory;
  *
  * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
  * @version $Id$
- * 
- * @plexus.component 
- *              role="org.apache.maven.archiva.web.startup.Banner"
- *              role-hint="default"
  */
 public class Banner
 {
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/tags/CopyPasteSnippet.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/tags/CopyPasteSnippet.java
deleted file mode 100644 (file)
index ab7387b..0000000
+++ /dev/null
@@ -1,157 +0,0 @@
-package org.apache.maven.archiva.web.tags;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.IOException;
-
-import javax.servlet.jsp.JspException;
-import javax.servlet.jsp.JspWriter;
-import javax.servlet.jsp.PageContext;
-
-import org.apache.commons.lang.StringEscapeUtils;
-import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
-import org.apache.maven.archiva.web.util.ContextUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * CopyPasteSnippet
- *
- * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
- * @version $Id$
- * @plexus.component role="org.apache.maven.archiva.web.tags.CopyPasteSnippet"
- */
-public class CopyPasteSnippet
-{
-    private Logger log = LoggerFactory.getLogger( CopyPasteSnippet.class );
-    
-    public static final String PRE = "pre";
-    
-    public static final String TOGGLE = "toggle";
-    
-    public void write( String wrapper, Object o, PageContext pageContext )
-        throws JspException
-    {
-        StringBuffer prefix = new StringBuffer();
-        StringBuffer buf = new StringBuffer();
-        StringBuffer suffix = new StringBuffer();
-
-        if ( o == null )
-        {
-            buf.append( "Error generating snippet." );
-            log.error( "Unable to generate snippet for null object." );
-        }
-        else if ( o instanceof ManagedRepositoryConfiguration )
-        {
-            ManagedRepositoryConfiguration repo = (ManagedRepositoryConfiguration) o;
-            
-            if ( TOGGLE.equals( wrapper ) )
-            {
-                prefix.append( "<a href=\"#\" onclick=\"Effect.toggle('repoPom" );
-                prefix.append( repo.getId() ).append( "','slide'); return false;\">Show POM Snippet</a><br/>" );
-                prefix.append( "<pre class=\"pom\" style=\"display: none;\" id=\"repoPom" ).append( repo.getId() );
-                prefix.append( "\"><code>" );
-
-                suffix.append( "</code></pre>" );
-            }
-            else if ( PRE.equals( wrapper ) )
-            {
-                prefix.append( "<pre>" );
-                suffix.append( "</pre>" );
-            }
-            
-            createSnippet( buf, repo, pageContext );
-        }
-        else
-        {
-            buf.append( "Unable to generate snippet for object " ).append( o.getClass().getName() );
-        }
-
-        try
-        {
-            JspWriter out = pageContext.getOut();
-
-            out.write( prefix.toString() );
-            out.write( StringEscapeUtils.escapeXml( buf.toString() ) );
-            out.write( suffix.toString() );
-            
-            out.flush();
-        }
-        catch ( IOException e )
-        {
-            throw new JspException( "Unable to write snippet to output: " + e.getMessage(), e );
-        }
-    }
-
-    private void createSnippet( StringBuffer snippet, ManagedRepositoryConfiguration repo, PageContext pageContext )
-    {
-        snippet.append( "<project>\n" );
-        snippet.append( "  ...\n" );
-        snippet.append( "  <distributionManagement>\n" );
-
-        String distRepoName = "repository";
-        if ( repo.isSnapshots() )
-        {
-            distRepoName = "snapshotRepository";
-        }
-
-        snippet.append( "    <" ).append( distRepoName ).append( ">\n" );
-        snippet.append( "      <id>" ).append( repo.getId() ).append( "</id>\n" );
-        snippet.append( "      <url>dav:" ).append( ContextUtils.getBaseURL( pageContext, "repository" ) );
-        snippet.append( "/" ).append( repo.getId() ).append( "/" ).append( "</url>\n" );
-
-        if ( !"default".equals( repo.getLayout() ) )
-        {
-            snippet.append( "      <layout>" ).append( repo.getLayout() ).append( "</layout>" );
-        }
-
-        snippet.append( "    </" ).append( distRepoName ).append( ">\n" );
-        snippet.append( "  </distributionManagement>\n" );
-        snippet.append( "\n" );
-
-        snippet.append( "  <repositories>\n" );
-        snippet.append( "    <repository>\n" );
-        snippet.append( "      <id>" ).append( repo.getId() ).append( "</id>\n" );
-        snippet.append( "      <name>" ).append( repo.getName() ).append( "</name>\n" );
-
-        snippet.append( "      <url>" );
-        snippet.append( ContextUtils.getBaseURL( pageContext, "repository" ) );
-        snippet.append( "/" ).append( repo.getId() ).append( "/" );
-
-        snippet.append( "</url>\n" );
-
-        if ( !"default".equals( repo.getLayout() ) )
-        {
-            snippet.append( "      <layout>" ).append( repo.getLayout() ).append( "</layout>\n" );
-        }
-
-        snippet.append( "      <releases>\n" );
-        snippet.append( "        <enabled>" ).append( Boolean.valueOf( repo.isReleases() ) ).append( "</enabled>\n" );
-        snippet.append( "      </releases>\n" );
-        snippet.append( "      <snapshots>\n" );
-        snippet.append( "        <enabled>" ).append( Boolean.valueOf( repo.isSnapshots() ) ).append( "</enabled>\n" );
-        snippet.append( "      </snapshots>\n" );
-        snippet.append( "    </repository>\n" );
-        snippet.append( "  </repositories>\n" );
-
-        snippet.append( "  ...\n" );
-        snippet.append( "</project>\n" );
-    }
-}
index 47054e82f9c3f8545c08cb2332304655a03d06bb..0a18effe69bb2d4628ebca511e0cea80fd261577 100644 (file)
@@ -19,11 +19,19 @@ package org.apache.maven.archiva.web.tags;
  * under the License.
  */
 
-import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
+import java.io.IOException;
 
 import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.JspWriter;
+import javax.servlet.jsp.PageContext;
 import javax.servlet.jsp.tagext.TagSupport;
 
+import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
+import org.apache.maven.archiva.web.util.ContextUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 /**
  * CopyPasteSnippetTag 
  *
@@ -33,10 +41,16 @@ import javax.servlet.jsp.tagext.TagSupport;
 public class CopyPasteSnippetTag
     extends TagSupport
 {
+    private Logger log = LoggerFactory.getLogger( CopyPasteSnippetTag.class );
+    
     private Object object;
     
-    private String wrapper = CopyPasteSnippet.PRE;
+    private String wrapper = PRE;
 
+    public static final String PRE = "pre";
+    
+    public static final String TOGGLE = "toggle";
+    
     public void release()
     {
         object = null;
@@ -46,22 +60,55 @@ public class CopyPasteSnippetTag
     public int doEndTag()
         throws JspException
     {
-        CopyPasteSnippet snippet;
-        try
+        StringBuffer prefix = new StringBuffer();
+        StringBuffer buf = new StringBuffer();
+        StringBuffer suffix = new StringBuffer();
+        
+        if ( object == null )
         {
-            snippet = (CopyPasteSnippet) PlexusTagUtil.lookup( pageContext, CopyPasteSnippet.class.getName() );
+            buf.append( "Error generating snippet." );
+            log.error( "Unable to generate snippet for null object." );
         }
-        catch ( ComponentLookupException e )
+        else if ( object instanceof ManagedRepositoryConfiguration )
         {
-            throw new JspException( "Unable to lookup CopyPasteSnippet: " + e.getMessage(), e );
+            ManagedRepositoryConfiguration repo = (ManagedRepositoryConfiguration) object;
+            
+            if ( TOGGLE.equals( wrapper ) )
+            {
+                prefix.append( "<a href=\"#\" onclick=\"Effect.toggle('repoPom" );
+                prefix.append( repo.getId() ).append( "','slide'); return false;\">Show POM Snippet</a><br/>" );
+                prefix.append( "<pre class=\"pom\" style=\"display: none;\" id=\"repoPom" ).append( repo.getId() );
+                prefix.append( "\"><code>" );
+        
+                suffix.append( "</code></pre>" );
+            }
+            else if ( PRE.equals( wrapper ) )
+            {
+                prefix.append( "<pre>" );
+                suffix.append( "</pre>" );
+            }
+            
+            createSnippet( buf, repo, pageContext );
         }
-
-        if ( snippet == null )
+        else
         {
-            throw new JspException( "Unable to process snippet.  Component not found." );
+            buf.append( "Unable to generate snippet for object " ).append( object.getClass().getName() );
+        }
+        
+        try
+        {
+            JspWriter out = pageContext.getOut();
+        
+            out.write( prefix.toString() );
+            out.write( StringEscapeUtils.escapeXml( buf.toString() ) );
+            out.write( suffix.toString() );
+            
+            out.flush();
+        }
+        catch ( IOException e )
+        {
+            throw new JspException( "Unable to write snippet to output: " + e.getMessage(), e );
         }
-
-        snippet.write( wrapper, object, pageContext );
 
         return super.doEndTag();
     }
@@ -75,4 +122,59 @@ public class CopyPasteSnippetTag
     {
         this.wrapper = wrapper;
     }
+
+    private void createSnippet( StringBuffer snippet, ManagedRepositoryConfiguration repo, PageContext pageContext )
+    {
+        snippet.append( "<project>\n" );
+        snippet.append( "  ...\n" );
+        snippet.append( "  <distributionManagement>\n" );
+
+        String distRepoName = "repository";
+        if ( repo.isSnapshots() )
+        {
+            distRepoName = "snapshotRepository";
+        }
+
+        snippet.append( "    <" ).append( distRepoName ).append( ">\n" );
+        snippet.append( "      <id>" ).append( repo.getId() ).append( "</id>\n" );
+        snippet.append( "      <url>dav:" ).append( ContextUtils.getBaseURL( pageContext, "repository" ) );
+        snippet.append( "/" ).append( repo.getId() ).append( "/" ).append( "</url>\n" );
+
+        if ( !"default".equals( repo.getLayout() ) )
+        {
+            snippet.append( "      <layout>" ).append( repo.getLayout() ).append( "</layout>" );
+        }
+
+        snippet.append( "    </" ).append( distRepoName ).append( ">\n" );
+        snippet.append( "  </distributionManagement>\n" );
+        snippet.append( "\n" );
+
+        snippet.append( "  <repositories>\n" );
+        snippet.append( "    <repository>\n" );
+        snippet.append( "      <id>" ).append( repo.getId() ).append( "</id>\n" );
+        snippet.append( "      <name>" ).append( repo.getName() ).append( "</name>\n" );
+
+        snippet.append( "      <url>" );
+        snippet.append( ContextUtils.getBaseURL( pageContext, "repository" ) );
+        snippet.append( "/" ).append( repo.getId() ).append( "/" );
+
+        snippet.append( "</url>\n" );
+
+        if ( !"default".equals( repo.getLayout() ) )
+        {
+            snippet.append( "      <layout>" ).append( repo.getLayout() ).append( "</layout>\n" );
+        }
+
+        snippet.append( "      <releases>\n" );
+        snippet.append( "        <enabled>" ).append( Boolean.valueOf( repo.isReleases() ) ).append( "</enabled>\n" );
+        snippet.append( "      </releases>\n" );
+        snippet.append( "      <snapshots>\n" );
+        snippet.append( "        <enabled>" ).append( Boolean.valueOf( repo.isSnapshots() ) ).append( "</enabled>\n" );
+        snippet.append( "      </snapshots>\n" );
+        snippet.append( "    </repository>\n" );
+        snippet.append( "  </repositories>\n" );
+
+        snippet.append( "  ...\n" );
+        snippet.append( "</project>\n" );
+    }
 }
index 37df624f218a4077157a3c0b86ede564c34007a3..208d82ebeb537e80fe535e0506184b614a5e9a1c 100644 (file)
@@ -19,30 +19,25 @@ package org.apache.maven.archiva.web.util;
  * under the License.
  */
 
-import com.opensymphony.xwork.ActionContext;
+import java.util.HashMap;
+import java.util.Map;
 
 import org.apache.maven.archiva.security.ArchivaRoleConstants;
-import org.apache.maven.archiva.security.ArchivaUser;
 import org.codehaus.plexus.redback.system.SecuritySession;
 import org.codehaus.plexus.redback.system.SecuritySystemConstants;
 import org.codehaus.plexus.redback.users.User;
 
-import java.util.HashMap;
-import java.util.Map;
+import com.opensymphony.xwork.ActionContext;
 
 /**
  * ArchivaXworkUser 
  *
  * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
  * @version $Id$
- * 
- * @plexus.component role="org.apache.maven.archiva.security.ArchivaUser"
- *                   role-hint="xwork"
  */
 public class ArchivaXworkUser
-    implements ArchivaUser
 {
-    private Map<String, Object> getContextSession()
+    private static Map<String, Object> getContextSession()
     {
         ActionContext context = ActionContext.getContext();
         Map<String, Object> sessionMap = context.getSession();
@@ -54,7 +49,7 @@ public class ArchivaXworkUser
         return sessionMap;
     }
 
-    private SecuritySession getSecuritySession()
+    private static SecuritySession getSecuritySession()
     {
        SecuritySession securitySession =
             (SecuritySession) getContextSession().get( SecuritySystemConstants.SECURITY_SESSION_KEY );
@@ -67,7 +62,7 @@ public class ArchivaXworkUser
         return securitySession;        
     }
 
-    public String getActivePrincipal()
+    public static String getActivePrincipal()
     {
         SecuritySession securitySession = getSecuritySession();