ClassWorld classWorld = new ClassWorld();
- ClassRealm classRealm = new ClassRealm( classWorld, "maven", Thread.currentThread().getContextClassLoader() );
+ ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+
+ ClassRealm classRealm = new ClassRealm( classWorld, "maven", tccl )
+ {
+ public URL[] getURLs()
+ {
+ return super.getURLs();
+ }
+
+ };
conf.setRealm( classRealm );
conf.setClassWorld( classWorld );
*
* @todo no need to be a component when filetypes, legacy path parser is not
*
- * @plexus.component
+ * plexus.component
* role="org.apache.maven.archiva.repository.ManagedRepositoryContent"
* role-hint="legacy"
* instantiation-strategy="per-lookup"
<groupId>org.apache.archiva</groupId>
<artifactId>metadata-model</artifactId>
</dependency>
+
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-model</artifactId>
+ <version>${maven3x.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-model-builder</artifactId>
+ <version>${maven3x.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.sonatype.sisu</groupId>
+ <artifactId>sisu-inject-plexus</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.sonatype.sisu</groupId>
+ <artifactId>sisu-guice</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>archiva-plexus-bridge</artifactId>
+ </dependency>
+
<dependency>
<groupId>org.apache.archiva</groupId>
<artifactId>metadata-repository-api</artifactId>
</execution>
</executions>
</plugin>
- <plugin>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-component-metadata</artifactId>
- <configuration>
- <roleDefaults>
- <roleDefault>
- <role>com.opensymphony.xwork2.Action</role>
- <instantiation-strategy>per-lookup</instantiation-strategy>
- </roleDefault>
- </roleDefaults>
- </configuration>
- </plugin>
</plugins>
</build>
<profiles>
--- /dev/null
+package org.apache.maven.archiva.web.action;\r
+\r
+/*\r
+ * Licensed to the Apache Software Foundation (ASF) under one\r
+ * or more contributor license agreements. See the NOTICE file\r
+ * distributed with this work for additional information\r
+ * regarding copyright ownership. The ASF licenses this file\r
+ * to you under the Apache License, Version 2.0 (the\r
+ * "License"); you may not use this file except in compliance\r
+ * with the License. You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing,\r
+ * software distributed under the License is distributed on an\r
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\r
+ * KIND, either express or implied. See the License for the\r
+ * specific language governing permissions and limitations\r
+ * under the License.\r
+ */\r
+\r
+import com.google.common.collect.Lists;\r
+import com.opensymphony.xwork2.ActionContext;\r
+import com.opensymphony.xwork2.ActionSupport;\r
+import org.apache.archiva.audit.AuditEvent;\r
+import org.apache.archiva.audit.AuditListener;\r
+import org.apache.archiva.audit.Auditable;\r
+import org.apache.archiva.metadata.repository.RepositorySessionFactory;\r
+import org.apache.commons.lang.StringUtils;\r
+import org.apache.maven.archiva.security.ArchivaXworkUser;\r
+import org.apache.struts2.ServletActionContext;\r
+import org.apache.struts2.interceptor.SessionAware;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
+import org.springframework.context.ApplicationContext;\r
+\r
+import javax.annotation.PostConstruct;\r
+import javax.inject.Inject;\r
+import javax.servlet.http.HttpServletRequest;\r
+import java.util.ArrayList;\r
+import java.util.HashMap;\r
+import java.util.List;\r
+import java.util.Map;\r
+\r
+/**\r
+ * LogEnabled and SessionAware ActionSupport\r
+ */\r
+public abstract class AbstractActionSupport\r
+ extends ActionSupport\r
+ implements SessionAware, Auditable\r
+{\r
+ protected Map<?, ?> session;\r
+\r
+ protected Logger log = LoggerFactory.getLogger( getClass() );\r
+\r
+ /**\r
+ * plexus.requirement role="org.apache.archiva.audit.AuditListener"\r
+ */\r
+ private List<AuditListener> auditListeners = new ArrayList<AuditListener>();\r
+\r
+ /**\r
+ * plexus.requirement\r
+ */\r
+ @Inject\r
+ protected RepositorySessionFactory repositorySessionFactory;\r
+\r
+ @Inject\r
+ protected ApplicationContext applicationContext;\r
+\r
+ private String principal;\r
+\r
+ @PostConstruct\r
+ public void initialize()\r
+ {\r
+ // TODO some caching here\r
+ this.auditListeners = Lists.newArrayList( applicationContext.getBeansOfType( AuditListener.class ).values() );\r
+ }\r
+\r
+ @SuppressWarnings( "unchecked" )\r
+ public void setSession( Map map )\r
+ {\r
+ this.session = map;\r
+ }\r
+\r
+ public void addAuditListener( AuditListener listener )\r
+ {\r
+ this.auditListeners.add( listener );\r
+ }\r
+\r
+ public void clearAuditListeners()\r
+ {\r
+ this.auditListeners.clear();\r
+ }\r
+\r
+ public void removeAuditListener( AuditListener listener )\r
+ {\r
+ this.auditListeners.remove( listener );\r
+ }\r
+\r
+ protected void triggerAuditEvent( String repositoryId, String resource, String action )\r
+ {\r
+ AuditEvent event = new AuditEvent( repositoryId, getPrincipal(), resource, action );\r
+ event.setRemoteIP( getRemoteAddr() );\r
+\r
+ for ( AuditListener listener : auditListeners )\r
+ {\r
+ listener.auditEvent( event );\r
+ }\r
+ }\r
+\r
+ protected void triggerAuditEvent( String resource, String action )\r
+ {\r
+ AuditEvent event = new AuditEvent( null, getPrincipal(), resource, action );\r
+ event.setRemoteIP( getRemoteAddr() );\r
+\r
+ for ( AuditListener listener : auditListeners )\r
+ {\r
+ listener.auditEvent( event );\r
+ }\r
+ }\r
+\r
+ protected void triggerAuditEvent( String action )\r
+ {\r
+ AuditEvent event = new AuditEvent( null, getPrincipal(), null, action );\r
+ event.setRemoteIP( getRemoteAddr() );\r
+\r
+ for ( AuditListener listener : auditListeners )\r
+ {\r
+ listener.auditEvent( event );\r
+ }\r
+ }\r
+\r
+ private String getRemoteAddr()\r
+ {\r
+ HttpServletRequest request = ServletActionContext.getRequest();\r
+ return request != null ? request.getRemoteAddr() : null;\r
+ }\r
+\r
+ @SuppressWarnings( "unchecked" )\r
+ protected String getPrincipal()\r
+ {\r
+ if ( principal != null )\r
+ {\r
+ return principal;\r
+ }\r
+ return ArchivaXworkUser.getActivePrincipal( ActionContext.getContext().getSession() );\r
+ }\r
+\r
+ void setPrincipal( String principal )\r
+ {\r
+ this.principal = principal;\r
+ }\r
+\r
+ public void setAuditListeners( List<AuditListener> auditListeners )\r
+ {\r
+ this.auditListeners = auditListeners;\r
+ }\r
+\r
+ public void setRepositorySessionFactory( RepositorySessionFactory repositorySessionFactory )\r
+ {\r
+ this.repositorySessionFactory = repositorySessionFactory;\r
+ }\r
+\r
+ protected <T> Map<String, T> getBeansOfType( Class<T> clazz )\r
+ {\r
+ //TODO do some caching here !!!\r
+ // olamy : with plexus we get only roleHint\r
+ // as per convention we named spring bean role#hint remove role# if exists\r
+ Map<String, T> springBeans = applicationContext.getBeansOfType( clazz );\r
+\r
+ Map<String, T> beans = new HashMap<String, T>( springBeans.size() );\r
+\r
+ for ( Map.Entry<String, T> entry : springBeans.entrySet() )\r
+ {\r
+ String key = StringUtils.substringAfterLast( entry.getKey(), "#" );\r
+ beans.put( key, entry.getValue() );\r
+ }\r
+ return beans;\r
+ }\r
+}\r
import org.apache.maven.archiva.security.PrincipalNotFoundException;
import org.apache.maven.archiva.security.UserRepositories;
+import javax.inject.Inject;
+
public class AbstractRepositoryBasedAction
- extends PlexusActionSupport
+ extends AbstractActionSupport
{
/**
- * @plexus.requirement
+ * plexus.requirement
*/
+ @Inject
private UserRepositories userRepositories;
protected List<String> getObservableRepos()
import org.apache.archiva.metadata.repository.storage.maven2.MavenProjectFacet;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Controller;
import java.util.ArrayList;
import java.util.Collection;
* Browse the repository.
*
* @todo implement repository selectors (all or specific repository)
- * @plexus.component role="com.opensymphony.xwork2.Action" role-hint="browseAction" instantiation-strategy="per-lookup"
+ * plexus.component role="com.opensymphony.xwork2.Action" role-hint="browseAction" instantiation-strategy="per-lookup"
*/
+@Controller( "browseAction" )
+@Scope( "prototype" )
public class BrowseAction
extends AbstractRepositoryBasedAction
{
for ( String n : namespacesToCollapse )
{
// TODO: check performance of this
- namespaces.add( collapseNamespaces( repositorySession, metadataResolver, selectedRepos,
- groupId + "." + n ) );
+ namespaces.add(
+ collapseNamespaces( repositorySession, metadataResolver, selectedRepos, groupId + "." + n ) );
}
}
finally
Set<String> versions = new LinkedHashSet<String>();
for ( String repoId : selectedRepos )
{
- versions.addAll( metadataResolver.resolveProjectVersions( repositorySession, repoId, groupId,
- artifactId ) );
+ versions.addAll(
+ metadataResolver.resolveProjectVersions( repositorySession, repoId, groupId, artifactId ) );
}
// TODO: sort by known version ordering method
{
try
{
- versionMetadata = metadataResolver.resolveProjectVersion( repositorySession, repoId, groupId,
- artifactId, version );
+ versionMetadata =
+ metadataResolver.resolveProjectVersion( repositorySession, repoId, groupId, artifactId,
+ version );
}
catch ( MetadataResolutionException e )
{
log.error(
- "Skipping invalid metadata while compiling shared model for " + groupId + ":" + artifactId +
- " in repo " + repoId + ": " + e.getMessage() );
+ "Skipping invalid metadata while compiling shared model for " + groupId + ":" + artifactId
+ + " in repo " + repoId + ": " + e.getMessage() );
}
}
}
}
else
{
- MavenProjectFacet versionMetadataMavenFacet = (MavenProjectFacet) versionMetadata.getFacet(
- MavenProjectFacet.FACET_ID );
+ MavenProjectFacet versionMetadataMavenFacet =
+ (MavenProjectFacet) versionMetadata.getFacet( MavenProjectFacet.FACET_ID );
if ( versionMetadataMavenFacet != null )
{
if ( mavenFacet.getPackaging() != null && !StringUtils.equalsIgnoreCase( mavenFacet.getPackaging(),
sharedModel.setDescription( null );
}
- if ( sharedModel.getIssueManagement() != null && versionMetadata.getIssueManagement() != null &&
- !StringUtils.equalsIgnoreCase( sharedModel.getIssueManagement().getUrl(),
- versionMetadata.getIssueManagement().getUrl() ) )
+ if ( sharedModel.getIssueManagement() != null && versionMetadata.getIssueManagement() != null
+ && !StringUtils.equalsIgnoreCase( sharedModel.getIssueManagement().getUrl(),
+ versionMetadata.getIssueManagement().getUrl() ) )
{
sharedModel.setIssueManagement( null );
}
- if ( sharedModel.getCiManagement() != null && versionMetadata.getCiManagement() != null &&
- !StringUtils.equalsIgnoreCase( sharedModel.getCiManagement().getUrl(),
- versionMetadata.getCiManagement().getUrl() ) )
+ if ( sharedModel.getCiManagement() != null && versionMetadata.getCiManagement() != null
+ && !StringUtils.equalsIgnoreCase( sharedModel.getCiManagement().getUrl(),
+ versionMetadata.getCiManagement().getUrl() ) )
{
sharedModel.setCiManagement( null );
}
- if ( sharedModel.getOrganization() != null && versionMetadata.getOrganization() != null &&
- !StringUtils.equalsIgnoreCase( sharedModel.getOrganization().getName(),
- versionMetadata.getOrganization().getName() ) )
+ if ( sharedModel.getOrganization() != null && versionMetadata.getOrganization() != null
+ && !StringUtils.equalsIgnoreCase( sharedModel.getOrganization().getName(),
+ versionMetadata.getOrganization().getName() ) )
{
sharedModel.setOrganization( null );
}
* under the License.
*/
+import com.google.common.collect.Lists;
import com.opensymphony.xwork2.Preparable;
import com.opensymphony.xwork2.Validateable;
import org.apache.archiva.audit.AuditEvent;
import org.apache.maven.archiva.security.ArchivaSecurityException;
import org.apache.maven.archiva.security.PrincipalNotFoundException;
import org.apache.maven.archiva.security.UserRepositories;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Controller;
+import javax.annotation.PostConstruct;
+import javax.inject.Inject;
import java.io.File;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
/**
* Delete an artifact. Metadata will be updated if one exists, otherwise it would be created.
- *
- * @plexus.component role="com.opensymphony.xwork2.Action" role-hint="deleteArtifactAction" instantiation-strategy="per-lookup"
+ * <p/>
+ * plexus.component role="com.opensymphony.xwork2.Action" role-hint="deleteArtifactAction" instantiation-strategy="per-lookup"
*/
+@Controller( "deleteArtifactAction" )
+@Scope( "prototype" )
public class DeleteArtifactAction
- extends PlexusActionSupport
+ extends AbstractActionSupport
implements Validateable, Preparable, Auditable
{
/**
private List<String> managedRepos;
/**
- * @plexus.requirement
+ * plexus.requirement
*/
+ @Inject
private UserRepositories userRepositories;
/**
- * @plexus.requirement role-hint="default"
+ * plexus.requirement role-hint="default"
*/
+ @Inject
private ArchivaConfiguration configuration;
/**
- * @plexus.requirement
+ * plexus.requirement
*/
+ @Inject
private RepositoryContentFactory repositoryFactory;
/**
- * @plexus.requirement role="org.apache.archiva.repository.events.RepositoryListener"
+ * plexus.requirement role="org.apache.archiva.repository.events.RepositoryListener"
*/
private List<RepositoryListener> listeners;
- private ChecksumAlgorithm[] algorithms = new ChecksumAlgorithm[]{ChecksumAlgorithm.SHA1, ChecksumAlgorithm.MD5};
+ private ChecksumAlgorithm[] algorithms = new ChecksumAlgorithm[]{ ChecksumAlgorithm.SHA1, ChecksumAlgorithm.MD5 };
+
+ @PostConstruct
+ public void initialize()
+ {
+ super.initialize();
+ listeners = Lists.newArrayList( applicationContext.getBeansOfType( RepositoryListener.class ).values() );
+ }
public String getGroupId()
{
TimeZone timezone = TimeZone.getTimeZone( "UTC" );
DateFormat fmt = new SimpleDateFormat( "yyyyMMdd.HHmmss" );
fmt.setTimeZone( timezone );
- ManagedRepositoryConfiguration repoConfig = configuration.getConfiguration().findManagedRepositoryById(
- repositoryId );
+ ManagedRepositoryConfiguration repoConfig =
+ configuration.getConfiguration().findManagedRepositoryById( repositoryId );
VersionedReference ref = new VersionedReference();
ref.setArtifactId( artifactId );
updateMetadata( metadata, metadataFile, lastUpdatedTimestamp );
MetadataRepository metadataRepository = repositorySession.getRepository();
- Collection<ArtifactMetadata> artifacts = metadataRepository.getArtifacts( repositoryId, groupId, artifactId,
- version );
+ Collection<ArtifactMetadata> artifacts =
+ metadataRepository.getArtifacts( repositoryId, groupId, artifactId, version );
for ( ArtifactMetadata artifact : artifacts )
{
repositorySession.close();
}
- String msg = "Artifact \'" + groupId + ":" + artifactId + ":" + version +
- "\' was successfully deleted from repository \'" + repositoryId + "\'";
+ String msg = "Artifact \'" + groupId + ":" + artifactId + ":" + version
+ + "\' was successfully deleted from repository \'" + repositoryId + "\'";
addActionMessage( msg );
private void trimAllRequestParameterValues()
{
- if( StringUtils.isNotEmpty(groupId))
+ if ( StringUtils.isNotEmpty( groupId ) )
{
groupId = groupId.trim();
}
- if(StringUtils.isNotEmpty(artifactId))
+ if ( StringUtils.isNotEmpty( artifactId ) )
{
artifactId = artifactId.trim();
}
- if(StringUtils.isNotEmpty(version))
+ if ( StringUtils.isNotEmpty( version ) )
{
version = version.trim();
}
- if(StringUtils.isNotEmpty(repositoryId))
+ if ( StringUtils.isNotEmpty( repositoryId ) )
{
repositoryId = repositoryId.trim();
}
import org.apache.maven.archiva.configuration.Configuration;
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.maven.archiva.web.action.admin.SchedulerAction;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Controller;
+import javax.inject.Inject;
+import javax.inject.Named;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
/**
- * @plexus.component role="com.opensymphony.xwork2.Action" role-hint="mergeAction" instantiation-strategy="per-lookup"
+ * plexus.component role="com.opensymphony.xwork2.Action" role-hint="mergeAction" instantiation-strategy="per-lookup"
*/
+@Controller( "mergeAction" )
+@Scope( "prototype" )
public class MergeAction
- extends PlexusActionSupport
+ extends AbstractActionSupport
implements Validateable, Preparable, Auditable
{
/**
- * @plexus.requirement role="org.apache.archiva.stagerepository.merge.RepositoryMerger" role-hint="maven2"
+ * plexus.requirement role="org.apache.archiva.stagerepository.merge.RepositoryMerger" role-hint="maven2"
*/
+ @Inject
+ @Named( value = "repositoryMerger#maven2" )
private Maven2RepositoryMerger repositoryMerger;
/**
- * @plexus.requirement
+ * plexus.requirement
*/
+ @Inject
protected ArchivaConfiguration archivaConfiguration;
/**
- * @plexus.requirement role="com.opensymphony.xwork2.Action" role-hint="schedulerAction"
+ * TODO olamy : why using an action ???
+ * plexus.requirement role="com.opensymphony.xwork2.Action" role-hint="schedulerAction"
*/
+ @Inject
private SchedulerAction scheduler;
private ManagedRepositoryConfiguration repository;
else
{
- Filter<ArtifactMetadata> artifactsWithOutConflicts = new IncludesFilter<ArtifactMetadata>(
- sourceArtifacts );
+ Filter<ArtifactMetadata> artifactsWithOutConflicts =
+ new IncludesFilter<ArtifactMetadata>( sourceArtifacts );
repositoryMerger.merge( metadataRepository, sourceRepoId, repoid, artifactsWithOutConflicts );
for ( ArtifactMetadata metadata : sourceArtifacts )
{
RepositorySession repositorySession = repositorySessionFactory.createSession();
try
{
- conflictSourceArtifacts = repositoryMerger.getConflictingArtifacts( repositorySession.getRepository(),
- sourceRepoId, repoid );
+ conflictSourceArtifacts =
+ repositoryMerger.getConflictingArtifacts( repositorySession.getRepository(), sourceRepoId, repoid );
}
catch ( Exception e )
{
RepositorySession repositorySession = repositorySessionFactory.createSession();
try
{
- conflictSourceArtifacts = repositoryMerger.getConflictingArtifacts( repositorySession.getRepository(),
- sourceRepoId, repoid );
+ conflictSourceArtifacts =
+ repositoryMerger.getConflictingArtifacts( repositorySession.getRepository(), sourceRepoId, repoid );
}
finally
{
+++ /dev/null
-package org.apache.maven.archiva.web.action;\r
-\r
-/*\r
- * Licensed to the Apache Software Foundation (ASF) under one\r
- * or more contributor license agreements. See the NOTICE file\r
- * distributed with this work for additional information\r
- * regarding copyright ownership. The ASF licenses this file\r
- * to you under the Apache License, Version 2.0 (the\r
- * "License"); you may not use this file except in compliance\r
- * with the License. You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing,\r
- * software distributed under the License is distributed on an\r
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\r
- * KIND, either express or implied. See the License for the\r
- * specific language governing permissions and limitations\r
- * under the License.\r
- */\r
-\r
-import com.opensymphony.xwork2.ActionContext;\r
-import com.opensymphony.xwork2.ActionSupport;\r
-import org.apache.archiva.audit.AuditEvent;\r
-import org.apache.archiva.audit.AuditListener;\r
-import org.apache.archiva.audit.Auditable;\r
-import org.apache.archiva.metadata.repository.RepositorySessionFactory;\r
-import org.apache.maven.archiva.security.ArchivaXworkUser;\r
-import org.apache.struts2.ServletActionContext;\r
-import org.apache.struts2.interceptor.SessionAware;\r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
-\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-import java.util.Map;\r
-import javax.servlet.http.HttpServletRequest;\r
-\r
-/**\r
- * LogEnabled and SessionAware ActionSupport\r
- */\r
-public abstract class PlexusActionSupport\r
- extends ActionSupport\r
- implements SessionAware, Auditable\r
-{\r
- protected Map<?, ?> session;\r
-\r
- protected Logger log = LoggerFactory.getLogger( getClass() );\r
-\r
- /**\r
- * @plexus.requirement role="org.apache.archiva.audit.AuditListener"\r
- */\r
- private List<AuditListener> auditListeners = new ArrayList<AuditListener>();\r
-\r
- /**\r
- * @plexus.requirement\r
- */\r
- protected RepositorySessionFactory repositorySessionFactory;\r
-\r
- private String principal;\r
-\r
- @SuppressWarnings( "unchecked" )\r
- public void setSession( Map map )\r
- {\r
- this.session = map;\r
- }\r
-\r
- public void addAuditListener( AuditListener listener )\r
- {\r
- this.auditListeners.add( listener );\r
- }\r
-\r
- public void clearAuditListeners()\r
- {\r
- this.auditListeners.clear();\r
- }\r
-\r
- public void removeAuditListener( AuditListener listener )\r
- {\r
- this.auditListeners.remove( listener );\r
- }\r
-\r
- protected void triggerAuditEvent( String repositoryId, String resource, String action )\r
- {\r
- AuditEvent event = new AuditEvent( repositoryId, getPrincipal(), resource, action );\r
- event.setRemoteIP( getRemoteAddr() );\r
-\r
- for ( AuditListener listener : auditListeners )\r
- {\r
- listener.auditEvent( event );\r
- }\r
- }\r
-\r
- protected void triggerAuditEvent( String resource, String action )\r
- {\r
- AuditEvent event = new AuditEvent( null, getPrincipal(), resource, action );\r
- event.setRemoteIP( getRemoteAddr() );\r
-\r
- for ( AuditListener listener : auditListeners )\r
- {\r
- listener.auditEvent( event );\r
- }\r
- }\r
-\r
- protected void triggerAuditEvent( String action )\r
- {\r
- AuditEvent event = new AuditEvent( null, getPrincipal(), null, action );\r
- event.setRemoteIP( getRemoteAddr() );\r
-\r
- for ( AuditListener listener : auditListeners )\r
- {\r
- listener.auditEvent( event );\r
- }\r
- }\r
-\r
- private String getRemoteAddr()\r
- {\r
- HttpServletRequest request = ServletActionContext.getRequest();\r
- return request != null ? request.getRemoteAddr() : null;\r
- }\r
-\r
- @SuppressWarnings( "unchecked" )\r
- protected String getPrincipal()\r
- {\r
- if ( principal != null )\r
- {\r
- return principal;\r
- }\r
- return ArchivaXworkUser.getActivePrincipal( ActionContext.getContext().getSession() );\r
- }\r
-\r
- void setPrincipal( String principal )\r
- {\r
- this.principal = principal;\r
- }\r
-\r
- public void setAuditListeners( List<AuditListener> auditListeners )\r
- {\r
- this.auditListeners = auditListeners;\r
- }\r
-\r
- public void setRepositorySessionFactory( RepositorySessionFactory repositorySessionFactory )\r
- {\r
- this.repositorySessionFactory = repositorySessionFactory;\r
- }\r
-}\r
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.struts2.ServletActionContext;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Controller;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
/**
* Search all indexed fields by the given criteria.
*
- * @plexus.component role="com.opensymphony.xwork2.Action" role-hint="searchAction" instantiation-strategy="per-lookup"
+ * plexus.component role="com.opensymphony.xwork2.Action" role-hint="searchAction" instantiation-strategy="per-lookup"
*/
+@Controller( "searchAction" )
+@Scope( "prototype" )
public class SearchAction
extends AbstractRepositoryBasedAction
implements Preparable
* Query string.
*/
+ // FIXME olamy WTF here??
private ArchivaConfiguration archivaConfiguration;
private String q;
import org.apache.maven.archiva.repository.RepositoryContentFactory;
import org.apache.maven.archiva.repository.RepositoryException;
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Controller;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
*
* TODO change name to ShowVersionedAction to conform to terminology.
*
- * @plexus.component role="com.opensymphony.xwork2.Action" role-hint="showArtifactAction"
+ * plexus.component role="com.opensymphony.xwork2.Action" role-hint="showArtifactAction"
* instantiation-strategy="per-lookup"
*/
@SuppressWarnings( "serial" )
+@Controller( "showArtifactAction" )
+@Scope( "prototype" )
public class ShowArtifactAction
extends AbstractRepositoryBasedAction
implements Validateable
/* .\ Not Exposed \._____________________________________________ */
/**
- * @plexus.requirement
+ * plexus.requirement
*/
private RepositoryContentFactory repositoryFactory;
import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
import org.codehaus.plexus.taskqueue.TaskQueueException;
import org.codehaus.plexus.util.IOUtil;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Controller;
+import javax.inject.Inject;
+import javax.inject.Named;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
/**
* 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.
- *
- * @plexus.component role="com.opensymphony.xwork2.Action" role-hint="uploadAction" instantiation-strategy="per-lookup"
+ * <p/>
+ * plexus.component role="com.opensymphony.xwork2.Action" role-hint="uploadAction" instantiation-strategy="per-lookup"
*/
@SuppressWarnings( "serial" )
+@Controller( "uploadAction" )
+@Scope( "prototype" )
public class UploadAction
- extends PlexusActionSupport
+ extends AbstractActionSupport
implements Validateable, Preparable, Auditable
{
/**
private List<String> managedRepoIdList;
/**
- * @plexus.requirement
+ * plexus.requirement
*/
+ @Inject
private UserRepositories userRepositories;
/**
- * @plexus.requirement role-hint="default"
+ * plexus.requirement role-hint="default"
*/
+ @Inject
private ArchivaConfiguration configuration;
/**
- * @plexus.requirement
+ * plexus.requirement
*/
+ @Inject
private RepositoryContentFactory repositoryFactory;
/**
- * @plexus.requirement role="org.apache.archiva.scheduler.ArchivaTaskScheduler" role-hint="repository"
+ * lexus.requirement role="org.apache.archiva.scheduler.ArchivaTaskScheduler" role-hint="repository"
*/
+ @Inject
+ @Named( value = "archivaTaskScheduler#repository" )
private ArchivaTaskScheduler scheduler;
-
- private ChecksumAlgorithm[] algorithms = new ChecksumAlgorithm[]{ChecksumAlgorithm.SHA1, ChecksumAlgorithm.MD5};
+
+ private ChecksumAlgorithm[] algorithms = new ChecksumAlgorithm[]{ ChecksumAlgorithm.SHA1, ChecksumAlgorithm.MD5 };
public void setArtifact( File file )
{
if ( !config.getRepositoryScanning().getKnownContentConsumers().contains( "metadata-updater" ) )
{
updateProjectMetadata( targetPath.getAbsolutePath(), lastUpdatedTimestamp, timestamp, newBuildNumber,
- fixChecksums );
-
- if ( VersionUtil.isSnapshot( version ) )
- {
- updateVersionMetadata( versionMetadata, versionMetadataFile, lastUpdatedTimestamp, timestamp,
- newBuildNumber, fixChecksums );
- }
+ fixChecksums );
+
+ if ( VersionUtil.isSnapshot( version ) )
+ {
+ updateVersionMetadata( versionMetadata, versionMetadataFile, lastUpdatedTimestamp, timestamp,
+ newBuildNumber, fixChecksums );
+ }
}
- String msg = "Artifact \'" + groupId + ":" + artifactId + ":" + version +
- "\' was successfully deployed to repository \'" + repositoryId + "\'";
+ String msg = "Artifact \'" + groupId + ":" + artifactId + ":" + version
+ + "\' was successfully deployed to repository \'" + repositoryId + "\'";
addActionMessage( msg );
}
return metadata;
}
-
-
+
+
/**
* Update version level metadata for snapshot artifacts. If it does not exist, create the metadata and fix checksums
* if necessary.
/**
* Update artifact level metadata. If it does not exist, create the metadata and fix checksums if necessary.
*/
- private void updateProjectMetadata( String targetPath, Date lastUpdatedTimestamp, String timestamp,
- int buildNumber, boolean fixChecksums )
+ private void updateProjectMetadata( String targetPath, Date lastUpdatedTimestamp, String timestamp, int buildNumber,
+ boolean fixChecksums )
throws RepositoryMetadataException
{
List<String> availableVersions = new ArrayList<String>();
String latestVersion = version;
File projectDir = new File( targetPath ).getParentFile();
- File projectMetadataFile = new File( projectDir, MetadataTools.MAVEN_METADATA );
+ File projectMetadataFile = new File( projectDir, MetadataTools.MAVEN_METADATA );
ArchivaRepositoryMetadata projectMetadata = getMetadata( projectMetadataFile );
{
projectMetadata.setGroupId( groupId );
}
-
+
if ( projectMetadata.getArtifactId() == null )
{
projectMetadata.setArtifactId( artifactId );
}
catch ( TaskQueueException e )
{
- log.error(
- "Unable to queue repository task to execute consumers on resource file ['" + localFile.getName() +
- "']." );
+ log.error( "Unable to queue repository task to execute consumers on resource file ['" + localFile.getName()
+ + "']." );
}
}
import org.apache.archiva.scheduler.repository.RepositoryTask;
import org.apache.commons.lang.StringUtils;
import org.apache.maven.archiva.security.ArchivaRoleConstants;
-import org.apache.maven.archiva.web.action.PlexusActionSupport;
+import org.apache.maven.archiva.web.action.AbstractActionSupport;
import org.codehaus.plexus.redback.rbac.Resource;
import org.codehaus.plexus.taskqueue.TaskQueueException;
import org.codehaus.redback.integration.interceptor.SecureAction;
import org.codehaus.redback.integration.interceptor.SecureActionBundle;
import org.codehaus.redback.integration.interceptor.SecureActionException;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Controller;
+
+import javax.inject.Inject;
+import javax.inject.Named;
/**
* Configures the application.
- *
- * @plexus.component role="com.opensymphony.xwork2.Action" role-hint="schedulerAction" instantiation-strategy="per-lookup"
+ * <p/>
+ * plexus.component role="com.opensymphony.xwork2.Action" role-hint="schedulerAction" instantiation-strategy="per-lookup"
*/
+@Controller( "schedulerAction" )
+@Scope( "prototype" )
public class SchedulerAction
- extends PlexusActionSupport
+ extends AbstractActionSupport
implements SecureAction
{
/**
- * @plexus.requirement role="org.apache.archiva.scheduler.ArchivaTaskScheduler" role-hint="repository"
+ * plexus.requirement role="org.apache.archiva.scheduler.ArchivaTaskScheduler" role-hint="repository"
*/
+ @Inject
+ @Named( value = "archivaTaskScheduler#repository" )
private RepositoryArchivaTaskScheduler repositoryTaskScheduler;
private String repoid;
-
+
private boolean scanAll;
-
+
public String scanRepository()
{
if ( StringUtils.isBlank( repoid ) )
}
catch ( TaskQueueException e )
{
- addActionError( "Unable to queue your request to have repository [" + repoid + "] be indexed: "
- + e.getMessage() );
+ addActionError(
+ "Unable to queue your request to have repository [" + repoid + "] be indexed: " + e.getMessage() );
}
}
{
this.repoid = repoid;
}
-
+
public boolean getScanAll()
{
return scanAll;
import org.apache.archiva.repository.scanner.RepositoryScanner;
import org.apache.maven.archiva.security.ArchivaRoleConstants;
-import org.apache.maven.archiva.web.action.PlexusActionSupport;
+import org.apache.maven.archiva.web.action.AbstractActionSupport;
import org.codehaus.plexus.cache.Cache;
import org.codehaus.plexus.redback.rbac.Resource;
import org.codehaus.plexus.taskqueue.TaskQueue;
import org.codehaus.redback.integration.interceptor.SecureAction;
import org.codehaus.redback.integration.interceptor.SecureActionBundle;
import org.codehaus.redback.integration.interceptor.SecureActionException;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Controller;
+import javax.annotation.PostConstruct;
+import javax.inject.Inject;
import java.util.Map;
/**
* Shows system status information for the administrator.
*
* @version $Id$
- * @plexus.component role="com.opensymphony.xwork2.Action" role-hint="systemStatus" instantiation-strategy="per-lookup"
+ * plexus.component role="com.opensymphony.xwork2.Action" role-hint="systemStatus" instantiation-strategy="per-lookup"
*/
+@Controller( "systemStatus" )
+@Scope( "prototype" )
public class SystemStatusAction
- extends PlexusActionSupport
+ extends AbstractActionSupport
implements SecureAction
{
/**
- * @plexus.requirement role="org.codehaus.plexus.taskqueue.TaskQueue"
+ * plexus.requirement role="org.codehaus.plexus.taskqueue.TaskQueue"
*/
- private Map<String,TaskQueue> queues;
+ private Map<String, TaskQueue> queues;
/**
- * @plexus.requirement role="org.codehaus.plexus.cache.Cache"
+ * plexus.requirement role="org.codehaus.plexus.cache.Cache"
*/
- private Map<String,Cache> caches;
+ private Map<String, Cache> caches;
/**
- * @plexus.requirement
+ * plexus.requirement
*/
+ @Inject
private RepositoryScanner scanner;
private String memoryStatus;
+ @PostConstruct
+ public void initialize()
+ {
+ super.initialize();
+ queues = getBeansOfType( TaskQueue.class );
+ caches = getBeansOfType( Cache.class );
+ }
+
public SecureActionBundle getSecureActionBundle()
throws SecureActionException
{
long total = runtime.totalMemory();
long used = total - runtime.freeMemory();
long max = runtime.maxMemory();
- memoryStatus = formatMemory(used) + "/" + formatMemory(total) + " (Max: " + formatMemory(max) + ")";
-
+ memoryStatus = formatMemory( used ) + "/" + formatMemory( total ) + " (Max: " + formatMemory( max ) + ")";
+
return SUCCESS;
}
private static String formatMemory( long l )
{
- return l / ( 1024 * 1024 ) + "M";
+ return l / ( 1024 * 1024 ) + "M";
}
public String getMemoryStatus()
* under the License.
*/
+import com.opensymphony.xwork2.Preparable;
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.configuration.Configuration;
import org.apache.maven.archiva.configuration.OrganisationInformation;
+import org.apache.maven.archiva.web.action.AbstractActionSupport;
-import com.opensymphony.xwork2.Preparable;
-import org.apache.maven.archiva.web.action.PlexusActionSupport;
+import javax.inject.Inject;
/**
- * AbstractAppearanceAction
+ * AbstractAppearanceAction
*
* @version $Id$
*/
public abstract class AbstractAppearanceAction
- extends PlexusActionSupport
+ extends AbstractActionSupport
implements Preparable
{
/**
* Archiva Application Configuration
- * @plexus.requirement
+ * plexus.requirement
*/
+ @Inject
protected ArchivaConfiguration configuration;
-
+
private String organisationLogo;
private String organisationUrl;
private String organisationName;
- public void setConfiguration(ArchivaConfiguration configuration)
+ public void setConfiguration( ArchivaConfiguration configuration )
{
this.configuration = configuration;
}
-
- public String getOrganisationLogo()
+
+ public String getOrganisationLogo()
{
return organisationLogo;
}
- public String getOrganisationName()
+ public String getOrganisationName()
{
return organisationName;
}
- public String getOrganisationUrl()
+ public String getOrganisationUrl()
{
return organisationUrl;
}
- public void setOrganisationLogo(String organisationLogo)
+ public void setOrganisationLogo( String organisationLogo )
{
this.organisationLogo = organisationLogo;
}
- public void setOrganisationName(String organisationName)
+ public void setOrganisationName( String organisationName )
{
this.organisationName = organisationName;
}
- public void setOrganisationUrl(String organisationUrl)
+ public void setOrganisationUrl( String organisationUrl )
{
this.organisationUrl = organisationUrl;
}
public void prepare()
throws Exception
- {
+ {
Configuration config = configuration.getConfiguration();
- if (config != null)
+ if ( config != null )
{
OrganisationInformation orgInfo = config.getOrganisationInfo();
- if (orgInfo != null)
+ if ( orgInfo != null )
{
- setOrganisationLogo(orgInfo.getLogoLocation());
- setOrganisationName(orgInfo.getName());
- setOrganisationUrl(orgInfo.getUrl());
+ setOrganisationLogo( orgInfo.getLogoLocation() );
+ setOrganisationName( orgInfo.getName() );
+ setOrganisationUrl( orgInfo.getUrl() );
}
}
}
import org.codehaus.redback.integration.interceptor.SecureAction;
import org.codehaus.redback.integration.interceptor.SecureActionBundle;
import org.codehaus.redback.integration.interceptor.SecureActionException;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Controller;
/**
* @version $Id: ConfigurationAction.java 480950 2006-11-30 14:58:35Z evenisse $
- *
- * @plexus.component role="com.opensymphony.xwork2.Action"
- * role-hint="editOrganisationInfo"
- * instantiation-strategy="per-lookup"
+ * plexus.component role="com.opensymphony.xwork2.Action"
+ * role-hint="editOrganisationInfo"
+ * instantiation-strategy="per-lookup"
*/
+@Controller( "editOrganisationInfo" )
+@Scope( "prototype" )
public class EditOrganisationInfoAction
extends AbstractAppearanceAction
implements SecureAction, Validateable
throws RegistryException, IndeterminateConfigurationException
{
Configuration config = configuration.getConfiguration();
- if (config != null)
+ if ( config != null )
{
OrganisationInformation orgInfo = config.getOrganisationInfo();
- if (orgInfo == null)
+ if ( orgInfo == null )
{
- config.setOrganisationInfo(orgInfo);
+ config.setOrganisationInfo( orgInfo );
}
-
- orgInfo.setLogoLocation(getOrganisationLogo());
- orgInfo.setName(getOrganisationName());
- orgInfo.setUrl(getOrganisationUrl());
-
- configuration.save(config);
+
+ orgInfo.setLogoLocation( getOrganisationLogo() );
+ orgInfo.setName( getOrganisationName() );
+ orgInfo.setUrl( getOrganisationUrl() );
+
+ configuration.save( config );
}
return SUCCESS;
}
-
+
public SecureActionBundle getSecureActionBundle()
throws SecureActionException
{
bundle.addRequiredAuthorization( ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION, Resource.GLOBAL );
return bundle;
}
-
+
public void validate()
{
// trim all unecessary trailing/leading white-spaces; always put this statement before the closing braces(after all validation).
trimAllRequestParameterValues();
}
-
+
private void trimAllRequestParameterValues()
{
- if(StringUtils.isNotEmpty(super.getOrganisationName()))
+ if ( StringUtils.isNotEmpty( super.getOrganisationName() ) )
{
- super.setOrganisationName(super.getOrganisationName().trim());
+ super.setOrganisationName( super.getOrganisationName().trim() );
}
- if(StringUtils.isNotEmpty(super.getOrganisationUrl()))
+ if ( StringUtils.isNotEmpty( super.getOrganisationUrl() ) )
{
- super.setOrganisationUrl(super.getOrganisationUrl().trim());
+ super.setOrganisationUrl( super.getOrganisationUrl().trim() );
}
- if(StringUtils.isNotEmpty(super.getOrganisationLogo()))
+ if ( StringUtils.isNotEmpty( super.getOrganisationLogo() ) )
{
- super.setOrganisationLogo(super.getOrganisationLogo().trim());
+ super.setOrganisationLogo( super.getOrganisationLogo().trim() );
}
}
}
* under the License.
*/
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Controller;
+
/**
* Stores the organisation information for displaying on the page.
- *
- * @plexus.component role="com.opensymphony.xwork2.Action" role-hint="organisationInfo" instantiation-strategy="per-lookup"
+ * <p/>
+ * plexus.component role="com.opensymphony.xwork2.Action" role-hint="organisationInfo" instantiation-strategy="per-lookup"
*/
+@Controller( "organisationInfo" )
+@Scope( "prototype" )
public class OrganisationInfoAction
extends AbstractAppearanceAction
{
+ // no op
}
import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration;
import org.apache.maven.archiva.configuration.functors.ProxyConnectorSelectionPredicate;
import org.apache.maven.archiva.security.ArchivaRoleConstants;
-import org.apache.maven.archiva.web.action.PlexusActionSupport;
+import org.apache.maven.archiva.web.action.AbstractActionSupport;
import org.codehaus.plexus.redback.rbac.Resource;
import org.codehaus.plexus.registry.RegistryException;
import org.codehaus.redback.integration.interceptor.SecureActionBundle;
import org.codehaus.redback.integration.interceptor.SecureActionException;
+import javax.inject.Inject;
+
/**
* AbstractProxyConnectorAction
*
* @version $Id$
*/
public abstract class AbstractProxyConnectorAction
- extends PlexusActionSupport
+ extends AbstractActionSupport
implements SecureAction
{
public static final String DIRECT_CONNECTION = "(direct connection)";
/**
- * @plexus.requirement
+ * plexus.requirement
*/
+ @Inject
protected ArchivaConfiguration archivaConfiguration;
public SecureActionBundle getSecureActionBundle()
import java.util.List;
import java.util.Map;
+import com.google.common.collect.Lists;
+import org.apache.archiva.audit.AuditListener;
import org.apache.commons.lang.StringUtils;
import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration;
import org.apache.maven.archiva.policies.DownloadErrorPolicy;
import com.opensymphony.xwork2.Preparable;
+import javax.annotation.PostConstruct;
+
/**
* AbstractProxyConnectorFormAction - generic fields and methods for either add or edit actions related with the
* Proxy Connector.
{
/**
- * @plexus.requirement role="org.apache.maven.archiva.policies.PreDownloadPolicy"
+ * plexus.requirement role="org.apache.maven.archiva.policies.PreDownloadPolicy"
*/
private Map<String, PreDownloadPolicy> preDownloadPolicyMap;
/**
- * @plexus.requirement role="org.apache.maven.archiva.policies.PostDownloadPolicy"
+ * plexus.requirement role="org.apache.maven.archiva.policies.PostDownloadPolicy"
*/
private Map<String, PostDownloadPolicy> postDownloadPolicyMap;
/**
- * @plexus.requirement role="org.apache.maven.archiva.policies.DownloadErrorPolicy"
+ * plexus.requirement role="org.apache.maven.archiva.policies.DownloadErrorPolicy"
*/
private Map<String, DownloadErrorPolicy> downloadErrorPolicyMap;
*/
protected ProxyConnectorConfiguration connector;
+
+ @PostConstruct
+ public void initialize()
+ {
+ super.initialize();
+ this.preDownloadPolicyMap = getBeansOfType( PreDownloadPolicy.class );
+ this.postDownloadPolicyMap = getBeansOfType( PostDownloadPolicy.class );
+ this.downloadErrorPolicyMap = getBeansOfType( DownloadErrorPolicy.class );
+ }
+
protected List<String> escapePatterns( List<String> patterns )
{
List<String> escapedPatterns = new ArrayList<String>();
import org.apache.commons.lang.StringUtils;
import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Controller;
/**
- * AddProxyConnectorAction
+ * AddProxyConnectorAction
*
* @version $Id$
- *
- * @plexus.component role="com.opensymphony.xwork2.Action" role-hint="addProxyConnectorAction" instantiation-strategy="per-lookup"
+ * <p/>
+ * plexus.component role="com.opensymphony.xwork2.Action" role-hint="addProxyConnectorAction" instantiation-strategy="per-lookup"
*/
+@Controller( "addProxyConnectorAction" )
+@Scope( "prototype" )
public class AddProxyConnectorAction
extends AbstractProxyConnectorFormAction
{
super.prepare();
connector = new ProxyConnectorConfiguration();
}
-
+
@Override
public String input()
{
- if( connector != null )
+ if ( connector != null )
{
- // MRM-1135
+ // MRM-1135
connector.setBlackListPatterns( escapePatterns( connector.getBlackListPatterns() ) );
connector.setWhiteListPatterns( escapePatterns( connector.getWhiteListPatterns() ) );
}
-
+
return INPUT;
}
ProxyConnectorConfiguration otherConnector = findProxyConnector( sourceId, targetId );
if ( otherConnector != null )
{
- addActionError( "Unable to add proxy connector, as one already exists with source repository id ["
- + sourceId + "] and target repository id [" + targetId + "]." );
+ addActionError(
+ "Unable to add proxy connector, as one already exists with source repository id [" + sourceId
+ + "] and target repository id [" + targetId + "]." );
}
-
+
validateConnector();
if ( hasActionErrors() )
{
return INPUT;
}
-
- if( StringUtils.equals( DIRECT_CONNECTION, connector.getProxyId() ) )
+
+ if ( StringUtils.equals( DIRECT_CONNECTION, connector.getProxyId() ) )
{
connector.setProxyId( null );
}
// MRM-1135
connector.setBlackListPatterns( unescapePatterns( connector.getBlackListPatterns() ) );
connector.setWhiteListPatterns( unescapePatterns( connector.getWhiteListPatterns() ) );
-
+
addProxyConnector( connector );
return saveConfiguration();
}
*/
import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Controller;
/**
* DeleteProxyConnectorAction
*
* @version $Id$
*
- * @plexus.component role="com.opensymphony.xwork2.Action" role-hint="deleteProxyConnectorAction" instantiation-strategy="per-lookup"
+ * plexus.component role="com.opensymphony.xwork2.Action" role-hint="deleteProxyConnectorAction" instantiation-strategy="per-lookup"
*/
+@Controller( "deleteProxyConnectorAction" )
+@Scope( "prototype" )
public class DeleteProxyConnectorAction
extends AbstractProxyConnectorAction
{
package org.apache.maven.archiva.web.action.admin.connectors.proxy;
import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Controller;
/*
* Licensed to the Apache Software Foundation (ASF) under one
*/
/**
- * DisableProxyConnectorAction
- *
- * @plexus.component role="com.opensymphony.xwork2.Action" role-hint="disableProxyConnectorAction" instantiation-strategy="per-lookup"
+ * DisableProxyConnectorAction
+ *
+ * plexus.component role="com.opensymphony.xwork2.Action" role-hint="disableProxyConnectorAction" instantiation-strategy="per-lookup"
*/
-public class DisableProxyConnectorAction extends AbstractProxyConnectorAction
+@Controller( "disableProxyConnectorAction" )
+@Scope( "prototype" )
+public class DisableProxyConnectorAction
+ extends AbstractProxyConnectorAction
{
private String source;
-
+
private String target;
-
+
private ProxyConnectorConfiguration proxyConfig;
-
+
public String confirmDisable()
{
this.proxyConfig = findProxyConnector( source, target );
// Not set? Then there is nothing to delete.
if ( this.proxyConfig == null )
{
- addActionError( "Unable to disable proxy configuration, configuration with source [" + source
- + "], and target [" + target + "] does not exist." );
+ addActionError(
+ "Unable to disable proxy configuration, configuration with source [" + source + "], and target ["
+ + target + "] does not exist." );
return ERROR;
}
return INPUT;
}
-
+
public String disable()
- {
+ {
this.proxyConfig = findProxyConnector( source, target );
// Not set? Then there is nothing to delete.
if ( this.proxyConfig == null )
{
- addActionError( "Unable to disable proxy configuration, configuration with source [" + source
- + "], and target [" + target + "] does not exist." );
+ addActionError(
+ "Unable to disable proxy configuration, configuration with source [" + source + "], and target ["
+ + target + "] does not exist." );
return ERROR;
}
{
return ERROR;
}
-
- proxyConfig.setDisabled(true);
-
+
+ proxyConfig.setDisabled( true );
+
addActionMessage( "Successfully disabled proxy connector [" + source + " , " + target + " ]" );
setSource( null );
setTarget( null );
-
+
return saveConfiguration();
}
return source;
}
- public void setSource(String source)
+ public void setSource( String source )
{
this.source = source;
}
- public String getTarget()
+ public String getTarget()
{
return target;
}
- public void setTarget(String target)
+ public void setTarget( String target )
{
this.target = target;
}
*/
import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration;
-
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Controller;
/**
* EditProxyConnectorAction
*
* @version $Id$
*
- * @plexus.component role="com.opensymphony.xwork2.Action" role-hint="editProxyConnectorAction" instantiation-strategy="per-lookup"
+ * plexus.component role="com.opensymphony.xwork2.Action" role-hint="editProxyConnectorAction" instantiation-strategy="per-lookup"
*/
+@Controller( "editProxyConnectorAction" )
+@Scope( "prototype")
public class EditProxyConnectorAction
extends AbstractProxyConnectorFormAction
{
package org.apache.maven.archiva.web.action.admin.connectors.proxy;
import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Controller;
/*
* Licensed to the Apache Software Foundation (ASF) under one
*/
/**
- * EnableProxyConnectorAction
- *
- * @plexus.component role="com.opensymphony.xwork2.Action" role-hint="enableProxyConnectorAction" instantiation-strategy="per-lookup"
+ * EnableProxyConnectorAction
+ * <p/>
+ * plexus.component role="com.opensymphony.xwork2.Action" role-hint="enableProxyConnectorAction" instantiation-strategy="per-lookup"
*/
-public class EnableProxyConnectorAction extends AbstractProxyConnectorAction
+@Controller( "enableProxyConnectorAction" )
+@Scope( "prototype" )
+public class EnableProxyConnectorAction
+ extends AbstractProxyConnectorAction
{
private String source;
-
+
private String target;
-
+
private ProxyConnectorConfiguration proxyConfig;
-
+
public String confirmEnable()
{
this.proxyConfig = findProxyConnector( source, target );
// Not set? Then there is nothing to delete.
if ( this.proxyConfig == null )
{
- addActionError( "Unable to enable proxy configuration, configuration with source [" + source
- + "], and target [" + target + "] does not exist." );
+ addActionError(
+ "Unable to enable proxy configuration, configuration with source [" + source + "], and target ["
+ + target + "] does not exist." );
return ERROR;
}
return INPUT;
}
-
+
public String enable()
{
this.proxyConfig = findProxyConnector( source, target );
// Not set? Then there is nothing to delete.
if ( this.proxyConfig == null )
{
- addActionError( "Unable to enabled proxy configuration, configuration with source [" + source
- + "], and target [" + target + "] does not exist." );
+ addActionError(
+ "Unable to enabled proxy configuration, configuration with source [" + source + "], and target ["
+ + target + "] does not exist." );
return ERROR;
}
{
return ERROR;
}
-
- proxyConfig.setDisabled(false);
-
+
+ proxyConfig.setDisabled( false );
+
addActionMessage( "Successfully enabled proxy connector [" + source + " , " + target + " ]" );
setSource( null );
setTarget( null );
-
+
return saveConfiguration();
}
return source;
}
- public void setSource(String source)
+ public void setSource( String source )
{
this.source = source;
}
- public String getTarget()
+ public String getTarget()
{
return target;
}
- public void setTarget(String target)
+ public void setTarget( String target )
{
this.target = target;
}
import org.apache.maven.archiva.configuration.AbstractRepositoryConfiguration;
import org.apache.maven.archiva.configuration.Configuration;
import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Controller;
import java.util.HashMap;
import java.util.List;
*
* @version $Id$
*
- * @plexus.component role="com.opensymphony.xwork2.Action" role-hint="proxyConnectorsAction" instantiation-strategy="per-lookup"
+ * plexus.component role="com.opensymphony.xwork2.Action" role-hint="proxyConnectorsAction" instantiation-strategy="per-lookup"
*/
+@Controller( "proxyConnectorsAction" )
+@Scope( "prototype" )
public class ProxyConnectorsAction
extends AbstractProxyConnectorAction
implements Preparable
import org.apache.commons.lang.StringUtils;
import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Controller;
import java.util.List;
/**
- * SortProxyConnectorsAction -
+ * SortProxyConnectorsAction -
*
* @version $Id$
- *
- * @plexus.component role="com.opensymphony.xwork2.Action" role-hint="sortProxyConnectorsAction" instantiation-strategy="per-lookup"
+ * <p/>
+ * plexus.component role="com.opensymphony.xwork2.Action" role-hint="sortProxyConnectorsAction" instantiation-strategy="per-lookup"
*/
+@Controller( "sortProxyConnectorsAction" )
+@Scope( "prototype" )
public class SortProxyConnectorsAction
extends AbstractProxyConnectorAction
{
import com.opensymphony.xwork2.Preparable;
import com.opensymphony.xwork2.Validateable;
import org.apache.commons.lang.StringUtils;
-import org.apache.maven.archiva.web.action.PlexusActionSupport;
+import org.apache.maven.archiva.web.action.AbstractActionSupport;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Controller;
+
+import javax.inject.Inject;
+import javax.inject.Named;
/**
* Add a LegacyArtifactPath to archiva configuration
*
* @since 1.1
- * @plexus.component role="com.opensymphony.xwork2.Action" role-hint="addLegacyArtifactPathAction" instantiation-strategy="per-lookup"
+ * plexus.component role="com.opensymphony.xwork2.Action" role-hint="addLegacyArtifactPathAction" instantiation-strategy="per-lookup"
*/
+@Controller( "addLegacyArtifactPathAction" )
+@Scope( "prototype" )
public class AddLegacyArtifactPathAction
- extends PlexusActionSupport
+ extends AbstractActionSupport
implements Preparable, Validateable
{
/**
- * @plexus.requirement
+ * plexus.requirement
*/
+ @Inject
private ArchivaConfiguration archivaConfiguration;
/**
- * @plexus.requirement role-hint="legacy"
+ * plexus.requirement role-hint="legacy"
*/
+ @Inject
+ @Named(value = "managedRepositoryContent#legacy")
private ManagedRepositoryContent repositoryContent;
* under the License.\r
*/\r
\r
-import java.util.Iterator;\r
-\r
import org.apache.maven.archiva.configuration.ArchivaConfiguration;\r
import org.apache.maven.archiva.configuration.Configuration;\r
import org.apache.maven.archiva.configuration.IndeterminateConfigurationException;\r
import org.apache.maven.archiva.configuration.LegacyArtifactPath;\r
-import org.apache.maven.archiva.web.action.PlexusActionSupport;\r
+import org.apache.maven.archiva.web.action.AbstractActionSupport;\r
import org.codehaus.plexus.registry.RegistryException;\r
+import org.springframework.context.annotation.Scope;\r
+import org.springframework.stereotype.Controller;\r
+\r
+import javax.inject.Inject;\r
+import java.util.Iterator;\r
\r
/**\r
* Delete a LegacyArtifactPath to archiva configuration\r
*\r
- *\r
* @since 1.1\r
- * @plexus.component role="com.opensymphony.xwork2.Action" role-hint="deleteLegacyArtifactPathAction" instantiation-strategy="per-lookup"\r
+ * plexus.component role="com.opensymphony.xwork2.Action" role-hint="deleteLegacyArtifactPathAction" instantiation-strategy="per-lookup"\r
*/\r
+@Controller( "deleteLegacyArtifactPathAction" )\r
+@Scope( "prototype" )\r
public class DeleteLegacyArtifactPathAction\r
- extends PlexusActionSupport\r
+ extends AbstractActionSupport\r
{\r
/**\r
- * @plexus.requirement\r
+ * plexus.requirement\r
*/\r
+ @Inject\r
private ArchivaConfiguration archivaConfiguration;\r
\r
private String path;\r
{\r
log.info( "remove [" + path + "] from legacy artifact path resolution" );\r
Configuration configuration = archivaConfiguration.getConfiguration();\r
- for ( Iterator<LegacyArtifactPath> iterator = configuration.getLegacyArtifactPaths().iterator(); iterator.hasNext(); )\r
+ for ( Iterator<LegacyArtifactPath> iterator = configuration.getLegacyArtifactPaths().iterator();\r
+ iterator.hasNext(); )\r
{\r
LegacyArtifactPath legacyArtifactPath = (LegacyArtifactPath) iterator.next();\r
- if (legacyArtifactPath.match( path ))\r
+ if ( legacyArtifactPath.match( path ) )\r
{\r
iterator.remove();\r
}\r
* under the License.\r
*/\r
\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-import javax.servlet.http.HttpServletRequest;\r
-\r
+import com.opensymphony.xwork2.Preparable;\r
import org.apache.maven.archiva.configuration.ArchivaConfiguration;\r
import org.apache.maven.archiva.configuration.Configuration;\r
import org.apache.maven.archiva.configuration.LegacyArtifactPath;\r
import org.apache.maven.archiva.security.ArchivaRoleConstants;\r
+import org.apache.maven.archiva.web.action.AbstractActionSupport;\r
import org.apache.maven.archiva.web.util.ContextUtils;\r
-import org.codehaus.plexus.redback.rbac.Resource;\r
-\r
import org.apache.struts2.interceptor.ServletRequestAware;\r
-import com.opensymphony.xwork2.Preparable;\r
-import org.apache.maven.archiva.web.action.PlexusActionSupport;\r
+import org.codehaus.plexus.redback.rbac.Resource;\r
import org.codehaus.redback.integration.interceptor.SecureAction;\r
import org.codehaus.redback.integration.interceptor.SecureActionBundle;\r
import org.codehaus.redback.integration.interceptor.SecureActionException;\r
+import org.springframework.context.annotation.Scope;\r
+import org.springframework.stereotype.Controller;\r
+\r
+import javax.inject.Inject;\r
+import javax.servlet.http.HttpServletRequest;\r
+import java.util.ArrayList;\r
+import java.util.List;\r
\r
/**\r
* Shows the LegacyArtifactPath Tab for the administrator.\r
*\r
* @since 1.1\r
- * @plexus.component role="com.opensymphony.xwork2.Action" role-hint="legacyArtifactPathAction" instantiation-strategy="per-lookup"\r
+ * plexus.component role="com.opensymphony.xwork2.Action" role-hint="legacyArtifactPathAction" instantiation-strategy="per-lookup"\r
*/\r
+@Controller( "legacyArtifactPathAction" )\r
+@Scope( "prototype" )\r
public class LegacyArtifactPathAction\r
- extends PlexusActionSupport\r
+ extends AbstractActionSupport\r
implements SecureAction, ServletRequestAware, Preparable\r
{\r
/**\r
- * @plexus.requirement\r
+ * plexus.requirement\r
*/\r
+ @Inject\r
private ArchivaConfiguration archivaConfiguration;\r
\r
private List<LegacyArtifactPath> legacyArtifactPaths;\r
SecureActionBundle bundle = new SecureActionBundle();\r
\r
bundle.setRequiresAuthentication( true );\r
- bundle.addRequiredAuthorization( ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION,\r
- Resource.GLOBAL );\r
+ bundle.addRequiredAuthorization( ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION, Resource.GLOBAL );\r
\r
return bundle;\r
}\r
import org.apache.maven.archiva.configuration.NetworkProxyConfiguration;
import org.apache.maven.archiva.configuration.functors.NetworkProxySelectionPredicate;
import org.apache.maven.archiva.security.ArchivaRoleConstants;
-import org.apache.maven.archiva.web.action.PlexusActionSupport;
+import org.apache.maven.archiva.web.action.AbstractActionSupport;
import org.codehaus.plexus.redback.rbac.Resource;
import org.codehaus.plexus.registry.RegistryException;
import org.codehaus.redback.integration.interceptor.SecureAction;
import org.codehaus.redback.integration.interceptor.SecureActionBundle;
import org.codehaus.redback.integration.interceptor.SecureActionException;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Controller;
+
+import javax.inject.Inject;
/**
* ConfigureNetworkProxyAction
*
* @version $Id$
- * @plexus.component role="com.opensymphony.xwork2.Action" role-hint="configureNetworkProxyAction" instantiation-strategy="per-lookup"
+ * plexus.component role="com.opensymphony.xwork2.Action" role-hint="configureNetworkProxyAction" instantiation-strategy="per-lookup"
*/
+@Controller( "configureNetworkProxyAction" )
+@Scope( "prototype" )
public class ConfigureNetworkProxyAction
- extends PlexusActionSupport
+ extends AbstractActionSupport
implements SecureAction, Preparable, Validateable
{
/**
- * @plexus.requirement
+ * plexus.requirement
*/
+ @Inject
private ArchivaConfiguration archivaConfiguration;
private String mode;
}
NetworkProxySelectionPredicate networkProxySelection = new NetworkProxySelectionPredicate( id );
- NetworkProxyConfiguration proxyConfig = (NetworkProxyConfiguration) CollectionUtils.find( config
- .getNetworkProxies(), networkProxySelection );
+ NetworkProxyConfiguration proxyConfig =
+ (NetworkProxyConfiguration) CollectionUtils.find( config.getNetworkProxies(), networkProxySelection );
if ( proxyConfig == null )
{
addActionError( "Unable to remove network proxy, proxy with id [" + id + "] not found." );
private void trimAllRequestParameterValues()
{
- if(StringUtils.isNotEmpty(proxy.getId()))
+ if ( StringUtils.isNotEmpty( proxy.getId() ) )
{
- proxy.setId(proxy.getId().trim());
+ proxy.setId( proxy.getId().trim() );
}
-
- if(StringUtils.isNotEmpty(proxy.getHost()))
+
+ if ( StringUtils.isNotEmpty( proxy.getHost() ) )
{
- proxy.setHost(proxy.getHost().trim());
+ proxy.setHost( proxy.getHost().trim() );
}
- if(StringUtils.isNotEmpty(proxy.getPassword()))
+ if ( StringUtils.isNotEmpty( proxy.getPassword() ) )
{
- proxy.setPassword(proxy.getPassword().trim());
+ proxy.setPassword( proxy.getPassword().trim() );
}
- if(StringUtils.isNotEmpty(proxy.getProtocol()))
+ if ( StringUtils.isNotEmpty( proxy.getProtocol() ) )
{
- proxy.setProtocol(proxy.getProtocol().trim());
+ proxy.setProtocol( proxy.getProtocol().trim() );
}
- if(StringUtils.isNotEmpty(proxy.getUsername()))
+ if ( StringUtils.isNotEmpty( proxy.getUsername() ) )
{
- proxy.setUsername(proxy.getUsername().trim());
+ proxy.setUsername( proxy.getUsername().trim() );
}
}
}
*/
import com.opensymphony.xwork2.Preparable;
-
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.configuration.NetworkProxyConfiguration;
import org.apache.maven.archiva.security.ArchivaRoleConstants;
-import org.apache.maven.archiva.web.action.PlexusActionSupport;
+import org.apache.maven.archiva.web.action.AbstractActionSupport;
import org.codehaus.plexus.redback.rbac.Resource;
import org.codehaus.redback.integration.interceptor.SecureAction;
import org.codehaus.redback.integration.interceptor.SecureActionBundle;
import org.codehaus.redback.integration.interceptor.SecureActionException;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Controller;
+import javax.inject.Inject;
import java.util.List;
/**
- * NetworkProxiesAction
+ * NetworkProxiesAction
*
* @version $Id$
- *
- * @plexus.component role="com.opensymphony.xwork2.Action" role-hint="networkProxiesAction" instantiation-strategy="per-lookup"
+ * <p/>
+ * plexus.component role="com.opensymphony.xwork2.Action" role-hint="networkProxiesAction" instantiation-strategy="per-lookup"
*/
+@Controller( "networkProxiesAction" )
+@Scope( "prototype" )
public class NetworkProxiesAction
- extends PlexusActionSupport
+ extends AbstractActionSupport
implements Preparable, SecureAction
{
/**
- * @plexus.requirement
+ * plexus.requirement
*/
+ @Inject
private ArchivaConfiguration configuration;
private List<NetworkProxyConfiguration> networkProxies;
import org.codehaus.plexus.redback.role.RoleManagerException;
import org.codehaus.plexus.registry.Registry;
+import javax.inject.Inject;
+import javax.inject.Named;
import java.io.File;
import java.io.IOException;
/**
* Abstract ManagedRepositories Action.
- *
+ * <p/>
* Place for all generic methods used in Managed Repository Administration.
*
* @version $Id$
extends AbstractRepositoriesAdminAction
{
/**
- * @plexus.requirement role-hint="default"
+ * plexus.requirement role-hint="default"
*/
+ @Inject
protected RoleManager roleManager;
/**
* Plexus registry to read the configuration from.
- *
- * @plexus.requirement role-hint="commons-configuration"
+ * <p/>
+ * plexus.requirement role-hint="commons-configuration"
*/
+ @Inject
+ @Named( value = "commons-configuration" )
private Registry registry;
public static final String CONFIRM = "confirm";
-
+
public RoleManager getRoleManager()
{
return roleManager;
}
if ( !file.exists() || !file.isDirectory() )
{
- throw new IOException( "Unable to add repository - no write access, can not create the root directory: " + file );
+ throw new IOException(
+ "Unable to add repository - no write access, can not create the root directory: " + file );
}
configuration.addManagedRepository( repository );
}
- protected void addRepositoryRoles( ManagedRepositoryConfiguration newRepository ) throws RoleManagerException
+ protected void addRepositoryRoles( ManagedRepositoryConfiguration newRepository )
+ throws RoleManagerException
{
String repoId = newRepository.getId();
-
+
// TODO: double check these are configured on start up
// TODO: belongs in the business logic
-
+
if ( !roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, repoId ) )
{
roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, repoId );
throws RoleManagerException
{
String repoId = existingRepository.getId();
-
+
if ( roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, repoId ) )
{
roleManager.removeTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, repoId );
}
-
+
if ( roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, repoId ) )
{
roleManager.removeTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, repoId );
protected String removeExpressions( String directory )
{
- String value = StringUtils.replace( directory, "${appserver.base}", registry.getString( "appserver.base",
- "${appserver.base}" ) );
- value = StringUtils.replace( value, "${appserver.home}", registry.getString( "appserver.home",
- "${appserver.home}" ) );
+ String value = StringUtils.replace( directory, "${appserver.base}",
+ registry.getString( "appserver.base", "${appserver.base}" ) );
+ value = StringUtils.replace( value, "${appserver.home}",
+ registry.getString( "appserver.home", "${appserver.home}" ) );
return value;
}
}
import org.apache.maven.archiva.configuration.InvalidConfigurationException;
import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration;
import org.apache.maven.archiva.security.ArchivaRoleConstants;
-import org.apache.maven.archiva.web.action.PlexusActionSupport;
+import org.apache.maven.archiva.web.action.AbstractActionSupport;
import org.codehaus.plexus.redback.rbac.Resource;
import org.codehaus.plexus.registry.RegistryException;
import org.codehaus.redback.integration.interceptor.SecureAction;
import org.codehaus.redback.integration.interceptor.SecureActionBundle;
import org.codehaus.redback.integration.interceptor.SecureActionException;
+import javax.inject.Inject;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
/**
* Abstract AdminRepositories Action base.
- *
+ * <p/>
* Base class for all repository administrative functions.
* This should be neutral to the type of action (add/edit/delete) and type of repo (managed/remote)
*
* @version $Id$
*/
public abstract class AbstractRepositoriesAdminAction
- extends PlexusActionSupport
+ extends AbstractActionSupport
implements SecureAction, Auditable
{
/**
- * @plexus.requirement
+ * plexus.requirement
*/
+ @Inject
protected ArchivaConfiguration archivaConfiguration;
public ArchivaConfiguration getArchivaConfiguration()
/**
* Save the configuration.
- *
+ *
* @param configuration the configuration to save.
* @return the webwork result code to issue.
- * @throws IOException thrown if unable to save file to disk.
+ * @throws IOException thrown if unable to save file to disk.
* @throws InvalidConfigurationException thrown if configuration is invalid.
- * @throws RegistryException thrown if configuration subsystem has a problem saving the configuration to disk.
+ * @throws RegistryException thrown if configuration subsystem has a problem saving the configuration to disk.
*/
protected String saveConfiguration( Configuration configuration )
{
/**
* Get the list of ProxyConnectors that are present in the configuration.
- *
+ *
* @return a new list of ProxyConnectors present in the configuration.
*/
protected List<ProxyConnectorConfiguration> getProxyConnectors()
{
- return new ArrayList<ProxyConnectorConfiguration>( archivaConfiguration.getConfiguration().getProxyConnectors() );
+ return new ArrayList<ProxyConnectorConfiguration>(
+ archivaConfiguration.getConfiguration().getProxyConnectors() );
}
}
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
import org.codehaus.plexus.redback.role.RoleManagerException;
import org.codehaus.redback.components.scheduler.CronExpressionValidator;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Controller;
import java.io.File;
import java.io.IOException;
/**
- * AddManagedRepositoryAction
+ * AddManagedRepositoryAction
*
* @version $Id$
- *
- * @plexus.component role="com.opensymphony.xwork2.Action" role-hint="addManagedRepositoryAction" instantiation-strategy="per-lookup"
+ * <p/>
+ * plexus.component role="com.opensymphony.xwork2.Action" role-hint="addManagedRepositoryAction" instantiation-strategy="per-lookup"
*/
+@Controller( "addManagedRepositoryAction" )
+@Scope( "prototype" )
public class AddManagedRepositoryAction
extends AbstractManagedRepositoriesAction
implements Preparable, Validateable
{
this.repository = new ManagedRepositoryConfiguration();
this.repository.setReleases( false );
- this.repository.setScanned( false );
+ this.repository.setScanned( false );
this.repository.setBlockRedeployments( false );
}
repository.setLocation( removeExpressions( repository.getLocation() ) );
File location = new File( repository.getLocation() );
- if( location.exists() )
+ if ( location.exists() )
{
return CONFIRM;
}
addFieldError( "repository.id", "Unable to add new repository with id [" + repoId
+ "], that id already exists as a remote repository." );
}
- else if( config.getRepositoryGroupsAsMap().containsKey( repoId ) )
+ else if ( config.getRepositoryGroupsAsMap().containsKey( repoId ) )
{
addFieldError( "repository.id", "Unable to add new repository with id [" + repoId
- + "], that id already exists as a repository group." );
+ + "], that id already exists as a repository group." );
}
else if ( repoId.toLowerCase().contains( "stage" ) )
{
- addFieldError( "repository.id", "Unable to add new repository with id [" + repoId +
- "], rpository id cannot contains word stage" );
+ addFieldError( "repository.id", "Unable to add new repository with id [" + repoId
+ + "], rpository id cannot contains word stage" );
}
if ( !validator.validate( repository.getRefreshCronExpression() ) )
private void trimAllRequestParameterValues()
{
- if(StringUtils.isNotEmpty(repository.getId()))
+ if ( StringUtils.isNotEmpty( repository.getId() ) )
{
- repository.setId(repository.getId().trim());
+ repository.setId( repository.getId().trim() );
}
- if(StringUtils.isNotEmpty(repository.getName()))
+ if ( StringUtils.isNotEmpty( repository.getName() ) )
{
- repository.setName(repository.getName().trim());
+ repository.setName( repository.getName().trim() );
}
- if(StringUtils.isNotEmpty(repository.getLocation()))
+ if ( StringUtils.isNotEmpty( repository.getLocation() ) )
{
- repository.setLocation(repository.getLocation().trim());
+ repository.setLocation( repository.getLocation().trim() );
}
-
- if(StringUtils.isNotEmpty(repository.getIndexDir()))
+
+ if ( StringUtils.isNotEmpty( repository.getIndexDir() ) )
{
- repository.setIndexDir(repository.getIndexDir().trim());
+ repository.setIndexDir( repository.getIndexDir().trim() );
}
}
{
this.stageNeeded = stageNeeded;
}
-
+
public String getAction()
{
return action;
import org.apache.maven.archiva.configuration.Configuration;
import org.apache.maven.archiva.configuration.RemoteRepositoryConfiguration;
import org.codehaus.plexus.redback.role.RoleManagerException;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Controller;
import java.io.IOException;
/**
- * AddRemoteRepositoryAction
+ * AddRemoteRepositoryAction
*
* @version $Id$
- *
- * @plexus.component role="com.opensymphony.xwork2.Action" role-hint="addRemoteRepositoryAction" instantiation-strategy="per-lookup"
+ * <p/>
+ * plexus.component role="com.opensymphony.xwork2.Action" role-hint="addRemoteRepositoryAction" instantiation-strategy="per-lookup"
*/
+@Controller( "addRemoteRepositoryAction" )
+@Scope( "prototype" )
public class AddRemoteRepositoryAction
extends AbstractRemoteRepositoriesAction
implements Preparable, Validateable
/**
* The model for this action.
*/
- private RemoteRepositoryConfiguration repository;
-
+ private RemoteRepositoryConfiguration repository;
+
public void prepare()
{
this.repository = new RemoteRepositoryConfiguration();
public String commit()
{
Configuration configuration = archivaConfiguration.getConfiguration();
-
+
//MRM-752 - url needs trimming
- repository.setUrl(repository.getUrl().trim());
-
+ repository.setUrl( repository.getUrl().trim() );
+
// Save the repository configuration.
String result;
try
return result;
}
-
+
@Override
public void validate()
{
Configuration config = archivaConfiguration.getConfiguration();
-
+
String repoId = repository.getId();
-
+
if ( config.getManagedRepositoriesAsMap().containsKey( repoId ) )
{
addFieldError( "repository.id", "Unable to add new repository with id [" + repoId
addFieldError( "repository.id", "Unable to add new repository with id [" + repoId
+ "], that id already exists as a remote repository." );
}
- else if( config.getRepositoryGroupsAsMap().containsKey( repoId ) )
+ else if ( config.getRepositoryGroupsAsMap().containsKey( repoId ) )
{
addFieldError( "repository.id", "Unable to add new repository with id [" + repoId
- + "], that id already exists as a repository group." );
+ + "], that id already exists as a repository group." );
}
}
-
+
public RemoteRepositoryConfiguration getRepository()
{
return repository;
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration;
import org.codehaus.plexus.redback.role.RoleManagerException;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Controller;
+import javax.inject.Inject;
import java.io.IOException;
import java.util.List;
import java.util.Map;
* @version $Id$
* @plexus.component role="com.opensymphony.xwork2.Action" role-hint="deleteManagedRepositoryAction" instantiation-strategy="per-lookup"
*/
+@Controller( "deleteManagedRepositoryAction" )
+@Scope( "prototype" )
public class DeleteManagedRepositoryAction
extends AbstractManagedRepositoriesAction
implements Preparable
private String repoid;
/**
- * @plexus.requirement
+ * plexus.requirement
*/
+ @Inject
private RepositoryStatisticsManager repositoryStatisticsManager;
public void prepare()
if ( StringUtils.isNotBlank( repoid ) )
{
this.repository = archivaConfiguration.getConfiguration().findManagedRepositoryById( repoid );
- this.stagingRepository = archivaConfiguration.getConfiguration().findManagedRepositoryById(
- repoid + "-stage" );
+ this.stagingRepository =
+ archivaConfiguration.getConfiguration().findManagedRepositoryById( repoid + "-stage" );
}
}
import org.apache.maven.archiva.configuration.Configuration;
import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration;
import org.apache.maven.archiva.configuration.RemoteRepositoryConfiguration;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Controller;
import java.util.List;
/**
- * DeleteRemoteRepositoryAction
+ * DeleteRemoteRepositoryAction
*
* @version $Id$
- *
- * @plexus.component role="com.opensymphony.xwork2.Action" role-hint="deleteRemoteRepositoryAction" instantiation-strategy="per-lookup"
+ * plexus.component role="com.opensymphony.xwork2.Action" role-hint="deleteRemoteRepositoryAction" instantiation-strategy="per-lookup"
*/
+@Controller( "deleteRemoteRepositoryAction" )
+@Scope( "prototype" )
public class DeleteRemoteRepositoryAction
extends AbstractRemoteRepositoriesAction
implements Preparable
removeRepository( repoid, configuration );
triggerAuditEvent( repoid, null, AuditEvent.DELETE_REMOTE_REPO );
result = saveConfiguration( configuration );
-
+
cleanupRepositoryData( existingRepository );
return result;
private void cleanupRepositoryData( RemoteRepositoryConfiguration existingRepository )
{
// [MRM-520] Proxy Connectors are not deleted with the deletion of a Repository.
-
+
List<ProxyConnectorConfiguration> proxyConnectors = getProxyConnectors();
for ( ProxyConnectorConfiguration proxyConnector : proxyConnectors )
{
import org.apache.commons.lang.StringUtils;
import org.apache.maven.archiva.configuration.Configuration;
import org.apache.maven.archiva.configuration.RepositoryGroupConfiguration;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Controller;
/**
* DeleteRepositoryGroupAction
- *
- * @version
- * @plexus.component role="com.opensymphony.xwork2.Action" role-hint="deleteRepositoryGroupAction" instantiation-strategy="per-lookup"
+ *
+ * plexus.component role="com.opensymphony.xwork2.Action" role-hint="deleteRepositoryGroupAction" instantiation-strategy="per-lookup"
*/
-public class DeleteRepositoryGroupAction
+@Controller( "deleteRepositoryGroupAction" )
+@Scope( "prototype" )
+public class DeleteRepositoryGroupAction
extends AbstractRepositoriesAdminAction
implements Preparable
{
private RepositoryGroupConfiguration repositoryGroup;
private String repoGroupId;
-
+
public void prepare()
{
if ( StringUtils.isNotBlank( repoGroupId ) )
this.repositoryGroup = archivaConfiguration.getConfiguration().findRepositoryGroupById( repoGroupId );
}
}
-
+
public String confirmDelete()
{
if ( StringUtils.isBlank( repoGroupId ) )
addActionError( "A repository group with that id does not exist." );
return ERROR;
}
-
+
config.removeRepositoryGroup( group );
triggerAuditEvent( AuditEvent.DELETE_REPO_GROUP + " " + repoGroupId );
return saveConfiguration( config );
}
-
+
public RepositoryGroupConfiguration getRepositoryGroup()
{
return repositoryGroup;
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
import org.codehaus.plexus.redback.role.RoleManagerException;
import org.codehaus.redback.components.scheduler.CronExpressionValidator;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Controller;
+import javax.inject.Inject;
import java.io.File;
import java.io.IOException;
* @version $Id$
* @plexus.component role="com.opensymphony.xwork2.Action" role-hint="editManagedRepositoryAction" instantiation-strategy="per-lookup"
*/
+@Controller( "editManagedRepositoryAction" )
+@Scope( "prototype" )
public class EditManagedRepositoryAction
extends AbstractManagedRepositoriesAction
implements Preparable, Validateable
private boolean stageNeeded;
/**
- * @plexus.requirement
+ * plexus.requirement
*/
+ @Inject
private RepositoryStatisticsManager repositoryStatisticsManager;
public void prepare()
import org.apache.maven.archiva.configuration.Configuration;
import org.apache.maven.archiva.configuration.RemoteRepositoryConfiguration;
import org.codehaus.plexus.redback.role.RoleManagerException;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Controller;
import java.io.IOException;
/**
- * EditRemoteRepositoryAction
+ * EditRemoteRepositoryAction
*
* @version $Id$
- *
- * @plexus.component role="com.opensymphony.xwork2.Action" role-hint="editRemoteRepositoryAction" instantiation-strategy="per-lookup"
+ * <p/>
+ * plexus.component role="com.opensymphony.xwork2.Action" role-hint="editRemoteRepositoryAction" instantiation-strategy="per-lookup"
*/
+@Controller( "editRemoteRepositoryAction" )
+@Scope( "prototype" )
public class EditRemoteRepositoryAction
extends AbstractRemoteRepositoriesAction
implements Preparable
addActionError( "Edit failure, unable to edit a repository with a blank repository id." );
return ERROR;
}
-
+
return INPUT;
}
public String commit()
{
Configuration configuration = archivaConfiguration.getConfiguration();
-
+
// We are in edit mode, remove the old repository configuration.
removeRepository( repository.getId(), configuration );
return result;
}
-
+
public RemoteRepositoryConfiguration getRepository()
{
return repository;
import org.apache.maven.archiva.configuration.RemoteRepositoryConfiguration;
import org.apache.maven.archiva.configuration.functors.RepositoryConfigurationComparator;
import org.apache.maven.archiva.security.ArchivaRoleConstants;
-import org.apache.maven.archiva.web.action.PlexusActionSupport;
+import org.apache.maven.archiva.web.action.AbstractActionSupport;
import org.apache.maven.archiva.web.util.ContextUtils;
import org.apache.struts2.interceptor.ServletRequestAware;
import org.codehaus.plexus.redback.rbac.Resource;
import org.codehaus.redback.integration.interceptor.SecureAction;
import org.codehaus.redback.integration.interceptor.SecureActionBundle;
import org.codehaus.redback.integration.interceptor.SecureActionException;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Controller;
+import javax.inject.Inject;
+import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import javax.servlet.http.HttpServletRequest;
/**
* Shows the Repositories Tab for the administrator.
*
* @version $Id$
- * @plexus.component role="com.opensymphony.xwork2.Action" role-hint="repositoriesAction" instantiation-strategy="per-lookup"
+ * plexus.component role="com.opensymphony.xwork2.Action" role-hint="repositoriesAction" instantiation-strategy="per-lookup"
*/
+@Controller( "repositoriesAction" )
+@Scope( "prototype" )
public class RepositoriesAction
- extends PlexusActionSupport
+ extends AbstractActionSupport
implements SecureAction, ServletRequestAware, Preparable
{
/**
- * @plexus.requirement
+ * plexus.requirement
*/
+ @Inject
private ArchivaConfiguration archivaConfiguration;
private List<ManagedRepositoryConfiguration> managedRepositories;
private String baseUrl;
/**
- * @plexus.requirement
+ * plexus.requirement
*/
+ @Inject
private RepositoryStatisticsManager repositoryStatisticsManager;
public void setServletRequest( HttpServletRequest request )
import org.apache.maven.archiva.configuration.RepositoryGroupConfiguration;
import org.apache.maven.archiva.web.util.ContextUtils;
import org.apache.struts2.interceptor.ServletRequestAware;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Controller;
+import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import javax.servlet.http.HttpServletRequest;
/**
* RepositoryGroupsAction
- *
- * @version
- * @plexus.component role="com.opensymphony.xwork2.Action" role-hint="repositoryGroupsAction" instantiation-strategy="per-lookup"
+ *
+ * @version plexus.component role="com.opensymphony.xwork2.Action" role-hint="repositoryGroupsAction" instantiation-strategy="per-lookup"
*/
+@Controller( "repositoryGroupsAction" )
+@Scope( "prototype" )
public class RepositoryGroupsAction
extends AbstractRepositoriesAdminAction
implements ServletRequestAware, Preparable
private Map<String, List<String>> groupToRepositoryMap;
private String repoGroupId;
-
+
private String repoId;
/**
* Used to construct the repository WebDAV URL in the repository action.
*/
private String baseUrl;
-
- private static final Pattern REPO_GROUP_ID_PATTERN = Pattern.compile( "[A-Za-z0-9\\._\\-]+" );
-
+
+ private static final Pattern REPO_GROUP_ID_PATTERN = Pattern.compile( "[A-Za-z0-9\\._\\-]+" );
+
public void setServletRequest( HttpServletRequest request )
{
this.baseUrl = ContextUtils.getBaseURL( request, "repository" );
public void prepare()
{
Configuration config = archivaConfiguration.getConfiguration();
-
+
repositoryGroup = new RepositoryGroupConfiguration();
repositoryGroups = config.getRepositoryGroupsAsMap();
managedRepositories = config.getManagedRepositoriesAsMap();
groupToRepositoryMap = config.getGroupToRepositoryMap();
}
-
+
public String addRepositoryGroup()
{
Configuration configuration = archivaConfiguration.getConfiguration();
String repoGroupId = repositoryGroup.getId();
-
- if( repoGroupId == null || "".equals( repoGroupId.trim() ) )
+
+ if ( repoGroupId == null || "".equals( repoGroupId.trim() ) )
{
addActionError( "Identifier field is required." );
return ERROR;
}
-
- if( repoGroupId.length() > 100 )
+
+ if ( repoGroupId.length() > 100 )
{
addActionError( "Identifier [" + repoGroupId + "] is over the maximum limit of 100 characters" );
return ERROR;
}
-
- Matcher matcher = REPO_GROUP_ID_PATTERN.matcher( repoGroupId );
- if( !matcher.matches() )
+
+ Matcher matcher = REPO_GROUP_ID_PATTERN.matcher( repoGroupId );
+ if ( !matcher.matches() )
{
- addActionError( "Invalid character(s) found in identifier. Only the following characters are allowed: alphanumeric, '.', '-' and '_'" );
+ addActionError(
+ "Invalid character(s) found in identifier. Only the following characters are allowed: alphanumeric, '.', '-' and '_'" );
return ERROR;
}
-
+
if ( StringUtils.isBlank( repoGroupId ) )
{
- addActionError( "You must enter a repository group id." );
- return ERROR;
+ addActionError( "You must enter a repository group id." );
+ return ERROR;
}
-
+
if ( configuration.getRepositoryGroupsAsMap().containsKey( repoGroupId ) )
{
addActionError( "Unable to add new repository group with id [" + repoGroupId
- + "], that id already exists as a repository group." );
+ + "], that id already exists as a repository group." );
return ERROR;
}
else if ( configuration.getManagedRepositoriesAsMap().containsKey( repoGroupId ) )
{
addActionError( "Unable to add new repository group with id [" + repoGroupId
- + "], that id already exists as a managed repository." );
+ + "], that id already exists as a managed repository." );
return ERROR;
}
else if ( configuration.getRemoteRepositoriesAsMap().containsKey( repoGroupId ) )
{
addActionError( "Unable to add new repository group with id [" + repoGroupId
- + "], that id already exists as a remote repository." );
+ + "], that id already exists as a remote repository." );
return ERROR;
}
-
+
configuration.addRepositoryGroup( repositoryGroup );
triggerAuditEvent( AuditEvent.ADD_REPO_GROUP + " " + repoGroupId );
return saveConfiguration( configuration );
}
-
+
public String addRepositoryToGroup()
{
Configuration config = archivaConfiguration.getConfiguration();
RepositoryGroupConfiguration group = config.findRepositoryGroupById( repoGroupId );
-
+
validateRepository();
-
+
if ( hasErrors() )
{
return ERROR;
// remove the old repository group configuration
config.removeRepositoryGroup( group );
-
+
// save repository group configuration
group.addRepository( repoId );
config.addRepositoryGroup( group );
-
+
triggerAuditEvent( repoId, null, AuditEvent.ADD_REPO_TO_GROUP + " " + repoGroupId );
-
+
return saveConfiguration( config );
}
-
+
public String removeRepositoryFromGroup()
{
Configuration config = archivaConfiguration.getConfiguration();
RepositoryGroupConfiguration group = config.findRepositoryGroupById( repoGroupId );
-
+
validateRepository();
-
- if( hasErrors() )
+
+ if ( hasErrors() )
{
return ERROR;
}
-
+
if ( !group.getRepositories().contains( repoId ) )
{
addActionError( "No repository with id[" + repoId + "] found in the group" );
return ERROR;
}
-
+
// remove the old repository group configuration
config.removeRepositoryGroup( group );
-
+
// save repository group configuration
group.removeRepository( repoId );
config.addRepositoryGroup( group );
-
+
triggerAuditEvent( repoId, null, AuditEvent.DELETE_REPO_FROM_GROUP + " " + repoGroupId );
-
+
return saveConfiguration( config );
}
-
+
public void validateRepository()
{
Configuration config = archivaConfiguration.getConfiguration();
RepositoryGroupConfiguration group = config.findRepositoryGroupById( repoGroupId );
ManagedRepositoryConfiguration repo = config.findManagedRepositoryById( repoId );
-
+
if ( group == null )
{
addActionError( "A repository group with that id does not exist." );
}
-
+
if ( repo == null )
{
addActionError( "A repository with that id does not exist." );
}
}
-
+
public RepositoryGroupConfiguration getRepositoryGroup()
{
return repositoryGroup;
}
-
+
public void setRepositoryGroup( RepositoryGroupConfiguration repositoryGroup )
{
this.repositoryGroup = repositoryGroup;
}
-
+
public Map<String, RepositoryGroupConfiguration> getRepositoryGroups()
{
return repositoryGroups;
}
-
+
public void setRepositoryGroups( Map<String, RepositoryGroupConfiguration> repositoryGroups )
{
this.repositoryGroups = repositoryGroups;
}
-
+
public Map<String, ManagedRepositoryConfiguration> getManagedRepositories()
{
return managedRepositories;
}
-
+
public Map<String, List<String>> getGroupToRepositoryMap()
{
return this.groupToRepositoryMap;
}
-
+
public String getRepoGroupId()
{
return repoGroupId;
}
-
+
public void setRepoGroupId( String repoGroupId )
{
this.repoGroupId = repoGroupId;
}
-
+
public String getRepoId()
{
return repoId;
}
-
+
public void setRepoId( String repoId )
{
this.repoId = repoId;
}
-
+
public String getBaseUrl()
{
return baseUrl;
* under the License.
*/
-import java.util.List;
-
import org.apache.commons.lang.StringUtils;
import org.apache.maven.archiva.configuration.Configuration;
import org.apache.maven.archiva.configuration.RepositoryGroupConfiguration;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Controller;
+
+import java.util.List;
/**
* SortRepositoriesAction
- *
- * @version
- * @plexus.component role="com.opensymphony.xwork2.Action" role-hint="sortRepositoriesAction" instantiation-strategy="per-lookup"
+ *
+ * @version plexus.component role="com.opensymphony.xwork2.Action" role-hint="sortRepositoriesAction" instantiation-strategy="per-lookup"
*/
-public class SortRepositoriesAction
+@Controller( "sortRepositoriesAction" )
+@Scope( "prototype" )
+public class SortRepositoriesAction
extends AbstractRepositoriesAdminAction
{
private String repoGroupId;
-
+
private String targetRepo;
-
+
public String sortDown()
{
Configuration config = archivaConfiguration.getConfiguration();
-
+
List<String> repositories = getRepositoriesFromGroup();
-
+
int idx = findTargetRepository( repositories, targetRepo );
-
+
if ( idx >= 0 && validIndex( repositories, idx + 1 ) )
{
repositories.remove( idx );
repositories.add( idx + 1, targetRepo );
}
-
+
return saveConfiguration( config );
}
-
+
public String sortUp()
{
Configuration config = archivaConfiguration.getConfiguration();
-
+
List<String> repositories = getRepositoriesFromGroup();
int idx = findTargetRepository( repositories, targetRepo );
-
+
if ( idx >= 0 && validIndex( repositories, idx - 1 ) )
{
repositories.remove( idx );
repositories.add( idx - 1, targetRepo );
}
-
+
return saveConfiguration( config );
}
-
+
public String getRepoGroupId()
{
return repoGroupId;
}
-
+
public void setRepoGroupId( String repoGroupId )
{
this.repoGroupId = repoGroupId;
}
-
+
public String getTargetRepo()
{
return targetRepo;
}
-
+
public void setTargetRepo( String targetRepo )
{
this.targetRepo = targetRepo;
}
-
+
private int findTargetRepository( List<String> repositories, String targetRepository )
{
int idx = ( -1 );
-
+
for ( int i = 0; i < repositories.size(); i++ )
{
- if ( StringUtils.equals( targetRepository, repositories.get(i) ) )
+ if ( StringUtils.equals( targetRepository, repositories.get( i ) ) )
{
idx = i;
break;
}
return idx;
}
-
+
private List<String> getRepositoriesFromGroup()
{
Configuration config = archivaConfiguration.getConfiguration();
RepositoryGroupConfiguration repoGroup = config.findRepositoryGroupById( repoGroupId );
return repoGroup.getRepositories();
}
-
+
private boolean validIndex( List<String> repositories, int idx )
- {
- return ( idx >= 0 ) && ( idx < repositories.size() );
- }
+ {
+ return ( idx >= 0 ) && ( idx < repositories.size() );
+ }
}
import org.apache.maven.archiva.configuration.functors.FiletypeSelectionPredicate;
import org.apache.maven.archiva.configuration.functors.FiletypeToMapClosure;
import org.apache.maven.archiva.security.ArchivaRoleConstants;
-import org.apache.maven.archiva.web.action.PlexusActionSupport;
+import org.apache.maven.archiva.web.action.AbstractActionSupport;
import org.codehaus.plexus.redback.rbac.Resource;
import org.codehaus.plexus.registry.RegistryException;
import org.codehaus.redback.integration.interceptor.SecureAction;
import org.codehaus.redback.integration.interceptor.SecureActionBundle;
import org.codehaus.redback.integration.interceptor.SecureActionException;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Controller;
+import javax.inject.Inject;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
* RepositoryScanningAction
*
* @version $Id$
- * @plexus.component role="com.opensymphony.xwork2.Action" role-hint="repositoryScanningAction" instantiation-strategy="per-lookup"
+ * plexus.component role="com.opensymphony.xwork2.Action" role-hint="repositoryScanningAction" instantiation-strategy="per-lookup"
*/
+@Controller( "repositoryScanningAction" )
+@Scope( "prototype" )
public class RepositoryScanningAction
- extends PlexusActionSupport
+ extends AbstractActionSupport
implements Preparable, Validateable, SecureAction, Auditable
{
/**
- * @plexus.requirement
+ * plexus.requirement
*/
+ @Inject
private ArchivaConfiguration archivaConfiguration;
/**
- * @plexus.requirement
+ * plexus.requirement
*/
+ @Inject
private RepositoryContentConsumers repoconsumerUtil;
private Map<String, FileType> fileTypeMap;
private String pattern;
private String fileTypeId;
-
+
public void addActionError( String anErrorMessage )
{
super.addActionError( anErrorMessage );
- log.warn( "[ActionError] " + anErrorMessage );
+ log.warn( "[ActionError] {}", anErrorMessage );
}
public void addActionMessage( String aMessage )
{
super.addActionMessage( aMessage );
- log.info( "[ActionMessage] " + aMessage );
+ log.info( "[ActionMessage] {}", aMessage );
}
public String addFiletypePattern()
filetype.addPattern( pattern );
addActionMessage( "Added pattern \"" + pattern + "\" to filetype " + id );
-
+
triggerAuditEvent( AuditEvent.ADD_PATTERN + " " + pattern );
return saveConfiguration();
}
filetype.removePattern( getPattern() );
-
+
triggerAuditEvent( AuditEvent.REMOVE_PATTERN + " " + pattern );
return saveConfiguration();
public String updateInvalidConsumers()
{
addActionMessage( "Update Invalid Consumers" );
-
- List<String> oldConsumers = archivaConfiguration.getConfiguration().getRepositoryScanning().getInvalidContentConsumers();
+
+ List<String> oldConsumers =
+ archivaConfiguration.getConfiguration().getRepositoryScanning().getInvalidContentConsumers();
archivaConfiguration.getConfiguration().getRepositoryScanning().setInvalidContentConsumers(
enabledInvalidContentConsumers );
-
+
if ( enabledInvalidContentConsumers != null )
{
filterAddedConsumers( oldConsumers, enabledInvalidContentConsumers );
- filterRemovedConsumers( oldConsumers, enabledInvalidContentConsumers );
+ filterRemovedConsumers( oldConsumers, enabledInvalidContentConsumers );
}
else
{
public String updateKnownConsumers()
{
addActionMessage( "Update Known Consumers" );
-
- List<String> oldConsumers = archivaConfiguration.getConfiguration().getRepositoryScanning().getKnownContentConsumers();
+
+ List<String> oldConsumers =
+ archivaConfiguration.getConfiguration().getRepositoryScanning().getKnownContentConsumers();
archivaConfiguration.getConfiguration().getRepositoryScanning().setKnownContentConsumers(
enabledKnownContentConsumers );
-
+
if ( enabledKnownContentConsumers != null )
{
filterAddedConsumers( oldConsumers, enabledKnownContentConsumers );
- filterRemovedConsumers( oldConsumers, enabledKnownContentConsumers );
+ filterRemovedConsumers( oldConsumers, enabledKnownContentConsumers );
}
else
{
}
}
}
-
+
private void filterRemovedConsumers( List<String> oldList, List<String> newList )
{
for ( String consumer : oldList )
}
}
}
-
+
private void disableAllEnabledConsumers( List<String> consumers )
{
for ( String consumer : consumers )
{
this.enabledKnownContentConsumers = enabledKnownContentConsumers;
}
-
+
public ArchivaConfiguration getArchivaConfiguration()
{
return archivaConfiguration;
}
-
+
public void setArchivaConfiguration( ArchivaConfiguration archivaConfiguration )
{
this.archivaConfiguration = archivaConfiguration;
import org.codehaus.redback.integration.interceptor.SecureActionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Controller;
+import javax.inject.Inject;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.TreeMap;
/**
- * @plexus.component role="com.opensymphony.xwork2.Action" role-hint="generateReport" instantiation-strategy="per-lookup"
+ * plexus.component role="com.opensymphony.xwork2.Action" role-hint="generateReport" instantiation-strategy="per-lookup"
*/
+@Controller( "generateReport" )
+@Scope( "prototype" )
public class GenerateReportAction
extends AbstractRepositoryBasedAction
implements SecureAction, Preparable
public static final String BLANK = "blank";
private static final String[] datePatterns =
- new String[]{"MM/dd/yy", "MM/dd/yyyy", "MMMMM/dd/yyyy", "MMMMM/dd/yy", "dd MMMMM yyyy", "dd/MM/yy",
- "dd/MM/yyyy", "yyyy/MM/dd", "yyyy-MM-dd", "yyyy-dd-MM", "MM-dd-yyyy", "MM-dd-yy"};
+ new String[]{ "MM/dd/yy", "MM/dd/yyyy", "MMMMM/dd/yyyy", "MMMMM/dd/yy", "dd MMMMM yyyy", "dd/MM/yy",
+ "dd/MM/yyyy", "yyyy/MM/dd", "yyyy-MM-dd", "yyyy-dd-MM", "MM-dd-yyyy", "MM-dd-yy" };
public static final String SEND_FILE = "send-file";
private Logger log = LoggerFactory.getLogger( GenerateReportAction.class );
/**
- * @plexus.requirement
+ * plexus.requirement
*/
+ @Inject
private ArchivaConfiguration archivaConfiguration;
/**
- * @plexus.requirement
+ * plexus.requirement
*/
+ @Inject
private RepositoryStatisticsManager repositoryStatisticsManager;
private String groupId;
/**
* Generate the statistics report.
- *
+ * <p/>
* check whether single repo report or comparison report
* 1. if it is a single repository, get all the statistics for the repository on the specified date
* - if no date is specified, get only the latest
* (total page = 1 --> no pagination since only the most recent stats will be displayed)
* - otherwise, get everything within the date range (total pages = repo stats / rows per page)
* - required params: repository, startDate, endDate
- *
+ * <p/>
* 2. if multiple repositories, get the latest statistics on each repository on the specified date
* - if no date is specified, use the current date endDate
* - required params: repositories, endDate
List<RepositoryStatistics> stats = null;
try
{
- stats = repositoryStatisticsManager.getStatisticsInRange( metadataRepository, repo,
- startDateInDF, endDateInDF );
+ stats =
+ repositoryStatisticsManager.getStatisticsInRange( metadataRepository, repo, startDateInDF,
+ endDateInDF );
}
catch ( MetadataRepositoryException e )
{
}
input = new StringBuffer(
- "Repository,Total File Count,Total Size,Artifact Count,Group Count,Project Count,Plugins,Archetypes," +
- "Jars,Wars\n" );
+ "Repository,Total File Count,Total Size,Artifact Count,Group Count,Project Count,Plugins,Archetypes,"
+ + "Jars,Wars\n" );
// multiple repos
for ( String repo : selectedRepositories )
List<RepositoryStatistics> stats = null;
try
{
- stats = repositoryStatisticsManager.getStatisticsInRange( metadataRepository, repo,
- startDateInDF, endDateInDF );
+ stats =
+ repositoryStatisticsManager.getStatisticsInRange( metadataRepository, repo, startDateInDF,
+ endDateInDF );
}
catch ( MetadataRepositoryException e )
{
}
input = new StringBuffer(
- "Date of Scan,Total File Count,Total Size,Artifact Count,Group Count,Project Count,Plugins," +
- "Archetypes,Jars,Wars\n" );
+ "Date of Scan,Total File Count,Total Size,Artifact Count,Group Count,Project Count,Plugins,"
+ + "Archetypes,Jars,Wars\n" );
for ( RepositoryStatistics repositoryStats : stats )
{
// TODO: improve performance by navigating into a group subtree. Currently group is property, not part of name of item
for ( String name : metadataRepository.getMetadataFacets( repoId, RepositoryProblemFacet.FACET_ID ) )
{
- RepositoryProblemFacet metadataFacet = (RepositoryProblemFacet) metadataRepository.getMetadataFacet(
- repoId, RepositoryProblemFacet.FACET_ID, name );
+ RepositoryProblemFacet metadataFacet =
+ (RepositoryProblemFacet) metadataRepository.getMetadataFacet( repoId,
+ RepositoryProblemFacet.FACET_ID,
+ name );
if ( StringUtils.isEmpty( groupId ) || groupId.equals( metadataFacet.getNamespace() ) )
{
import org.apache.maven.archiva.security.ArchivaSecurityException;
import org.apache.maven.archiva.security.PrincipalNotFoundException;
import org.apache.maven.archiva.security.UserRepositories;
-import org.apache.maven.archiva.web.action.PlexusActionSupport;
+import org.apache.maven.archiva.web.action.AbstractActionSupport;
import org.apache.struts2.interceptor.ServletRequestAware;
import org.codehaus.redback.integration.interceptor.SecureAction;
import org.codehaus.redback.integration.interceptor.SecureActionBundle;
import org.codehaus.redback.integration.interceptor.SecureActionException;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Controller;
+import javax.inject.Inject;
+import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.List;
-import javax.servlet.http.HttpServletRequest;
/**
- * @plexus.component role="com.opensymphony.xwork2.Action" role-hint="viewAuditLogReport"
+ * plexus.component role="com.opensymphony.xwork2.Action" role-hint="viewAuditLogReport"
* instantiation-strategy="per-lookup"
*/
+@Controller( "viewAuditLogReport" )
+@Scope( "prototype" )
public class ViewAuditLogReportAction
- extends PlexusActionSupport
+ extends AbstractActionSupport
implements SecureAction, ServletRequestAware, Preparable
{
protected HttpServletRequest request;
/**
- * @plexus.requirement
+ * plexus.requirement
*/
+ @Inject
private UserRepositories userRepositories;
private String repository;
private static final String HEADER_RESULTS = "Results";
private String[] datePatterns =
- new String[]{"MM/dd/yy", "MM/dd/yyyy", "MMMMM/dd/yyyy", "MMMMM/dd/yy", "dd MMMMM yyyy", "dd/MM/yy",
- "dd/MM/yyyy", "yyyy/MM/dd", "yyyy-MM-dd", "yyyy-dd-MM", "MM-dd-yyyy", "MM-dd-yy"};
+ new String[]{ "MM/dd/yy", "MM/dd/yyyy", "MMMMM/dd/yyyy", "MMMMM/dd/yy", "dd MMMMM yyyy", "dd/MM/yy",
+ "dd/MM/yyyy", "yyyy/MM/dd", "yyyy-MM-dd", "yyyy-dd-MM", "MM-dd-yyyy", "MM-dd-yy" };
/**
- * @plexus.requirement
+ * plexus.requirement
*/
+ @Inject
private AuditManager auditManager;
public SecureActionBundle getSecureActionBundle()
RepositorySession repositorySession = repositorySessionFactory.createSession();
try
{
- auditLogs = auditManager.getAuditEventsInRange( repositorySession.getRepository(), repos, resource,
- startDateInDF, endDateInDF );
+ auditLogs =
+ auditManager.getAuditEventsInRange( repositorySession.getRepository(), repos, resource, startDateInDF,
+ endDateInDF );
}
finally
{
auditLogs.remove( rowCount );
}
- prev = request.getRequestURL() + "?page=" + ( page - 1 ) + "&rowCount=" + rowCount + "&groupId=" + groupId +
- "&artifactId=" + artifactId + "&repository=" + repository + "&startDate=" + startDate + "&endDate=" +
- endDate;
+ prev = request.getRequestURL() + "?page=" + ( page - 1 ) + "&rowCount=" + rowCount + "&groupId=" + groupId
+ + "&artifactId=" + artifactId + "&repository=" + repository + "&startDate=" + startDate + "&endDate="
+ + endDate;
- next = request.getRequestURL() + "?page=" + ( page + 1 ) + "&rowCount=" + rowCount + "&groupId=" + groupId +
- "&artifactId=" + artifactId + "&repository=" + repository + "&startDate=" + startDate + "&endDate=" +
- endDate;
+ next = request.getRequestURL() + "?page=" + ( page + 1 ) + "&rowCount=" + rowCount + "&groupId=" + groupId
+ + "&artifactId=" + artifactId + "&repository=" + repository + "&startDate=" + startDate + "&endDate="
+ + endDate;
prev = StringUtils.replace( prev, " ", "%20" );
next = StringUtils.replace( next, " ", "%20" );
* under the License.
*/
-import org.apache.struts2.ServletActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.Interceptor;
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
+import org.apache.struts2.ServletActionContext;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Service;
+import javax.inject.Inject;
import javax.servlet.ServletContext;
/**
* @plexus.component role="com.opensymphony.xwork2.interceptor.Interceptor"
* role-hint="configurationInterceptor"
*/
+@Service( "configurationInterceptor" )
+@Scope( "prototype" )
public class ConfigurationInterceptor
implements Interceptor
{
/**
- * @plexus.requirement role-hint="default"
+ * plexus.requirement role-hint="default"
*/
+ @Inject
private ArchivaConfiguration configuration;
public String intercept( ActionInvocation actionInvocation )
* under the License.
*/
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang.StringUtils;
import org.apache.maven.archiva.common.ArchivaException;
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.configuration.ConfigurationNames;
import org.codehaus.plexus.registry.RegistryListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.context.ApplicationContext;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.PostConstruct;
+import javax.inject.Inject;
+import javax.inject.Named;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
/**
* ConfigurationSynchronization
*
* @version $Id$
- * @plexus.component role="org.apache.maven.archiva.web.startup.SecuritySynchronization"
+ * plexus.component role="org.apache.maven.archiva.web.startup.SecuritySynchronization"
* role-hint="default"
*/
+@Service
public class SecuritySynchronization
implements RegistryListener
{
private Logger log = LoggerFactory.getLogger( SecuritySynchronization.class );
/**
- * @plexus.requirement role-hint="default"
+ * plexus.requirement role-hint="default"
*/
+ @Inject
private RoleManager roleManager;
/**
- * @plexus.requirement role-hint="cached"
+ * plexus.requirement role-hint="cached"
*/
+ @Inject
+ @Named( value = "rBACManager#cached" )
private RBACManager rbacManager;
/**
private Map<String, EnvironmentCheck> checkers;
/**
- * @plexus.requirement
+ * plexus.requirement
*/
+ @Inject
private ArchivaConfiguration archivaConfiguration;
+ @Inject
+ private ApplicationContext applicationContext;
+
+ @PostConstruct
+ public void initialize()
+ {
+ checkers = getBeansOfType( EnvironmentCheck.class );
+ }
+
+ protected <T> Map<String, T> getBeansOfType( Class<T> clazz )
+ {
+ //TODO do some caching here !!!
+ // olamy : with plexus we get only roleHint
+ // as per convention we named spring bean role#hint remove role# if exists
+ Map<String, T> springBeans = applicationContext.getBeansOfType( clazz );
+
+ Map<String, T> beans = new HashMap<String, T>( springBeans.size() );
+
+ for ( Map.Entry<String, T> entry : springBeans.entrySet() )
+ {
+ String key = StringUtils.substringAfterLast( entry.getKey(), "#" );
+ beans.put( key, entry.getValue() );
+ }
+ return beans;
+ }
+
public void afterConfigurationChange( Registry registry, String propertyName, Object propertyValue )
{
if ( ConfigurationNames.isManagedRepositories( propertyName ) )
msg.append( "======================================================================" );
log.error( msg.toString() );
- throw new ArchivaException( "Unable to initialize Redback Security Environment, [" + violations.size() +
- "] violation(s) encountered, See log for details." );
+ throw new ArchivaException( "Unable to initialize Redback Security Environment, [" + violations.size()
+ + "] violation(s) encountered, See log for details." );
}
}
}
catch ( RbacManagerException e )
{
- log.warn(
- "Unable to add role [" + ArchivaRoleConstants.toRepositoryObserverRoleName( repoId ) + "] to " +
- principal + " user.", e );
+ log.warn( "Unable to add role [" + ArchivaRoleConstants.toRepositoryObserverRoleName( repoId ) + "] to "
+ + principal + " user.", e );
}
}
}
* under the License.
*/
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Stack;
-
import com.opensymphony.xwork2.ActionContext;
import org.apache.archiva.dependency.tree.maven2.DependencyTreeBuilder;
import org.apache.commons.lang.StringUtils;
import org.apache.maven.shared.dependency.tree.traversal.DependencyNodeVisitor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+
+import javax.inject.Inject;
+import java.util.ArrayList;
+import java.util.List;
/**
* DependencyTree
*
* @version $Id$
- * @plexus.component role="org.apache.maven.archiva.web.tags.DependencyTree"
+ * plexus.component role="org.apache.maven.archiva.web.tags.DependencyTree"
*/
+@Service
public class DependencyTree
{
private Logger log = LoggerFactory.getLogger( DependencyTree.class );
/**
- * @plexus.requirement role-hint="maven2"
+ * plexus.requirement role-hint="maven2"
*/
+ @Inject
private DependencyTreeBuilder dependencyTreeBuilder;
/**
- * @plexus.requirement
+ * plexus.requirement
*/
+ @Inject
private UserRepositories userRepositories;
public static class TreeEntry
{
if ( StringUtils.isBlank( groupId ) )
{
- String emsg = "Error generating dependency tree [" + Keys.toKey( groupId, artifactId, modelVersion ) +
- "]: groupId is blank.";
+ String emsg = "Error generating dependency tree [" + Keys.toKey( groupId, artifactId, modelVersion )
+ + "]: groupId is blank.";
log.error( emsg );
throw new ArchivaException( emsg );
}
if ( StringUtils.isBlank( artifactId ) )
{
- String emsg = "Error generating dependency tree [" + Keys.toKey( groupId, artifactId, modelVersion ) +
- "]: artifactId is blank.";
+ String emsg = "Error generating dependency tree [" + Keys.toKey( groupId, artifactId, modelVersion )
+ + "]: artifactId is blank.";
log.error( emsg );
throw new ArchivaException( emsg );
}
if ( StringUtils.isBlank( modelVersion ) )
{
- String emsg = "Error generating dependency tree [" + Keys.toKey( groupId, artifactId, modelVersion ) +
- "]: version is blank.";
+ String emsg = "Error generating dependency tree [" + Keys.toKey( groupId, artifactId, modelVersion )
+ + "]: version is blank.";
log.error( emsg );
throw new ArchivaException( emsg );
}
# define our own action mapper here
struts.mapper.class = org.apache.maven.archiva.web.mapper.RepositoryActionMapper
-struts.objectFactory = org.codehaus.plexus.spring.Struts2PlexusInSpringObjectFactory
+#struts.objectFactory = org.codehaus.plexus.spring.Struts2PlexusInSpringObjectFactory
+
+## TODO olamy chech fix for https://issues.apache.org/jira/browse/WW-3460
+## upgrade of struts version or use our own hacked ObjectFactory
+struts.objectFactory = org.apache.struts2.spring.StrutsSpringObjectFactory
+struts.objectFactory.spring.autoWire = type
+
struts.url.includeParams = none
+
+## freemarker configuration
struts.freemarker.templatesCache=true
+struts.freemarker.mru.max.strong.size=1000
+struts.freemarker.templatesCache.updateDelay=3600000
#struts.devMode = true
struts.configuration.xml.reload=true
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
+ http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+ http://www.springframework.org/schema/context
+ http://www.springframework.org/schema/context/spring-context-3.0.xsd">
+
+ <context:property-placeholder location="classpath:application.properties" />
+
<bean id="loggerManager" class="org.codehaus.plexus.logging.slf4j.Slf4jLoggerManager"
init-method="initialize"/>
<alias name="repositorySessionFactory#file" alias="repositorySessionFactory"/>
+ <!--
+ TODO olamy check user agent used in wagon !!
<bean name="wagon#http" class="org.apache.maven.wagon.providers.http.LightweightHttpWagon" scope="prototype">
<property name="httpHeaders">
<map>
</map>
</property>
</bean>
-
- <bean id="propertyPlaceholder" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
- <property name="location" value="classpath:application.properties"/>
- </bean>
-
+ -->
<bean name="xmlRpcUserRepositories" class="org.apache.archiva.web.xmlrpc.security.XmlRpcUserRepositories">
<constructor-arg ref="userRepositories"/>
<constructor-arg ref="xmlRpcAuthenticator"/>
<bean name="profileActivator#jdk-prefix" class="org.apache.archiva.web.spring.DummyProfileActivator"/>
<bean name="profileActivator#system-property" class="org.apache.archiva.web.spring.DummyProfileActivator"/>
<bean name="profileActivator#always-on" class="org.apache.archiva.web.spring.DummyProfileActivator"/>
+
+ <bean name="commons-configuration" class="org.codehaus.redback.components.registry.commons.CommonsConfigurationRegistry">
+ <property name="properties">
+ <value>
+ <![CDATA[
+ <configuration>
+ <system/>
+ <jndi prefix="java:comp/env" config-optional="true"/>
+ <xml fileName="${user.home}/.m2/archiva.xml" config-optional="true"
+ config-name="org.apache.maven.archiva.user"
+ config-at="org.apache.maven.archiva"/>
+ <xml fileName="${user.home}/.m2/shared.xml" config-optional="true"
+ config-name="org.apache.maven.shared.app.user" config-at="org.apache.maven.shared.app"
+ config-forceCreate="true"/>
+ <properties fileName="${user.home}/.m2/security.properties" config-optional="true"
+ config-at="org.codehaus.plexus.redback"/>
+ <properties fileName="${user.home}/.m2/archiva.properties" config-optional="true"
+ config-at="org.codehaus.plexus.redback"/>
+ <xml fileName="${appserver.base}/conf/archiva.xml" config-optional="true"
+ config-name="org.apache.maven.archiva.base"
+ config-at="org.apache.maven.archiva"/>
+ <xml fileName="${appserver.base}/conf/shared.xml" config-optional="true"
+ config-name="org.apache.maven.shared.app.base" config-at="org.apache.maven.shared.app"/>
+ <xml fileName="${appserver.base}/conf/common.xml" config-optional="true"/>
+ <properties fileName="${appserver.base}/conf/security.properties" config-optional="true"
+ config-at="org.codehaus.plexus.redback"/>
+ <xml fileName="${appserver.home}/conf/archiva.xml" config-optional="true"
+ config-at="org.apache.maven.archiva"/>
+ <xml fileName="${appserver.home}/conf/shared.xml" config-optional="true"
+ config-at="org.apache.maven.shared.app"/>
+ <xml fileName="${appserver.home}/conf/common.xml" config-optional="true"/>
+ <properties fileName="${appserver.home}/conf/security.properties" config-optional="true"
+ config-at="org.codehaus.plexus.redback"/>
+ <properties fileName="org/apache/maven/archiva/security.properties" config-at="org.codehaus.plexus.redback"/>
+ </configuration>
+ ]]>
+ </value>
+ </property>
+ </bean>
+
+ <bean name="jdoFactory#users" class="org.codehaus.plexus.jdo.DataSourceConfigurableJdoFactory">
+ <property name="connectionFactoryName" value="java:comp/env/jdbc/users"/>
+ <property name="shutdownConnectionFactoryName" value="java:comp/env/jdbc/usersShutdown"/>
+ <property name="persistenceManagerFactoryClass" value="org.jpox.PersistenceManagerFactoryImpl"/>
+ <property name="otherProperties">
+ <props>
+ <prop key="org.jpox.autoCreateSchema">true</prop>
+ <prop key="org.jpox.validateTables">false</prop>
+ <prop key="org.jpox.validateConstraints">false</prop>
+ <prop key="org.jpox.validateColumns">false</prop>
+ <prop key="org.jpox.autoStartMechanism">None</prop>
+ <prop key="org.jpox.transactionIsolation">READ_COMMITTED</prop>
+ <prop key="org.jpox.poid.transactionIsolation">READ_COMMITTED</prop>
+ <prop key="org.jpox.rdbms.dateTimezone">JDK_DEFAULT_TIMEZONE</prop>
+ <!-- NEEDED FOR MYSQL UTF-8 Databases -->
+ <prop key="org.jpox.rdbms.stringDefaultLength">255</prop>
+
+ <!-- NEEDED FOR POSTGRES, But causes problems in other JDBC implementations.
+ <prop key="org.jpox.identifier.case">PreserveCase</prop>
+ -->
+ </props>
+ </property>
+ </bean>
+
+
+
+
+ <!-- <component>
+ <role>org.apache.maven.archiva.webdav.util.MimeTypes</role>
+ <implementation>org.apache.maven.archiva.webdav.util.MimeTypes</implementation>
+ <description>MimeTypes</description>
+ <configuration>
+ <resource>archiva-mime-types.txt</resource>
+ </configuration>
+ </component> -->
+
+
+ <!--
+ olamy TODO check if necessary !!
+ PLXREDBACK-81 bad role hint, redefining here until redback alpha-2 is released.
+
+ <component>
+ <role>org.codehaus.plexus.redback.system.check.EnvironmentCheck</role>
+ <role-hint>locked-admin-check</role-hint>
+ <implementation>org.codehaus.redback.integration.checks.security.LockedAdminEnvironmentCheck</implementation>
+ <description>LockedAdminEnvironmentCheck: checks if accounts marked as system administrator are locked
+ and unlocks them on startup.
+ </description>
+ <requirements>
+ <requirement>
+ <role>org.codehaus.plexus.redback.users.UserManager</role>
+ <role-hint>cached</role-hint>
+ <field-name>userManager</field-name>
+ </requirement>
+ <requirement>
+ <role>org.codehaus.plexus.redback.rbac.RBACManager</role>
+ <role-hint>cached</role-hint>
+ <field-name>rbacManager</field-name>
+ </requirement>
+ </requirements>
+ </component>
+ -->
+
+ <!-- TODO move to spring sample and test it -->
+ <!-- START SNIPPET: ldap -->
+ <!--
+ Ldap Authentication can be enabled by setting enabling these components and setting the following configuration options in your security.properties file
+
+ ============================================================
+ user.manager.impl=ldap
+ ldap.bind.authenticator.enabled=true
+ redback.default.admin=admin
+ security.policy.password.expiration.enabled=false
+
+ ldap.config.hostname=ldap.hostname
+ ldap.config.port=389
+ ldap.config.base.dn=o=com
+ ldap.config.context.factory=com.sun.jndi.ldap.LdapCtxFactory
+ ldap.config.bind.dn=uid=myusername,o=com
+ ldap.config.password=s3cr3t
+ #ldap.config.authentication.method=
+ ============================================================
+
+ * ldap.config.hostname - The hostname of the ldap server
+ * ldap.config.port - The port of the ldap server
+ * ldap.config.base.dn - The baseDn of the ldap system
+ * ldap.config.context.factory - context factory for ldap connections
+ * ldap.config.bind.dn - the core user used for authentication the ldap server, must be able to perform the necessary searches, etc.
+ * ldap.config.password - password for the bindDn for the root ldap connection
+
+ until this process is better documented, the following is the document for configuration ldap with redback
+
+ http://redback.codehaus.org/integration/ldap.html
+ -->
+
+ <!--
+
+ this component manages the connection to the ldap server
+ -->
+
+ <!-- component>
+ <role>org.codehaus.plexus.redback.common.ldap.connection.LdapConnectionFactory</role>
+ <role-hint>configurable</role-hint>
+ <implementation>org.codehaus.plexus.redback.common.ldap.connection.ConfigurableLdapConnectionFactory</implementation>
+ <requirements>
+ <requirement>
+ <role>org.codehaus.plexus.redback.configuration.UserConfiguration</role>
+ </requirement>
+ </requirements>
+ </component-->
+
+ <!--
+
+ this component manages the mapping of attributes in ldap to user information in redback. To configure the mapping, you can add the following properties in your security.properties
+
+ ============================================================
+ ldap.config.mapper.attribute.email=mail
+ ldap.config.mapper.attribute.fullname=givenName
+ ldap.config.mapper.attribute.password=userPassword
+ ldap.config.mapper.attribute.user.id=cn
+ ldap.config.mapper.attribute.user.base.dn=
+ ldap.config.mapper.attribute.user.object.class=inetOrgPerson
+ ldap.config.mapper.attribute.user.filter=(attributeName=value)
+ ============================================================
+
+
+ * email-attribute - The name of the attribute on a user that contains the email address
+ * full-name-attribute - The name of the attribute on a user that contains the users fullName
+ * password-attribute - The name of the attribute containing the users password, used for the authentiction using the user manager and not the ldap bind authenticator
+ * user-id-attribute - The name of the attribute containing the users userId, most commonly cn or sn.
+ * user-base-dn - The base dn that will be subtree searched for users.
+ * user-object-class - the objectClass used in the ldap server for indentifying users, most commonly inetOrgPerson.
+ -->
+
+ <!-- component>
+ <role>org.codehaus.plexus.redback.common.ldap.UserMapper</role>
+ <role-hint>ldap</role-hint>
+ <implementation>org.codehaus.plexus.redback.common.ldap.LdapUserMapper</implementation>
+ <configuration>
+ <email-attribute>email</email-attribute>
+ <full-name-attribute>givenName</full-name-attribute>
+ <password-attribute>userPassword</password-attribute>
+ <user-id-attribute>cn</user-id-attribute>
+ <user-base-dn>o=com</user-base-dn>
+ <user-object-class>inetOrgPerson</user-object-class>
+ </configuration>
+ <requirements>
+ <requirement>
+ <role>org.codehaus.plexus.redback.configuration.UserConfiguration</role>
+ </requirement>
+ </requirements>
+ </component-->
+
+ <!--
+
+ If caching is desired to improve performance then make uncomment this and make sure the following configuration parameter is in the security.properties
+
+ user.manager.impl=cached
+ -->
+
+ <!-- component>
+ <role>org.codehaus.plexus.redback.users.UserManager</role>
+ <role-hint>cached</role-hint>
+ <implementation>org.codehaus.plexus.redback.users.cached.CachedUserManager</implementation>
+ <description>CachedUserManager</description>
+ <requirements>
+ <requirement>
+ <role>org.codehaus.plexus.redback.users.UserManager</role>
+ <role-hint>ldap</role-hint>
+ <field-name>userImpl</field-name>
+ </requirement>
+ <requirement>
+ <role>org.codehaus.plexus.cache.Cache</role>
+ <role-hint>users</role-hint>
+ <field-name>usersCache</field-name>
+ </requirement>
+ </requirements>
+ </component-->
+
+ <!--
+
+ if using the user manager authenticator to authenticate the user and not the ldap bind authenticator make sure
+ this definition has the correct password encoder
+
+ Note: you should probably just use the ldap bind authenticator which is enabled by putting
+
+ ldap.bind.authenticator.enabled=true
+
+ in the security.properties
+ -->
+
+ <!-- component>
+ <role>org.codehaus.plexus.redback.policy.UserSecurityPolicy</role>
+ <role-hint>default</role-hint>
+ <implementation>org.codehaus.plexus.redback.policy.DefaultUserSecurityPolicy</implementation>
+ <description>User Security Policy.</description>
+ <requirements>
+ <requirement>
+ <role>org.codehaus.plexus.redback.configuration.UserConfiguration</role>
+ <field-name>config</field-name>
+ </requirement>
+ <requirement>
+ <role>org.codehaus.plexus.redback.policy.PasswordEncoder</role>
+ <role-hint>sha1</role-hint>
+ <field-name>passwordEncoder</field-name>
+ </requirement>
+ <requirement>
+ <role>org.codehaus.plexus.redback.policy.UserValidationSettings</role>
+ <field-name>userValidationSettings</field-name>
+ </requirement>
+ <requirement>
+ <role>org.codehaus.plexus.redback.policy.CookieSettings</role>
+ <role-hint>rememberMe</role-hint>
+ <field-name>rememberMeCookieSettings</field-name>
+ </requirement>
+ <requirement>
+ <role>org.codehaus.plexus.redback.policy.CookieSettings</role>
+ <role-hint>signon</role-hint>
+ <field-name>signonCookieSettings</field-name>
+ </requirement>
+ <requirement>
+ <role>org.codehaus.plexus.redback.policy.PasswordRule</role>
+ <field-name>rules</field-name>
+ </requirement>
+ </requirements>
+ </component-->
+ <!-- END SNIPPET: ldap -->
+
</beans>
<display-name>Apache Archiva</display-name>
- <filter>
- <filter-name>webwork-cleanup</filter-name>
- <filter-class>org.apache.struts2.dispatcher.ActionContextCleanUp</filter-class>
- </filter>
+ <filter>
+ <filter-name>webwork-cleanup</filter-name>
+ <filter-class>org.apache.struts2.dispatcher.ActionContextCleanUp</filter-class>
+ </filter>
<filter>
<filter-name>sitemesh</filter-name>
</filter-class>
</filter>
- <filter>
- <filter-name>struts2</filter-name>
- <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
- </filter>
+ <filter>
+ <filter-name>struts2</filter-name>
+ <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
+ </filter>
- <filter>
- <filter-name>encodingFilter</filter-name>
- <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
- <init-param>
- <param-name>encoding</param-name>
- <param-value>UTF-8</param-value>
- </init-param>
- <init-param>
- <param-name>forceEncoding</param-name>
- <param-value>true</param-value>
- </init-param>
- </filter>
+ <filter>
+ <filter-name>encodingFilter</filter-name>
+ <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
+ <init-param>
+ <param-name>encoding</param-name>
+ <param-value>UTF-8</param-value>
+ </init-param>
+ <init-param>
+ <param-name>forceEncoding</param-name>
+ <param-value>true</param-value>
+ </init-param>
+ </filter>
<filter-mapping>
<filter-name>encodingFilter</filter-name>
</listener-class>
</listener>
- <context-param>
- <param-name>contextClass</param-name>
- <param-value>
- org.codehaus.plexus.spring.PlexusWebApplicationContext
- </param-value>
- </context-param>
-
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
- classpath*:META-INF/plexus/components.xml
classpath*:META-INF/spring-context.xml
- /WEB-INF/application.xml
/WEB-INF/applicationContext.xml
</param-value>
</context-param>
import java.util.Map;
import com.opensymphony.xwork2.Action;
-import org.apache.archiva.audit.AuditListener;
import org.apache.commons.io.FileUtils;
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.configuration.Configuration;
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.maven.archiva.security.ArchivaRoleConstants;
-import org.apache.maven.archiva.web.action.PlexusActionSupport;
import org.apache.maven.archiva.web.validator.utils.ValidatorUtil;
import org.codehaus.plexus.redback.role.RoleManager;
import org.codehaus.plexus.registry.Registry;
<artifactId>commons-logging-api</artifactId>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-simple</artifactId>
- <scope>test</scope>
- </dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model-builder</artifactId>
<artifactId>test-repository</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<dependencyManagement>
<dependencies>
public void initialize()
throws PlexusSisuBridgeException
{
- builder = plexusSisuBridge.lookup( ModelBuilder.class );
+ builder = plexusSisuBridge.lookup( ModelBuilder.class, "default" );
}
public ProjectMetadata readProjectMetadata( String repoId, String namespace, String projectId )
<wagon.version>1.0-beta-5</wagon.version>
<redback.version>1.3-SNAPSHOT</redback.version>
<jetty.version>6.1.19</jetty.version>
- <slf4j.version>1.5.8</slf4j.version>
+ <slf4j.version>1.6.1</slf4j.version>
<binder.version>0.9</binder.version>
<spring.version>3.0.5.RELEASE</spring.version>
<jackrabbit.version>2.2.5</jackrabbit.version>