import com.opensymphony.xwork2.Preparable;
import com.opensymphony.xwork2.Validateable;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.managed.ManagedRepository;
+import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
import org.apache.archiva.audit.AuditEvent;
import org.apache.archiva.audit.Auditable;
import org.apache.archiva.checksum.ChecksumAlgorithm;
import org.apache.archiva.metadata.repository.MetadataResolutionException;
import org.apache.archiva.metadata.repository.RepositorySession;
import org.apache.archiva.repository.events.RepositoryListener;
+import org.apache.archiva.security.AccessDeniedException;
+import org.apache.archiva.security.ArchivaSecurityException;
+import org.apache.archiva.security.PrincipalNotFoundException;
+import org.apache.archiva.security.UserRepositories;
import org.apache.commons.lang.StringUtils;
import org.apache.maven.archiva.common.utils.VersionComparator;
import org.apache.maven.archiva.common.utils.VersionUtil;
-import org.apache.maven.archiva.configuration.ArchivaConfiguration;
-import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.maven.archiva.model.ArchivaRepositoryMetadata;
import org.apache.maven.archiva.model.VersionedReference;
import org.apache.maven.archiva.repository.ContentNotFoundException;
import org.apache.maven.archiva.repository.metadata.RepositoryMetadataException;
import org.apache.maven.archiva.repository.metadata.RepositoryMetadataReader;
import org.apache.maven.archiva.repository.metadata.RepositoryMetadataWriter;
-import org.apache.archiva.security.AccessDeniedException;
-import org.apache.archiva.security.ArchivaSecurityException;
-import org.apache.archiva.security.PrincipalNotFoundException;
-import org.apache.archiva.security.UserRepositories;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
@Inject
private UserRepositories userRepositories;
- @Inject
- private ArchivaConfiguration configuration;
-
@Inject
private RepositoryContentFactory repositoryFactory;
@Inject
private List<RepositoryListener> listeners;
+ @Inject
+ private ManagedRepositoryAdmin managedRepositoryAdmin;
+
private ChecksumAlgorithm[] algorithms = new ChecksumAlgorithm[]{ ChecksumAlgorithm.SHA1, ChecksumAlgorithm.MD5 };
@PostConstruct
public String doDelete()
{
- Date lastUpdatedTimestamp = Calendar.getInstance().getTime();
-
- TimeZone timezone = TimeZone.getTimeZone( "UTC" );
- DateFormat fmt = new SimpleDateFormat( "yyyyMMdd.HHmmss" );
- fmt.setTimeZone( timezone );
- ManagedRepositoryConfiguration repoConfig =
- configuration.getConfiguration().findManagedRepositoryById( repositoryId );
-
- VersionedReference ref = new VersionedReference();
- ref.setArtifactId( artifactId );
- ref.setGroupId( groupId );
- ref.setVersion( version );
RepositorySession repositorySession = repositorySessionFactory.createSession();
try
{
+ Date lastUpdatedTimestamp = Calendar.getInstance().getTime();
+
+ TimeZone timezone = TimeZone.getTimeZone( "UTC" );
+ DateFormat fmt = new SimpleDateFormat( "yyyyMMdd.HHmmss" );
+ fmt.setTimeZone( timezone );
+ ManagedRepository repoConfig = getManagedRepositoryAdmin().getManagedRepository( repositoryId );
+
+ VersionedReference ref = new VersionedReference();
+ ref.setArtifactId( artifactId );
+ ref.setGroupId( groupId );
+ ref.setVersion( version );
ManagedRepositoryContent repository = repositoryFactory.getManagedRepositoryContent( repositoryId );
String path = repository.toMetadataPath( ref );
addActionError( "Repository exception: " + e.getMessage() );
return ERROR;
}
+ catch ( RepositoryAdminException e )
+ {
+ addActionError( "RepositoryAdmin exception: " + e.getMessage() );
+ return ERROR;
+ }
finally
{
repositorySession.close();
this.repositoryFactory = repositoryFactory;
}
- public void setConfiguration( ArchivaConfiguration configuration )
+ public ManagedRepositoryAdmin getManagedRepositoryAdmin()
+ {
+ return managedRepositoryAdmin;
+ }
+
+ public void setManagedRepositoryAdmin( ManagedRepositoryAdmin managedRepositoryAdmin )
{
- this.configuration = configuration;
+ this.managedRepositoryAdmin = managedRepositoryAdmin;
}
}
implements SecureAction, Auditable
{
- @Inject
- protected ArchivaConfiguration archivaConfiguration;
-
@Inject
private ManagedRepositoryAdmin managedRepositoryAdmin;
@Inject
private RepositoryCommonValidator repositoryCommonValidator;
- public ArchivaConfiguration getArchivaConfiguration()
- {
- return archivaConfiguration;
- }
public SecureActionBundle getSecureActionBundle()
throws SecureActionException
return bundle;
}
- public void setArchivaConfiguration( ArchivaConfiguration archivaConfiguration )
- {
- this.archivaConfiguration = archivaConfiguration;
- }
- /**
- * 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 InvalidConfigurationException thrown if configuration is invalid.
- * @throws RegistryException thrown if configuration subsystem has a problem saving the configuration to disk.
- */
- protected String saveConfiguration( Configuration configuration )
- {
- try
- {
- archivaConfiguration.save( configuration );
- addActionMessage( "Successfully saved configuration" );
- }
- catch ( IndeterminateConfigurationException e )
- {
- addActionError( e.getMessage() );
- return INPUT;
- }
- catch ( RegistryException e )
- {
- addActionError( "Configuration Registry Exception: " + e.getMessage() );
- return INPUT;
- }
-
- return SUCCESS;
- }
public ManagedRepositoryAdmin getManagedRepositoryAdmin()
{
import org.apache.archiva.admin.model.RepositoryAdminException;
import org.apache.archiva.admin.model.managed.ManagedRepository;
import org.apache.commons.lang.StringUtils;
-import org.apache.maven.archiva.configuration.Configuration;
-import org.codehaus.redback.components.scheduler.CronExpressionValidator;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
return result;
}
- // FIXME olamy dupe with admin repo component
@Override
public void validate()
{
- Configuration config = archivaConfiguration.getConfiguration();
-
- CronExpressionValidator validator = new CronExpressionValidator();
- String repoId = repository.getId();
-
- if ( config.getManagedRepositoriesAsMap().containsKey( repoId ) )
- {
- addFieldError( "repository.id", "Unable to add new repository with id [" + repoId
- + "], that id already exists as a managed repository." );
- }
- else if ( config.getRemoteRepositoriesAsMap().containsKey( 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 ) )
- {
- addFieldError( "repository.id", "Unable to add new repository with id [" + repoId
- + "], 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
- + "], repository id cannot contains word stage" );
- }
-
- if ( !validator.validate( repository.getCronExpression() ) )
- {
- addFieldError( "repository.refreshCronExpression", "Invalid cron expression." );
- }
-
// trim all unecessary trailing/leading white-spaces; always put this statement before the closing braces(after all validation).
trimAllRequestParameterValues();
}
import com.opensymphony.xwork2.Validateable;
import org.apache.archiva.admin.model.RepositoryAdminException;
import org.apache.archiva.admin.model.remote.RemoteRepository;
-import org.apache.maven.archiva.configuration.Configuration;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
return result;
}
- // FIXME olamy dupe with admin repo component
- @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
- + "], that id already exists as a managed repository." );
- }
- else if ( config.getRemoteRepositoriesAsMap().containsKey( 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 ) )
- {
- addFieldError( "repository.id", "Unable to add new repository with id [" + repoId
- + "], that id already exists as a repository group." );
- }
- }
public RemoteRepository getRepository()
{
import org.apache.archiva.admin.model.RepositoryAdminException;
import org.apache.archiva.admin.model.managed.ManagedRepository;
import org.apache.commons.lang.StringUtils;
-import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
import org.codehaus.redback.components.scheduler.CronExpressionValidator;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
return save( true );
}
- // FIXME olamy use ManagedRepositoryAdmin rather tha, directly archivaConfiguration
public String commit()
+ throws RepositoryAdminException
{
- ManagedRepositoryConfiguration existingConfig =
- archivaConfiguration.getConfiguration().findManagedRepositoryById( repository.getId() );
+ ManagedRepository existingConfig = getManagedRepositoryAdmin().getManagedRepository( repository.getId() );
boolean resetStats = false;
// check if the location was changed
import org.apache.archiva.metadata.repository.stats.RepositoryStatisticsManager;
import org.apache.archiva.security.common.ArchivaRoleConstants;
import org.apache.archiva.web.util.ContextUtils;
-import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.web.action.AbstractActionSupport;
import org.apache.struts2.interceptor.ServletRequestAware;
import org.codehaus.plexus.redback.rbac.Resource;
*/
import org.apache.commons.lang.StringUtils;
+import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.configuration.Configuration;
+import org.apache.maven.archiva.configuration.IndeterminateConfigurationException;
import org.apache.maven.archiva.configuration.RepositoryGroupConfiguration;
+import org.codehaus.plexus.registry.RegistryException;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
+import javax.inject.Inject;
import java.util.List;
/**
private String targetRepo;
+ @Inject
+ protected ArchivaConfiguration archivaConfiguration;
+
public String sortDown()
{
Configuration config = archivaConfiguration.getConfiguration();
return saveConfiguration( config );
}
+/**
+ * Save the configuration.
+ *
+ * @param configuration the configuration to save.
+ * @return the webwork result code to issue.
+ * @throws java.io.IOException thrown if unable to save file to disk.
+ * @throws org.apache.maven.archiva.configuration.InvalidConfigurationException thrown if configuration is invalid.
+ * @throws org.codehaus.plexus.registry.RegistryException thrown if configuration subsystem has a problem saving the configuration to disk.
+ */
+ protected String saveConfiguration( Configuration configuration )
+ {
+ try
+ {
+ archivaConfiguration.save( configuration );
+ addActionMessage( "Successfully saved configuration" );
+ }
+ catch ( IndeterminateConfigurationException e )
+ {
+ addActionError( e.getMessage() );
+ return INPUT;
+ }
+ catch ( RegistryException e )
+ {
+ addActionError( "Configuration Registry Exception: " + e.getMessage() );
+ return INPUT;
+ }
+
+ return SUCCESS;
+ }
+
public String getRepoGroupId()
{
return repoGroupId;
{
return ( idx >= 0 ) && ( idx < repositories.size() );
}
+
+ public ArchivaConfiguration getArchivaConfiguration()
+ {
+ return archivaConfiguration;
+ }
+
+ public void setArchivaConfiguration( ArchivaConfiguration archivaConfiguration )
+ {
+ this.archivaConfiguration = archivaConfiguration;
+ }
}
import net.sf.beanlib.provider.replicator.BeanReplicator;
import org.apache.archiva.admin.model.managed.ManagedRepository;
+import org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin;
import org.apache.archiva.metadata.model.ArtifactMetadata;
import org.apache.archiva.metadata.repository.MetadataRepository;
import org.apache.archiva.metadata.repository.RepositorySession;
repositorySessionFactory.setRepositorySession( repositorySession );
- action.setConfiguration( configuration );
+ (( DefaultManagedRepositoryAdmin)action.getManagedRepositoryAdmin()).setArchivaConfiguration( configuration );
action.setRepositoryFactory( repositoryFactory );
}
archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
- action.setArchivaConfiguration( archivaConfiguration );
roleManagerControl = MockControl.createControl( RoleManager.class );
roleManager = (RoleManager) roleManagerControl.getMock();
archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
- action.setArchivaConfiguration( archivaConfiguration );
+
( (DefaultRemoteRepositoryAdmin) action.getRemoteRepositoryAdmin() ).setArchivaConfiguration(
archivaConfiguration );
}
archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
- action.setArchivaConfiguration( archivaConfiguration );
roleManagerControl = MockControl.createControl( RoleManager.class );
roleManager = (RoleManager) roleManagerControl.getMock();
archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
- action.setArchivaConfiguration( archivaConfiguration );
( (DefaultRemoteRepositoryAdmin) action.getRemoteRepositoryAdmin() ).setArchivaConfiguration(
archivaConfiguration );
archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
- action.setArchivaConfiguration( archivaConfiguration );
( (DefaultRepositoryGroupAdmin) action.getRepositoryGroupAdmin() ).setArchivaConfiguration(
archivaConfiguration );
archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
- action.setArchivaConfiguration( archivaConfiguration );
roleManagerControl = MockControl.createControl( RoleManager.class );
roleManager = (RoleManager) roleManagerControl.getMock();
archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
- action.setArchivaConfiguration( archivaConfiguration );
( (DefaultRemoteRepositoryAdmin) action.getRemoteRepositoryAdmin() ).setArchivaConfiguration(
archivaConfiguration );
archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
- action.setArchivaConfiguration( archivaConfiguration );
+
( (DefaultRepositoryGroupAdmin) action.getRepositoryGroupAdmin() ).setArchivaConfiguration(
archivaConfiguration );
( (DefaultManagedRepositoryAdmin) ( (DefaultRepositoryGroupAdmin) action.getRepositoryGroupAdmin() ).getManagedRepositoryAdmin() ).setArchivaConfiguration(