* 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;
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
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";
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: ";
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;
*/
private RepositoryContentFactory repositoryFactory;
- /**
- * @plexus.requirement role-hint="model400"
- */
- private ProjectModelReader project400Reader;
-
- /**
- * @plexus.requirement role-hint="model300"
- */
- private ProjectModelReader project300Reader;
-
/**
* @plexus.requirement role-hint="expression"
*/
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
*
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
* @version $Id$
- *
- * @plexus.component role="org.apache.maven.archiva.dependency.DependencyGraphFactory"
*/
public class DependencyGraphFactory
{
*
* @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
*
* @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
*
* @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
*
* @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
*
* @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
*
* @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
*
* @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
*
* @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
*
* @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
*
* @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
*
* @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
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
*
* @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
{
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;
* @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"
* @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"
* @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"
* @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"
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;
*/
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 )
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 );
*
* @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
*
* @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
*
* @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
{
*
* @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
{
super.setUp();
- modelWriter = (ProjectModelWriter) lookup( ProjectModelWriter.class, "model400" );
+ modelWriter = new ProjectModel400Writer();
}
public void testSimpleWrite()
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;
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" );
+++ /dev/null
-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();
-}
* 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.
*
*/
private UserRepositories userRepositories;
- /**
- * @plexus.requirement role-hint="xwork"
- */
- private ArchivaUser archivaUser;
-
private BrowsingResults results;
private String groupId;
private String getPrincipal()
{
- return archivaUser.getActivePrincipal();
+ return ArchivaXworkUser.getActivePrincipal();
}
private List<String> getObservableRepos()
* 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;
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.
*
*/
private UserRepositories userRepositories;
- /**
- * @plexus.requirement role-hint="xwork"
- */
- private ArchivaUser archivaUser;
-
private static final String RESULTS = "results";
private static final String ARTIFACT = "artifact";
private String getPrincipal()
{
- return archivaUser.getActivePrincipal();
+ return ArchivaXworkUser.getActivePrincipal();
}
private List<String> getObservableRepos()
* 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;
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.
*/
private UserRepositories userRepositories;
- /**
- * @plexus.requirement role-hint="xwork"
- */
- private ArchivaUser archivaUser;
-
/* .\ Input Parameters \.________________________________________ */
private String groupId;
private String getPrincipal()
{
- return archivaUser.getActivePrincipal();
+ return ArchivaXworkUser.getActivePrincipal();
}
private List<String> getObservableRepos()
* 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;
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.
*/
private List<String> managedRepoIdList;
- /**
- * @plexus.requirement role-hint="xwork"
- */
- private ArchivaUser archivaUser;
-
/**
* @plexus.requirement
*/
*/
private RepositoryContentFactory repositoryFactory;
- /**
- * @plexus.requirement role-hint="model400"
- */
- private ProjectModelWriter pomWriter;
+ private ProjectModelWriter pomWriter = new ProjectModel400Writer();
/**
* @plexus.requirement
private String getPrincipal()
{
- return archivaUser.getActivePrincipal();
+ return ArchivaXworkUser.getActivePrincipal();
}
private void copyFile( File targetPath, String artifactFilename )
* 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;
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;
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
*
*/
private MetadataTools metadataTools;
- /**
- * @plexus.requirement role-hint="xwork"
- */
- private ArchivaUser archivaUser;
-
private ManagedRepositoryContent managedRepository;
public String getPrefix()
private void triggerAuditEvent( DavServerRequest request, String resource, String action )
{
- triggerAuditEvent( archivaUser.getActivePrincipal(), getRemoteIP( request ), resource,
+ triggerAuditEvent( ArchivaXworkUser.getActivePrincipal(), getRemoteIP( request ), resource,
action );
}
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
{
*
* @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
{
+++ /dev/null
-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" );
- }
-}
* 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
*
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;
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();
}
{
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" );
+ }
}
* 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();
return sessionMap;
}
- private SecuritySession getSecuritySession()
+ private static SecuritySession getSecuritySession()
{
SecuritySession securitySession =
(SecuritySession) getContextSession().get( SecuritySystemConstants.SECURITY_SESSION_KEY );
return securitySession;
}
- public String getActivePrincipal()
+ public static String getActivePrincipal()
{
SecuritySession securitySession = getSecuritySession();