archiva-modules/archiva-web/archiva-webapp-test/cargo-installs/
*.ipr
*.iws
+.DS_Store
* under the License.
*/
-import java.util.Date;
-
-import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
+import org.apache.archiva.admin.model.managed.ManagedRepository;
import org.apache.maven.archiva.consumers.AbstractMonitoredConsumer;
import org.apache.maven.archiva.consumers.ConsumerException;
import org.apache.maven.archiva.consumers.RepositoryContentConsumer;
+import java.util.Date;
+
/**
* AbstractProgressConsumer
*
{
private int count = 0;
- public void beginScan( ManagedRepositoryConfiguration repository, Date whenGathered )
+ public void beginScan( ManagedRepository repository, Date whenGathered )
throws ConsumerException
{
this.count = 0;
}
- public void beginScan( ManagedRepositoryConfiguration repository, Date whenGathered, boolean executeOnEntireRepo )
+ public void beginScan( ManagedRepository repository, Date whenGathered, boolean executeOnEntireRepo )
throws ConsumerException
{
beginScan( repository, whenGathered );
import com.sampullara.cli.Args;
import com.sampullara.cli.Argument;
+import org.apache.archiva.admin.model.managed.ManagedRepository;
import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException;
import org.apache.archiva.repository.scanner.RepositoryScanStatistics;
WagonManager wagonManager = plexusSisuBridge.lookup( WagonManager.class );
wagonManager.addMirror( "internal", "*", new File( path ).toURL().toExternalForm() );
- ManagedRepositoryConfiguration repo = new ManagedRepositoryConfiguration();
+ ManagedRepository repo = new ManagedRepository();
repo.setId( "cliRepo" );
repo.setName( "Archiva CLI Provided Repo" );
repo.setLocation( path );
--- /dev/null
+package org.apache.maven.archiva.common;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * @author Olivier Lamy
+ * @since 1.4
+ */
+public class FileTypeUtils
+{
+
+ /**
+ * Default exclusions from artifact consumers that are using the file types. Note that this is simplistic in the
+ * case of the support files (based on extension) as it is elsewhere - it may be better to match these to actual
+ * artifacts and exclude later during scanning.
+ */
+ public static final List<String> DEFAULT_EXCLUSIONS =
+ Arrays.asList( "**/maven-metadata.xml", "**/maven-metadata-*.xml", "**/*.sha1", "**/*.asc", "**/*.md5",
+ "**/*.pgp", "**/.index/**", "**/.indexer/**" );
+}
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.Predicate;
import org.apache.commons.configuration.CombinedConfiguration;
+import org.apache.maven.archiva.common.FileTypeUtils;
import org.apache.maven.archiva.configuration.functors.FiletypeSelectionPredicate;
import org.apache.maven.archiva.configuration.io.registry.ConfigurationRegistryReader;
import org.codehaus.plexus.registry.Registry;
* Default exclusions from artifact consumers that are using the file types. Note that this is simplistic in the
* case of the support files (based on extension) as it is elsewhere - it may be better to match these to actual
* artifacts and exclude later during scanning.
+ * @deprecated
*/
- public static final List<String> DEFAULT_EXCLUSIONS =
- Arrays.asList( "**/maven-metadata.xml", "**/maven-metadata-*.xml", "**/*.sha1", "**/*.asc", "**/*.md5",
- "**/*.pgp", "**/.index/**", "**/.indexer/**" );
+ public static final List<String> DEFAULT_EXCLUSIONS = FileTypeUtils.DEFAULT_EXCLUSIONS;
public void setArchivaConfiguration( ArchivaConfiguration archivaConfiguration )
{
<dependencies>
<dependency>
<groupId>org.apache.archiva</groupId>
- <artifactId>archiva-configuration</artifactId>
+ <artifactId>archiva-repository-admin-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>archiva-common</artifactId>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
* under the License.
*/
+import org.apache.maven.archiva.common.FileTypeUtils;
+
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
-import org.apache.maven.archiva.configuration.FileTypes;
-
/**
* AbstractMonitoredConsumer
*
protected List<String> getDefaultArtifactExclusions()
{
- return FileTypes.DEFAULT_EXCLUSIONS;
+ return FileTypeUtils.DEFAULT_EXCLUSIONS;
}
public interface InvalidRepositoryContentConsumer
extends RepositoryContentConsumer
{
-
+ // no op
}
* under the License.
*/
-import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
+import org.apache.archiva.admin.model.managed.ManagedRepository;
import java.util.Date;
import java.util.List;
* @param whenGathered the start of the repository scan
* @throws ConsumerException if there was a problem with using the provided repository with the consumer.
*/
- void beginScan( ManagedRepositoryConfiguration repository, Date whenGathered )
+ void beginScan( ManagedRepository repository, Date whenGathered )
throws ConsumerException;
/**
* @param whenGathered the start of the repository scan
* @param executeOnEntireRepo flags whether the consumer will be executed on an entire repository or just on a specific resource
* @throws ConsumerException if there was a problem with using the provided repository with the consumer.
- * @see RepositoryContentConsumer#beginScan(org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration, java.util.Date)
+ * @see RepositoryContentConsumer#beginScan(ManagedRepository, java.util.Date)
*/
- void beginScan( ManagedRepositoryConfiguration repository, Date whenGathered, boolean executeOnEntireRepo )
+ void beginScan( ManagedRepository repository, Date whenGathered, boolean executeOnEntireRepo )
throws ConsumerException;
/**
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-consumer-api</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>archiva-repository-admin-api</artifactId>
+ </dependency>
<dependency>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-repository-layer</artifactId>
<artifactId>mockito-all</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>archiva-repository-admin-default</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.redback</groupId>
+ <artifactId>redback-rbac-cached</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.derby</groupId>
+ <artifactId>derby</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <systemPropertyVariables>
+ <appserver.base>${basedir}/target/appserver-base</appserver.base>
+ <plexus.home>${project.build.outputDirectory}</plexus.home>
+ <java.io.tmpdir>${project.build.outputDirectory}</java.io.tmpdir>
+ </systemPropertyVariables>
+ </configuration>
+ </plugin>
<plugin>
<groupId>org.apache.rat</groupId>
<artifactId>apache-rat-plugin</artifactId>
* under the License.
*/
+import org.apache.archiva.admin.model.managed.ManagedRepository;
import org.apache.archiva.checksum.ChecksumAlgorithm;
import org.apache.archiva.checksum.ChecksummedFile;
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.configuration.ConfigurationNames;
import org.apache.maven.archiva.configuration.FileTypes;
-import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.maven.archiva.consumers.AbstractMonitoredConsumer;
import org.apache.maven.archiva.consumers.ConsumerException;
import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
return false;
}
- public void beginScan( ManagedRepositoryConfiguration repo, Date whenGathered )
+ public void beginScan( ManagedRepository repo, Date whenGathered )
throws ConsumerException
{
this.repositoryDir = new File( repo.getLocation() );
}
- public void beginScan( ManagedRepositoryConfiguration repo, Date whenGathered, boolean executeOnEntireRepo )
+ public void beginScan( ManagedRepository repo, Date whenGathered, boolean executeOnEntireRepo )
throws ConsumerException
{
beginScan( repo, whenGathered );
* under the License.
*/
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.lang.StringUtils;
+import org.apache.archiva.admin.model.managed.ManagedRepository;
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.configuration.ConfigurationNames;
import org.apache.maven.archiva.configuration.FileTypes;
-import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.maven.archiva.consumers.AbstractMonitoredConsumer;
import org.apache.maven.archiva.consumers.ConsumerException;
import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
return false;
}
- public void beginScan( ManagedRepositoryConfiguration repository, Date whenGathered )
+ public void beginScan( ManagedRepository repository, Date whenGathered )
throws ConsumerException
{
this.repositoryDir = new File( repository.getLocation() );
}
- public void beginScan( ManagedRepositoryConfiguration repository, Date whenGathered, boolean executeOnEntireRepo )
+ public void beginScan( ManagedRepository repository, Date whenGathered, boolean executeOnEntireRepo )
throws ConsumerException
{
beginScan( repository, whenGathered );
* under the License.
*/
+import org.apache.archiva.admin.model.managed.ManagedRepository;
import org.apache.commons.io.FileUtils;
-import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.maven.archiva.consumers.AbstractMonitoredConsumer;
import org.apache.maven.archiva.consumers.ConsumerException;
import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
return false;
}
- public void beginScan( ManagedRepositoryConfiguration repository, Date whenGathered )
+ public void beginScan( ManagedRepository repository, Date whenGathered )
throws ConsumerException
{
this.repositoryDir = new File( repository.getLocation() );
}
- public void beginScan( ManagedRepositoryConfiguration repository, Date whenGathered, boolean executeOnEntireRepo )
+ public void beginScan( ManagedRepository repository, Date whenGathered, boolean executeOnEntireRepo )
throws ConsumerException
{
beginScan( repository, whenGathered );
* under the License.
*/
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
+import org.apache.archiva.admin.model.managed.ManagedRepository;
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.configuration.ConfigurationNames;
import org.apache.maven.archiva.configuration.FileTypes;
-import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.maven.archiva.consumers.AbstractMonitoredConsumer;
import org.apache.maven.archiva.consumers.ConsumerException;
import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
/**
* MetadataUpdaterConsumer will create and update the metadata present within the repository.
this.includes = includes;
}
- public void beginScan( ManagedRepositoryConfiguration repoConfig, Date whenGathered )
+ public void beginScan( ManagedRepository repoConfig, Date whenGathered )
throws ConsumerException
{
try
}
}
- public void beginScan( ManagedRepositoryConfiguration repository, Date whenGathered, boolean executeOnEntireRepo )
+ public void beginScan( ManagedRepository repository, Date whenGathered, boolean executeOnEntireRepo )
throws ConsumerException
{
beginScan( repository, whenGathered );
* under the License.
*/
+import org.apache.archiva.admin.model.managed.ManagedRepository;
import org.apache.archiva.common.plexusbridge.DigesterUtils;
import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException;
-import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.maven.archiva.consumers.AbstractMonitoredConsumer;
import org.apache.maven.archiva.consumers.ConsumerException;
import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
-import java.util.Iterator;
import java.util.List;
/**
return false;
}
- public void beginScan( ManagedRepositoryConfiguration repository, Date whenGathered )
+ public void beginScan( ManagedRepository repository, Date whenGathered )
throws ConsumerException
{
this.repositoryDir = new File( repository.getLocation() );
}
- public void beginScan( ManagedRepositoryConfiguration repository, Date whenGathered, boolean executeOnEntireRepo )
+ public void beginScan( ManagedRepository repository, Date whenGathered, boolean executeOnEntireRepo )
throws ConsumerException
{
beginScan( repository, whenGathered );
* under the License.
*/
+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.metadata.repository.MetadataRepository;
import org.apache.archiva.metadata.repository.RepositorySession;
import org.apache.archiva.repository.events.RepositoryListener;
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.ArchivaArtifact;
import org.apache.maven.archiva.model.ArtifactReference;
import org.apache.maven.archiva.model.ProjectReference;
* This will look in a single managed repository, and purge any snapshots that are present
* that have a corresponding released version on the same repository.
* </p>
- *
+ * <p/>
* <p>
* So, if you have the following (presented in the m2/default layout form) ...
* <pre>
{
private MetadataTools metadataTools;
- private ArchivaConfiguration archivaConfig;
+ private ManagedRepositoryAdmin managedRepositoryAdmin;
private RepositoryContentFactory repoContentFactory;
public CleanupReleasedSnapshotsRepositoryPurge( ManagedRepositoryContent repository, MetadataTools metadataTools,
- ArchivaConfiguration archivaConfig,
+ ManagedRepositoryAdmin managedRepositoryAdmin,
RepositoryContentFactory repoContentFactory,
RepositorySession repositorySession,
List<RepositoryListener> listeners )
{
super( repository, repositorySession, listeners );
this.metadataTools = metadataTools;
- this.archivaConfig = archivaConfig;
+ this.managedRepositoryAdmin = managedRepositoryAdmin;
this.repoContentFactory = repoContentFactory;
}
// Gather up all of the versions.
List<String> allVersions = new ArrayList<String>( repository.getVersions( reference ) );
- List<ManagedRepositoryConfiguration> repos = archivaConfig.getConfiguration().getManagedRepositories();
- for ( ManagedRepositoryConfiguration repo : repos )
+ List<ManagedRepository> repos = managedRepositoryAdmin.getManagedRepositories();
+ for ( ManagedRepository repo : repos )
{
if ( repo.isReleases() && !repo.getId().equals( repository.getId() ) )
{
try
{
- ManagedRepositoryContent repoContent = repoContentFactory.getManagedRepositoryContent(
- repo.getId() );
+ ManagedRepositoryContent repoContent =
+ repoContentFactory.getManagedRepositoryContent( repo.getId() );
allVersions.addAll( repoContent.getVersions( reference ) );
}
catch ( RepositoryNotFoundException e )
versionRef.setGroupId( artifactRef.getGroupId() );
versionRef.setArtifactId( artifactRef.getArtifactId() );
- ArchivaArtifact artifact = new ArchivaArtifact( artifactRef.getGroupId(), artifactRef.getArtifactId(),
- artifactRef.getVersion(), artifactRef.getClassifier(),
- artifactRef.getType(), repository.getId() );
+ ArchivaArtifact artifact =
+ new ArchivaArtifact( artifactRef.getGroupId(), artifactRef.getArtifactId(), artifactRef.getVersion(),
+ artifactRef.getClassifier(), artifactRef.getType(), repository.getId() );
MetadataRepository metadataRepository = repositorySession.getRepository();
for ( String version : snapshotVersions )
{
updateMetadata( artifactRef );
}
+ } catch ( RepositoryAdminException e )
+ {
+ throw new RepositoryPurgeException( e.getMessage(), e );
}
catch ( LayoutException e )
{
* under the License.
*/
+import org.apache.archiva.admin.model.managed.ManagedRepository;
+import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
import org.apache.archiva.metadata.repository.RepositorySession;
import org.apache.archiva.metadata.repository.RepositorySessionFactory;
import org.apache.archiva.repository.events.RepositoryListener;
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.configuration.ConfigurationNames;
import org.apache.maven.archiva.configuration.FileTypes;
-import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.maven.archiva.consumers.AbstractMonitoredConsumer;
import org.apache.maven.archiva.consumers.ConsumerException;
import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
import org.apache.maven.archiva.repository.metadata.MetadataTools;
import org.codehaus.plexus.registry.Registry;
import org.codehaus.plexus.registry.RegistryListener;
-import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
@Named( value = "archivaConfiguration#default" )
private ArchivaConfiguration configuration;
+ @Inject
+ private ManagedRepositoryAdmin managedRepositoryAdmin;
+
/**
*
*/
@Inject
- @Named(value = "repositoryContentFactory#default")
+ @Named( value = "repositoryContentFactory#default" )
private RepositoryContentFactory repositoryContentFactory;
/**
*
*/
@Inject
- @Named(value = "fileTypes")
+ @Named( value = "fileTypes" )
private FileTypes filetypes;
private List<String> includes = new ArrayList<String>();
/**
* TODO: this could be multiple implementations and needs to be configured.
- *
*/
@Inject
private RepositorySessionFactory repositorySessionFactory;
return this.includes;
}
- public void beginScan( ManagedRepositoryConfiguration repository, Date whenGathered )
+ public void beginScan( ManagedRepository repository, Date whenGathered )
throws ConsumerException
{
ManagedRepositoryContent repositoryContent;
listeners );
}
- cleanUp = new CleanupReleasedSnapshotsRepositoryPurge( repositoryContent, metadataTools, configuration,
+ cleanUp = new CleanupReleasedSnapshotsRepositoryPurge( repositoryContent, metadataTools, managedRepositoryAdmin,
repositoryContentFactory, repositorySession, listeners );
deleteReleasedSnapshots = repository.isDeleteReleasedSnapshots();
}
- public void beginScan( ManagedRepositoryConfiguration repository, Date whenGathered, boolean executeOnEntireRepo )
+ public void beginScan( ManagedRepository repository, Date whenGathered, boolean executeOnEntireRepo )
throws ConsumerException
{
beginScan( repository, whenGathered );
--- /dev/null
+package org.apache.archiva.metadata.repository;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.metadata.model.ArtifactMetadata;
+import org.apache.archiva.metadata.model.MetadataFacet;
+import org.apache.archiva.metadata.model.ProjectMetadata;
+import org.apache.archiva.metadata.model.ProjectVersionMetadata;
+import org.apache.archiva.metadata.model.ProjectVersionReference;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+
+public class TestMetadataRepository
+ implements MetadataRepository
+{
+ public ProjectMetadata getProject( String repoId, String namespace, String projectId )
+ {
+ return null;
+ }
+
+ public ProjectVersionMetadata getProjectVersion( String repoId, String namespace, String projectId,
+ String projectVersion )
+ {
+ return null;
+ }
+
+ public Collection<String> getArtifactVersions( String repoId, String namespace, String projectId,
+ String projectVersion )
+ {
+ return null;
+ }
+
+ public Collection<ProjectVersionReference> getProjectReferences( String repoId, String namespace, String projectId,
+ String projectVersion )
+ {
+ return null;
+ }
+
+ public Collection<String> getRootNamespaces( String repoId )
+ {
+ return null;
+ }
+
+ public Collection<String> getNamespaces( String repoId, String namespace )
+ {
+ return null;
+ }
+
+ public Collection<String> getProjects( String repoId, String namespace )
+ {
+ return null;
+ }
+
+ public Collection<String> getProjectVersions( String repoId, String namespace, String projectId )
+ {
+ return null;
+ }
+
+ public void updateProject( String repoId, ProjectMetadata project )
+ {
+ }
+
+ public void updateArtifact( String repoId, String namespace, String projectId, String projectVersion,
+ ArtifactMetadata artifactMeta )
+ {
+
+ }
+
+ public void updateProjectVersion( String repoId, String namespace, String projectId,
+ ProjectVersionMetadata versionMetadata )
+ {
+
+ }
+
+ public void updateNamespace( String repoId, String namespace )
+ {
+
+ }
+
+ public List<String> getMetadataFacets( String repodId, String facetId )
+ {
+ return Collections.emptyList();
+ }
+
+ public MetadataFacet getMetadataFacet( String repositoryId, String facetId, String name )
+ {
+ return null;
+ }
+
+ public void addMetadataFacet( String repositoryId, MetadataFacet metadataFacet )
+ {
+
+ }
+
+ public void removeMetadataFacets( String repositoryId, String facetId )
+ {
+
+ }
+
+ public void removeMetadataFacet( String repoId, String facetId, String name )
+ {
+
+ }
+
+ public List<ArtifactMetadata> getArtifactsByDateRange( String repoId, Date startTime, Date endTime )
+ {
+ return null;
+ }
+
+ public Collection<String> getRepositories()
+ {
+ return null;
+ }
+
+ public List<ArtifactMetadata> getArtifactsByChecksum( String repoId, String checksum )
+ {
+ return null;
+ }
+
+ public void removeArtifact( String repositoryId, String namespace, String project, String version, String id )
+ {
+
+ }
+
+ public void removeRepository( String repoId )
+ {
+
+ }
+
+ public Collection<ArtifactMetadata> getArtifacts( String repoId, String namespace, String projectId,
+ String projectVersion )
+ {
+ return null;
+ }
+
+ public void save()
+ {
+
+ }
+
+ public void close()
+ {
+
+ }
+
+ public void revert()
+ {
+
+ }
+
+ public boolean canObtainAccess( Class<?> aClass )
+ {
+ return false;
+ }
+
+ public Object obtainAccess( Class<?> aClass )
+ {
+ return null;
+ }
+
+ public List<ArtifactMetadata> getArtifacts( String repositoryId )
+ {
+ return null;
+ }
+}
* specific language governing permissions and limitations
* under the License.
*/
-@Service("repositorySessionFactory#test")
+@Service( "repositorySessionFactory#test" )
public class TestRepositorySessionFactory
implements RepositorySessionFactory
{
public RepositorySession createSession()
{
- return new RepositorySession( repository, resolver );
+ return new RepositorySession( new TestMetadataRepository(), resolver )
+ {
+ @Override
+ public void close()
+ {
+ return;
+ }
+ };
}
public void setRepository( MetadataRepository repository )
package org.apache.maven.archiva.consumers.core;
+import org.apache.archiva.admin.model.managed.ManagedRepository;
import org.apache.archiva.checksum.ChecksumAlgorithm;
import org.apache.archiva.checksum.ChecksummedFile;
import org.apache.commons.io.FileUtils;
-import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
import org.junit.Before;
import org.junit.Test;
public class ArtifactMissingChecksumsConsumerTest
extends AbstractArtifactConsumerTest
{
- private ManagedRepositoryConfiguration repoConfig;
+ private ManagedRepository repoConfig;
@Before
public void setUp()
{
super.setUp();
- repoConfig = new ManagedRepositoryConfiguration();
+ repoConfig = new ManagedRepository();
repoConfig.setId( "test-repo" );
repoConfig.setName( "Test Repository" );
repoConfig.setLayout( "default" );
*/
import junit.framework.TestCase;
+import org.apache.archiva.admin.model.managed.ManagedRepository;
import org.apache.archiva.metadata.repository.MetadataRepository;
import org.apache.archiva.metadata.repository.RepositorySession;
import org.apache.archiva.repository.events.RepositoryListener;
protected static final String RELEASES_TEST_REPO_NAME = "Releases Test Repo One";
- private ManagedRepositoryConfiguration config;
+ private ManagedRepository config;
private ManagedRepositoryContent repo;
repo = null;
}
- public ManagedRepositoryConfiguration getRepoConfiguration( String repoId, String repoName )
+ public ManagedRepository getRepoConfiguration( String repoId, String repoName )
{
- config = new ManagedRepositoryConfiguration();
+ config = new ManagedRepository();
config.setId( repoId );
config.setName( repoName );
config.setDaysOlder( TEST_DAYS_OLDER );
* under the License.
*/
+import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
+import org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin;
import org.apache.archiva.repository.events.RepositoryListener;
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.repository.RepositoryContentFactory;
import org.apache.maven.archiva.repository.metadata.MetadataTools;
import org.custommonkey.xmlunit.XMLAssert;
super.setUp();
RepositoryContentFactory factory =
- applicationContext.getBean( "repositoryContentFactory#cleanup-released-snapshots", RepositoryContentFactory.class );
+ applicationContext.getBean( "repositoryContentFactory#cleanup-released-snapshots",
+ RepositoryContentFactory.class );
archivaConfiguration =
applicationContext.getBean( "archivaConfiguration#cleanup-released-snapshots", ArchivaConfiguration.class );
listener = (RepositoryListener) listenerControl.getMock();
List<RepositoryListener> listeners = Collections.singletonList( listener );
- repoPurge =
- new CleanupReleasedSnapshotsRepositoryPurge( getRepository(), metadataTools, archivaConfiguration, factory,
- repositorySession, listeners );
+ repoPurge = new CleanupReleasedSnapshotsRepositoryPurge( getRepository(), metadataTools,
+ applicationContext.getBean(
+ ManagedRepositoryAdmin.class ), factory,
+ repositorySession, listeners );
+
+ ( (DefaultManagedRepositoryAdmin) applicationContext.getBean(
+ ManagedRepositoryAdmin.class ) ).setArchivaConfiguration( archivaConfiguration );
}
@Test
public void testReleasedSnapshotsExistsInSameRepo()
throws Exception
{
- Configuration config = archivaConfiguration.getConfiguration();
- config.removeManagedRepository( config.findManagedRepositoryById( TEST_REPO_ID ) );
- config.addManagedRepository( getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME ) );
+ /**
+ Configuration config = archivaConfiguration.getConfiguration();
+ config.removeManagedRepository( config.findManagedRepositoryById( TEST_REPO_ID ) );
+ config.addManagedRepository( getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME ) );
+ **/
+
+ applicationContext.getBean( ManagedRepositoryAdmin.class ).deleteManagedRepository( TEST_REPO_ID, null, false );
+ applicationContext.getBean( ManagedRepositoryAdmin.class ).addManagedRepository(
+ getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME ), false, null );
String repoRoot = prepareTestRepos();
public void testNonArtifactFile()
throws Exception
{
- Configuration config = archivaConfiguration.getConfiguration();
+ /*Configuration config = archivaConfiguration.getConfiguration();
config.removeManagedRepository( config.findManagedRepositoryById( TEST_REPO_ID ) );
- config.addManagedRepository( getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME ) );
+ config.addManagedRepository( getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME ) );*/
+
+ applicationContext.getBean( ManagedRepositoryAdmin.class ).deleteManagedRepository( TEST_REPO_ID, null, false );
+ applicationContext.getBean( ManagedRepositoryAdmin.class ).addManagedRepository(
+ getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME ), false, null );
String repoRoot = prepareTestRepos();
listenerControl.replay();
File file = new File( repoRoot, INDEX_PATH );
- if (!file.exists())
+ if ( !file.exists() )
{
// help windauze to create directory with .
file.getParentFile().mkdirs();
public void testReleasedSnapshotsExistsInDifferentRepo()
throws Exception
{
+ /*
Configuration config = archivaConfiguration.getConfiguration();
config.removeManagedRepository( config.findManagedRepositoryById( TEST_REPO_ID ) );
config.addManagedRepository( getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME ) );
config.addManagedRepository( getRepoConfiguration( RELEASES_TEST_REPO_ID, RELEASES_TEST_REPO_NAME ) );
+ */
+ applicationContext.getBean( ManagedRepositoryAdmin.class ).deleteManagedRepository( TEST_REPO_ID, null, false );
+ applicationContext.getBean( ManagedRepositoryAdmin.class ).addManagedRepository(
+ getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME ), false, null );
+
+ applicationContext.getBean( ManagedRepositoryAdmin.class ).addManagedRepository(
+ getRepoConfiguration( RELEASES_TEST_REPO_ID, RELEASES_TEST_REPO_NAME ), false, null );
String repoRoot = prepareTestRepos();
public void testHigherSnapshotExistsInSameRepo()
throws Exception
{
+ /*
Configuration config = archivaConfiguration.getConfiguration();
config.removeManagedRepository( config.findManagedRepositoryById( TEST_REPO_ID ) );
config.addManagedRepository( getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME ) );
+ */
+ applicationContext.getBean( ManagedRepositoryAdmin.class ).deleteManagedRepository( TEST_REPO_ID, null, false );
+ applicationContext.getBean( ManagedRepositoryAdmin.class ).addManagedRepository(
+ getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME ), false, null );
String repoRoot = prepareTestRepos();
* under the License.
*/
+import org.apache.archiva.admin.model.managed.ManagedRepository;
import org.apache.archiva.repository.events.RepositoryListener;
import org.apache.commons.lang.time.DateUtils;
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
public void testByLastModified()
throws Exception
{
- ManagedRepositoryConfiguration repoConfiguration = getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME );
+ ManagedRepository repoConfiguration = getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME );
repoPurge = new DaysOldRepositoryPurge( getRepository(), repoConfiguration.getDaysOlder(),
repoConfiguration.getRetentionCount(), repositorySession,
Collections.singletonList( listener ) );
public void testOrderOfDeletion()
throws Exception
{
- ManagedRepositoryConfiguration repoConfiguration = getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME );
+ ManagedRepository repoConfiguration = getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME );
List<RepositoryListener> listeners = Collections.singletonList( listener );
repoPurge = new DaysOldRepositoryPurge( getRepository(), repoConfiguration.getDaysOlder(),
repoConfiguration.getRetentionCount(), repositorySession, listeners );
public void testMetadataDrivenSnapshots()
throws Exception
{
- ManagedRepositoryConfiguration repoConfiguration = getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME );
+ ManagedRepository repoConfiguration = getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME );
List<RepositoryListener> listeners = Collections.singletonList( listener );
repoPurge = new DaysOldRepositoryPurge( getRepository(), repoConfiguration.getDaysOlder(),
repoConfiguration.getRetentionCount(), repositorySession, listeners );
* under the License.
*/
+import org.apache.archiva.admin.model.managed.ManagedRepository;
+import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
+import org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin;
import org.apache.archiva.metadata.repository.TestRepositorySessionFactory;
import org.apache.commons.io.FileUtils;
import org.apache.maven.archiva.common.utils.BaseFile;
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
-import org.apache.maven.archiva.configuration.Configuration;
import org.apache.maven.archiva.configuration.FileType;
import org.apache.maven.archiva.configuration.FileTypes;
-import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
import org.apache.maven.archiva.consumers.functors.ConsumerWantsFilePredicate;
import org.custommonkey.xmlunit.XMLAssert;
public class RepositoryPurgeConsumerTest
extends AbstractRepositoryPurgeTest
{
+ @Before
+ public void setUp()
+ throws Exception
+ {
+ super.setUp();
+
+ TestRepositorySessionFactory factory = applicationContext.getBean( TestRepositorySessionFactory.class );
+ factory.setRepository( metadataRepository );
+ }
+
@Test
public void testConsumption()
throws Exception
applicationContext.getBean( "knownRepositoryContentConsumer#repo-purge-consumer-by-retention-count",
KnownRepositoryContentConsumer.class );
- ManagedRepositoryConfiguration repoConfiguration = getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME );
+ ManagedRepository repoConfiguration = getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME );
repoConfiguration.setDaysOlder( 0 ); // force days older off to allow retention count purge to execute.
repoConfiguration.setRetentionCount( TEST_RETENTION_COUNT );
addRepoToConfiguration( "retention-count", repoConfiguration );
removeRepoFromConfiguration( "retention-count", repoConfiguration );
}
- private void addRepoToConfiguration( String configHint, ManagedRepositoryConfiguration repoConfiguration )
+ private void addRepoToConfiguration( String configHint, ManagedRepository repoConfiguration )
throws Exception
{
ArchivaConfiguration archivaConfiguration =
applicationContext.getBean( "archivaConfiguration#" + configHint, ArchivaConfiguration.class );
- Configuration configuration = archivaConfiguration.getConfiguration();
- ManagedRepositoryConfiguration managedRepositoryConfiguration =
- configuration.findManagedRepositoryById( repoConfiguration.getId() );
- if ( managedRepositoryConfiguration != null )
+ ( (DefaultManagedRepositoryAdmin) applicationContext.getBean(
+ ManagedRepositoryAdmin.class ) ).setArchivaConfiguration( archivaConfiguration );
+ /**
+ Configuration configuration = archivaConfiguration.getConfiguration();
+ ManagedRepositoryConfiguration managedRepositoryConfiguration =
+ configuration.findManagedRepositoryById( repoConfiguration.getId() );
+ if ( managedRepositoryConfiguration != null )
+ {
+ configuration.removeManagedRepository( managedRepositoryConfiguration );
+ }
+ configuration.addManagedRepository( repoConfiguration );
+ **/
+ ManagedRepositoryAdmin managedRepositoryAdmin = applicationContext.getBean( ManagedRepositoryAdmin.class );
+ if ( managedRepositoryAdmin.getManagedRepository( repoConfiguration.getId() ) != null )
{
- configuration.removeManagedRepository( managedRepositoryConfiguration );
+ managedRepositoryAdmin.deleteManagedRepository( repoConfiguration.getId(), null, false );
}
- configuration.addManagedRepository( repoConfiguration );
+ managedRepositoryAdmin.addManagedRepository( repoConfiguration, false, null );
}
- private void removeRepoFromConfiguration( String configHint, ManagedRepositoryConfiguration repoConfiguration )
+ private void removeRepoFromConfiguration( String configHint, ManagedRepository repoConfiguration )
throws Exception
{
ArchivaConfiguration archivaConfiguration =
applicationContext.getBean( "archivaConfiguration#" + configHint, ArchivaConfiguration.class );
- Configuration configuration = archivaConfiguration.getConfiguration();
- ManagedRepositoryConfiguration managedRepositoryConfiguration =
- configuration.findManagedRepositoryById( repoConfiguration.getId() );
- if ( managedRepositoryConfiguration != null )
+
+ ( (DefaultManagedRepositoryAdmin) applicationContext.getBean(
+ ManagedRepositoryAdmin.class ) ).setArchivaConfiguration( archivaConfiguration );
+ /**
+ Configuration configuration = archivaConfiguration.getConfiguration();
+ ManagedRepositoryConfiguration managedRepositoryConfiguration =
+ configuration.findManagedRepositoryById( repoConfiguration.getId() );
+ if ( managedRepositoryConfiguration != null )
+ {
+ configuration.removeManagedRepository( managedRepositoryConfiguration );
+ }*/
+ ManagedRepositoryAdmin managedRepositoryAdmin = applicationContext.getBean( ManagedRepositoryAdmin.class );
+ if ( managedRepositoryAdmin.getManagedRepository( repoConfiguration.getId() ) != null )
{
- configuration.removeManagedRepository( managedRepositoryConfiguration );
+ managedRepositoryAdmin.deleteManagedRepository( repoConfiguration.getId(), null, true );
}
}
applicationContext.getBean( "knownRepositoryContentConsumer#repo-purge-consumer-by-days-old",
KnownRepositoryContentConsumer.class );
- ManagedRepositoryConfiguration repoConfiguration = getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME );
+ ManagedRepository repoConfiguration = getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME );
repoConfiguration.setDaysOlder( TEST_DAYS_OLDER );
addRepoToConfiguration( "days-old", repoConfiguration );
applicationContext.getBean( "knownRepositoryContentConsumer#repo-purge-consumer-by-retention-count",
KnownRepositoryContentConsumer.class );
- ManagedRepositoryConfiguration repoConfiguration = getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME );
+ ManagedRepository repoConfiguration = getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME );
repoConfiguration.setDeleteReleasedSnapshots( false ); // Set to NOT delete released snapshots.
addRepoToConfiguration( "retention-count", repoConfiguration );
applicationContext.getBean( "knownRepositoryContentConsumer#repo-purge-consumer-by-days-old",
KnownRepositoryContentConsumer.class );
- ManagedRepositoryConfiguration repoConfiguration = getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME );
+ ManagedRepository repoConfiguration = getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME );
repoConfiguration.setDeleteReleasedSnapshots( true );
addRepoToConfiguration( "days-old", repoConfiguration );
removeRepoFromConfiguration( "days-old", repoConfiguration );
}
-
- @Before
- public void setUp()
- throws Exception
- {
- super.setUp();
-
- TestRepositorySessionFactory factory = applicationContext.getBean( TestRepositorySessionFactory.class );
- factory.setRepository( metadataRepository );
- }
}
* under the License.
*/
+import org.apache.archiva.admin.model.managed.ManagedRepository;
import org.apache.archiva.repository.events.RepositoryListener;
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
import org.junit.Before;
{
super.setUp();
- ManagedRepositoryConfiguration repoConfiguration = getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME );
+ ManagedRepository repoConfiguration = getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME );
List<RepositoryListener> listeners = Collections.singletonList( listener );
repoPurge = new RetentionCountRepositoryPurge( getRepository(), repoConfiguration.getRetentionCount(),
repositorySession, listeners );
--- /dev/null
+<redback-role-model>
+ <modelVersion>1.0.0</modelVersion>
+ <applications>
+ <application>
+ <id>System</id>
+ <description>Roles that apply system-wide, across all of the applications</description>
+ <version>1.0.0</version>
+ <resources>
+ <resource>
+ <id>global</id>
+ <name>*</name>
+ <permanent>true</permanent>
+ <description>global resource implies full access for authorization</description>
+ </resource>
+ <resource>
+ <id>username</id>
+ <name>${username}</name>
+ <permanent>true</permanent>
+ <description>replaced with the username of the principal at authorization check time</description>
+ </resource>
+ </resources>
+ <operations>
+ <operation>
+ <id>configuration-edit</id>
+ <name>configuration-edit</name>
+ <description>edit configuration</description>
+ <permanent>true</permanent>
+ </operation>
+ <operation>
+ <id>user-management-user-create</id>
+ <name>user-management-user-create</name>
+ <description>create user</description>
+ <permanent>true</permanent>
+ </operation>
+ <operation>
+ <id>user-management-user-edit</id>
+ <name>user-management-user-edit</name>
+ <description>edit user</description>
+ <permanent>true</permanent>
+ </operation>
+ <operation>
+ <id>user-management-user-role</id>
+ <name>user-management-user-role</name>
+ <description>user roles</description>
+ <permanent>true</permanent>
+ </operation>
+ <operation>
+ <id>user-management-user-delete</id>
+ <name>user-management-user-delete</name>
+ <description>delete user</description>
+ <permanent>true</permanent>
+ </operation>
+ <operation>
+ <id>user-management-user-list</id>
+ <name>user-management-user-list</name>
+ <description>list users</description>
+ <permanent>true</permanent>
+ </operation>
+ <operation>
+ <id>user-management-role-grant</id>
+ <name>user-management-role-grant</name>
+ <description>grant role</description>
+ <permanent>true</permanent>
+ </operation>
+ <operation>
+ <id>user-management-role-drop</id>
+ <name>user-management-role-drop</name>
+ <description>drop role</description>
+ <permanent>true</permanent>
+ </operation>
+ <operation>
+ <id>user-management-rbac-admin</id>
+ <name>user-management-rbac-admin</name>
+ <description>administer rbac</description>
+ <permanent>true</permanent>
+ </operation>
+ <operation>
+ <id>guest-access</id>
+ <name>guest-access</name>
+ <description>access guest</description>
+ <permanent>true</permanent>
+ </operation>
+ <operation>
+ <id>user-management-manage-data</id>
+ <name>user-management-manage-data</name>
+ <description>manage data</description>
+ <permanent>true</permanent>
+ </operation>
+ </operations>
+ <roles>
+ <role>
+ <id>system-administrator</id>
+ <name>System Administrator</name>
+ <permanent>true</permanent>
+ <assignable>true</assignable>
+ <permissions>
+ <permission>
+ <id>edit-redback-configuration</id>
+ <name>Edit Redback Configuration</name>
+ <operation>configuration-edit</operation>
+ <resource>global</resource>
+ <permanent>true</permanent>
+ </permission>
+ <permission>
+ <id>manage-rbac-setup</id>
+ <name>User RBAC Management</name>
+ <operation>user-management-rbac-admin</operation>
+ <resource>global</resource>
+ <permanent>true</permanent>
+ </permission>
+ <permission>
+ <id>manage-rbac-data</id>
+ <name>RBAC Manage Data</name>
+ <operation>user-management-manage-data</operation>
+ <resource>global</resource>
+ <permanent>true</permanent>
+ </permission>
+ </permissions>
+ <childRoles>
+ <childRole>user-administrator</childRole>
+ </childRoles>
+ </role>
+ <role>
+ <id>user-administrator</id>
+ <name>User Administrator</name>
+ <permanent>true</permanent>
+ <assignable>true</assignable>
+ <permissions>
+ <permission>
+ <id>drop-roles-for-anyone</id>
+ <name>Drop Roles for Anyone</name>
+ <operation>user-management-role-drop</operation>
+ <resource>global</resource>
+ <permanent>true</permanent>
+ </permission>
+ <permission>
+ <id>grant-roles-for-anyone</id>
+ <name>Grant Roles for Anyone</name>
+ <operation>user-management-role-grant</operation>
+ <resource>global</resource>
+ <permanent>true</permanent>
+ </permission>
+ <permission>
+ <id>user-create</id>
+ <name>Create Users</name>
+ <operation>user-management-user-create</operation>
+ <resource>global</resource>
+ <permanent>true</permanent>
+ </permission>
+ <permission>
+ <id>user-delete</id>
+ <name>Delete Users</name>
+ <operation>user-management-user-delete</operation>
+ <resource>global</resource>
+ <permanent>true</permanent>
+ </permission>
+ <permission>
+ <id>user-edit</id>
+ <name>Edit Users</name>
+ <operation>user-management-user-edit</operation>
+ <resource>global</resource>
+ <permanent>true</permanent>
+ </permission>
+ <permission>
+ <id>access-users-roles</id>
+ <name>Access Users Roles</name>
+ <operation>user-management-user-role</operation>
+ <resource>global</resource>
+ <permanent>true</permanent>
+ </permission>
+ <permission>
+ <id>access-user-list</id>
+ <name>Access User List</name>
+ <operation>user-management-user-list</operation>
+ <resource>global</resource>
+ <permanent>true</permanent>
+ </permission>
+ </permissions>
+ </role>
+ <role>
+ <id>registered-user</id>
+ <name>Registered User</name>
+ <permanent>true</permanent>
+ <assignable>true</assignable>
+ <permissions>
+ <permission>
+ <id>edit-user-by-username</id>
+ <name>Edit User Data by Username</name>
+ <operation>user-management-user-edit</operation>
+ <resource>username</resource>
+ <permanent>true</permanent>
+ </permission>
+ </permissions>
+ </role>
+ <role>
+ <id>guest</id>
+ <name>Guest</name>
+ <permanent>true</permanent>
+ <assignable>true</assignable>
+ <permissions>
+ <permission>
+ <id>guest-permission</id>
+ <name>Guest Permission</name>
+ <operation>guest-access</operation>
+ <resource>global</resource>
+ <permanent>true</permanent>
+ </permission>
+ </permissions>
+ </role>
+ </roles>
+ </application>
+ </applications>
+</redback-role-model>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0"?>
+
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+<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-3.0.xsd
+ http://www.springframework.org/schema/context
+ http://www.springframework.org/schema/context/spring-context-3.0.xsd" default-lazy-init="true">
+
+ <bean name="scheduler" class="org.codehaus.redback.components.scheduler.DefaultScheduler">
+ <property name="properties">
+ <props>
+ <prop key="org.quartz.scheduler.instanceName">scheduler1</prop>
+ <prop key="org.quartz.threadPool.class">org.quartz.simpl.SimpleThreadPool</prop>
+ <prop key="org.quartz.threadPool.threadCount">2</prop>
+ <prop key="org.quartz.threadPool.threadPriority">4</prop>
+ <prop key="org.quartz.jobStore.class">org.quartz.simpl.RAMJobStore</prop>
+ </props>
+ </property>
+ </bean>
+
+</beans>
\ No newline at end of file
* under the License.
*/
+import org.apache.archiva.admin.model.managed.ManagedRepository;
import org.apache.archiva.common.plexusbridge.MavenIndexerUtils;
import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException;
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.configuration.ConfigurationNames;
import org.apache.maven.archiva.configuration.FileTypes;
-import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.maven.archiva.consumers.AbstractMonitoredConsumer;
import org.apache.maven.archiva.consumers.ConsumerException;
import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
import org.apache.maven.index.context.IndexCreator;
import org.apache.maven.index.context.IndexingContext;
import org.apache.maven.index.context.UnsupportedExistingLuceneIndexException;
-import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
-import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
import org.codehaus.plexus.registry.Registry;
import org.codehaus.plexus.registry.RegistryListener;
import org.codehaus.plexus.taskqueue.TaskQueueException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import javax.annotation.PostConstruct;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
*/
public class NexusIndexerConsumer
extends AbstractMonitoredConsumer
- implements KnownRepositoryContentConsumer, RegistryListener, Initializable
+ implements KnownRepositoryContentConsumer, RegistryListener
{
private Logger log = LoggerFactory.getLogger( NexusIndexerConsumer.class );
private List<String> includes = new ArrayList<String>();
- private ManagedRepositoryConfiguration repository;
+ private ManagedRepository repository;
private List<? extends IndexCreator> allIndexCreators;
return false;
}
- public void beginScan( ManagedRepositoryConfiguration repository, Date whenGathered )
+ public void beginScan( ManagedRepository repository, Date whenGathered )
throws ConsumerException
{
this.repository = repository;
}
}
- public void beginScan( ManagedRepositoryConfiguration repository, Date whenGathered, boolean executeOnEntireRepo )
+ public void beginScan( ManagedRepository repository, Date whenGathered, boolean executeOnEntireRepo )
throws ConsumerException
{
if ( executeOnEntireRepo )
includes.addAll( filetypes.getFileTypePatterns( FileTypes.ARTIFACTS ) );
}
+ @PostConstruct
public void initialize()
- throws InitializationException
{
configuration.addChangeListener( this );
*/
import junit.framework.TestCase;
+import org.apache.archiva.admin.model.managed.ManagedRepository;
import org.apache.archiva.common.plexusbridge.MavenIndexerUtils;
import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
import org.apache.archiva.scheduler.ArchivaTaskScheduler;
private KnownRepositoryContentConsumer nexusIndexerConsumer;
- private ManagedRepositoryConfiguration repositoryConfig;
+ private ManagedRepository repositoryConfig;
private ArchivaTaskSchedulerStub scheduler;
new NexusIndexerConsumer( scheduler, configuration, filetypes, plexusSisuBridge, mavenIndexerUtils );
// initialize to set the file types to be processed
- ( (Initializable) nexusIndexerConsumer ).initialize();
+ ( (NexusIndexerConsumer) nexusIndexerConsumer ).initialize();
- repositoryConfig = new ManagedRepositoryConfiguration();
+ repositoryConfig = new ManagedRepository();
repositoryConfig.setId( "test-repo" );
repositoryConfig.setLocation( "target/test-classes/test-repo" );
repositoryConfig.setLayout( "default" );
* under the License.
*/
+import org.apache.archiva.admin.model.managed.ManagedRepository;
import org.apache.archiva.metadata.model.ArtifactMetadata;
import org.apache.archiva.metadata.model.ProjectMetadata;
import org.apache.archiva.metadata.model.ProjectVersionMetadata;
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.configuration.ConfigurationNames;
import org.apache.maven.archiva.configuration.FileTypes;
-import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.maven.archiva.consumers.AbstractMonitoredConsumer;
import org.apache.maven.archiva.consumers.ConsumerException;
import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
return this.includes;
}
- public void beginScan( ManagedRepositoryConfiguration repo, Date whenGathered )
+ public void beginScan( ManagedRepository repo, Date whenGathered )
throws ConsumerException
{
repoId = repo.getId();
this.whenGathered = whenGathered;
}
- public void beginScan( ManagedRepositoryConfiguration repository, Date whenGathered, boolean executeOnEntireRepo )
+ public void beginScan( ManagedRepository repository, Date whenGathered, boolean executeOnEntireRepo )
throws ConsumerException
{
beginScan( repository, whenGathered );
* under the License.
*/
+import org.apache.archiva.admin.model.managed.ManagedRepository;
import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException;
import org.apache.archiva.repository.scanner.RepositoryScanner;
{
String defaultRepositoryUrl = PathUtil.toUrl( repositoryDirectory );
- ManagedRepositoryConfiguration legacyRepository = new ManagedRepositoryConfiguration();
+ ManagedRepository legacyRepository = new ManagedRepository();
legacyRepository.setId( "legacy" );
legacyRepository.setName( "Legacy Repository" );
legacyRepository.setLocation( legacyRepositoryDirectory.getAbsolutePath() );
* under the License.
*/
+import org.apache.archiva.admin.model.managed.ManagedRepository;
import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException;
-import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.maven.archiva.consumers.AbstractMonitoredConsumer;
import org.apache.maven.archiva.consumers.ConsumerException;
import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
artifactFactory = plexusSisuBridge.lookup( ArtifactFactory.class );
}
- public void beginScan( ManagedRepositoryConfiguration repository, Date whenGathered )
+ public void beginScan( ManagedRepository repository, Date whenGathered )
throws ConsumerException
{
this.managedRepository = new ManagedDefaultRepositoryContent();
this.managedRepository.setRepository( repository );
}
- public void beginScan( ManagedRepositoryConfiguration repository, Date whenGathered, boolean executeOnEntireRepo )
+ public void beginScan( ManagedRepository repository, Date whenGathered, boolean executeOnEntireRepo )
throws ConsumerException
{
beginScan( repository, whenGathered );
--- /dev/null
+package org.apache.maven.archiva.converter.mock;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.admin.model.AuditInformation;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.admin.ArchivaAdministration;
+import org.apache.archiva.admin.model.admin.FileType;
+import org.apache.archiva.admin.model.admin.LegacyArtifactPath;
+import org.apache.archiva.admin.model.admin.OrganisationInformation;
+
+import java.util.List;
+
+/**
+ * @author Olivier Lamy
+ */
+public class MockArchivaAdministration implements ArchivaAdministration
+{
+ public List<LegacyArtifactPath> getLegacyArtifactPaths()
+ throws RepositoryAdminException
+ {
+ return null;
+ }
+
+ public void addLegacyArtifactPath( LegacyArtifactPath legacyArtifactPath, AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+
+ }
+
+ public void deleteLegacyArtifactPath( String path, AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+
+ }
+
+ public void addFileTypePattern( String fileTypeId, String pattern, AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+
+ }
+
+ public void removeFileTypePattern( String fileTypeId, String pattern, AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+
+ }
+
+ public List<FileType> getFileTypes()
+ throws RepositoryAdminException
+ {
+ return null;
+ }
+
+ public FileType getFileType( String fileTypeId )
+ throws RepositoryAdminException
+ {
+ return null;
+ }
+
+ public void addFileType( FileType fileType, AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+
+ }
+
+ public void removeFileType( String fileTypeId, AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+
+ }
+
+ public void addKnownContentConsumer( String knownContentConsumer, AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+
+ }
+
+ public void setKnownContentConsumers( List<String> knownContentConsumers, AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+
+ }
+
+ public List<String> getKnownContentConsumers()
+ throws RepositoryAdminException
+ {
+ return null;
+ }
+
+ public void removeKnownContentConsumer( String knownContentConsumer, AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+
+ }
+
+ public void addInvalidContentConsumer( String invalidContentConsumer, AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+
+ }
+
+ public void setInvalidContentConsumers( List<String> invalidContentConsumers, AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+
+ }
+
+ public List<String> getInvalidContentConsumers()
+ throws RepositoryAdminException
+ {
+ return null;
+ }
+
+ public void removeInvalidContentConsumer( String invalidContentConsumer, AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+
+ }
+
+ public OrganisationInformation getOrganisationInformation()
+ throws RepositoryAdminException
+ {
+ return null;
+ }
+
+ public void setOrganisationInformation( OrganisationInformation organisationInformation )
+ throws RepositoryAdminException
+ {
+
+ }
+}
http://www.springframework.org/schema/context/spring-context-3.0.xsd"
default-lazy-init="true">
+ <bean name="mockArchivaAdministration" class="org.apache.maven.archiva.converter.mock.MockArchivaAdministration"/>
</beans>
\ No newline at end of file
hit = new SearchResultHit();
hit.setArtifactId( artifactInfo.artifactId );
hit.setGroupId( artifactInfo.groupId );
- // do we still need to set the repository id even though we're merging everything?
- //hit.setRepositoryId( artifactInfo.repository );
+ hit.setRepositoryId( artifactInfo.repository );
+ // FIXME archiva url ??
hit.setUrl( artifactInfo.repository + "/" + artifactInfo.fname );
hit.addVersion( artifactInfo.version );
hit.setBundleExportPackage( artifactInfo.bundleExportPackage );
@Override
public String toString()
{
- return "SearchResultHit{" + "context='" + context + '\'' + ", url='" + url + '\'' + ", groupId='" + groupId
- + '\'' + ", artifactId='" + artifactId + '\'' + ", version='" + version + '\'' + ", repositoryId='"
- + repositoryId + '\'' + ", versions=" + versions + ", bundleVersion='" + bundleVersion + '\''
- + ", bundleSymbolicName='" + bundleSymbolicName + '\'' + ", bundleExportPackage='" + bundleExportPackage
- + '\'' + ", bundleExportService='" + bundleExportService + '\'' + '}';
+ final StringBuilder sb = new StringBuilder();
+ sb.append( "SearchResultHit" );
+ sb.append( "{context='" ).append( context ).append( '\'' );
+ sb.append( ", url='" ).append( url ).append( '\'' );
+ sb.append( ", groupId='" ).append( groupId ).append( '\'' );
+ sb.append( ", artifactId='" ).append( artifactId ).append( '\'' );
+ sb.append( ", version='" ).append( version ).append( '\'' );
+ sb.append( ", repositoryId='" ).append( repositoryId ).append( '\'' );
+ sb.append( ", versions=" ).append( versions );
+ sb.append( ", bundleVersion='" ).append( bundleVersion ).append( '\'' );
+ sb.append( ", bundleSymbolicName='" ).append( bundleSymbolicName ).append( '\'' );
+ sb.append( ", bundleExportPackage='" ).append( bundleExportPackage ).append( '\'' );
+ sb.append( ", bundleExportService='" ).append( bundleExportService ).append( '\'' );
+ sb.append( '}' );
+ return sb.toString();
}
+
+
}
<artifactId>slf4j-simple</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>archiva-repository-admin-default</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.redback</groupId>
+ <artifactId>redback-rbac-cached</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.derby</groupId>
+ <artifactId>derby</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>archiva-security-common</artifactId>
+ </dependency>
</dependencies>
<build>
<plugins>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
+ <appserver.base>${basedir}/target/appserver-base</appserver.base>
+ <plexus.home>${project.build.outputDirectory}</plexus.home>
<java.io.tmpdir>${project.build.outputDirectory}</java.io.tmpdir>
</systemPropertyVariables>
</configuration>
}
AuthenticationInfo authInfo = null;
- String username = remoteRepository.getRepository().getUsername();
+ String username = remoteRepository.getRepository().getUserName();
String password = remoteRepository.getRepository().getPassword();
if ( StringUtils.isNotBlank( username ) && StringUtils.isNotBlank( password ) )
*/
import net.sf.ehcache.CacheManager;
+import org.apache.archiva.admin.model.managed.ManagedRepository;
+import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
+import org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin;
import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
import org.apache.commons.lang.ArrayUtils;
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import javax.inject.Inject;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.Collection;
import java.util.Date;
import java.util.Locale;
-import javax.inject.Inject;
import static org.junit.Assert.*;
* @version $Id$
*/
@RunWith( SpringJUnit4ClassRunner.class )
-@ContextConfiguration( locations = {"classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml"} )
+@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml" } )
public abstract class AbstractProxyTestCase
{
@Inject
WagonDelegate delegate;
+ @Inject
+ protected ManagedRepositoryAdmin managedRepositoryAdmin;
+
@Inject
PlexusSisuBridge plexusSisuBridge;
public void setUp()
throws Exception
{
- config = (MockConfiguration) applicationContext.getBean( "archivaConfiguration#mock",
- ArchivaConfiguration.class );
+ config =
+ (MockConfiguration) applicationContext.getBean( "archivaConfiguration#mock", ArchivaConfiguration.class );
config.getConfiguration().setManagedRepositories( new ArrayList<ManagedRepositoryConfiguration>() );
config.getConfiguration().setRemoteRepositories( new ArrayList<RemoteRepositoryConfiguration>() );
String repoPath = "target/test-repository/managed/" + name;
File repoLocation = new File( repoPath );
- managedDefaultRepository = createRepository( ID_DEFAULT_MANAGED, "Default Managed Repository", repoPath,
- "default" );
+ managedDefaultRepository =
+ createRepository( ID_DEFAULT_MANAGED, "Default Managed Repository", repoPath, "default" );
managedDefaultDir = new File( managedDefaultRepository.getRepoRoot() );
- ManagedRepositoryConfiguration repoConfig = managedDefaultRepository.getRepository();
+ ManagedRepository repoConfig = managedDefaultRepository.getRepository();
- config.getConfiguration().addManagedRepository( repoConfig );
+ ( (DefaultManagedRepositoryAdmin) applicationContext.getBean(
+ ManagedRepositoryAdmin.class ) ).setArchivaConfiguration( config );
+
+ applicationContext.getBean( ManagedRepositoryAdmin.class ).addManagedRepository( repoConfig, false, null );
+ //config.getConfiguration().addManagedRepository( repoConfig );
// Setup source repository (using legacy layout)
repoLocation = new File( REPOPATH_LEGACY_MANAGED_TARGET );
}
copyDirectoryStructure( new File( REPOPATH_LEGACY_MANAGED ), repoLocation );
- managedLegacyRepository = createRepository( ID_LEGACY_MANAGED, "Legacy Managed Repository",
- REPOPATH_LEGACY_MANAGED_TARGET, "legacy" );
+ managedLegacyRepository =
+ createRepository( ID_LEGACY_MANAGED, "Legacy Managed Repository", REPOPATH_LEGACY_MANAGED_TARGET,
+ "legacy" );
managedLegacyDir = new File( managedLegacyRepository.getRepoRoot() );
repoConfig = managedLegacyRepository.getRepository();
- config.getConfiguration().addManagedRepository( repoConfig );
+ //config.getConfiguration().addManagedRepository( repoConfig );
+ applicationContext.getBean( ManagedRepositoryAdmin.class ).addManagedRepository( repoConfig, false, null );
// Setup target (proxied to) repository.
- saveRemoteRepositoryConfig( ID_PROXIED1, "Proxied Repository 1", new File(
- REPOPATH_PROXIED1 ).toURL().toExternalForm(), "default" );
+ saveRemoteRepositoryConfig( ID_PROXIED1, "Proxied Repository 1",
+ new File( REPOPATH_PROXIED1 ).toURL().toExternalForm(), "default" );
// Setup target (proxied to) repository.
- saveRemoteRepositoryConfig( ID_PROXIED2, "Proxied Repository 2", new File(
- REPOPATH_PROXIED2 ).toURL().toExternalForm(), "default" );
+ saveRemoteRepositoryConfig( ID_PROXIED2, "Proxied Repository 2",
+ new File( REPOPATH_PROXIED2 ).toURL().toExternalForm(), "default" );
// Setup target (proxied to) repository using legacy layout.
- saveRemoteRepositoryConfig( ID_LEGACY_PROXIED, "Proxied Legacy Repository", new File(
- REPOPATH_PROXIED_LEGACY ).toURL().toExternalForm(), "legacy" );
+ saveRemoteRepositoryConfig( ID_LEGACY_PROXIED, "Proxied Legacy Repository",
+ new File( REPOPATH_PROXIED_LEGACY ).toURL().toExternalForm(), "legacy" );
// Setup the proxy handler.
//proxyHandler = applicationContext.getBean (RepositoryProxyConnectors) lookup( RepositoryProxyConnectors.class.getName() );
{
return false;
}
- return MockControl.ARRAY_MATCHER.matches( ArrayUtils.remove( expected, 1 ), ArrayUtils.remove( actual,
- 1 ) );
+ return MockControl.ARRAY_MATCHER.matches( ArrayUtils.remove( expected, 1 ),
+ ArrayUtils.remove( actual, 1 ) );
}
public String toString( Object[] arguments )
return;
}
- Collection<File> tmpFiles = org.apache.commons.io.FileUtils.listFiles( workingDir, new String[]{"tmp"}, false );
+ Collection<File> tmpFiles =
+ org.apache.commons.io.FileUtils.listFiles( workingDir, new String[]{ "tmp" }, false );
if ( !tmpFiles.isEmpty() )
{
StringBuffer emsg = new StringBuffer();
protected ManagedRepositoryContent createRepository( String id, String name, String path, String layout )
throws Exception
{
- ManagedRepositoryConfiguration repo = new ManagedRepositoryConfiguration();
+ ManagedRepository repo = new ManagedRepository();
repo.setId( id );
repo.setName( name );
repo.setLocation( path );
repo.setLayout( layout );
- ManagedRepositoryContent repoContent = applicationContext.getBean( "managedRepositoryContent#" + layout,
- ManagedRepositoryContent.class );
+ ManagedRepositoryContent repoContent =
+ applicationContext.getBean( "managedRepositoryContent#" + layout, ManagedRepositoryContent.class );
repoContent.setRepository( repo );
return repoContent;
}
config.triggerChange( prefix + ".policies.checksum", connectorConfig.getPolicy( "checksum", "" ) );
config.triggerChange( prefix + ".policies.snapshots", connectorConfig.getPolicy( "snapshots", "" ) );
config.triggerChange( prefix + ".policies.cache-failures", connectorConfig.getPolicy( "cache-failures", "" ) );
- config.triggerChange( prefix + ".policies.propagate-errors", connectorConfig.getPolicy( "propagate-errors",
- "" ) );
- config.triggerChange( prefix + ".policies.propagate-errors-on-update", connectorConfig.getPolicy(
- "propagate-errors-on-update", "" ) );
+ config.triggerChange( prefix + ".policies.propagate-errors",
+ connectorConfig.getPolicy( "propagate-errors", "" ) );
+ config.triggerChange( prefix + ".policies.propagate-errors-on-update",
+ connectorConfig.getPolicy( "propagate-errors-on-update", "" ) );
}
protected void saveManagedRepositoryConfig( String id, String name, String path, String layout )
String managedLegacyPath = managedLegacyDir.getCanonicalPath();
String testFile = file.getCanonicalPath();
- assertTrue( "Unit Test Failure: File <" + testFile +
- "> should be have been defined within the legacy managed path of <" + managedLegacyPath + ">",
- testFile.startsWith( managedLegacyPath ) );
+ assertTrue(
+ "Unit Test Failure: File <" + testFile + "> should be have been defined within the legacy managed path of <"
+ + managedLegacyPath + ">", testFile.startsWith( managedLegacyPath ) );
assertFalse( "File < " + testFile + "> should not exist in managed legacy repository.", file.exists() );
}
String managedDefaultPath = managedDefaultDir.getCanonicalPath();
String testFile = file.getCanonicalPath();
- assertTrue( "Unit Test Failure: File <" + testFile +
- "> should be have been defined within the managed default path of <" + managedDefaultPath + ">",
- testFile.startsWith( managedDefaultPath ) );
+ assertTrue( "Unit Test Failure: File <" + testFile
+ + "> should be have been defined within the managed default path of <" + managedDefaultPath
+ + ">", testFile.startsWith( managedDefaultPath ) );
assertFalse( "File < " + testFile + "> should not exist in managed default repository.", file.exists() );
}
* under the License.
*/
+import org.apache.archiva.admin.model.managed.ManagedRepository;
+import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
+import org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin;
import org.apache.commons.io.FileUtils;
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
-import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.maven.archiva.configuration.NetworkProxyConfiguration;
import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration;
import org.apache.maven.archiva.configuration.RemoteRepositoryConfiguration;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import java.io.File;
-import java.io.IOException;
import javax.inject.Inject;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import java.io.File;
+import java.io.IOException;
import static org.junit.Assert.*;
* @version $Id: ManagedDefaultTransferTest.java 677852 2008-07-18 08:16:24Z brett $
*/
@RunWith( SpringJUnit4ClassRunner.class )
-@ContextConfiguration( locations = {"classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml"} )
+@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml" } )
public class HttpProxyTransferTest
{
private static final String PROXY_ID = "proxy";
// Make the destination dir.
destRepoDir.mkdirs();
- ManagedRepositoryConfiguration repo = new ManagedRepositoryConfiguration();
+ ManagedRepository repo = new ManagedRepository();
repo.setId( MANAGED_ID );
repo.setName( "Default Managed Repository" );
repo.setLocation( repoPath );
repo.setLayout( "default" );
- ManagedRepositoryContent repoContent = applicationContext.getBean( "managedRepositoryContent#default",
- ManagedRepositoryContent.class );
+ ManagedRepositoryContent repoContent =
+ applicationContext.getBean( "managedRepositoryContent#default", ManagedRepositoryContent.class );
repoContent.setRepository( repo );
managedDefaultRepository = repoContent;
- config.getConfiguration().addManagedRepository( repo );
+ ( (DefaultManagedRepositoryAdmin) applicationContext.getBean(
+ ManagedRepositoryAdmin.class ) ).setArchivaConfiguration( config );
+
+ ManagedRepositoryAdmin managedRepositoryAdmin = applicationContext.getBean( ManagedRepositoryAdmin.class );
+ if ( managedRepositoryAdmin.getManagedRepository( repo.getId() ) == null )
+ {
+ managedRepositoryAdmin.addManagedRepository( repo, false, null );
+ }
+
+ //config.getConfiguration().addManagedRepository( repo );
Handler handler = new AbstractHandler()
{
--- /dev/null
+<redback-role-model>
+ <modelVersion>1.0.0</modelVersion>
+ <applications>
+ <application>
+ <id>System</id>
+ <description>Roles that apply system-wide, across all of the applications</description>
+ <version>1.0.0</version>
+ <resources>
+ <resource>
+ <id>global</id>
+ <name>*</name>
+ <permanent>true</permanent>
+ <description>global resource implies full access for authorization</description>
+ </resource>
+ <resource>
+ <id>username</id>
+ <name>${username}</name>
+ <permanent>true</permanent>
+ <description>replaced with the username of the principal at authorization check time</description>
+ </resource>
+ </resources>
+ <operations>
+ <operation>
+ <id>configuration-edit</id>
+ <name>configuration-edit</name>
+ <description>edit configuration</description>
+ <permanent>true</permanent>
+ </operation>
+ <operation>
+ <id>user-management-user-create</id>
+ <name>user-management-user-create</name>
+ <description>create user</description>
+ <permanent>true</permanent>
+ </operation>
+ <operation>
+ <id>user-management-user-edit</id>
+ <name>user-management-user-edit</name>
+ <description>edit user</description>
+ <permanent>true</permanent>
+ </operation>
+ <operation>
+ <id>user-management-user-role</id>
+ <name>user-management-user-role</name>
+ <description>user roles</description>
+ <permanent>true</permanent>
+ </operation>
+ <operation>
+ <id>user-management-user-delete</id>
+ <name>user-management-user-delete</name>
+ <description>delete user</description>
+ <permanent>true</permanent>
+ </operation>
+ <operation>
+ <id>user-management-user-list</id>
+ <name>user-management-user-list</name>
+ <description>list users</description>
+ <permanent>true</permanent>
+ </operation>
+ <operation>
+ <id>user-management-role-grant</id>
+ <name>user-management-role-grant</name>
+ <description>grant role</description>
+ <permanent>true</permanent>
+ </operation>
+ <operation>
+ <id>user-management-role-drop</id>
+ <name>user-management-role-drop</name>
+ <description>drop role</description>
+ <permanent>true</permanent>
+ </operation>
+ <operation>
+ <id>user-management-rbac-admin</id>
+ <name>user-management-rbac-admin</name>
+ <description>administer rbac</description>
+ <permanent>true</permanent>
+ </operation>
+ <operation>
+ <id>guest-access</id>
+ <name>guest-access</name>
+ <description>access guest</description>
+ <permanent>true</permanent>
+ </operation>
+ <operation>
+ <id>user-management-manage-data</id>
+ <name>user-management-manage-data</name>
+ <description>manage data</description>
+ <permanent>true</permanent>
+ </operation>
+ </operations>
+ <roles>
+ <role>
+ <id>system-administrator</id>
+ <name>System Administrator</name>
+ <permanent>true</permanent>
+ <assignable>true</assignable>
+ <permissions>
+ <permission>
+ <id>edit-redback-configuration</id>
+ <name>Edit Redback Configuration</name>
+ <operation>configuration-edit</operation>
+ <resource>global</resource>
+ <permanent>true</permanent>
+ </permission>
+ <permission>
+ <id>manage-rbac-setup</id>
+ <name>User RBAC Management</name>
+ <operation>user-management-rbac-admin</operation>
+ <resource>global</resource>
+ <permanent>true</permanent>
+ </permission>
+ <permission>
+ <id>manage-rbac-data</id>
+ <name>RBAC Manage Data</name>
+ <operation>user-management-manage-data</operation>
+ <resource>global</resource>
+ <permanent>true</permanent>
+ </permission>
+ </permissions>
+ <childRoles>
+ <childRole>user-administrator</childRole>
+ </childRoles>
+ </role>
+ <role>
+ <id>user-administrator</id>
+ <name>User Administrator</name>
+ <permanent>true</permanent>
+ <assignable>true</assignable>
+ <permissions>
+ <permission>
+ <id>drop-roles-for-anyone</id>
+ <name>Drop Roles for Anyone</name>
+ <operation>user-management-role-drop</operation>
+ <resource>global</resource>
+ <permanent>true</permanent>
+ </permission>
+ <permission>
+ <id>grant-roles-for-anyone</id>
+ <name>Grant Roles for Anyone</name>
+ <operation>user-management-role-grant</operation>
+ <resource>global</resource>
+ <permanent>true</permanent>
+ </permission>
+ <permission>
+ <id>user-create</id>
+ <name>Create Users</name>
+ <operation>user-management-user-create</operation>
+ <resource>global</resource>
+ <permanent>true</permanent>
+ </permission>
+ <permission>
+ <id>user-delete</id>
+ <name>Delete Users</name>
+ <operation>user-management-user-delete</operation>
+ <resource>global</resource>
+ <permanent>true</permanent>
+ </permission>
+ <permission>
+ <id>user-edit</id>
+ <name>Edit Users</name>
+ <operation>user-management-user-edit</operation>
+ <resource>global</resource>
+ <permanent>true</permanent>
+ </permission>
+ <permission>
+ <id>access-users-roles</id>
+ <name>Access Users Roles</name>
+ <operation>user-management-user-role</operation>
+ <resource>global</resource>
+ <permanent>true</permanent>
+ </permission>
+ <permission>
+ <id>access-user-list</id>
+ <name>Access User List</name>
+ <operation>user-management-user-list</operation>
+ <resource>global</resource>
+ <permanent>true</permanent>
+ </permission>
+ </permissions>
+ </role>
+ <role>
+ <id>registered-user</id>
+ <name>Registered User</name>
+ <permanent>true</permanent>
+ <assignable>true</assignable>
+ <permissions>
+ <permission>
+ <id>edit-user-by-username</id>
+ <name>Edit User Data by Username</name>
+ <operation>user-management-user-edit</operation>
+ <resource>username</resource>
+ <permanent>true</permanent>
+ </permission>
+ </permissions>
+ </role>
+ <role>
+ <id>guest</id>
+ <name>Guest</name>
+ <permanent>true</permanent>
+ <assignable>true</assignable>
+ <permissions>
+ <permission>
+ <id>guest-permission</id>
+ <name>Guest Permission</name>
+ <operation>guest-access</operation>
+ <resource>global</resource>
+ <permanent>true</permanent>
+ </permission>
+ </permissions>
+ </role>
+ </roles>
+ </application>
+ </applications>
+</redback-role-model>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>archiva-repository-admin</artifactId>
+ <version>1.4-SNAPSHOT</version>
+ </parent>
+ <artifactId>archiva-repository-admin-api</artifactId>
+ <name>Archiva Base :: Repository Admin Api</name>
+ <dependencies>
+ <dependency>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.redback</groupId>
+ <artifactId>redback-users-api</artifactId>
+ </dependency>
+ </dependencies>
+
+</project>
--- /dev/null
+package org.apache.archiva.admin.model;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.Serializable;
+
+/**
+ * @author Olivier Lamy
+ * @since 1.4
+ */
+public class AbstractRepository
+ implements Serializable
+{
+
+ private String id;
+
+ private String name;
+
+ private String layout = "default";
+
+ public AbstractRepository()
+ {
+ // no op
+ }
+
+ public AbstractRepository( String id, String name, String layout )
+ {
+ this.id = id;
+ this.name = name;
+ this.layout = layout;
+ }
+
+ public String getId()
+ {
+ return id;
+ }
+
+ public void setId( String id )
+ {
+ this.id = id;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName( String name )
+ {
+ this.name = name;
+ }
+
+ public String getLayout()
+ {
+ return layout;
+ }
+
+ public void setLayout( String layout )
+ {
+ this.layout = layout;
+ }
+
+
+ public int hashCode()
+ {
+ int result = 17;
+ result = 37 * result + ( id != null ? id.hashCode() : 0 );
+ return result;
+ }
+
+ public boolean equals( Object other )
+ {
+ if ( this == other )
+ {
+ return true;
+ }
+
+ if ( !( other instanceof AbstractRepository ) )
+ {
+ return false;
+ }
+
+ AbstractRepository that = (AbstractRepository) other;
+ boolean result = true;
+ result = result && ( getId() == null ? that.getId() == null : getId().equals( that.getId() ) );
+ return result;
+ }
+
+ @Override
+ public String toString()
+ {
+ final StringBuilder sb = new StringBuilder();
+ sb.append( "AbstractRepository" );
+ sb.append( "{id='" ).append( id ).append( '\'' );
+ sb.append( ", name='" ).append( name ).append( '\'' );
+ sb.append( ", layout='" ).append( layout ).append( '\'' );
+ sb.append( '}' );
+ return sb.toString();
+ }
+}
--- /dev/null
+package org.apache.archiva.admin.model;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author Olivier Lamy
+ * @since 1.4
+ */
+public abstract class AbstractRepositoryConnector
+ implements Serializable
+{
+ /**
+ * The Repository Source for this connector.
+ */
+ private String sourceRepoId;
+
+ /**
+ * The Repository Target for this connector.
+ */
+ private String targetRepoId;
+
+ /**
+ * The network proxy ID to use for this connector.
+ */
+ private String proxyId;
+
+ /**
+ * Field blackListPatterns.
+ */
+ private List<String> blackListPatterns;
+
+ /**
+ * Field whiteListPatterns.
+ */
+ private List<String> whiteListPatterns;
+
+ /**
+ * Field policies.
+ */
+ private Map<String, String> policies;
+
+ /**
+ * Field properties.
+ */
+ private Map<String, String> properties;
+
+ /**
+ * If the the repository proxy connector is disabled or not
+ */
+ private boolean disabled = false;
+
+ //-----------/
+ //- Methods -/
+ //-----------/
+
+ /**
+ * Method addBlackListPattern.
+ *
+ * @param string
+ */
+ public void addBlackListPattern( String string )
+ {
+ getBlackListPatterns().add( string );
+ }
+
+ /**
+ * Method addPolicy.
+ *
+ * @param key
+ * @param value
+ */
+ public void addPolicy( String key, String value )
+ {
+ getPolicies().put( key, value );
+ }
+
+ /**
+ * Method addProperty.
+ *
+ * @param key
+ * @param value
+ */
+ public void addProperty( String key, String value )
+ {
+ getProperties().put( key, value );
+ }
+
+ /**
+ * Method addWhiteListPattern.
+ *
+ * @param string
+ */
+ public void addWhiteListPattern( String string )
+ {
+ getWhiteListPatterns().add( string );
+ }
+
+ /**
+ * Method getBlackListPatterns.
+ *
+ * @return List
+ */
+ public List<String> getBlackListPatterns()
+ {
+ if ( this.blackListPatterns == null )
+ {
+ this.blackListPatterns = new ArrayList<String>();
+ }
+
+ return this.blackListPatterns;
+ }
+
+ /**
+ * Method getPolicies.
+ *
+ * @return Map
+ */
+ public Map<String, String> getPolicies()
+ {
+ if ( this.policies == null )
+ {
+ this.policies = new HashMap<String, String>();
+ }
+
+ return this.policies;
+ }
+
+ /**
+ * Method getProperties.
+ *
+ * @return Map
+ */
+ public Map<String, String> getProperties()
+ {
+ if ( this.properties == null )
+ {
+ this.properties = new HashMap<String, String>();
+ }
+
+ return this.properties;
+ }
+
+ /**
+ * Get the network proxy ID to use for this connector.
+ *
+ * @return String
+ */
+ public String getProxyId()
+ {
+ return this.proxyId;
+ }
+
+ /**
+ * Get the Repository Source for this connector.
+ *
+ * @return String
+ */
+ public String getSourceRepoId()
+ {
+ return this.sourceRepoId;
+ }
+
+ /**
+ * Get the Repository Target for this connector.
+ *
+ * @return String
+ */
+ public String getTargetRepoId()
+ {
+ return this.targetRepoId;
+ }
+
+ /**
+ * Method getWhiteListPatterns.
+ *
+ * @return List
+ */
+ public List<String> getWhiteListPatterns()
+ {
+ if ( this.whiteListPatterns == null )
+ {
+ this.whiteListPatterns = new ArrayList<String>();
+ }
+
+ return this.whiteListPatterns;
+ }
+
+ /**
+ * Get if the the repository proxy connector is disabled or not
+ * .
+ *
+ * @return boolean
+ */
+ public boolean isDisabled()
+ {
+ return this.disabled;
+ }
+
+ /**
+ * Method removeBlackListPattern.
+ *
+ * @param string
+ */
+ public void removeBlackListPattern( String string )
+ {
+ getBlackListPatterns().remove( string );
+ }
+
+ /**
+ * Method removeWhiteListPattern.
+ *
+ * @param string
+ */
+ public void removeWhiteListPattern( String string )
+ {
+ getWhiteListPatterns().remove( string );
+ }
+
+ /**
+ * Set the list of blacklisted patterns for this connector.
+ *
+ * @param blackListPatterns
+ */
+ public void setBlackListPatterns( List<String> blackListPatterns )
+ {
+ this.blackListPatterns = blackListPatterns;
+ }
+
+ /**
+ * Set if the the repository proxy connector is
+ * disabled or not
+ * .
+ *
+ * @param disabled
+ */
+ public void setDisabled( boolean disabled )
+ {
+ this.disabled = disabled;
+ }
+
+ /**
+ * Set policy configuration for the connector.
+ *
+ * @param policies
+ */
+ public void setPolicies( Map<String, String> policies )
+ {
+ this.policies = policies;
+ }
+
+ /**
+ * Set configuration for the connector.
+ *
+ * @param properties
+ */
+ public void setProperties( Map<String, String> properties )
+ {
+ this.properties = properties;
+ }
+
+ /**
+ * Set the network proxy ID to use for this connector.
+ *
+ * @param proxyId
+ */
+ public void setProxyId( String proxyId )
+ {
+ this.proxyId = proxyId;
+ }
+
+ /**
+ * Set the Repository Source for this connector.
+ *
+ * @param sourceRepoId
+ */
+ public void setSourceRepoId( String sourceRepoId )
+ {
+ this.sourceRepoId = sourceRepoId;
+ }
+
+ /**
+ * Set the Repository Target for this connector.
+ *
+ * @param targetRepoId
+ */
+ public void setTargetRepoId( String targetRepoId )
+ {
+ this.targetRepoId = targetRepoId;
+ }
+
+ /**
+ * Set
+ * The list of whitelisted patterns for this
+ * connector.
+ *
+ * @param whiteListPatterns
+ */
+ public void setWhiteListPatterns( List<String> whiteListPatterns )
+ {
+ this.whiteListPatterns = whiteListPatterns;
+ }
+
+
+ /**
+ * Obtain a specific policy from the underlying connector.
+ *
+ * @param policyId the policy id to fetch.
+ * @param defaultValue the default value for the policy id.
+ * @return the configured policy value (or default value if not found).
+ */
+ public String getPolicy( String policyId, String defaultValue )
+ {
+ if ( this.getPolicies() == null )
+ {
+ return null;
+ }
+
+ String value = this.getPolicies().get( policyId );
+
+ if ( value == null )
+ {
+ return defaultValue;
+ }
+
+ return value;
+ }
+
+ @Override
+ public boolean equals( Object o )
+ {
+ if ( this == o )
+ {
+ return true;
+ }
+ if ( o == null || getClass() != o.getClass() )
+ {
+ return false;
+ }
+
+ AbstractRepositoryConnector that = (AbstractRepositoryConnector) o;
+
+ if ( sourceRepoId != null ? !sourceRepoId.equals( that.sourceRepoId ) : that.sourceRepoId != null )
+ {
+ return false;
+ }
+ if ( targetRepoId != null ? !targetRepoId.equals( that.targetRepoId ) : that.targetRepoId != null )
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int result = sourceRepoId != null ? sourceRepoId.hashCode() : 0;
+ result = 31 * result + ( targetRepoId != null ? targetRepoId.hashCode() : 0 );
+ return result;
+ }
+
+ @Override
+ public String toString()
+ {
+ final StringBuilder sb = new StringBuilder();
+ sb.append( "AbstractRepositoryConnector" );
+ sb.append( "{sourceRepoId='" ).append( sourceRepoId ).append( '\'' );
+ sb.append( ", targetRepoId='" ).append( targetRepoId ).append( '\'' );
+ sb.append( ", proxyId='" ).append( proxyId ).append( '\'' );
+ sb.append( ", blackListPatterns=" ).append( blackListPatterns );
+ sb.append( ", whiteListPatterns=" ).append( whiteListPatterns );
+ sb.append( ", policies=" ).append( policies );
+ sb.append( ", properties=" ).append( properties );
+ sb.append( ", disabled=" ).append( disabled );
+ sb.append( '}' );
+ return sb.toString();
+ }
+}
+
--- /dev/null
+package org.apache.archiva.admin.model;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.codehaus.plexus.redback.users.User;
+
+/**
+ * @author Olivier Lamy
+ * @since 1.4
+ */
+public class AuditInformation
+{
+ private User user;
+
+ private String remoteAddr;
+
+ public AuditInformation( User user, String remoteAddr )
+ {
+ this.user = user;
+ this.remoteAddr = remoteAddr;
+ }
+
+ public User getUser()
+ {
+ return user;
+ }
+
+ public void setUser( User user )
+ {
+ this.user = user;
+ }
+
+ public String getRemoteAddr()
+ {
+ return remoteAddr;
+ }
+
+ public void setRemoteAddr( String remoteAddr )
+ {
+ this.remoteAddr = remoteAddr;
+ }
+
+ @Override
+ public String toString()
+ {
+ final StringBuilder sb = new StringBuilder();
+ sb.append( "AuditInformation" );
+ sb.append( "{user=" ).append( user );
+ sb.append( ", remoteAddr='" ).append( remoteAddr ).append( '\'' );
+ sb.append( '}' );
+ return sb.toString();
+ }
+}
--- /dev/null
+package org.apache.archiva.admin.model;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+/**
+ * @author Olivier Lamy
+ * @since 1.4
+ */
+public class RepositoryAdminException
+ extends Exception
+{
+ public RepositoryAdminException( String s )
+ {
+ super( s );
+ }
+
+ public RepositoryAdminException( String message, Throwable cause )
+ {
+ super( message, cause );
+ }
+}
--- /dev/null
+package org.apache.archiva.admin.model.admin;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.admin.model.AuditInformation;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+
+import java.util.List;
+
+/**
+ * @author Olivier Lamy
+ * @since 1.4
+ */
+public interface ArchivaAdministration
+{
+
+ List<LegacyArtifactPath> getLegacyArtifactPaths()
+ throws RepositoryAdminException;
+
+ void addLegacyArtifactPath( LegacyArtifactPath legacyArtifactPath, AuditInformation auditInformation )
+ throws RepositoryAdminException;
+
+ void deleteLegacyArtifactPath( String path, AuditInformation auditInformation )
+ throws RepositoryAdminException;
+
+ void addFileTypePattern( String fileTypeId, String pattern, AuditInformation auditInformation )
+ throws RepositoryAdminException;
+
+ void removeFileTypePattern( String fileTypeId, String pattern, AuditInformation auditInformation )
+ throws RepositoryAdminException;
+
+ List<FileType> getFileTypes()
+ throws RepositoryAdminException;
+
+ FileType getFileType( String fileTypeId )
+ throws RepositoryAdminException;
+
+ void addFileType( FileType fileType, AuditInformation auditInformation )
+ throws RepositoryAdminException;
+
+ void removeFileType( String fileTypeId, AuditInformation auditInformation )
+ throws RepositoryAdminException;
+
+ void addKnownContentConsumer( String knownContentConsumer, AuditInformation auditInformation )
+ throws RepositoryAdminException;
+
+ void setKnownContentConsumers( List<String> knownContentConsumers, AuditInformation auditInformation )
+ throws RepositoryAdminException;
+
+ List<String> getKnownContentConsumers()
+ throws RepositoryAdminException;
+
+ void removeKnownContentConsumer( String knownContentConsumer, AuditInformation auditInformation )
+ throws RepositoryAdminException;
+
+ void addInvalidContentConsumer( String invalidContentConsumer, AuditInformation auditInformation )
+ throws RepositoryAdminException;
+
+ void setInvalidContentConsumers( List<String> invalidContentConsumers, AuditInformation auditInformation )
+ throws RepositoryAdminException;
+
+ List<String> getInvalidContentConsumers()
+ throws RepositoryAdminException;
+
+ void removeInvalidContentConsumer( String invalidContentConsumer, AuditInformation auditInformation )
+ throws RepositoryAdminException;
+
+ OrganisationInformation getOrganisationInformation()
+ throws RepositoryAdminException;
+
+ void setOrganisationInformation( OrganisationInformation organisationInformation )
+ throws RepositoryAdminException;
+
+}
--- /dev/null
+package org.apache.archiva.admin.model.admin;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Olivier Lamy
+ * @since 1.4
+ */
+public class FileType
+ implements Serializable
+{
+ /**
+ * Field id.
+ */
+ private String id;
+
+ /**
+ * Field patterns.
+ */
+ private List<String> patterns;
+
+ public FileType()
+ {
+ // no op
+ }
+
+ public FileType( String id, List<String> patterns )
+ {
+ this.id = id;
+ this.patterns = patterns;
+ }
+
+ public String getId()
+ {
+ return id;
+ }
+
+ public void setId( String id )
+ {
+ this.id = id;
+ }
+
+ public List<String> getPatterns()
+ {
+ if ( patterns == null )
+ {
+ this.patterns = new ArrayList<String>();
+ }
+ return patterns;
+ }
+
+ public void setPatterns( List<String> patterns )
+ {
+ this.patterns = patterns;
+ }
+
+ public void addPattern( String pattern )
+ {
+ getPatterns().add( pattern );
+ }
+
+ public void removePattern( String pattern )
+ {
+ getPatterns().remove( pattern );
+ }
+
+ @Override
+ public boolean equals( Object o )
+ {
+ if ( this == o )
+ {
+ return true;
+ }
+ if ( o == null || getClass() != o.getClass() )
+ {
+ return false;
+ }
+
+ FileType fileType = (FileType) o;
+
+ if ( id != null ? !id.equals( fileType.id ) : fileType.id != null )
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return id != null ? 37 + id.hashCode() : 0;
+ }
+
+ @Override
+ public String toString()
+ {
+ final StringBuilder sb = new StringBuilder();
+ sb.append( "FileType" );
+ sb.append( "{id='" ).append( id ).append( '\'' );
+ sb.append( ", patterns=" ).append( patterns );
+ sb.append( '}' );
+ return sb.toString();
+ }
+}
--- /dev/null
+package org.apache.archiva.admin.model.admin;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.Serializable;
+
+/**
+ * @author Olivier Lamy
+ * @since 1.4
+ */
+public class LegacyArtifactPath
+ implements Serializable
+{
+ /**
+ * The legacy path.
+ */
+ private String path;
+
+ /**
+ * The artifact reference, as " [groupId] :
+ * [artifactId] : [version] : [classifier] : [type] ".
+ */
+ private String artifact;
+
+ public LegacyArtifactPath()
+ {
+ // no op
+ }
+
+ public LegacyArtifactPath( String path, String artifact )
+ {
+ this.path = path;
+ this.artifact = artifact;
+ }
+
+ public String getPath()
+ {
+ return path;
+ }
+
+ public void setPath( String path )
+ {
+ this.path = path;
+ }
+
+ public String getArtifact()
+ {
+ return artifact;
+ }
+
+ public void setArtifact( String artifact )
+ {
+ this.artifact = artifact;
+ }
+
+ public boolean match( String path )
+ {
+ return path.equals( this.path );
+ }
+
+ public String getGroupId()
+ {
+ return artifact.split( ":" )[0];
+ }
+
+ public String getArtifactId()
+ {
+ return artifact.split( ":" )[1];
+ }
+
+ public String getVersion()
+ {
+ return artifact.split( ":" )[2];
+ }
+
+ public String getClassifier()
+ {
+ String classifier = artifact.split( ":" )[3];
+ return classifier.length() > 0 ? classifier : null;
+ }
+
+ public String getType()
+ {
+ return artifact.split( ":" )[4];
+ }
+
+ @Override
+ public boolean equals( Object o )
+ {
+ if ( this == o )
+ {
+ return true;
+ }
+ if ( o == null || getClass() != o.getClass() )
+ {
+ return false;
+ }
+
+ LegacyArtifactPath that = (LegacyArtifactPath) o;
+
+ if ( path != null ? !path.equals( that.path ) : that.path != null )
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return path != null ? 37 + path.hashCode() : 0;
+ }
+
+ @Override
+ public String toString()
+ {
+ final StringBuilder sb = new StringBuilder();
+ sb.append( "LegacyArtifactPath" );
+ sb.append( "{path='" ).append( path ).append( '\'' );
+ sb.append( ", artifact='" ).append( artifact ).append( '\'' );
+ sb.append( '}' );
+ return sb.toString();
+ }
+}
--- /dev/null
+package org.apache.archiva.admin.model.admin;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * @author Olivier Lamy
+ * @since 1.4
+ */
+public class OrganisationInformation
+{
+ /**
+ * name of the organisation.
+ */
+ private String name;
+
+ /**
+ * name of the organisation.
+ */
+ private String url;
+
+ /**
+ * name of the organisation.
+ */
+ private String logoLocation;
+
+ public OrganisationInformation()
+ {
+ // no op
+ }
+
+ public OrganisationInformation( String name, String url, String logoLocation )
+ {
+ this.name = name;
+ this.url = url;
+ this.logoLocation = logoLocation;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName( String name )
+ {
+ this.name = name;
+ }
+
+ public String getUrl()
+ {
+ return url;
+ }
+
+ public void setUrl( String url )
+ {
+ this.url = url;
+ }
+
+ public String getLogoLocation()
+ {
+ return logoLocation;
+ }
+
+ public void setLogoLocation( String logoLocation )
+ {
+ this.logoLocation = logoLocation;
+ }
+
+ @Override
+ public String toString()
+ {
+ final StringBuilder sb = new StringBuilder();
+ sb.append( "OrganisationInformation" );
+ sb.append( "{name='" ).append( name ).append( '\'' );
+ sb.append( ", url='" ).append( url ).append( '\'' );
+ sb.append( ", logoLocation='" ).append( logoLocation ).append( '\'' );
+ sb.append( '}' );
+ return sb.toString();
+ }
+}
--- /dev/null
+package org.apache.archiva.admin.model.group;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Olivier Lamy
+ * @since 1.4
+ */
+public class RepositoryGroup
+ implements Serializable
+{
+ /**
+ * repository group Id
+ */
+ private String id;
+
+ /**
+ * repositories ids
+ */
+ private List<String> repositories;
+
+ public RepositoryGroup()
+ {
+ // no op
+ }
+
+ public RepositoryGroup( String id, List<String> repositories )
+ {
+ this.id = id;
+ this.repositories = repositories;
+ }
+
+ /**
+ * Method addRepository.
+ *
+ * @param string
+ */
+ public void addRepository( String string )
+ {
+ getRepositories().add( string );
+ }
+
+ /**
+ * Get the id of the repository group.
+ *
+ * @return String
+ */
+ public String getId()
+ {
+ return this.id;
+ }
+
+ /**
+ * Method getRepositories.
+ *
+ * @return List
+ */
+ public java.util.List<String> getRepositories()
+ {
+ if ( this.repositories == null )
+ {
+ this.repositories = new ArrayList<String>();
+ }
+
+ return this.repositories;
+ }
+
+ /**
+ * Method removeRepository.
+ *
+ * @param string
+ */
+ public void removeRepository( String string )
+ {
+ getRepositories().remove( string );
+ }
+
+ /**
+ * Set the id of the repository group.
+ *
+ * @param id
+ */
+ public void setId( String id )
+ {
+ this.id = id;
+ }
+
+ /**
+ * Set the list of repository ids under the group.
+ *
+ * @param repositories
+ */
+ public void setRepositories( List<String> repositories )
+ {
+ this.repositories = repositories;
+ }
+
+ public boolean equals( Object other )
+ {
+ if ( this == other )
+ {
+ return true;
+ }
+
+ if ( !( other instanceof RepositoryGroup ) )
+ {
+ return false;
+ }
+
+ RepositoryGroup that = (RepositoryGroup) other;
+ boolean result = true;
+ result = result && ( getId() == null ? that.getId() == null : getId().equals( that.getId() ) );
+ return result;
+ }
+
+ public int hashCode()
+ {
+ int result = 17;
+ result = 37 * result + ( id != null ? id.hashCode() : 0 );
+ return result;
+ }
+
+ @Override
+ public String toString()
+ {
+ final StringBuilder sb = new StringBuilder();
+ sb.append( "RepositoryGroup" );
+ sb.append( "{id='" ).append( id ).append( '\'' );
+ sb.append( ", repositories=" ).append( repositories );
+ sb.append( '}' );
+ return sb.toString();
+ }
+}
--- /dev/null
+package org.apache.archiva.admin.model.group;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.admin.model.AuditInformation;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author Olivier Lamy
+ * @since 1.4
+ */
+public interface RepositoryGroupAdmin
+{
+ List<RepositoryGroup> getRepositoriesGroups()
+ throws RepositoryAdminException;
+
+ RepositoryGroup getRepositoryGroup( String repositoryGroupId )
+ throws RepositoryAdminException;
+
+ Boolean addRepositoryGroup( RepositoryGroup repositoryGroup, AuditInformation auditInformation )
+ throws RepositoryAdminException;
+
+ Boolean updateRepositoryGroup( RepositoryGroup repositoryGroup, AuditInformation auditInformation )
+ throws RepositoryAdminException;
+
+ Boolean deleteRepositoryGroup( String repositoryGroupId, AuditInformation auditInformation )
+ throws RepositoryAdminException;
+
+ Boolean addRepositoryToGroup( String repositoryGroupId, String repositoryId, AuditInformation auditInformation )
+ throws RepositoryAdminException;
+
+ Boolean deleteRepositoryFromGroup( String repositoryGroupId, String repositoryId,
+ AuditInformation auditInformation )
+ throws RepositoryAdminException;
+
+ /**
+ * @return Map with key repoGroupId and value repoGroup
+ * @throws RepositoryAdminException
+ */
+ Map<String, RepositoryGroup> getRepositoryGroupsAsMap()
+ throws RepositoryAdminException;
+
+ /**
+ * @return Map with key repoGroupId and value List of ManagedRepositories
+ * @throws RepositoryAdminException
+ */
+ Map<String, List<String>> getGroupToRepositoryMap()
+ throws RepositoryAdminException;
+
+ /**
+ * @return Map with key managedRepo id and value List of repositoryGroup ids where the repo is
+ * @throws RepositoryAdminException
+ */
+ Map<String, List<String>> getRepositoryToGroupMap()
+ throws RepositoryAdminException;
+}
--- /dev/null
+package org.apache.archiva.admin.model.managed;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.admin.model.AbstractRepository;
+
+import java.io.Serializable;
+
+/**
+ * @author Olivier Lamy
+ * @since 1.4
+ */
+public class ManagedRepository
+ extends AbstractRepository
+ implements Serializable
+{
+
+ private String location;
+
+ private boolean snapshots = false;
+
+ private boolean releases = true;
+
+ private boolean blockRedeployments = false;
+
+ /**
+ * default model value
+ */
+ private String cronExpression = "0 0 * * * ?";
+
+
+ /**
+ * not need when creating the repo : only available when reading
+ */
+ private ManagedRepository stagingRepository;
+
+ private boolean scanned = false;
+
+ private String indexDirectory;
+
+ /**
+ * default model value
+ */
+ private int daysOlder = 100;
+
+ /**
+ * default model value
+ */
+ private int retentionCount = 2;
+
+ private boolean deleteReleasedSnapshots;
+
+ public ManagedRepository()
+ {
+ // no op
+ }
+
+ public ManagedRepository( String id, String name, String location, String layout, boolean snapshots,
+ boolean releases, boolean blockRedeployments, String cronExpression, String indexDir,
+ boolean scanned, int daysOlder, int retentionCount, boolean deleteReleasedSnapshots )
+ {
+ super(id, name, layout);
+
+ this.location = location;
+ this.snapshots = snapshots;
+ this.releases = releases;
+ this.blockRedeployments = blockRedeployments;
+ this.cronExpression = cronExpression;
+ this.indexDirectory = indexDir;
+ this.scanned = scanned;
+ this.daysOlder = daysOlder;
+ this.retentionCount = retentionCount;
+ this.deleteReleasedSnapshots = deleteReleasedSnapshots;
+ }
+
+ public String getLocation()
+ {
+ return this.location;
+ }
+
+
+ public boolean isReleases()
+ {
+ return this.releases;
+ }
+
+ /**
+ * Get null
+ */
+ public boolean isSnapshots()
+ {
+ return this.snapshots;
+ }
+
+
+ public void setReleases( boolean releases )
+ {
+ this.releases = releases;
+ }
+
+ public void setSnapshots( boolean snapshots )
+ {
+ this.snapshots = snapshots;
+ }
+
+ public void setLocation( String location )
+ {
+ this.location = location;
+ }
+
+ public boolean isBlockRedeployments()
+ {
+ return blockRedeployments;
+ }
+
+ public void setBlockRedeployments( boolean blockRedeployments )
+ {
+ this.blockRedeployments = blockRedeployments;
+ }
+
+ public String getCronExpression()
+ {
+ return cronExpression;
+ }
+
+ public void setCronExpression( String cronExpression )
+ {
+ this.cronExpression = cronExpression;
+ }
+
+ public ManagedRepository getStagingRepository()
+ {
+ return stagingRepository;
+ }
+
+
+ public void setStagingRepository( ManagedRepository stagingRepository )
+ {
+ this.stagingRepository = stagingRepository;
+ }
+
+ public boolean isScanned()
+ {
+ return scanned;
+ }
+
+ public void setScanned( boolean scanned )
+ {
+ this.scanned = scanned;
+ }
+
+ public String getIndexDirectory()
+ {
+ return indexDirectory;
+ }
+
+ public void setIndexDirectory( String indexDirectory )
+ {
+ this.indexDirectory = indexDirectory;
+ }
+
+ public int getDaysOlder()
+ {
+ return daysOlder;
+ }
+
+ public void setDaysOlder( int daysOlder )
+ {
+ this.daysOlder = daysOlder;
+ }
+
+ public int getRetentionCount()
+ {
+ return retentionCount;
+ }
+
+ public void setRetentionCount( int retentionCount )
+ {
+ this.retentionCount = retentionCount;
+ }
+
+ public boolean isDeleteReleasedSnapshots()
+ {
+ return deleteReleasedSnapshots;
+ }
+
+ public void setDeleteReleasedSnapshots( boolean deleteReleasedSnapshots )
+ {
+ this.deleteReleasedSnapshots = deleteReleasedSnapshots;
+ }
+
+
+ @Override
+ public String toString()
+ {
+ final StringBuilder sb = new StringBuilder();
+ sb.append( "ManagedRepository" );
+ sb.append( "{location='" ).append( location ).append( '\'' );
+ sb.append( ", snapshots=" ).append( snapshots );
+ sb.append( ", releases=" ).append( releases );
+ sb.append( ", blockRedeployments=" ).append( blockRedeployments );
+ sb.append( ", cronExpression='" ).append( cronExpression ).append( '\'' );
+ sb.append( ", stagingRepository=" ).append( stagingRepository );
+ sb.append( ", scanned=" ).append( scanned );
+ sb.append( ", indexDirectory='" ).append( indexDirectory ).append( '\'' );
+ sb.append( ", daysOlder=" ).append( daysOlder );
+ sb.append( ", retentionCount=" ).append( retentionCount );
+ sb.append( ", deleteReleasedSnapshots=" ).append( deleteReleasedSnapshots );
+ sb.append( '}' );
+ sb.append( super.toString() );
+ return sb.toString();
+ }
+
+
+}
\ No newline at end of file
--- /dev/null
+package org.apache.archiva.admin.model.managed;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+import org.apache.archiva.admin.model.AuditInformation;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author Olivier Lamy
+ * @since 1.4
+ */
+public interface ManagedRepositoryAdmin
+{
+ List<ManagedRepository> getManagedRepositories()
+ throws RepositoryAdminException;
+
+ Map<String, ManagedRepository> getManagedRepositoriesAsMap()
+ throws RepositoryAdminException;
+
+ ManagedRepository getManagedRepository( String repositoryId )
+ throws RepositoryAdminException;
+
+ Boolean deleteManagedRepository( String repositoryId, AuditInformation auditInformation, boolean deleteContent )
+ throws RepositoryAdminException;
+
+ Boolean addManagedRepository( ManagedRepository managedRepository, boolean needStageRepo,
+ AuditInformation auditInformation )
+ throws RepositoryAdminException;
+
+
+ Boolean updateManagedRepository( ManagedRepository managedRepository, boolean needStageRepo,
+ AuditInformation auditInformation, boolean resetStats )
+ throws RepositoryAdminException;
+
+
+}
--- /dev/null
+package org.apache.archiva.admin.model.networkproxy;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.Serializable;
+
+/**
+ * @author Olivier Lamy
+ * @since 1.4
+ */
+public class NetworkProxy
+ implements Serializable
+{
+ private String id;
+
+ /**
+ * The network protocol to use with this proxy: "http", "socks-4"
+ * .
+ */
+ private String protocol = "http";
+
+ /**
+ * The proxy host.
+ */
+ private String host;
+
+ /**
+ * The proxy port.
+ */
+ private int port = 8080;
+
+ /**
+ * The proxy user.
+ */
+ private String username;
+
+ /**
+ * The proxy password.
+ */
+ private String password;
+
+ public NetworkProxy()
+ {
+ // no op
+ }
+
+ public NetworkProxy( String id, String protocol, String host, int port, String username, String password )
+ {
+ this.id = id;
+ this.protocol = protocol;
+ this.host = host;
+ this.port = port;
+ this.username = username;
+ this.password = password;
+ }
+
+ public String getId()
+ {
+ return id;
+ }
+
+ public void setId( String id )
+ {
+ this.id = id;
+ }
+
+ public String getProtocol()
+ {
+ return protocol;
+ }
+
+ public void setProtocol( String protocol )
+ {
+ this.protocol = protocol;
+ }
+
+ public String getHost()
+ {
+ return host;
+ }
+
+ public void setHost( String host )
+ {
+ this.host = host;
+ }
+
+ public int getPort()
+ {
+ return port;
+ }
+
+ public void setPort( int port )
+ {
+ this.port = port;
+ }
+
+ public String getUsername()
+ {
+ return username;
+ }
+
+ public void setUsername( String username )
+ {
+ this.username = username;
+ }
+
+ public String getPassword()
+ {
+ return password;
+ }
+
+ public void setPassword( String password )
+ {
+ this.password = password;
+ }
+
+ @Override
+ public boolean equals( Object o )
+ {
+ if ( this == o )
+ {
+ return true;
+ }
+ if ( o == null || getClass() != o.getClass() )
+ {
+ return false;
+ }
+
+ NetworkProxy that = (NetworkProxy) o;
+
+ if ( id != null ? !id.equals( that.id ) : that.id != null )
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int result = 17;
+ result = 37 * result + ( id != null ? id.hashCode() : 0 );
+ return result;
+ }
+
+ @Override
+ public String toString()
+ {
+ final StringBuilder sb = new StringBuilder();
+ sb.append( "NetworkProxy" );
+ sb.append( "{id='" ).append( id ).append( '\'' );
+ sb.append( ", protocol='" ).append( protocol ).append( '\'' );
+ sb.append( ", host='" ).append( host ).append( '\'' );
+ sb.append( ", port=" ).append( port );
+ sb.append( ", username='" ).append( username ).append( '\'' );
+ sb.append( ", password='" ).append( password ).append( '\'' );
+ sb.append( '}' );
+ return sb.toString();
+ }
+}
--- /dev/null
+package org.apache.archiva.admin.model.networkproxy;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.admin.model.AuditInformation;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+
+import java.util.List;
+
+/**
+ * @author Olivier Lamy
+ * @since 1.4
+ */
+public interface NetworkProxyAdmin
+{
+ List<NetworkProxy> getNetworkProxies()
+ throws RepositoryAdminException;
+
+ NetworkProxy getNetworkProxy( String networkProxyId )
+ throws RepositoryAdminException;
+
+ void addNetworkProxy( NetworkProxy networkProxy, AuditInformation auditInformation )
+ throws RepositoryAdminException;
+
+ void updateNetworkProxy( NetworkProxy networkProxy, AuditInformation auditInformation )
+ throws RepositoryAdminException;
+
+ void deleteNetworkProxy( String networkProxyId, AuditInformation auditInformation )
+ throws RepositoryAdminException;
+}
--- /dev/null
+package org.apache.archiva.admin.model.proxyconnector;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.admin.model.AbstractRepositoryConnector;
+
+import java.io.Serializable;
+
+/**
+ * @author Olivier Lamy
+ * @since 1.4
+ */
+public class ProxyConnector
+ extends AbstractRepositoryConnector
+ implements Serializable
+{
+ /**
+ * The order id for UNORDERED
+ */
+ public static final int UNORDERED = 0;
+
+ /**
+ * The policy key {@link #getPolicies()} for error handling.
+ * See {@link org.apache.maven.archiva.policies.DownloadErrorPolicy}
+ * for details on potential values to this policy key.
+ */
+ public static final String POLICY_PROPAGATE_ERRORS = "propagate-errors";
+
+ /**
+ * The policy key {@link #getPolicies()} for error handling when an artifact is present.
+ * See {@link org.apache.maven.archiva.policies.DownloadErrorPolicy}
+ * for details on potential values to this policy key.
+ */
+ public static final String POLICY_PROPAGATE_ERRORS_ON_UPDATE = "propagate-errors-on-update";
+
+ /**
+ * The policy key {@link #getPolicies()} for snapshot handling.
+ * See {@link org.apache.maven.archiva.policies.SnapshotsPolicy}
+ * for details on potential values to this policy key.
+ */
+ public static final String POLICY_SNAPSHOTS = "snapshots";
+
+ /**
+ * The policy key {@link #getPolicies()} for releases handling.
+ * See {@link org.apache.maven.archiva.policies.ReleasesPolicy}
+ * for details on potential values to this policy key.
+ */
+ public static final String POLICY_RELEASES = "releases";
+
+ /**
+ * The policy key {@link #getPolicies()} for checksum handling.
+ * See {@link org.apache.maven.archiva.policies.ChecksumPolicy}
+ * for details on potential values to this policy key.
+ */
+ public static final String POLICY_CHECKSUM = "checksum";
+
+ /**
+ * The policy key {@link #getPolicies()} for cache-failures handling.
+ * See {@link org.apache.maven.archiva.policies.CachedFailuresPolicy}
+ * for details on potential values to this policy key.
+ */
+ public static final String POLICY_CACHE_FAILURES = "cache-failures";
+
+ /**
+ *
+ * The order of the proxy connectors. (0 means no order specified)
+ * .
+ */
+ private int order = 0;
+
+ /**
+ * Get the order of the proxy connectors. (0 means no order specified)
+ * @return int
+ */
+ public int getOrder()
+ {
+ return this.order;
+ }
+
+
+ /**
+ * Set the order of the proxy connectors. (0 means no order specified)
+ * @param order
+ */
+ public void setOrder( int order )
+ {
+ this.order = order;
+ }
+
+ @Override
+ public String toString()
+ {
+ final StringBuilder sb = new StringBuilder();
+ sb.append( "ProxyConnector" );
+ sb.append( "{order=" ).append( order );
+ sb.append( '}' );
+ sb.append( super.toString() );
+ return sb.toString();
+ }
+}
--- /dev/null
+package org.apache.archiva.admin.model.proxyconnector;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.admin.model.AuditInformation;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * <b>No update method for changing source and target here as id is : sourceRepoId and targetRepoId, use delete then add.</b>
+ *
+ * @author Olivier Lamy
+ * @since 1.4
+ */
+public interface ProxyConnectorAdmin
+{
+ List<ProxyConnector> getProxyConnectors()
+ throws RepositoryAdminException;
+
+ ProxyConnector getProxyConnector( String sourceRepoId, String targetRepoId )
+ throws RepositoryAdminException;
+
+ Boolean addProxyConnector( ProxyConnector proxyConnector, AuditInformation auditInformation )
+ throws RepositoryAdminException;
+
+ Boolean deleteProxyConnector( ProxyConnector proxyConnector, AuditInformation auditInformation )
+ throws RepositoryAdminException;
+
+ /**
+ * <b>only for enabled/disable or changing bean values except target/source</b>
+ * @param proxyConnector
+ * @param auditInformation
+ * @return
+ * @throws RepositoryAdminException
+ */
+ Boolean updateProxyConnector( ProxyConnector proxyConnector, AuditInformation auditInformation )
+ throws RepositoryAdminException;
+
+
+ Map<String, List<ProxyConnector>> getProxyConnectorAsMap()
+ throws RepositoryAdminException;
+
+}
--- /dev/null
+package org.apache.archiva.admin.model.proxyconnector;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.Comparator;
+
+/**
+ * @author Olivier Lamy
+ * @since 1.4
+ */
+public class ProxyConnectorOrderComparator
+ implements Comparator<ProxyConnector>
+{
+ private static ProxyConnectorOrderComparator INSTANCE = new ProxyConnectorOrderComparator();
+
+ public int compare( ProxyConnector o1, ProxyConnector o2 )
+ {
+ if ( o1 == null && o2 == null )
+ {
+ return 0;
+ }
+
+ // Ensure null goes to end of list.
+ if ( o1 == null && o2 != null )
+ {
+ return 1;
+ }
+
+ if ( o1 != null && o2 == null )
+ {
+ return -1;
+ }
+
+ // Ensure 0 (unordered) goes to end of list.
+ if ( o1.getOrder() == 0 && o2.getOrder() != 0 )
+ {
+ return 1;
+ }
+
+ if ( o1.getOrder() != 0 && o2.getOrder() == 0 )
+ {
+ return -1;
+ }
+
+ return o1.getOrder() - o2.getOrder();
+ }
+
+ public static ProxyConnectorOrderComparator getInstance()
+ {
+ return INSTANCE;
+ }
+}
--- /dev/null
+package org.apache.archiva.admin.model.proxyconnector;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.commons.collections.Predicate;
+import org.apache.commons.lang.StringUtils;
+
+/**
+ * @author Olivier Lamy
+ * @since 1.4
+ */
+public class ProxyConnectorSelectionPredicate
+ implements Predicate
+{
+ private String sourceId;
+
+ private String targetId;
+
+ public ProxyConnectorSelectionPredicate( String sourceId, String targetId )
+ {
+ this.sourceId = sourceId;
+ this.targetId = targetId;
+ }
+
+ public boolean evaluate( Object object )
+ {
+ boolean satisfies = false;
+
+ if ( object instanceof ProxyConnector )
+ {
+ ProxyConnector connector = (ProxyConnector) object;
+ return ( StringUtils.equals( sourceId, connector.getSourceRepoId() ) && StringUtils.equals( targetId,
+ connector.getTargetRepoId() ) );
+ }
+
+ return satisfies;
+ }
+}
--- /dev/null
+package org.apache.archiva.admin.model.remote;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.admin.model.AbstractRepository;
+
+import java.io.Serializable;
+
+/**
+ * @author Olivier Lamy
+ * @since 1.4
+ */
+public class RemoteRepository
+ extends AbstractRepository
+ implements Serializable
+{
+
+ private String url;
+
+ private String userName;
+
+ private String password;
+
+ private int timeout = 60;
+
+ public RemoteRepository()
+ {
+ // no op
+ }
+
+ public RemoteRepository( String id, String name, String url, String layout )
+ {
+ super( id, name, layout );
+ this.url = url;
+ }
+
+ public RemoteRepository( String id, String name, String url, String layout, String userName, String password,
+ int timeOut )
+ {
+ super( id, name, layout );
+ this.url = url;
+ this.userName = userName;
+ this.password = password;
+ this.timeout = timeOut;
+ }
+
+ public String getUrl()
+ {
+ return url;
+ }
+
+ public void setUrl( String url )
+ {
+ this.url = url;
+ }
+
+ public String getUserName()
+ {
+ return userName;
+ }
+
+ public void setUserName( String userName )
+ {
+ this.userName = userName;
+ }
+
+ public String getPassword()
+ {
+ return password;
+ }
+
+ public void setPassword( String password )
+ {
+ this.password = password;
+ }
+
+ public int getTimeout()
+ {
+ return timeout;
+ }
+
+ public void setTimeout( int timeout )
+ {
+ this.timeout = timeout;
+ }
+
+ @Override
+ public String toString()
+ {
+ final StringBuilder sb = new StringBuilder();
+ sb.append( "RemoteRepository" );
+ sb.append( "{url='" ).append( url ).append( '\'' );
+ sb.append( ", userName='" ).append( userName ).append( '\'' );
+ sb.append( ", password='" ).append( password ).append( '\'' );
+ sb.append( ", timeout=" ).append( timeout );
+ sb.append( '}' );
+ sb.append( super.toString() );
+ return sb.toString();
+ }
+
+
+}
\ No newline at end of file
--- /dev/null
+package org.apache.archiva.admin.model.remote;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+import org.apache.archiva.admin.model.AuditInformation;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author Olivier Lamy
+ * @since 1.4
+ */
+public interface RemoteRepositoryAdmin
+{
+ List<RemoteRepository> getRemoteRepositories()
+ throws RepositoryAdminException;
+
+ RemoteRepository getRemoteRepository( String repositoryId )
+ throws RepositoryAdminException;
+
+ Boolean deleteRemoteRepository( String repositoryId, AuditInformation auditInformation )
+ throws RepositoryAdminException;
+
+ Boolean addRemoteRepository( RemoteRepository remoteRepository, AuditInformation auditInformation )
+ throws RepositoryAdminException;
+
+ Boolean updateRemoteRepository( RemoteRepository remoteRepository, AuditInformation auditInformation )
+ throws RepositoryAdminException;
+
+ Map<String, RemoteRepository> getRemoteRepositoriesAsMap()
+ throws RepositoryAdminException;
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>archiva-repository-admin</artifactId>
+ <version>1.4-SNAPSHOT</version>
+ </parent>
+ <artifactId>archiva-repository-admin-default</artifactId>
+ <name>Archiva Base :: Repository Admin Default</name>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>archiva-configuration</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>archiva-security-common</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>archiva-scheduler-repository</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>archiva-repository-admin-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>audit</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>javax.inject</groupId>
+ <artifactId>javax.inject</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>net.sf.beanlib</groupId>
+ <artifactId>beanlib</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>cglib</groupId>
+ <artifactId>cglib</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>aopalliance</groupId>
+ <artifactId>aopalliance</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context-support</artifactId>
+ <version>${spring.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ <version>${spring.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-validator</groupId>
+ <artifactId>commons-validator</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>oro</groupId>
+ <artifactId>oro</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.redback.components</groupId>
+ <artifactId>spring-quartz</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.redback</groupId>
+ <artifactId>redback-rbac-role-manager</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.redback</groupId>
+ <artifactId>redback-authentication-api</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codehaus.redback</groupId>
+ <artifactId>redback-users-memory</artifactId>
+ <scope>test</scope>
+ <version>${redback.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codehaus.redback</groupId>
+ <artifactId>redback-keys-memory</artifactId>
+ <scope>test</scope>
+ <version>${redback.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codehaus.redback</groupId>
+ <artifactId>redback-rbac-cached</artifactId>
+ <version>${redback.version}</version>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.derby</groupId>
+ <artifactId>derby</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl-over-slf4j</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>metadata-store-file</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <systemPropertyVariables>
+ <appserver.base>${project.build.outputDirectory}</appserver.base>
+ <plexus.home>${project.build.outputDirectory}</plexus.home>
+ </systemPropertyVariables>
+ </configuration>
+
+ </plugin>
+ </plugins>
+ </build>
+</project>
--- /dev/null
+package org.apache.archiva.admin.repository;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.admin.model.AuditInformation;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.audit.AuditEvent;
+import org.apache.archiva.audit.AuditListener;
+import org.apache.maven.archiva.configuration.ArchivaConfiguration;
+import org.apache.maven.archiva.configuration.Configuration;
+import org.apache.maven.archiva.configuration.IndeterminateConfigurationException;
+import org.codehaus.plexus.redback.users.User;
+import org.codehaus.plexus.registry.Registry;
+import org.codehaus.plexus.registry.RegistryException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Olivier Lamy
+ * @since 1.4
+ */
+public abstract class AbstractRepositoryAdmin
+{
+ protected Logger log = LoggerFactory.getLogger( getClass() );
+
+ @Inject
+ private List<AuditListener> auditListeners = new ArrayList<AuditListener>();
+
+
+ @Inject
+ private RepositoryCommonValidator repositoryCommonValidator;
+
+ @Inject
+ private ArchivaConfiguration archivaConfiguration;
+
+ @Inject
+ @Named( value = "commons-configuration" )
+ private Registry registry;
+
+ protected void triggerAuditEvent( String repositoryId, String resource, String action,
+ AuditInformation auditInformation )
+ {
+ User user = auditInformation == null ? null : auditInformation.getUser();
+ AuditEvent event =
+ new AuditEvent( repositoryId, user == null ? "null" : (String) user.getPrincipal(), resource, action );
+ event.setRemoteIP( auditInformation == null ? "null" : auditInformation.getRemoteAddr() );
+
+ for ( AuditListener listener : getAuditListeners() )
+ {
+ listener.auditEvent( event );
+ }
+
+ }
+
+ protected void saveConfiguration( Configuration config )
+ throws RepositoryAdminException
+ {
+ try
+ {
+ getArchivaConfiguration().save( config );
+ }
+ catch ( RegistryException e )
+ {
+ throw new RepositoryAdminException( "Error occurred in the registry.", e );
+ }
+ catch ( IndeterminateConfigurationException e )
+ {
+ throw new RepositoryAdminException( "Error occurred while saving the configuration.", e );
+ }
+ }
+
+ public List<AuditListener> getAuditListeners()
+ {
+ return auditListeners;
+ }
+
+ public void setAuditListeners( List<AuditListener> auditListeners )
+ {
+ this.auditListeners = auditListeners;
+ }
+
+ public void setArchivaConfiguration( ArchivaConfiguration archivaConfiguration )
+ {
+ this.archivaConfiguration = archivaConfiguration;
+ }
+
+ public ArchivaConfiguration getArchivaConfiguration()
+ {
+ return archivaConfiguration;
+ }
+
+ public RepositoryCommonValidator getRepositoryCommonValidator()
+ {
+ return repositoryCommonValidator;
+ }
+
+ public void setRepositoryCommonValidator( RepositoryCommonValidator repositoryCommonValidator )
+ {
+ this.repositoryCommonValidator = repositoryCommonValidator;
+ }
+
+ public Registry getRegistry()
+ {
+ return registry;
+ }
+
+ public void setRegistry( Registry registry )
+ {
+ this.registry = registry;
+ }
+}
--- /dev/null
+package org.apache.archiva.admin.repository;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.admin.model.AbstractRepository;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.validator.GenericValidator;
+import org.apache.maven.archiva.configuration.ArchivaConfiguration;
+import org.apache.maven.archiva.configuration.Configuration;
+import org.codehaus.plexus.registry.Registry;
+import org.springframework.stereotype.Service;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+/**
+ * apply basic repository validation : id and name.
+ * Check if already exists.
+ *
+ * @author Olivier Lamy
+ * @since 1.4
+ */
+@Service
+public class RepositoryCommonValidator
+{
+
+ public static final String REPOSITORY_ID_VALID_EXPRESSION = "^[a-zA-Z0-9._-]+$";
+
+ public static final String REPOSITORY_NAME_VALID_EXPRESSION = "^([a-zA-Z0-9.)/_(-]|\\s)+$";
+
+
+ @Inject
+ private ArchivaConfiguration archivaConfiguration;
+
+ @Inject
+ @Named( value = "commons-configuration" )
+ private Registry registry;
+
+ /**
+ * @param abstractRepository
+ * @param update in update mode if yes already exists won't be check
+ * @throws RepositoryAdminException
+ */
+ public void basicValidation( AbstractRepository abstractRepository, boolean update )
+ throws RepositoryAdminException
+ {
+ Configuration config = archivaConfiguration.getConfiguration();
+
+ String repoId = abstractRepository.getId();
+
+ if ( !update )
+ {
+
+ if ( config.getManagedRepositoriesAsMap().containsKey( repoId ) )
+ {
+ throw new RepositoryAdminException( "Unable to add new repository with id [" + repoId
+ + "], that id already exists as a managed repository." );
+ }
+ else if ( config.getRepositoryGroupsAsMap().containsKey( repoId ) )
+ {
+ throw new RepositoryAdminException( "Unable to add new repository with id [" + repoId
+ + "], that id already exists as a repository group." );
+ }
+ else if ( config.getRemoteRepositoriesAsMap().containsKey( repoId ) )
+ {
+ throw new RepositoryAdminException( "Unable to add new repository with id [" + repoId
+ + "], that id already exists as a remote repository." );
+ }
+ }
+
+ if ( StringUtils.isBlank( repoId ) )
+ {
+ throw new RepositoryAdminException( "Repository ID cannot be empty." );
+ }
+
+ if ( !GenericValidator.matchRegexp( repoId, REPOSITORY_ID_VALID_EXPRESSION ) )
+ {
+ throw new RepositoryAdminException(
+ "Invalid repository ID. Identifier must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
+ }
+
+ String name = abstractRepository.getName();
+
+ if ( StringUtils.isBlank( name ) )
+ {
+ throw new RepositoryAdminException( "repository name cannot be empty" );
+ }
+
+ if ( !GenericValidator.matchRegexp( name, REPOSITORY_NAME_VALID_EXPRESSION ) )
+ {
+ throw new RepositoryAdminException(
+ "Invalid repository name. Repository Name must only contain alphanumeric characters, white-spaces(' '), "
+ + "forward-slashes(/), open-parenthesis('('), close-parenthesis(')'), underscores(_), dots(.), and dashes(-)." );
+ }
+
+
+ }
+
+ /**
+ * replace some interpolations ${appserver.base} with correct values
+ *
+ * @param directory
+ * @return
+ */
+ public String removeExpressions( String directory )
+ {
+ String value = StringUtils.replace( directory, "${appserver.base}",
+ getRegistry().getString( "appserver.base", "${appserver.base}" ) );
+ value = StringUtils.replace( value, "${appserver.home}",
+ getRegistry().getString( "appserver.home", "${appserver.home}" ) );
+ return value;
+ }
+
+ public ArchivaConfiguration getArchivaConfiguration()
+ {
+ return archivaConfiguration;
+ }
+
+ public void setArchivaConfiguration( ArchivaConfiguration archivaConfiguration )
+ {
+ this.archivaConfiguration = archivaConfiguration;
+ }
+
+ public Registry getRegistry()
+ {
+ return registry;
+ }
+
+ public void setRegistry( Registry registry )
+ {
+ this.registry = registry;
+ }
+}
--- /dev/null
+package org.apache.archiva.admin.repository.admin;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import net.sf.beanlib.provider.replicator.BeanReplicator;
+import org.apache.archiva.admin.model.AuditInformation;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.admin.ArchivaAdministration;
+import org.apache.archiva.admin.model.admin.FileType;
+import org.apache.archiva.admin.model.admin.LegacyArtifactPath;
+import org.apache.archiva.admin.model.admin.OrganisationInformation;
+import org.apache.archiva.admin.repository.AbstractRepositoryAdmin;
+import org.apache.archiva.audit.AuditEvent;
+import org.apache.commons.lang.StringUtils;
+import org.apache.maven.archiva.configuration.Configuration;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * @author Olivier Lamy
+ */
+@Service( "archivaAdministration#default" )
+public class DefaultArchivaAdministration
+ extends AbstractRepositoryAdmin
+ implements ArchivaAdministration
+{
+ public List<LegacyArtifactPath> getLegacyArtifactPaths()
+ throws RepositoryAdminException
+ {
+ List<LegacyArtifactPath> legacyArtifactPaths = new ArrayList<LegacyArtifactPath>();
+ for ( org.apache.maven.archiva.configuration.LegacyArtifactPath legacyArtifactPath : getArchivaConfiguration().getConfiguration().getLegacyArtifactPaths() )
+ {
+ legacyArtifactPaths.add(
+ new BeanReplicator().replicateBean( legacyArtifactPath, LegacyArtifactPath.class ) );
+ }
+ return legacyArtifactPaths;
+
+ }
+
+ public void addLegacyArtifactPath( LegacyArtifactPath legacyArtifactPath, AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+ Configuration configuration = getArchivaConfiguration().getConfiguration();
+
+ configuration.addLegacyArtifactPath( new BeanReplicator().replicateBean( legacyArtifactPath,
+ org.apache.maven.archiva.configuration.LegacyArtifactPath.class ) );
+
+ saveConfiguration( configuration );
+ triggerAuditEvent( "", "", AuditEvent.ADD_LEGACY_PATH, auditInformation );
+ }
+
+ public void deleteLegacyArtifactPath( String path, AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+ Configuration configuration = getArchivaConfiguration().getConfiguration();
+ org.apache.maven.archiva.configuration.LegacyArtifactPath legacyArtifactPath =
+ new org.apache.maven.archiva.configuration.LegacyArtifactPath();
+
+ legacyArtifactPath.setPath( path );
+ configuration.removeLegacyArtifactPath( legacyArtifactPath );
+
+ saveConfiguration( configuration );
+ triggerAuditEvent( "", "", AuditEvent.REMOVE_LEGACY_PATH, auditInformation );
+ }
+
+
+ public void addFileTypePattern( String fileTypeId, String pattern, AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+ Configuration configuration = getArchivaConfiguration().getConfiguration();
+
+ org.apache.maven.archiva.configuration.FileType fileType = getFileTypeById( fileTypeId, configuration );
+ if ( fileType == null )
+ {
+ return;
+ }
+ fileType.addPattern( pattern );
+
+ saveConfiguration( configuration );
+ triggerAuditEvent( "", "", AuditEvent.ADD_PATTERN, auditInformation );
+ }
+
+ public void removeFileTypePattern( String fileTypeId, String pattern, AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+ Configuration configuration = getArchivaConfiguration().getConfiguration();
+
+ org.apache.maven.archiva.configuration.FileType fileType = getFileTypeById( fileTypeId, configuration );
+ if ( fileType == null )
+ {
+ return;
+ }
+ fileType.removePattern( pattern );
+
+ saveConfiguration( configuration );
+ triggerAuditEvent( "", "", AuditEvent.REMOVE_PATTERN, auditInformation );
+ }
+
+ public FileType getFileType( String fileTypeId )
+ throws RepositoryAdminException
+ {
+ org.apache.maven.archiva.configuration.FileType fileType =
+ getFileTypeById( fileTypeId, getArchivaConfiguration().getConfiguration() );
+ if ( fileType == null )
+ {
+ return null;
+ }
+ return new BeanReplicator().replicateBean( fileType, FileType.class );
+ }
+
+ public void addFileType( FileType fileType, AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+ Configuration configuration = getArchivaConfiguration().getConfiguration();
+ if ( getFileTypeById( fileType.getId(), configuration ) != null )
+ {
+ throw new RepositoryAdminException(
+ "impossible to FileType with id " + fileType.getId() + " already exists" );
+ }
+
+ configuration.getRepositoryScanning().addFileType(
+ new BeanReplicator().replicateBean( fileType, org.apache.maven.archiva.configuration.FileType.class ) );
+ saveConfiguration( configuration );
+ }
+
+ public void removeFileType( String fileTypeId, AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+ Configuration configuration = getArchivaConfiguration().getConfiguration();
+ org.apache.maven.archiva.configuration.FileType fileType =
+ new org.apache.maven.archiva.configuration.FileType();
+ fileType.setId( fileTypeId );
+ configuration.getRepositoryScanning().removeFileType( fileType );
+ saveConfiguration( configuration );
+ }
+
+ public void addKnownContentConsumer( String knownContentConsumer, AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+ Configuration configuration = getArchivaConfiguration().getConfiguration();
+ if ( configuration.getRepositoryScanning().getKnownContentConsumers().contains( knownContentConsumer ) )
+ {
+ log.warn( "skip adding knownContentConsumer {} as already here", knownContentConsumer );
+ return;
+ }
+ configuration.getRepositoryScanning().addKnownContentConsumer( knownContentConsumer );
+ saveConfiguration( configuration );
+ triggerAuditEvent( "", "", AuditEvent.ENABLE_REPO_CONSUMER, auditInformation );
+ }
+
+ public void removeKnownContentConsumer( String knownContentConsumer, AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+ Configuration configuration = getArchivaConfiguration().getConfiguration();
+ configuration.getRepositoryScanning().removeKnownContentConsumer( knownContentConsumer );
+ saveConfiguration( configuration );
+ triggerAuditEvent( "", "", AuditEvent.DISABLE_REPO_CONSUMER, auditInformation );
+ }
+
+ public void addInvalidContentConsumer( String invalidContentConsumer, AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+ Configuration configuration = getArchivaConfiguration().getConfiguration();
+ if ( configuration.getRepositoryScanning().getInvalidContentConsumers().contains( invalidContentConsumer ) )
+ {
+ log.warn( "skip adding invalidContentConsumer {} as already here", invalidContentConsumer );
+ return;
+ }
+ configuration.getRepositoryScanning().addInvalidContentConsumer( invalidContentConsumer );
+ saveConfiguration( configuration );
+ triggerAuditEvent( "", "", AuditEvent.ENABLE_REPO_CONSUMER, auditInformation );
+ }
+
+ public void removeInvalidContentConsumer( String invalidContentConsumer, AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+ Configuration configuration = getArchivaConfiguration().getConfiguration();
+ configuration.getRepositoryScanning().removeInvalidContentConsumer( invalidContentConsumer );
+ saveConfiguration( configuration );
+ triggerAuditEvent( "", "", AuditEvent.DISABLE_REPO_CONSUMER, auditInformation );
+ }
+
+ public void setKnownContentConsumers( List<String> knownContentConsumers, AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+ if ( knownContentConsumers == null )
+ {
+ return;
+ }
+ for ( String knowContentConsumer : knownContentConsumers )
+ {
+ addKnownContentConsumer( knowContentConsumer, auditInformation );
+ }
+ }
+
+ public void setInvalidContentConsumers( List<String> invalidContentConsumers, AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+ if ( invalidContentConsumers == null )
+ {
+ return;
+ }
+ for ( String invalidContentConsumer : invalidContentConsumers )
+ {
+ addKnownContentConsumer( invalidContentConsumer, auditInformation );
+ }
+ }
+
+ public List<FileType> getFileTypes()
+ throws RepositoryAdminException
+ {
+ List<org.apache.maven.archiva.configuration.FileType> configFileTypes =
+ getArchivaConfiguration().getConfiguration().getRepositoryScanning().getFileTypes();
+ if ( configFileTypes == null || configFileTypes.isEmpty() )
+ {
+ return Collections.emptyList();
+ }
+ List<FileType> fileTypes = new ArrayList<FileType>();
+ for ( org.apache.maven.archiva.configuration.FileType fileType : configFileTypes )
+ {
+ fileTypes.add( new BeanReplicator().replicateBean( fileType, FileType.class ) );
+ }
+ return fileTypes;
+ }
+
+ public List<String> getKnownContentConsumers()
+ throws RepositoryAdminException
+ {
+ return new ArrayList<String>(
+ getArchivaConfiguration().getConfiguration().getRepositoryScanning().getKnownContentConsumers() );
+ }
+
+ public List<String> getInvalidContentConsumers()
+ throws RepositoryAdminException
+ {
+ return new ArrayList<String>(
+ getArchivaConfiguration().getConfiguration().getRepositoryScanning().getInvalidContentConsumers() );
+ }
+
+ public OrganisationInformation getOrganisationInformation()
+ throws RepositoryAdminException
+ {
+ org.apache.maven.archiva.configuration.OrganisationInformation organisationInformation =
+ getArchivaConfiguration().getConfiguration().getOrganisationInfo();
+ if ( organisationInformation == null )
+ {
+ return null;
+ }
+ return new BeanReplicator().replicateBean( organisationInformation, OrganisationInformation.class );
+ }
+
+ public void setOrganisationInformation( OrganisationInformation organisationInformation )
+ throws RepositoryAdminException
+ {
+ Configuration configuration = getArchivaConfiguration().getConfiguration();
+ if ( organisationInformation != null )
+ {
+ org.apache.maven.archiva.configuration.OrganisationInformation organisationInformationModel =
+ new BeanReplicator().replicateBean( organisationInformation,
+ org.apache.maven.archiva.configuration.OrganisationInformation.class );
+ configuration.setOrganisationInfo( organisationInformationModel );
+ }
+ else
+ {
+ configuration.setOrganisationInfo( null );
+ }
+ saveConfiguration( configuration );
+ }
+
+ //-------------------------
+ //
+ //-------------------------
+
+ private org.apache.maven.archiva.configuration.FileType getFileTypeById( String id, Configuration configuration )
+ {
+ for ( org.apache.maven.archiva.configuration.FileType fileType : configuration.getRepositoryScanning().getFileTypes() )
+ {
+ if ( StringUtils.equals( id, fileType.getId() ) )
+ {
+ return fileType;
+ }
+ }
+ return null;
+ }
+
+}
--- /dev/null
+package org.apache.archiva.admin.repository.admin;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.admin.model.admin.FileType;
+import org.apache.commons.collections.Closure;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * FiletypeToMapClosure
+ *
+ * @since 1.4
+ */
+public class FiletypeToMapClosure
+ implements Closure
+{
+ private Map<String, FileType> map = new HashMap<String, FileType>();
+
+ public void execute( Object input )
+ {
+ if ( input instanceof FileType )
+ {
+ FileType filetype = (FileType) input;
+ map.put( filetype.getId(), filetype );
+ }
+ }
+
+ public Map<String, FileType> getMap()
+ {
+ return map;
+ }
+}
--- /dev/null
+package org.apache.archiva.admin.repository.group;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.admin.model.AuditInformation;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.group.RepositoryGroup;
+import org.apache.archiva.admin.model.group.RepositoryGroupAdmin;
+import org.apache.archiva.admin.model.managed.ManagedRepository;
+import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
+import org.apache.archiva.admin.repository.AbstractRepositoryAdmin;
+import org.apache.archiva.audit.AuditEvent;
+import org.apache.commons.lang.StringUtils;
+import org.apache.maven.archiva.configuration.Configuration;
+import org.apache.maven.archiva.configuration.RepositoryGroupConfiguration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+
+import javax.inject.Inject;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * @author Olivier Lamy
+ */
+@Service( "repositoryGroupAdmin#default" )
+public class DefaultRepositoryGroupAdmin
+ extends AbstractRepositoryAdmin
+ implements RepositoryGroupAdmin
+{
+
+ private Logger log = LoggerFactory.getLogger( getClass() );
+
+ private static final Pattern REPO_GROUP_ID_PATTERN = Pattern.compile( "[A-Za-z0-9\\._\\-]+" );
+
+ @Inject
+ private ManagedRepositoryAdmin managedRepositoryAdmin;
+
+ public List<RepositoryGroup> getRepositoriesGroups()
+ throws RepositoryAdminException
+ {
+ List<RepositoryGroup> repositoriesGroups = new ArrayList<RepositoryGroup>();
+
+ for ( RepositoryGroupConfiguration repositoryGroupConfiguration : getArchivaConfiguration().getConfiguration().getRepositoryGroups() )
+ {
+ repositoriesGroups.add( new RepositoryGroup( repositoryGroupConfiguration.getId(), new ArrayList<String>(
+ repositoryGroupConfiguration.getRepositories() ) ) );
+ }
+
+ return repositoriesGroups;
+ }
+
+ public RepositoryGroup getRepositoryGroup( String repositoryGroupId )
+ throws RepositoryAdminException
+ {
+ List<RepositoryGroup> repositoriesGroups = getRepositoriesGroups();
+ for ( RepositoryGroup repositoryGroup : repositoriesGroups )
+ {
+ if ( StringUtils.equals( repositoryGroupId, repositoryGroup.getId() ) )
+ {
+ return repositoryGroup;
+ }
+ }
+ return null;
+ }
+
+ public Boolean addRepositoryGroup( RepositoryGroup repositoryGroup, AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+ validateRepositoryGroup( repositoryGroup, false );
+ validateManagedRepositoriesExists( repositoryGroup.getRepositories() );
+ RepositoryGroupConfiguration repositoryGroupConfiguration = new RepositoryGroupConfiguration();
+ repositoryGroupConfiguration.setId( repositoryGroup.getId() );
+ repositoryGroupConfiguration.setRepositories( repositoryGroup.getRepositories() );
+ Configuration configuration = getArchivaConfiguration().getConfiguration();
+ configuration.addRepositoryGroup( repositoryGroupConfiguration );
+ saveConfiguration( configuration );
+ triggerAuditEvent( repositoryGroup.getId(), null, AuditEvent.ADD_REPO_GROUP, auditInformation );
+ return Boolean.TRUE;
+ }
+
+ public Boolean deleteRepositoryGroup( String repositoryGroupId, AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+ Configuration configuration = getArchivaConfiguration().getConfiguration();
+ RepositoryGroupConfiguration repositoryGroupConfiguration =
+ configuration.getRepositoryGroupsAsMap().get( repositoryGroupId );
+ if ( repositoryGroupConfiguration == null )
+ {
+ throw new RepositoryAdminException(
+ "repositoryGroup with id " + repositoryGroupId + " doesn't not exists so cannot remove" );
+ }
+ configuration.removeRepositoryGroup( repositoryGroupConfiguration );
+ triggerAuditEvent( repositoryGroupId, null, AuditEvent.DELETE_REPO_GROUP, auditInformation );
+ return Boolean.TRUE;
+ }
+
+ public Boolean updateRepositoryGroup( RepositoryGroup repositoryGroup, AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+ return updateRepositoryGroup( repositoryGroup, auditInformation, true );
+ }
+
+ private Boolean updateRepositoryGroup( RepositoryGroup repositoryGroup, AuditInformation auditInformation,
+ boolean triggerAuditEvent )
+ throws RepositoryAdminException
+ {
+ validateRepositoryGroup( repositoryGroup, true );
+ validateManagedRepositoriesExists( repositoryGroup.getRepositories() );
+ Configuration configuration = getArchivaConfiguration().getConfiguration();
+
+ RepositoryGroupConfiguration repositoryGroupConfiguration =
+ configuration.getRepositoryGroupsAsMap().get( repositoryGroup.getId() );
+
+ configuration.removeRepositoryGroup( repositoryGroupConfiguration );
+
+ repositoryGroupConfiguration.setRepositories( repositoryGroup.getRepositories() );
+ configuration.addRepositoryGroup( repositoryGroupConfiguration );
+
+ saveConfiguration( configuration );
+ if ( triggerAuditEvent )
+ {
+ triggerAuditEvent( repositoryGroup.getId(), null, AuditEvent.MODIFY_REPO_GROUP, auditInformation );
+ }
+ return Boolean.TRUE;
+ }
+
+
+ public Boolean addRepositoryToGroup( String repositoryGroupId, String repositoryId,
+ AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+ RepositoryGroup repositoryGroup = getRepositoryGroup( repositoryGroupId );
+ if ( repositoryGroup == null )
+ {
+ throw new RepositoryAdminException(
+ "repositoryGroup with id " + repositoryGroupId + " doesn't not exists so cannot add repository to it" );
+ }
+
+ if ( repositoryGroup.getRepositories().contains( repositoryId ) )
+ {
+ throw new RepositoryAdminException(
+ "repositoryGroup with id " + repositoryGroupId + " already contain repository with id" + repositoryId );
+ }
+ validateManagedRepositoriesExists( Arrays.asList( repositoryId ) );
+
+ repositoryGroup.addRepository( repositoryId );
+ updateRepositoryGroup( repositoryGroup, auditInformation, false );
+ triggerAuditEvent( repositoryGroup.getId(), null, AuditEvent.ADD_REPO_TO_GROUP, auditInformation );
+ return Boolean.TRUE;
+ }
+
+ public Boolean deleteRepositoryFromGroup( String repositoryGroupId, String repositoryId,
+ AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+ RepositoryGroup repositoryGroup = getRepositoryGroup( repositoryGroupId );
+ if ( repositoryGroup == null )
+ {
+ throw new RepositoryAdminException( "repositoryGroup with id " + repositoryGroupId
+ + " doesn't not exists so cannot remove repository from it" );
+ }
+
+ if ( !repositoryGroup.getRepositories().contains( repositoryId ) )
+ {
+ throw new RepositoryAdminException(
+ "repositoryGroup with id " + repositoryGroupId + " doesn't not contains repository with id"
+ + repositoryId );
+ }
+
+ repositoryGroup.removeRepository( repositoryId );
+ updateRepositoryGroup( repositoryGroup, auditInformation, false );
+ triggerAuditEvent( repositoryGroup.getId(), null, AuditEvent.DELETE_REPO_FROM_GROUP, auditInformation );
+ return Boolean.TRUE;
+ }
+
+ public Map<String, RepositoryGroup> getRepositoryGroupsAsMap()
+ throws RepositoryAdminException
+ {
+ List<RepositoryGroup> repositoriesGroups = getRepositoriesGroups();
+ Map<String, RepositoryGroup> map = new HashMap<String, RepositoryGroup>( repositoriesGroups.size() );
+ for ( RepositoryGroup repositoryGroup : repositoriesGroups )
+ {
+ map.put( repositoryGroup.getId(), repositoryGroup );
+ }
+ return map;
+ }
+
+ public Map<String, List<String>> getGroupToRepositoryMap()
+ throws RepositoryAdminException
+ {
+
+ java.util.Map<String, java.util.List<String>> map = new java.util.HashMap<String, java.util.List<String>>();
+
+ for ( ManagedRepository repo : getManagedRepositoryAdmin().getManagedRepositories() )
+ {
+ for ( RepositoryGroup group : getRepositoriesGroups() )
+ {
+ if ( !group.getRepositories().contains( repo.getId() ) )
+ {
+ String groupId = group.getId();
+ java.util.List<String> repos = map.get( groupId );
+ if ( repos == null )
+ {
+ repos = new java.util.ArrayList<String>();
+ map.put( groupId, repos );
+ }
+ repos.add( repo.getId() );
+ }
+ }
+ }
+ return map;
+ }
+
+ public Map<String, List<String>> getRepositoryToGroupMap()
+ throws RepositoryAdminException
+ {
+ java.util.Map<String, java.util.List<String>> map = new java.util.HashMap<String, java.util.List<String>>();
+
+ for ( RepositoryGroup group : getRepositoriesGroups() )
+ {
+ for ( String repositoryId : group.getRepositories() )
+ {
+ java.util.List<String> groups = map.get( repositoryId );
+ if ( groups == null )
+ {
+ groups = new java.util.ArrayList<String>();
+ map.put( repositoryId, groups );
+ }
+ groups.add( group.getId() );
+ }
+ }
+ return map;
+ }
+
+ public Boolean validateRepositoryGroup( RepositoryGroup repositoryGroup, boolean updateMode )
+ throws RepositoryAdminException
+ {
+ String repoGroupId = repositoryGroup.getId();
+ if ( StringUtils.isBlank( repoGroupId ) )
+ {
+ throw new RepositoryAdminException( "repositoryGroup id cannot be empty" );
+ }
+
+ if ( repoGroupId.length() > 100 )
+ {
+ throw new RepositoryAdminException(
+ "Identifier [" + repoGroupId + "] is over the maximum limit of 100 characters" );
+
+ }
+
+ Matcher matcher = REPO_GROUP_ID_PATTERN.matcher( repoGroupId );
+ if ( !matcher.matches() )
+ {
+ throw new RepositoryAdminException(
+ "Invalid character(s) found in identifier. Only the following characters are allowed: alphanumeric, '.', '-' and '_'" );
+ }
+
+ Configuration configuration = getArchivaConfiguration().getConfiguration();
+
+ if ( configuration.getRepositoryGroupsAsMap().containsKey( repoGroupId ) )
+ {
+ if ( !updateMode )
+ {
+ throw new RepositoryAdminException( "Unable to add new repository group with id [" + repoGroupId
+ + "], that id already exists as a repository group." );
+ }
+ }
+ else if ( configuration.getManagedRepositoriesAsMap().containsKey( repoGroupId ) )
+ {
+ throw new RepositoryAdminException( "Unable to add new repository group with id [" + repoGroupId
+ + "], that id already exists as a managed repository." );
+ }
+ else if ( configuration.getRemoteRepositoriesAsMap().containsKey( repoGroupId ) )
+ {
+ throw new RepositoryAdminException( "Unable to add new repository group with id [" + repoGroupId
+ + "], that id already exists as a remote repository." );
+ }
+
+ return Boolean.TRUE;
+ }
+
+ private void validateManagedRepositoriesExists( List<String> managedRepositoriesIds )
+ throws RepositoryAdminException
+ {
+ for ( String id : managedRepositoriesIds )
+ {
+ if ( getManagedRepositoryAdmin().getManagedRepository( id ) == null )
+ {
+ throw new RepositoryAdminException(
+ "managedRepository with id " + id + " not exists so cannot be used in a repositoryGroup" );
+ }
+ }
+ }
+
+ public ManagedRepositoryAdmin getManagedRepositoryAdmin()
+ {
+ return managedRepositoryAdmin;
+ }
+
+ public void setManagedRepositoryAdmin( ManagedRepositoryAdmin managedRepositoryAdmin )
+ {
+ this.managedRepositoryAdmin = managedRepositoryAdmin;
+ }
+}
--- /dev/null
+package org.apache.archiva.admin.repository.managed;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.admin.model.AuditInformation;
+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.admin.repository.AbstractRepositoryAdmin;
+import org.apache.archiva.audit.AuditEvent;
+import org.apache.archiva.metadata.repository.MetadataRepository;
+import org.apache.archiva.metadata.repository.MetadataRepositoryException;
+import org.apache.archiva.metadata.repository.RepositorySession;
+import org.apache.archiva.metadata.repository.RepositorySessionFactory;
+import org.apache.archiva.metadata.repository.stats.RepositoryStatisticsManager;
+import org.apache.archiva.scheduler.repository.RepositoryArchivaTaskScheduler;
+import org.apache.archiva.scheduler.repository.RepositoryTask;
+import org.apache.archiva.security.common.ArchivaRoleConstants;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.validator.GenericValidator;
+import org.apache.maven.archiva.configuration.Configuration;
+import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
+import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration;
+import org.apache.maven.archiva.configuration.RepositoryGroupConfiguration;
+import org.codehaus.plexus.redback.role.RoleManager;
+import org.codehaus.plexus.redback.role.RoleManagerException;
+import org.codehaus.plexus.taskqueue.TaskQueueException;
+import org.codehaus.redback.components.scheduler.CronExpressionValidator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * FIXME remove all generic Exception to have usefull ones
+ * FIXME review the staging mechanism to have a per user session one
+ *
+ * @author Olivier Lamy
+ */
+@Service( "managedRepositoryAdmin#default" )
+public class DefaultManagedRepositoryAdmin
+ extends AbstractRepositoryAdmin
+ implements ManagedRepositoryAdmin
+{
+
+ public static final String REPOSITORY_LOCATION_VALID_EXPRESSION = "^[-a-zA-Z0-9._/~:?!&=\\\\]+$";
+
+ private Logger log = LoggerFactory.getLogger( getClass() );
+
+ public static final String STAGE_REPO_ID_END = "-stage";
+
+
+ @Inject
+ @Named( value = "archivaTaskScheduler#repository" )
+ private RepositoryArchivaTaskScheduler repositoryTaskScheduler;
+
+ @Inject
+ private RepositorySessionFactory repositorySessionFactory;
+
+ @Inject
+ private RepositoryStatisticsManager repositoryStatisticsManager;
+
+
+ @Inject
+ protected RoleManager roleManager;
+
+ public List<ManagedRepository> getManagedRepositories()
+ throws RepositoryAdminException
+ {
+ List<ManagedRepositoryConfiguration> managedRepoConfigs =
+ getArchivaConfiguration().getConfiguration().getManagedRepositories();
+
+ List<ManagedRepository> managedRepos = new ArrayList<ManagedRepository>( managedRepoConfigs.size() );
+
+ for ( ManagedRepositoryConfiguration repoConfig : managedRepoConfigs )
+ {
+ // TODO add staging repo information back too
+ ManagedRepository repo =
+ new ManagedRepository( repoConfig.getId(), repoConfig.getName(), repoConfig.getLocation(),
+ repoConfig.getLayout(), repoConfig.isSnapshots(), repoConfig.isReleases(),
+ repoConfig.isBlockRedeployments(), repoConfig.getRefreshCronExpression(),
+ repoConfig.getIndexDir(), repoConfig.isScanned(), repoConfig.getDaysOlder(),
+ repoConfig.getRetentionCount(), repoConfig.isDeleteReleasedSnapshots() );
+
+ managedRepos.add( repo );
+ }
+
+ return managedRepos;
+ }
+
+ public Map<String, ManagedRepository> getManagedRepositoriesAsMap()
+ throws RepositoryAdminException
+ {
+ List<ManagedRepository> managedRepositories = getManagedRepositories();
+ Map<String, ManagedRepository> repositoriesMap =
+ new HashMap<String, ManagedRepository>( managedRepositories.size() );
+ for ( ManagedRepository managedRepository : managedRepositories )
+ {
+ repositoriesMap.put( managedRepository.getId(), managedRepository );
+ }
+ return repositoriesMap;
+ }
+
+ public ManagedRepository getManagedRepository( String repositoryId )
+ throws RepositoryAdminException
+ {
+ List<ManagedRepository> repos = getManagedRepositories();
+ for ( ManagedRepository repo : repos )
+ {
+ if ( StringUtils.equals( repo.getId(), repositoryId ) )
+ {
+ return repo;
+ }
+ }
+ return null;
+ }
+
+ public Boolean addManagedRepository( ManagedRepository managedRepository, boolean needStageRepo,
+ AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+
+ getRepositoryCommonValidator().basicValidation( managedRepository, false );
+ triggerAuditEvent( managedRepository.getId(), null, AuditEvent.ADD_MANAGED_REPO, auditInformation );
+ return
+ addManagedRepository( managedRepository.getId(), managedRepository.getLayout(), managedRepository.getName(),
+ managedRepository.getLocation(), managedRepository.isBlockRedeployments(),
+ managedRepository.isReleases(), managedRepository.isSnapshots(), needStageRepo,
+ managedRepository.getCronExpression(), managedRepository.getIndexDirectory(),
+ managedRepository.getDaysOlder(), managedRepository.getRetentionCount(),
+ managedRepository.isDeleteReleasedSnapshots(), auditInformation,
+ getArchivaConfiguration().getConfiguration() ) != null;
+
+ }
+
+ private ManagedRepositoryConfiguration addManagedRepository( String repoId, String layout, String name,
+ String location, boolean blockRedeployments,
+ boolean releasesIncluded, boolean snapshotsIncluded,
+ boolean stageRepoNeeded, String cronExpression,
+ String indexDir, int daysOlder, int retentionCount,
+ boolean deteleReleasedSnapshots,
+ AuditInformation auditInformation,
+ Configuration config )
+ throws RepositoryAdminException
+ {
+
+ // FIXME : olamy can be empty to avoid scheduled scan ?
+ if ( StringUtils.isNotBlank( cronExpression ) )
+ {
+ CronExpressionValidator validator = new CronExpressionValidator();
+
+ if ( !validator.validate( cronExpression ) )
+ {
+ throw new RepositoryAdminException( "Invalid cron expression." );
+ }
+ }
+ else
+ {
+ throw new RepositoryAdminException( "Cron expression cannot be empty." );
+ }
+
+ String repoLocation = getRepositoryCommonValidator().removeExpressions( location );
+
+ if ( !GenericValidator.matchRegexp( repoLocation, REPOSITORY_LOCATION_VALID_EXPRESSION ) )
+ {
+ throw new RepositoryAdminException(
+ "Invalid repository location. Directory must only contain alphanumeric characters, equals(=), question-marks(?), "
+ + "exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-)." );
+ }
+
+ ManagedRepositoryConfiguration repository = new ManagedRepositoryConfiguration();
+
+ repository.setId( repoId );
+ repository.setBlockRedeployments( blockRedeployments );
+ repository.setReleases( releasesIncluded );
+ repository.setSnapshots( snapshotsIncluded );
+ repository.setName( name );
+ repository.setLocation( repoLocation );
+ repository.setLayout( layout );
+ repository.setRefreshCronExpression( cronExpression );
+ repository.setIndexDir( indexDir );
+ repository.setDaysOlder( daysOlder );
+ repository.setRetentionCount( retentionCount );
+ repository.setDeleteReleasedSnapshots( deteleReleasedSnapshots );
+
+
+ try
+ {
+ addRepository( repository, config );
+ addRepositoryRoles( repository );
+
+ if ( stageRepoNeeded )
+ {
+ ManagedRepositoryConfiguration stagingRepository = getStageRepoConfig( repository );
+ addRepository( stagingRepository, config );
+ addRepositoryRoles( stagingRepository );
+ triggerAuditEvent( stagingRepository.getId(), null, AuditEvent.ADD_MANAGED_REPO, auditInformation );
+ }
+ }
+ catch ( RoleManagerException e )
+ {
+ throw new RepositoryAdminException( "failed to add repository roles " + e.getMessage(), e );
+ }
+ catch ( IOException e )
+ {
+ throw new RepositoryAdminException( "failed to add repository " + e.getMessage(), e );
+ }
+
+ saveConfiguration( config );
+
+ //MRM-1342 Repository statistics report doesn't appear to be working correctly
+ //scan repository when adding of repository is successful
+ try
+ {
+ scanRepository( repoId, true );
+ // olamy no need of scanning staged repo
+ /*
+ if ( stageRepoNeeded )
+ {
+ ManagedRepositoryConfiguration stagingRepository = getStageRepoConfig( repository );
+ scanRepository( stagingRepository.getId(), true );
+ }*/
+ }
+ catch ( Exception e )
+ {
+ log.warn( new StringBuilder( "Unable to scan repository [" ).append( repoId ).append( "]: " ).append(
+ e.getMessage() ).toString(), e );
+ }
+
+ return repository;
+ }
+
+
+ // FIXME cleanup repositoryGroups when deleting a ManagedRepo
+ public Boolean deleteManagedRepository( String repositoryId, AuditInformation auditInformation,
+ boolean deleteContent )
+ throws RepositoryAdminException
+ {
+ Configuration config = getArchivaConfiguration().getConfiguration();
+
+ ManagedRepositoryConfiguration repository = config.findManagedRepositoryById( repositoryId );
+
+ if ( repository == null )
+ {
+ throw new RepositoryAdminException( "A repository with that id does not exist" );
+ }
+
+ triggerAuditEvent( repositoryId, null, AuditEvent.DELETE_MANAGED_REPO, auditInformation );
+
+ deleteManagedRepository( repository, deleteContent, config, false );
+
+ // stage repo exists ?
+ ManagedRepositoryConfiguration stagingRepository =
+ getArchivaConfiguration().getConfiguration().findManagedRepositoryById( repositoryId + STAGE_REPO_ID_END );
+ if ( stagingRepository != null )
+ {
+ // do not trigger event when deleting the staged one
+ //triggerAuditEvent( stagingRepository.getId(), null, AuditEvent.DELETE_MANAGED_REPO, auditInformation );
+ deleteManagedRepository( stagingRepository, deleteContent, config, true );
+ }
+
+ try
+ {
+ saveConfiguration( config );
+ }
+ catch ( Exception e )
+ {
+ throw new RepositoryAdminException( "Error saving configuration for delete action" + e.getMessage() );
+ }
+
+ return Boolean.TRUE;
+ }
+
+ private Boolean deleteManagedRepository( ManagedRepositoryConfiguration repository, boolean deleteContent,
+ Configuration config, boolean stagedOne )
+ throws RepositoryAdminException
+ {
+ if ( !stagedOne )
+ {
+ RepositorySession repositorySession = getRepositorySessionFactory().createSession();
+ try
+ {
+ MetadataRepository metadataRepository = repositorySession.getRepository();
+ metadataRepository.removeRepository( repository.getId() );
+ log.debug( "call repositoryStatisticsManager.deleteStatistics" );
+ getRepositoryStatisticsManager().deleteStatistics( metadataRepository, repository.getId() );
+ repositorySession.save();
+ }
+ catch ( MetadataRepositoryException e )
+ {
+ throw new RepositoryAdminException( e.getMessage(), e );
+ }
+ finally
+ {
+ repositorySession.close();
+ }
+ }
+ config.removeManagedRepository( repository );
+
+ if ( deleteContent )
+ {
+ // TODO could be async ? as directory can be huge
+ File dir = new File( repository.getLocation() );
+ if ( !FileUtils.deleteQuietly( dir ) )
+ {
+ throw new RepositoryAdminException( "Cannot delete repository " + dir );
+ }
+ }
+
+ // olamy: copy list for reading as a unit test in webapp fail with ConcurrentModificationException
+ List<ProxyConnectorConfiguration> proxyConnectors =
+ new ArrayList<ProxyConnectorConfiguration>( config.getProxyConnectors() );
+ for ( ProxyConnectorConfiguration proxyConnector : proxyConnectors )
+ {
+ if ( StringUtils.equals( proxyConnector.getSourceRepoId(), repository.getId() ) )
+ {
+ config.removeProxyConnector( proxyConnector );
+ }
+ }
+
+ Map<String, List<String>> repoToGroupMap = config.getRepositoryToGroupMap();
+ if ( repoToGroupMap != null )
+ {
+ if ( repoToGroupMap.containsKey( repository.getId() ) )
+ {
+ List<String> repoGroups = repoToGroupMap.get( repository.getId() );
+ for ( String repoGroup : repoGroups )
+ {
+ // copy to prevent UnsupportedOperationException
+ RepositoryGroupConfiguration repositoryGroupConfiguration =
+ config.findRepositoryGroupById( repoGroup );
+ List<String> repos = new ArrayList<String>( repositoryGroupConfiguration.getRepositories() );
+ config.removeRepositoryGroup( repositoryGroupConfiguration );
+ repos.remove( repository.getId() );
+ repositoryGroupConfiguration.setRepositories( repos );
+ config.addRepositoryGroup( repositoryGroupConfiguration );
+ }
+ }
+ }
+
+ try
+ {
+ removeRepositoryRoles( repository );
+ }
+ catch ( RoleManagerException e )
+ {
+ throw new RepositoryAdminException(
+ "fail to remove repository roles for repository " + repository.getId() + " : " + e.getMessage(), e );
+ }
+
+ saveConfiguration( config );
+
+ return Boolean.TRUE;
+ }
+
+
+ public Boolean updateManagedRepository( ManagedRepository managedRepository, boolean needStageRepo,
+ AuditInformation auditInformation, boolean resetStats )
+ throws RepositoryAdminException
+ {
+
+ log.debug( "updateManagedConfiguration repo {} needStage {} resetStats {} ",
+ Arrays.asList( managedRepository, needStageRepo, resetStats ).toArray() );
+
+ // Ensure that the fields are valid.
+
+ getRepositoryCommonValidator().basicValidation( managedRepository, true );
+
+ Configuration configuration = getArchivaConfiguration().getConfiguration();
+
+ ManagedRepositoryConfiguration toremove = configuration.findManagedRepositoryById( managedRepository.getId() );
+
+ if ( toremove != null )
+ {
+ configuration.removeManagedRepository( toremove );
+ }
+
+ ManagedRepositoryConfiguration stagingRepository = getStageRepoConfig( toremove );
+
+ // TODO remove content from old if path has changed !!!!!
+
+ if ( stagingRepository != null )
+ {
+ configuration.removeManagedRepository( stagingRepository );
+ }
+
+ ManagedRepositoryConfiguration managedRepositoryConfiguration =
+ addManagedRepository( managedRepository.getId(), managedRepository.getLayout(), managedRepository.getName(),
+ managedRepository.getLocation(), managedRepository.isBlockRedeployments(),
+ managedRepository.isReleases(), managedRepository.isSnapshots(), needStageRepo,
+ managedRepository.getCronExpression(), managedRepository.getIndexDirectory(),
+ managedRepository.getDaysOlder(), managedRepository.getRetentionCount(),
+ managedRepository.isDeleteReleasedSnapshots(), auditInformation,
+ getArchivaConfiguration().getConfiguration() );
+
+ // Save the repository configuration.
+ RepositorySession repositorySession = getRepositorySessionFactory().createSession();
+
+ try
+ {
+ triggerAuditEvent( managedRepositoryConfiguration.getId(), null, AuditEvent.MODIFY_MANAGED_REPO,
+ auditInformation );
+
+ saveConfiguration( this.getArchivaConfiguration().getConfiguration() );
+ if ( resetStats )
+ {
+ log.debug( "call repositoryStatisticsManager.deleteStatistics" );
+ getRepositoryStatisticsManager().deleteStatistics( repositorySession.getRepository(),
+ managedRepositoryConfiguration.getId() );
+ repositorySession.save();
+ }
+
+ }
+ catch ( MetadataRepositoryException e )
+ {
+ throw new RepositoryAdminException( e.getMessage(), e );
+ }
+ finally
+ {
+ repositorySession.close();
+ }
+
+ return true;
+ }
+
+ //--------------------------
+ // utils methods
+ //--------------------------
+
+
+ protected void addRepository( ManagedRepositoryConfiguration repository, Configuration configuration )
+ throws RepositoryAdminException, IOException
+ {
+ // Normalize the path
+ File file = new File( repository.getLocation() );
+ repository.setLocation( file.getCanonicalPath() );
+ if ( !file.exists() )
+ {
+ file.mkdirs();
+ }
+ if ( !file.exists() || !file.isDirectory() )
+ {
+ throw new RepositoryAdminException(
+ "Unable to add repository - no write access, can not create the root directory: " + file );
+ }
+
+ configuration.addManagedRepository( repository );
+ }
+
+ private ManagedRepositoryConfiguration getStageRepoConfig( ManagedRepositoryConfiguration repository )
+ {
+ ManagedRepositoryConfiguration stagingRepository = new ManagedRepositoryConfiguration();
+ stagingRepository.setId( repository.getId() + STAGE_REPO_ID_END );
+ stagingRepository.setLayout( repository.getLayout() );
+ stagingRepository.setName( repository.getName() + STAGE_REPO_ID_END );
+ stagingRepository.setBlockRedeployments( repository.isBlockRedeployments() );
+ stagingRepository.setDaysOlder( repository.getDaysOlder() );
+ stagingRepository.setDeleteReleasedSnapshots( repository.isDeleteReleasedSnapshots() );
+ stagingRepository.setIndexDir( repository.getIndexDir() );
+ String path = repository.getLocation();
+ int lastIndex = path.lastIndexOf( '/' );
+ stagingRepository.setLocation( path.substring( 0, lastIndex ) + "/" + stagingRepository.getId() );
+ stagingRepository.setRefreshCronExpression( repository.getRefreshCronExpression() );
+ stagingRepository.setReleases( repository.isReleases() );
+ stagingRepository.setRetentionCount( repository.getRetentionCount() );
+ stagingRepository.setScanned( repository.isScanned() );
+ stagingRepository.setSnapshots( repository.isSnapshots() );
+ return stagingRepository;
+ }
+
+ public Boolean scanRepository( String repositoryId, boolean fullScan )
+ {
+ if ( getRepositoryTaskScheduler().isProcessingRepositoryTask( repositoryId ) )
+ {
+ log.info( "scanning of repository with id {} already scheduled", repositoryId );
+ }
+ RepositoryTask task = new RepositoryTask();
+ task.setRepositoryId( repositoryId );
+ task.setScanAll( fullScan );
+ try
+ {
+ getRepositoryTaskScheduler().queueTask( task );
+ }
+ catch ( TaskQueueException e )
+ {
+ log.error( "failed to schedule scanning of repo with id {}", repositoryId, e );
+ return false;
+ }
+ return true;
+ }
+
+ 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 ( !getRoleManager().templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, repoId ) )
+ {
+ getRoleManager().createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, repoId );
+ }
+
+ if ( !getRoleManager().templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, repoId ) )
+ {
+ getRoleManager().createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, repoId );
+ }
+ }
+
+ protected void removeRepositoryRoles( ManagedRepositoryConfiguration existingRepository )
+ throws RoleManagerException
+ {
+ String repoId = existingRepository.getId();
+
+ if ( getRoleManager().templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, repoId ) )
+ {
+ getRoleManager().removeTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, repoId );
+ }
+
+ if ( getRoleManager().templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, repoId ) )
+ {
+ getRoleManager().removeTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, repoId );
+ }
+
+ log.debug( "removed user roles associated with repository {}", repoId );
+ }
+
+ //--------------------------
+ // setters/getters
+ //--------------------------
+
+
+ public RoleManager getRoleManager()
+ {
+ return roleManager;
+ }
+
+ public void setRoleManager( RoleManager roleManager )
+ {
+ this.roleManager = roleManager;
+ }
+
+ public RepositoryStatisticsManager getRepositoryStatisticsManager()
+ {
+ return repositoryStatisticsManager;
+ }
+
+ public void setRepositoryStatisticsManager( RepositoryStatisticsManager repositoryStatisticsManager )
+ {
+ this.repositoryStatisticsManager = repositoryStatisticsManager;
+ }
+
+ public RepositorySessionFactory getRepositorySessionFactory()
+ {
+ return repositorySessionFactory;
+ }
+
+ public void setRepositorySessionFactory( RepositorySessionFactory repositorySessionFactory )
+ {
+ this.repositorySessionFactory = repositorySessionFactory;
+ }
+
+
+ public RepositoryArchivaTaskScheduler getRepositoryTaskScheduler()
+ {
+ return repositoryTaskScheduler;
+ }
+
+ public void setRepositoryTaskScheduler( RepositoryArchivaTaskScheduler repositoryTaskScheduler )
+ {
+ this.repositoryTaskScheduler = repositoryTaskScheduler;
+ }
+}
--- /dev/null
+package org.apache.archiva.admin.repository.networkproxy;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import net.sf.beanlib.provider.replicator.BeanReplicator;
+import org.apache.archiva.admin.model.AuditInformation;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.networkproxy.NetworkProxy;
+import org.apache.archiva.admin.model.networkproxy.NetworkProxyAdmin;
+import org.apache.archiva.admin.repository.AbstractRepositoryAdmin;
+import org.apache.archiva.audit.AuditEvent;
+import org.apache.commons.lang.StringUtils;
+import org.apache.maven.archiva.configuration.Configuration;
+import org.apache.maven.archiva.configuration.NetworkProxyConfiguration;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Olivier Lamy
+ * @since 1.4
+ */
+@Service( "networkProxyAdmin#default" )
+public class DefaultNetworkProxyAdmin
+ extends AbstractRepositoryAdmin
+ implements NetworkProxyAdmin
+{
+
+ public List<NetworkProxy> getNetworkProxies()
+ throws RepositoryAdminException
+ {
+ List<NetworkProxy> networkProxies = new ArrayList<NetworkProxy>();
+ for ( NetworkProxyConfiguration networkProxyConfiguration : getArchivaConfiguration().getConfiguration().getNetworkProxies() )
+ {
+ networkProxies.add( getNetworkProxy( networkProxyConfiguration ) );
+ }
+ return networkProxies;
+ }
+
+ public NetworkProxy getNetworkProxy( String networkProxyId )
+ throws RepositoryAdminException
+ {
+ for ( NetworkProxy networkProxy : getNetworkProxies() )
+ {
+ if ( StringUtils.equals( networkProxyId, networkProxy.getId() ) )
+ {
+ return networkProxy;
+ }
+ }
+
+ return null;
+ }
+
+ public void addNetworkProxy( NetworkProxy networkProxy, AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+ if ( networkProxy == null )
+ {
+ return;
+ }
+ if ( getNetworkProxy( networkProxy.getId() ) != null )
+ {
+ throw new RepositoryAdminException(
+ "cannot add NetworkProxy with id " + networkProxy.getId() + " already exist" );
+ }
+ Configuration configuration = getArchivaConfiguration().getConfiguration();
+ configuration.addNetworkProxy( getNetworkProxyConfiguration( networkProxy ) );
+
+ triggerAuditEvent( networkProxy.getId(), null, AuditEvent.ADD_NETWORK_PROXY, auditInformation );
+
+ saveConfiguration( configuration );
+ }
+
+ public void updateNetworkProxy( NetworkProxy networkProxy, AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+ if ( networkProxy == null )
+ {
+ return;
+ }
+ if ( getNetworkProxy( networkProxy.getId() ) == null )
+ {
+ throw new RepositoryAdminException(
+ "cannot update NetworkProxy with id " + networkProxy.getId() + " as not exist" );
+ }
+ Configuration configuration = getArchivaConfiguration().getConfiguration();
+ NetworkProxyConfiguration networkProxyConfiguration = getNetworkProxyConfiguration( networkProxy );
+ configuration.removeNetworkProxy( networkProxyConfiguration );
+ configuration.addNetworkProxy( networkProxyConfiguration );
+
+ triggerAuditEvent( networkProxy.getId(), null, AuditEvent.MODIFY_NETWORK_PROXY, auditInformation );
+
+ saveConfiguration( configuration );
+ }
+
+ public void deleteNetworkProxy( String networkProxyId, AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+
+ NetworkProxy networkProxy = getNetworkProxy( networkProxyId );
+ if ( networkProxy == null )
+ {
+ throw new RepositoryAdminException(
+ "cannot delete NetworkProxy with id " + networkProxyId + " as not exist" );
+ }
+ Configuration configuration = getArchivaConfiguration().getConfiguration();
+ NetworkProxyConfiguration networkProxyConfiguration = getNetworkProxyConfiguration( networkProxy );
+ configuration.removeNetworkProxy( networkProxyConfiguration );
+
+ triggerAuditEvent( networkProxy.getId(), null, AuditEvent.DELETE_NETWORK_PROXY, auditInformation );
+
+ saveConfiguration( configuration );
+ }
+
+ protected NetworkProxy getNetworkProxy( NetworkProxyConfiguration networkProxyConfiguration )
+ {
+ return networkProxyConfiguration == null
+ ? null
+ : new BeanReplicator().replicateBean( networkProxyConfiguration, NetworkProxy.class );
+ }
+
+ protected NetworkProxyConfiguration getNetworkProxyConfiguration( NetworkProxy networkProxy )
+ {
+ return networkProxy == null
+ ? null
+ : new BeanReplicator().replicateBean( networkProxy, NetworkProxyConfiguration.class );
+ }
+}
--- /dev/null
+package org.apache.archiva.admin.repository.proxyconnector;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import net.sf.beanlib.provider.replicator.BeanReplicator;
+import org.apache.archiva.admin.model.AuditInformation;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
+import org.apache.archiva.admin.model.proxyconnector.ProxyConnector;
+import org.apache.archiva.admin.model.proxyconnector.ProxyConnectorAdmin;
+import org.apache.archiva.admin.model.proxyconnector.ProxyConnectorOrderComparator;
+import org.apache.archiva.admin.model.remote.RemoteRepositoryAdmin;
+import org.apache.archiva.admin.repository.AbstractRepositoryAdmin;
+import org.apache.archiva.audit.AuditEvent;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.maven.archiva.configuration.Configuration;
+import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration;
+import org.apache.maven.archiva.configuration.functors.ProxyConnectorSelectionPredicate;
+import org.springframework.stereotype.Service;
+
+import javax.inject.Inject;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author Olivier Lamy
+ * @since 1.4
+ */
+@Service( "proxyConnectorAdmin#default" )
+public class DefaultProxyConnectorAdmin
+ extends AbstractRepositoryAdmin
+ implements ProxyConnectorAdmin
+{
+
+ @Inject
+ private ManagedRepositoryAdmin managedRepositoryAdmin;
+
+ @Inject
+ private RemoteRepositoryAdmin remoteRepositoryAdmin;
+
+ public List<ProxyConnector> getProxyConnectors()
+ throws RepositoryAdminException
+ {
+ List<ProxyConnectorConfiguration> proxyConnectorConfigurations =
+ getArchivaConfiguration().getConfiguration().getProxyConnectors();
+ List<ProxyConnector> proxyConnectors = new ArrayList<ProxyConnector>( proxyConnectorConfigurations.size() );
+ for ( ProxyConnectorConfiguration configuration : proxyConnectorConfigurations )
+ {
+ proxyConnectors.add( getProxyConnector( configuration ) );
+ }
+
+ return proxyConnectors;
+ }
+
+ public ProxyConnector getProxyConnector( String sourceRepoId, String targetRepoId )
+ throws RepositoryAdminException
+ {
+ for ( ProxyConnector proxyConnector : getProxyConnectors() )
+ {
+ if ( StringUtils.equals( sourceRepoId, proxyConnector.getSourceRepoId() ) && StringUtils.equals(
+ targetRepoId, proxyConnector.getTargetRepoId() ) )
+ {
+ return proxyConnector;
+ }
+ }
+ return null;
+ }
+
+ public Boolean addProxyConnector( ProxyConnector proxyConnector, AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+ if ( getProxyConnector( proxyConnector.getSourceRepoId(), proxyConnector.getTargetRepoId() ) != null )
+ {
+ throw new RepositoryAdminException(
+ "Unable to add proxy connector, as one already exists with source repository id ["
+ + proxyConnector.getSourceRepoId() + "] and target repository id ["
+ + proxyConnector.getTargetRepoId() + "]." );
+ }
+
+ validateProxyConnector( proxyConnector );
+
+ proxyConnector.setBlackListPatterns( unescapePatterns( proxyConnector.getBlackListPatterns() ) );
+ proxyConnector.setWhiteListPatterns( unescapePatterns( proxyConnector.getWhiteListPatterns() ) );
+
+ Configuration configuration = getArchivaConfiguration().getConfiguration();
+
+ ProxyConnectorConfiguration proxyConnectorConfiguration = getProxyConnectorConfiguration( proxyConnector );
+ configuration.addProxyConnector( proxyConnectorConfiguration );
+ saveConfiguration( configuration );
+ triggerAuditEvent( proxyConnector.getSourceRepoId() + "-" + proxyConnector.getTargetRepoId(), null,
+ AuditEvent.ADD_PROXY_CONNECTOR, auditInformation );
+ return Boolean.TRUE;
+
+ }
+
+ public Boolean deleteProxyConnector( ProxyConnector proxyConnector, AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+ Configuration configuration = getArchivaConfiguration().getConfiguration();
+ ProxyConnectorConfiguration proxyConnectorConfiguration =
+ findProxyConnector( proxyConnector.getSourceRepoId(), proxyConnector.getTargetRepoId(), configuration );
+ if ( proxyConnectorConfiguration == null )
+ {
+ throw new RepositoryAdminException(
+ "unable to find ProxyConnector with source " + proxyConnector.getSourceRepoId() + " and target "
+ + proxyConnector.getTargetRepoId() );
+ }
+ configuration.removeProxyConnector( proxyConnectorConfiguration );
+ saveConfiguration( configuration );
+ triggerAuditEvent( proxyConnector.getSourceRepoId() + "-" + proxyConnector.getTargetRepoId(), null,
+ AuditEvent.DELETE_PROXY_CONNECTOR, auditInformation );
+ return Boolean.TRUE;
+ }
+
+ public Boolean updateProxyConnector( ProxyConnector proxyConnector, AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+ Configuration configuration = getArchivaConfiguration().getConfiguration();
+ ProxyConnectorConfiguration proxyConnectorConfiguration =
+ findProxyConnector( proxyConnector.getSourceRepoId(), proxyConnector.getTargetRepoId(), configuration );
+ configuration.removeProxyConnector( proxyConnectorConfiguration );
+ configuration.addProxyConnector( getProxyConnectorConfiguration( proxyConnector ) );
+ triggerAuditEvent( proxyConnector.getSourceRepoId() + "-" + proxyConnector.getTargetRepoId(), null,
+ AuditEvent.MODIFY_PROXY_CONNECTOR, auditInformation );
+ return Boolean.TRUE;
+ }
+
+ protected List<String> unescapePatterns( List<String> patterns )
+ {
+ List<String> rawPatterns = new ArrayList<String>();
+ if ( patterns != null )
+ {
+ for ( String pattern : patterns )
+ {
+ rawPatterns.add( StringUtils.replace( pattern, "\\\\", "\\" ) );
+ }
+ }
+
+ return rawPatterns;
+ }
+
+ public Map<String, List<ProxyConnector>> getProxyConnectorAsMap()
+ throws RepositoryAdminException
+ {
+ Map<String, List<ProxyConnector>> proxyConnectorMap = new HashMap<String, java.util.List<ProxyConnector>>();
+
+ Iterator<ProxyConnector> it = getProxyConnectors().iterator();
+ while ( it.hasNext() )
+ {
+ ProxyConnector proxyConfig = it.next();
+ String key = proxyConfig.getSourceRepoId();
+
+ List<ProxyConnector> connectors = proxyConnectorMap.get( key );
+ if ( connectors == null )
+ {
+ connectors = new ArrayList<ProxyConnector>();
+ proxyConnectorMap.put( key, connectors );
+ }
+
+ connectors.add( proxyConfig );
+
+ Collections.sort( connectors, ProxyConnectorOrderComparator.getInstance() );
+ }
+
+ return proxyConnectorMap;
+ }
+
+ private ProxyConnectorConfiguration findProxyConnector( String sourceId, String targetId,
+ Configuration configuration )
+ {
+ if ( StringUtils.isBlank( sourceId ) )
+ {
+ return null;
+ }
+
+ if ( StringUtils.isBlank( targetId ) )
+ {
+ return null;
+ }
+
+ ProxyConnectorSelectionPredicate selectedProxy = new ProxyConnectorSelectionPredicate( sourceId, targetId );
+ return (ProxyConnectorConfiguration) CollectionUtils.find( configuration.getProxyConnectors(), selectedProxy );
+ }
+
+ protected ProxyConnectorConfiguration getProxyConnectorConfiguration( ProxyConnector proxyConnector )
+ {
+ /*
+ ProxyConnectorConfiguration proxyConnectorConfiguration = new ProxyConnectorConfiguration();
+ proxyConnectorConfiguration.setOrder( proxyConnector.getOrder() );
+ proxyConnectorConfiguration.setBlackListPatterns(
+ new ArrayList<String>( proxyConnector.getBlackListPatterns() ) );
+ proxyConnectorConfiguration.setWhiteListPatterns(
+ new ArrayList<String>( proxyConnector.getWhiteListPatterns() ) );
+ proxyConnectorConfiguration.setDisabled( proxyConnector.isDisabled() );
+ proxyConnectorConfiguration.setPolicies( new HashMap( proxyConnector.getPolicies() ) );
+ proxyConnectorConfiguration.setProperties( new HashMap( proxyConnector.getProperties() ) );
+ proxyConnectorConfiguration.setProxyId( proxyConnector.getProxyId() );
+ proxyConnectorConfiguration.setSourceRepoId( proxyConnector.getSourceRepoId() );
+ proxyConnectorConfiguration.setTargetRepoId( proxyConnector.getTargetRepoId() );
+ return proxyConnectorConfiguration;*/
+
+ return proxyConnector == null
+ ? null
+ : new BeanReplicator().replicateBean( proxyConnector, ProxyConnectorConfiguration.class );
+ }
+
+ protected ProxyConnector getProxyConnector( ProxyConnectorConfiguration proxyConnectorConfiguration )
+ {
+ return proxyConnectorConfiguration == null
+ ? null
+ : new BeanReplicator().replicateBean( proxyConnectorConfiguration, ProxyConnector.class );
+ }
+
+ protected void validateProxyConnector( ProxyConnector proxyConnector )
+ throws RepositoryAdminException
+ {
+ // validate source a Managed target a Remote
+ if ( managedRepositoryAdmin.getManagedRepository( proxyConnector.getSourceRepoId() ) == null )
+ {
+ throw new RepositoryAdminException(
+ "non valid ProxyConnector sourceRepo with id " + proxyConnector.getSourceRepoId()
+ + " is not a ManagedRepository" );
+ }
+ if ( remoteRepositoryAdmin.getRemoteRepository( proxyConnector.getTargetRepoId() ) == null )
+ {
+ throw new RepositoryAdminException(
+ "non valid ProxyConnector sourceRepo with id " + proxyConnector.getTargetRepoId()
+ + " is not a RemoteRepository" );
+ }
+
+ // FIXME validate NetworkProxyConfiguration too when available
+ }
+}
--- /dev/null
+package org.apache.archiva.admin.repository.remote;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.admin.model.AuditInformation;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.remote.RemoteRepository;
+import org.apache.archiva.admin.model.remote.RemoteRepositoryAdmin;
+import org.apache.archiva.admin.repository.AbstractRepositoryAdmin;
+import org.apache.archiva.audit.AuditEvent;
+import org.apache.commons.lang.StringUtils;
+import org.apache.maven.archiva.configuration.Configuration;
+import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration;
+import org.apache.maven.archiva.configuration.RemoteRepositoryConfiguration;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author Olivier Lamy
+ * @since 1.4
+ */
+@Service( "remoteRepositoryAdmin#default" )
+public class DefaultRemoteRepositoryAdmin
+ extends AbstractRepositoryAdmin
+ implements RemoteRepositoryAdmin
+{
+
+
+ public List<RemoteRepository> getRemoteRepositories()
+ throws RepositoryAdminException
+ {
+ List<RemoteRepository> remoteRepositories = new ArrayList<RemoteRepository>();
+ for ( RemoteRepositoryConfiguration repositoryConfiguration : getArchivaConfiguration().getConfiguration().getRemoteRepositories() )
+ {
+ remoteRepositories.add(
+ new RemoteRepository( repositoryConfiguration.getId(), repositoryConfiguration.getName(),
+ repositoryConfiguration.getUrl(), repositoryConfiguration.getLayout(),
+ repositoryConfiguration.getUsername(), repositoryConfiguration.getPassword(),
+ repositoryConfiguration.getTimeout() ) );
+ }
+ return remoteRepositories;
+ }
+
+ public RemoteRepository getRemoteRepository( String repositoryId )
+ throws RepositoryAdminException
+ {
+ for ( RemoteRepository remoteRepository : getRemoteRepositories() )
+ {
+ if ( StringUtils.equals( repositoryId, remoteRepository.getId() ) )
+ {
+ return remoteRepository;
+ }
+ }
+ return null;
+ }
+
+ public Boolean addRemoteRepository( RemoteRepository remoteRepository, AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+ triggerAuditEvent( remoteRepository.getId(), null, AuditEvent.ADD_REMOTE_REPO, auditInformation );
+ getRepositoryCommonValidator().basicValidation( remoteRepository, false );
+
+ //TODO we can validate it's a good uri/url
+ if ( StringUtils.isEmpty( remoteRepository.getUrl() ) )
+ {
+ throw new RepositoryAdminException( "url cannot be null" );
+ }
+
+ //MRM-752 - url needs trimming
+ remoteRepository.setUrl( StringUtils.trim( remoteRepository.getUrl() ) );
+
+ RemoteRepositoryConfiguration remoteRepositoryConfiguration =
+ getRemoteRepositoryConfiguration( remoteRepository );
+
+ Configuration configuration = getArchivaConfiguration().getConfiguration();
+ configuration.addRemoteRepository( remoteRepositoryConfiguration );
+ saveConfiguration( configuration );
+
+ return Boolean.TRUE;
+ }
+
+ public Boolean deleteRemoteRepository( String repositoryId, AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+
+ triggerAuditEvent( repositoryId, null, AuditEvent.DELETE_REMOTE_REPO, auditInformation );
+
+ Configuration configuration = getArchivaConfiguration().getConfiguration();
+
+ RemoteRepositoryConfiguration remoteRepositoryConfiguration =
+ configuration.getRemoteRepositoriesAsMap().get( repositoryId );
+ if ( remoteRepositoryConfiguration == null )
+ {
+ throw new RepositoryAdminException(
+ "remoteRepository with id " + repositoryId + " not exist cannot remove it" );
+ }
+
+ configuration.removeRemoteRepository( remoteRepositoryConfiguration );
+
+ // TODO use ProxyConnectorAdmin interface ?
+ // [MRM-520] Proxy Connectors are not deleted with the deletion of a Repository.
+ List<ProxyConnectorConfiguration> proxyConnectors =
+ new ArrayList<ProxyConnectorConfiguration>( configuration.getProxyConnectors() );
+ for ( ProxyConnectorConfiguration proxyConnector : proxyConnectors )
+ {
+ if ( StringUtils.equals( proxyConnector.getTargetRepoId(), repositoryId ) )
+ {
+ configuration.removeProxyConnector( proxyConnector );
+ }
+ }
+
+ saveConfiguration( configuration );
+
+ return Boolean.TRUE;
+ }
+
+ public Boolean updateRemoteRepository( RemoteRepository remoteRepository, AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+
+ String repositoryId = remoteRepository.getId();
+
+ triggerAuditEvent( repositoryId, null, AuditEvent.MODIFY_REMOTE_REPO, auditInformation );
+
+ // update means : remove and add
+
+ Configuration configuration = getArchivaConfiguration().getConfiguration();
+
+ RemoteRepositoryConfiguration remoteRepositoryConfiguration =
+ configuration.getRemoteRepositoriesAsMap().get( repositoryId );
+ if ( remoteRepositoryConfiguration == null )
+ {
+ throw new RepositoryAdminException(
+ "remoteRepository with id " + repositoryId + " not exist cannot remove it" );
+ }
+
+ configuration.removeRemoteRepository( remoteRepositoryConfiguration );
+
+ remoteRepositoryConfiguration = getRemoteRepositoryConfiguration( remoteRepository );
+ configuration.addRemoteRepository( remoteRepositoryConfiguration );
+ saveConfiguration( configuration );
+
+ return Boolean.TRUE;
+ }
+
+ public Map<String, RemoteRepository> getRemoteRepositoriesAsMap()
+ throws RepositoryAdminException
+ {
+ java.util.Map<String, RemoteRepository> map = new HashMap<String, RemoteRepository>();
+
+ for ( RemoteRepository repo : getRemoteRepositories() )
+ {
+ map.put( repo.getId(), repo );
+ }
+
+ return map;
+ }
+
+ private RemoteRepositoryConfiguration getRemoteRepositoryConfiguration( RemoteRepository remoteRepository )
+ {
+ RemoteRepositoryConfiguration remoteRepositoryConfiguration = new RemoteRepositoryConfiguration();
+ remoteRepositoryConfiguration.setId( remoteRepository.getId() );
+ remoteRepositoryConfiguration.setPassword( remoteRepository.getPassword() );
+ remoteRepositoryConfiguration.setTimeout( remoteRepository.getTimeout() );
+ remoteRepositoryConfiguration.setUrl( remoteRepository.getUrl() );
+ remoteRepositoryConfiguration.setUsername( remoteRepository.getUserName() );
+ remoteRepositoryConfiguration.setLayout( remoteRepository.getLayout() );
+ remoteRepositoryConfiguration.setName( remoteRepository.getName() );
+ return remoteRepositoryConfiguration;
+ }
+
+}
--- /dev/null
+package org.apache.archiva.admin.repository.utils;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.admin.model.AbstractRepository;
+
+import java.util.Comparator;
+
+/**
+ * @author Olivier Lamy
+ * @since 1.4
+ */
+public class RepositoryComparator
+ implements Comparator<AbstractRepository>
+{
+ public int compare( AbstractRepository o1, AbstractRepository o2 )
+ {
+ if ( o1 == null && o2 == null )
+ {
+ return 0;
+ }
+
+ if ( o1 == null )
+ {
+ return -1;
+ }
+
+ if ( o2 == null )
+ {
+ return 1;
+ }
+
+ return o1.getId().compareToIgnoreCase( o2.getId() );
+ }
+}
--- /dev/null
+<?xml version="1.0"?>
+
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+<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-3.0.xsd
+ http://www.springframework.org/schema/context
+ http://www.springframework.org/schema/context/spring-context-3.0.xsd" default-lazy-init="true">
+
+
+ <context:annotation-config />
+ <context:component-scan
+ base-package="org.apache.archiva.admin.repository"/>
+
+
+
+</beans>
\ No newline at end of file
--- /dev/null
+package org.apache.archiva.admin.mock;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.audit.AuditEvent;
+import org.apache.archiva.audit.AuditListener;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Olivier Lamy
+ */
+@Service( "auditListener#mock" )
+public class MockAuditListener
+ implements AuditListener
+{
+
+ private List<AuditEvent> auditEvents = new ArrayList<AuditEvent>();
+
+ public void auditEvent( AuditEvent event )
+ {
+ auditEvents.add( event );
+ }
+
+ public List<AuditEvent> getAuditEvents()
+ {
+ return auditEvents;
+ }
+
+ public void clearEvents()
+ {
+ auditEvents.clear();
+ }
+}
--- /dev/null
+package org.apache.archiva.admin.repository;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import junit.framework.TestCase;
+import org.apache.archiva.admin.mock.MockAuditListener;
+import org.apache.archiva.admin.model.AuditInformation;
+import org.apache.archiva.admin.model.managed.ManagedRepository;
+import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
+import org.apache.archiva.admin.model.proxyconnector.ProxyConnectorAdmin;
+import org.apache.archiva.admin.model.remote.RemoteRepository;
+import org.apache.archiva.admin.model.remote.RemoteRepositoryAdmin;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang.StringUtils;
+import org.codehaus.plexus.redback.role.RoleManager;
+import org.codehaus.plexus.redback.users.User;
+import org.codehaus.plexus.redback.users.memory.SimpleUser;
+import org.junit.runner.RunWith;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import javax.inject.Inject;
+import java.io.File;
+import java.util.List;
+
+/**
+ * @author Olivier Lamy
+ */
+@RunWith( SpringJUnit4ClassRunner.class )
+@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml" } )
+public abstract class AbstractRepositoryAdminTest
+ extends TestCase
+{
+ protected Logger log = LoggerFactory.getLogger( getClass() );
+
+ public static final String APPSERVER_BASE_PATH = System.getProperty( "appserver.base" );
+
+ @Inject
+ protected MockAuditListener mockAuditListener;
+
+ @Inject
+ protected RoleManager roleManager;
+
+ @Inject
+ protected RemoteRepositoryAdmin remoteRepositoryAdmin;
+
+ @Inject
+ protected ManagedRepositoryAdmin managedRepositoryAdmin;
+
+ @Inject
+ protected ProxyConnectorAdmin proxyConnectorAdmin;
+
+ protected AuditInformation getFakeAuditInformation()
+ {
+ AuditInformation auditInformation = new AuditInformation( getFakeUser(), "archiva-localhost" );
+ return auditInformation;
+ }
+
+ protected User getFakeUser()
+ {
+ SimpleUser user = new SimpleUser()
+ {
+ @Override
+ public Object getPrincipal()
+ {
+ return "root";
+ }
+
+ };
+
+ user.setUsername( "root" );
+ user.setFullName( "The top user" );
+ return user;
+ }
+
+ protected ManagedRepository getTestManagedRepository( String repoId, String repoLocation )
+ {
+ return new ManagedRepository( repoId, "test repo", repoLocation, "default", false, true, true, "0 0 * * * ?",
+ repoLocation + "/.index", false, 1, 2, true );
+ }
+
+ protected File clearRepoLocation( String path )
+ throws Exception
+ {
+ File repoDir = new File( path );
+ if ( repoDir.exists() )
+ {
+ FileUtils.deleteDirectory( repoDir );
+ }
+ assertFalse( repoDir.exists() );
+ return repoDir;
+ }
+
+ protected ManagedRepository findManagedRepoById( List<ManagedRepository> repos, String id )
+ {
+ for ( ManagedRepository repo : repos )
+ {
+ if ( StringUtils.equals( id, repo.getId() ) )
+ {
+ return repo;
+ }
+ }
+ return null;
+ }
+
+ protected RemoteRepository getRemoteRepository()
+ {
+ return getRemoteRepository( "foo" );
+ }
+
+ protected RemoteRepository getRemoteRepository(String id)
+ {
+ RemoteRepository remoteRepository = new RemoteRepository();
+ remoteRepository.setUrl( "http://foo.com/maven-it-rocks" );
+ remoteRepository.setTimeout( 10 );
+ remoteRepository.setName( "maven foo" );
+ remoteRepository.setUserName( "foo-name" );
+ remoteRepository.setPassword( "toto" );
+ remoteRepository.setId( id );
+ return remoteRepository;
+ }
+}
--- /dev/null
+package org.apache.archiva.admin.repository.admin;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.admin.ArchivaAdministration;
+import org.apache.archiva.admin.model.admin.FileType;
+import org.apache.archiva.admin.model.admin.LegacyArtifactPath;
+import org.apache.archiva.admin.model.admin.OrganisationInformation;
+import org.apache.archiva.admin.repository.AbstractRepositoryAdminTest;
+import org.apache.archiva.audit.AuditEvent;
+import org.junit.Test;
+
+import javax.inject.Inject;
+import java.util.Arrays;
+
+/**
+ * @author Olivier Lamy
+ */
+public class ArchivaAdministrationTest
+ extends AbstractRepositoryAdminTest
+{
+ @Inject
+ ArchivaAdministration archivaAdministration;
+
+
+ @Test
+ public void getAllLegacyPaths()
+ throws Exception
+ {
+ assertNotNull( archivaAdministration.getLegacyArtifactPaths() );
+ assertFalse( archivaAdministration.getLegacyArtifactPaths().isEmpty() );
+ assertEquals( 1, archivaAdministration.getLegacyArtifactPaths().size() );
+ log.info( "all legacy paths {}", archivaAdministration.getLegacyArtifactPaths() );
+ }
+
+ public void addAndDeleteLegacyPath()
+ throws Exception
+ {
+ int initialSize = archivaAdministration.getLegacyArtifactPaths().size();
+
+ LegacyArtifactPath legacyArtifactPath = new LegacyArtifactPath( "foo", "bar" );
+ archivaAdministration.addLegacyArtifactPath( legacyArtifactPath, getFakeAuditInformation() );
+
+ assertTrue( archivaAdministration.getLegacyArtifactPaths().contains( new LegacyArtifactPath( "foo", "bar" ) ) );
+ assertEquals( initialSize + 1, archivaAdministration.getLegacyArtifactPaths().size() );
+
+ archivaAdministration.deleteLegacyArtifactPath( legacyArtifactPath.getPath(), getFakeAuditInformation() );
+
+ assertFalse(
+ archivaAdministration.getLegacyArtifactPaths().contains( new LegacyArtifactPath( "foo", "bar" ) ) );
+ assertEquals( initialSize, archivaAdministration.getLegacyArtifactPaths().size() );
+ mockAuditListener.clearEvents();
+ }
+
+ @Test
+ public void addAndUpdateAndDeleteFileType()
+ throws RepositoryAdminException
+ {
+ int initialSize = archivaAdministration.getFileTypes().size();
+
+ FileType fileType = new FileType();
+ fileType.setId( "foo" );
+ fileType.setPatterns( Arrays.asList( "bar", "toto" ) );
+
+ archivaAdministration.addFileType( fileType, getFakeAuditInformation() );
+
+ assertEquals( initialSize + 1, archivaAdministration.getFileTypes().size() );
+
+ archivaAdministration.addFileTypePattern( "foo", "zorro", getFakeAuditInformation() );
+
+ assertEquals( initialSize + 1, archivaAdministration.getFileTypes().size() );
+
+ assertEquals( 3, archivaAdministration.getFileType( "foo" ).getPatterns().size() );
+
+ assertTrue( archivaAdministration.getFileType( "foo" ).getPatterns().contains( "bar" ) );
+ assertTrue( archivaAdministration.getFileType( "foo" ).getPatterns().contains( "toto" ) );
+ assertTrue( archivaAdministration.getFileType( "foo" ).getPatterns().contains( "zorro" ) );
+
+ archivaAdministration.removeFileTypePattern( "foo", "zorro", getFakeAuditInformation() );
+
+ assertEquals( initialSize + 1, archivaAdministration.getFileTypes().size() );
+
+ assertEquals( 2, archivaAdministration.getFileType( "foo" ).getPatterns().size() );
+
+ assertTrue( archivaAdministration.getFileType( "foo" ).getPatterns().contains( "bar" ) );
+ assertTrue( archivaAdministration.getFileType( "foo" ).getPatterns().contains( "toto" ) );
+ assertFalse( archivaAdministration.getFileType( "foo" ).getPatterns().contains( "zorro" ) );
+
+ archivaAdministration.removeFileType( "foo", getFakeAuditInformation() );
+
+ assertEquals( initialSize, archivaAdministration.getFileTypes().size() );
+ assertNull( archivaAdministration.getFileType( "foo" ) );
+ mockAuditListener.clearEvents();
+ }
+
+ @Test
+ public void knownContentConsumersTest()
+ throws Exception
+ {
+ int initialSize = archivaAdministration.getKnownContentConsumers().size();
+
+ archivaAdministration.addKnownContentConsumer( "foo", getFakeAuditInformation() );
+
+ assertEquals( initialSize + 1, archivaAdministration.getKnownContentConsumers().size() );
+ assertTrue( archivaAdministration.getKnownContentConsumers().contains( "foo" ) );
+
+ // ensure we don't add it twice as it's an ArrayList as storage
+ archivaAdministration.addKnownContentConsumer( "foo", getFakeAuditInformation() );
+
+ assertEquals( initialSize + 1, archivaAdministration.getKnownContentConsumers().size() );
+ assertTrue( archivaAdministration.getKnownContentConsumers().contains( "foo" ) );
+
+ archivaAdministration.removeKnownContentConsumer( "foo", getFakeAuditInformation() );
+
+ assertEquals( initialSize, archivaAdministration.getKnownContentConsumers().size() );
+ assertFalse( archivaAdministration.getKnownContentConsumers().contains( "foo" ) );
+
+ assertEquals( 2, mockAuditListener.getAuditEvents().size() );
+ assertEquals( AuditEvent.ENABLE_REPO_CONSUMER, mockAuditListener.getAuditEvents().get( 0 ).getAction() );
+ assertEquals( AuditEvent.DISABLE_REPO_CONSUMER, mockAuditListener.getAuditEvents().get( 1 ).getAction() );
+
+ mockAuditListener.clearEvents();
+
+ }
+
+ @Test
+ public void invalidContentConsumersTest()
+ throws Exception
+ {
+ int initialSize = archivaAdministration.getInvalidContentConsumers().size();
+
+ archivaAdministration.addInvalidContentConsumer( "foo", getFakeAuditInformation() );
+
+ assertEquals( initialSize + 1, archivaAdministration.getInvalidContentConsumers().size() );
+ assertTrue( archivaAdministration.getInvalidContentConsumers().contains( "foo" ) );
+
+ // ensure we don't add it twice as it's an ArrayList as storage
+ archivaAdministration.addInvalidContentConsumer( "foo", getFakeAuditInformation() );
+
+ assertEquals( initialSize + 1, archivaAdministration.getInvalidContentConsumers().size() );
+ assertTrue( archivaAdministration.getInvalidContentConsumers().contains( "foo" ) );
+
+ archivaAdministration.removeInvalidContentConsumer( "foo", getFakeAuditInformation() );
+
+ assertEquals( initialSize, archivaAdministration.getInvalidContentConsumers().size() );
+ assertFalse( archivaAdministration.getInvalidContentConsumers().contains( "foo" ) );
+
+ assertEquals( 2, mockAuditListener.getAuditEvents().size() );
+ assertEquals( AuditEvent.ENABLE_REPO_CONSUMER, mockAuditListener.getAuditEvents().get( 0 ).getAction() );
+ assertEquals( AuditEvent.DISABLE_REPO_CONSUMER, mockAuditListener.getAuditEvents().get( 1 ).getAction() );
+
+ mockAuditListener.clearEvents();
+
+ }
+
+
+ public void organisationInfoUpdate()
+ throws Exception
+ {
+ OrganisationInformation organisationInformation = archivaAdministration.getOrganisationInformation();
+ assertNull( organisationInformation );
+
+ organisationInformation = new OrganisationInformation();
+ organisationInformation.setLogoLocation( "http://foo.com/bar.png" );
+ organisationInformation.setName( "foo org" );
+ organisationInformation.setUrl( "http:/foo.com" );
+
+ archivaAdministration.setOrganisationInformation( organisationInformation );
+
+ organisationInformation = archivaAdministration.getOrganisationInformation();
+ assertNotNull( organisationInformation );
+ assertEquals( "http://foo.com/bar.png", organisationInformation.getLogoLocation() );
+ assertEquals( "foo org", organisationInformation.getName() );
+ assertEquals( "http://foo.com", organisationInformation.getUrl() );
+
+ }
+}
--- /dev/null
+package org.apache.archiva.admin.repository.group;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.admin.model.group.RepositoryGroup;
+import org.apache.archiva.admin.model.group.RepositoryGroupAdmin;
+import org.apache.archiva.admin.model.managed.ManagedRepository;
+import org.apache.archiva.admin.repository.AbstractRepositoryAdminTest;
+import org.apache.archiva.audit.AuditEvent;
+import org.junit.Test;
+
+import javax.inject.Inject;
+import java.io.File;
+import java.util.Arrays;
+
+/**
+ * @author Olivier Lamy
+ */
+public class RepositoryGroupAdminTest
+ extends AbstractRepositoryAdminTest
+{
+ @Inject
+ RepositoryGroupAdmin repositoryGroupAdmin;
+
+ @Test
+ public void addAndDeleteGroup()
+ throws Exception
+ {
+ try
+ {
+ ManagedRepository managedRepositoryOne =
+ getTestManagedRepository( "test-new-one", APPSERVER_BASE_PATH + File.separator + "test-new-one" );
+
+ ManagedRepository managedRepositoryTwo =
+ getTestManagedRepository( "test-new-two", APPSERVER_BASE_PATH + File.separator + "test-new-two" );
+
+ managedRepositoryAdmin.addManagedRepository( managedRepositoryOne, false, getFakeAuditInformation() );
+
+ managedRepositoryAdmin.addManagedRepository( managedRepositoryTwo, false, getFakeAuditInformation() );
+
+ RepositoryGroup repositoryGroup =
+ new RepositoryGroup( "repo-group-one", Arrays.asList( "test-new-one", "test-new-two" ) );
+
+ mockAuditListener.clearEvents();
+
+ repositoryGroupAdmin.addRepositoryGroup( repositoryGroup, getFakeAuditInformation() );
+
+ assertEquals( 1, repositoryGroupAdmin.getRepositoriesGroups().size() );
+ assertEquals( "repo-group-one", repositoryGroupAdmin.getRepositoriesGroups().get( 0 ).getId() );
+ assertEquals( 2, repositoryGroupAdmin.getRepositoriesGroups().get( 0 ).getRepositories().size() );
+ assertEquals( Arrays.asList( "test-new-one", "test-new-two" ),
+ repositoryGroupAdmin.getRepositoriesGroups().get( 0 ).getRepositories() );
+
+ repositoryGroupAdmin.deleteRepositoryGroup( "repo-group-one", getFakeAuditInformation() );
+
+ assertEquals( 0, repositoryGroupAdmin.getRepositoriesGroups().size() );
+
+ assertEquals( 2, mockAuditListener.getAuditEvents().size() );
+
+ assertEquals( AuditEvent.ADD_REPO_GROUP, mockAuditListener.getAuditEvents().get( 0 ).getAction() );
+ assertEquals( AuditEvent.DELETE_REPO_GROUP, mockAuditListener.getAuditEvents().get( 1 ).getAction() );
+ }
+ finally
+ {
+ mockAuditListener.clearEvents();
+ managedRepositoryAdmin.deleteManagedRepository( "test-new-one", getFakeAuditInformation(), true );
+ managedRepositoryAdmin.deleteManagedRepository( "test-new-two", getFakeAuditInformation(), true );
+ }
+ }
+
+ @Test
+ public void addAndUpdateAndDeleteGroup()
+ throws Exception
+ {
+ try
+ {
+ ManagedRepository managedRepositoryOne =
+ getTestManagedRepository( "test-new-one", APPSERVER_BASE_PATH + File.separator + "test-new-one" );
+
+ ManagedRepository managedRepositoryTwo =
+ getTestManagedRepository( "test-new-two", APPSERVER_BASE_PATH + File.separator + "test-new-two" );
+
+ managedRepositoryAdmin.addManagedRepository( managedRepositoryOne, false, getFakeAuditInformation() );
+
+ managedRepositoryAdmin.addManagedRepository( managedRepositoryTwo, false, getFakeAuditInformation() );
+
+ RepositoryGroup repositoryGroup = new RepositoryGroup( "repo-group-one", Arrays.asList( "test-new-one" ) );
+
+ mockAuditListener.clearEvents();
+
+ repositoryGroupAdmin.addRepositoryGroup( repositoryGroup, getFakeAuditInformation() );
+
+ assertEquals( 1, repositoryGroupAdmin.getRepositoriesGroups().size() );
+ assertEquals( "repo-group-one", repositoryGroupAdmin.getRepositoriesGroups().get( 0 ).getId() );
+ assertEquals( 1, repositoryGroupAdmin.getRepositoriesGroups().get( 0 ).getRepositories().size() );
+ assertEquals( Arrays.asList( "test-new-one" ),
+ repositoryGroupAdmin.getRepositoriesGroups().get( 0 ).getRepositories() );
+
+ repositoryGroup = repositoryGroupAdmin.getRepositoryGroup( "repo-group-one" );
+ assertNotNull( repositoryGroup );
+
+ repositoryGroup.addRepository( managedRepositoryTwo.getId() );
+
+ repositoryGroupAdmin.updateRepositoryGroup( repositoryGroup, getFakeAuditInformation() );
+
+ assertEquals( 1, repositoryGroupAdmin.getRepositoriesGroups().size() );
+ assertEquals( "repo-group-one", repositoryGroupAdmin.getRepositoriesGroups().get( 0 ).getId() );
+ assertEquals( 2, repositoryGroupAdmin.getRepositoriesGroups().get( 0 ).getRepositories().size() );
+ assertEquals( Arrays.asList( "test-new-one", "test-new-two" ),
+ repositoryGroupAdmin.getRepositoriesGroups().get( 0 ).getRepositories() );
+
+ repositoryGroupAdmin.deleteRepositoryGroup( "repo-group-one", getFakeAuditInformation() );
+
+ assertEquals( 0, repositoryGroupAdmin.getRepositoriesGroups().size() );
+
+ assertEquals( 3, mockAuditListener.getAuditEvents().size() );
+
+ assertEquals( AuditEvent.ADD_REPO_GROUP, mockAuditListener.getAuditEvents().get( 0 ).getAction() );
+ assertEquals( AuditEvent.MODIFY_REPO_GROUP, mockAuditListener.getAuditEvents().get( 1 ).getAction() );
+ assertEquals( AuditEvent.DELETE_REPO_GROUP, mockAuditListener.getAuditEvents().get( 2 ).getAction() );
+ }
+ finally
+ {
+ mockAuditListener.clearEvents();
+ managedRepositoryAdmin.deleteManagedRepository( "test-new-one", getFakeAuditInformation(), true );
+ managedRepositoryAdmin.deleteManagedRepository( "test-new-two", getFakeAuditInformation(), true );
+ }
+ }
+
+
+ @Test
+ public void addAndDeleteGroupWithRemowingManagedRepo()
+ throws Exception
+ {
+ try
+ {
+ ManagedRepository managedRepositoryOne =
+ getTestManagedRepository( "test-new-one", APPSERVER_BASE_PATH + File.separator + "test-new-one" );
+
+ ManagedRepository managedRepositoryTwo =
+ getTestManagedRepository( "test-new-two", APPSERVER_BASE_PATH + File.separator + "test-new-two" );
+
+ managedRepositoryAdmin.addManagedRepository( managedRepositoryOne, false, getFakeAuditInformation() );
+
+ managedRepositoryAdmin.addManagedRepository( managedRepositoryTwo, false, getFakeAuditInformation() );
+
+ RepositoryGroup repositoryGroup =
+ new RepositoryGroup( "repo-group-one", Arrays.asList( "test-new-one", "test-new-two" ) );
+
+ mockAuditListener.clearEvents();
+
+ repositoryGroupAdmin.addRepositoryGroup( repositoryGroup, getFakeAuditInformation() );
+
+ assertEquals( 1, repositoryGroupAdmin.getRepositoriesGroups().size() );
+ assertEquals( "repo-group-one", repositoryGroupAdmin.getRepositoriesGroups().get( 0 ).getId() );
+ assertEquals( 2, repositoryGroupAdmin.getRepositoriesGroups().get( 0 ).getRepositories().size() );
+ assertEquals( Arrays.asList( "test-new-one", "test-new-two" ),
+ repositoryGroupAdmin.getRepositoriesGroups().get( 0 ).getRepositories() );
+
+ // deleting a managed repo to validate repogroup correctly updated !
+ managedRepositoryAdmin.deleteManagedRepository( "test-new-one", getFakeAuditInformation(), true );
+
+ assertEquals( 1, repositoryGroupAdmin.getRepositoriesGroups().size() );
+ assertEquals( "repo-group-one", repositoryGroupAdmin.getRepositoriesGroups().get( 0 ).getId() );
+ assertEquals( 1, repositoryGroupAdmin.getRepositoriesGroups().get( 0 ).getRepositories().size() );
+ assertEquals( Arrays.asList( "test-new-two" ),
+ repositoryGroupAdmin.getRepositoriesGroups().get( 0 ).getRepositories() );
+
+ repositoryGroupAdmin.deleteRepositoryGroup( "repo-group-one", getFakeAuditInformation() );
+
+ assertEquals( 0, repositoryGroupAdmin.getRepositoriesGroups().size() );
+
+ assertEquals( 3, mockAuditListener.getAuditEvents().size() );
+
+ assertEquals( AuditEvent.ADD_REPO_GROUP, mockAuditListener.getAuditEvents().get( 0 ).getAction() );
+ assertEquals( AuditEvent.DELETE_MANAGED_REPO, mockAuditListener.getAuditEvents().get( 1 ).getAction() );
+ assertEquals( AuditEvent.DELETE_REPO_GROUP, mockAuditListener.getAuditEvents().get( 2 ).getAction() );
+ }
+ finally
+ {
+ mockAuditListener.clearEvents();
+
+ managedRepositoryAdmin.deleteManagedRepository( "test-new-two", getFakeAuditInformation(), true );
+ }
+ }
+}
--- /dev/null
+package org.apache.archiva.admin.repository.managed;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.admin.model.managed.ManagedRepository;
+import org.apache.archiva.admin.repository.AbstractRepositoryAdminTest;
+import org.apache.archiva.audit.AuditEvent;
+import org.apache.archiva.security.common.ArchivaRoleConstants;
+import org.junit.Test;
+
+import java.io.File;
+import java.util.List;
+
+/**
+ * @author Olivier Lamy
+ */
+public class ManagedRepositoryAdminTest
+ extends AbstractRepositoryAdminTest
+{
+ public static final String STAGE_REPO_ID_END = DefaultManagedRepositoryAdmin.STAGE_REPO_ID_END;
+
+ @Test
+ public void getAllManagedRepos()
+ throws Exception
+ {
+ mockAuditListener.clearEvents();
+ List<ManagedRepository> repos = managedRepositoryAdmin.getManagedRepositories();
+ assertNotNull( repos );
+ assertTrue( repos.size() > 0 );
+ log.info( "repos " + repos );
+
+ // check default internal
+ ManagedRepository internal = findManagedRepoById( repos, "internal" );
+ assertNotNull( internal );
+ assertTrue( internal.isReleases() );
+ assertFalse( internal.isSnapshots() );
+ mockAuditListener.clearEvents();
+ }
+
+ @Test
+ public void getById()
+ throws Exception
+ {
+ mockAuditListener.clearEvents();
+ ManagedRepository repo = managedRepositoryAdmin.getManagedRepository( "internal" );
+ assertNotNull( repo );
+ mockAuditListener.clearEvents();
+ }
+
+ @Test
+ public void addDeleteManagedRepo()
+ throws Exception
+ {
+ mockAuditListener.clearEvents();
+
+ String repoId = "test-new-one";
+
+ String repoLocation = APPSERVER_BASE_PATH + File.separator + repoId;
+
+ File repoDir = clearRepoLocation( repoLocation );
+
+ List<ManagedRepository> repos = managedRepositoryAdmin.getManagedRepositories();
+ assertNotNull( repos );
+ int initialSize = repos.size();
+ assertTrue( initialSize > 0 );
+
+ ManagedRepository repo = new ManagedRepository();
+ repo.setId( repoId );
+ repo.setName( "test repo" );
+ repo.setLocation( repoLocation );
+ repo.setCronExpression( "0 0 * * * ?" );
+ managedRepositoryAdmin.addManagedRepository( repo, false, getFakeAuditInformation() );
+ repos = managedRepositoryAdmin.getManagedRepositories();
+ assertNotNull( repos );
+ assertEquals( initialSize + 1, repos.size() );
+
+ assertNotNull( managedRepositoryAdmin.getManagedRepository( repoId ) );
+
+ assertTemplateRoleExists( repoId );
+
+ managedRepositoryAdmin.deleteManagedRepository( repoId, getFakeAuditInformation(), false );
+
+ // deleteContents false
+ assertTrue( repoDir.exists() );
+
+ repos = managedRepositoryAdmin.getManagedRepositories();
+ assertNotNull( repos );
+ assertEquals( initialSize, repos.size() );
+
+ assertTemplateRoleNotExists( repoId );
+
+ assertEquals( 2, mockAuditListener.getAuditEvents().size() );
+
+ assertAuditListenerCallAddAndDelete();
+
+ mockAuditListener.clearEvents();
+ }
+
+ @Test
+ public void updateDeleteManagedRepo()
+ throws Exception
+ {
+ String repoId = "test-new-one";
+
+ String repoLocation = APPSERVER_BASE_PATH + File.separator + "new-path";
+
+ File repoDir = clearRepoLocation( repoLocation );
+
+ mockAuditListener.clearEvents();
+ List<ManagedRepository> repos = managedRepositoryAdmin.getManagedRepositories();
+ assertNotNull( repos );
+ int initialSize = repos.size();
+ assertTrue( initialSize > 0 );
+
+ ManagedRepository repo = new ManagedRepository();
+ repo.setId( repoId );
+ repo.setName( "test repo" );
+ repo.setLocation( repoLocation );
+ repo.setCronExpression( "0 0 * * * ?" );
+ managedRepositoryAdmin.addManagedRepository( repo, false, getFakeAuditInformation() );
+
+ assertTemplateRoleExists( repoId );
+
+ repos = managedRepositoryAdmin.getManagedRepositories();
+ assertNotNull( repos );
+ assertEquals( initialSize + 1, repos.size() );
+
+ String newName = "test repo update";
+
+ repo.setName( newName );
+
+ repo.setLocation( repoLocation );
+ repo.setCronExpression( "0 0 * * * ?" );
+
+ managedRepositoryAdmin.updateManagedRepository( repo, false, getFakeAuditInformation(), false );
+
+ repo = managedRepositoryAdmin.getManagedRepository( repoId );
+ assertNotNull( repo );
+ assertEquals( newName, repo.getName() );
+ assertEquals( new File( repoLocation ).getCanonicalPath(), new File( repo.getLocation() ).getCanonicalPath() );
+ assertTrue( new File( repoLocation ).exists() );
+
+ assertTemplateRoleExists( repoId );
+
+ managedRepositoryAdmin.deleteManagedRepository( repo.getId(), getFakeAuditInformation(), false );
+
+ // check deleteContents false
+ assertTrue( repoDir.exists() );
+
+ assertTemplateRoleNotExists( repoId );
+
+ assertAuditListenerCallAndUpdateAddAndDelete( false );
+
+ mockAuditListener.clearEvents();
+
+ }
+
+
+ @Test
+ public void addDeleteManagedRepoWithStaged()
+ throws Exception
+ {
+
+ String repoId = "test-new-one";
+ String repoLocation = APPSERVER_BASE_PATH + File.separator + repoId;
+
+ File repoDir = clearRepoLocation( repoLocation );
+
+ mockAuditListener.clearEvents();
+ List<ManagedRepository> repos = managedRepositoryAdmin.getManagedRepositories();
+ assertNotNull( repos );
+ int initialSize = repos.size();
+ assertTrue( initialSize > 0 );
+
+ ManagedRepository repo = new ManagedRepository();
+ repo.setId( repoId );
+ repo.setName( "test repo" );
+ repo.setLocation( repoLocation );
+ repo.setCronExpression( "0 0 * * * ?" );
+ managedRepositoryAdmin.addManagedRepository( repo, true, getFakeAuditInformation() );
+ repos = managedRepositoryAdmin.getManagedRepositories();
+ assertNotNull( repos );
+ assertEquals( initialSize + 2, repos.size() );
+
+ assertNotNull( managedRepositoryAdmin.getManagedRepository( repoId ) );
+
+ assertTemplateRoleExists( repoId );
+
+ assertTrue( repoDir.exists() );
+
+ assertNotNull( managedRepositoryAdmin.getManagedRepository( repoId + STAGE_REPO_ID_END ) );
+
+ assertTemplateRoleExists( repoId + STAGE_REPO_ID_END );
+
+ assertTrue( new File( repoLocation + STAGE_REPO_ID_END ).exists() );
+
+ managedRepositoryAdmin.deleteManagedRepository( repoId, getFakeAuditInformation(), true );
+
+ assertFalse( repoDir.exists() );
+
+ assertFalse( new File( repoLocation + STAGE_REPO_ID_END ).exists() );
+
+ assertTemplateRoleNotExists( repoId + STAGE_REPO_ID_END );
+
+ repos = managedRepositoryAdmin.getManagedRepositories();
+ assertNotNull( repos );
+ assertEquals( initialSize, repos.size() );
+
+ assertTemplateRoleNotExists( repoId );
+
+ assertTemplateRoleNotExists( repoId + STAGE_REPO_ID_END );
+
+ mockAuditListener.clearEvents();
+
+ }
+
+ @Test
+ public void updateDeleteManagedRepoWithStagedRepo()
+ throws Exception
+ {
+ String repoId = "test-new-one";
+
+ String repoLocation = APPSERVER_BASE_PATH + File.separator + "new-path";
+
+ String stageRepoLocation = APPSERVER_BASE_PATH + File.separator + repoId;
+
+ File repoDir = clearRepoLocation( repoLocation );
+
+ mockAuditListener.clearEvents();
+ List<ManagedRepository> repos = managedRepositoryAdmin.getManagedRepositories();
+ assertNotNull( repos );
+ int initialSize = repos.size();
+ assertTrue( initialSize > 0 );
+
+ ManagedRepository repo = getTestManagedRepository( repoId, repoLocation );
+
+ managedRepositoryAdmin.addManagedRepository( repo, false, getFakeAuditInformation() );
+
+ assertTemplateRoleExists( repoId );
+
+ assertFalse( new File( repoLocation + STAGE_REPO_ID_END ).exists() );
+
+ assertTemplateRoleNotExists( repoId + STAGE_REPO_ID_END );
+
+ repos = managedRepositoryAdmin.getManagedRepositories();
+ assertNotNull( repos );
+ assertEquals( initialSize + 1, repos.size() );
+
+ repo = managedRepositoryAdmin.getManagedRepository( repoId );
+
+ assertEquals( getTestManagedRepository( repoId, repoLocation ).getIndexDirectory(), repo.getIndexDirectory() );
+
+ String newName = "test repo update";
+
+ repo.setName( newName );
+
+ repo.setLocation( repoLocation );
+
+ managedRepositoryAdmin.updateManagedRepository( repo, true, getFakeAuditInformation(), false );
+
+ repo = managedRepositoryAdmin.getManagedRepository( repoId );
+ assertNotNull( repo );
+ assertEquals( newName, repo.getName() );
+ assertEquals( new File( repoLocation ).getCanonicalPath(), new File( repo.getLocation() ).getCanonicalPath() );
+ assertTrue( new File( repoLocation ).exists() );
+ assertEquals( getTestManagedRepository( repoId, repoLocation ).getCronExpression(), repo.getCronExpression() );
+ assertEquals( getTestManagedRepository( repoId, repoLocation ).getLayout(), repo.getLayout() );
+ assertEquals( getTestManagedRepository( repoId, repoLocation ).getId(), repo.getId() );
+ assertEquals( getTestManagedRepository( repoId, repoLocation ).getIndexDirectory(), repo.getIndexDirectory() );
+
+ assertEquals( getTestManagedRepository( repoId, repoLocation ).getDaysOlder(), repo.getDaysOlder() );
+ assertEquals( getTestManagedRepository( repoId, repoLocation ).getRetentionCount(), repo.getRetentionCount() );
+ assertEquals( getTestManagedRepository( repoId, repoLocation ).isDeleteReleasedSnapshots(),
+ repo.isDeleteReleasedSnapshots() );
+
+ assertTemplateRoleExists( repoId );
+
+ assertTrue( new File( stageRepoLocation + STAGE_REPO_ID_END ).exists() );
+
+ assertTemplateRoleExists( repoId + STAGE_REPO_ID_END );
+
+ managedRepositoryAdmin.deleteManagedRepository( repo.getId(), getFakeAuditInformation(), false );
+
+ // check deleteContents false
+ assertTrue( repoDir.exists() );
+
+ assertTemplateRoleNotExists( repoId );
+
+ assertTrue( new File( stageRepoLocation + STAGE_REPO_ID_END ).exists() );
+
+ assertTemplateRoleNotExists( repoId + STAGE_REPO_ID_END );
+
+ assertAuditListenerCallAndUpdateAddAndDelete( true );
+
+ mockAuditListener.clearEvents();
+
+ }
+
+ //----------------------------------
+ // utility methods
+ //----------------------------------
+
+ private void assertTemplateRoleExists( String repoId )
+ throws Exception
+ {
+ assertTrue( roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, repoId ) );
+ assertTrue( roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, repoId ) );
+ }
+
+
+ private void assertTemplateRoleNotExists( String repoId )
+ throws Exception
+ {
+ assertFalse( roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, repoId ) );
+ assertFalse( roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, repoId ) );
+ }
+
+ private void assertAuditListenerCallAddAndDelete()
+ {
+ assertEquals( 2, mockAuditListener.getAuditEvents().size() );
+
+ assertEquals( AuditEvent.ADD_MANAGED_REPO, mockAuditListener.getAuditEvents().get( 0 ).getAction() );
+ assertEquals( "root", mockAuditListener.getAuditEvents().get( 0 ).getUserId() );
+ assertEquals( "archiva-localhost", mockAuditListener.getAuditEvents().get( 0 ).getRemoteIP() );
+
+ assertEquals( AuditEvent.DELETE_MANAGED_REPO, mockAuditListener.getAuditEvents().get( 1 ).getAction() );
+ assertEquals( "root", mockAuditListener.getAuditEvents().get( 0 ).getUserId() );
+ }
+
+ private void assertAuditListenerCallAndUpdateAddAndDelete( boolean stageNeeded )
+ {
+ if ( stageNeeded )
+ {
+ assertEquals( "not 4 audit events " + mockAuditListener.getAuditEvents(), 4,
+ mockAuditListener.getAuditEvents().size() );
+ }
+ else
+ {
+ assertEquals( "not 3 audit events " + mockAuditListener.getAuditEvents(), 3,
+ mockAuditListener.getAuditEvents().size() );
+ }
+ assertEquals( AuditEvent.ADD_MANAGED_REPO, mockAuditListener.getAuditEvents().get( 0 ).getAction() );
+ assertEquals( "root", mockAuditListener.getAuditEvents().get( 0 ).getUserId() );
+ assertEquals( "archiva-localhost", mockAuditListener.getAuditEvents().get( 0 ).getRemoteIP() );
+
+ if ( stageNeeded )
+ {
+ assertEquals( AuditEvent.ADD_MANAGED_REPO, mockAuditListener.getAuditEvents().get( 1 ).getAction() );
+ assertEquals( AuditEvent.MODIFY_MANAGED_REPO, mockAuditListener.getAuditEvents().get( 2 ).getAction() );
+ assertEquals( AuditEvent.DELETE_MANAGED_REPO, mockAuditListener.getAuditEvents().get( 3 ).getAction() );
+ }
+ else
+ {
+ assertEquals( AuditEvent.MODIFY_MANAGED_REPO, mockAuditListener.getAuditEvents().get( 1 ).getAction() );
+ assertEquals( AuditEvent.DELETE_MANAGED_REPO, mockAuditListener.getAuditEvents().get( 2 ).getAction() );
+ }
+
+ }
+
+
+
+}
--- /dev/null
+package org.apache.archiva.admin.repository.networkproxy;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.admin.model.networkproxy.NetworkProxy;
+import org.apache.archiva.admin.model.networkproxy.NetworkProxyAdmin;
+import org.apache.archiva.admin.repository.AbstractRepositoryAdminTest;
+import org.apache.archiva.audit.AuditEvent;
+import org.junit.Test;
+
+import javax.inject.Inject;
+
+/**
+ * @author Olivier Lamy
+ */
+public class NetworkProxyAdminTest
+ extends AbstractRepositoryAdminTest
+{
+
+ @Inject
+ private NetworkProxyAdmin networkProxyAdmin;
+
+ @Test
+ public void getAllEmpty()
+ throws Exception
+ {
+ assertNotNull( networkProxyAdmin.getNetworkProxies() );
+ }
+
+ @Test
+ public void addAndDelete()
+ throws Exception
+ {
+ mockAuditListener.clearEvents();
+ int initialSize = networkProxyAdmin.getNetworkProxies().size();
+ NetworkProxy networkProxy = getNetworkProxyTest( "foo" );
+
+ networkProxyAdmin.addNetworkProxy( networkProxy, getFakeAuditInformation() );
+
+ assertEquals( initialSize + 1, networkProxyAdmin.getNetworkProxies().size() );
+
+ networkProxy = networkProxyAdmin.getNetworkProxy( "foo" );
+
+ assertNotNull( networkProxy );
+ assertEquals( getNetworkProxyTest( "foo" ).getId(), networkProxy.getId() );
+ assertEquals( getNetworkProxyTest( "foo" ).getHost(), networkProxy.getHost() );
+ assertEquals( getNetworkProxyTest( "foo" ).getPassword(), networkProxy.getPassword() );
+ assertEquals( getNetworkProxyTest( "foo" ).getPort(), networkProxy.getPort() );
+ assertEquals( getNetworkProxyTest( "foo" ).getUsername(), networkProxy.getUsername() );
+ assertEquals( getNetworkProxyTest( "foo" ).getProtocol(), networkProxy.getProtocol() );
+
+ networkProxyAdmin.deleteNetworkProxy( "foo", getFakeAuditInformation() );
+
+ assertNull( networkProxyAdmin.getNetworkProxy( "foo" ) );
+
+ assertEquals( 2, mockAuditListener.getAuditEvents().size() );
+
+ assertEquals( AuditEvent.ADD_NETWORK_PROXY, mockAuditListener.getAuditEvents().get( 0 ).getAction() );
+ assertEquals( AuditEvent.DELETE_NETWORK_PROXY, mockAuditListener.getAuditEvents().get( 1 ).getAction() );
+
+ mockAuditListener.clearEvents();
+ }
+
+ @Test
+ public void addAndUpdateAndDelete()
+ throws Exception
+ {
+ mockAuditListener.clearEvents();
+ int initialSize = networkProxyAdmin.getNetworkProxies().size();
+ NetworkProxy networkProxy = getNetworkProxyTest( "foo" );
+
+ networkProxyAdmin.addNetworkProxy( networkProxy, getFakeAuditInformation() );
+
+ assertEquals( initialSize + 1, networkProxyAdmin.getNetworkProxies().size() );
+
+ networkProxy = networkProxyAdmin.getNetworkProxy( "foo" );
+
+ assertNotNull( networkProxy );
+ assertEquals( getNetworkProxyTest( "foo" ).getId(), networkProxy.getId() );
+ assertEquals( getNetworkProxyTest( "foo" ).getHost(), networkProxy.getHost() );
+ assertEquals( getNetworkProxyTest( "foo" ).getPassword(), networkProxy.getPassword() );
+ assertEquals( getNetworkProxyTest( "foo" ).getPort(), networkProxy.getPort() );
+ assertEquals( getNetworkProxyTest( "foo" ).getUsername(), networkProxy.getUsername() );
+ assertEquals( getNetworkProxyTest( "foo" ).getProtocol(), networkProxy.getProtocol() );
+
+ networkProxy.setHost( "https://toto.com" );
+ networkProxy.setPassword( "newpasswd" );
+ networkProxy.setPort( 9191 );
+ networkProxy.setProtocol( "http" );
+ networkProxy.setUsername( "newusername" );
+
+ networkProxyAdmin.updateNetworkProxy( networkProxy, getFakeAuditInformation() );
+
+ NetworkProxy updatedNetworkProxy = networkProxyAdmin.getNetworkProxy( "foo" );
+
+ assertNotNull( updatedNetworkProxy );
+ assertEquals( networkProxy.getId(), updatedNetworkProxy.getId() );
+ assertEquals( networkProxy.getHost(), updatedNetworkProxy.getHost() );
+ assertEquals( networkProxy.getPassword(), updatedNetworkProxy.getPassword() );
+ assertEquals( networkProxy.getPort(), updatedNetworkProxy.getPort() );
+ assertEquals( networkProxy.getUsername(), updatedNetworkProxy.getUsername() );
+ assertEquals( networkProxy.getProtocol(), updatedNetworkProxy.getProtocol() );
+
+ networkProxyAdmin.deleteNetworkProxy( "foo", getFakeAuditInformation() );
+
+ assertEquals( 3, mockAuditListener.getAuditEvents().size() );
+
+ assertEquals( AuditEvent.ADD_NETWORK_PROXY, mockAuditListener.getAuditEvents().get( 0 ).getAction() );
+ assertEquals( AuditEvent.MODIFY_NETWORK_PROXY, mockAuditListener.getAuditEvents().get( 1 ).getAction() );
+ assertEquals( AuditEvent.DELETE_NETWORK_PROXY, mockAuditListener.getAuditEvents().get( 2 ).getAction() );
+
+ mockAuditListener.clearEvents();
+ }
+
+
+ protected NetworkProxy getNetworkProxyTest( String id )
+ {
+ NetworkProxy networkProxy = new NetworkProxy();
+ networkProxy.setId( "foo" );
+ networkProxy.setHost( "http://foo.com" );
+ networkProxy.setPassword( "passwd" );
+ networkProxy.setPort( 9090 );
+ networkProxy.setUsername( "root" );
+ networkProxy.setProtocol( "https" );
+ return networkProxy;
+ }
+
+}
--- /dev/null
+package org.apache.archiva.admin.repository.proxyconnector;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.admin.model.proxyconnector.ProxyConnector;
+import org.apache.archiva.admin.model.remote.RemoteRepository;
+import org.apache.archiva.admin.repository.AbstractRepositoryAdminTest;
+import org.apache.archiva.audit.AuditEvent;
+import org.junit.Test;
+
+import java.util.Arrays;
+
+/**
+ * @author Olivier Lamy
+ */
+public class ProxyConnectorAdminTest
+ extends AbstractRepositoryAdminTest
+{
+
+ @Test
+ public void addAndDelete()
+ throws Exception
+ {
+ mockAuditListener.clearEvents();
+ assertEquals( "not proxyConnectors 2 " + proxyConnectorAdmin.getProxyConnectors(), 2,
+ proxyConnectorAdmin.getProxyConnectors().size() );
+ assertFalse( proxyConnectorAdmin.getProxyConnectors().isEmpty() );
+ ProxyConnector proxyConnector = new ProxyConnector();
+ proxyConnector.setSourceRepoId( "snapshots" );
+ proxyConnector.setTargetRepoId( "central" );
+ proxyConnectorAdmin.addProxyConnector( proxyConnector, getFakeAuditInformation() );
+
+ assertFalse( proxyConnectorAdmin.getProxyConnectors().isEmpty() );
+ assertEquals( 3, proxyConnectorAdmin.getProxyConnectors().size() );
+
+ assertNotNull( proxyConnectorAdmin.getProxyConnector( "snapshots", "central" ) );
+
+ proxyConnectorAdmin.deleteProxyConnector( proxyConnector, getFakeAuditInformation() );
+
+ assertEquals( 2, proxyConnectorAdmin.getProxyConnectors().size() );
+ assertFalse( proxyConnectorAdmin.getProxyConnectors().isEmpty() );
+
+ assertEquals( 2, mockAuditListener.getAuditEvents().size() );
+
+ assertEquals( AuditEvent.ADD_PROXY_CONNECTOR, mockAuditListener.getAuditEvents().get( 0 ).getAction() );
+ assertEquals( "root", mockAuditListener.getAuditEvents().get( 0 ).getUserId() );
+ assertEquals( "archiva-localhost", mockAuditListener.getAuditEvents().get( 0 ).getRemoteIP() );
+
+ assertEquals( AuditEvent.DELETE_PROXY_CONNECTOR, mockAuditListener.getAuditEvents().get( 1 ).getAction() );
+ assertEquals( "root", mockAuditListener.getAuditEvents().get( 1 ).getUserId() );
+
+ assertNull( proxyConnectorAdmin.getProxyConnector( "snapshots", "central" ) );
+
+ mockAuditListener.clearEvents();
+ }
+
+ @Test
+ public void addAndUpdateAndDelete()
+ throws Exception
+ {
+ mockAuditListener.clearEvents();
+ RemoteRepository remoteRepository = getRemoteRepository( "test-new-one" );
+
+ remoteRepositoryAdmin.addRemoteRepository( remoteRepository, getFakeAuditInformation() );
+
+ assertEquals( "not proxyConnectors 2 " + proxyConnectorAdmin.getProxyConnectors(), 2,
+ proxyConnectorAdmin.getProxyConnectors().size() );
+ assertFalse( proxyConnectorAdmin.getProxyConnectors().isEmpty() );
+ ProxyConnector proxyConnector = new ProxyConnector();
+ proxyConnector.setSourceRepoId( "snapshots" );
+ proxyConnector.setTargetRepoId( "central" );
+ proxyConnector.setWhiteListPatterns( Arrays.asList( "foo", "bar" ) );
+ proxyConnectorAdmin.addProxyConnector( proxyConnector, getFakeAuditInformation() );
+
+ assertFalse( proxyConnectorAdmin.getProxyConnectors().isEmpty() );
+ assertEquals( 3, proxyConnectorAdmin.getProxyConnectors().size() );
+
+ assertNotNull( proxyConnectorAdmin.getProxyConnector( "snapshots", "central" ) );
+ assertEquals( Arrays.asList( "foo", "bar" ),
+ proxyConnectorAdmin.getProxyConnector( "snapshots", "central" ).getWhiteListPatterns() );
+
+ proxyConnectorAdmin.deleteProxyConnector( proxyConnector, getFakeAuditInformation() );
+
+ proxyConnector.setTargetRepoId( remoteRepository.getId() );
+ proxyConnectorAdmin.addProxyConnector( proxyConnector, getFakeAuditInformation() );
+
+ assertNull( proxyConnectorAdmin.getProxyConnector( "snapshots", "central" ) );
+ assertNotNull( remoteRepository.getId(),
+ proxyConnectorAdmin.getProxyConnector( "snapshots", remoteRepository.getId() ) );
+
+ proxyConnectorAdmin.deleteProxyConnector( proxyConnector, getFakeAuditInformation() );
+
+ assertNull( proxyConnectorAdmin.getProxyConnector( "snapshots", "central" ) );
+
+ assertEquals( 2, proxyConnectorAdmin.getProxyConnectors().size() );
+ assertFalse( proxyConnectorAdmin.getProxyConnectors().isEmpty() );
+
+ assertEquals( 5, mockAuditListener.getAuditEvents().size() );
+
+ assertEquals( AuditEvent.ADD_REMOTE_REPO, mockAuditListener.getAuditEvents().get( 0 ).getAction() );
+
+ assertEquals( AuditEvent.ADD_PROXY_CONNECTOR, mockAuditListener.getAuditEvents().get( 1 ).getAction() );
+ assertEquals( "root", mockAuditListener.getAuditEvents().get( 2 ).getUserId() );
+ assertEquals( "archiva-localhost", mockAuditListener.getAuditEvents().get( 2 ).getRemoteIP() );
+
+ assertEquals( AuditEvent.DELETE_PROXY_CONNECTOR, mockAuditListener.getAuditEvents().get( 2 ).getAction() );
+
+ assertEquals( AuditEvent.ADD_PROXY_CONNECTOR, mockAuditListener.getAuditEvents().get( 3 ).getAction() );
+
+ assertEquals( AuditEvent.DELETE_PROXY_CONNECTOR, mockAuditListener.getAuditEvents().get( 4 ).getAction() );
+ assertEquals( "root", mockAuditListener.getAuditEvents().get( 4 ).getUserId() );
+
+ remoteRepositoryAdmin.deleteRemoteRepository( remoteRepository.getId(), getFakeAuditInformation() );
+ mockAuditListener.clearEvents();
+ }
+
+ @Test
+ public void findProxyConnector()
+ throws Exception
+ {
+ ProxyConnector proxyConnector = proxyConnectorAdmin.getProxyConnector( "internal", "central" );
+ assertNotNull( proxyConnector );
+ }
+
+ @Test
+ public void updateProxyConnector()
+ throws Exception
+ {
+ mockAuditListener.clearEvents();
+ ProxyConnector proxyConnector = proxyConnectorAdmin.getProxyConnector( "internal", "central" );
+ assertNotNull( proxyConnector );
+ proxyConnector.setDisabled( false );
+ proxyConnectorAdmin.updateProxyConnector( proxyConnector, getFakeAuditInformation() );
+ proxyConnector = proxyConnectorAdmin.getProxyConnector( "internal", "central" );
+ assertFalse( proxyConnector.isDisabled() );
+
+ proxyConnector.setDisabled( true );
+ proxyConnectorAdmin.updateProxyConnector( proxyConnector, getFakeAuditInformation() );
+ proxyConnector = proxyConnectorAdmin.getProxyConnector( "internal", "central" );
+ assertTrue( proxyConnector.isDisabled() );
+
+ proxyConnector.setOrder( 4 );
+ proxyConnectorAdmin.updateProxyConnector( proxyConnector, getFakeAuditInformation() );
+ proxyConnector = proxyConnectorAdmin.getProxyConnector( "internal", "central" );
+ assertEquals( 4, proxyConnector.getOrder() );
+ mockAuditListener.clearEvents();
+
+ }
+
+}
--- /dev/null
+package org.apache.archiva.admin.repository.remote;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.admin.model.remote.RemoteRepository;
+import org.apache.archiva.admin.repository.AbstractRepositoryAdminTest;
+import org.apache.archiva.audit.AuditEvent;
+import org.junit.Test;
+
+import java.util.List;
+
+/**
+ * @author Olivier Lamy
+ */
+public class RemoteRepositoryAdminTest
+ extends AbstractRepositoryAdminTest
+{
+
+ @Test
+ public void getAll()
+ throws Exception
+ {
+ List<RemoteRepository> remoteRepositories = remoteRepositoryAdmin.getRemoteRepositories();
+ assertNotNull( remoteRepositories );
+ assertTrue( remoteRepositories.size() > 0 );
+ log.info( "remote " + remoteRepositories );
+ }
+
+ @Test
+ public void getById()
+ throws Exception
+ {
+ RemoteRepository central = remoteRepositoryAdmin.getRemoteRepository( "central" );
+ assertNotNull( central );
+ assertEquals( "http://repo1.maven.org/maven2", central.getUrl() );
+ assertEquals( 60, central.getTimeout() );
+ assertNull( central.getUserName() );
+ assertNull( central.getPassword() );
+ }
+
+ @Test
+ public void addAndDelete()
+ throws Exception
+ {
+ mockAuditListener.clearEvents();
+ int initialSize = remoteRepositoryAdmin.getRemoteRepositories().size();
+
+ RemoteRepository remoteRepository = getRemoteRepository();
+
+ remoteRepositoryAdmin.addRemoteRepository( remoteRepository, getFakeAuditInformation() );
+
+ assertEquals( initialSize + 1, remoteRepositoryAdmin.getRemoteRepositories().size() );
+
+ RemoteRepository repo = remoteRepositoryAdmin.getRemoteRepository( "foo" );
+ assertNotNull( repo );
+ assertEquals( getRemoteRepository().getPassword(), repo.getPassword() );
+ assertEquals( getRemoteRepository().getUrl(), repo.getUrl() );
+ assertEquals( getRemoteRepository().getUserName(), repo.getUserName() );
+ assertEquals( getRemoteRepository().getName(), repo.getName() );
+ assertEquals( getRemoteRepository().getTimeout(), repo.getTimeout() );
+
+ remoteRepositoryAdmin.deleteRemoteRepository( "foo", getFakeAuditInformation() );
+
+ assertEquals( initialSize, remoteRepositoryAdmin.getRemoteRepositories().size() );
+
+ repo = remoteRepositoryAdmin.getRemoteRepository( "foo" );
+ assertNull( repo );
+
+ assertEquals( 2, mockAuditListener.getAuditEvents().size() );
+
+ assertEquals( AuditEvent.ADD_REMOTE_REPO, mockAuditListener.getAuditEvents().get( 0 ).getAction() );
+ assertEquals( "root", mockAuditListener.getAuditEvents().get( 0 ).getUserId() );
+ assertEquals( "archiva-localhost", mockAuditListener.getAuditEvents().get( 0 ).getRemoteIP() );
+
+ assertEquals( AuditEvent.DELETE_REMOTE_REPO, mockAuditListener.getAuditEvents().get( 1 ).getAction() );
+ assertEquals( "root", mockAuditListener.getAuditEvents().get( 1 ).getUserId() );
+
+ }
+
+
+ @Test
+ public void addAndUpdateAndDelete()
+ throws Exception
+ {
+ mockAuditListener.clearEvents();
+ int initialSize = remoteRepositoryAdmin.getRemoteRepositories().size();
+
+ RemoteRepository remoteRepository = getRemoteRepository();
+
+ remoteRepositoryAdmin.addRemoteRepository( remoteRepository, getFakeAuditInformation() );
+
+ assertEquals( initialSize + 1, remoteRepositoryAdmin.getRemoteRepositories().size() );
+
+ RemoteRepository repo = remoteRepositoryAdmin.getRemoteRepository( "foo" );
+ assertNotNull( repo );
+ assertEquals( getRemoteRepository().getPassword(), repo.getPassword() );
+ assertEquals( getRemoteRepository().getUrl(), repo.getUrl() );
+ assertEquals( getRemoteRepository().getUserName(), repo.getUserName() );
+ assertEquals( getRemoteRepository().getName(), repo.getName() );
+ assertEquals( getRemoteRepository().getTimeout(), repo.getTimeout() );
+
+ repo.setUserName( "foo-name-changed" );
+ repo.setPassword( "titi" );
+ repo.setUrl( "http://foo.com/maven-really-rocks" );
+
+ remoteRepositoryAdmin.updateRemoteRepository( repo, getFakeAuditInformation() );
+
+ repo = remoteRepositoryAdmin.getRemoteRepository( "foo" );
+
+ assertEquals( "foo-name-changed", repo.getUserName() );
+ assertEquals( "titi", repo.getPassword() );
+ assertEquals( "http://foo.com/maven-really-rocks", repo.getUrl() );
+
+ remoteRepositoryAdmin.deleteRemoteRepository( "foo", getFakeAuditInformation() );
+
+ assertEquals( initialSize, remoteRepositoryAdmin.getRemoteRepositories().size() );
+
+ repo = remoteRepositoryAdmin.getRemoteRepository( "foo" );
+ assertNull( repo );
+
+ assertEquals( 3, mockAuditListener.getAuditEvents().size() );
+
+ assertEquals( AuditEvent.ADD_REMOTE_REPO, mockAuditListener.getAuditEvents().get( 0 ).getAction() );
+ assertEquals( "root", mockAuditListener.getAuditEvents().get( 0 ).getUserId() );
+ assertEquals( "archiva-localhost", mockAuditListener.getAuditEvents().get( 0 ).getRemoteIP() );
+
+ assertEquals( AuditEvent.MODIFY_REMOTE_REPO, mockAuditListener.getAuditEvents().get( 1 ).getAction() );
+ assertEquals( "root", mockAuditListener.getAuditEvents().get( 1 ).getUserId() );
+ assertEquals( "archiva-localhost", mockAuditListener.getAuditEvents().get( 1 ).getRemoteIP() );
+
+ assertEquals( AuditEvent.DELETE_REMOTE_REPO, mockAuditListener.getAuditEvents().get( 2 ).getAction() );
+ assertEquals( "root", mockAuditListener.getAuditEvents().get( 2 ).getUserId() );
+
+ }
+
+
+
+}
--- /dev/null
+<redback-role-model>
+ <modelVersion>1.0.0</modelVersion>
+ <applications>
+ <application>
+ <id>System</id>
+ <description>Roles that apply system-wide, across all of the applications</description>
+ <version>1.0.0</version>
+ <resources>
+ <resource>
+ <id>global</id>
+ <name>*</name>
+ <permanent>true</permanent>
+ <description>global resource implies full access for authorization</description>
+ </resource>
+ <resource>
+ <id>username</id>
+ <name>${username}</name>
+ <permanent>true</permanent>
+ <description>replaced with the username of the principal at authorization check time</description>
+ </resource>
+ </resources>
+ <operations>
+ <operation>
+ <id>configuration-edit</id>
+ <name>configuration-edit</name>
+ <description>edit configuration</description>
+ <permanent>true</permanent>
+ </operation>
+ <operation>
+ <id>user-management-user-create</id>
+ <name>user-management-user-create</name>
+ <description>create user</description>
+ <permanent>true</permanent>
+ </operation>
+ <operation>
+ <id>user-management-user-edit</id>
+ <name>user-management-user-edit</name>
+ <description>edit user</description>
+ <permanent>true</permanent>
+ </operation>
+ <operation>
+ <id>user-management-user-role</id>
+ <name>user-management-user-role</name>
+ <description>user roles</description>
+ <permanent>true</permanent>
+ </operation>
+ <operation>
+ <id>user-management-user-delete</id>
+ <name>user-management-user-delete</name>
+ <description>delete user</description>
+ <permanent>true</permanent>
+ </operation>
+ <operation>
+ <id>user-management-user-list</id>
+ <name>user-management-user-list</name>
+ <description>list users</description>
+ <permanent>true</permanent>
+ </operation>
+ <operation>
+ <id>user-management-role-grant</id>
+ <name>user-management-role-grant</name>
+ <description>grant role</description>
+ <permanent>true</permanent>
+ </operation>
+ <operation>
+ <id>user-management-role-drop</id>
+ <name>user-management-role-drop</name>
+ <description>drop role</description>
+ <permanent>true</permanent>
+ </operation>
+ <operation>
+ <id>user-management-rbac-admin</id>
+ <name>user-management-rbac-admin</name>
+ <description>administer rbac</description>
+ <permanent>true</permanent>
+ </operation>
+ <operation>
+ <id>guest-access</id>
+ <name>guest-access</name>
+ <description>access guest</description>
+ <permanent>true</permanent>
+ </operation>
+ <operation>
+ <id>user-management-manage-data</id>
+ <name>user-management-manage-data</name>
+ <description>manage data</description>
+ <permanent>true</permanent>
+ </operation>
+ </operations>
+ <roles>
+ <role>
+ <id>system-administrator</id>
+ <name>System Administrator</name>
+ <permanent>true</permanent>
+ <assignable>true</assignable>
+ <permissions>
+ <permission>
+ <id>edit-redback-configuration</id>
+ <name>Edit Redback Configuration</name>
+ <operation>configuration-edit</operation>
+ <resource>global</resource>
+ <permanent>true</permanent>
+ </permission>
+ <permission>
+ <id>manage-rbac-setup</id>
+ <name>User RBAC Management</name>
+ <operation>user-management-rbac-admin</operation>
+ <resource>global</resource>
+ <permanent>true</permanent>
+ </permission>
+ <permission>
+ <id>manage-rbac-data</id>
+ <name>RBAC Manage Data</name>
+ <operation>user-management-manage-data</operation>
+ <resource>global</resource>
+ <permanent>true</permanent>
+ </permission>
+ </permissions>
+ <childRoles>
+ <childRole>user-administrator</childRole>
+ </childRoles>
+ </role>
+ <role>
+ <id>user-administrator</id>
+ <name>User Administrator</name>
+ <permanent>true</permanent>
+ <assignable>true</assignable>
+ <permissions>
+ <permission>
+ <id>drop-roles-for-anyone</id>
+ <name>Drop Roles for Anyone</name>
+ <operation>user-management-role-drop</operation>
+ <resource>global</resource>
+ <permanent>true</permanent>
+ </permission>
+ <permission>
+ <id>grant-roles-for-anyone</id>
+ <name>Grant Roles for Anyone</name>
+ <operation>user-management-role-grant</operation>
+ <resource>global</resource>
+ <permanent>true</permanent>
+ </permission>
+ <permission>
+ <id>user-create</id>
+ <name>Create Users</name>
+ <operation>user-management-user-create</operation>
+ <resource>global</resource>
+ <permanent>true</permanent>
+ </permission>
+ <permission>
+ <id>user-delete</id>
+ <name>Delete Users</name>
+ <operation>user-management-user-delete</operation>
+ <resource>global</resource>
+ <permanent>true</permanent>
+ </permission>
+ <permission>
+ <id>user-edit</id>
+ <name>Edit Users</name>
+ <operation>user-management-user-edit</operation>
+ <resource>global</resource>
+ <permanent>true</permanent>
+ </permission>
+ <permission>
+ <id>access-users-roles</id>
+ <name>Access Users Roles</name>
+ <operation>user-management-user-role</operation>
+ <resource>global</resource>
+ <permanent>true</permanent>
+ </permission>
+ <permission>
+ <id>access-user-list</id>
+ <name>Access User List</name>
+ <operation>user-management-user-list</operation>
+ <resource>global</resource>
+ <permanent>true</permanent>
+ </permission>
+ </permissions>
+ </role>
+ <role>
+ <id>registered-user</id>
+ <name>Registered User</name>
+ <permanent>true</permanent>
+ <assignable>true</assignable>
+ <permissions>
+ <permission>
+ <id>edit-user-by-username</id>
+ <name>Edit User Data by Username</name>
+ <operation>user-management-user-edit</operation>
+ <resource>username</resource>
+ <permanent>true</permanent>
+ </permission>
+ </permissions>
+ </role>
+ <role>
+ <id>guest</id>
+ <name>Guest</name>
+ <permanent>true</permanent>
+ <assignable>true</assignable>
+ <permissions>
+ <permission>
+ <id>guest-permission</id>
+ <name>Guest Permission</name>
+ <operation>guest-access</operation>
+ <resource>global</resource>
+ <permanent>true</permanent>
+ </permission>
+ </permissions>
+ </role>
+ </roles>
+ </application>
+ </applications>
+</redback-role-model>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
+
+ <appender name="console" class="org.apache.log4j.ConsoleAppender">
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d [%t] %-5p %c %x - %m%n"/>
+ </layout>
+ </appender>
+
+
+
+ <logger name="org.apache.archiva.admin.repository.managed" >
+ <level value="debug"/>
+ </logger>
+ <logger name="JPOX">
+ <level value="ERROR"/>
+ </logger>
+
+ <logger name="org.springframework">
+ <level value="error"/>
+ </logger>
+
+ <root>
+ <priority value ="info" />
+ <appender-ref ref="console" />
+ </root>
+
+</log4j:configuration>
--- /dev/null
+<?xml version="1.0"?>
+
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+<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-3.0.xsd
+ http://www.springframework.org/schema/context
+ http://www.springframework.org/schema/context/spring-context-3.0.xsd" default-lazy-init="true">
+
+ <context:annotation-config/>
+ <context:component-scan base-package="org.apache.archiva.admin.mock"/>
+
+ <bean name="scheduler" class="org.codehaus.redback.components.scheduler.DefaultScheduler">
+ <property name="properties">
+ <props>
+ <prop key="org.quartz.scheduler.instanceName">scheduler1</prop>
+ <prop key="org.quartz.threadPool.class">org.quartz.simpl.SimpleThreadPool</prop>
+ <prop key="org.quartz.threadPool.threadCount">2</prop>
+ <prop key="org.quartz.threadPool.threadPriority">4</prop>
+ <prop key="org.quartz.jobStore.class">org.quartz.simpl.RAMJobStore</prop>
+ </props>
+ </property>
+ </bean>
+
+ <bean name="commons-configuration" class="org.codehaus.redback.components.registry.commons.CommonsConfigurationRegistry">
+ <property name="properties">
+ <value>
+ <![CDATA[
+ <configuration>
+ <system/>
+ <xml fileName="${appserver.base}/conf/archiva.xml" config-forceCreate="true"
+ config-optional="true"
+ config-name="org.apache.maven.archiva.base" config-at="org.apache.maven.archiva"/>
+ </configuration>
+ ]]>
+ </value>
+ </property>
+ </bean>
+
+</beans>
\ No newline at end of file
</parent>
<artifactId>archiva-repository-admin</artifactId>
<name>Archiva Base :: Repository Admin</name>
- <dependencies>
- <dependency>
- <groupId>org.apache.archiva</groupId>
- <artifactId>archiva-configuration</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.archiva</groupId>
- <artifactId>archiva-security-common</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.archiva</groupId>
- <artifactId>archiva-scheduler-repository</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.archiva</groupId>
- <artifactId>audit</artifactId>
- </dependency>
- <dependency>
- <groupId>javax.inject</groupId>
- <artifactId>javax.inject</artifactId>
- </dependency>
- <dependency>
- <groupId>net.sf.beanlib</groupId>
- <artifactId>beanlib</artifactId>
- <exclusions>
- <exclusion>
- <groupId>cglib</groupId>
- <artifactId>cglib</artifactId>
- </exclusion>
- <exclusion>
- <groupId>aopalliance</groupId>
- <artifactId>aopalliance</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-context-support</artifactId>
- <version>${spring.version}</version>
- <exclusions>
- <exclusion>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-context</artifactId>
- <version>${spring.version}</version>
- <exclusions>
- <exclusion>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
- <dependency>
- <groupId>commons-validator</groupId>
- <artifactId>commons-validator</artifactId>
- </dependency>
- <dependency>
- <groupId>oro</groupId>
- <artifactId>oro</artifactId>
- </dependency>
- <dependency>
- <groupId>org.codehaus.redback.components</groupId>
- <artifactId>spring-quartz</artifactId>
- </dependency>
- <dependency>
- <groupId>org.codehaus.redback</groupId>
- <artifactId>redback-rbac-role-manager</artifactId>
- <exclusions>
- <exclusion>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.codehaus.redback</groupId>
- <artifactId>redback-authentication-api</artifactId>
- <exclusions>
- <exclusion>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.codehaus.redback</groupId>
- <artifactId>redback-users-memory</artifactId>
- <scope>test</scope>
- <version>${redback.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.codehaus.redback</groupId>
- <artifactId>redback-keys-memory</artifactId>
- <scope>test</scope>
- <version>${redback.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.codehaus.redback</groupId>
- <artifactId>redback-rbac-cached</artifactId>
- <version>${redback.version}</version>
- <scope>test</scope>
- <exclusions>
- <exclusion>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>org.apache.derby</groupId>
- <artifactId>derby</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>jcl-over-slf4j</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.archiva</groupId>
- <artifactId>metadata-store-file</artifactId>
- <scope>test</scope>
- </dependency>
-
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <systemPropertyVariables>
- <appserver.base>${project.build.outputDirectory}</appserver.base>
- <plexus.home>${project.build.outputDirectory}</plexus.home>
- </systemPropertyVariables>
- </configuration>
-
- </plugin>
- </plugins>
- </build>
+ <packaging>pom</packaging>
+ <modules>
+ <module>archiva-repository-admin-api</module>
+ <module>archiva-repository-admin-default</module>
+ </modules>
</project>
+++ /dev/null
-package org.apache.archiva.admin;
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.codehaus.plexus.redback.users.User;
-
-/**
- * @author Olivier Lamy
- * @since 1.4
- */
-public class AuditInformation
-{
- private User user;
-
- private String remoteAddr;
-
- public AuditInformation( User user, String remoteAddr )
- {
- this.user = user;
- this.remoteAddr = remoteAddr;
- }
-
- public User getUser()
- {
- return user;
- }
-
- public void setUser( User user )
- {
- this.user = user;
- }
-
- public String getRemoteAddr()
- {
- return remoteAddr;
- }
-
- public void setRemoteAddr( String remoteAddr )
- {
- this.remoteAddr = remoteAddr;
- }
-
- @Override
- public String toString()
- {
- final StringBuilder sb = new StringBuilder();
- sb.append( "AuditInformation" );
- sb.append( "{user=" ).append( user );
- sb.append( ", remoteAddr='" ).append( remoteAddr ).append( '\'' );
- sb.append( '}' );
- return sb.toString();
- }
-}
+++ /dev/null
-package org.apache.archiva.admin.repository;
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.Serializable;
-
-/**
- * @author Olivier Lamy
- * @since 1.4
- */
-public class AbstractRepository
- implements Serializable
-{
-
- private String id;
-
- private String name;
-
- private String layout = "default";
-
- public AbstractRepository()
- {
- // no op
- }
-
- public AbstractRepository( String id, String name, String layout )
- {
- this.id = id;
- this.name = name;
- this.layout = layout;
- }
-
- public String getId()
- {
- return id;
- }
-
- public void setId( String id )
- {
- this.id = id;
- }
-
- public String getName()
- {
- return name;
- }
-
- public void setName( String name )
- {
- this.name = name;
- }
-
- public String getLayout()
- {
- return layout;
- }
-
- public void setLayout( String layout )
- {
- this.layout = layout;
- }
-
-
- public int hashCode()
- {
- int result = 17;
- result = 37 * result + ( id != null ? id.hashCode() : 0 );
- return result;
- }
-
- public boolean equals( Object other )
- {
- if ( this == other )
- {
- return true;
- }
-
- if ( !( other instanceof AbstractRepository ) )
- {
- return false;
- }
-
- AbstractRepository that = (AbstractRepository) other;
- boolean result = true;
- result = result && ( getId() == null ? that.getId() == null : getId().equals( that.getId() ) );
- return result;
- }
-
- @Override
- public String toString()
- {
- final StringBuilder sb = new StringBuilder();
- sb.append( "AbstractRepository" );
- sb.append( "{id='" ).append( id ).append( '\'' );
- sb.append( ", name='" ).append( name ).append( '\'' );
- sb.append( ", layout='" ).append( layout ).append( '\'' );
- sb.append( '}' );
- return sb.toString();
- }
-}
+++ /dev/null
-package org.apache.archiva.admin.repository;
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.archiva.admin.AuditInformation;
-import org.apache.archiva.audit.AuditEvent;
-import org.apache.archiva.audit.AuditListener;
-import org.apache.maven.archiva.configuration.ArchivaConfiguration;
-import org.apache.maven.archiva.configuration.Configuration;
-import org.apache.maven.archiva.configuration.IndeterminateConfigurationException;
-import org.codehaus.plexus.redback.users.User;
-import org.codehaus.plexus.registry.Registry;
-import org.codehaus.plexus.registry.RegistryException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.inject.Inject;
-import javax.inject.Named;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author Olivier Lamy
- * @since 1.4
- */
-public abstract class AbstractRepositoryAdmin
-{
- protected Logger log = LoggerFactory.getLogger( getClass() );
-
- @Inject
- private List<AuditListener> auditListeners = new ArrayList<AuditListener>();
-
-
- @Inject
- private RepositoryCommonValidator repositoryCommonValidator;
-
- @Inject
- private ArchivaConfiguration archivaConfiguration;
-
- @Inject
- @Named( value = "commons-configuration" )
- private Registry registry;
-
- protected void triggerAuditEvent( String repositoryId, String resource, String action,
- AuditInformation auditInformation )
- {
- User user = auditInformation == null ? null : auditInformation.getUser();
- AuditEvent event =
- new AuditEvent( repositoryId, user == null ? "null" : (String) user.getPrincipal(), resource, action );
- event.setRemoteIP( auditInformation == null ? "null" : auditInformation.getRemoteAddr() );
-
- for ( AuditListener listener : getAuditListeners() )
- {
- listener.auditEvent( event );
- }
-
- }
-
- protected void saveConfiguration( Configuration config )
- throws RepositoryAdminException
- {
- try
- {
- getArchivaConfiguration().save( config );
- }
- catch ( RegistryException e )
- {
- throw new RepositoryAdminException( "Error occurred in the registry.", e );
- }
- catch ( IndeterminateConfigurationException e )
- {
- throw new RepositoryAdminException( "Error occurred while saving the configuration.", e );
- }
- }
-
- public List<AuditListener> getAuditListeners()
- {
- return auditListeners;
- }
-
- public void setAuditListeners( List<AuditListener> auditListeners )
- {
- this.auditListeners = auditListeners;
- }
-
- public void setArchivaConfiguration( ArchivaConfiguration archivaConfiguration )
- {
- this.archivaConfiguration = archivaConfiguration;
- }
-
- public ArchivaConfiguration getArchivaConfiguration()
- {
- return archivaConfiguration;
- }
-
- public RepositoryCommonValidator getRepositoryCommonValidator()
- {
- return repositoryCommonValidator;
- }
-
- public void setRepositoryCommonValidator( RepositoryCommonValidator repositoryCommonValidator )
- {
- this.repositoryCommonValidator = repositoryCommonValidator;
- }
-
- public Registry getRegistry()
- {
- return registry;
- }
-
- public void setRegistry( Registry registry )
- {
- this.registry = registry;
- }
-}
+++ /dev/null
-package org.apache.archiva.admin.repository;
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author Olivier Lamy
- * @since 1.4
- */
-public abstract class AbstractRepositoryConnector
- implements Serializable
-{
- /**
- * The Repository Source for this connector.
- */
- private String sourceRepoId;
-
- /**
- * The Repository Target for this connector.
- */
- private String targetRepoId;
-
- /**
- * The network proxy ID to use for this connector.
- */
- private String proxyId;
-
- /**
- * Field blackListPatterns.
- */
- private List<String> blackListPatterns;
-
- /**
- * Field whiteListPatterns.
- */
- private List<String> whiteListPatterns;
-
- /**
- * Field policies.
- */
- private Map<String, String> policies;
-
- /**
- * Field properties.
- */
- private Map<String, String> properties;
-
- /**
- * If the the repository proxy connector is disabled or not
- */
- private boolean disabled = false;
-
- //-----------/
- //- Methods -/
- //-----------/
-
- /**
- * Method addBlackListPattern.
- *
- * @param string
- */
- public void addBlackListPattern( String string )
- {
- getBlackListPatterns().add( string );
- }
-
- /**
- * Method addPolicy.
- *
- * @param key
- * @param value
- */
- public void addPolicy( String key, String value )
- {
- getPolicies().put( key, value );
- }
-
- /**
- * Method addProperty.
- *
- * @param key
- * @param value
- */
- public void addProperty( String key, String value )
- {
- getProperties().put( key, value );
- }
-
- /**
- * Method addWhiteListPattern.
- *
- * @param string
- */
- public void addWhiteListPattern( String string )
- {
- getWhiteListPatterns().add( string );
- }
-
- /**
- * Method getBlackListPatterns.
- *
- * @return List
- */
- public List<String> getBlackListPatterns()
- {
- if ( this.blackListPatterns == null )
- {
- this.blackListPatterns = new ArrayList<String>();
- }
-
- return this.blackListPatterns;
- }
-
- /**
- * Method getPolicies.
- *
- * @return Map
- */
- public Map<String, String> getPolicies()
- {
- if ( this.policies == null )
- {
- this.policies = new HashMap<String, String>();
- }
-
- return this.policies;
- }
-
- /**
- * Method getProperties.
- *
- * @return Map
- */
- public Map<String, String> getProperties()
- {
- if ( this.properties == null )
- {
- this.properties = new HashMap<String, String>();
- }
-
- return this.properties;
- }
-
- /**
- * Get the network proxy ID to use for this connector.
- *
- * @return String
- */
- public String getProxyId()
- {
- return this.proxyId;
- }
-
- /**
- * Get the Repository Source for this connector.
- *
- * @return String
- */
- public String getSourceRepoId()
- {
- return this.sourceRepoId;
- }
-
- /**
- * Get the Repository Target for this connector.
- *
- * @return String
- */
- public String getTargetRepoId()
- {
- return this.targetRepoId;
- }
-
- /**
- * Method getWhiteListPatterns.
- *
- * @return List
- */
- public List<String> getWhiteListPatterns()
- {
- if ( this.whiteListPatterns == null )
- {
- this.whiteListPatterns = new ArrayList<String>();
- }
-
- return this.whiteListPatterns;
- }
-
- /**
- * Get if the the repository proxy connector is disabled or not
- * .
- *
- * @return boolean
- */
- public boolean isDisabled()
- {
- return this.disabled;
- }
-
- /**
- * Method removeBlackListPattern.
- *
- * @param string
- */
- public void removeBlackListPattern( String string )
- {
- getBlackListPatterns().remove( string );
- }
-
- /**
- * Method removeWhiteListPattern.
- *
- * @param string
- */
- public void removeWhiteListPattern( String string )
- {
- getWhiteListPatterns().remove( string );
- }
-
- /**
- * Set the list of blacklisted patterns for this connector.
- *
- * @param blackListPatterns
- */
- public void setBlackListPatterns( List<String> blackListPatterns )
- {
- this.blackListPatterns = blackListPatterns;
- }
-
- /**
- * Set if the the repository proxy connector is
- * disabled or not
- * .
- *
- * @param disabled
- */
- public void setDisabled( boolean disabled )
- {
- this.disabled = disabled;
- }
-
- /**
- * Set policy configuration for the connector.
- *
- * @param policies
- */
- public void setPolicies( Map<String, String> policies )
- {
- this.policies = policies;
- }
-
- /**
- * Set configuration for the connector.
- *
- * @param properties
- */
- public void setProperties( Map<String, String> properties )
- {
- this.properties = properties;
- }
-
- /**
- * Set the network proxy ID to use for this connector.
- *
- * @param proxyId
- */
- public void setProxyId( String proxyId )
- {
- this.proxyId = proxyId;
- }
-
- /**
- * Set the Repository Source for this connector.
- *
- * @param sourceRepoId
- */
- public void setSourceRepoId( String sourceRepoId )
- {
- this.sourceRepoId = sourceRepoId;
- }
-
- /**
- * Set the Repository Target for this connector.
- *
- * @param targetRepoId
- */
- public void setTargetRepoId( String targetRepoId )
- {
- this.targetRepoId = targetRepoId;
- }
-
- /**
- * Set
- * The list of whitelisted patterns for this
- * connector.
- *
- * @param whiteListPatterns
- */
- public void setWhiteListPatterns( List<String> whiteListPatterns )
- {
- this.whiteListPatterns = whiteListPatterns;
- }
-
-
- /**
- * Obtain a specific policy from the underlying connector.
- *
- * @param policyId the policy id to fetch.
- * @param defaultValue the default value for the policy id.
- * @return the configured policy value (or default value if not found).
- */
- public String getPolicy( String policyId, String defaultValue )
- {
- if ( this.getPolicies() == null )
- {
- return null;
- }
-
- String value = this.getPolicies().get( policyId );
-
- if ( value == null )
- {
- return defaultValue;
- }
-
- return value;
- }
-
- @Override
- public boolean equals( Object o )
- {
- if ( this == o )
- {
- return true;
- }
- if ( o == null || getClass() != o.getClass() )
- {
- return false;
- }
-
- AbstractRepositoryConnector that = (AbstractRepositoryConnector) o;
-
- if ( sourceRepoId != null ? !sourceRepoId.equals( that.sourceRepoId ) : that.sourceRepoId != null )
- {
- return false;
- }
- if ( targetRepoId != null ? !targetRepoId.equals( that.targetRepoId ) : that.targetRepoId != null )
- {
- return false;
- }
-
- return true;
- }
-
- @Override
- public int hashCode()
- {
- int result = sourceRepoId != null ? sourceRepoId.hashCode() : 0;
- result = 31 * result + ( targetRepoId != null ? targetRepoId.hashCode() : 0 );
- return result;
- }
-
- @Override
- public String toString()
- {
- final StringBuilder sb = new StringBuilder();
- sb.append( "AbstractRepositoryConnector" );
- sb.append( "{sourceRepoId='" ).append( sourceRepoId ).append( '\'' );
- sb.append( ", targetRepoId='" ).append( targetRepoId ).append( '\'' );
- sb.append( ", proxyId='" ).append( proxyId ).append( '\'' );
- sb.append( ", blackListPatterns=" ).append( blackListPatterns );
- sb.append( ", whiteListPatterns=" ).append( whiteListPatterns );
- sb.append( ", policies=" ).append( policies );
- sb.append( ", properties=" ).append( properties );
- sb.append( ", disabled=" ).append( disabled );
- sb.append( '}' );
- return sb.toString();
- }
-}
-
+++ /dev/null
-package org.apache.archiva.admin.repository;
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-/**
- * @author Olivier Lamy
- * @since 1.4
- */
-public class RepositoryAdminException
- extends Exception
-{
- public RepositoryAdminException( String s )
- {
- super( s );
- }
-
- public RepositoryAdminException( String message, Throwable cause )
- {
- super( message, cause );
- }
-}
+++ /dev/null
-package org.apache.archiva.admin.repository;
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.validator.GenericValidator;
-import org.apache.maven.archiva.configuration.ArchivaConfiguration;
-import org.apache.maven.archiva.configuration.Configuration;
-import org.codehaus.plexus.registry.Registry;
-import org.springframework.stereotype.Service;
-
-import javax.inject.Inject;
-import javax.inject.Named;
-
-/**
- * apply basic repository validation : id and name.
- * Check if already exists.
- *
- * @author Olivier Lamy
- * @since 1.4
- */
-@Service
-public class RepositoryCommonValidator
-{
-
- public static final String REPOSITORY_ID_VALID_EXPRESSION = "^[a-zA-Z0-9._-]+$";
-
- public static final String REPOSITORY_NAME_VALID_EXPRESSION = "^([a-zA-Z0-9.)/_(-]|\\s)+$";
-
-
- @Inject
- private ArchivaConfiguration archivaConfiguration;
-
- @Inject
- @Named( value = "commons-configuration" )
- private Registry registry;
-
- /**
- * @param abstractRepository
- * @param update in update mode if yes already exists won't be check
- * @throws RepositoryAdminException
- */
- public void basicValidation( AbstractRepository abstractRepository, boolean update )
- throws RepositoryAdminException
- {
- Configuration config = archivaConfiguration.getConfiguration();
-
- String repoId = abstractRepository.getId();
-
- if ( !update )
- {
-
- if ( config.getManagedRepositoriesAsMap().containsKey( repoId ) )
- {
- throw new RepositoryAdminException( "Unable to add new repository with id [" + repoId
- + "], that id already exists as a managed repository." );
- }
- else if ( config.getRepositoryGroupsAsMap().containsKey( repoId ) )
- {
- throw new RepositoryAdminException( "Unable to add new repository with id [" + repoId
- + "], that id already exists as a repository group." );
- }
- else if ( config.getRemoteRepositoriesAsMap().containsKey( repoId ) )
- {
- throw new RepositoryAdminException( "Unable to add new repository with id [" + repoId
- + "], that id already exists as a remote repository." );
- }
- }
-
- if ( StringUtils.isBlank( repoId ) )
- {
- throw new RepositoryAdminException( "Repository ID cannot be empty." );
- }
-
- if ( !GenericValidator.matchRegexp( repoId, REPOSITORY_ID_VALID_EXPRESSION ) )
- {
- throw new RepositoryAdminException(
- "Invalid repository ID. Identifier must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
- }
-
- String name = abstractRepository.getName();
-
- if ( StringUtils.isBlank( name ) )
- {
- throw new RepositoryAdminException( "repository name cannot be empty" );
- }
-
- if ( !GenericValidator.matchRegexp( name, REPOSITORY_NAME_VALID_EXPRESSION ) )
- {
- throw new RepositoryAdminException(
- "Invalid repository name. Repository Name must only contain alphanumeric characters, white-spaces(' '), "
- + "forward-slashes(/), open-parenthesis('('), close-parenthesis(')'), underscores(_), dots(.), and dashes(-)." );
- }
-
-
- }
-
- /**
- * replace some interpolations ${appserver.base} with correct values
- *
- * @param directory
- * @return
- */
- public String removeExpressions( String directory )
- {
- String value = StringUtils.replace( directory, "${appserver.base}",
- getRegistry().getString( "appserver.base", "${appserver.base}" ) );
- value = StringUtils.replace( value, "${appserver.home}",
- getRegistry().getString( "appserver.home", "${appserver.home}" ) );
- return value;
- }
-
- public ArchivaConfiguration getArchivaConfiguration()
- {
- return archivaConfiguration;
- }
-
- public void setArchivaConfiguration( ArchivaConfiguration archivaConfiguration )
- {
- this.archivaConfiguration = archivaConfiguration;
- }
-
- public Registry getRegistry()
- {
- return registry;
- }
-
- public void setRegistry( Registry registry )
- {
- this.registry = registry;
- }
-}
+++ /dev/null
-package org.apache.archiva.admin.repository.admin;
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.archiva.admin.AuditInformation;
-import org.apache.archiva.admin.repository.RepositoryAdminException;
-
-import java.util.List;
-
-/**
- * @author Olivier Lamy
- * @since 1.4
- */
-public interface ArchivaAdministration
-{
-
- List<LegacyArtifactPath> getLegacyArtifactPaths()
- throws RepositoryAdminException;
-
- void addLegacyArtifactPath( LegacyArtifactPath legacyArtifactPath, AuditInformation auditInformation )
- throws RepositoryAdminException;
-
- void deleteLegacyArtifactPath( String path, AuditInformation auditInformation )
- throws RepositoryAdminException;
-
- void addFileTypePattern( String fileTypeId, String pattern, AuditInformation auditInformation )
- throws RepositoryAdminException;
-
- void removeFileTypePattern( String fileTypeId, String pattern, AuditInformation auditInformation )
- throws RepositoryAdminException;
-
- List<FileType> getFileTypes()
- throws RepositoryAdminException;
-
- FileType getFileType( String fileTypeId )
- throws RepositoryAdminException;
-
- void addFileType( FileType fileType, AuditInformation auditInformation )
- throws RepositoryAdminException;
-
- void removeFileType( String fileTypeId, AuditInformation auditInformation )
- throws RepositoryAdminException;
-
- void addKnownContentConsumer( String knownContentConsumer, AuditInformation auditInformation )
- throws RepositoryAdminException;
-
- void setKnownContentConsumers( List<String> knownContentConsumers, AuditInformation auditInformation )
- throws RepositoryAdminException;
-
- List<String> getKnownContentConsumers()
- throws RepositoryAdminException;
-
- void removeKnownContentConsumer( String knownContentConsumer, AuditInformation auditInformation )
- throws RepositoryAdminException;
-
- void addInvalidContentConsumer( String invalidContentConsumer, AuditInformation auditInformation )
- throws RepositoryAdminException;
-
- void setInvalidContentConsumers( List<String> invalidContentConsumers, AuditInformation auditInformation )
- throws RepositoryAdminException;
-
- List<String> getInvalidContentConsumers()
- throws RepositoryAdminException;
-
- void removeInvalidContentConsumer( String invalidContentConsumer, AuditInformation auditInformation )
- throws RepositoryAdminException;
-
- OrganisationInformation getOrganisationInformation()
- throws RepositoryAdminException;
-
- void setOrganisationInformation( OrganisationInformation organisationInformation )
- throws RepositoryAdminException;
-
-}
+++ /dev/null
-package org.apache.archiva.admin.repository.admin;
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import net.sf.beanlib.provider.replicator.BeanReplicator;
-import org.apache.archiva.admin.AuditInformation;
-import org.apache.archiva.admin.repository.AbstractRepositoryAdmin;
-import org.apache.archiva.admin.repository.RepositoryAdminException;
-import org.apache.archiva.audit.AuditEvent;
-import org.apache.commons.lang.StringUtils;
-import org.apache.maven.archiva.configuration.Configuration;
-import org.springframework.stereotype.Service;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-/**
- * @author Olivier Lamy
- */
-@Service( "archivaAdministration#default" )
-public class DefaultArchivaAdministration
- extends AbstractRepositoryAdmin
- implements ArchivaAdministration
-{
- public List<LegacyArtifactPath> getLegacyArtifactPaths()
- throws RepositoryAdminException
- {
- List<LegacyArtifactPath> legacyArtifactPaths = new ArrayList<LegacyArtifactPath>();
- for ( org.apache.maven.archiva.configuration.LegacyArtifactPath legacyArtifactPath : getArchivaConfiguration().getConfiguration().getLegacyArtifactPaths() )
- {
- legacyArtifactPaths.add(
- new BeanReplicator().replicateBean( legacyArtifactPath, LegacyArtifactPath.class ) );
- }
- return legacyArtifactPaths;
-
- }
-
- public void addLegacyArtifactPath( LegacyArtifactPath legacyArtifactPath, AuditInformation auditInformation )
- throws RepositoryAdminException
- {
- Configuration configuration = getArchivaConfiguration().getConfiguration();
-
- configuration.addLegacyArtifactPath( new BeanReplicator().replicateBean( legacyArtifactPath,
- org.apache.maven.archiva.configuration.LegacyArtifactPath.class ) );
-
- saveConfiguration( configuration );
- triggerAuditEvent( "", "", AuditEvent.ADD_LEGACY_PATH, auditInformation );
- }
-
- public void deleteLegacyArtifactPath( String path, AuditInformation auditInformation )
- throws RepositoryAdminException
- {
- Configuration configuration = getArchivaConfiguration().getConfiguration();
- org.apache.maven.archiva.configuration.LegacyArtifactPath legacyArtifactPath =
- new org.apache.maven.archiva.configuration.LegacyArtifactPath();
-
- legacyArtifactPath.setPath( path );
- configuration.removeLegacyArtifactPath( legacyArtifactPath );
-
- saveConfiguration( configuration );
- triggerAuditEvent( "", "", AuditEvent.REMOVE_LEGACY_PATH, auditInformation );
- }
-
-
- public void addFileTypePattern( String fileTypeId, String pattern, AuditInformation auditInformation )
- throws RepositoryAdminException
- {
- Configuration configuration = getArchivaConfiguration().getConfiguration();
-
- org.apache.maven.archiva.configuration.FileType fileType = getFileTypeById( fileTypeId, configuration );
- if ( fileType == null )
- {
- return;
- }
- fileType.addPattern( pattern );
-
- saveConfiguration( configuration );
- triggerAuditEvent( "", "", AuditEvent.ADD_PATTERN, auditInformation );
- }
-
- public void removeFileTypePattern( String fileTypeId, String pattern, AuditInformation auditInformation )
- throws RepositoryAdminException
- {
- Configuration configuration = getArchivaConfiguration().getConfiguration();
-
- org.apache.maven.archiva.configuration.FileType fileType = getFileTypeById( fileTypeId, configuration );
- if ( fileType == null )
- {
- return;
- }
- fileType.removePattern( pattern );
-
- saveConfiguration( configuration );
- triggerAuditEvent( "", "", AuditEvent.REMOVE_PATTERN, auditInformation );
- }
-
- public FileType getFileType( String fileTypeId )
- throws RepositoryAdminException
- {
- org.apache.maven.archiva.configuration.FileType fileType =
- getFileTypeById( fileTypeId, getArchivaConfiguration().getConfiguration() );
- if ( fileType == null )
- {
- return null;
- }
- return new BeanReplicator().replicateBean( fileType, FileType.class );
- }
-
- public void addFileType( FileType fileType, AuditInformation auditInformation )
- throws RepositoryAdminException
- {
- Configuration configuration = getArchivaConfiguration().getConfiguration();
- if ( getFileTypeById( fileType.getId(), configuration ) != null )
- {
- throw new RepositoryAdminException(
- "impossible to FileType with id " + fileType.getId() + " already exists" );
- }
-
- configuration.getRepositoryScanning().addFileType(
- new BeanReplicator().replicateBean( fileType, org.apache.maven.archiva.configuration.FileType.class ) );
- saveConfiguration( configuration );
- }
-
- public void removeFileType( String fileTypeId, AuditInformation auditInformation )
- throws RepositoryAdminException
- {
- Configuration configuration = getArchivaConfiguration().getConfiguration();
- org.apache.maven.archiva.configuration.FileType fileType =
- new org.apache.maven.archiva.configuration.FileType();
- fileType.setId( fileTypeId );
- configuration.getRepositoryScanning().removeFileType( fileType );
- saveConfiguration( configuration );
- }
-
- public void addKnownContentConsumer( String knownContentConsumer, AuditInformation auditInformation )
- throws RepositoryAdminException
- {
- Configuration configuration = getArchivaConfiguration().getConfiguration();
- if ( configuration.getRepositoryScanning().getKnownContentConsumers().contains( knownContentConsumer ) )
- {
- log.warn( "skip adding knownContentConsumer {} as already here", knownContentConsumer );
- return;
- }
- configuration.getRepositoryScanning().addKnownContentConsumer( knownContentConsumer );
- saveConfiguration( configuration );
- triggerAuditEvent( "", "", AuditEvent.ENABLE_REPO_CONSUMER, auditInformation );
- }
-
- public void removeKnownContentConsumer( String knownContentConsumer, AuditInformation auditInformation )
- throws RepositoryAdminException
- {
- Configuration configuration = getArchivaConfiguration().getConfiguration();
- configuration.getRepositoryScanning().removeKnownContentConsumer( knownContentConsumer );
- saveConfiguration( configuration );
- triggerAuditEvent( "", "", AuditEvent.DISABLE_REPO_CONSUMER, auditInformation );
- }
-
- public void addInvalidContentConsumer( String invalidContentConsumer, AuditInformation auditInformation )
- throws RepositoryAdminException
- {
- Configuration configuration = getArchivaConfiguration().getConfiguration();
- if ( configuration.getRepositoryScanning().getInvalidContentConsumers().contains( invalidContentConsumer ) )
- {
- log.warn( "skip adding invalidContentConsumer {} as already here", invalidContentConsumer );
- return;
- }
- configuration.getRepositoryScanning().addInvalidContentConsumer( invalidContentConsumer );
- saveConfiguration( configuration );
- triggerAuditEvent( "", "", AuditEvent.ENABLE_REPO_CONSUMER, auditInformation );
- }
-
- public void removeInvalidContentConsumer( String invalidContentConsumer, AuditInformation auditInformation )
- throws RepositoryAdminException
- {
- Configuration configuration = getArchivaConfiguration().getConfiguration();
- configuration.getRepositoryScanning().removeInvalidContentConsumer( invalidContentConsumer );
- saveConfiguration( configuration );
- triggerAuditEvent( "", "", AuditEvent.DISABLE_REPO_CONSUMER, auditInformation );
- }
-
- public void setKnownContentConsumers( List<String> knownContentConsumers, AuditInformation auditInformation )
- throws RepositoryAdminException
- {
- if ( knownContentConsumers == null )
- {
- return;
- }
- for ( String knowContentConsumer : knownContentConsumers )
- {
- addKnownContentConsumer( knowContentConsumer, auditInformation );
- }
- }
-
- public void setInvalidContentConsumers( List<String> invalidContentConsumers, AuditInformation auditInformation )
- throws RepositoryAdminException
- {
- if ( invalidContentConsumers == null )
- {
- return;
- }
- for ( String invalidContentConsumer : invalidContentConsumers )
- {
- addKnownContentConsumer( invalidContentConsumer, auditInformation );
- }
- }
-
- public List<FileType> getFileTypes()
- throws RepositoryAdminException
- {
- List<org.apache.maven.archiva.configuration.FileType> configFileTypes =
- getArchivaConfiguration().getConfiguration().getRepositoryScanning().getFileTypes();
- if ( configFileTypes == null || configFileTypes.isEmpty() )
- {
- return Collections.emptyList();
- }
- List<FileType> fileTypes = new ArrayList<FileType>();
- for ( org.apache.maven.archiva.configuration.FileType fileType : configFileTypes )
- {
- fileTypes.add( new BeanReplicator().replicateBean( fileType, FileType.class ) );
- }
- return fileTypes;
- }
-
- public List<String> getKnownContentConsumers()
- throws RepositoryAdminException
- {
- return new ArrayList<String>(
- getArchivaConfiguration().getConfiguration().getRepositoryScanning().getKnownContentConsumers() );
- }
-
- public List<String> getInvalidContentConsumers()
- throws RepositoryAdminException
- {
- return new ArrayList<String>(
- getArchivaConfiguration().getConfiguration().getRepositoryScanning().getInvalidContentConsumers() );
- }
-
- public OrganisationInformation getOrganisationInformation()
- throws RepositoryAdminException
- {
- org.apache.maven.archiva.configuration.OrganisationInformation organisationInformation =
- getArchivaConfiguration().getConfiguration().getOrganisationInfo();
- if ( organisationInformation == null )
- {
- return null;
- }
- return new BeanReplicator().replicateBean( organisationInformation, OrganisationInformation.class );
- }
-
- public void setOrganisationInformation( OrganisationInformation organisationInformation )
- throws RepositoryAdminException
- {
- Configuration configuration = getArchivaConfiguration().getConfiguration();
- if ( organisationInformation != null )
- {
- org.apache.maven.archiva.configuration.OrganisationInformation organisationInformationModel =
- new BeanReplicator().replicateBean( organisationInformation,
- org.apache.maven.archiva.configuration.OrganisationInformation.class );
- configuration.setOrganisationInfo( organisationInformationModel );
- }
- else
- {
- configuration.setOrganisationInfo( null );
- }
- saveConfiguration( configuration );
- }
-
- //-------------------------
- //
- //-------------------------
-
- private org.apache.maven.archiva.configuration.FileType getFileTypeById( String id, Configuration configuration )
- {
- for ( org.apache.maven.archiva.configuration.FileType fileType : configuration.getRepositoryScanning().getFileTypes() )
- {
- if ( StringUtils.equals( id, fileType.getId() ) )
- {
- return fileType;
- }
- }
- return null;
- }
-
-}
+++ /dev/null
-package org.apache.archiva.admin.repository.admin;
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author Olivier Lamy
- * @since 1.4
- */
-public class FileType
- implements Serializable
-{
- /**
- * Field id.
- */
- private String id;
-
- /**
- * Field patterns.
- */
- private List<String> patterns;
-
- public FileType()
- {
- // no op
- }
-
- public FileType( String id, List<String> patterns )
- {
- this.id = id;
- this.patterns = patterns;
- }
-
- public String getId()
- {
- return id;
- }
-
- public void setId( String id )
- {
- this.id = id;
- }
-
- public List<String> getPatterns()
- {
- if ( patterns == null )
- {
- this.patterns = new ArrayList<String>();
- }
- return patterns;
- }
-
- public void setPatterns( List<String> patterns )
- {
- this.patterns = patterns;
- }
-
- public void addPattern( String pattern )
- {
- getPatterns().add( pattern );
- }
-
- public void removePattern( String pattern )
- {
- getPatterns().remove( pattern );
- }
-
- @Override
- public boolean equals( Object o )
- {
- if ( this == o )
- {
- return true;
- }
- if ( o == null || getClass() != o.getClass() )
- {
- return false;
- }
-
- FileType fileType = (FileType) o;
-
- if ( id != null ? !id.equals( fileType.id ) : fileType.id != null )
- {
- return false;
- }
-
- return true;
- }
-
- @Override
- public int hashCode()
- {
- return id != null ? 37 + id.hashCode() : 0;
- }
-
- @Override
- public String toString()
- {
- final StringBuilder sb = new StringBuilder();
- sb.append( "FileType" );
- sb.append( "{id='" ).append( id ).append( '\'' );
- sb.append( ", patterns=" ).append( patterns );
- sb.append( '}' );
- return sb.toString();
- }
-}
+++ /dev/null
-package org.apache.archiva.admin.repository.admin;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.commons.collections.Closure;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * FiletypeToMapClosure
- *
- * @since 1.4
- */
-public class FiletypeToMapClosure
- implements Closure
-{
- private Map<String, FileType> map = new HashMap<String, FileType>();
-
- public void execute( Object input )
- {
- if ( input instanceof FileType )
- {
- FileType filetype = (FileType) input;
- map.put( filetype.getId(), filetype );
- }
- }
-
- public Map<String, FileType> getMap()
- {
- return map;
- }
-}
+++ /dev/null
-package org.apache.archiva.admin.repository.admin;
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.Serializable;
-
-/**
- * @author Olivier Lamy
- * @since 1.4
- */
-public class LegacyArtifactPath
- implements Serializable
-{
- /**
- * The legacy path.
- */
- private String path;
-
- /**
- * The artifact reference, as " [groupId] :
- * [artifactId] : [version] : [classifier] : [type] ".
- */
- private String artifact;
-
- public LegacyArtifactPath()
- {
- // no op
- }
-
- public LegacyArtifactPath( String path, String artifact )
- {
- this.path = path;
- this.artifact = artifact;
- }
-
- public String getPath()
- {
- return path;
- }
-
- public void setPath( String path )
- {
- this.path = path;
- }
-
- public String getArtifact()
- {
- return artifact;
- }
-
- public void setArtifact( String artifact )
- {
- this.artifact = artifact;
- }
-
- public boolean match( String path )
- {
- return path.equals( this.path );
- }
-
- public String getGroupId()
- {
- return artifact.split( ":" )[0];
- }
-
- public String getArtifactId()
- {
- return artifact.split( ":" )[1];
- }
-
- public String getVersion()
- {
- return artifact.split( ":" )[2];
- }
-
- public String getClassifier()
- {
- String classifier = artifact.split( ":" )[3];
- return classifier.length() > 0 ? classifier : null;
- }
-
- public String getType()
- {
- return artifact.split( ":" )[4];
- }
-
- @Override
- public boolean equals( Object o )
- {
- if ( this == o )
- {
- return true;
- }
- if ( o == null || getClass() != o.getClass() )
- {
- return false;
- }
-
- LegacyArtifactPath that = (LegacyArtifactPath) o;
-
- if ( path != null ? !path.equals( that.path ) : that.path != null )
- {
- return false;
- }
-
- return true;
- }
-
- @Override
- public int hashCode()
- {
- return path != null ? 37 + path.hashCode() : 0;
- }
-
- @Override
- public String toString()
- {
- final StringBuilder sb = new StringBuilder();
- sb.append( "LegacyArtifactPath" );
- sb.append( "{path='" ).append( path ).append( '\'' );
- sb.append( ", artifact='" ).append( artifact ).append( '\'' );
- sb.append( '}' );
- return sb.toString();
- }
-}
+++ /dev/null
-package org.apache.archiva.admin.repository.admin;
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * @author Olivier Lamy
- * @since 1.4
- */
-public class OrganisationInformation
-{
- /**
- * name of the organisation.
- */
- private String name;
-
- /**
- * name of the organisation.
- */
- private String url;
-
- /**
- * name of the organisation.
- */
- private String logoLocation;
-
- public OrganisationInformation()
- {
- // no op
- }
-
- public OrganisationInformation( String name, String url, String logoLocation )
- {
- this.name = name;
- this.url = url;
- this.logoLocation = logoLocation;
- }
-
- public String getName()
- {
- return name;
- }
-
- public void setName( String name )
- {
- this.name = name;
- }
-
- public String getUrl()
- {
- return url;
- }
-
- public void setUrl( String url )
- {
- this.url = url;
- }
-
- public String getLogoLocation()
- {
- return logoLocation;
- }
-
- public void setLogoLocation( String logoLocation )
- {
- this.logoLocation = logoLocation;
- }
-
- @Override
- public String toString()
- {
- final StringBuilder sb = new StringBuilder();
- sb.append( "OrganisationInformation" );
- sb.append( "{name='" ).append( name ).append( '\'' );
- sb.append( ", url='" ).append( url ).append( '\'' );
- sb.append( ", logoLocation='" ).append( logoLocation ).append( '\'' );
- sb.append( '}' );
- return sb.toString();
- }
-}
+++ /dev/null
-package org.apache.archiva.admin.repository.group;
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.archiva.admin.AuditInformation;
-import org.apache.archiva.admin.repository.AbstractRepositoryAdmin;
-import org.apache.archiva.admin.repository.RepositoryAdminException;
-import org.apache.archiva.admin.repository.managed.ManagedRepository;
-import org.apache.archiva.admin.repository.managed.ManagedRepositoryAdmin;
-import org.apache.archiva.audit.AuditEvent;
-import org.apache.commons.lang.StringUtils;
-import org.apache.maven.archiva.configuration.Configuration;
-import org.apache.maven.archiva.configuration.RepositoryGroupConfiguration;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Service;
-
-import javax.inject.Inject;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * @author Olivier Lamy
- */
-@Service( "repositoryGroupAdmin#default" )
-public class DefaultRepositoryGroupAdmin
- extends AbstractRepositoryAdmin
- implements RepositoryGroupAdmin
-{
-
- private Logger log = LoggerFactory.getLogger( getClass() );
-
- private static final Pattern REPO_GROUP_ID_PATTERN = Pattern.compile( "[A-Za-z0-9\\._\\-]+" );
-
- @Inject
- private ManagedRepositoryAdmin managedRepositoryAdmin;
-
- public List<RepositoryGroup> getRepositoriesGroups()
- throws RepositoryAdminException
- {
- List<RepositoryGroup> repositoriesGroups = new ArrayList<RepositoryGroup>();
-
- for ( RepositoryGroupConfiguration repositoryGroupConfiguration : getArchivaConfiguration().getConfiguration().getRepositoryGroups() )
- {
- repositoriesGroups.add( new RepositoryGroup( repositoryGroupConfiguration.getId(), new ArrayList<String>(
- repositoryGroupConfiguration.getRepositories() ) ) );
- }
-
- return repositoriesGroups;
- }
-
- public RepositoryGroup getRepositoryGroup( String repositoryGroupId )
- throws RepositoryAdminException
- {
- List<RepositoryGroup> repositoriesGroups = getRepositoriesGroups();
- for ( RepositoryGroup repositoryGroup : repositoriesGroups )
- {
- if ( StringUtils.equals( repositoryGroupId, repositoryGroup.getId() ) )
- {
- return repositoryGroup;
- }
- }
- return null;
- }
-
- public Boolean addRepositoryGroup( RepositoryGroup repositoryGroup, AuditInformation auditInformation )
- throws RepositoryAdminException
- {
- validateRepositoryGroup( repositoryGroup, false );
- validateManagedRepositoriesExists( repositoryGroup.getRepositories() );
- RepositoryGroupConfiguration repositoryGroupConfiguration = new RepositoryGroupConfiguration();
- repositoryGroupConfiguration.setId( repositoryGroup.getId() );
- repositoryGroupConfiguration.setRepositories( repositoryGroup.getRepositories() );
- Configuration configuration = getArchivaConfiguration().getConfiguration();
- configuration.addRepositoryGroup( repositoryGroupConfiguration );
- saveConfiguration( configuration );
- triggerAuditEvent( repositoryGroup.getId(), null, AuditEvent.ADD_REPO_GROUP, auditInformation );
- return Boolean.TRUE;
- }
-
- public Boolean deleteRepositoryGroup( String repositoryGroupId, AuditInformation auditInformation )
- throws RepositoryAdminException
- {
- Configuration configuration = getArchivaConfiguration().getConfiguration();
- RepositoryGroupConfiguration repositoryGroupConfiguration =
- configuration.getRepositoryGroupsAsMap().get( repositoryGroupId );
- if ( repositoryGroupConfiguration == null )
- {
- throw new RepositoryAdminException(
- "repositoryGroup with id " + repositoryGroupId + " doesn't not exists so cannot remove" );
- }
- configuration.removeRepositoryGroup( repositoryGroupConfiguration );
- triggerAuditEvent( repositoryGroupId, null, AuditEvent.DELETE_REPO_GROUP, auditInformation );
- return Boolean.TRUE;
- }
-
- public Boolean updateRepositoryGroup( RepositoryGroup repositoryGroup, AuditInformation auditInformation )
- throws RepositoryAdminException
- {
- return updateRepositoryGroup( repositoryGroup, auditInformation, true );
- }
-
- private Boolean updateRepositoryGroup( RepositoryGroup repositoryGroup, AuditInformation auditInformation,
- boolean triggerAuditEvent )
- throws RepositoryAdminException
- {
- validateRepositoryGroup( repositoryGroup, true );
- validateManagedRepositoriesExists( repositoryGroup.getRepositories() );
- Configuration configuration = getArchivaConfiguration().getConfiguration();
-
- RepositoryGroupConfiguration repositoryGroupConfiguration =
- configuration.getRepositoryGroupsAsMap().get( repositoryGroup.getId() );
-
- configuration.removeRepositoryGroup( repositoryGroupConfiguration );
-
- repositoryGroupConfiguration.setRepositories( repositoryGroup.getRepositories() );
- configuration.addRepositoryGroup( repositoryGroupConfiguration );
-
- saveConfiguration( configuration );
- if ( triggerAuditEvent )
- {
- triggerAuditEvent( repositoryGroup.getId(), null, AuditEvent.MODIFY_REPO_GROUP, auditInformation );
- }
- return Boolean.TRUE;
- }
-
-
- public Boolean addRepositoryToGroup( String repositoryGroupId, String repositoryId,
- AuditInformation auditInformation )
- throws RepositoryAdminException
- {
- RepositoryGroup repositoryGroup = getRepositoryGroup( repositoryGroupId );
- if ( repositoryGroup == null )
- {
- throw new RepositoryAdminException(
- "repositoryGroup with id " + repositoryGroupId + " doesn't not exists so cannot add repository to it" );
- }
-
- if ( repositoryGroup.getRepositories().contains( repositoryId ) )
- {
- throw new RepositoryAdminException(
- "repositoryGroup with id " + repositoryGroupId + " already contain repository with id" + repositoryId );
- }
- validateManagedRepositoriesExists( Arrays.asList( repositoryId ) );
-
- repositoryGroup.addRepository( repositoryId );
- updateRepositoryGroup( repositoryGroup, auditInformation, false );
- triggerAuditEvent( repositoryGroup.getId(), null, AuditEvent.ADD_REPO_TO_GROUP, auditInformation );
- return Boolean.TRUE;
- }
-
- public Boolean deleteRepositoryFromGroup( String repositoryGroupId, String repositoryId,
- AuditInformation auditInformation )
- throws RepositoryAdminException
- {
- RepositoryGroup repositoryGroup = getRepositoryGroup( repositoryGroupId );
- if ( repositoryGroup == null )
- {
- throw new RepositoryAdminException( "repositoryGroup with id " + repositoryGroupId
- + " doesn't not exists so cannot remove repository from it" );
- }
-
- if ( !repositoryGroup.getRepositories().contains( repositoryId ) )
- {
- throw new RepositoryAdminException(
- "repositoryGroup with id " + repositoryGroupId + " doesn't not contains repository with id"
- + repositoryId );
- }
-
- repositoryGroup.removeRepository( repositoryId );
- updateRepositoryGroup( repositoryGroup, auditInformation, false );
- triggerAuditEvent( repositoryGroup.getId(), null, AuditEvent.DELETE_REPO_FROM_GROUP, auditInformation );
- return Boolean.TRUE;
- }
-
- public Map<String, RepositoryGroup> getRepositoryGroupsAsMap()
- throws RepositoryAdminException
- {
- List<RepositoryGroup> repositoriesGroups = getRepositoriesGroups();
- Map<String, RepositoryGroup> map = new HashMap<String, RepositoryGroup>( repositoriesGroups.size() );
- for ( RepositoryGroup repositoryGroup : repositoriesGroups )
- {
- map.put( repositoryGroup.getId(), repositoryGroup );
- }
- return map;
- }
-
- public Map<String, List<String>> getGroupToRepositoryMap()
- throws RepositoryAdminException
- {
-
- java.util.Map<String, java.util.List<String>> map = new java.util.HashMap<String, java.util.List<String>>();
-
- for ( ManagedRepository repo : getManagedRepositoryAdmin().getManagedRepositories() )
- {
- for ( RepositoryGroup group : getRepositoriesGroups() )
- {
- if ( !group.getRepositories().contains( repo.getId() ) )
- {
- String groupId = group.getId();
- java.util.List<String> repos = map.get( groupId );
- if ( repos == null )
- {
- repos = new java.util.ArrayList<String>();
- map.put( groupId, repos );
- }
- repos.add( repo.getId() );
- }
- }
- }
- return map;
- }
-
- public Map<String, List<String>> getRepositoryToGroupMap()
- throws RepositoryAdminException
- {
- java.util.Map<String, java.util.List<String>> map = new java.util.HashMap<String, java.util.List<String>>();
-
- for ( RepositoryGroup group : getRepositoriesGroups() )
- {
- for ( String repositoryId : group.getRepositories() )
- {
- java.util.List<String> groups = map.get( repositoryId );
- if ( groups == null )
- {
- groups = new java.util.ArrayList<String>();
- map.put( repositoryId, groups );
- }
- groups.add( group.getId() );
- }
- }
- return map;
- }
-
- public Boolean validateRepositoryGroup( RepositoryGroup repositoryGroup, boolean updateMode )
- throws RepositoryAdminException
- {
- String repoGroupId = repositoryGroup.getId();
- if ( StringUtils.isBlank( repoGroupId ) )
- {
- throw new RepositoryAdminException( "repositoryGroup id cannot be empty" );
- }
-
- if ( repoGroupId.length() > 100 )
- {
- throw new RepositoryAdminException(
- "Identifier [" + repoGroupId + "] is over the maximum limit of 100 characters" );
-
- }
-
- Matcher matcher = REPO_GROUP_ID_PATTERN.matcher( repoGroupId );
- if ( !matcher.matches() )
- {
- throw new RepositoryAdminException(
- "Invalid character(s) found in identifier. Only the following characters are allowed: alphanumeric, '.', '-' and '_'" );
- }
-
- Configuration configuration = getArchivaConfiguration().getConfiguration();
-
- if ( configuration.getRepositoryGroupsAsMap().containsKey( repoGroupId ) )
- {
- if ( !updateMode )
- {
- throw new RepositoryAdminException( "Unable to add new repository group with id [" + repoGroupId
- + "], that id already exists as a repository group." );
- }
- }
- else if ( configuration.getManagedRepositoriesAsMap().containsKey( repoGroupId ) )
- {
- throw new RepositoryAdminException( "Unable to add new repository group with id [" + repoGroupId
- + "], that id already exists as a managed repository." );
- }
- else if ( configuration.getRemoteRepositoriesAsMap().containsKey( repoGroupId ) )
- {
- throw new RepositoryAdminException( "Unable to add new repository group with id [" + repoGroupId
- + "], that id already exists as a remote repository." );
- }
-
- return Boolean.TRUE;
- }
-
- private void validateManagedRepositoriesExists( List<String> managedRepositoriesIds )
- throws RepositoryAdminException
- {
- for ( String id : managedRepositoriesIds )
- {
- if ( getManagedRepositoryAdmin().getManagedRepository( id ) == null )
- {
- throw new RepositoryAdminException(
- "managedRepository with id " + id + " not exists so cannot be used in a repositoryGroup" );
- }
- }
- }
-
- public ManagedRepositoryAdmin getManagedRepositoryAdmin()
- {
- return managedRepositoryAdmin;
- }
-
- public void setManagedRepositoryAdmin( ManagedRepositoryAdmin managedRepositoryAdmin )
- {
- this.managedRepositoryAdmin = managedRepositoryAdmin;
- }
-}
+++ /dev/null
-package org.apache.archiva.admin.repository.group;
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author Olivier Lamy
- * @since 1.4
- */
-public class RepositoryGroup
- implements Serializable
-{
- /**
- * repository group Id
- */
- private String id;
-
- /**
- * repositories ids
- */
- private List<String> repositories;
-
- public RepositoryGroup()
- {
- // no op
- }
-
- public RepositoryGroup( String id, List<String> repositories )
- {
- this.id = id;
- this.repositories = repositories;
- }
-
- /**
- * Method addRepository.
- *
- * @param string
- */
- public void addRepository( String string )
- {
- getRepositories().add( string );
- }
-
- /**
- * Get the id of the repository group.
- *
- * @return String
- */
- public String getId()
- {
- return this.id;
- }
-
- /**
- * Method getRepositories.
- *
- * @return List
- */
- public java.util.List<String> getRepositories()
- {
- if ( this.repositories == null )
- {
- this.repositories = new ArrayList<String>();
- }
-
- return this.repositories;
- }
-
- /**
- * Method removeRepository.
- *
- * @param string
- */
- public void removeRepository( String string )
- {
- getRepositories().remove( string );
- }
-
- /**
- * Set the id of the repository group.
- *
- * @param id
- */
- public void setId( String id )
- {
- this.id = id;
- }
-
- /**
- * Set the list of repository ids under the group.
- *
- * @param repositories
- */
- public void setRepositories( List<String> repositories )
- {
- this.repositories = repositories;
- }
-
- public boolean equals( Object other )
- {
- if ( this == other )
- {
- return true;
- }
-
- if ( !( other instanceof RepositoryGroup ) )
- {
- return false;
- }
-
- RepositoryGroup that = (RepositoryGroup) other;
- boolean result = true;
- result = result && ( getId() == null ? that.getId() == null : getId().equals( that.getId() ) );
- return result;
- }
-
- public int hashCode()
- {
- int result = 17;
- result = 37 * result + ( id != null ? id.hashCode() : 0 );
- return result;
- }
-
- @Override
- public String toString()
- {
- final StringBuilder sb = new StringBuilder();
- sb.append( "RepositoryGroup" );
- sb.append( "{id='" ).append( id ).append( '\'' );
- sb.append( ", repositories=" ).append( repositories );
- sb.append( '}' );
- return sb.toString();
- }
-}
+++ /dev/null
-package org.apache.archiva.admin.repository.group;
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.archiva.admin.AuditInformation;
-import org.apache.archiva.admin.repository.RepositoryAdminException;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author Olivier Lamy
- * @since 1.4
- */
-public interface RepositoryGroupAdmin
-{
- List<RepositoryGroup> getRepositoriesGroups()
- throws RepositoryAdminException;
-
- RepositoryGroup getRepositoryGroup( String repositoryGroupId )
- throws RepositoryAdminException;
-
- Boolean addRepositoryGroup( RepositoryGroup repositoryGroup, AuditInformation auditInformation )
- throws RepositoryAdminException;
-
- Boolean updateRepositoryGroup( RepositoryGroup repositoryGroup, AuditInformation auditInformation )
- throws RepositoryAdminException;
-
- Boolean deleteRepositoryGroup( String repositoryGroupId, AuditInformation auditInformation )
- throws RepositoryAdminException;
-
- Boolean addRepositoryToGroup( String repositoryGroupId, String repositoryId, AuditInformation auditInformation )
- throws RepositoryAdminException;
-
- Boolean deleteRepositoryFromGroup( String repositoryGroupId, String repositoryId,
- AuditInformation auditInformation )
- throws RepositoryAdminException;
-
- /**
- * @return Map with key repoGroupId and value repoGroup
- * @throws RepositoryAdminException
- */
- Map<String, RepositoryGroup> getRepositoryGroupsAsMap()
- throws RepositoryAdminException;
-
- /**
- * @return Map with key repoGroupId and value List of ManagedRepositories
- * @throws RepositoryAdminException
- */
- Map<String, List<String>> getGroupToRepositoryMap()
- throws RepositoryAdminException;
-
- /**
- * @return Map with key managedRepo id and value List of repositoryGroup ids where the repo is
- * @throws RepositoryAdminException
- */
- Map<String, List<String>> getRepositoryToGroupMap()
- throws RepositoryAdminException;
-}
+++ /dev/null
-package org.apache.archiva.admin.repository.managed;
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.archiva.admin.AuditInformation;
-import org.apache.archiva.admin.repository.AbstractRepositoryAdmin;
-import org.apache.archiva.admin.repository.RepositoryAdminException;
-import org.apache.archiva.audit.AuditEvent;
-import org.apache.archiva.metadata.repository.MetadataRepository;
-import org.apache.archiva.metadata.repository.MetadataRepositoryException;
-import org.apache.archiva.metadata.repository.RepositorySession;
-import org.apache.archiva.metadata.repository.RepositorySessionFactory;
-import org.apache.archiva.metadata.repository.stats.RepositoryStatisticsManager;
-import org.apache.archiva.scheduler.repository.RepositoryArchivaTaskScheduler;
-import org.apache.archiva.scheduler.repository.RepositoryTask;
-import org.apache.archiva.security.common.ArchivaRoleConstants;
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.validator.GenericValidator;
-import org.apache.maven.archiva.configuration.Configuration;
-import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
-import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration;
-import org.apache.maven.archiva.configuration.RepositoryGroupConfiguration;
-import org.codehaus.plexus.redback.role.RoleManager;
-import org.codehaus.plexus.redback.role.RoleManagerException;
-import org.codehaus.plexus.taskqueue.TaskQueueException;
-import org.codehaus.redback.components.scheduler.CronExpressionValidator;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Service;
-
-import javax.inject.Inject;
-import javax.inject.Named;
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * FIXME remove all generic Exception to have usefull ones
- * FIXME review the staging mechanism to have a per user session one
- *
- * @author Olivier Lamy
- */
-@Service( "managedRepositoryAdmin#default" )
-public class DefaultManagedRepositoryAdmin
- extends AbstractRepositoryAdmin
- implements ManagedRepositoryAdmin
-{
-
- public static final String REPOSITORY_LOCATION_VALID_EXPRESSION = "^[-a-zA-Z0-9._/~:?!&=\\\\]+$";
-
- private Logger log = LoggerFactory.getLogger( getClass() );
-
- public static final String STAGE_REPO_ID_END = "-stage";
-
-
- @Inject
- @Named( value = "archivaTaskScheduler#repository" )
- private RepositoryArchivaTaskScheduler repositoryTaskScheduler;
-
- @Inject
- private RepositorySessionFactory repositorySessionFactory;
-
- @Inject
- private RepositoryStatisticsManager repositoryStatisticsManager;
-
-
- @Inject
- protected RoleManager roleManager;
-
- public List<ManagedRepository> getManagedRepositories()
- throws RepositoryAdminException
- {
- List<ManagedRepositoryConfiguration> managedRepoConfigs =
- getArchivaConfiguration().getConfiguration().getManagedRepositories();
-
- List<ManagedRepository> managedRepos = new ArrayList<ManagedRepository>( managedRepoConfigs.size() );
-
- for ( ManagedRepositoryConfiguration repoConfig : managedRepoConfigs )
- {
- // TODO add staging repo information back too
- ManagedRepository repo =
- new ManagedRepository( repoConfig.getId(), repoConfig.getName(), repoConfig.getLocation(),
- repoConfig.getLayout(), repoConfig.isSnapshots(), repoConfig.isReleases(),
- repoConfig.isBlockRedeployments(), repoConfig.getRefreshCronExpression(),
- repoConfig.getIndexDir(), repoConfig.isScanned(), repoConfig.getDaysOlder(),
- repoConfig.getRetentionCount(), repoConfig.isDeleteReleasedSnapshots() );
-
- managedRepos.add( repo );
- }
-
- return managedRepos;
- }
-
- public Map<String, ManagedRepository> getManagedRepositoriesAsMap()
- throws RepositoryAdminException
- {
- List<ManagedRepository> managedRepositories = getManagedRepositories();
- Map<String, ManagedRepository> repositoriesMap =
- new HashMap<String, ManagedRepository>( managedRepositories.size() );
- for ( ManagedRepository managedRepository : managedRepositories )
- {
- repositoriesMap.put( managedRepository.getId(), managedRepository );
- }
- return repositoriesMap;
- }
-
- public ManagedRepository getManagedRepository( String repositoryId )
- throws RepositoryAdminException
- {
- List<ManagedRepository> repos = getManagedRepositories();
- for ( ManagedRepository repo : repos )
- {
- if ( StringUtils.equals( repo.getId(), repositoryId ) )
- {
- return repo;
- }
- }
- return null;
- }
-
- public Boolean addManagedRepository( ManagedRepository managedRepository, boolean needStageRepo,
- AuditInformation auditInformation )
- throws RepositoryAdminException
- {
-
- getRepositoryCommonValidator().basicValidation( managedRepository, false );
- triggerAuditEvent( managedRepository.getId(), null, AuditEvent.ADD_MANAGED_REPO, auditInformation );
- return
- addManagedRepository( managedRepository.getId(), managedRepository.getLayout(), managedRepository.getName(),
- managedRepository.getLocation(), managedRepository.isBlockRedeployments(),
- managedRepository.isReleases(), managedRepository.isSnapshots(), needStageRepo,
- managedRepository.getCronExpression(), managedRepository.getIndexDirectory(),
- managedRepository.getDaysOlder(), managedRepository.getRetentionCount(),
- managedRepository.isDeleteReleasedSnapshots(), auditInformation,
- getArchivaConfiguration().getConfiguration() ) != null;
-
- }
-
- private ManagedRepositoryConfiguration addManagedRepository( String repoId, String layout, String name,
- String location, boolean blockRedeployments,
- boolean releasesIncluded, boolean snapshotsIncluded,
- boolean stageRepoNeeded, String cronExpression,
- String indexDir, int daysOlder, int retentionCount,
- boolean deteleReleasedSnapshots,
- AuditInformation auditInformation,
- Configuration config )
- throws RepositoryAdminException
- {
-
- // FIXME : olamy can be empty to avoid scheduled scan ?
- if ( StringUtils.isNotBlank( cronExpression ) )
- {
- CronExpressionValidator validator = new CronExpressionValidator();
-
- if ( !validator.validate( cronExpression ) )
- {
- throw new RepositoryAdminException( "Invalid cron expression." );
- }
- }
- else
- {
- throw new RepositoryAdminException( "Cron expression cannot be empty." );
- }
-
- String repoLocation = getRepositoryCommonValidator().removeExpressions( location );
-
- if ( !GenericValidator.matchRegexp( repoLocation, REPOSITORY_LOCATION_VALID_EXPRESSION ) )
- {
- throw new RepositoryAdminException(
- "Invalid repository location. Directory must only contain alphanumeric characters, equals(=), question-marks(?), "
- + "exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-)." );
- }
-
- ManagedRepositoryConfiguration repository = new ManagedRepositoryConfiguration();
-
- repository.setId( repoId );
- repository.setBlockRedeployments( blockRedeployments );
- repository.setReleases( releasesIncluded );
- repository.setSnapshots( snapshotsIncluded );
- repository.setName( name );
- repository.setLocation( repoLocation );
- repository.setLayout( layout );
- repository.setRefreshCronExpression( cronExpression );
- repository.setIndexDir( indexDir );
- repository.setDaysOlder( daysOlder );
- repository.setRetentionCount( retentionCount );
- repository.setDeleteReleasedSnapshots( deteleReleasedSnapshots );
- try
- {
- addRepository( repository, config );
- addRepositoryRoles( repository );
-
- if ( stageRepoNeeded )
- {
- ManagedRepositoryConfiguration stagingRepository = getStageRepoConfig( repository );
- addRepository( stagingRepository, config );
- addRepositoryRoles( stagingRepository );
- triggerAuditEvent( stagingRepository.getId(), null, AuditEvent.ADD_MANAGED_REPO, auditInformation );
- }
- }
- catch ( RoleManagerException e )
- {
- throw new RepositoryAdminException( "failed to add repository roles " + e.getMessage(), e );
- }
- catch ( IOException e )
- {
- throw new RepositoryAdminException( "failed to add repository " + e.getMessage(), e );
- }
-
- saveConfiguration( config );
-
- //MRM-1342 Repository statistics report doesn't appear to be working correctly
- //scan repository when adding of repository is successful
- try
- {
- scanRepository( repoId, true );
- // olamy no need of scanning staged repo
- /*
- if ( stageRepoNeeded )
- {
- ManagedRepositoryConfiguration stagingRepository = getStageRepoConfig( repository );
- scanRepository( stagingRepository.getId(), true );
- }*/
- }
- catch ( Exception e )
- {
- log.warn( new StringBuilder( "Unable to scan repository [" ).append( repoId ).append( "]: " ).append(
- e.getMessage() ).toString(), e );
- }
-
- return repository;
- }
-
-
- // FIXME cleanup repositoryGroups when deleting a ManagedRepo
- public Boolean deleteManagedRepository( String repositoryId, AuditInformation auditInformation,
- boolean deleteContent )
- throws RepositoryAdminException
- {
- Configuration config = getArchivaConfiguration().getConfiguration();
-
- ManagedRepositoryConfiguration repository = config.findManagedRepositoryById( repositoryId );
-
- if ( repository == null )
- {
- throw new RepositoryAdminException( "A repository with that id does not exist" );
- }
-
- triggerAuditEvent( repositoryId, null, AuditEvent.DELETE_MANAGED_REPO, auditInformation );
-
- deleteManagedRepository( repository, deleteContent, config, false );
-
- // stage repo exists ?
- ManagedRepositoryConfiguration stagingRepository =
- getArchivaConfiguration().getConfiguration().findManagedRepositoryById( repositoryId + STAGE_REPO_ID_END );
- if ( stagingRepository != null )
- {
- // do not trigger event when deleting the staged one
- //triggerAuditEvent( stagingRepository.getId(), null, AuditEvent.DELETE_MANAGED_REPO, auditInformation );
- deleteManagedRepository( stagingRepository, deleteContent, config, true );
- }
-
- try
- {
- saveConfiguration( config );
- }
- catch ( Exception e )
- {
- throw new RepositoryAdminException( "Error saving configuration for delete action" + e.getMessage() );
- }
-
- return Boolean.TRUE;
- }
-
- private Boolean deleteManagedRepository( ManagedRepositoryConfiguration repository, boolean deleteContent,
- Configuration config, boolean stagedOne )
- throws RepositoryAdminException
- {
- if ( !stagedOne )
- {
- RepositorySession repositorySession = getRepositorySessionFactory().createSession();
- try
- {
- MetadataRepository metadataRepository = repositorySession.getRepository();
- metadataRepository.removeRepository( repository.getId() );
- log.debug( "call repositoryStatisticsManager.deleteStatistics" );
- getRepositoryStatisticsManager().deleteStatistics( metadataRepository, repository.getId() );
- repositorySession.save();
- }
- catch ( MetadataRepositoryException e )
- {
- throw new RepositoryAdminException( e.getMessage(), e );
- }
- finally
- {
- repositorySession.close();
- }
- }
- config.removeManagedRepository( repository );
-
- if ( deleteContent )
- {
- // TODO could be async ? as directory can be huge
- File dir = new File( repository.getLocation() );
- if ( !FileUtils.deleteQuietly( dir ) )
- {
- throw new RepositoryAdminException( "Cannot delete repository " + dir );
- }
- }
-
- // olamy: copy list for reading as a unit test in webapp fail with ConcurrentModificationException
- List<ProxyConnectorConfiguration> proxyConnectors =
- new ArrayList<ProxyConnectorConfiguration>( config.getProxyConnectors() );
- for ( ProxyConnectorConfiguration proxyConnector : proxyConnectors )
- {
- if ( StringUtils.equals( proxyConnector.getSourceRepoId(), repository.getId() ) )
- {
- config.removeProxyConnector( proxyConnector );
- }
- }
-
- Map<String, List<String>> repoToGroupMap = config.getRepositoryToGroupMap();
- if ( repoToGroupMap != null )
- {
- if ( repoToGroupMap.containsKey( repository.getId() ) )
- {
- List<String> repoGroups = repoToGroupMap.get( repository.getId() );
- for ( String repoGroup : repoGroups )
- {
- // copy to prevent UnsupportedOperationException
- RepositoryGroupConfiguration repositoryGroupConfiguration =
- config.findRepositoryGroupById( repoGroup );
- List<String> repos = new ArrayList<String>( repositoryGroupConfiguration.getRepositories() );
- config.removeRepositoryGroup( repositoryGroupConfiguration );
- repos.remove( repository.getId() );
- repositoryGroupConfiguration.setRepositories( repos );
- config.addRepositoryGroup( repositoryGroupConfiguration );
- }
- }
- }
-
- try
- {
- removeRepositoryRoles( repository );
- }
- catch ( RoleManagerException e )
- {
- throw new RepositoryAdminException(
- "fail to remove repository roles for repository " + repository.getId() + " : " + e.getMessage(), e );
- }
-
- saveConfiguration( config );
-
- return Boolean.TRUE;
- }
-
-
- public Boolean updateManagedRepository( ManagedRepository managedRepository, boolean needStageRepo,
- AuditInformation auditInformation, boolean resetStats )
- throws RepositoryAdminException
- {
-
- log.debug( "updateManagedConfiguration repo {} needStage {} resetStats {} ",
- Arrays.asList( managedRepository, needStageRepo, resetStats ).toArray() );
-
- // Ensure that the fields are valid.
-
- getRepositoryCommonValidator().basicValidation( managedRepository, true );
-
- Configuration configuration = getArchivaConfiguration().getConfiguration();
-
- ManagedRepositoryConfiguration toremove = configuration.findManagedRepositoryById( managedRepository.getId() );
-
- if ( toremove != null )
- {
- configuration.removeManagedRepository( toremove );
- }
-
- ManagedRepositoryConfiguration stagingRepository = getStageRepoConfig( toremove );
-
- // TODO remove content from old if path has changed !!!!!
-
- if ( stagingRepository != null )
- {
- configuration.removeManagedRepository( stagingRepository );
- }
-
- ManagedRepositoryConfiguration managedRepositoryConfiguration =
- addManagedRepository( managedRepository.getId(), managedRepository.getLayout(), managedRepository.getName(),
- managedRepository.getLocation(), managedRepository.isBlockRedeployments(),
- managedRepository.isReleases(), managedRepository.isSnapshots(), needStageRepo,
- managedRepository.getCronExpression(), managedRepository.getIndexDirectory(),
- managedRepository.getDaysOlder(), managedRepository.getRetentionCount(),
- managedRepository.isDeleteReleasedSnapshots(), auditInformation,
- getArchivaConfiguration().getConfiguration() );
-
- // Save the repository configuration.
- RepositorySession repositorySession = getRepositorySessionFactory().createSession();
-
- try
- {
- triggerAuditEvent( managedRepositoryConfiguration.getId(), null, AuditEvent.MODIFY_MANAGED_REPO,
- auditInformation );
-
- saveConfiguration( this.getArchivaConfiguration().getConfiguration() );
- if ( resetStats )
- {
- log.debug( "call repositoryStatisticsManager.deleteStatistics" );
- getRepositoryStatisticsManager().deleteStatistics( repositorySession.getRepository(),
- managedRepositoryConfiguration.getId() );
- repositorySession.save();
- }
-
- }
- catch ( MetadataRepositoryException e )
- {
- throw new RepositoryAdminException( e.getMessage(), e );
- }
- finally
- {
- repositorySession.close();
- }
-
- return true;
- }
-
- //--------------------------
- // utils methods
- //--------------------------
-
-
- protected void addRepository( ManagedRepositoryConfiguration repository, Configuration configuration )
- throws RepositoryAdminException, IOException
- {
- // Normalize the path
- File file = new File( repository.getLocation() );
- repository.setLocation( file.getCanonicalPath() );
- if ( !file.exists() )
- {
- file.mkdirs();
- }
- if ( !file.exists() || !file.isDirectory() )
- {
- throw new RepositoryAdminException(
- "Unable to add repository - no write access, can not create the root directory: " + file );
- }
-
- configuration.addManagedRepository( repository );
- }
-
- private ManagedRepositoryConfiguration getStageRepoConfig( ManagedRepositoryConfiguration repository )
- {
- ManagedRepositoryConfiguration stagingRepository = new ManagedRepositoryConfiguration();
- stagingRepository.setId( repository.getId() + STAGE_REPO_ID_END );
- stagingRepository.setLayout( repository.getLayout() );
- stagingRepository.setName( repository.getName() + STAGE_REPO_ID_END );
- stagingRepository.setBlockRedeployments( repository.isBlockRedeployments() );
- stagingRepository.setDaysOlder( repository.getDaysOlder() );
- stagingRepository.setDeleteReleasedSnapshots( repository.isDeleteReleasedSnapshots() );
- stagingRepository.setIndexDir( repository.getIndexDir() );
- String path = repository.getLocation();
- int lastIndex = path.lastIndexOf( '/' );
- stagingRepository.setLocation( path.substring( 0, lastIndex ) + "/" + stagingRepository.getId() );
- stagingRepository.setRefreshCronExpression( repository.getRefreshCronExpression() );
- stagingRepository.setReleases( repository.isReleases() );
- stagingRepository.setRetentionCount( repository.getRetentionCount() );
- stagingRepository.setScanned( repository.isScanned() );
- stagingRepository.setSnapshots( repository.isSnapshots() );
- return stagingRepository;
- }
-
- public Boolean scanRepository( String repositoryId, boolean fullScan )
- {
- if ( getRepositoryTaskScheduler().isProcessingRepositoryTask( repositoryId ) )
- {
- log.info( "scanning of repository with id {} already scheduled", repositoryId );
- }
- RepositoryTask task = new RepositoryTask();
- task.setRepositoryId( repositoryId );
- task.setScanAll( fullScan );
- try
- {
- getRepositoryTaskScheduler().queueTask( task );
- }
- catch ( TaskQueueException e )
- {
- log.error( "failed to schedule scanning of repo with id {}", repositoryId, e );
- return false;
- }
- return true;
- }
-
- 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 ( !getRoleManager().templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, repoId ) )
- {
- getRoleManager().createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, repoId );
- }
-
- if ( !getRoleManager().templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, repoId ) )
- {
- getRoleManager().createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, repoId );
- }
- }
-
- protected void removeRepositoryRoles( ManagedRepositoryConfiguration existingRepository )
- throws RoleManagerException
- {
- String repoId = existingRepository.getId();
-
- if ( getRoleManager().templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, repoId ) )
- {
- getRoleManager().removeTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, repoId );
- }
-
- if ( getRoleManager().templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, repoId ) )
- {
- getRoleManager().removeTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, repoId );
- }
-
- log.debug( "removed user roles associated with repository {}", repoId );
- }
-
- //--------------------------
- // setters/getters
- //--------------------------
-
-
- public RoleManager getRoleManager()
- {
- return roleManager;
- }
-
- public void setRoleManager( RoleManager roleManager )
- {
- this.roleManager = roleManager;
- }
-
- public RepositoryStatisticsManager getRepositoryStatisticsManager()
- {
- return repositoryStatisticsManager;
- }
-
- public void setRepositoryStatisticsManager( RepositoryStatisticsManager repositoryStatisticsManager )
- {
- this.repositoryStatisticsManager = repositoryStatisticsManager;
- }
-
- public RepositorySessionFactory getRepositorySessionFactory()
- {
- return repositorySessionFactory;
- }
-
- public void setRepositorySessionFactory( RepositorySessionFactory repositorySessionFactory )
- {
- this.repositorySessionFactory = repositorySessionFactory;
- }
-
-
- public RepositoryArchivaTaskScheduler getRepositoryTaskScheduler()
- {
- return repositoryTaskScheduler;
- }
-
- public void setRepositoryTaskScheduler( RepositoryArchivaTaskScheduler repositoryTaskScheduler )
- {
- this.repositoryTaskScheduler = repositoryTaskScheduler;
- }
-}
+++ /dev/null
-package org.apache.archiva.admin.repository.managed;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.archiva.admin.repository.AbstractRepository;
-
-import java.io.Serializable;
-
-/**
- * @author Olivier Lamy
- * @since 1.4
- */
-public class ManagedRepository
- extends AbstractRepository
- implements Serializable
-{
-
- private String location;
-
- private boolean snapshots = false;
-
- private boolean releases = true;
-
- private boolean blockRedeployments = false;
-
- /**
- * default model value
- */
- private String cronExpression = "0 0 * * * ?";
-
-
- /**
- * not need when creating the repo : only available when reading
- */
- private ManagedRepository stagingRepository;
-
- private boolean scanned = true;
-
- private String indexDirectory;
-
- /**
- * default model value
- */
- private int daysOlder = 100;
-
- /**
- * default model value
- */
- private int retentionCount = 2;
-
- private boolean deleteReleasedSnapshots;
-
- public ManagedRepository()
- {
- // no op
- }
-
- public ManagedRepository( String id, String name, String location, String layout, boolean snapshots,
- boolean releases, boolean blockRedeployments, String cronExpression, String indexDir,
- boolean scanned, int daysOlder, int retentionCount, boolean deleteReleasedSnapshots )
- {
- super(id, name, layout);
-
- this.location = location;
- this.snapshots = snapshots;
- this.releases = releases;
- this.blockRedeployments = blockRedeployments;
- this.cronExpression = cronExpression;
- this.indexDirectory = indexDir;
- this.scanned = scanned;
- this.daysOlder = daysOlder;
- this.retentionCount = retentionCount;
- this.deleteReleasedSnapshots = deleteReleasedSnapshots;
- }
-
- public String getLocation()
- {
- return this.location;
- }
-
-
- public boolean isReleases()
- {
- return this.releases;
- }
-
- /**
- * Get null
- */
- public boolean isSnapshots()
- {
- return this.snapshots;
- }
-
-
- public void setReleases( boolean releases )
- {
- this.releases = releases;
- }
-
- public void setSnapshots( boolean snapshots )
- {
- this.snapshots = snapshots;
- }
-
- public void setLocation( String location )
- {
- this.location = location;
- }
-
- public boolean isBlockRedeployments()
- {
- return blockRedeployments;
- }
-
- public void setBlockRedeployments( boolean blockRedeployments )
- {
- this.blockRedeployments = blockRedeployments;
- }
-
- public String getCronExpression()
- {
- return cronExpression;
- }
-
- public void setCronExpression( String cronExpression )
- {
- this.cronExpression = cronExpression;
- }
-
- public ManagedRepository getStagingRepository()
- {
- return stagingRepository;
- }
-
-
- public void setStagingRepository( ManagedRepository stagingRepository )
- {
- this.stagingRepository = stagingRepository;
- }
-
- public boolean isScanned()
- {
- return scanned;
- }
-
- public void setScanned( boolean scanned )
- {
- this.scanned = scanned;
- }
-
- public String getIndexDirectory()
- {
- return indexDirectory;
- }
-
- public void setIndexDirectory( String indexDirectory )
- {
- this.indexDirectory = indexDirectory;
- }
-
- public int getDaysOlder()
- {
- return daysOlder;
- }
-
- public void setDaysOlder( int daysOlder )
- {
- this.daysOlder = daysOlder;
- }
-
- public int getRetentionCount()
- {
- return retentionCount;
- }
-
- public void setRetentionCount( int retentionCount )
- {
- this.retentionCount = retentionCount;
- }
-
- public boolean isDeleteReleasedSnapshots()
- {
- return deleteReleasedSnapshots;
- }
-
- public void setDeleteReleasedSnapshots( boolean deleteReleasedSnapshots )
- {
- this.deleteReleasedSnapshots = deleteReleasedSnapshots;
- }
-
-
- @Override
- public String toString()
- {
- final StringBuilder sb = new StringBuilder();
- sb.append( "ManagedRepository" );
- sb.append( "{location='" ).append( location ).append( '\'' );
- sb.append( ", snapshots=" ).append( snapshots );
- sb.append( ", releases=" ).append( releases );
- sb.append( ", blockRedeployments=" ).append( blockRedeployments );
- sb.append( ", cronExpression='" ).append( cronExpression ).append( '\'' );
- sb.append( ", stagingRepository=" ).append( stagingRepository );
- sb.append( ", scanned=" ).append( scanned );
- sb.append( ", indexDirectory='" ).append( indexDirectory ).append( '\'' );
- sb.append( ", daysOlder=" ).append( daysOlder );
- sb.append( ", retentionCount=" ).append( retentionCount );
- sb.append( ", deleteReleasedSnapshots=" ).append( deleteReleasedSnapshots );
- sb.append( '}' );
- sb.append( super.toString() );
- return sb.toString();
- }
-
-
-}
\ No newline at end of file
+++ /dev/null
-package org.apache.archiva.admin.repository.managed;
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-import org.apache.archiva.admin.AuditInformation;
-import org.apache.archiva.admin.repository.RepositoryAdminException;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author Olivier Lamy
- * @since 1.4
- */
-public interface ManagedRepositoryAdmin
-{
- List<ManagedRepository> getManagedRepositories()
- throws RepositoryAdminException;
-
- Map<String, ManagedRepository> getManagedRepositoriesAsMap()
- throws RepositoryAdminException;
-
- ManagedRepository getManagedRepository( String repositoryId )
- throws RepositoryAdminException;
-
- Boolean deleteManagedRepository( String repositoryId, AuditInformation auditInformation, boolean deleteContent )
- throws RepositoryAdminException;
-
- Boolean addManagedRepository( ManagedRepository managedRepository, boolean needStageRepo,
- AuditInformation auditInformation )
- throws RepositoryAdminException;
-
-
- Boolean updateManagedRepository( ManagedRepository managedRepository, boolean needStageRepo,
- AuditInformation auditInformation, boolean resetStats )
- throws RepositoryAdminException;
-
-
-}
+++ /dev/null
-package org.apache.archiva.admin.repository.networkproxy;
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import net.sf.beanlib.provider.replicator.BeanReplicator;
-import org.apache.archiva.admin.AuditInformation;
-import org.apache.archiva.admin.repository.AbstractRepositoryAdmin;
-import org.apache.archiva.admin.repository.RepositoryAdminException;
-import org.apache.archiva.audit.AuditEvent;
-import org.apache.commons.lang.StringUtils;
-import org.apache.maven.archiva.configuration.Configuration;
-import org.apache.maven.archiva.configuration.NetworkProxyConfiguration;
-import org.springframework.stereotype.Service;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author Olivier Lamy
- * @since 1.4
- */
-@Service( "networkProxyAdmin#default" )
-public class DefaultNetworkProxyAdmin
- extends AbstractRepositoryAdmin
- implements NetworkProxyAdmin
-{
-
- public List<NetworkProxy> getNetworkProxies()
- throws RepositoryAdminException
- {
- List<NetworkProxy> networkProxies = new ArrayList<NetworkProxy>();
- for ( NetworkProxyConfiguration networkProxyConfiguration : getArchivaConfiguration().getConfiguration().getNetworkProxies() )
- {
- networkProxies.add( getNetworkProxy( networkProxyConfiguration ) );
- }
- return networkProxies;
- }
-
- public NetworkProxy getNetworkProxy( String networkProxyId )
- throws RepositoryAdminException
- {
- for ( NetworkProxy networkProxy : getNetworkProxies() )
- {
- if ( StringUtils.equals( networkProxyId, networkProxy.getId() ) )
- {
- return networkProxy;
- }
- }
-
- return null;
- }
-
- public void addNetworkProxy( NetworkProxy networkProxy, AuditInformation auditInformation )
- throws RepositoryAdminException
- {
- if ( networkProxy == null )
- {
- return;
- }
- if ( getNetworkProxy( networkProxy.getId() ) != null )
- {
- throw new RepositoryAdminException(
- "cannot add NetworkProxy with id " + networkProxy.getId() + " already exist" );
- }
- Configuration configuration = getArchivaConfiguration().getConfiguration();
- configuration.addNetworkProxy( getNetworkProxyConfiguration( networkProxy ) );
-
- triggerAuditEvent( networkProxy.getId(), null, AuditEvent.ADD_NETWORK_PROXY, auditInformation );
-
- saveConfiguration( configuration );
- }
-
- public void updateNetworkProxy( NetworkProxy networkProxy, AuditInformation auditInformation )
- throws RepositoryAdminException
- {
- if ( networkProxy == null )
- {
- return;
- }
- if ( getNetworkProxy( networkProxy.getId() ) == null )
- {
- throw new RepositoryAdminException(
- "cannot update NetworkProxy with id " + networkProxy.getId() + " as not exist" );
- }
- Configuration configuration = getArchivaConfiguration().getConfiguration();
- NetworkProxyConfiguration networkProxyConfiguration = getNetworkProxyConfiguration( networkProxy );
- configuration.removeNetworkProxy( networkProxyConfiguration );
- configuration.addNetworkProxy( networkProxyConfiguration );
-
- triggerAuditEvent( networkProxy.getId(), null, AuditEvent.MODIFY_NETWORK_PROXY, auditInformation );
-
- saveConfiguration( configuration );
- }
-
- public void deleteNetworkProxy( String networkProxyId, AuditInformation auditInformation )
- throws RepositoryAdminException
- {
-
- NetworkProxy networkProxy = getNetworkProxy( networkProxyId );
- if ( networkProxy == null )
- {
- throw new RepositoryAdminException(
- "cannot delete NetworkProxy with id " + networkProxyId + " as not exist" );
- }
- Configuration configuration = getArchivaConfiguration().getConfiguration();
- NetworkProxyConfiguration networkProxyConfiguration = getNetworkProxyConfiguration( networkProxy );
- configuration.removeNetworkProxy( networkProxyConfiguration );
-
- triggerAuditEvent( networkProxy.getId(), null, AuditEvent.DELETE_NETWORK_PROXY, auditInformation );
-
- saveConfiguration( configuration );
- }
-
- protected NetworkProxy getNetworkProxy( NetworkProxyConfiguration networkProxyConfiguration )
- {
- return networkProxyConfiguration == null
- ? null
- : new BeanReplicator().replicateBean( networkProxyConfiguration, NetworkProxy.class );
- }
-
- protected NetworkProxyConfiguration getNetworkProxyConfiguration( NetworkProxy networkProxy )
- {
- return networkProxy == null
- ? null
- : new BeanReplicator().replicateBean( networkProxy, NetworkProxyConfiguration.class );
- }
-}
+++ /dev/null
-package org.apache.archiva.admin.repository.networkproxy;
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.Serializable;
-
-/**
- * @author Olivier Lamy
- * @since 1.4
- */
-public class NetworkProxy
- implements Serializable
-{
- private String id;
-
- /**
- * The network protocol to use with this proxy: "http", "socks-4"
- * .
- */
- private String protocol = "http";
-
- /**
- * The proxy host.
- */
- private String host;
-
- /**
- * The proxy port.
- */
- private int port = 8080;
-
- /**
- * The proxy user.
- */
- private String username;
-
- /**
- * The proxy password.
- */
- private String password;
-
- public NetworkProxy()
- {
- // no op
- }
-
- public NetworkProxy( String id, String protocol, String host, int port, String username, String password )
- {
- this.id = id;
- this.protocol = protocol;
- this.host = host;
- this.port = port;
- this.username = username;
- this.password = password;
- }
-
- public String getId()
- {
- return id;
- }
-
- public void setId( String id )
- {
- this.id = id;
- }
-
- public String getProtocol()
- {
- return protocol;
- }
-
- public void setProtocol( String protocol )
- {
- this.protocol = protocol;
- }
-
- public String getHost()
- {
- return host;
- }
-
- public void setHost( String host )
- {
- this.host = host;
- }
-
- public int getPort()
- {
- return port;
- }
-
- public void setPort( int port )
- {
- this.port = port;
- }
-
- public String getUsername()
- {
- return username;
- }
-
- public void setUsername( String username )
- {
- this.username = username;
- }
-
- public String getPassword()
- {
- return password;
- }
-
- public void setPassword( String password )
- {
- this.password = password;
- }
-
- @Override
- public boolean equals( Object o )
- {
- if ( this == o )
- {
- return true;
- }
- if ( o == null || getClass() != o.getClass() )
- {
- return false;
- }
-
- NetworkProxy that = (NetworkProxy) o;
-
- if ( id != null ? !id.equals( that.id ) : that.id != null )
- {
- return false;
- }
-
- return true;
- }
-
- @Override
- public int hashCode()
- {
- int result = 17;
- result = 37 * result + ( id != null ? id.hashCode() : 0 );
- return result;
- }
-
- @Override
- public String toString()
- {
- final StringBuilder sb = new StringBuilder();
- sb.append( "NetworkProxy" );
- sb.append( "{id='" ).append( id ).append( '\'' );
- sb.append( ", protocol='" ).append( protocol ).append( '\'' );
- sb.append( ", host='" ).append( host ).append( '\'' );
- sb.append( ", port=" ).append( port );
- sb.append( ", username='" ).append( username ).append( '\'' );
- sb.append( ", password='" ).append( password ).append( '\'' );
- sb.append( '}' );
- return sb.toString();
- }
-}
+++ /dev/null
-package org.apache.archiva.admin.repository.networkproxy;
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.archiva.admin.AuditInformation;
-import org.apache.archiva.admin.repository.RepositoryAdminException;
-
-import java.util.List;
-
-/**
- * @author Olivier Lamy
- * @since 1.4
- */
-public interface NetworkProxyAdmin
-{
- List<NetworkProxy> getNetworkProxies()
- throws RepositoryAdminException;
-
- NetworkProxy getNetworkProxy( String networkProxyId )
- throws RepositoryAdminException;
-
- void addNetworkProxy( NetworkProxy networkProxy, AuditInformation auditInformation )
- throws RepositoryAdminException;
-
- void updateNetworkProxy( NetworkProxy networkProxy, AuditInformation auditInformation )
- throws RepositoryAdminException;
-
- void deleteNetworkProxy( String networkProxyId, AuditInformation auditInformation )
- throws RepositoryAdminException;
-}
+++ /dev/null
-package org.apache.archiva.admin.repository.proxyconnector;
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import net.sf.beanlib.provider.replicator.BeanReplicator;
-import org.apache.archiva.admin.AuditInformation;
-import org.apache.archiva.admin.repository.AbstractRepositoryAdmin;
-import org.apache.archiva.admin.repository.RepositoryAdminException;
-import org.apache.archiva.admin.repository.managed.ManagedRepositoryAdmin;
-import org.apache.archiva.admin.repository.remote.RemoteRepositoryAdmin;
-import org.apache.archiva.audit.AuditEvent;
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.lang.StringUtils;
-import org.apache.maven.archiva.configuration.Configuration;
-import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration;
-import org.apache.maven.archiva.configuration.functors.ProxyConnectorSelectionPredicate;
-import org.springframework.stereotype.Service;
-
-import javax.inject.Inject;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author Olivier Lamy
- * @since 1.4
- */
-@Service( "proxyConnectorAdmin#default" )
-public class DefaultProxyConnectorAdmin
- extends AbstractRepositoryAdmin
- implements ProxyConnectorAdmin
-{
-
- @Inject
- private ManagedRepositoryAdmin managedRepositoryAdmin;
-
- @Inject
- private RemoteRepositoryAdmin remoteRepositoryAdmin;
-
- public List<ProxyConnector> getProxyConnectors()
- throws RepositoryAdminException
- {
- List<ProxyConnectorConfiguration> proxyConnectorConfigurations =
- getArchivaConfiguration().getConfiguration().getProxyConnectors();
- List<ProxyConnector> proxyConnectors = new ArrayList<ProxyConnector>( proxyConnectorConfigurations.size() );
- for ( ProxyConnectorConfiguration configuration : proxyConnectorConfigurations )
- {
- proxyConnectors.add( getProxyConnector( configuration ) );
- }
-
- return proxyConnectors;
- }
-
- public ProxyConnector getProxyConnector( String sourceRepoId, String targetRepoId )
- throws RepositoryAdminException
- {
- for ( ProxyConnector proxyConnector : getProxyConnectors() )
- {
- if ( StringUtils.equals( sourceRepoId, proxyConnector.getSourceRepoId() ) && StringUtils.equals(
- targetRepoId, proxyConnector.getTargetRepoId() ) )
- {
- return proxyConnector;
- }
- }
- return null;
- }
-
- public Boolean addProxyConnector( ProxyConnector proxyConnector, AuditInformation auditInformation )
- throws RepositoryAdminException
- {
- if ( getProxyConnector( proxyConnector.getSourceRepoId(), proxyConnector.getTargetRepoId() ) != null )
- {
- throw new RepositoryAdminException(
- "Unable to add proxy connector, as one already exists with source repository id ["
- + proxyConnector.getSourceRepoId() + "] and target repository id ["
- + proxyConnector.getTargetRepoId() + "]." );
- }
-
- validateProxyConnector( proxyConnector );
-
- proxyConnector.setBlackListPatterns( unescapePatterns( proxyConnector.getBlackListPatterns() ) );
- proxyConnector.setWhiteListPatterns( unescapePatterns( proxyConnector.getWhiteListPatterns() ) );
-
- Configuration configuration = getArchivaConfiguration().getConfiguration();
-
- ProxyConnectorConfiguration proxyConnectorConfiguration = getProxyConnectorConfiguration( proxyConnector );
- configuration.addProxyConnector( proxyConnectorConfiguration );
- saveConfiguration( configuration );
- triggerAuditEvent( proxyConnector.getSourceRepoId() + "-" + proxyConnector.getTargetRepoId(), null,
- AuditEvent.ADD_PROXY_CONNECTOR, auditInformation );
- return Boolean.TRUE;
-
- }
-
- public Boolean deleteProxyConnector( ProxyConnector proxyConnector, AuditInformation auditInformation )
- throws RepositoryAdminException
- {
- Configuration configuration = getArchivaConfiguration().getConfiguration();
- ProxyConnectorConfiguration proxyConnectorConfiguration =
- findProxyConnector( proxyConnector.getSourceRepoId(), proxyConnector.getTargetRepoId(), configuration );
- if ( proxyConnectorConfiguration == null )
- {
- throw new RepositoryAdminException(
- "unable to find ProxyConnector with source " + proxyConnector.getSourceRepoId() + " and target "
- + proxyConnector.getTargetRepoId() );
- }
- configuration.removeProxyConnector( proxyConnectorConfiguration );
- saveConfiguration( configuration );
- triggerAuditEvent( proxyConnector.getSourceRepoId() + "-" + proxyConnector.getTargetRepoId(), null,
- AuditEvent.DELETE_PROXY_CONNECTOR, auditInformation );
- return Boolean.TRUE;
- }
-
- public Boolean updateProxyConnector( ProxyConnector proxyConnector, AuditInformation auditInformation )
- throws RepositoryAdminException
- {
- Configuration configuration = getArchivaConfiguration().getConfiguration();
- ProxyConnectorConfiguration proxyConnectorConfiguration =
- findProxyConnector( proxyConnector.getSourceRepoId(), proxyConnector.getTargetRepoId(), configuration );
- configuration.removeProxyConnector( proxyConnectorConfiguration );
- configuration.addProxyConnector( getProxyConnectorConfiguration( proxyConnector ) );
- triggerAuditEvent( proxyConnector.getSourceRepoId() + "-" + proxyConnector.getTargetRepoId(), null,
- AuditEvent.MODIFY_PROXY_CONNECTOR, auditInformation );
- return Boolean.TRUE;
- }
-
- protected List<String> unescapePatterns( List<String> patterns )
- {
- List<String> rawPatterns = new ArrayList<String>();
- if ( patterns != null )
- {
- for ( String pattern : patterns )
- {
- rawPatterns.add( StringUtils.replace( pattern, "\\\\", "\\" ) );
- }
- }
-
- return rawPatterns;
- }
-
- public Map<String, List<ProxyConnector>> getProxyConnectorAsMap()
- throws RepositoryAdminException
- {
- Map<String, List<ProxyConnector>> proxyConnectorMap = new HashMap<String, java.util.List<ProxyConnector>>();
-
- Iterator<ProxyConnector> it = getProxyConnectors().iterator();
- while ( it.hasNext() )
- {
- ProxyConnector proxyConfig = it.next();
- String key = proxyConfig.getSourceRepoId();
-
- List<ProxyConnector> connectors = proxyConnectorMap.get( key );
- if ( connectors == null )
- {
- connectors = new ArrayList<ProxyConnector>();
- proxyConnectorMap.put( key, connectors );
- }
-
- connectors.add( proxyConfig );
-
- Collections.sort( connectors, ProxyConnectorOrderComparator.getInstance() );
- }
-
- return proxyConnectorMap;
- }
-
- private ProxyConnectorConfiguration findProxyConnector( String sourceId, String targetId,
- Configuration configuration )
- {
- if ( StringUtils.isBlank( sourceId ) )
- {
- return null;
- }
-
- if ( StringUtils.isBlank( targetId ) )
- {
- return null;
- }
-
- ProxyConnectorSelectionPredicate selectedProxy = new ProxyConnectorSelectionPredicate( sourceId, targetId );
- return (ProxyConnectorConfiguration) CollectionUtils.find( configuration.getProxyConnectors(), selectedProxy );
- }
-
- protected ProxyConnectorConfiguration getProxyConnectorConfiguration( ProxyConnector proxyConnector )
- {
- /*
- ProxyConnectorConfiguration proxyConnectorConfiguration = new ProxyConnectorConfiguration();
- proxyConnectorConfiguration.setOrder( proxyConnector.getOrder() );
- proxyConnectorConfiguration.setBlackListPatterns(
- new ArrayList<String>( proxyConnector.getBlackListPatterns() ) );
- proxyConnectorConfiguration.setWhiteListPatterns(
- new ArrayList<String>( proxyConnector.getWhiteListPatterns() ) );
- proxyConnectorConfiguration.setDisabled( proxyConnector.isDisabled() );
- proxyConnectorConfiguration.setPolicies( new HashMap( proxyConnector.getPolicies() ) );
- proxyConnectorConfiguration.setProperties( new HashMap( proxyConnector.getProperties() ) );
- proxyConnectorConfiguration.setProxyId( proxyConnector.getProxyId() );
- proxyConnectorConfiguration.setSourceRepoId( proxyConnector.getSourceRepoId() );
- proxyConnectorConfiguration.setTargetRepoId( proxyConnector.getTargetRepoId() );
- return proxyConnectorConfiguration;*/
-
- return proxyConnector == null
- ? null
- : new BeanReplicator().replicateBean( proxyConnector, ProxyConnectorConfiguration.class );
- }
-
- protected ProxyConnector getProxyConnector( ProxyConnectorConfiguration proxyConnectorConfiguration )
- {
- return proxyConnectorConfiguration == null
- ? null
- : new BeanReplicator().replicateBean( proxyConnectorConfiguration, ProxyConnector.class );
- }
-
- protected void validateProxyConnector( ProxyConnector proxyConnector )
- throws RepositoryAdminException
- {
- // validate source a Managed target a Remote
- if ( managedRepositoryAdmin.getManagedRepository( proxyConnector.getSourceRepoId() ) == null )
- {
- throw new RepositoryAdminException(
- "non valid ProxyConnector sourceRepo with id " + proxyConnector.getSourceRepoId()
- + " is not a ManagedRepository" );
- }
- if ( remoteRepositoryAdmin.getRemoteRepository( proxyConnector.getTargetRepoId() ) == null )
- {
- throw new RepositoryAdminException(
- "non valid ProxyConnector sourceRepo with id " + proxyConnector.getTargetRepoId()
- + " is not a RemoteRepository" );
- }
-
- // FIXME validate NetworkProxyConfiguration too when available
- }
-}
+++ /dev/null
-package org.apache.archiva.admin.repository.proxyconnector;
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.archiva.admin.repository.AbstractRepositoryConnector;
-
-import java.io.Serializable;
-
-/**
- * @author Olivier Lamy
- * @since 1.4
- */
-public class ProxyConnector
- extends AbstractRepositoryConnector
- implements Serializable
-{
- /**
- * The order id for UNORDERED
- */
- public static final int UNORDERED = 0;
-
- /**
- * The policy key {@link #getPolicies()} for error handling.
- * See {@link org.apache.maven.archiva.policies.DownloadErrorPolicy}
- * for details on potential values to this policy key.
- */
- public static final String POLICY_PROPAGATE_ERRORS = "propagate-errors";
-
- /**
- * The policy key {@link #getPolicies()} for error handling when an artifact is present.
- * See {@link org.apache.maven.archiva.policies.DownloadErrorPolicy}
- * for details on potential values to this policy key.
- */
- public static final String POLICY_PROPAGATE_ERRORS_ON_UPDATE = "propagate-errors-on-update";
-
- /**
- * The policy key {@link #getPolicies()} for snapshot handling.
- * See {@link org.apache.maven.archiva.policies.SnapshotsPolicy}
- * for details on potential values to this policy key.
- */
- public static final String POLICY_SNAPSHOTS = "snapshots";
-
- /**
- * The policy key {@link #getPolicies()} for releases handling.
- * See {@link org.apache.maven.archiva.policies.ReleasesPolicy}
- * for details on potential values to this policy key.
- */
- public static final String POLICY_RELEASES = "releases";
-
- /**
- * The policy key {@link #getPolicies()} for checksum handling.
- * See {@link org.apache.maven.archiva.policies.ChecksumPolicy}
- * for details on potential values to this policy key.
- */
- public static final String POLICY_CHECKSUM = "checksum";
-
- /**
- * The policy key {@link #getPolicies()} for cache-failures handling.
- * See {@link org.apache.maven.archiva.policies.CachedFailuresPolicy}
- * for details on potential values to this policy key.
- */
- public static final String POLICY_CACHE_FAILURES = "cache-failures";
-
- /**
- *
- * The order of the proxy connectors. (0 means no order specified)
- * .
- */
- private int order = 0;
-
- /**
- * Get the order of the proxy connectors. (0 means no order specified)
- * @return int
- */
- public int getOrder()
- {
- return this.order;
- }
-
-
- /**
- * Set the order of the proxy connectors. (0 means no order specified)
- * @param order
- */
- public void setOrder( int order )
- {
- this.order = order;
- }
-
- @Override
- public String toString()
- {
- final StringBuilder sb = new StringBuilder();
- sb.append( "ProxyConnector" );
- sb.append( "{order=" ).append( order );
- sb.append( '}' );
- sb.append( super.toString() );
- return sb.toString();
- }
-}
+++ /dev/null
-package org.apache.archiva.admin.repository.proxyconnector;
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.archiva.admin.AuditInformation;
-import org.apache.archiva.admin.repository.RepositoryAdminException;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * <b>No update method for changing source and target here as id is : sourceRepoId and targetRepoId, use delete then add.</b>
- *
- * @author Olivier Lamy
- * @since 1.4
- */
-public interface ProxyConnectorAdmin
-{
- List<ProxyConnector> getProxyConnectors()
- throws RepositoryAdminException;
-
- ProxyConnector getProxyConnector( String sourceRepoId, String targetRepoId )
- throws RepositoryAdminException;
-
- Boolean addProxyConnector( ProxyConnector proxyConnector, AuditInformation auditInformation )
- throws RepositoryAdminException;
-
- Boolean deleteProxyConnector( ProxyConnector proxyConnector, AuditInformation auditInformation )
- throws RepositoryAdminException;
-
- /**
- * <b>only for enabled/disable or changing bean values except target/source</b>
- * @param proxyConnector
- * @param auditInformation
- * @return
- * @throws RepositoryAdminException
- */
- Boolean updateProxyConnector( ProxyConnector proxyConnector, AuditInformation auditInformation )
- throws RepositoryAdminException;
-
-
- Map<String, List<ProxyConnector>> getProxyConnectorAsMap()
- throws RepositoryAdminException;
-
-}
+++ /dev/null
-package org.apache.archiva.admin.repository.proxyconnector;
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.Comparator;
-
-/**
- * @author Olivier Lamy
- * @since 1.4
- */
-public class ProxyConnectorOrderComparator
- implements Comparator<ProxyConnector>
-{
- private static ProxyConnectorOrderComparator INSTANCE = new ProxyConnectorOrderComparator();
-
- public int compare( ProxyConnector o1, ProxyConnector o2 )
- {
- if ( o1 == null && o2 == null )
- {
- return 0;
- }
-
- // Ensure null goes to end of list.
- if ( o1 == null && o2 != null )
- {
- return 1;
- }
-
- if ( o1 != null && o2 == null )
- {
- return -1;
- }
-
- // Ensure 0 (unordered) goes to end of list.
- if ( o1.getOrder() == 0 && o2.getOrder() != 0 )
- {
- return 1;
- }
-
- if ( o1.getOrder() != 0 && o2.getOrder() == 0 )
- {
- return -1;
- }
-
- return o1.getOrder() - o2.getOrder();
- }
-
- public static ProxyConnectorOrderComparator getInstance()
- {
- return INSTANCE;
- }
-}
+++ /dev/null
-package org.apache.archiva.admin.repository.proxyconnector;
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.commons.collections.Predicate;
-import org.apache.commons.lang.StringUtils;
-
-/**
- * @author Olivier Lamy
- * @since 1.4
- */
-public class ProxyConnectorSelectionPredicate
- implements Predicate
-{
- private String sourceId;
-
- private String targetId;
-
- public ProxyConnectorSelectionPredicate( String sourceId, String targetId )
- {
- this.sourceId = sourceId;
- this.targetId = targetId;
- }
-
- public boolean evaluate( Object object )
- {
- boolean satisfies = false;
-
- if ( object instanceof ProxyConnector )
- {
- ProxyConnector connector = (ProxyConnector) object;
- return ( StringUtils.equals( sourceId, connector.getSourceRepoId() ) && StringUtils.equals( targetId,
- connector.getTargetRepoId() ) );
- }
-
- return satisfies;
- }
-}
+++ /dev/null
-package org.apache.archiva.admin.repository.remote;
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.archiva.admin.AuditInformation;
-import org.apache.archiva.admin.repository.AbstractRepositoryAdmin;
-import org.apache.archiva.admin.repository.RepositoryAdminException;
-import org.apache.archiva.audit.AuditEvent;
-import org.apache.commons.lang.StringUtils;
-import org.apache.maven.archiva.configuration.Configuration;
-import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration;
-import org.apache.maven.archiva.configuration.RemoteRepositoryConfiguration;
-import org.springframework.stereotype.Service;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author Olivier Lamy
- * @since 1.4
- */
-@Service( "remoteRepositoryAdmin#default" )
-public class DefaultRemoteRepositoryAdmin
- extends AbstractRepositoryAdmin
- implements RemoteRepositoryAdmin
-{
-
-
- public List<RemoteRepository> getRemoteRepositories()
- throws RepositoryAdminException
- {
- List<RemoteRepository> remoteRepositories = new ArrayList<RemoteRepository>();
- for ( RemoteRepositoryConfiguration repositoryConfiguration : getArchivaConfiguration().getConfiguration().getRemoteRepositories() )
- {
- remoteRepositories.add(
- new RemoteRepository( repositoryConfiguration.getId(), repositoryConfiguration.getName(),
- repositoryConfiguration.getUrl(), repositoryConfiguration.getLayout(),
- repositoryConfiguration.getUsername(), repositoryConfiguration.getPassword(),
- repositoryConfiguration.getTimeout() ) );
- }
- return remoteRepositories;
- }
-
- public RemoteRepository getRemoteRepository( String repositoryId )
- throws RepositoryAdminException
- {
- for ( RemoteRepository remoteRepository : getRemoteRepositories() )
- {
- if ( StringUtils.equals( repositoryId, remoteRepository.getId() ) )
- {
- return remoteRepository;
- }
- }
- return null;
- }
-
- public Boolean addRemoteRepository( RemoteRepository remoteRepository, AuditInformation auditInformation )
- throws RepositoryAdminException
- {
- triggerAuditEvent( remoteRepository.getId(), null, AuditEvent.ADD_REMOTE_REPO, auditInformation );
- getRepositoryCommonValidator().basicValidation( remoteRepository, false );
-
- //TODO we can validate it's a good uri/url
- if ( StringUtils.isEmpty( remoteRepository.getUrl() ) )
- {
- throw new RepositoryAdminException( "url cannot be null" );
- }
-
- //MRM-752 - url needs trimming
- remoteRepository.setUrl( StringUtils.trim( remoteRepository.getUrl() ) );
-
- RemoteRepositoryConfiguration remoteRepositoryConfiguration =
- getRemoteRepositoryConfiguration( remoteRepository );
-
- Configuration configuration = getArchivaConfiguration().getConfiguration();
- configuration.addRemoteRepository( remoteRepositoryConfiguration );
- saveConfiguration( configuration );
-
- return Boolean.TRUE;
- }
-
- public Boolean deleteRemoteRepository( String repositoryId, AuditInformation auditInformation )
- throws RepositoryAdminException
- {
-
- triggerAuditEvent( repositoryId, null, AuditEvent.DELETE_REMOTE_REPO, auditInformation );
-
- Configuration configuration = getArchivaConfiguration().getConfiguration();
-
- RemoteRepositoryConfiguration remoteRepositoryConfiguration =
- configuration.getRemoteRepositoriesAsMap().get( repositoryId );
- if ( remoteRepositoryConfiguration == null )
- {
- throw new RepositoryAdminException(
- "remoteRepository with id " + repositoryId + " not exist cannot remove it" );
- }
-
- configuration.removeRemoteRepository( remoteRepositoryConfiguration );
-
- // TODO use ProxyConnectorAdmin interface ?
- // [MRM-520] Proxy Connectors are not deleted with the deletion of a Repository.
- List<ProxyConnectorConfiguration> proxyConnectors =
- new ArrayList<ProxyConnectorConfiguration>( configuration.getProxyConnectors() );
- for ( ProxyConnectorConfiguration proxyConnector : proxyConnectors )
- {
- if ( StringUtils.equals( proxyConnector.getTargetRepoId(), repositoryId ) )
- {
- configuration.removeProxyConnector( proxyConnector );
- }
- }
-
- saveConfiguration( configuration );
-
- return Boolean.TRUE;
- }
-
- public Boolean updateRemoteRepository( RemoteRepository remoteRepository, AuditInformation auditInformation )
- throws RepositoryAdminException
- {
-
- String repositoryId = remoteRepository.getId();
-
- triggerAuditEvent( repositoryId, null, AuditEvent.MODIFY_REMOTE_REPO, auditInformation );
-
- // update means : remove and add
-
- Configuration configuration = getArchivaConfiguration().getConfiguration();
-
- RemoteRepositoryConfiguration remoteRepositoryConfiguration =
- configuration.getRemoteRepositoriesAsMap().get( repositoryId );
- if ( remoteRepositoryConfiguration == null )
- {
- throw new RepositoryAdminException(
- "remoteRepository with id " + repositoryId + " not exist cannot remove it" );
- }
-
- configuration.removeRemoteRepository( remoteRepositoryConfiguration );
-
- remoteRepositoryConfiguration = getRemoteRepositoryConfiguration( remoteRepository );
- configuration.addRemoteRepository( remoteRepositoryConfiguration );
- saveConfiguration( configuration );
-
- return Boolean.TRUE;
- }
-
- public Map<String, RemoteRepository> getRemoteRepositoriesAsMap()
- throws RepositoryAdminException
- {
- java.util.Map<String, RemoteRepository> map = new HashMap<String, RemoteRepository>();
-
- for ( RemoteRepository repo : getRemoteRepositories() )
- {
- map.put( repo.getId(), repo );
- }
-
- return map;
- }
-
- private RemoteRepositoryConfiguration getRemoteRepositoryConfiguration( RemoteRepository remoteRepository )
- {
- RemoteRepositoryConfiguration remoteRepositoryConfiguration = new RemoteRepositoryConfiguration();
- remoteRepositoryConfiguration.setId( remoteRepository.getId() );
- remoteRepositoryConfiguration.setPassword( remoteRepository.getPassword() );
- remoteRepositoryConfiguration.setTimeout( remoteRepository.getTimeout() );
- remoteRepositoryConfiguration.setUrl( remoteRepository.getUrl() );
- remoteRepositoryConfiguration.setUsername( remoteRepository.getUserName() );
- remoteRepositoryConfiguration.setLayout( remoteRepository.getLayout() );
- remoteRepositoryConfiguration.setName( remoteRepository.getName() );
- return remoteRepositoryConfiguration;
- }
-
-}
+++ /dev/null
-package org.apache.archiva.admin.repository.remote;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.archiva.admin.repository.AbstractRepository;
-
-import java.io.Serializable;
-
-/**
- * @author Olivier Lamy
- * @since 1.4
- */
-public class RemoteRepository
- extends AbstractRepository
- implements Serializable
-{
-
- private String url;
-
- private String userName;
-
- private String password;
-
- private int timeout = 60;
-
- public RemoteRepository()
- {
- // no op
- }
-
- public RemoteRepository( String id, String name, String url, String layout )
- {
- super( id, name, layout );
- this.url = url;
- }
-
- public RemoteRepository( String id, String name, String url, String layout, String userName, String password,
- int timeOut )
- {
- super( id, name, layout );
- this.url = url;
- this.userName = userName;
- this.password = password;
- this.timeout = timeOut;
- }
-
- public String getUrl()
- {
- return url;
- }
-
- public void setUrl( String url )
- {
- this.url = url;
- }
-
- public String getUserName()
- {
- return userName;
- }
-
- public void setUserName( String userName )
- {
- this.userName = userName;
- }
-
- public String getPassword()
- {
- return password;
- }
-
- public void setPassword( String password )
- {
- this.password = password;
- }
-
- public int getTimeout()
- {
- return timeout;
- }
-
- public void setTimeout( int timeout )
- {
- this.timeout = timeout;
- }
-
- @Override
- public String toString()
- {
- final StringBuilder sb = new StringBuilder();
- sb.append( "RemoteRepository" );
- sb.append( "{url='" ).append( url ).append( '\'' );
- sb.append( ", userName='" ).append( userName ).append( '\'' );
- sb.append( ", password='" ).append( password ).append( '\'' );
- sb.append( ", timeout=" ).append( timeout );
- sb.append( '}' );
- sb.append( super.toString() );
- return sb.toString();
- }
-
-
-}
\ No newline at end of file
+++ /dev/null
-package org.apache.archiva.admin.repository.remote;
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-import org.apache.archiva.admin.AuditInformation;
-import org.apache.archiva.admin.repository.RepositoryAdminException;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author Olivier Lamy
- * @since 1.4
- */
-public interface RemoteRepositoryAdmin
-{
- List<RemoteRepository> getRemoteRepositories()
- throws RepositoryAdminException;
-
- RemoteRepository getRemoteRepository( String repositoryId )
- throws RepositoryAdminException;
-
- Boolean deleteRemoteRepository( String repositoryId, AuditInformation auditInformation )
- throws RepositoryAdminException;
-
- Boolean addRemoteRepository( RemoteRepository remoteRepository, AuditInformation auditInformation )
- throws RepositoryAdminException;
-
- Boolean updateRemoteRepository( RemoteRepository remoteRepository, AuditInformation auditInformation )
- throws RepositoryAdminException;
-
- Map<String, RemoteRepository> getRemoteRepositoriesAsMap()
- throws RepositoryAdminException;
-}
+++ /dev/null
-package org.apache.archiva.admin.repository.utils;
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.archiva.admin.repository.AbstractRepository;
-
-import java.util.Comparator;
-
-/**
- * @author Olivier Lamy
- * @since 1.4
- */
-public class RepositoryComparator
- implements Comparator<AbstractRepository>
-{
- public int compare( AbstractRepository o1, AbstractRepository o2 )
- {
- if ( o1 == null && o2 == null )
- {
- return 0;
- }
-
- if ( o1 == null )
- {
- return -1;
- }
-
- if ( o2 == null )
- {
- return 1;
- }
-
- return o1.getId().compareToIgnoreCase( o2.getId() );
- }
-}
+++ /dev/null
-<?xml version="1.0"?>
-
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing,
- ~ software distributed under the License is distributed on an
- ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- ~ KIND, either express or implied. See the License for the
- ~ specific language governing permissions and limitations
- ~ under the License.
- -->
-<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-3.0.xsd
- http://www.springframework.org/schema/context
- http://www.springframework.org/schema/context/spring-context-3.0.xsd" default-lazy-init="true">
-
-
- <context:annotation-config />
- <context:component-scan
- base-package="org.apache.archiva.admin.repository"/>
-
-
-
-</beans>
\ No newline at end of file
+++ /dev/null
-package org.apache.archiva.admin.mock;
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.archiva.audit.AuditEvent;
-import org.apache.archiva.audit.AuditListener;
-import org.springframework.stereotype.Service;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author Olivier Lamy
- */
-@Service( "auditListener#mock" )
-public class MockAuditListener
- implements AuditListener
-{
-
- private List<AuditEvent> auditEvents = new ArrayList<AuditEvent>();
-
- public void auditEvent( AuditEvent event )
- {
- auditEvents.add( event );
- }
-
- public List<AuditEvent> getAuditEvents()
- {
- return auditEvents;
- }
-
- public void clearEvents()
- {
- auditEvents.clear();
- }
-}
+++ /dev/null
-package org.apache.archiva.admin.repository;
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import junit.framework.TestCase;
-import org.apache.archiva.admin.AuditInformation;
-import org.apache.archiva.admin.mock.MockAuditListener;
-import org.apache.archiva.admin.repository.managed.ManagedRepository;
-import org.apache.archiva.admin.repository.managed.ManagedRepositoryAdmin;
-import org.apache.archiva.admin.repository.proxyconnector.ProxyConnectorAdmin;
-import org.apache.archiva.admin.repository.remote.RemoteRepository;
-import org.apache.archiva.admin.repository.remote.RemoteRepositoryAdmin;
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.lang.StringUtils;
-import org.codehaus.plexus.redback.role.RoleManager;
-import org.codehaus.plexus.redback.users.User;
-import org.codehaus.plexus.redback.users.memory.SimpleUser;
-import org.junit.runner.RunWith;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-import javax.inject.Inject;
-import java.io.File;
-import java.util.List;
-
-/**
- * @author Olivier Lamy
- */
-@RunWith( SpringJUnit4ClassRunner.class )
-@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml" } )
-public abstract class AbstractRepositoryAdminTest
- extends TestCase
-{
- protected Logger log = LoggerFactory.getLogger( getClass() );
-
- public static final String APPSERVER_BASE_PATH = System.getProperty( "appserver.base" );
-
- @Inject
- protected MockAuditListener mockAuditListener;
-
- @Inject
- protected RoleManager roleManager;
-
- @Inject
- protected RemoteRepositoryAdmin remoteRepositoryAdmin;
-
- @Inject
- protected ManagedRepositoryAdmin managedRepositoryAdmin;
-
- @Inject
- protected ProxyConnectorAdmin proxyConnectorAdmin;
-
- protected AuditInformation getFakeAuditInformation()
- {
- AuditInformation auditInformation = new AuditInformation( getFakeUser(), "archiva-localhost" );
- return auditInformation;
- }
-
- protected User getFakeUser()
- {
- SimpleUser user = new SimpleUser()
- {
- @Override
- public Object getPrincipal()
- {
- return "root";
- }
-
- };
-
- user.setUsername( "root" );
- user.setFullName( "The top user" );
- return user;
- }
-
- protected ManagedRepository getTestManagedRepository( String repoId, String repoLocation )
- {
- return new ManagedRepository( repoId, "test repo", repoLocation, "default", false, true, true, "0 0 * * * ?",
- repoLocation + "/.index", false, 1, 2, true );
- }
-
- protected File clearRepoLocation( String path )
- throws Exception
- {
- File repoDir = new File( path );
- if ( repoDir.exists() )
- {
- FileUtils.deleteDirectory( repoDir );
- }
- assertFalse( repoDir.exists() );
- return repoDir;
- }
-
- protected ManagedRepository findManagedRepoById( List<ManagedRepository> repos, String id )
- {
- for ( ManagedRepository repo : repos )
- {
- if ( StringUtils.equals( id, repo.getId() ) )
- {
- return repo;
- }
- }
- return null;
- }
-
- protected RemoteRepository getRemoteRepository()
- {
- return getRemoteRepository( "foo" );
- }
-
- protected RemoteRepository getRemoteRepository(String id)
- {
- RemoteRepository remoteRepository = new RemoteRepository();
- remoteRepository.setUrl( "http://foo.com/maven-it-rocks" );
- remoteRepository.setTimeout( 10 );
- remoteRepository.setName( "maven foo" );
- remoteRepository.setUserName( "foo-name" );
- remoteRepository.setPassword( "toto" );
- remoteRepository.setId( id );
- return remoteRepository;
- }
-}
+++ /dev/null
-package org.apache.archiva.admin.repository.admin;
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.archiva.admin.repository.AbstractRepositoryAdminTest;
-import org.apache.archiva.admin.repository.RepositoryAdminException;
-import org.apache.archiva.audit.AuditEvent;
-import org.junit.Test;
-
-import javax.inject.Inject;
-import java.util.Arrays;
-
-/**
- * @author Olivier Lamy
- */
-public class ArchivaAdministrationTest
- extends AbstractRepositoryAdminTest
-{
- @Inject
- ArchivaAdministration archivaAdministration;
-
-
- @Test
- public void getAllLegacyPaths()
- throws Exception
- {
- assertNotNull( archivaAdministration.getLegacyArtifactPaths() );
- assertFalse( archivaAdministration.getLegacyArtifactPaths().isEmpty() );
- assertEquals( 1, archivaAdministration.getLegacyArtifactPaths().size() );
- log.info( "all legacy paths {}", archivaAdministration.getLegacyArtifactPaths() );
- }
-
- public void addAndDeleteLegacyPath()
- throws Exception
- {
- int initialSize = archivaAdministration.getLegacyArtifactPaths().size();
-
- LegacyArtifactPath legacyArtifactPath = new LegacyArtifactPath( "foo", "bar" );
- archivaAdministration.addLegacyArtifactPath( legacyArtifactPath, getFakeAuditInformation() );
-
- assertTrue( archivaAdministration.getLegacyArtifactPaths().contains( new LegacyArtifactPath( "foo", "bar" ) ) );
- assertEquals( initialSize + 1, archivaAdministration.getLegacyArtifactPaths().size() );
-
- archivaAdministration.deleteLegacyArtifactPath( legacyArtifactPath.getPath(), getFakeAuditInformation() );
-
- assertFalse(
- archivaAdministration.getLegacyArtifactPaths().contains( new LegacyArtifactPath( "foo", "bar" ) ) );
- assertEquals( initialSize, archivaAdministration.getLegacyArtifactPaths().size() );
- mockAuditListener.clearEvents();
- }
-
- @Test
- public void addAndUpdateAndDeleteFileType()
- throws RepositoryAdminException
- {
- int initialSize = archivaAdministration.getFileTypes().size();
-
- FileType fileType = new FileType();
- fileType.setId( "foo" );
- fileType.setPatterns( Arrays.asList( "bar", "toto" ) );
-
- archivaAdministration.addFileType( fileType, getFakeAuditInformation() );
-
- assertEquals( initialSize + 1, archivaAdministration.getFileTypes().size() );
-
- archivaAdministration.addFileTypePattern( "foo", "zorro", getFakeAuditInformation() );
-
- assertEquals( initialSize + 1, archivaAdministration.getFileTypes().size() );
-
- assertEquals( 3, archivaAdministration.getFileType( "foo" ).getPatterns().size() );
-
- assertTrue( archivaAdministration.getFileType( "foo" ).getPatterns().contains( "bar" ) );
- assertTrue( archivaAdministration.getFileType( "foo" ).getPatterns().contains( "toto" ) );
- assertTrue( archivaAdministration.getFileType( "foo" ).getPatterns().contains( "zorro" ) );
-
- archivaAdministration.removeFileTypePattern( "foo", "zorro", getFakeAuditInformation() );
-
- assertEquals( initialSize + 1, archivaAdministration.getFileTypes().size() );
-
- assertEquals( 2, archivaAdministration.getFileType( "foo" ).getPatterns().size() );
-
- assertTrue( archivaAdministration.getFileType( "foo" ).getPatterns().contains( "bar" ) );
- assertTrue( archivaAdministration.getFileType( "foo" ).getPatterns().contains( "toto" ) );
- assertFalse( archivaAdministration.getFileType( "foo" ).getPatterns().contains( "zorro" ) );
-
- archivaAdministration.removeFileType( "foo", getFakeAuditInformation() );
-
- assertEquals( initialSize, archivaAdministration.getFileTypes().size() );
- assertNull( archivaAdministration.getFileType( "foo" ) );
- mockAuditListener.clearEvents();
- }
-
- @Test
- public void knownContentConsumersTest()
- throws Exception
- {
- int initialSize = archivaAdministration.getKnownContentConsumers().size();
-
- archivaAdministration.addKnownContentConsumer( "foo", getFakeAuditInformation() );
-
- assertEquals( initialSize + 1, archivaAdministration.getKnownContentConsumers().size() );
- assertTrue( archivaAdministration.getKnownContentConsumers().contains( "foo" ) );
-
- // ensure we don't add it twice as it's an ArrayList as storage
- archivaAdministration.addKnownContentConsumer( "foo", getFakeAuditInformation() );
-
- assertEquals( initialSize + 1, archivaAdministration.getKnownContentConsumers().size() );
- assertTrue( archivaAdministration.getKnownContentConsumers().contains( "foo" ) );
-
- archivaAdministration.removeKnownContentConsumer( "foo", getFakeAuditInformation() );
-
- assertEquals( initialSize, archivaAdministration.getKnownContentConsumers().size() );
- assertFalse( archivaAdministration.getKnownContentConsumers().contains( "foo" ) );
-
- assertEquals( 2, mockAuditListener.getAuditEvents().size() );
- assertEquals( AuditEvent.ENABLE_REPO_CONSUMER, mockAuditListener.getAuditEvents().get( 0 ).getAction() );
- assertEquals( AuditEvent.DISABLE_REPO_CONSUMER, mockAuditListener.getAuditEvents().get( 1 ).getAction() );
-
- mockAuditListener.clearEvents();
-
- }
-
- @Test
- public void invalidContentConsumersTest()
- throws Exception
- {
- int initialSize = archivaAdministration.getInvalidContentConsumers().size();
-
- archivaAdministration.addInvalidContentConsumer( "foo", getFakeAuditInformation() );
-
- assertEquals( initialSize + 1, archivaAdministration.getInvalidContentConsumers().size() );
- assertTrue( archivaAdministration.getInvalidContentConsumers().contains( "foo" ) );
-
- // ensure we don't add it twice as it's an ArrayList as storage
- archivaAdministration.addInvalidContentConsumer( "foo", getFakeAuditInformation() );
-
- assertEquals( initialSize + 1, archivaAdministration.getInvalidContentConsumers().size() );
- assertTrue( archivaAdministration.getInvalidContentConsumers().contains( "foo" ) );
-
- archivaAdministration.removeInvalidContentConsumer( "foo", getFakeAuditInformation() );
-
- assertEquals( initialSize, archivaAdministration.getInvalidContentConsumers().size() );
- assertFalse( archivaAdministration.getInvalidContentConsumers().contains( "foo" ) );
-
- assertEquals( 2, mockAuditListener.getAuditEvents().size() );
- assertEquals( AuditEvent.ENABLE_REPO_CONSUMER, mockAuditListener.getAuditEvents().get( 0 ).getAction() );
- assertEquals( AuditEvent.DISABLE_REPO_CONSUMER, mockAuditListener.getAuditEvents().get( 1 ).getAction() );
-
- mockAuditListener.clearEvents();
-
- }
-
-
- public void organisationInfoUpdate()
- throws Exception
- {
- OrganisationInformation organisationInformation = archivaAdministration.getOrganisationInformation();
- assertNull( organisationInformation );
-
- organisationInformation = new OrganisationInformation();
- organisationInformation.setLogoLocation( "http://foo.com/bar.png" );
- organisationInformation.setName( "foo org" );
- organisationInformation.setUrl( "http:/foo.com" );
-
- archivaAdministration.setOrganisationInformation( organisationInformation );
-
- organisationInformation = archivaAdministration.getOrganisationInformation();
- assertNotNull( organisationInformation );
- assertEquals( "http://foo.com/bar.png", organisationInformation.getLogoLocation() );
- assertEquals( "foo org", organisationInformation.getName() );
- assertEquals( "http://foo.com", organisationInformation.getUrl() );
-
- }
-}
+++ /dev/null
-package org.apache.archiva.admin.repository.group;
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.archiva.admin.repository.AbstractRepositoryAdminTest;
-import org.apache.archiva.admin.repository.managed.ManagedRepository;
-import org.apache.archiva.audit.AuditEvent;
-import org.junit.Test;
-
-import javax.inject.Inject;
-import java.io.File;
-import java.util.Arrays;
-
-/**
- * @author Olivier Lamy
- */
-public class RepositoryGroupAdminTest
- extends AbstractRepositoryAdminTest
-{
- @Inject
- RepositoryGroupAdmin repositoryGroupAdmin;
-
- @Test
- public void addAndDeleteGroup()
- throws Exception
- {
- try
- {
- ManagedRepository managedRepositoryOne =
- getTestManagedRepository( "test-new-one", APPSERVER_BASE_PATH + File.separator + "test-new-one" );
-
- ManagedRepository managedRepositoryTwo =
- getTestManagedRepository( "test-new-two", APPSERVER_BASE_PATH + File.separator + "test-new-two" );
-
- managedRepositoryAdmin.addManagedRepository( managedRepositoryOne, false, getFakeAuditInformation() );
-
- managedRepositoryAdmin.addManagedRepository( managedRepositoryTwo, false, getFakeAuditInformation() );
-
- RepositoryGroup repositoryGroup =
- new RepositoryGroup( "repo-group-one", Arrays.asList( "test-new-one", "test-new-two" ) );
-
- mockAuditListener.clearEvents();
-
- repositoryGroupAdmin.addRepositoryGroup( repositoryGroup, getFakeAuditInformation() );
-
- assertEquals( 1, repositoryGroupAdmin.getRepositoriesGroups().size() );
- assertEquals( "repo-group-one", repositoryGroupAdmin.getRepositoriesGroups().get( 0 ).getId() );
- assertEquals( 2, repositoryGroupAdmin.getRepositoriesGroups().get( 0 ).getRepositories().size() );
- assertEquals( Arrays.asList( "test-new-one", "test-new-two" ),
- repositoryGroupAdmin.getRepositoriesGroups().get( 0 ).getRepositories() );
-
- repositoryGroupAdmin.deleteRepositoryGroup( "repo-group-one", getFakeAuditInformation() );
-
- assertEquals( 0, repositoryGroupAdmin.getRepositoriesGroups().size() );
-
- assertEquals( 2, mockAuditListener.getAuditEvents().size() );
-
- assertEquals( AuditEvent.ADD_REPO_GROUP, mockAuditListener.getAuditEvents().get( 0 ).getAction() );
- assertEquals( AuditEvent.DELETE_REPO_GROUP, mockAuditListener.getAuditEvents().get( 1 ).getAction() );
- }
- finally
- {
- mockAuditListener.clearEvents();
- managedRepositoryAdmin.deleteManagedRepository( "test-new-one", getFakeAuditInformation(), true );
- managedRepositoryAdmin.deleteManagedRepository( "test-new-two", getFakeAuditInformation(), true );
- }
- }
-
- @Test
- public void addAndUpdateAndDeleteGroup()
- throws Exception
- {
- try
- {
- ManagedRepository managedRepositoryOne =
- getTestManagedRepository( "test-new-one", APPSERVER_BASE_PATH + File.separator + "test-new-one" );
-
- ManagedRepository managedRepositoryTwo =
- getTestManagedRepository( "test-new-two", APPSERVER_BASE_PATH + File.separator + "test-new-two" );
-
- managedRepositoryAdmin.addManagedRepository( managedRepositoryOne, false, getFakeAuditInformation() );
-
- managedRepositoryAdmin.addManagedRepository( managedRepositoryTwo, false, getFakeAuditInformation() );
-
- RepositoryGroup repositoryGroup = new RepositoryGroup( "repo-group-one", Arrays.asList( "test-new-one" ) );
-
- mockAuditListener.clearEvents();
-
- repositoryGroupAdmin.addRepositoryGroup( repositoryGroup, getFakeAuditInformation() );
-
- assertEquals( 1, repositoryGroupAdmin.getRepositoriesGroups().size() );
- assertEquals( "repo-group-one", repositoryGroupAdmin.getRepositoriesGroups().get( 0 ).getId() );
- assertEquals( 1, repositoryGroupAdmin.getRepositoriesGroups().get( 0 ).getRepositories().size() );
- assertEquals( Arrays.asList( "test-new-one" ),
- repositoryGroupAdmin.getRepositoriesGroups().get( 0 ).getRepositories() );
-
- repositoryGroup = repositoryGroupAdmin.getRepositoryGroup( "repo-group-one" );
- assertNotNull( repositoryGroup );
-
- repositoryGroup.addRepository( managedRepositoryTwo.getId() );
-
- repositoryGroupAdmin.updateRepositoryGroup( repositoryGroup, getFakeAuditInformation() );
-
- assertEquals( 1, repositoryGroupAdmin.getRepositoriesGroups().size() );
- assertEquals( "repo-group-one", repositoryGroupAdmin.getRepositoriesGroups().get( 0 ).getId() );
- assertEquals( 2, repositoryGroupAdmin.getRepositoriesGroups().get( 0 ).getRepositories().size() );
- assertEquals( Arrays.asList( "test-new-one", "test-new-two" ),
- repositoryGroupAdmin.getRepositoriesGroups().get( 0 ).getRepositories() );
-
- repositoryGroupAdmin.deleteRepositoryGroup( "repo-group-one", getFakeAuditInformation() );
-
- assertEquals( 0, repositoryGroupAdmin.getRepositoriesGroups().size() );
-
- assertEquals( 3, mockAuditListener.getAuditEvents().size() );
-
- assertEquals( AuditEvent.ADD_REPO_GROUP, mockAuditListener.getAuditEvents().get( 0 ).getAction() );
- assertEquals( AuditEvent.MODIFY_REPO_GROUP, mockAuditListener.getAuditEvents().get( 1 ).getAction() );
- assertEquals( AuditEvent.DELETE_REPO_GROUP, mockAuditListener.getAuditEvents().get( 2 ).getAction() );
- }
- finally
- {
- mockAuditListener.clearEvents();
- managedRepositoryAdmin.deleteManagedRepository( "test-new-one", getFakeAuditInformation(), true );
- managedRepositoryAdmin.deleteManagedRepository( "test-new-two", getFakeAuditInformation(), true );
- }
- }
-
-
- @Test
- public void addAndDeleteGroupWithRemowingManagedRepo()
- throws Exception
- {
- try
- {
- ManagedRepository managedRepositoryOne =
- getTestManagedRepository( "test-new-one", APPSERVER_BASE_PATH + File.separator + "test-new-one" );
-
- ManagedRepository managedRepositoryTwo =
- getTestManagedRepository( "test-new-two", APPSERVER_BASE_PATH + File.separator + "test-new-two" );
-
- managedRepositoryAdmin.addManagedRepository( managedRepositoryOne, false, getFakeAuditInformation() );
-
- managedRepositoryAdmin.addManagedRepository( managedRepositoryTwo, false, getFakeAuditInformation() );
-
- RepositoryGroup repositoryGroup =
- new RepositoryGroup( "repo-group-one", Arrays.asList( "test-new-one", "test-new-two" ) );
-
- mockAuditListener.clearEvents();
-
- repositoryGroupAdmin.addRepositoryGroup( repositoryGroup, getFakeAuditInformation() );
-
- assertEquals( 1, repositoryGroupAdmin.getRepositoriesGroups().size() );
- assertEquals( "repo-group-one", repositoryGroupAdmin.getRepositoriesGroups().get( 0 ).getId() );
- assertEquals( 2, repositoryGroupAdmin.getRepositoriesGroups().get( 0 ).getRepositories().size() );
- assertEquals( Arrays.asList( "test-new-one", "test-new-two" ),
- repositoryGroupAdmin.getRepositoriesGroups().get( 0 ).getRepositories() );
-
- // deleting a managed repo to validate repogroup correctly updated !
- managedRepositoryAdmin.deleteManagedRepository( "test-new-one", getFakeAuditInformation(), true );
-
- assertEquals( 1, repositoryGroupAdmin.getRepositoriesGroups().size() );
- assertEquals( "repo-group-one", repositoryGroupAdmin.getRepositoriesGroups().get( 0 ).getId() );
- assertEquals( 1, repositoryGroupAdmin.getRepositoriesGroups().get( 0 ).getRepositories().size() );
- assertEquals( Arrays.asList( "test-new-two" ),
- repositoryGroupAdmin.getRepositoriesGroups().get( 0 ).getRepositories() );
-
- repositoryGroupAdmin.deleteRepositoryGroup( "repo-group-one", getFakeAuditInformation() );
-
- assertEquals( 0, repositoryGroupAdmin.getRepositoriesGroups().size() );
-
- assertEquals( 3, mockAuditListener.getAuditEvents().size() );
-
- assertEquals( AuditEvent.ADD_REPO_GROUP, mockAuditListener.getAuditEvents().get( 0 ).getAction() );
- assertEquals( AuditEvent.DELETE_MANAGED_REPO, mockAuditListener.getAuditEvents().get( 1 ).getAction() );
- assertEquals( AuditEvent.DELETE_REPO_GROUP, mockAuditListener.getAuditEvents().get( 2 ).getAction() );
- }
- finally
- {
- mockAuditListener.clearEvents();
-
- managedRepositoryAdmin.deleteManagedRepository( "test-new-two", getFakeAuditInformation(), true );
- }
- }
-}
+++ /dev/null
-package org.apache.archiva.admin.repository.managed;
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.archiva.admin.repository.AbstractRepositoryAdminTest;
-import org.apache.archiva.audit.AuditEvent;
-import org.apache.archiva.security.common.ArchivaRoleConstants;
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.lang.StringUtils;
-import org.junit.Test;
-
-import java.io.File;
-import java.util.List;
-
-/**
- * @author Olivier Lamy
- */
-public class ManagedRepositoryAdminTest
- extends AbstractRepositoryAdminTest
-{
- public static final String STAGE_REPO_ID_END = DefaultManagedRepositoryAdmin.STAGE_REPO_ID_END;
-
- @Test
- public void getAllManagedRepos()
- throws Exception
- {
- mockAuditListener.clearEvents();
- List<ManagedRepository> repos = managedRepositoryAdmin.getManagedRepositories();
- assertNotNull( repos );
- assertTrue( repos.size() > 0 );
- log.info( "repos " + repos );
-
- // check default internal
- ManagedRepository internal = findManagedRepoById( repos, "internal" );
- assertNotNull( internal );
- assertTrue( internal.isReleases() );
- assertFalse( internal.isSnapshots() );
- mockAuditListener.clearEvents();
- }
-
- @Test
- public void getById()
- throws Exception
- {
- mockAuditListener.clearEvents();
- ManagedRepository repo = managedRepositoryAdmin.getManagedRepository( "internal" );
- assertNotNull( repo );
- mockAuditListener.clearEvents();
- }
-
- @Test
- public void addDeleteManagedRepo()
- throws Exception
- {
- mockAuditListener.clearEvents();
-
- String repoId = "test-new-one";
-
- String repoLocation = APPSERVER_BASE_PATH + File.separator + repoId;
-
- File repoDir = clearRepoLocation( repoLocation );
-
- List<ManagedRepository> repos = managedRepositoryAdmin.getManagedRepositories();
- assertNotNull( repos );
- int initialSize = repos.size();
- assertTrue( initialSize > 0 );
-
- ManagedRepository repo = new ManagedRepository();
- repo.setId( repoId );
- repo.setName( "test repo" );
- repo.setLocation( repoLocation );
- repo.setCronExpression( "0 0 * * * ?" );
- managedRepositoryAdmin.addManagedRepository( repo, false, getFakeAuditInformation() );
- repos = managedRepositoryAdmin.getManagedRepositories();
- assertNotNull( repos );
- assertEquals( initialSize + 1, repos.size() );
-
- assertNotNull( managedRepositoryAdmin.getManagedRepository( repoId ) );
-
- assertTemplateRoleExists( repoId );
-
- managedRepositoryAdmin.deleteManagedRepository( repoId, getFakeAuditInformation(), false );
-
- // deleteContents false
- assertTrue( repoDir.exists() );
-
- repos = managedRepositoryAdmin.getManagedRepositories();
- assertNotNull( repos );
- assertEquals( initialSize, repos.size() );
-
- assertTemplateRoleNotExists( repoId );
-
- assertEquals( 2, mockAuditListener.getAuditEvents().size() );
-
- assertAuditListenerCallAddAndDelete();
-
- mockAuditListener.clearEvents();
- }
-
- @Test
- public void updateDeleteManagedRepo()
- throws Exception
- {
- String repoId = "test-new-one";
-
- String repoLocation = APPSERVER_BASE_PATH + File.separator + "new-path";
-
- File repoDir = clearRepoLocation( repoLocation );
-
- mockAuditListener.clearEvents();
- List<ManagedRepository> repos = managedRepositoryAdmin.getManagedRepositories();
- assertNotNull( repos );
- int initialSize = repos.size();
- assertTrue( initialSize > 0 );
-
- ManagedRepository repo = new ManagedRepository();
- repo.setId( repoId );
- repo.setName( "test repo" );
- repo.setLocation( repoLocation );
- repo.setCronExpression( "0 0 * * * ?" );
- managedRepositoryAdmin.addManagedRepository( repo, false, getFakeAuditInformation() );
-
- assertTemplateRoleExists( repoId );
-
- repos = managedRepositoryAdmin.getManagedRepositories();
- assertNotNull( repos );
- assertEquals( initialSize + 1, repos.size() );
-
- String newName = "test repo update";
-
- repo.setName( newName );
-
- repo.setLocation( repoLocation );
- repo.setCronExpression( "0 0 * * * ?" );
-
- managedRepositoryAdmin.updateManagedRepository( repo, false, getFakeAuditInformation(), false );
-
- repo = managedRepositoryAdmin.getManagedRepository( repoId );
- assertNotNull( repo );
- assertEquals( newName, repo.getName() );
- assertEquals( new File( repoLocation ).getCanonicalPath(), new File( repo.getLocation() ).getCanonicalPath() );
- assertTrue( new File( repoLocation ).exists() );
-
- assertTemplateRoleExists( repoId );
-
- managedRepositoryAdmin.deleteManagedRepository( repo.getId(), getFakeAuditInformation(), false );
-
- // check deleteContents false
- assertTrue( repoDir.exists() );
-
- assertTemplateRoleNotExists( repoId );
-
- assertAuditListenerCallAndUpdateAddAndDelete( false );
-
- mockAuditListener.clearEvents();
-
- }
-
-
- @Test
- public void addDeleteManagedRepoWithStaged()
- throws Exception
- {
-
- String repoId = "test-new-one";
- String repoLocation = APPSERVER_BASE_PATH + File.separator + repoId;
-
- File repoDir = clearRepoLocation( repoLocation );
-
- mockAuditListener.clearEvents();
- List<ManagedRepository> repos = managedRepositoryAdmin.getManagedRepositories();
- assertNotNull( repos );
- int initialSize = repos.size();
- assertTrue( initialSize > 0 );
-
- ManagedRepository repo = new ManagedRepository();
- repo.setId( repoId );
- repo.setName( "test repo" );
- repo.setLocation( repoLocation );
- repo.setCronExpression( "0 0 * * * ?" );
- managedRepositoryAdmin.addManagedRepository( repo, true, getFakeAuditInformation() );
- repos = managedRepositoryAdmin.getManagedRepositories();
- assertNotNull( repos );
- assertEquals( initialSize + 2, repos.size() );
-
- assertNotNull( managedRepositoryAdmin.getManagedRepository( repoId ) );
-
- assertTemplateRoleExists( repoId );
-
- assertTrue( repoDir.exists() );
-
- assertNotNull( managedRepositoryAdmin.getManagedRepository( repoId + STAGE_REPO_ID_END ) );
-
- assertTemplateRoleExists( repoId + STAGE_REPO_ID_END );
-
- assertTrue( new File( repoLocation + STAGE_REPO_ID_END ).exists() );
-
- managedRepositoryAdmin.deleteManagedRepository( repoId, getFakeAuditInformation(), true );
-
- assertFalse( repoDir.exists() );
-
- assertFalse( new File( repoLocation + STAGE_REPO_ID_END ).exists() );
-
- assertTemplateRoleNotExists( repoId + STAGE_REPO_ID_END );
-
- repos = managedRepositoryAdmin.getManagedRepositories();
- assertNotNull( repos );
- assertEquals( initialSize, repos.size() );
-
- assertTemplateRoleNotExists( repoId );
-
- assertTemplateRoleNotExists( repoId + STAGE_REPO_ID_END );
-
- mockAuditListener.clearEvents();
-
- }
-
- @Test
- public void updateDeleteManagedRepoWithStagedRepo()
- throws Exception
- {
- String repoId = "test-new-one";
-
- String repoLocation = APPSERVER_BASE_PATH + File.separator + "new-path";
-
- String stageRepoLocation = APPSERVER_BASE_PATH + File.separator + repoId;
-
- File repoDir = clearRepoLocation( repoLocation );
-
- mockAuditListener.clearEvents();
- List<ManagedRepository> repos = managedRepositoryAdmin.getManagedRepositories();
- assertNotNull( repos );
- int initialSize = repos.size();
- assertTrue( initialSize > 0 );
-
- ManagedRepository repo = getTestManagedRepository( repoId, repoLocation );
-
- managedRepositoryAdmin.addManagedRepository( repo, false, getFakeAuditInformation() );
-
- assertTemplateRoleExists( repoId );
-
- assertFalse( new File( repoLocation + STAGE_REPO_ID_END ).exists() );
-
- assertTemplateRoleNotExists( repoId + STAGE_REPO_ID_END );
-
- repos = managedRepositoryAdmin.getManagedRepositories();
- assertNotNull( repos );
- assertEquals( initialSize + 1, repos.size() );
-
- repo = managedRepositoryAdmin.getManagedRepository( repoId );
-
- assertEquals( getTestManagedRepository( repoId, repoLocation ).getIndexDirectory(), repo.getIndexDirectory() );
-
- String newName = "test repo update";
-
- repo.setName( newName );
-
- repo.setLocation( repoLocation );
-
- managedRepositoryAdmin.updateManagedRepository( repo, true, getFakeAuditInformation(), false );
-
- repo = managedRepositoryAdmin.getManagedRepository( repoId );
- assertNotNull( repo );
- assertEquals( newName, repo.getName() );
- assertEquals( new File( repoLocation ).getCanonicalPath(), new File( repo.getLocation() ).getCanonicalPath() );
- assertTrue( new File( repoLocation ).exists() );
- assertEquals( getTestManagedRepository( repoId, repoLocation ).getCronExpression(), repo.getCronExpression() );
- assertEquals( getTestManagedRepository( repoId, repoLocation ).getLayout(), repo.getLayout() );
- assertEquals( getTestManagedRepository( repoId, repoLocation ).getId(), repo.getId() );
- assertEquals( getTestManagedRepository( repoId, repoLocation ).getIndexDirectory(), repo.getIndexDirectory() );
-
- assertEquals( getTestManagedRepository( repoId, repoLocation ).getDaysOlder(), repo.getDaysOlder() );
- assertEquals( getTestManagedRepository( repoId, repoLocation ).getRetentionCount(), repo.getRetentionCount() );
- assertEquals( getTestManagedRepository( repoId, repoLocation ).isDeleteReleasedSnapshots(),
- repo.isDeleteReleasedSnapshots() );
-
- assertTemplateRoleExists( repoId );
-
- assertTrue( new File( stageRepoLocation + STAGE_REPO_ID_END ).exists() );
-
- assertTemplateRoleExists( repoId + STAGE_REPO_ID_END );
-
- managedRepositoryAdmin.deleteManagedRepository( repo.getId(), getFakeAuditInformation(), false );
-
- // check deleteContents false
- assertTrue( repoDir.exists() );
-
- assertTemplateRoleNotExists( repoId );
-
- assertTrue( new File( stageRepoLocation + STAGE_REPO_ID_END ).exists() );
-
- assertTemplateRoleNotExists( repoId + STAGE_REPO_ID_END );
-
- assertAuditListenerCallAndUpdateAddAndDelete( true );
-
- mockAuditListener.clearEvents();
-
- }
-
- //----------------------------------
- // utility methods
- //----------------------------------
-
- private void assertTemplateRoleExists( String repoId )
- throws Exception
- {
- assertTrue( roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, repoId ) );
- assertTrue( roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, repoId ) );
- }
-
-
- private void assertTemplateRoleNotExists( String repoId )
- throws Exception
- {
- assertFalse( roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, repoId ) );
- assertFalse( roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, repoId ) );
- }
-
- private void assertAuditListenerCallAddAndDelete()
- {
- assertEquals( 2, mockAuditListener.getAuditEvents().size() );
-
- assertEquals( AuditEvent.ADD_MANAGED_REPO, mockAuditListener.getAuditEvents().get( 0 ).getAction() );
- assertEquals( "root", mockAuditListener.getAuditEvents().get( 0 ).getUserId() );
- assertEquals( "archiva-localhost", mockAuditListener.getAuditEvents().get( 0 ).getRemoteIP() );
-
- assertEquals( AuditEvent.DELETE_MANAGED_REPO, mockAuditListener.getAuditEvents().get( 1 ).getAction() );
- assertEquals( "root", mockAuditListener.getAuditEvents().get( 0 ).getUserId() );
- }
-
- private void assertAuditListenerCallAndUpdateAddAndDelete( boolean stageNeeded )
- {
- if ( stageNeeded )
- {
- assertEquals( "not 4 audit events " + mockAuditListener.getAuditEvents(), 4,
- mockAuditListener.getAuditEvents().size() );
- }
- else
- {
- assertEquals( "not 3 audit events " + mockAuditListener.getAuditEvents(), 3,
- mockAuditListener.getAuditEvents().size() );
- }
- assertEquals( AuditEvent.ADD_MANAGED_REPO, mockAuditListener.getAuditEvents().get( 0 ).getAction() );
- assertEquals( "root", mockAuditListener.getAuditEvents().get( 0 ).getUserId() );
- assertEquals( "archiva-localhost", mockAuditListener.getAuditEvents().get( 0 ).getRemoteIP() );
-
- if ( stageNeeded )
- {
- assertEquals( AuditEvent.ADD_MANAGED_REPO, mockAuditListener.getAuditEvents().get( 1 ).getAction() );
- assertEquals( AuditEvent.MODIFY_MANAGED_REPO, mockAuditListener.getAuditEvents().get( 2 ).getAction() );
- assertEquals( AuditEvent.DELETE_MANAGED_REPO, mockAuditListener.getAuditEvents().get( 3 ).getAction() );
- }
- else
- {
- assertEquals( AuditEvent.MODIFY_MANAGED_REPO, mockAuditListener.getAuditEvents().get( 1 ).getAction() );
- assertEquals( AuditEvent.DELETE_MANAGED_REPO, mockAuditListener.getAuditEvents().get( 2 ).getAction() );
- }
-
- }
-
-
-
-}
+++ /dev/null
-package org.apache.archiva.admin.repository.networkproxy;
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.archiva.admin.repository.AbstractRepositoryAdminTest;
-import org.apache.archiva.audit.AuditEvent;
-import org.junit.Test;
-
-import javax.inject.Inject;
-
-/**
- * @author Olivier Lamy
- */
-public class NetworkProxyAdminTest
- extends AbstractRepositoryAdminTest
-{
-
- @Inject
- private NetworkProxyAdmin networkProxyAdmin;
-
- @Test
- public void getAllEmpty()
- throws Exception
- {
- assertNotNull( networkProxyAdmin.getNetworkProxies() );
- }
-
- @Test
- public void addAndDelete()
- throws Exception
- {
- mockAuditListener.clearEvents();
- int initialSize = networkProxyAdmin.getNetworkProxies().size();
- NetworkProxy networkProxy = getNetworkProxyTest( "foo" );
-
- networkProxyAdmin.addNetworkProxy( networkProxy, getFakeAuditInformation() );
-
- assertEquals( initialSize + 1, networkProxyAdmin.getNetworkProxies().size() );
-
- networkProxy = networkProxyAdmin.getNetworkProxy( "foo" );
-
- assertNotNull( networkProxy );
- assertEquals( getNetworkProxyTest( "foo" ).getId(), networkProxy.getId() );
- assertEquals( getNetworkProxyTest( "foo" ).getHost(), networkProxy.getHost() );
- assertEquals( getNetworkProxyTest( "foo" ).getPassword(), networkProxy.getPassword() );
- assertEquals( getNetworkProxyTest( "foo" ).getPort(), networkProxy.getPort() );
- assertEquals( getNetworkProxyTest( "foo" ).getUsername(), networkProxy.getUsername() );
- assertEquals( getNetworkProxyTest( "foo" ).getProtocol(), networkProxy.getProtocol() );
-
- networkProxyAdmin.deleteNetworkProxy( "foo", getFakeAuditInformation() );
-
- assertNull( networkProxyAdmin.getNetworkProxy( "foo" ) );
-
- assertEquals( 2, mockAuditListener.getAuditEvents().size() );
-
- assertEquals( AuditEvent.ADD_NETWORK_PROXY, mockAuditListener.getAuditEvents().get( 0 ).getAction() );
- assertEquals( AuditEvent.DELETE_NETWORK_PROXY, mockAuditListener.getAuditEvents().get( 1 ).getAction() );
-
- mockAuditListener.clearEvents();
- }
-
- @Test
- public void addAndUpdateAndDelete()
- throws Exception
- {
- mockAuditListener.clearEvents();
- int initialSize = networkProxyAdmin.getNetworkProxies().size();
- NetworkProxy networkProxy = getNetworkProxyTest( "foo" );
-
- networkProxyAdmin.addNetworkProxy( networkProxy, getFakeAuditInformation() );
-
- assertEquals( initialSize + 1, networkProxyAdmin.getNetworkProxies().size() );
-
- networkProxy = networkProxyAdmin.getNetworkProxy( "foo" );
-
- assertNotNull( networkProxy );
- assertEquals( getNetworkProxyTest( "foo" ).getId(), networkProxy.getId() );
- assertEquals( getNetworkProxyTest( "foo" ).getHost(), networkProxy.getHost() );
- assertEquals( getNetworkProxyTest( "foo" ).getPassword(), networkProxy.getPassword() );
- assertEquals( getNetworkProxyTest( "foo" ).getPort(), networkProxy.getPort() );
- assertEquals( getNetworkProxyTest( "foo" ).getUsername(), networkProxy.getUsername() );
- assertEquals( getNetworkProxyTest( "foo" ).getProtocol(), networkProxy.getProtocol() );
-
- networkProxy.setHost( "https://toto.com" );
- networkProxy.setPassword( "newpasswd" );
- networkProxy.setPort( 9191 );
- networkProxy.setProtocol( "http" );
- networkProxy.setUsername( "newusername" );
-
- networkProxyAdmin.updateNetworkProxy( networkProxy, getFakeAuditInformation() );
-
- NetworkProxy updatedNetworkProxy = networkProxyAdmin.getNetworkProxy( "foo" );
-
- assertNotNull( updatedNetworkProxy );
- assertEquals( networkProxy.getId(), updatedNetworkProxy.getId() );
- assertEquals( networkProxy.getHost(), updatedNetworkProxy.getHost() );
- assertEquals( networkProxy.getPassword(), updatedNetworkProxy.getPassword() );
- assertEquals( networkProxy.getPort(), updatedNetworkProxy.getPort() );
- assertEquals( networkProxy.getUsername(), updatedNetworkProxy.getUsername() );
- assertEquals( networkProxy.getProtocol(), updatedNetworkProxy.getProtocol() );
-
- networkProxyAdmin.deleteNetworkProxy( "foo", getFakeAuditInformation() );
-
- assertEquals( 3, mockAuditListener.getAuditEvents().size() );
-
- assertEquals( AuditEvent.ADD_NETWORK_PROXY, mockAuditListener.getAuditEvents().get( 0 ).getAction() );
- assertEquals( AuditEvent.MODIFY_NETWORK_PROXY, mockAuditListener.getAuditEvents().get( 1 ).getAction() );
- assertEquals( AuditEvent.DELETE_NETWORK_PROXY, mockAuditListener.getAuditEvents().get( 2 ).getAction() );
-
- mockAuditListener.clearEvents();
- }
-
-
- protected NetworkProxy getNetworkProxyTest( String id )
- {
- NetworkProxy networkProxy = new NetworkProxy();
- networkProxy.setId( "foo" );
- networkProxy.setHost( "http://foo.com" );
- networkProxy.setPassword( "passwd" );
- networkProxy.setPort( 9090 );
- networkProxy.setUsername( "root" );
- networkProxy.setProtocol( "https" );
- return networkProxy;
- }
-
-}
+++ /dev/null
-package org.apache.archiva.admin.repository.proxyconnector;
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.archiva.admin.repository.AbstractRepositoryAdminTest;
-import org.apache.archiva.admin.repository.remote.RemoteRepository;
-import org.apache.archiva.audit.AuditEvent;
-import org.junit.Test;
-
-import java.util.Arrays;
-
-/**
- * @author Olivier Lamy
- */
-public class ProxyConnectorAdminTest
- extends AbstractRepositoryAdminTest
-{
-
- @Test
- public void addAndDelete()
- throws Exception
- {
- mockAuditListener.clearEvents();
- assertEquals( "not proxyConnectors 2 " + proxyConnectorAdmin.getProxyConnectors(), 2,
- proxyConnectorAdmin.getProxyConnectors().size() );
- assertFalse( proxyConnectorAdmin.getProxyConnectors().isEmpty() );
- ProxyConnector proxyConnector = new ProxyConnector();
- proxyConnector.setSourceRepoId( "snapshots" );
- proxyConnector.setTargetRepoId( "central" );
- proxyConnectorAdmin.addProxyConnector( proxyConnector, getFakeAuditInformation() );
-
- assertFalse( proxyConnectorAdmin.getProxyConnectors().isEmpty() );
- assertEquals( 3, proxyConnectorAdmin.getProxyConnectors().size() );
-
- assertNotNull( proxyConnectorAdmin.getProxyConnector( "snapshots", "central" ) );
-
- proxyConnectorAdmin.deleteProxyConnector( proxyConnector, getFakeAuditInformation() );
-
- assertEquals( 2, proxyConnectorAdmin.getProxyConnectors().size() );
- assertFalse( proxyConnectorAdmin.getProxyConnectors().isEmpty() );
-
- assertEquals( 2, mockAuditListener.getAuditEvents().size() );
-
- assertEquals( AuditEvent.ADD_PROXY_CONNECTOR, mockAuditListener.getAuditEvents().get( 0 ).getAction() );
- assertEquals( "root", mockAuditListener.getAuditEvents().get( 0 ).getUserId() );
- assertEquals( "archiva-localhost", mockAuditListener.getAuditEvents().get( 0 ).getRemoteIP() );
-
- assertEquals( AuditEvent.DELETE_PROXY_CONNECTOR, mockAuditListener.getAuditEvents().get( 1 ).getAction() );
- assertEquals( "root", mockAuditListener.getAuditEvents().get( 1 ).getUserId() );
-
- assertNull( proxyConnectorAdmin.getProxyConnector( "snapshots", "central" ) );
-
- mockAuditListener.clearEvents();
- }
-
- @Test
- public void addAndUpdateAndDelete()
- throws Exception
- {
- mockAuditListener.clearEvents();
- RemoteRepository remoteRepository = getRemoteRepository( "test-new-one" );
-
- remoteRepositoryAdmin.addRemoteRepository( remoteRepository, getFakeAuditInformation() );
-
- assertEquals( "not proxyConnectors 2 " + proxyConnectorAdmin.getProxyConnectors(), 2,
- proxyConnectorAdmin.getProxyConnectors().size() );
- assertFalse( proxyConnectorAdmin.getProxyConnectors().isEmpty() );
- ProxyConnector proxyConnector = new ProxyConnector();
- proxyConnector.setSourceRepoId( "snapshots" );
- proxyConnector.setTargetRepoId( "central" );
- proxyConnector.setWhiteListPatterns( Arrays.asList( "foo", "bar" ) );
- proxyConnectorAdmin.addProxyConnector( proxyConnector, getFakeAuditInformation() );
-
- assertFalse( proxyConnectorAdmin.getProxyConnectors().isEmpty() );
- assertEquals( 3, proxyConnectorAdmin.getProxyConnectors().size() );
-
- assertNotNull( proxyConnectorAdmin.getProxyConnector( "snapshots", "central" ) );
- assertEquals( Arrays.asList( "foo", "bar" ),
- proxyConnectorAdmin.getProxyConnector( "snapshots", "central" ).getWhiteListPatterns() );
-
- proxyConnectorAdmin.deleteProxyConnector( proxyConnector, getFakeAuditInformation() );
-
- proxyConnector.setTargetRepoId( remoteRepository.getId() );
- proxyConnectorAdmin.addProxyConnector( proxyConnector, getFakeAuditInformation() );
-
- assertNull( proxyConnectorAdmin.getProxyConnector( "snapshots", "central" ) );
- assertNotNull( remoteRepository.getId(),
- proxyConnectorAdmin.getProxyConnector( "snapshots", remoteRepository.getId() ) );
-
- proxyConnectorAdmin.deleteProxyConnector( proxyConnector, getFakeAuditInformation() );
-
- assertNull( proxyConnectorAdmin.getProxyConnector( "snapshots", "central" ) );
-
- assertEquals( 2, proxyConnectorAdmin.getProxyConnectors().size() );
- assertFalse( proxyConnectorAdmin.getProxyConnectors().isEmpty() );
-
- assertEquals( 5, mockAuditListener.getAuditEvents().size() );
-
- assertEquals( AuditEvent.ADD_REMOTE_REPO, mockAuditListener.getAuditEvents().get( 0 ).getAction() );
-
- assertEquals( AuditEvent.ADD_PROXY_CONNECTOR, mockAuditListener.getAuditEvents().get( 1 ).getAction() );
- assertEquals( "root", mockAuditListener.getAuditEvents().get( 2 ).getUserId() );
- assertEquals( "archiva-localhost", mockAuditListener.getAuditEvents().get( 2 ).getRemoteIP() );
-
- assertEquals( AuditEvent.DELETE_PROXY_CONNECTOR, mockAuditListener.getAuditEvents().get( 2 ).getAction() );
-
- assertEquals( AuditEvent.ADD_PROXY_CONNECTOR, mockAuditListener.getAuditEvents().get( 3 ).getAction() );
-
- assertEquals( AuditEvent.DELETE_PROXY_CONNECTOR, mockAuditListener.getAuditEvents().get( 4 ).getAction() );
- assertEquals( "root", mockAuditListener.getAuditEvents().get( 4 ).getUserId() );
-
- remoteRepositoryAdmin.deleteRemoteRepository( remoteRepository.getId(), getFakeAuditInformation() );
- mockAuditListener.clearEvents();
- }
-
- @Test
- public void findProxyConnector()
- throws Exception
- {
- ProxyConnector proxyConnector = proxyConnectorAdmin.getProxyConnector( "internal", "central" );
- assertNotNull( proxyConnector );
- }
-
- @Test
- public void updateProxyConnector()
- throws Exception
- {
- mockAuditListener.clearEvents();
- ProxyConnector proxyConnector = proxyConnectorAdmin.getProxyConnector( "internal", "central" );
- assertNotNull( proxyConnector );
- proxyConnector.setDisabled( false );
- proxyConnectorAdmin.updateProxyConnector( proxyConnector, getFakeAuditInformation() );
- proxyConnector = proxyConnectorAdmin.getProxyConnector( "internal", "central" );
- assertFalse( proxyConnector.isDisabled() );
-
- proxyConnector.setDisabled( true );
- proxyConnectorAdmin.updateProxyConnector( proxyConnector, getFakeAuditInformation() );
- proxyConnector = proxyConnectorAdmin.getProxyConnector( "internal", "central" );
- assertTrue( proxyConnector.isDisabled() );
-
- proxyConnector.setOrder( 4 );
- proxyConnectorAdmin.updateProxyConnector( proxyConnector, getFakeAuditInformation() );
- proxyConnector = proxyConnectorAdmin.getProxyConnector( "internal", "central" );
- assertEquals( 4, proxyConnector.getOrder() );
- mockAuditListener.clearEvents();
-
- }
-
-}
+++ /dev/null
-package org.apache.archiva.admin.repository.remote;
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.archiva.admin.repository.AbstractRepositoryAdminTest;
-import org.apache.archiva.audit.AuditEvent;
-import org.junit.Test;
-
-import java.util.List;
-
-/**
- * @author Olivier Lamy
- */
-public class RemoteRepositoryAdminTest
- extends AbstractRepositoryAdminTest
-{
-
- @Test
- public void getAll()
- throws Exception
- {
- List<RemoteRepository> remoteRepositories = remoteRepositoryAdmin.getRemoteRepositories();
- assertNotNull( remoteRepositories );
- assertTrue( remoteRepositories.size() > 0 );
- log.info( "remote " + remoteRepositories );
- }
-
- @Test
- public void getById()
- throws Exception
- {
- RemoteRepository central = remoteRepositoryAdmin.getRemoteRepository( "central" );
- assertNotNull( central );
- assertEquals( "http://repo1.maven.org/maven2", central.getUrl() );
- assertEquals( 60, central.getTimeout() );
- assertNull( central.getUserName() );
- assertNull( central.getPassword() );
- }
-
- @Test
- public void addAndDelete()
- throws Exception
- {
- mockAuditListener.clearEvents();
- int initialSize = remoteRepositoryAdmin.getRemoteRepositories().size();
-
- RemoteRepository remoteRepository = getRemoteRepository();
-
- remoteRepositoryAdmin.addRemoteRepository( remoteRepository, getFakeAuditInformation() );
-
- assertEquals( initialSize + 1, remoteRepositoryAdmin.getRemoteRepositories().size() );
-
- RemoteRepository repo = remoteRepositoryAdmin.getRemoteRepository( "foo" );
- assertNotNull( repo );
- assertEquals( getRemoteRepository().getPassword(), repo.getPassword() );
- assertEquals( getRemoteRepository().getUrl(), repo.getUrl() );
- assertEquals( getRemoteRepository().getUserName(), repo.getUserName() );
- assertEquals( getRemoteRepository().getName(), repo.getName() );
- assertEquals( getRemoteRepository().getTimeout(), repo.getTimeout() );
-
- remoteRepositoryAdmin.deleteRemoteRepository( "foo", getFakeAuditInformation() );
-
- assertEquals( initialSize, remoteRepositoryAdmin.getRemoteRepositories().size() );
-
- repo = remoteRepositoryAdmin.getRemoteRepository( "foo" );
- assertNull( repo );
-
- assertEquals( 2, mockAuditListener.getAuditEvents().size() );
-
- assertEquals( AuditEvent.ADD_REMOTE_REPO, mockAuditListener.getAuditEvents().get( 0 ).getAction() );
- assertEquals( "root", mockAuditListener.getAuditEvents().get( 0 ).getUserId() );
- assertEquals( "archiva-localhost", mockAuditListener.getAuditEvents().get( 0 ).getRemoteIP() );
-
- assertEquals( AuditEvent.DELETE_REMOTE_REPO, mockAuditListener.getAuditEvents().get( 1 ).getAction() );
- assertEquals( "root", mockAuditListener.getAuditEvents().get( 1 ).getUserId() );
-
- }
-
-
- @Test
- public void addAndUpdateAndDelete()
- throws Exception
- {
- mockAuditListener.clearEvents();
- int initialSize = remoteRepositoryAdmin.getRemoteRepositories().size();
-
- RemoteRepository remoteRepository = getRemoteRepository();
-
- remoteRepositoryAdmin.addRemoteRepository( remoteRepository, getFakeAuditInformation() );
-
- assertEquals( initialSize + 1, remoteRepositoryAdmin.getRemoteRepositories().size() );
-
- RemoteRepository repo = remoteRepositoryAdmin.getRemoteRepository( "foo" );
- assertNotNull( repo );
- assertEquals( getRemoteRepository().getPassword(), repo.getPassword() );
- assertEquals( getRemoteRepository().getUrl(), repo.getUrl() );
- assertEquals( getRemoteRepository().getUserName(), repo.getUserName() );
- assertEquals( getRemoteRepository().getName(), repo.getName() );
- assertEquals( getRemoteRepository().getTimeout(), repo.getTimeout() );
-
- repo.setUserName( "foo-name-changed" );
- repo.setPassword( "titi" );
- repo.setUrl( "http://foo.com/maven-really-rocks" );
-
- remoteRepositoryAdmin.updateRemoteRepository( repo, getFakeAuditInformation() );
-
- repo = remoteRepositoryAdmin.getRemoteRepository( "foo" );
-
- assertEquals( "foo-name-changed", repo.getUserName() );
- assertEquals( "titi", repo.getPassword() );
- assertEquals( "http://foo.com/maven-really-rocks", repo.getUrl() );
-
- remoteRepositoryAdmin.deleteRemoteRepository( "foo", getFakeAuditInformation() );
-
- assertEquals( initialSize, remoteRepositoryAdmin.getRemoteRepositories().size() );
-
- repo = remoteRepositoryAdmin.getRemoteRepository( "foo" );
- assertNull( repo );
-
- assertEquals( 3, mockAuditListener.getAuditEvents().size() );
-
- assertEquals( AuditEvent.ADD_REMOTE_REPO, mockAuditListener.getAuditEvents().get( 0 ).getAction() );
- assertEquals( "root", mockAuditListener.getAuditEvents().get( 0 ).getUserId() );
- assertEquals( "archiva-localhost", mockAuditListener.getAuditEvents().get( 0 ).getRemoteIP() );
-
- assertEquals( AuditEvent.MODIFY_REMOTE_REPO, mockAuditListener.getAuditEvents().get( 1 ).getAction() );
- assertEquals( "root", mockAuditListener.getAuditEvents().get( 1 ).getUserId() );
- assertEquals( "archiva-localhost", mockAuditListener.getAuditEvents().get( 1 ).getRemoteIP() );
-
- assertEquals( AuditEvent.DELETE_REMOTE_REPO, mockAuditListener.getAuditEvents().get( 2 ).getAction() );
- assertEquals( "root", mockAuditListener.getAuditEvents().get( 2 ).getUserId() );
-
- }
-
-
-
-}
+++ /dev/null
-<redback-role-model>
- <modelVersion>1.0.0</modelVersion>
- <applications>
- <application>
- <id>System</id>
- <description>Roles that apply system-wide, across all of the applications</description>
- <version>1.0.0</version>
- <resources>
- <resource>
- <id>global</id>
- <name>*</name>
- <permanent>true</permanent>
- <description>global resource implies full access for authorization</description>
- </resource>
- <resource>
- <id>username</id>
- <name>${username}</name>
- <permanent>true</permanent>
- <description>replaced with the username of the principal at authorization check time</description>
- </resource>
- </resources>
- <operations>
- <operation>
- <id>configuration-edit</id>
- <name>configuration-edit</name>
- <description>edit configuration</description>
- <permanent>true</permanent>
- </operation>
- <operation>
- <id>user-management-user-create</id>
- <name>user-management-user-create</name>
- <description>create user</description>
- <permanent>true</permanent>
- </operation>
- <operation>
- <id>user-management-user-edit</id>
- <name>user-management-user-edit</name>
- <description>edit user</description>
- <permanent>true</permanent>
- </operation>
- <operation>
- <id>user-management-user-role</id>
- <name>user-management-user-role</name>
- <description>user roles</description>
- <permanent>true</permanent>
- </operation>
- <operation>
- <id>user-management-user-delete</id>
- <name>user-management-user-delete</name>
- <description>delete user</description>
- <permanent>true</permanent>
- </operation>
- <operation>
- <id>user-management-user-list</id>
- <name>user-management-user-list</name>
- <description>list users</description>
- <permanent>true</permanent>
- </operation>
- <operation>
- <id>user-management-role-grant</id>
- <name>user-management-role-grant</name>
- <description>grant role</description>
- <permanent>true</permanent>
- </operation>
- <operation>
- <id>user-management-role-drop</id>
- <name>user-management-role-drop</name>
- <description>drop role</description>
- <permanent>true</permanent>
- </operation>
- <operation>
- <id>user-management-rbac-admin</id>
- <name>user-management-rbac-admin</name>
- <description>administer rbac</description>
- <permanent>true</permanent>
- </operation>
- <operation>
- <id>guest-access</id>
- <name>guest-access</name>
- <description>access guest</description>
- <permanent>true</permanent>
- </operation>
- <operation>
- <id>user-management-manage-data</id>
- <name>user-management-manage-data</name>
- <description>manage data</description>
- <permanent>true</permanent>
- </operation>
- </operations>
- <roles>
- <role>
- <id>system-administrator</id>
- <name>System Administrator</name>
- <permanent>true</permanent>
- <assignable>true</assignable>
- <permissions>
- <permission>
- <id>edit-redback-configuration</id>
- <name>Edit Redback Configuration</name>
- <operation>configuration-edit</operation>
- <resource>global</resource>
- <permanent>true</permanent>
- </permission>
- <permission>
- <id>manage-rbac-setup</id>
- <name>User RBAC Management</name>
- <operation>user-management-rbac-admin</operation>
- <resource>global</resource>
- <permanent>true</permanent>
- </permission>
- <permission>
- <id>manage-rbac-data</id>
- <name>RBAC Manage Data</name>
- <operation>user-management-manage-data</operation>
- <resource>global</resource>
- <permanent>true</permanent>
- </permission>
- </permissions>
- <childRoles>
- <childRole>user-administrator</childRole>
- </childRoles>
- </role>
- <role>
- <id>user-administrator</id>
- <name>User Administrator</name>
- <permanent>true</permanent>
- <assignable>true</assignable>
- <permissions>
- <permission>
- <id>drop-roles-for-anyone</id>
- <name>Drop Roles for Anyone</name>
- <operation>user-management-role-drop</operation>
- <resource>global</resource>
- <permanent>true</permanent>
- </permission>
- <permission>
- <id>grant-roles-for-anyone</id>
- <name>Grant Roles for Anyone</name>
- <operation>user-management-role-grant</operation>
- <resource>global</resource>
- <permanent>true</permanent>
- </permission>
- <permission>
- <id>user-create</id>
- <name>Create Users</name>
- <operation>user-management-user-create</operation>
- <resource>global</resource>
- <permanent>true</permanent>
- </permission>
- <permission>
- <id>user-delete</id>
- <name>Delete Users</name>
- <operation>user-management-user-delete</operation>
- <resource>global</resource>
- <permanent>true</permanent>
- </permission>
- <permission>
- <id>user-edit</id>
- <name>Edit Users</name>
- <operation>user-management-user-edit</operation>
- <resource>global</resource>
- <permanent>true</permanent>
- </permission>
- <permission>
- <id>access-users-roles</id>
- <name>Access Users Roles</name>
- <operation>user-management-user-role</operation>
- <resource>global</resource>
- <permanent>true</permanent>
- </permission>
- <permission>
- <id>access-user-list</id>
- <name>Access User List</name>
- <operation>user-management-user-list</operation>
- <resource>global</resource>
- <permanent>true</permanent>
- </permission>
- </permissions>
- </role>
- <role>
- <id>registered-user</id>
- <name>Registered User</name>
- <permanent>true</permanent>
- <assignable>true</assignable>
- <permissions>
- <permission>
- <id>edit-user-by-username</id>
- <name>Edit User Data by Username</name>
- <operation>user-management-user-edit</operation>
- <resource>username</resource>
- <permanent>true</permanent>
- </permission>
- </permissions>
- </role>
- <role>
- <id>guest</id>
- <name>Guest</name>
- <permanent>true</permanent>
- <assignable>true</assignable>
- <permissions>
- <permission>
- <id>guest-permission</id>
- <name>Guest Permission</name>
- <operation>guest-access</operation>
- <resource>global</resource>
- <permanent>true</permanent>
- </permission>
- </permissions>
- </role>
- </roles>
- </application>
- </applications>
-</redback-role-model>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" ?>
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing,
- ~ software distributed under the License is distributed on an
- ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- ~ KIND, either express or implied. See the License for the
- ~ specific language governing permissions and limitations
- ~ under the License.
- -->
-
-<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
-
-<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
-
- <appender name="console" class="org.apache.log4j.ConsoleAppender">
- <layout class="org.apache.log4j.PatternLayout">
- <param name="ConversionPattern" value="%d [%t] %-5p %c %x - %m%n"/>
- </layout>
- </appender>
-
-
-
- <logger name="org.apache.archiva.admin.repository.managed" >
- <level value="debug"/>
- </logger>
- <logger name="JPOX">
- <level value="ERROR"/>
- </logger>
-
- <logger name="org.springframework">
- <level value="error"/>
- </logger>
-
- <root>
- <priority value ="info" />
- <appender-ref ref="console" />
- </root>
-
-</log4j:configuration>
+++ /dev/null
-<?xml version="1.0"?>
-
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing,
- ~ software distributed under the License is distributed on an
- ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- ~ KIND, either express or implied. See the License for the
- ~ specific language governing permissions and limitations
- ~ under the License.
- -->
-<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-3.0.xsd
- http://www.springframework.org/schema/context
- http://www.springframework.org/schema/context/spring-context-3.0.xsd" default-lazy-init="true">
-
- <context:annotation-config/>
- <context:component-scan base-package="org.apache.archiva.admin.mock"/>
-
- <bean name="scheduler" class="org.codehaus.redback.components.scheduler.DefaultScheduler">
- <property name="properties">
- <props>
- <prop key="org.quartz.scheduler.instanceName">scheduler1</prop>
- <prop key="org.quartz.threadPool.class">org.quartz.simpl.SimpleThreadPool</prop>
- <prop key="org.quartz.threadPool.threadCount">2</prop>
- <prop key="org.quartz.threadPool.threadPriority">4</prop>
- <prop key="org.quartz.jobStore.class">org.quartz.simpl.RAMJobStore</prop>
- </props>
- </property>
- </bean>
-
- <bean name="commons-configuration" class="org.codehaus.redback.components.registry.commons.CommonsConfigurationRegistry">
- <property name="properties">
- <value>
- <![CDATA[
- <configuration>
- <system/>
- <xml fileName="${appserver.base}/conf/archiva.xml" config-forceCreate="true"
- config-optional="true"
- config-name="org.apache.maven.archiva.base" config-at="org.apache.maven.archiva"/>
- </configuration>
- ]]>
- </value>
- </property>
- </bean>
-
-</beans>
\ No newline at end of file
* under the License.
*/
-import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
+import org.apache.archiva.admin.model.managed.ManagedRepository;
import org.apache.maven.archiva.model.ArchivaArtifact;
import org.apache.maven.archiva.model.ArtifactReference;
import org.apache.maven.archiva.model.ProjectReference;
import java.util.Set;
/**
- * ManagedRepositoryContent interface for interacting with a managed repository in an abstract way,
+ * ManagedRepositoryContent interface for interacting with a managed repository in an abstract way,
* without the need for processing based on filesystem paths, or working with the database.
*
* @version $Id$
/**
* Delete from the managed repository all files / directories associated with the
* provided version reference.
- *
+ *
* @param reference the version reference to delete.
- * @throws ContentNotFoundException
+ * @throws ContentNotFoundException
*/
void deleteVersion( VersionedReference reference )
throws ContentNotFoundException;
* <p>
* Convenience method to get the repository id.
* </p>
- *
+ * <p/>
* <p>
* Equivalent to calling <code>.getRepository().getId()</code>
* </p>
- *
+ *
* @return the repository id.
*/
String getId();
/**
* <p>
* Gather up the list of related artifacts to the ArtifactReference provided.
- * This typically inclues the pom files, and those things with
+ * This typically inclues the pom files, and those things with
* classifiers (such as doc, source code, test libs, etc...)
* </p>
- *
+ * <p/>
* <p>
* <strong>NOTE:</strong> Some layouts (such as maven 1 "legacy") are not compatible with this query.
- * </p>
- *
+ * </p>
+ *
* @param reference the reference to work off of.
* @return the set of ArtifactReferences for related artifacts.
* @throws ContentNotFoundException if the initial artifact reference does not exist within the repository.
- * @throws LayoutException
+ * @throws LayoutException
*/
Set<ArtifactReference> getRelatedArtifacts( ArtifactReference reference )
throws ContentNotFoundException;
* <p>
* Convenience method to get the repository (on disk) root directory.
* </p>
- *
+ * <p/>
* <p>
* Equivalent to calling <code>.getRepository().getLocation()</code>
* </p>
- *
+ *
* @return the repository (on disk) root directory.
*/
String getRepoRoot();
/**
* Get the repository configuration associated with this
* repository content.
- *
+ *
* @return the repository that is associated with this repository content.
*/
- ManagedRepositoryConfiguration getRepository();
+ ManagedRepository getRepository();
/**
* Given a specific {@link ProjectReference}, return the list of available versions for
* that project reference.
- *
+ *
* @param reference the project reference to work off of.
* @return the list of versions found for that project reference.
* @throws ContentNotFoundException if the project reference does nto exist within the repository.
- * @throws LayoutException
+ * @throws LayoutException
*/
Set<String> getVersions( ProjectReference reference )
throws ContentNotFoundException, LayoutException;
* Given a specific {@link VersionedReference}, return the list of available versions for that
* versioned reference.
* </p>
- *
+ * <p/>
* <p>
* <strong>NOTE:</strong> This is really only useful when working with SNAPSHOTs.
* </p>
- *
+ *
* @param reference the versioned reference to work off of.
* @return the set of versions found.
* @throws ContentNotFoundException if the versioned reference does not exist within the repository.
- * @throws LayoutException
+ * @throws LayoutException
*/
- public Set<String> getVersions( VersionedReference reference )
+ Set<String> getVersions( VersionedReference reference )
throws ContentNotFoundException;
/**
* Determines if the artifact referenced exists in the repository.
- *
+ *
* @param reference the artifact reference to check for.
* @return true if the artifact referenced exists.
*/
- public boolean hasContent( ArtifactReference reference );
+ boolean hasContent( ArtifactReference reference );
/**
* Determines if the project referenced exists in the repository.
- *
+ *
* @param reference the project reference to check for.
* @return true it the project referenced exists.
*/
- public boolean hasContent( ProjectReference reference );
+ boolean hasContent( ProjectReference reference );
/**
* Determines if the version reference exists in the repository.
- *
+ *
* @param reference the version reference to check for.
* @return true if the version referenced exists.
*/
- public boolean hasContent( VersionedReference reference );
+ boolean hasContent( VersionedReference reference );
/**
* Set the repository configuration to associate with this
* repository content.
- *
+ *
* @param repo the repository to associate with this repository content.
*/
- public void setRepository( ManagedRepositoryConfiguration repo );
+ void setRepository( ManagedRepository repo );
/**
* Given a repository relative path to a filename, return the {@link VersionedReference} object suitable for the path.
* a {@link ArtifactReference})
* @throws LayoutException if there was a problem converting the path to an artifact.
*/
- public ArtifactReference toArtifactReference( String path )
+ ArtifactReference toArtifactReference( String path )
throws LayoutException;
/**
* @param reference the artifact reference to use.
* @return the relative path to the artifact.
*/
- public File toFile( ArtifactReference reference );
-
+ File toFile( ArtifactReference reference );
+
/**
* Given an {@link ArchivaArtifact}, return the file reference to the artifact.
*
* @param reference the archiva artifact to use.
* @return the relative path to the artifact.
*/
- public File toFile( ArchivaArtifact reference );
+ File toFile( ArchivaArtifact reference );
/**
* Given a {@link ProjectReference}, return the path to the metadata for
- * the project.
- *
+ * the project.
+ *
* @param reference the reference to use.
* @return the path to the metadata file, or null if no metadata is appropriate.
*/
- public String toMetadataPath( ProjectReference reference );
+ String toMetadataPath( ProjectReference reference );
/**
* Given a {@link VersionedReference}, return the path to the metadata for
- * the specific version of the project.
- *
+ * the specific version of the project.
+ *
* @param reference the reference to use.
* @return the path to the metadata file, or null if no metadata is appropriate.
*/
- public String toMetadataPath( VersionedReference reference );
+ String toMetadataPath( VersionedReference reference );
/**
* Given an {@link ArtifactReference}, return the relative path to the artifact.
* @param reference the artifact reference to use.
* @return the relative path to the artifact.
*/
- public String toPath( ArtifactReference reference );
-
+ String toPath( ArtifactReference reference );
+
/**
* Given an {@link ArchivaArtifact}, return the relative path to the artifact.
*
* @param reference the archiva artifact to use.
* @return the relative path to the artifact.
*/
- public String toPath( ArchivaArtifact reference );
+ String toPath( ArchivaArtifact reference );
}
* under the License.
*/
+import org.apache.archiva.admin.model.remote.RemoteRepository;
import org.apache.maven.archiva.configuration.RemoteRepositoryConfiguration;
import org.apache.maven.archiva.model.ArtifactReference;
import org.apache.maven.archiva.model.RepositoryURL;
*
* @return the repository that is associated with this repository content.
*/
- RemoteRepositoryConfiguration getRepository();
+ RemoteRepository getRepository();
/**
* <p>
*
* @param repo the repository to associate with this repository content.
*/
- void setRepository( RemoteRepositoryConfiguration repo );
+ void setRepository( RemoteRepository repo );
/**
* Given a repository relative path to a filename, return the {@link VersionedReference} object suitable for the path.
* under the License.
*/
+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.admin.model.remote.RemoteRepository;
+import org.apache.archiva.admin.model.remote.RemoteRepositoryAdmin;
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.configuration.ConfigurationNames;
-import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
-import org.apache.maven.archiva.configuration.RemoteRepositoryConfiguration;
import org.codehaus.plexus.registry.Registry;
import org.codehaus.plexus.registry.RegistryListener;
import org.springframework.context.ApplicationContext;
@Inject
private ArchivaConfiguration archivaConfiguration;
+ @Inject
+ private ManagedRepositoryAdmin managedRepositoryAdmin;
+
+ @Inject
+ private RemoteRepositoryAdmin remoteRepositoryAdmin;
+
@Inject
private ApplicationContext applicationContext;
public ManagedRepositoryContent getManagedRepositoryContent( String repoId )
throws RepositoryNotFoundException, RepositoryException
{
- ManagedRepositoryContent repo = managedContentMap.get( repoId );
-
- if ( repo != null )
+ try
{
+ ManagedRepositoryContent repo = managedContentMap.get( repoId );
+
+ if ( repo != null )
+ {
+ return repo;
+ }
+
+ ManagedRepository repoConfig = managedRepositoryAdmin.getManagedRepository( repoId );
+ if ( repoConfig == null )
+ {
+ throw new RepositoryNotFoundException(
+ "Unable to find managed repository configuration for id:" + repoId );
+ }
+
+ repo = applicationContext.getBean( "managedRepositoryContent#" + repoConfig.getLayout(),
+ ManagedRepositoryContent.class );
+ repo.setRepository( repoConfig );
+ managedContentMap.put( repoId, repo );
+
return repo;
}
-
- ManagedRepositoryConfiguration repoConfig =
- archivaConfiguration.getConfiguration().findManagedRepositoryById( repoId );
- if ( repoConfig == null )
+ catch ( RepositoryAdminException e )
{
- throw new RepositoryNotFoundException( "Unable to find managed repository configuration for id:" + repoId );
+ throw new RepositoryException( e.getMessage(), e );
}
-
- repo = applicationContext.getBean( "managedRepositoryContent#" + repoConfig.getLayout(),
- ManagedRepositoryContent.class );
- repo.setRepository( repoConfig );
- managedContentMap.put( repoId, repo );
-
- return repo;
}
public RemoteRepositoryContent getRemoteRepositoryContent( String repoId )
throws RepositoryNotFoundException, RepositoryException
{
- RemoteRepositoryContent repo = remoteContentMap.get( repoId );
-
- if ( repo != null )
+ try
{
+ RemoteRepositoryContent repo = remoteContentMap.get( repoId );
+
+ if ( repo != null )
+ {
+ return repo;
+ }
+
+ RemoteRepository repoConfig = remoteRepositoryAdmin.getRemoteRepository( repoId );
+ if ( repoConfig == null )
+ {
+ throw new RepositoryNotFoundException(
+ "Unable to find remote repository configuration for id:" + repoId );
+ }
+
+ repo = applicationContext.getBean( "remoteRepositoryContent#" + repoConfig.getLayout(),
+ RemoteRepositoryContent.class );
+ repo.setRepository( repoConfig );
+ remoteContentMap.put( repoId, repo );
+
return repo;
}
-
- RemoteRepositoryConfiguration repoConfig =
- archivaConfiguration.getConfiguration().findRemoteRepositoryById( repoId );
- if ( repoConfig == null )
+ catch ( RepositoryAdminException e )
{
- throw new RepositoryNotFoundException( "Unable to find remote repository configuration for id:" + repoId );
+ throw new RepositoryException( e.getMessage(), e );
}
-
- repo = applicationContext.getBean( "remoteRepositoryContent#" + repoConfig.getLayout(),
- RemoteRepositoryContent.class );
- repo.setRepository( repoConfig );
- remoteContentMap.put( repoId, repo );
-
- return repo;
}
* under the License.
*/
+import org.apache.archiva.admin.model.managed.ManagedRepository;
import org.apache.archiva.metadata.repository.storage.maven2.DefaultArtifactMappingProvider;
import org.apache.commons.io.FileUtils;
import org.apache.maven.archiva.common.utils.PathUtil;
@Named(value = "fileTypes" )
private FileTypes filetypes;
- private ManagedRepositoryConfiguration repository;
+ private ManagedRepository repository;
public ManagedDefaultRepositoryContent()
{
return repository.getLocation();
}
- public ManagedRepositoryConfiguration getRepository()
+ public ManagedRepository getRepository()
{
return repository;
}
}
}
- public void setRepository( ManagedRepositoryConfiguration repository )
+ public void setRepository( ManagedRepository repository )
{
this.repository = repository;
}
* under the License.
*/
+import org.apache.archiva.admin.model.managed.ManagedRepository;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.maven.archiva.common.utils.PathUtil;
@Inject
private FileTypes filetypes;
- private ManagedRepositoryConfiguration repository;
+ private ManagedRepository repository;
public void deleteVersion( VersionedReference reference )
throws ContentNotFoundException
return repository.getLocation();
}
- public ManagedRepositoryConfiguration getRepository()
+ public ManagedRepository getRepository()
{
return repository;
}
}
}
- public void setRepository( ManagedRepositoryConfiguration repository )
+ public void setRepository( ManagedRepository repository )
{
this.repository = repository;
}
* under the License.
*/
+import org.apache.archiva.admin.model.remote.RemoteRepository;
import org.apache.maven.archiva.configuration.RemoteRepositoryConfiguration;
import org.apache.maven.archiva.model.ArtifactReference;
import org.apache.maven.archiva.model.RepositoryURL;
extends AbstractDefaultRepositoryContent
implements RemoteRepositoryContent
{
- private RemoteRepositoryConfiguration repository;
+ private RemoteRepository repository;
public String getId()
{
return repository.getId();
}
- public RemoteRepositoryConfiguration getRepository()
+ public RemoteRepository getRepository()
{
return repository;
}
return new RepositoryURL( repository.getUrl() );
}
- public void setRepository( RemoteRepositoryConfiguration repository )
+ public void setRepository( RemoteRepository repository )
{
this.repository = repository;
}
* under the License.
*/
+import org.apache.archiva.admin.model.remote.RemoteRepository;
import org.apache.maven.archiva.configuration.RemoteRepositoryConfiguration;
import org.apache.maven.archiva.model.ArtifactReference;
import org.apache.maven.archiva.model.RepositoryURL;
extends AbstractLegacyRepositoryContent
implements RemoteRepositoryContent
{
- private RemoteRepositoryConfiguration repository;
+ private RemoteRepository repository;
public String getId()
{
return repository.getId();
}
- public RemoteRepositoryConfiguration getRepository()
+ public RemoteRepository getRepository()
{
return repository;
}
return new RepositoryURL( repository.getUrl() );
}
- public void setRepository( RemoteRepositoryConfiguration repository )
+ public void setRepository( RemoteRepository repository )
{
this.repository = repository;
}
* under the License.
*/
+import org.apache.archiva.admin.model.managed.ManagedRepository;
+import org.apache.archiva.admin.model.remote.RemoteRepository;
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.maven.archiva.configuration.RemoteRepositoryConfiguration;
import org.junit.Rule;
@Inject
protected ApplicationContext applicationContext;
- protected ManagedRepositoryConfiguration createRepository( String id, String name, File location )
+ protected ManagedRepository createRepository( String id, String name, File location )
{
- ManagedRepositoryConfiguration repo = new ManagedRepositoryConfiguration();
+ ManagedRepository repo = new ManagedRepository();
repo.setId( id );
repo.setName( name );
repo.setLocation( location.getAbsolutePath() );
return repo;
}
- protected RemoteRepositoryConfiguration createRemoteRepository( String id, String name, String url )
+ protected RemoteRepository createRemoteRepository( String id, String name, String url )
{
- RemoteRepositoryConfiguration repo = new RemoteRepositoryConfiguration();
+ RemoteRepository repo = new RemoteRepository();
repo.setId( id );
repo.setName( name );
repo.setUrl( url );
String layout )
throws Exception
{
- ManagedRepositoryConfiguration repo = new ManagedRepositoryConfiguration();
+ ManagedRepository repo = new ManagedRepository();
repo.setId( id );
repo.setName( name );
repo.setLocation( location.getAbsolutePath() );
protected RemoteRepositoryContent createRemoteRepositoryContent( String id, String name, String url, String layout )
throws Exception
{
- RemoteRepositoryConfiguration repo = new RemoteRepositoryConfiguration();
+ RemoteRepository repo = new RemoteRepository();
repo.setId( id );
repo.setName( name );
repo.setUrl( url );
* under the License.
*/
+import org.apache.archiva.admin.model.managed.ManagedRepository;
import org.apache.maven.archiva.common.utils.VersionComparator;
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.configuration.FileType;
{
File repoDir = new File( "src/test/repositories/default-repository" );
- ManagedRepositoryConfiguration repository = createRepository( "testRepo", "Unit Test Repo", repoDir );
+ ManagedRepository repository = createRepository( "testRepo", "Unit Test Repo", repoDir );
FileType fileType =
* under the License.
*/
+import org.apache.archiva.admin.model.managed.ManagedRepository;
import org.apache.maven.archiva.common.utils.VersionComparator;
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.maven.archiva.model.ArtifactReference;
{
File repoDir = new File( "src/test/repositories/legacy-repository" );
- ManagedRepositoryConfiguration repository = createRepository( "testRepo", "Unit Test Repo", repoDir );
+ ManagedRepository repository = createRepository( "testRepo", "Unit Test Repo", repoDir );
repository.setLayout( "legacy" );
//repoContent = (ManagedRepositoryContent) lookup( ManagedRepositoryContent.class, "legacy" );
* under the License.
*/
+import org.apache.archiva.admin.model.remote.RemoteRepository;
import org.apache.maven.archiva.configuration.RemoteRepositoryConfiguration;
import org.apache.maven.archiva.model.ArtifactReference;
import org.apache.maven.archiva.repository.RemoteRepositoryContent;
public void setUp()
throws Exception
{
- RemoteRepositoryConfiguration repository = createRemoteRepository( "testRemoteRepo", "Unit Test Remote Repo",
+ RemoteRepository repository = createRemoteRepository( "testRemoteRepo", "Unit Test Remote Repo",
"http://repo1.maven.org/maven2/" );
//repoContent = (RemoteRepositoryContent) lookup( RemoteRepositoryContent.class, "default" );
* under the License.
*/
+import org.apache.archiva.admin.model.remote.RemoteRepository;
import org.apache.maven.archiva.configuration.RemoteRepositoryConfiguration;
import org.apache.maven.archiva.model.ArtifactReference;
import org.apache.maven.archiva.repository.RemoteRepositoryContent;
public void setUp()
throws Exception
{
- RemoteRepositoryConfiguration repository =
+ RemoteRepository repository =
createRemoteRepository( "testRemoteLegacyRepo", "Unit Test Remote Legacy Repo",
"http://repo1.maven.org/maven/" );
repository.setLayout( "legacy" );
* under the License.
*/
+import org.apache.archiva.admin.model.managed.ManagedRepository;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.maven.archiva.common.utils.VersionComparator;
reference.setArtifactId( artifactId );
reference.setVersion( version );
- ManagedRepositoryConfiguration repo =
+ ManagedRepository repo =
createRepository( "test-repo", "Test Repository: " + name.getMethodName(), repoRootDir );
ManagedRepositoryContent repoContent =
applicationContext.getBean( "managedRepositoryContent#default", ManagedRepositoryContent.class );
repoRoot.mkdirs();
- ManagedRepositoryConfiguration repoConfig =
+ ManagedRepository repoConfig =
createRepository( "test-repo", "Test Repository: " + name.getMethodName(), repoRoot );
ManagedRepositoryContent repoContent =
</dependency>
<dependency>
<groupId>org.apache.archiva</groupId>
- <artifactId>archiva-configuration</artifactId>
+ <artifactId>archiva-repository-admin-api</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>slf4j-simple</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>archiva-configuration</artifactId>
+ <!-- FIXME olamy : should be scope test but it depends on FileTypes
+ <scope>test</scope>
+ -->
+ </dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
* under the License.
*/
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.managed.ManagedRepository;
import org.apache.commons.collections.CollectionUtils;
import org.apache.maven.archiva.configuration.FileTypes;
-import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.maven.archiva.consumers.InvalidRepositoryContentConsumer;
import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
import org.apache.maven.archiva.consumers.RepositoryContentConsumer;
import org.codehaus.plexus.util.DirectoryWalker;
import org.springframework.stereotype.Service;
+import javax.inject.Inject;
import java.io.File;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
-import javax.inject.Inject;
/**
* DefaultRepositoryScanner
*
* @version $Id$
*/
-@Service("repositoryScanner#default")
+@Service( "repositoryScanner#default" )
public class DefaultRepositoryScanner
implements RepositoryScanner
{
private Set<RepositoryScannerInstance> inProgressScans = new LinkedHashSet<RepositoryScannerInstance>();
- public RepositoryScanStatistics scan( ManagedRepositoryConfiguration repository, long changesSince )
+ public RepositoryScanStatistics scan( ManagedRepository repository, long changesSince )
throws RepositoryScannerException
{
- List<KnownRepositoryContentConsumer> knownContentConsumers = consumerUtil.getSelectedKnownConsumers();
- List<InvalidRepositoryContentConsumer> invalidContentConsumers = consumerUtil.getSelectedInvalidConsumers();
- List<String> ignoredPatterns = filetypes.getFileTypePatterns( FileTypes.IGNORED );
+ try
+ {
+ List<KnownRepositoryContentConsumer> knownContentConsumers = consumerUtil.getSelectedKnownConsumers();
+ List<InvalidRepositoryContentConsumer> invalidContentConsumers = consumerUtil.getSelectedInvalidConsumers();
+ List<String> ignoredPatterns = filetypes.getFileTypePatterns( FileTypes.IGNORED );
- return scan( repository, knownContentConsumers, invalidContentConsumers, ignoredPatterns, changesSince );
+ return scan( repository, knownContentConsumers, invalidContentConsumers, ignoredPatterns, changesSince );
+ }
+ catch ( RepositoryAdminException e )
+ {
+ throw new RepositoryScannerException( e.getMessage(), e );
+ }
}
- public RepositoryScanStatistics scan( ManagedRepositoryConfiguration repository,
+ public RepositoryScanStatistics scan( ManagedRepository repository,
List<KnownRepositoryContentConsumer> knownContentConsumers,
List<InvalidRepositoryContentConsumer> invalidContentConsumers,
List<String> ignoredContentPatterns, long changesSince )
//create the repo if not existing to have an empty stats
if ( !repositoryBase.exists() && !repositoryBase.mkdirs() )
{
- throw new UnsupportedOperationException( "Unable to scan a repository, directory "
- + repositoryBase.getPath() + " does not exist." );
+ throw new UnsupportedOperationException(
+ "Unable to scan a repository, directory " + repositoryBase.getPath() + " does not exist." );
}
if ( !repositoryBase.isDirectory() )
{
- throw new UnsupportedOperationException( "Unable to scan a repository, path "
- + repositoryBase.getPath() + " is not a directory." );
+ throw new UnsupportedOperationException(
+ "Unable to scan a repository, path " + repositoryBase.getPath() + " is not a directory." );
}
// Setup Includes / Excludes.
dirWalker.setExcludes( allExcludes );
// Setup the Scan Instance
- RepositoryScannerInstance scannerInstance = new RepositoryScannerInstance( repository, knownContentConsumers,
- invalidContentConsumers, changesSince );
+ RepositoryScannerInstance scannerInstance =
+ new RepositoryScannerInstance( repository, knownContentConsumers, invalidContentConsumers, changesSince );
inProgressScans.add( scannerInstance );
* under the License.
*/
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.admin.ArchivaAdministration;
+import org.apache.archiva.admin.model.managed.ManagedRepository;
import org.apache.archiva.repository.scanner.functors.ConsumerProcessFileClosure;
import org.apache.archiva.repository.scanner.functors.TriggerBeginScanClosure;
import org.apache.archiva.repository.scanner.functors.TriggerScanCompletedClosure;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.functors.IfClosure;
import org.apache.maven.archiva.common.utils.BaseFile;
-import org.apache.maven.archiva.configuration.ArchivaConfiguration;
-import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
-import org.apache.maven.archiva.configuration.RepositoryScanningConfiguration;
import org.apache.maven.archiva.consumers.InvalidRepositoryContentConsumer;
import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
import org.apache.maven.archiva.consumers.functors.ConsumerWantsFilePredicate;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
+import org.springframework.stereotype.Service;
+import javax.inject.Inject;
import java.io.File;
import java.util.ArrayList;
import java.util.Date;
*
* @version $Id$
*/
+@Service("repositoryContentConsumers")
public class RepositoryContentConsumers
implements ApplicationContextAware
{
+
+ @Inject
private ApplicationContext applicationContext;
- private ArchivaConfiguration archivaConfiguration;
+ private ArchivaAdministration archivaAdministration;
private List<KnownRepositoryContentConsumer> selectedKnownConsumers;
private List<InvalidRepositoryContentConsumer> selectedInvalidConsumers;
- public RepositoryContentConsumers( ArchivaConfiguration archivaConfiguration )
+ @Inject
+ public RepositoryContentConsumers( ArchivaAdministration archivaAdministration )
{
- this.archivaConfiguration = archivaConfiguration;
+ this.archivaAdministration = archivaAdministration;
}
public void setApplicationContext( ApplicationContext applicationContext )
* @return the list of consumer ids that have been selected by the configuration.
*/
public List<String> getSelectedKnownConsumerIds()
+ throws RepositoryAdminException
{
- RepositoryScanningConfiguration scanning = archivaConfiguration.getConfiguration().getRepositoryScanning();
- return scanning.getKnownContentConsumers();
+ return archivaAdministration.getKnownContentConsumers();
}
/**
* @return the list of consumer ids that have been selected by the configuration.
*/
public List<String> getSelectedInvalidConsumerIds()
+ throws RepositoryAdminException
{
- RepositoryScanningConfiguration scanning = archivaConfiguration.getConfiguration().getRepositoryScanning();
- return scanning.getInvalidContentConsumers();
+ return archivaAdministration.getInvalidContentConsumers();
}
/**
* @return the map of String ids to {@link KnownRepositoryContentConsumer} objects.
*/
public Map<String, KnownRepositoryContentConsumer> getSelectedKnownConsumersMap()
+ throws RepositoryAdminException
{
Map<String, KnownRepositoryContentConsumer> consumerMap = new HashMap<String, KnownRepositoryContentConsumer>();
* @return the map of String ids to {@link InvalidRepositoryContentConsumer} objects.
*/
public Map<String, InvalidRepositoryContentConsumer> getSelectedInvalidConsumersMap()
+ throws RepositoryAdminException
{
Map<String, InvalidRepositoryContentConsumer> consumerMap =
new HashMap<String, InvalidRepositoryContentConsumer>();
* by the active configuration.
*/
public synchronized List<KnownRepositoryContentConsumer> getSelectedKnownConsumers()
+ throws RepositoryAdminException
{
if ( selectedKnownConsumers == null )
{
* by the active configuration.
*/
public synchronized List<InvalidRepositoryContentConsumer> getSelectedInvalidConsumers()
+ throws RepositoryAdminException
{
if ( selectedInvalidConsumers == null )
{
* @param localFile the local file to execute the consumers against.
* @param updateRelatedArtifacts TODO
*/
- public void executeConsumers( ManagedRepositoryConfiguration repository, File localFile,
- boolean updateRelatedArtifacts )
+ public void executeConsumers( ManagedRepository repository, File localFile, boolean updateRelatedArtifacts )
+ throws RepositoryAdminException
{
// Run the repository consumers
try
return new Date( System.currentTimeMillis() );
}
- public void setArchivaConfiguration( ArchivaConfiguration archivaConfiguration )
+ public void setArchivaAdministration( ArchivaAdministration archivaAdministration )
{
- this.archivaConfiguration = archivaConfiguration;
+ this.archivaAdministration = archivaAdministration;
}
}
import java.util.List;
import java.util.Map;
+import org.apache.archiva.admin.model.managed.ManagedRepository;
import org.apache.commons.collections.CollectionUtils;
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
invalidConsumers = consumers;
}
- public String toDump( ManagedRepositoryConfiguration repo )
+ public String toDump( ManagedRepository repo )
{
StringBuffer buf = new StringBuffer();
* under the License.
*/
-import java.util.Collection;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
+import org.apache.archiva.admin.model.managed.ManagedRepository;
import org.apache.maven.archiva.consumers.InvalidRepositoryContentConsumer;
import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
+import java.util.List;
+import java.util.Set;
+
/**
- * RepositoryScanner
+ * RepositoryScanner
*
* @version $Id$
*/
public interface RepositoryScanner
{
/**
- * The value to pass to {@link #scan(ManagedRepositoryConfiguration, long)} to have the scan
+ * The value to pass to {@link #scan(ManagedRepository, long)} to have the scan
* operate in a fresh fashion, with no check on changes based on timestamp.
*/
public static final long FRESH_SCAN = 0;
* <p>
* Typical Ignorable Content patterns.
* </p>
- *
+ * <p/>
* <p><strong>
* NOTE: Do not use for normal webapp or task driven repository scanning.
* </strong></p>
- *
+ * <p/>
* <p>
* These patterns are only valid for archiva-cli and archiva-converter use.
* </p>
*/
- public static final String[] IGNORABLE_CONTENT = {
- "bin/**",
- "reports/**",
- ".index",
- ".reports/**",
- ".maven/**",
- "**/.svn/**",
- "**/*snapshot-version",
- "*/website/**",
- "*/licences/**",
- "**/.htaccess",
- "**/*.html",
- "**/*.txt",
- "**/README*",
- "**/CHANGELOG*",
- "**/KEYS*" };
+ public static final String[] IGNORABLE_CONTENT =
+ { "bin/**", "reports/**", ".index", ".reports/**", ".maven/**", "**/.svn/**", "**/*snapshot-version",
+ "*/website/**", "*/licences/**", "**/.htaccess", "**/*.html", "**/*.txt", "**/README*", "**/CHANGELOG*",
+ "**/KEYS*" };
/**
* Scan the repository for content changes.
- *
+ * <p/>
* Internally, this will use the as-configured known and invalid consumer lists.
- *
- * @param repository the repository to change.
+ *
+ * @param repository the repository to change.
* @param changesSince the timestamp to use as a threshold on what is considered new or changed.
* (To have all content be taken into consideration regardless of timestamp,
- * use the {@link #FRESH_SCAN} constant)
+ * use the {@link #FRESH_SCAN} constant)
* @return the statistics for this scan.
* @throws RepositoryScannerException if there was a fundamental problem with getting the discoverer started.
*/
- public RepositoryScanStatistics scan( ManagedRepositoryConfiguration repository, long changesSince )
+ RepositoryScanStatistics scan( ManagedRepository repository, long changesSince )
throws RepositoryScannerException;
/**
* Scan the repository for content changes.
- *
+ * <p/>
* Internally, this will use the as-configured known and invalid consumer lists.
- *
- * @param repository the repository to change.
- * @param knownContentConsumers the list of consumers that follow the {@link KnownRepositoryContentConsumer}
- * interface that should be used for this scan.
- * @param invalidContentConsumers the list of consumers that follow the {@link InvalidRepositoryContentConsumer}
- * interface that should be used for this scan.
- * @param ignoredContentPatterns list of patterns that should be ignored and not sent to any consumer.
- * @param changesSince the timestamp to use as a threshold on what is considered new or changed.
- * (To have all content be taken into consideration regardless of timestamp,
- * use the {@link #FRESH_SCAN} constant)
+ *
+ * @param repository the repository to change.
+ * @param knownContentConsumers the list of consumers that follow the {@link KnownRepositoryContentConsumer}
+ * interface that should be used for this scan.
+ * @param invalidContentConsumers the list of consumers that follow the {@link InvalidRepositoryContentConsumer}
+ * interface that should be used for this scan.
+ * @param ignoredContentPatterns list of patterns that should be ignored and not sent to any consumer.
+ * @param changesSince the timestamp to use as a threshold on what is considered new or changed.
+ * (To have all content be taken into consideration regardless of timestamp,
+ * use the {@link #FRESH_SCAN} constant)
* @return the statistics for this scan.
* @throws RepositoryScannerException if there was a fundamental problem with getting the discoverer started.
*/
- public RepositoryScanStatistics scan( ManagedRepositoryConfiguration repository,
- List<KnownRepositoryContentConsumer> knownContentConsumers,
- List<InvalidRepositoryContentConsumer> invalidContentConsumers,
- List<String> ignoredContentPatterns, long changesSince )
+ RepositoryScanStatistics scan( ManagedRepository repository,
+ List<KnownRepositoryContentConsumer> knownContentConsumers,
+ List<InvalidRepositoryContentConsumer> invalidContentConsumers,
+ List<String> ignoredContentPatterns, long changesSince )
throws RepositoryScannerException;
Set<RepositoryScannerInstance> getInProgressScans();
* under the License.
*/
-import java.io.File;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
+import org.apache.archiva.admin.model.managed.ManagedRepository;
import org.apache.archiva.repository.scanner.functors.ConsumerProcessFileClosure;
import org.apache.archiva.repository.scanner.functors.TriggerBeginScanClosure;
import org.apache.archiva.repository.scanner.functors.TriggerScanCompletedClosure;
import org.apache.commons.collections.functors.IfClosure;
import org.apache.commons.lang.SystemUtils;
import org.apache.maven.archiva.common.utils.BaseFile;
-import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.maven.archiva.consumers.InvalidRepositoryContentConsumer;
import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
import org.apache.maven.archiva.consumers.functors.ConsumerWantsFilePredicate;
import org.codehaus.plexus.util.DirectoryWalkListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
/**
* RepositoryScannerInstance
*
*/
private List<InvalidRepositoryContentConsumer> invalidConsumers;
- private ManagedRepositoryConfiguration repository;
+ private ManagedRepository repository;
private RepositoryScanStatistics stats;
private Map<String, Long> consumerCounts;
- public RepositoryScannerInstance( ManagedRepositoryConfiguration repository,
+ public RepositoryScannerInstance( ManagedRepository repository,
List<KnownRepositoryContentConsumer> knownConsumerList,
List<InvalidRepositoryContentConsumer> invalidConsumerList )
{
}
}
- public RepositoryScannerInstance( ManagedRepositoryConfiguration repository,
+ public RepositoryScannerInstance( ManagedRepository repository,
List<KnownRepositoryContentConsumer> knownContentConsumers,
List<InvalidRepositoryContentConsumer> invalidContentConsumers, long changesSince )
{
log.debug( "Repository Scanner: {}", message );
}
- public ManagedRepositoryConfiguration getRepository()
+ public ManagedRepository getRepository()
{
return repository;
}
* under the License.
*/
-import java.util.Date;
-
+import org.apache.archiva.admin.model.managed.ManagedRepository;
import org.apache.commons.collections.Closure;
-import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.maven.archiva.consumers.ConsumerException;
import org.apache.maven.archiva.consumers.RepositoryContentConsumer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.util.Date;
+
/**
* TriggerBeginScanClosure
*
{
private Logger log = LoggerFactory.getLogger( TriggerBeginScanClosure.class );
- private ManagedRepositoryConfiguration repository;
+ private ManagedRepository repository;
private Date whenGathered;
private boolean executeOnEntireRepo = true;
- public TriggerBeginScanClosure( ManagedRepositoryConfiguration repository )
+ public TriggerBeginScanClosure( ManagedRepository repository )
{
this.repository = repository;
}
- public TriggerBeginScanClosure( ManagedRepositoryConfiguration repository, Date whenGathered )
+ public TriggerBeginScanClosure( ManagedRepository repository, Date whenGathered )
{
this( repository );
this.whenGathered = whenGathered;
}
- public TriggerBeginScanClosure( ManagedRepositoryConfiguration repository, Date whenGathered, boolean executeOnEntireRepo )
+ public TriggerBeginScanClosure( ManagedRepository repository, Date whenGathered, boolean executeOnEntireRepo )
{
this( repository, whenGathered );
this.executeOnEntireRepo = executeOnEntireRepo;
* under the License.
*/
+import org.apache.archiva.admin.model.managed.ManagedRepository;
import org.apache.commons.collections.Closure;
-import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.maven.archiva.consumers.RepositoryContentConsumer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
{
private Logger log = LoggerFactory.getLogger( TriggerScanCompletedClosure.class );
- private final ManagedRepositoryConfiguration repository;
+ private final ManagedRepository repository;
private boolean executeOnEntireRepo = true;
- public TriggerScanCompletedClosure( ManagedRepositoryConfiguration repository )
+ public TriggerScanCompletedClosure( ManagedRepository repository )
{
this.repository = repository;
}
- public TriggerScanCompletedClosure( ManagedRepositoryConfiguration repository, boolean executeOnEntireRepo )
+ public TriggerScanCompletedClosure( ManagedRepository repository, boolean executeOnEntireRepo )
{
this( repository );
this.executeOnEntireRepo = executeOnEntireRepo;
<context:component-scan base-package="org.apache.archiva.repository.scanner"/>
<alias name="repositoryScanner#default" alias="repositoryScanner"/>
- <bean id="repositoryContentConsumers" class="org.apache.archiva.repository.scanner.RepositoryContentConsumers" scope="prototype">
- <constructor-arg>
- <ref bean="archivaConfiguration"/>
- </constructor-arg>
- </bean>
</beans>
--- /dev/null
+package org.apache.archiva.repository.scanner;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.admin.model.AuditInformation;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.admin.ArchivaAdministration;
+import org.apache.archiva.admin.model.admin.FileType;
+import org.apache.archiva.admin.model.admin.LegacyArtifactPath;
+import org.apache.archiva.admin.model.admin.OrganisationInformation;
+import org.apache.maven.archiva.configuration.ArchivaConfiguration;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * @author Olivier Lamy
+ */
+@Service
+public class ArchivaAdministrationStub
+ implements ArchivaAdministration
+{
+
+ private ArchivaConfiguration archivaConfiguration;
+
+ public ArchivaAdministrationStub()
+ {
+ // no op
+ }
+
+
+ public ArchivaAdministrationStub( ArchivaConfiguration archivaConfiguration )
+ {
+ this.archivaConfiguration = archivaConfiguration;
+ }
+
+ public List<LegacyArtifactPath> getLegacyArtifactPaths()
+ throws RepositoryAdminException
+ {
+ return null;
+ }
+
+ public void addLegacyArtifactPath( LegacyArtifactPath legacyArtifactPath, AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+
+ }
+
+ public void deleteLegacyArtifactPath( String path, AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+
+ }
+
+ public void addFileTypePattern( String fileTypeId, String pattern, AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+
+ }
+
+ public void removeFileTypePattern( String fileTypeId, String pattern, AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+
+ }
+
+ public List<FileType> getFileTypes()
+ throws RepositoryAdminException
+ {
+ return null;
+ }
+
+ public FileType getFileType( String fileTypeId )
+ throws RepositoryAdminException
+ {
+ return null;
+ }
+
+ public void addFileType( FileType fileType, AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+
+ }
+
+ public void removeFileType( String fileTypeId, AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+
+ }
+
+ public void addKnownContentConsumer( String knownContentConsumer, AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+
+ }
+
+ public void setKnownContentConsumers( List<String> knownContentConsumers, AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+
+ }
+
+ public List<String> getKnownContentConsumers()
+ throws RepositoryAdminException
+ {
+ return archivaConfiguration.getConfiguration().getRepositoryScanning().getKnownContentConsumers();
+ }
+
+ public void removeKnownContentConsumer( String knownContentConsumer, AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+
+ }
+
+ public void addInvalidContentConsumer( String invalidContentConsumer, AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+
+ }
+
+ public void setInvalidContentConsumers( List<String> invalidContentConsumers, AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+
+ }
+
+ public List<String> getInvalidContentConsumers()
+ throws RepositoryAdminException
+ {
+ return archivaConfiguration.getConfiguration().getRepositoryScanning().getInvalidContentConsumers();
+ }
+
+ public void removeInvalidContentConsumer( String invalidContentConsumer, AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+
+ }
+
+ public OrganisationInformation getOrganisationInformation()
+ throws RepositoryAdminException
+ {
+ return null;
+ }
+
+ public void setOrganisationInformation( OrganisationInformation organisationInformation )
+ throws RepositoryAdminException
+ {
+
+ }
+}
* under the License.
*/
-import java.util.Date;
-import java.util.List;
-
-import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
+import org.apache.archiva.admin.model.managed.ManagedRepository;
import org.apache.maven.archiva.consumers.AbstractMonitoredConsumer;
import org.apache.maven.archiva.consumers.ConsumerException;
import org.apache.maven.archiva.consumers.InvalidRepositoryContentConsumer;
+import java.util.Date;
+import java.util.List;
+
/**
* InvalidScanConsumer
*
private int processCount = 0;
- public void beginScan( ManagedRepositoryConfiguration repository, Date whenGathered )
+ public void beginScan( ManagedRepository repository, Date whenGathered )
throws ConsumerException
{
/* do nothing */
}
- public void beginScan( ManagedRepositoryConfiguration repository, Date whenGathered, boolean executeOnEntireRepo )
+ public void beginScan( ManagedRepository repository, Date whenGathered, boolean executeOnEntireRepo )
throws ConsumerException
{
beginScan( repository, whenGathered );
* under the License.
*/
+import org.apache.archiva.admin.model.managed.ManagedRepository;
+import org.apache.maven.archiva.consumers.AbstractMonitoredConsumer;
+import org.apache.maven.archiva.consumers.ConsumerException;
+import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
-import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
-import org.apache.maven.archiva.consumers.AbstractMonitoredConsumer;
-import org.apache.maven.archiva.consumers.ConsumerException;
-import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
-
/**
* ScanConsumer
*
return "Scan Consumer (for testing)";
}
- public void beginScan( ManagedRepositoryConfiguration repository, Date whenGathered )
+ public void beginScan( ManagedRepository repository, Date whenGathered )
throws ConsumerException
{
/* do nothing */
}
- public void beginScan( ManagedRepositoryConfiguration repository, Date whenGathered, boolean executeOnEntireRepo )
+ public void beginScan( ManagedRepository repository, Date whenGathered, boolean executeOnEntireRepo )
throws ConsumerException
{
beginScan( repository, whenGathered );
* under the License.
*/
-import java.util.Date;
+import org.apache.archiva.admin.model.admin.ArchivaAdministration;
-import org.apache.maven.archiva.configuration.ArchivaConfiguration;
+import java.util.Date;
public class RepositoryContentConsumersStub
extends RepositoryContentConsumers
{
- public RepositoryContentConsumersStub(ArchivaConfiguration archivaConfiguration)
+ public RepositoryContentConsumersStub( ArchivaAdministration archivaAdministration )
{
- super(archivaConfiguration);
+ super( archivaAdministration );
}
@Override
{
Date startTimeForTest = new Date( System.currentTimeMillis() );
startTimeForTest.setTime( 12345678 );
-
+
return startTimeForTest;
}
}
*/
import junit.framework.TestCase;
+import org.apache.archiva.admin.model.managed.ManagedRepository;
+import org.apache.archiva.admin.model.remote.RemoteRepository;
import org.apache.commons.lang.SystemUtils;
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
-import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
-import org.apache.maven.archiva.configuration.RemoteRepositoryConfiguration;
import org.apache.maven.archiva.consumers.InvalidRepositoryContentConsumer;
import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
import org.easymock.MockControl;
@Inject
ApplicationContext applicationContext;
- protected ManagedRepositoryConfiguration createRepository( String id, String name, File location )
+ protected ManagedRepository createRepository( String id, String name, File location )
{
- ManagedRepositoryConfiguration repo = new ManagedRepositoryConfiguration();
+ ManagedRepository repo = new ManagedRepository();
repo.setId( id );
repo.setName( name );
repo.setLocation( location.getAbsolutePath() );
return repo;
}
- protected RemoteRepositoryConfiguration createRemoteRepository( String id, String name, String url )
+ protected RemoteRepository createRemoteRepository( String id, String name, String url )
{
- RemoteRepositoryConfiguration repo = new RemoteRepositoryConfiguration();
+ RemoteRepository repo = new RemoteRepository();
repo.setId( id );
repo.setName( name );
repo.setUrl( url );
throws Exception
{
+
ArchivaConfiguration configuration =
applicationContext.getBean( "archivaConfiguration#test-conf", ArchivaConfiguration.class );
- RepositoryContentConsumers consumerUtilStub = new RepositoryContentConsumersStub( configuration );
+ ArchivaAdministrationStub administrationStub = new ArchivaAdministrationStub( configuration );
+
+ RepositoryContentConsumers consumerUtilStub = new RepositoryContentConsumersStub( administrationStub );
RepositoryContentConsumers consumerUtil =
(RepositoryContentConsumers) applicationContext.getBean( "repositoryContentConsumers#test",
consumerUtilStub.setApplicationContext( context );
consumerUtilStub.setSelectedInvalidConsumers( consumerUtil.getSelectedInvalidConsumers() );
consumerUtilStub.setSelectedKnownConsumers( consumerUtil.getSelectedKnownConsumers() );
- consumerUtilStub.setArchivaConfiguration( configuration );
+ consumerUtilStub.setArchivaAdministration( administrationStub );
assertNotNull( "RepositoryContentConsumers should not be null.", consumerUtilStub );
consumers.setSelectedInvalidConsumers( Collections.singletonList( selectedInvalidConsumer ) );
- ManagedRepositoryConfiguration repo = createRepository( "id", "name", new File( "target/test-repo" ) );
+ ManagedRepository repo = createRepository( "id", "name", new File( "target/test-repo" ) );
File testFile = new File( "target/test-repo/path/to/test-file.txt" );
Date startTime = new Date( System.currentTimeMillis() );
*/
import junit.framework.TestCase;
+import org.apache.archiva.admin.model.managed.ManagedRepository;
+import org.apache.archiva.admin.model.remote.RemoteRepository;
import org.apache.commons.io.FileUtils;
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.maven.archiva.configuration.RemoteRepositoryConfiguration;
@Inject
ApplicationContext applicationContext;
- protected ManagedRepositoryConfiguration createRepository( String id, String name, File location )
+ protected ManagedRepository createRepository( String id, String name, File location )
{
- ManagedRepositoryConfiguration repo = new ManagedRepositoryConfiguration();
+ ManagedRepository repo = new ManagedRepository();
repo.setId( id );
repo.setName( name );
repo.setLocation( location.getAbsolutePath() );
return repo;
}
- protected RemoteRepositoryConfiguration createRemoteRepository( String id, String name, String url )
+ protected RemoteRepository createRemoteRepository( String id, String name, String url )
{
- RemoteRepositoryConfiguration repo = new RemoteRepositoryConfiguration();
+ RemoteRepository repo = new RemoteRepository();
repo.setId( id );
repo.setName( name );
repo.setUrl( url );
private static final String[] ARTIFACT_PATTERNS =
new String[]{ "**/*.jar", "**/*.pom", "**/*.rar", "**/*.zip", "**/*.war", "**/*.tar.gz" };
- private ManagedRepositoryConfiguration createDefaultRepository()
+ private ManagedRepository createDefaultRepository()
{
File repoDir = new File( "src/test/repositories/default-repository" );
return createRepository( "testDefaultRepo", "Test Default Repository", repoDir );
}
- private ManagedRepositoryConfiguration createSimpleRepository()
+ private ManagedRepository createSimpleRepository()
throws IOException, ParseException
{
File srcDir = new File( "src/test/repositories/simple-repository" );
return fmt.parse( timestamp ).getTime();
}
- private ManagedRepositoryConfiguration createLegacyRepository()
+ private ManagedRepository createLegacyRepository()
{
File repoDir = new File( "src/test/repositories/legacy-repository" );
assertTrue( "Legacy Test Repository should exist.", repoDir.exists() && repoDir.isDirectory() );
- ManagedRepositoryConfiguration repo = createRepository( "testLegacyRepo", "Test Legacy Repository", repoDir );
+ ManagedRepository repo = createRepository( "testLegacyRepo", "Test Legacy Repository", repoDir );
repo.setLayout( "legacy" );
return repo;
public void testTimestampRepositoryScanner()
throws Exception
{
- ManagedRepositoryConfiguration repository = createSimpleRepository();
+ ManagedRepository repository = createSimpleRepository();
List<KnownRepositoryContentConsumer> knownConsumers = new ArrayList<KnownRepositoryContentConsumer>();
KnownScanConsumer consumer = new KnownScanConsumer();
public void testTimestampRepositoryScannerFreshScan()
throws Exception
{
- ManagedRepositoryConfiguration repository = createSimpleRepository();
+ ManagedRepository repository = createSimpleRepository();
List<KnownRepositoryContentConsumer> knownConsumers = new ArrayList<KnownRepositoryContentConsumer>();
KnownScanConsumer consumer = new KnownScanConsumer();
public void testTimestampRepositoryScannerProcessUnmodified()
throws Exception
{
- ManagedRepositoryConfiguration repository = createSimpleRepository();
+ ManagedRepository repository = createSimpleRepository();
List<KnownRepositoryContentConsumer> knownConsumers = new ArrayList<KnownRepositoryContentConsumer>();
KnownScanConsumer consumer = new KnownScanConsumer();
public void testDefaultRepositoryScanner()
throws Exception
{
- ManagedRepositoryConfiguration repository = createDefaultRepository();
+ ManagedRepository repository = createDefaultRepository();
List<KnownRepositoryContentConsumer> knownConsumers = new ArrayList<KnownRepositoryContentConsumer>();
KnownScanConsumer consumer = new KnownScanConsumer();
actualArtifactPaths.add( "org/apache/testgroup/discovery/1.0/discovery-1.0.pom" );
actualArtifactPaths.add( "javax/sql/jdbc/2.0/jdbc-2.0.jar" );
- ManagedRepositoryConfiguration repository = createDefaultRepository();
+ ManagedRepository repository = createDefaultRepository();
List<KnownRepositoryContentConsumer> knownConsumers = new ArrayList<KnownRepositoryContentConsumer>();
KnownScanConsumer consumer = new KnownScanConsumer();
actualMetadataPaths.add( "javax/sql/maven-metadata-repository.xml" );
actualMetadataPaths.add( "javax/maven-metadata.xml" );
- ManagedRepositoryConfiguration repository = createDefaultRepository();
+ ManagedRepository repository = createDefaultRepository();
List<KnownRepositoryContentConsumer> knownConsumers = new ArrayList<KnownRepositoryContentConsumer>();
KnownScanConsumer knownConsumer = new KnownScanConsumer();
actualProjectPaths.add( "org/apache/maven/samplejar/1.0/samplejar-1.0.pom" );
actualProjectPaths.add( "org/apache/testgroup/discovery/1.0/discovery-1.0.pom" );
- ManagedRepositoryConfiguration repository = createDefaultRepository();
+ ManagedRepository repository = createDefaultRepository();
List<KnownRepositoryContentConsumer> knownConsumers = new ArrayList<KnownRepositoryContentConsumer>();
KnownScanConsumer consumer = new KnownScanConsumer();
actualArtifactPaths.add( "org.apache.maven.update/jars/test-not-updated-1.0.jar" );
actualArtifactPaths.add( "org.apache.maven.update/jars/test-updated-1.0.jar" );
- ManagedRepositoryConfiguration repository = createLegacyRepository();
+ ManagedRepository repository = createLegacyRepository();
List<KnownRepositoryContentConsumer> knownConsumers = new ArrayList<KnownRepositoryContentConsumer>();
KnownScanConsumer consumer = new KnownScanConsumer();
* under the License.
*/
-import java.util.Date;
-import java.util.List;
-
-import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
+import org.apache.archiva.admin.model.managed.ManagedRepository;
import org.apache.maven.archiva.consumers.AbstractMonitoredConsumer;
import org.apache.maven.archiva.consumers.ConsumerException;
import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
+import java.util.Date;
+import java.util.List;
+
/**
* SampleKnownConsumer
*
*/
private String id = "unset-id";
- public void beginScan( ManagedRepositoryConfiguration repository, Date whenGathered )
+ public void beginScan( ManagedRepository repository, Date whenGathered )
throws ConsumerException
{
/* nothing to do */
}
- public void beginScan( ManagedRepositoryConfiguration repository, Date whenGathered, boolean executeOnEntireRepo )
+ public void beginScan( ManagedRepository repository, Date whenGathered, boolean executeOnEntireRepo )
throws ConsumerException
{
beginScan( repository, whenGathered );
<property name="registry" ref="registry#configured"/>
</bean>
+ <bean name="admin-test-conf" class="org.apache.archiva.repository.scanner.ArchivaAdministrationStub">
+ <constructor-arg ref="archivaConfiguration#test-conf"/>
+ </bean>
+
<bean name="registry#configured" class="org.codehaus.redback.components.registry.commons.CommonsConfigurationRegistry">
<property name="properties">
<value>
</bean>
<bean name="repositoryContentConsumers#test" class="org.apache.archiva.repository.scanner.RepositoryContentConsumersStub">
- <constructor-arg ref="archivaConfiguration#test-conf"/>
+ <constructor-arg ref="admin-test-conf"/>
</bean>
<artifactId>archiva-scheduler-api</artifactId>
<name>Archiva Scheduler :: API</name>
<dependencies>
+ <dependency>
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>archiva-repository-admin-api</artifactId>
+ </dependency>
<dependency>
<groupId>org.codehaus.redback.components</groupId>
<artifactId>spring-taskqueue</artifactId>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-scheduler-api</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>archiva-repository-admin-api</artifactId>
+ </dependency>
<dependency>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-configuration</artifactId>
* under the License.
*/
+import org.apache.archiva.admin.model.managed.ManagedRepository;
import org.apache.archiva.common.plexusbridge.MavenIndexerUtils;
import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException;
{
ArtifactIndexingTask indexingTask = (ArtifactIndexingTask) task;
- ManagedRepositoryConfiguration repository = indexingTask.getRepository();
+ ManagedRepository repository = indexingTask.getRepository();
IndexingContext context = indexingTask.getContext();
if ( ArtifactIndexingTask.Action.FINISH.equals( indexingTask.getAction() )
}
}
- private void finishIndexingTask( ArtifactIndexingTask indexingTask, ManagedRepositoryConfiguration repository,
+ private void finishIndexingTask( ArtifactIndexingTask indexingTask, ManagedRepository repository,
IndexingContext context )
throws TaskExecutionException
{
* under the License.
*/
-import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
+import org.apache.archiva.admin.model.managed.ManagedRepository;
import org.apache.maven.index.NexusIndexer;
import org.apache.maven.index.context.IndexCreator;
import org.apache.maven.index.context.IndexingContext;
FINISH
}
- private final ManagedRepositoryConfiguration repository;
+ private final ManagedRepository repository;
private final File resourceFile;
*/
private boolean onlyUpdate = false;
- public ArtifactIndexingTask( ManagedRepositoryConfiguration repository, File resourceFile, Action action,
+ public ArtifactIndexingTask( ManagedRepository repository, File resourceFile, Action action,
IndexingContext context )
{
this.repository = repository;
this.context = context;
}
- public ArtifactIndexingTask( ManagedRepositoryConfiguration repository, File resourceFile, Action action,
+ public ArtifactIndexingTask( ManagedRepository repository, File resourceFile, Action action,
IndexingContext context, boolean executeOnEntireRepo )
{
this( repository, resourceFile, action, context );
this.executeOnEntireRepo = executeOnEntireRepo;
}
- public ArtifactIndexingTask( ManagedRepositoryConfiguration repository, File resourceFile, Action action,
+ public ArtifactIndexingTask( ManagedRepository repository, File resourceFile, Action action,
IndexingContext context, boolean executeOnEntireRepo, boolean onlyUpdate )
{
this( repository, resourceFile, action, context, executeOnEntireRepo );
return action;
}
- public ManagedRepositoryConfiguration getRepository()
+ public ManagedRepository getRepository()
{
return repository;
}
* @throws IOException
* @throws UnsupportedExistingLuceneIndexException
*/
- public static IndexingContext createContext( ManagedRepositoryConfiguration repository, NexusIndexer indexer,
+ public static IndexingContext createContext( ManagedRepository repository, NexusIndexer indexer,
List<? extends IndexCreator> indexCreators )
throws IOException, UnsupportedExistingLuceneIndexException
{
- String indexDir = repository.getIndexDir();
+ String indexDir = repository.getIndexDirectory();
File managedRepository = new File( repository.getLocation() );
File indexDirectory = null;
if ( indexDir != null && !"".equals( indexDir ) )
{
- indexDirectory = new File( repository.getIndexDir() );
+ indexDirectory = new File( repository.getIndexDirectory() );
}
else
{
*/
import junit.framework.TestCase;
+import org.apache.archiva.admin.model.managed.ManagedRepository;
import org.apache.archiva.common.plexusbridge.MavenIndexerUtils;
import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
import org.apache.commons.io.FileUtils;
@Inject
private ArchivaIndexingTaskExecutor indexingExecutor;
- private ManagedRepositoryConfiguration repositoryConfig;
-
- private Configuration configuration;
+ private ManagedRepository repositoryConfig;
private NexusIndexer indexer;
{
super.setUp();
- repositoryConfig = new ManagedRepositoryConfiguration();
+ repositoryConfig = new ManagedRepository();
repositoryConfig.setId( "test-repo" );
repositoryConfig.setLocation( "target/test-classes/test-repo" );
repositoryConfig.setLayout( "default" );
repositoryConfig.setSnapshots( false );
repositoryConfig.setReleases( true );
- configuration = new Configuration();
- configuration.addManagedRepository( repositoryConfig );
-
indexer = plexusSisuBridge.lookup( NexusIndexer.class );
ArtifactIndexingTask.createContext( repositoryConfig, indexer, mavenIndexerUtils.getAllIndexCreators() );
* under the License.
*/
+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.metadata.repository.MetadataRepository;
import org.apache.archiva.metadata.repository.MetadataRepositoryException;
import org.apache.archiva.metadata.repository.RepositorySession;
import org.apache.archiva.repository.scanner.RepositoryScanner;
import org.apache.archiva.repository.scanner.RepositoryScannerException;
import org.apache.commons.lang.StringUtils;
-import org.apache.maven.archiva.configuration.ArchivaConfiguration;
-import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
import org.codehaus.plexus.taskqueue.Task;
import org.codehaus.plexus.taskqueue.execution.TaskExecutor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.scheduling.TaskScheduler;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
-import javax.inject.Named;
import java.util.Date;
/**
*
* @version $Id$
*/
-@Service("taskExecutor#repository-scanning")
+@Service( "taskExecutor#repository-scanning" )
public class ArchivaRepositoryScanningTaskExecutor
implements TaskExecutor, Initializable
{
*
*/
@Inject
- @Named(value="archivaConfiguration#default")
- private ArchivaConfiguration archivaConfiguration;
+ private ManagedRepositoryAdmin managedRepositoryAdmin;
/**
* The repository scanner component.
- *
- *
*/
@Inject
private RepositoryScanner repoScanner;
/**
* TODO: may be different implementations
- *
*/
@Inject
private RepositorySessionFactory repositorySessionFactory;
public void executeTask( Task task )
throws TaskExecutionException
{
-
- // TODO: replace this whole class with the prescribed content scanning service/action
- // - scan repository for artifacts that do not have corresponding metadata or have been updated and
- // send events for each
- // - scan metadata for artifacts that have been removed and send events for each
- // - scan metadata for missing plugin data
- // - store information so that it can restart upon failure (publish event on the server recovery
- // queue, remove it on successful completion)
-
- this.task = task;
-
- RepositoryTask repoTask = (RepositoryTask) task;
-
- String repoId = repoTask.getRepositoryId();
- if ( StringUtils.isBlank( repoId ) )
+ try
{
- throw new TaskExecutionException( "Unable to execute RepositoryTask with blank repository Id." );
- }
+ // TODO: replace this whole class with the prescribed content scanning service/action
+ // - scan repository for artifacts that do not have corresponding metadata or have been updated and
+ // send events for each
+ // - scan metadata for artifacts that have been removed and send events for each
+ // - scan metadata for missing plugin data
+ // - store information so that it can restart upon failure (publish event on the server recovery
+ // queue, remove it on successful completion)
- ManagedRepositoryConfiguration arepo = archivaConfiguration.getConfiguration().findManagedRepositoryById(
- repoId );
+ this.task = task;
- // execute consumers on resource file if set
- if ( repoTask.getResourceFile() != null )
- {
- log.debug( "Executing task from queue with job name: {}", repoTask );
- consumers.executeConsumers( arepo, repoTask.getResourceFile(), repoTask.isUpdateRelatedArtifacts() );
- }
- else
- {
- log.info( "Executing task from queue with job name: {}", repoTask );
+ RepositoryTask repoTask = (RepositoryTask) task;
- // otherwise, execute consumers on whole repository
- if ( arepo == null )
+ String repoId = repoTask.getRepositoryId();
+ if ( StringUtils.isBlank( repoId ) )
{
- throw new TaskExecutionException(
- "Unable to execute RepositoryTask with invalid repository id: " + repoId );
+ throw new TaskExecutionException( "Unable to execute RepositoryTask with blank repository Id." );
}
- long sinceWhen = RepositoryScanner.FRESH_SCAN;
- long previousFileCount = 0;
+ ManagedRepository arepo = managedRepositoryAdmin.getManagedRepository( repoId );
- RepositorySession repositorySession = repositorySessionFactory.createSession();
- MetadataRepository metadataRepository = repositorySession.getRepository();
- try
+ // execute consumers on resource file if set
+ if ( repoTask.getResourceFile() != null )
+ {
+ log.debug( "Executing task from queue with job name: {}", repoTask );
+ consumers.executeConsumers( arepo, repoTask.getResourceFile(), repoTask.isUpdateRelatedArtifacts() );
+ }
+ else
{
- if ( !repoTask.isScanAll() )
+ log.info( "Executing task from queue with job name: {}", repoTask );
+
+ // otherwise, execute consumers on whole repository
+ if ( arepo == null )
{
- RepositoryStatistics previousStats = repositoryStatisticsManager.getLastStatistics(
- metadataRepository, repoId );
- if ( previousStats != null )
- {
- sinceWhen = previousStats.getScanStartTime().getTime();
- previousFileCount = previousStats.getTotalFileCount();
- }
+ throw new TaskExecutionException(
+ "Unable to execute RepositoryTask with invalid repository id: " + repoId );
}
- RepositoryScanStatistics stats;
+ long sinceWhen = RepositoryScanner.FRESH_SCAN;
+ long previousFileCount = 0;
+
+ RepositorySession repositorySession = repositorySessionFactory.createSession();
+ MetadataRepository metadataRepository = repositorySession.getRepository();
try
{
- stats = repoScanner.scan( arepo, sinceWhen );
- }
- catch ( RepositoryScannerException e )
- {
- throw new TaskExecutionException( "Repository error when executing repository job.", e );
- }
+ if ( !repoTask.isScanAll() )
+ {
+ RepositoryStatistics previousStats =
+ repositoryStatisticsManager.getLastStatistics( metadataRepository, repoId );
+ if ( previousStats != null )
+ {
+ sinceWhen = previousStats.getScanStartTime().getTime();
+ previousFileCount = previousStats.getTotalFileCount();
+ }
+ }
+
+ RepositoryScanStatistics stats;
+ try
+ {
+ stats = repoScanner.scan( arepo, sinceWhen );
+ }
+ catch ( RepositoryScannerException e )
+ {
+ throw new TaskExecutionException( "Repository error when executing repository job.", e );
+ }
- log.info( "Finished first scan: " + stats.toDump( arepo ) );
+ log.info( "Finished first scan: {}", stats.toDump( arepo ) );
- // further statistics will be populated by the following method
- Date endTime = new Date( stats.getWhenGathered().getTime() + stats.getDuration() );
+ // further statistics will be populated by the following method
+ Date endTime = new Date( stats.getWhenGathered().getTime() + stats.getDuration() );
- log.info( "Gathering repository statistics" );
+ log.info( "Gathering repository statistics" );
- repositoryStatisticsManager.addStatisticsAfterScan( metadataRepository, repoId, stats.getWhenGathered(),
- endTime, stats.getTotalFileCount(),
- stats.getTotalFileCount() - previousFileCount );
- repositorySession.save();
- }
- catch ( MetadataRepositoryException e )
- {
- throw new TaskExecutionException( "Unable to store updated statistics: " + e.getMessage(), e );
- }
- finally
- {
- repositorySession.close();
- }
+ repositoryStatisticsManager.addStatisticsAfterScan( metadataRepository, repoId,
+ stats.getWhenGathered(), endTime,
+ stats.getTotalFileCount(),
+ stats.getTotalFileCount() - previousFileCount );
+ repositorySession.save();
+ }
+ catch ( MetadataRepositoryException e )
+ {
+ throw new TaskExecutionException( "Unable to store updated statistics: " + e.getMessage(), e );
+ }
+ finally
+ {
+ repositorySession.close();
+ }
// log.info( "Scanning for removed repository content" );
// metadataRepository.findAllProjects();
- // FIXME: do something
+ // FIXME: do something
- log.info( "Finished repository task: {}", repoTask );
+ log.info( "Finished repository task: {}", repoTask );
- this.task = null;
+ this.task = null;
+ }
+ }
+ catch ( RepositoryAdminException e )
+ {
+ log.error( e.getMessage(), e );
+ throw new TaskExecutionException( e.getMessage(), e );
}
}
return task;
}
- public ArchivaConfiguration getArchivaConfiguration()
- {
- return archivaConfiguration;
- }
-
- public void setArchivaConfiguration( ArchivaConfiguration archivaConfiguration )
- {
- this.archivaConfiguration = archivaConfiguration;
- }
-
public RepositoryScanner getRepoScanner()
{
return repoScanner;
{
this.repositoryStatisticsManager = repositoryStatisticsManager;
}
+
+ public ManagedRepositoryAdmin getManagedRepositoryAdmin()
+ {
+ return managedRepositoryAdmin;
+ }
+
+ public void setManagedRepositoryAdmin( ManagedRepositoryAdmin managedRepositoryAdmin )
+ {
+ this.managedRepositoryAdmin = managedRepositoryAdmin;
+ }
}
--- /dev/null
+package org.apache.archiva.mock;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.admin.model.AuditInformation;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.admin.ArchivaAdministration;
+import org.apache.archiva.admin.model.admin.FileType;
+import org.apache.archiva.admin.model.admin.LegacyArtifactPath;
+import org.apache.archiva.admin.model.admin.OrganisationInformation;
+import org.apache.maven.archiva.configuration.ArchivaConfiguration;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Olivier Lamy
+ */
+public class MockArchivaAdministration
+ implements ArchivaAdministration
+{
+ private ArchivaConfiguration archivaConfiguration;
+
+ public List<LegacyArtifactPath> getLegacyArtifactPaths()
+ throws RepositoryAdminException
+ {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void addLegacyArtifactPath( LegacyArtifactPath legacyArtifactPath, AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void deleteLegacyArtifactPath( String path, AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void addFileTypePattern( String fileTypeId, String pattern, AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void removeFileTypePattern( String fileTypeId, String pattern, AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public List<FileType> getFileTypes()
+ throws RepositoryAdminException
+ {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public FileType getFileType( String fileTypeId )
+ throws RepositoryAdminException
+ {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void addFileType( FileType fileType, AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void removeFileType( String fileTypeId, AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void addKnownContentConsumer( String knownContentConsumer, AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void setKnownContentConsumers( List<String> knownContentConsumers, AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public List<String> getKnownContentConsumers()
+ throws RepositoryAdminException
+ {
+ return new ArrayList<String>(
+ getArchivaConfiguration().getConfiguration().getRepositoryScanning().getKnownContentConsumers() );
+ }
+
+ public void removeKnownContentConsumer( String knownContentConsumer, AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void addInvalidContentConsumer( String invalidContentConsumer, AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void setInvalidContentConsumers( List<String> invalidContentConsumers, AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public List<String> getInvalidContentConsumers()
+ throws RepositoryAdminException
+ {
+ return new ArrayList<String>(
+ getArchivaConfiguration().getConfiguration().getRepositoryScanning().getInvalidContentConsumers() );
+ }
+
+ public void removeInvalidContentConsumer( String invalidContentConsumer, AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public OrganisationInformation getOrganisationInformation()
+ throws RepositoryAdminException
+ {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void setOrganisationInformation( OrganisationInformation organisationInformation )
+ throws RepositoryAdminException
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public ArchivaConfiguration getArchivaConfiguration()
+ {
+ return archivaConfiguration;
+ }
+
+ public void setArchivaConfiguration( ArchivaConfiguration archivaConfiguration )
+ {
+ this.archivaConfiguration = archivaConfiguration;
+ }
+}
--- /dev/null
+package org.apache.archiva.mock;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.admin.model.AuditInformation;
+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.commons.lang.StringUtils;
+import org.apache.maven.archiva.configuration.ArchivaConfiguration;
+import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author Olivier Lamy
+ */
+public class MockManagedRepositoryAdmin
+ implements ManagedRepositoryAdmin
+{
+ private ArchivaConfiguration archivaConfiguration;
+
+ public List<ManagedRepository> getManagedRepositories()
+ throws RepositoryAdminException
+ {
+ List<ManagedRepositoryConfiguration> managedRepoConfigs =
+ getArchivaConfiguration().getConfiguration().getManagedRepositories();
+
+ List<ManagedRepository> managedRepos = new ArrayList<ManagedRepository>( managedRepoConfigs.size() );
+
+ for ( ManagedRepositoryConfiguration repoConfig : managedRepoConfigs )
+ {
+ // TODO add staging repo information back too
+ ManagedRepository repo =
+ new ManagedRepository( repoConfig.getId(), repoConfig.getName(), repoConfig.getLocation(),
+ repoConfig.getLayout(), repoConfig.isSnapshots(), repoConfig.isReleases(),
+ repoConfig.isBlockRedeployments(), repoConfig.getRefreshCronExpression(),
+ repoConfig.getIndexDir(), repoConfig.isScanned(), repoConfig.getDaysOlder(),
+ repoConfig.getRetentionCount(), repoConfig.isDeleteReleasedSnapshots() );
+
+ managedRepos.add( repo );
+ }
+
+ return managedRepos;
+ }
+
+ public Map<String, ManagedRepository> getManagedRepositoriesAsMap()
+ throws RepositoryAdminException
+ {
+ return null;
+ }
+
+ public ManagedRepository getManagedRepository( String repositoryId )
+ throws RepositoryAdminException
+ {
+ List<ManagedRepository> repos = getManagedRepositories();
+ for ( ManagedRepository repo : repos )
+ {
+ if ( StringUtils.equals( repo.getId(), repositoryId ) )
+ {
+ return repo;
+ }
+ }
+ return null;
+ }
+
+ public Boolean deleteManagedRepository( String repositoryId, AuditInformation auditInformation,
+ boolean deleteContent )
+ throws RepositoryAdminException
+ {
+ return null;
+ }
+
+ public Boolean addManagedRepository( ManagedRepository managedRepository, boolean needStageRepo,
+ AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+ return null;
+ }
+
+ public Boolean updateManagedRepository( ManagedRepository managedRepository, boolean needStageRepo,
+ AuditInformation auditInformation, boolean resetStats )
+ throws RepositoryAdminException
+ {
+ return null;
+ }
+
+ public ArchivaConfiguration getArchivaConfiguration()
+ {
+ return archivaConfiguration;
+ }
+
+ public void setArchivaConfiguration( ArchivaConfiguration archivaConfiguration )
+ {
+ this.archivaConfiguration = archivaConfiguration;
+ }
+}
--- /dev/null
+package org.apache.archiva.mock;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.admin.model.AuditInformation;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.remote.RemoteRepository;
+import org.apache.archiva.admin.model.remote.RemoteRepositoryAdmin;
+import org.apache.maven.archiva.configuration.ArchivaConfiguration;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author Olivier Lamy
+ */
+public class MockRemoteRepositoryAdmin
+ implements RemoteRepositoryAdmin
+{
+ private ArchivaConfiguration archivaConfiguration;
+
+ public List<RemoteRepository> getRemoteRepositories()
+ throws RepositoryAdminException
+ {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public RemoteRepository getRemoteRepository( String repositoryId )
+ throws RepositoryAdminException
+ {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public Boolean deleteRemoteRepository( String repositoryId, AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public Boolean addRemoteRepository( RemoteRepository remoteRepository, AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public Boolean updateRemoteRepository( RemoteRepository remoteRepository, AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public Map<String, RemoteRepository> getRemoteRepositoriesAsMap()
+ throws RepositoryAdminException
+ {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public ArchivaConfiguration getArchivaConfiguration()
+ {
+ return archivaConfiguration;
+ }
+
+ public void setArchivaConfiguration( ArchivaConfiguration archivaConfiguration )
+ {
+ this.archivaConfiguration = archivaConfiguration;
+ }
+}
* under the License.
*/
-import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
+import org.apache.archiva.admin.model.managed.ManagedRepository;
import org.apache.maven.archiva.consumers.AbstractMonitoredConsumer;
import org.apache.maven.archiva.consumers.ConsumerException;
import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
import org.springframework.stereotype.Service;
import javax.inject.Inject;
-import javax.inject.Named;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
return null;
}
- public void beginScan( ManagedRepositoryConfiguration repository, Date whenGathered )
+ public void beginScan( ManagedRepository repository, Date whenGathered )
throws ConsumerException
{
consumed.clear();
}
}
- public void beginScan( ManagedRepositoryConfiguration repository, Date whenGathered, boolean executeOnEntireRepo )
+ public void beginScan( ManagedRepository repository, Date whenGathered, boolean executeOnEntireRepo )
throws ConsumerException
{
beginScan( repository, whenGathered );
<context:annotation-config/>
<context:component-scan base-package="org.apache.archiva.metadata.repository"/>
- <bean name="taskExecutor#test-repository-scanning" class="org.apache.archiva.scheduler.repository.ArchivaRepositoryScanningTaskExecutor">
+ <bean name="managedRepoAdmin#test" class="org.apache.archiva.mock.MockManagedRepositoryAdmin">
+ <property name="archivaConfiguration" ref="archivaConfiguration#test-repository-scanning"/>
+ </bean>
+
+ <bean name="archivaAdministration#mock" class="org.apache.archiva.mock.MockArchivaAdministration">
+ <property name="archivaConfiguration" ref="archivaConfiguration#test-repository-scanning"/>
+ </bean>
+
+ <bean name="remoteRepositoryAdmin#mock" class="org.apache.archiva.mock.MockRemoteRepositoryAdmin">
<property name="archivaConfiguration" ref="archivaConfiguration#test-repository-scanning"/>
</bean>
+ <bean name="taskExecutor#test-repository-scanning" class="org.apache.archiva.scheduler.repository.ArchivaRepositoryScanningTaskExecutor">
+ <property name="managedRepositoryAdmin" ref="managedRepoAdmin#test"/>
+ </bean>
+
<bean name="repositoryContentFactory#default" class="org.apache.maven.archiva.repository.RepositoryContentFactory">
<property name="archivaConfiguration" ref="archivaConfiguration#test-repository-scanning"/>
</bean>
private String type;
- //private Date whenGathered;
+ private String url;
+
+ /**
+ * contains osgi metadata Bundle-Version if available
+ *
+ * @since 1.4
+ */
+ private String bundleVersion;
+
+ /**
+ * contains osgi metadata Bundle-SymbolicName if available
+ *
+ * @since 1.4
+ */
+ private String bundleSymbolicName;
+
+ /**
+ * contains osgi metadata Export-Package if available
+ *
+ * @since 1.4
+ */
+ private String bundleExportPackage;
+
+ /**
+ * contains osgi metadata Export-Service if available
+ *
+ * @since 1.4
+ */
+ private String bundleExportService;
+
public Artifact()
{
private boolean stageRepoNeeded;
- private String cronExpression;
+ // default value
+ private String cronExpression = "0 0 * * * ?";
private boolean resetStats;
+ private boolean scanned =false;
+
public ManagedRepository()
{
// no op
this.resetStats = resetStats;
}
+ public boolean isScanned()
+ {
+ return scanned;
+ }
+
+ public void setScanned( boolean scanned )
+ {
+ this.scanned = scanned;
+ }
+
public int hashCode()
{
int result = 17;
sb.append( "ManagedRepository" );
sb.append( "{id='" ).append( id ).append( '\'' );
sb.append( ", name='" ).append( name ).append( '\'' );
- sb.append( ", location='" ).append( location ).append( '\'' );
sb.append( ", layout='" ).append( layout ).append( '\'' );
+ sb.append( ", location='" ).append( location ).append( '\'' );
sb.append( ", snapshots=" ).append( snapshots );
sb.append( ", releases=" ).append( releases );
sb.append( ", blockRedeployments=" ).append( blockRedeployments );
sb.append( ", stageRepoNeeded=" ).append( stageRepoNeeded );
sb.append( ", cronExpression='" ).append( cronExpression ).append( '\'' );
sb.append( ", resetStats=" ).append( resetStats );
+ sb.append( ", scanned=" ).append( scanned );
sb.append( '}' );
return sb.toString();
}
</dependency>
<dependency>
<groupId>org.apache.archiva</groupId>
- <artifactId>archiva-repository-admin</artifactId>
+ <artifactId>archiva-repository-admin-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.archiva</groupId>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-scheduler-repository</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>archiva-indexer</artifactId>
+ </dependency>
<dependency>
<groupId>org.codehaus.redback</groupId>
<artifactId>redback-authorization-api</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>archiva-repository-admin-default</artifactId>
+ <scope>test</scope>
+ </dependency>
+
</dependencies>
<build>
<systemPropertyVariables>
<plexus.home>${project.build.outputDirectory}</plexus.home>
<appserver.base>${basedir}/target/appserver-base</appserver.base>
+ <targetDir>${basedir}/target/</targetDir>
</systemPropertyVariables>
</configuration>
</plugin>
* under the License.
*/
-import org.apache.archiva.admin.AuditInformation;
+import org.apache.archiva.admin.model.AuditInformation;
import org.apache.archiva.audit.AuditListener;
import org.codehaus.plexus.redback.users.User;
import org.codehaus.redback.rest.services.RedbackAuthenticationThreadLocal;
*/
import net.sf.beanlib.provider.replicator.BeanReplicator;
-import org.apache.archiva.admin.repository.RepositoryAdminException;
-import org.apache.archiva.admin.repository.admin.ArchivaAdministration;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.admin.ArchivaAdministration;
import org.apache.archiva.rest.api.model.FileType;
import org.apache.archiva.rest.api.model.LegacyArtifactPath;
import org.apache.archiva.rest.api.model.OrganisationInformation;
try
{
List<LegacyArtifactPath> legacyArtifactPaths = new ArrayList<LegacyArtifactPath>();
- for ( org.apache.archiva.admin.repository.admin.LegacyArtifactPath legacyArtifactPath : archivaAdministration.getLegacyArtifactPaths() )
+ for ( org.apache.archiva.admin.model.admin.LegacyArtifactPath legacyArtifactPath : archivaAdministration.getLegacyArtifactPaths() )
{
legacyArtifactPaths.add(
new BeanReplicator().replicateBean( legacyArtifactPath, LegacyArtifactPath.class ) );
try
{
archivaAdministration.addLegacyArtifactPath( new BeanReplicator().replicateBean( legacyArtifactPath,
- org.apache.archiva.admin.repository.admin.LegacyArtifactPath.class ),
+ org.apache.archiva.admin.model.admin.LegacyArtifactPath.class ),
getAuditInformation() );
}
catch ( RepositoryAdminException e )
{
try
{
- org.apache.archiva.admin.repository.admin.FileType fileType =
- archivaAdministration.getFileType( fileTypeId );
+ org.apache.archiva.admin.model.admin.FileType fileType = archivaAdministration.getFileType( fileTypeId );
if ( fileType == null )
{
return null;
{
try
{
- archivaAdministration.addFileType( new BeanReplicator().replicateBean( fileType,
- org.apache.archiva.admin.repository.admin.FileType.class ),
- getAuditInformation() );
+ archivaAdministration.addFileType(
+ new BeanReplicator().replicateBean( fileType, org.apache.archiva.admin.model.admin.FileType.class ),
+ getAuditInformation() );
}
catch ( RepositoryAdminException e )
{
{
try
{
- List<org.apache.archiva.admin.repository.admin.FileType> modelfileTypes =
- archivaAdministration.getFileTypes();
+ List<org.apache.archiva.admin.model.admin.FileType> modelfileTypes = archivaAdministration.getFileTypes();
if ( modelfileTypes == null || modelfileTypes.isEmpty() )
{
return Collections.emptyList();
}
List<FileType> fileTypes = new ArrayList<FileType>( modelfileTypes.size() );
- for ( org.apache.archiva.admin.repository.admin.FileType fileType : modelfileTypes )
+ for ( org.apache.archiva.admin.model.admin.FileType fileType : modelfileTypes )
{
fileTypes.add( new BeanReplicator().replicateBean( fileType, FileType.class ) );
}
{
try
{
- org.apache.archiva.admin.repository.admin.OrganisationInformation organisationInformation =
+ org.apache.archiva.admin.model.admin.OrganisationInformation organisationInformation =
archivaAdministration.getOrganisationInformation();
return organisationInformation == null
{
archivaAdministration.setOrganisationInformation(
new BeanReplicator().replicateBean( organisationInformation,
- org.apache.archiva.admin.repository.admin.OrganisationInformation.class ) );
+ org.apache.archiva.admin.model.admin.OrganisationInformation.class ) );
}
}
catch ( RepositoryAdminException e )
* under the License.
*/
-import org.apache.archiva.admin.repository.RepositoryAdminException;
-import org.apache.archiva.admin.repository.managed.ManagedRepositoryAdmin;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
import org.apache.archiva.rest.api.model.ManagedRepository;
import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
import org.apache.archiva.rest.api.services.ManagedRepositoriesService;
{
try
{
- List<org.apache.archiva.admin.repository.managed.ManagedRepository> repos =
+ List<org.apache.archiva.admin.model.managed.ManagedRepository> repos =
managedRepositoryAdmin.getManagedRepositories();
List<ManagedRepository> managedRepos = new ArrayList<ManagedRepository>( repos.size() );
- for ( org.apache.archiva.admin.repository.managed.ManagedRepository repoConfig : repos )
+ for ( org.apache.archiva.admin.model.managed.ManagedRepository repoConfig : repos )
{
// TODO staging repo too
ManagedRepository repo =
public Boolean addManagedRepository( ManagedRepository managedRepository )
throws Exception
{
- org.apache.archiva.admin.repository.managed.ManagedRepository repo =
- new org.apache.archiva.admin.repository.managed.ManagedRepository();
+ org.apache.archiva.admin.model.managed.ManagedRepository repo =
+ new org.apache.archiva.admin.model.managed.ManagedRepository();
repo.setLocation( managedRepository.getLocation() );
repo.setBlockRedeployments( managedRepository.isBlockRedeployments() );
repo.setCronExpression( managedRepository.getCronExpression() );
public Boolean updateManagedRepository( ManagedRepository managedRepository )
throws Exception
{
- org.apache.archiva.admin.repository.managed.ManagedRepository repo =
- new org.apache.archiva.admin.repository.managed.ManagedRepository();
+ org.apache.archiva.admin.model.managed.ManagedRepository repo =
+ new org.apache.archiva.admin.model.managed.ManagedRepository();
repo.setLocation( managedRepository.getLocation() );
repo.setBlockRedeployments( managedRepository.isBlockRedeployments() );
repo.setCronExpression( managedRepository.getCronExpression() );
*/
import net.sf.beanlib.provider.replicator.BeanReplicator;
-import org.apache.archiva.admin.repository.RepositoryAdminException;
-import org.apache.archiva.admin.repository.networkproxy.NetworkProxyAdmin;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.networkproxy.NetworkProxyAdmin;
import org.apache.archiva.rest.api.model.NetworkProxy;
import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
import org.apache.archiva.rest.api.services.NetworkProxyService;
try
{
List<NetworkProxy> networkProxies = new ArrayList<NetworkProxy>();
- for ( org.apache.archiva.admin.repository.networkproxy.NetworkProxy networkProxy : networkProxyAdmin.getNetworkProxies() )
+ for ( org.apache.archiva.admin.model.networkproxy.NetworkProxy networkProxy : networkProxyAdmin.getNetworkProxies() )
{
networkProxies.add( new BeanReplicator().replicateBean( networkProxy, NetworkProxy.class ) );
}
{
try
{
- org.apache.archiva.admin.repository.networkproxy.NetworkProxy networkProxy =
+ org.apache.archiva.admin.model.networkproxy.NetworkProxy networkProxy =
networkProxyAdmin.getNetworkProxy( networkProxyId );
return networkProxy == null ? null : new BeanReplicator().replicateBean( networkProxy, NetworkProxy.class );
}
return;
}
getNetworkProxyAdmin().addNetworkProxy( new BeanReplicator().replicateBean( networkProxy,
- org.apache.archiva.admin.repository.networkproxy.NetworkProxy.class ),
+ org.apache.archiva.admin.model.networkproxy.NetworkProxy.class ),
getAuditInformation() );
}
catch ( RepositoryAdminException e )
try
{
getNetworkProxyAdmin().updateNetworkProxy( new BeanReplicator().replicateBean( networkProxy,
- org.apache.archiva.admin.repository.networkproxy.NetworkProxy.class ),
+ org.apache.archiva.admin.model.networkproxy.NetworkProxy.class ),
getAuditInformation() );
}
catch ( RepositoryAdminException e )
*/
import net.sf.beanlib.provider.replicator.BeanReplicator;
-import org.apache.archiva.admin.repository.RepositoryAdminException;
-import org.apache.archiva.admin.repository.proxyconnector.ProxyConnectorAdmin;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.proxyconnector.ProxyConnectorAdmin;
import org.apache.archiva.rest.api.model.ProxyConnector;
import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
import org.apache.archiva.rest.api.services.ProxyConnectorService;
try
{
List<ProxyConnector> proxyConnectors = new ArrayList<ProxyConnector>();
- for ( org.apache.archiva.admin.repository.proxyconnector.ProxyConnector proxyConnector : proxyConnectorAdmin.getProxyConnectors() )
+ for ( org.apache.archiva.admin.model.proxyconnector.ProxyConnector proxyConnector : proxyConnectorAdmin.getProxyConnectors() )
{
proxyConnectors.add( new BeanReplicator().replicateBean( proxyConnector, ProxyConnector.class ) );
}
{
try
{
- org.apache.archiva.admin.repository.proxyconnector.ProxyConnector proxyConnector =
+ org.apache.archiva.admin.model.proxyconnector.ProxyConnector proxyConnector =
proxyConnectorAdmin.getProxyConnector( sourceRepoId, targetRepoId );
return proxyConnector == null
? null
try
{
return proxyConnectorAdmin.addProxyConnector( new BeanReplicator().replicateBean( proxyConnector,
- org.apache.archiva.admin.repository.proxyconnector.ProxyConnector.class ),
+ org.apache.archiva.admin.model.proxyconnector.ProxyConnector.class ),
getAuditInformation() );
}
catch ( RepositoryAdminException e )
try
{
return proxyConnectorAdmin.deleteProxyConnector( new BeanReplicator().replicateBean( proxyConnector,
- org.apache.archiva.admin.repository.proxyconnector.ProxyConnector.class ),
+ org.apache.archiva.admin.model.proxyconnector.ProxyConnector.class ),
getAuditInformation() );
}
catch ( RepositoryAdminException e )
try
{
return proxyConnectorAdmin.updateProxyConnector( new BeanReplicator().replicateBean( proxyConnector,
- org.apache.archiva.admin.repository.proxyconnector.ProxyConnector.class ),
+ org.apache.archiva.admin.model.proxyconnector.ProxyConnector.class ),
getAuditInformation() );
}
catch ( RepositoryAdminException e )
* under the License.
*/
-import org.apache.archiva.admin.repository.RepositoryAdminException;
-import org.apache.archiva.admin.repository.remote.RemoteRepositoryAdmin;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.remote.RemoteRepositoryAdmin;
import org.apache.archiva.rest.api.model.RemoteRepository;
import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
import org.apache.archiva.rest.api.services.RemoteRepositoriesService;
try
{
List<RemoteRepository> remoteRepositories = new ArrayList<RemoteRepository>();
- for ( org.apache.archiva.admin.repository.remote.RemoteRepository remoteRepository : remoteRepositoryAdmin.getRemoteRepositories() )
+ for ( org.apache.archiva.admin.model.remote.RemoteRepository remoteRepository : remoteRepositoryAdmin.getRemoteRepositories() )
{
RemoteRepository repo = new RemoteRepository( remoteRepository.getId(), remoteRepository.getName(),
remoteRepository.getUrl(), remoteRepository.getLayout(),
getAuditInformation() );
}
- private org.apache.archiva.admin.repository.remote.RemoteRepository getModelRemoteRepository(
+ private org.apache.archiva.admin.model.remote.RemoteRepository getModelRemoteRepository(
RemoteRepository remoteRepository )
{
- return new org.apache.archiva.admin.repository.remote.RemoteRepository( remoteRepository.getId(),
- remoteRepository.getName(),
- remoteRepository.getUrl(),
- remoteRepository.getLayout(),
- remoteRepository.getUserName(),
- remoteRepository.getPassword(),
- remoteRepository.getTimeOut() );
+ return new org.apache.archiva.admin.model.remote.RemoteRepository( remoteRepository.getId(),
+ remoteRepository.getName(),
+ remoteRepository.getUrl(),
+ remoteRepository.getLayout(),
+ remoteRepository.getUserName(),
+ remoteRepository.getPassword(),
+ remoteRepository.getTimeOut() );
}
}
* under the License.
*/
-import org.apache.archiva.admin.repository.managed.ManagedRepositoryAdmin;
-import org.apache.archiva.metadata.repository.RepositorySessionFactory;
-import org.apache.archiva.metadata.repository.stats.RepositoryStatisticsManager;
import org.apache.archiva.rest.api.services.RepositoriesService;
import org.apache.archiva.scheduler.repository.RepositoryArchivaTaskScheduler;
import org.apache.archiva.scheduler.repository.RepositoryTask;
import org.codehaus.plexus.redback.role.RoleManager;
-import org.codehaus.plexus.registry.Registry;
import org.codehaus.plexus.taskqueue.TaskQueueException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
* under the License.
*/
-import org.apache.archiva.admin.repository.RepositoryAdminException;
-import org.apache.archiva.admin.repository.group.RepositoryGroupAdmin;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.group.RepositoryGroupAdmin;
import org.apache.archiva.rest.api.model.RepositoryGroup;
import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
import org.apache.archiva.rest.api.services.RepositoryGroupService;
try
{
List<RepositoryGroup> repositoriesGroups = new ArrayList<RepositoryGroup>();
- for ( org.apache.archiva.admin.repository.group.RepositoryGroup repoGroup : repositoryGroupAdmin.getRepositoriesGroups() )
+ for ( org.apache.archiva.admin.model.group.RepositoryGroup repoGroup : repositoryGroupAdmin.getRepositoriesGroups() )
{
repositoriesGroups.add(
new RepositoryGroup( repoGroup.getId(), new ArrayList<String>( repoGroup.getRepositories() ) ) );
try
{
return repositoryGroupAdmin.addRepositoryGroup(
- new org.apache.archiva.admin.repository.group.RepositoryGroup( repoGroup.getId(), new ArrayList<String>(
+ new org.apache.archiva.admin.model.group.RepositoryGroup( repoGroup.getId(), new ArrayList<String>(
repoGroup.getRepositories() ) ), getAuditInformation() );
}
catch ( RepositoryAdminException e )
try
{
return repositoryGroupAdmin.updateRepositoryGroup(
- new org.apache.archiva.admin.repository.group.RepositoryGroup( repoGroup.getId(), new ArrayList<String>(
+ new org.apache.archiva.admin.model.group.RepositoryGroup( repoGroup.getId(), new ArrayList<String>(
repoGroup.getRepositories() ) ), getAuditInformation() );
}
catch ( RepositoryAdminException e )
--- /dev/null
+package org.apache.archiva.rest.services;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import net.sf.beanlib.provider.replicator.BeanReplicator;
+import org.apache.archiva.indexer.search.RepositorySearch;
+import org.apache.archiva.indexer.search.RepositorySearchException;
+import org.apache.archiva.indexer.search.SearchResultHit;
+import org.apache.archiva.indexer.search.SearchResultLimits;
+import org.apache.archiva.indexer.search.SearchResults;
+import org.apache.archiva.rest.api.model.Artifact;
+import org.apache.archiva.rest.api.model.Dependency;
+import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
+import org.apache.archiva.rest.api.services.SearchService;
+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.codehaus.plexus.redback.users.UserManager;
+import org.codehaus.redback.rest.services.RedbackAuthenticationThreadLocal;
+import org.codehaus.redback.rest.services.RedbackRequestInformation;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+
+import javax.inject.Inject;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * @author Olivier Lamy
+ */
+@Service( "searchService#rest" )
+public class DefaultSearchService
+ implements SearchService
+{
+
+ private Logger log = LoggerFactory.getLogger( getClass() );
+
+ @Inject
+ private RepositorySearch repositorySearch;
+
+ @Inject
+ private UserRepositories userRepositories;
+
+ public List<Artifact> quickSearch( String queryString )
+ throws ArchivaRestServiceException
+ {
+ if ( StringUtils.isBlank( queryString ) )
+ {
+ return Collections.emptyList();
+ }
+
+ SearchResultLimits limits = new SearchResultLimits( 0 );
+ List<String> observableRepoIds = getObservableRepos();
+ try
+ {
+ SearchResults searchResults =
+ repositorySearch.search( getPrincipal(), getObservableRepos(), queryString, limits,
+ Collections.<String>emptyList() );
+ return getArtifacts( searchResults );
+ }
+ catch ( RepositorySearchException e )
+ {
+ log.error( e.getMessage(), e );
+ throw new ArchivaRestServiceException( e.getMessage() );
+ }
+ }
+
+ public List<Artifact> getArtifactByChecksum( String checksum )
+ throws ArchivaRestServiceException
+ {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public List<Artifact> getArtifactVersions( String groupId, String artifactId )
+ throws ArchivaRestServiceException
+ {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public List<Dependency> getDependencies( String groupId, String artifactId, String version )
+ throws ArchivaRestServiceException
+ {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+
+ protected List<String> getObservableRepos()
+ {
+ try
+ {
+ List<String> ids = userRepositories.getObservableRepositoryIds( getPrincipal() );
+ return ids == null ? Collections.<String>emptyList() : ids;
+ }
+ catch ( PrincipalNotFoundException e )
+ {
+ log.warn( e.getMessage(), e );
+ }
+ catch ( AccessDeniedException e )
+ {
+ log.warn( e.getMessage(), e );
+ }
+ catch ( ArchivaSecurityException e )
+ {
+ log.warn( e.getMessage(), e );
+ }
+ return Collections.emptyList();
+ }
+
+ protected String getPrincipal()
+ {
+ RedbackRequestInformation redbackRequestInformation = RedbackAuthenticationThreadLocal.get();
+
+ return redbackRequestInformation == null
+ ? UserManager.GUEST_USERNAME
+ : ( redbackRequestInformation.getUser() == null
+ ? UserManager.GUEST_USERNAME
+ : redbackRequestInformation.getUser().getUsername() );
+ }
+
+ protected List<Artifact> getArtifacts( SearchResults searchResults )
+ {
+ if ( searchResults == null || searchResults.isEmpty() )
+ {
+ return Collections.emptyList();
+ }
+ List<Artifact> artifacts = new ArrayList<Artifact>( searchResults.getReturnedHitsCount() );
+ for ( SearchResultHit searchResultHit : searchResults.getHits() )
+ {
+ Artifact artifact = new BeanReplicator().replicateBean( searchResultHit, Artifact.class );
+ artifacts.add( artifact );
+ // duplicate Artifact one per available version
+ if ( searchResultHit.getVersions().size() > 1 )
+ {
+ for ( String version : searchResultHit.getVersions() )
+ {
+ Artifact versionned = new BeanReplicator().replicateBean( searchResultHit, Artifact.class );
+ versionned.setVersion( version );
+ artifacts.add( versionned );
+ }
+ }
+ }
+ return artifacts;
+ }
+}
-->
<import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
- <context:annotation-config />
+ <context:annotation-config/>
<context:component-scan
- base-package="org.apache.archiva.rest.services"/>
+ base-package="org.apache.archiva.rest.services"/>
<jaxrs:server id="archivaServices" address="/archivaServices">
<ref bean="proxyConnectorService#rest"/>
<ref bean="networkProxyService#rest"/>
<ref bean="archivaAdministrationService#default"/>
+ <ref bean="searchService#rest"/>
</jaxrs:serviceBeans>
<jaxrs:outInterceptors>
<ref bean="threadLocalUserCleaner#rest"/>
</jaxrs:outInterceptors>
- </jaxrs:server>
+ </jaxrs:server>
</beans>
\ No newline at end of file
import org.apache.archiva.rest.api.services.RemoteRepositoriesService;
import org.apache.archiva.rest.api.services.RepositoriesService;
import org.apache.archiva.rest.api.services.RepositoryGroupService;
+import org.apache.archiva.rest.api.services.SearchService;
import org.apache.cxf.jaxrs.client.JAXRSClientFactory;
import org.apache.cxf.jaxrs.client.WebClient;
import org.apache.maven.archiva.common.utils.FileUtil;
protected RepositoriesService getRepositoriesService()
{
- return JAXRSClientFactory.create( "http://localhost:" + port + "/services/archivaServices/",
- RepositoriesService.class );
+ return getRepositoriesService( null );
+ }
+
+ protected RepositoriesService getRepositoriesService( String authzHeader )
+ {
+ RepositoriesService service =
+ JAXRSClientFactory.create( "http://localhost:" + port + "/services/archivaServices/",
+ RepositoriesService.class );
+
+ if ( authzHeader != null )
+ {
+ WebClient.client( service ).header( "Authorization", authzHeader );
+ }
+ WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 100000000 );
+ return service;
}
- protected ManagedRepositoriesService getManagedRepositoriesService()
+ protected ManagedRepositoriesService getManagedRepositoriesService( String authzHeader )
{
- return JAXRSClientFactory.create( "http://localhost:" + port + "/services/archivaServices/",
- ManagedRepositoriesService.class );
+ ManagedRepositoriesService service =
+ JAXRSClientFactory.create( "http://localhost:" + port + "/services/archivaServices/",
+ ManagedRepositoriesService.class );
+
+ if ( authzHeader != null )
+ {
+ WebClient.client( service ).header( "Authorization", authzHeader );
+ }
+ WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 100000000 );
+ return service;
}
return service;
}
+ protected SearchService getSearchService( String authzHeader )
+ {
+ SearchService service =
+ JAXRSClientFactory.create( "http://localhost:" + port + "/services/archivaServices/", SearchService.class );
+
+ if ( authzHeader != null )
+ {
+ WebClient.client( service ).header( "Authorization", authzHeader );
+ }
+ WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 100000000 );
+ return service;
+
+ }
+
protected ManagedRepository getTestManagedRepository()
{
String location = new File( FileUtil.getBasedir(), "target/test-repo" ).getAbsolutePath();
import org.apache.archiva.rest.api.model.ManagedRepository;
import org.apache.archiva.rest.api.services.ManagedRepositoriesService;
-import org.apache.cxf.jaxrs.client.WebClient;
-import org.apache.maven.archiva.common.utils.FileUtil;
import org.junit.Test;
-import java.io.File;
-
/**
* @author Olivier Lamy
*/
public void addManagedRepo()
throws Exception
{
- ManagedRepositoriesService service = getManagedRepositoriesService();
- WebClient.client( service ).header( "Authorization", authorizationHeader );
- WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 300000 );
+ ManagedRepositoriesService service = getManagedRepositoriesService( authorizationHeader );
+
ManagedRepository repo = getTestManagedRepository();
if ( service.getManagedRepository( repo.getId() ) != null )
{
public void updateManagedRepo()
throws Exception
{
- ManagedRepositoriesService service = getManagedRepositoriesService();
- WebClient.client( service ).header( "Authorization", authorizationHeader );
- WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 300000 );
+ ManagedRepositoriesService service = getManagedRepositoriesService( authorizationHeader );
+
ManagedRepository repo = getTestManagedRepository();
if ( service.getManagedRepository( repo.getId() ) != null )
{
assertNotNull( repo );
assertEquals( "toto", repo.getName() );
-
service.deleteManagedRepository( repo.getId(), true );
assertNull( service.getManagedRepository( repo.getId() ) );
}
-
-
}
WebClient.client( service ).header( "Authorization", authorizationHeader );
WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 300000 );
- ManagedRepositoriesService managedRepositoriesService = getManagedRepositoriesService();
- WebClient.client( managedRepositoriesService ).header( "Authorization", authorizationHeader );
+ ManagedRepositoriesService managedRepositoriesService = getManagedRepositoriesService( authorizationHeader );
+
WebClient.getConfig( managedRepositoriesService ).getHttpConduit().getClient().setReceiveTimeout( 300000 );
String repoId = managedRepositoriesService.getManagedRepositories().get( 0 ).getId();
assertTrue( service.getRepositoriesGroups().isEmpty() );
- ManagedRepositoriesService managedRepositoriesService = getManagedRepositoriesService();
- WebClient.client( managedRepositoriesService ).header( "Authorization", authorizationHeader );
+ ManagedRepositoriesService managedRepositoriesService = getManagedRepositoriesService( authorizationHeader );
+
WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 300000 );
ManagedRepository managedRepository = getTestManagedRepository();
--- /dev/null
+package org.apache.archiva.rest.services;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.rest.api.model.Artifact;
+import org.apache.archiva.rest.api.model.ManagedRepository;
+import org.apache.archiva.rest.api.services.ManagedRepositoriesService;
+import org.apache.archiva.rest.api.services.SearchService;
+import org.apache.commons.io.FileUtils;
+import org.junit.Test;
+
+import java.io.File;
+import java.util.List;
+
+/**
+ * @author Olivier Lamy
+ */
+public class SearchServiceTest
+ extends AbstractArchivaRestTest
+{
+ @Test
+ public void quickSearchOnArtifactId()
+ throws Exception
+ {
+
+ // olamy temporary disabled due to huge refactoring
+ if (true)
+ {
+ return;
+ }
+
+ String testRepoId = "test-repo";
+ // force guest user creation if not exists
+ if ( getUserService( authorizationHeader ).getGuestUser() == null )
+ {
+ assertNotNull( getUserService( authorizationHeader ).createGuestUser() );
+ }
+
+ File targetRepo = new File( System.getProperty( "targetDir", "./target" ), "test-repo" );
+
+ if ( targetRepo.exists() )
+ {
+ FileUtils.deleteDirectory( targetRepo );
+ }
+
+ File sourceRepo = new File( "src/test/repo-with-osgi" );
+
+ FileUtils.copyDirectory( sourceRepo, targetRepo );
+
+ ManagedRepository managedRepository = new ManagedRepository();
+ managedRepository.setId( testRepoId );
+ managedRepository.setName( "test repo" );
+ managedRepository.setCronExpression( "* * * * * ?" );
+
+ managedRepository.setLocation( targetRepo.getPath() );
+
+ ManagedRepositoriesService service = getManagedRepositoriesService( authorizationHeader );
+ service.addManagedRepository( managedRepository );
+
+ getRepositoriesService( authorizationHeader ).scanRepository( testRepoId, true );
+
+ while ( getRepositoriesService( authorizationHeader ).alreadyScanning( testRepoId ) )
+ {
+ Thread.sleep( 1000 );
+ }
+
+ SearchService searchService = getSearchService( authorizationHeader );
+
+ List<Artifact> artifacts = searchService.quickSearch( "commons-logging" );
+
+ assertNotNull( artifacts );
+ assertTrue( " empty results for commons-logging search", artifacts.size() > 0 );
+ log.info( "artifacts for commons-logginf search {}", artifacts );
+
+ deleteTestRepo( testRepoId );
+ }
+
+ private void deleteTestRepo( String id )
+ throws Exception
+ {
+ if ( getManagedRepositoriesService( authorizationHeader ).getManagedRepository( id ) != null )
+ {
+ getManagedRepositoriesService( authorizationHeader ).deleteManagedRepository( id, true );
+ }
+ }
+
+}
+
+
--- /dev/null
+fc9b2f6fb941aadf5ea34f68c983b0e6bfbf2ca7
\ No newline at end of file
--- /dev/null
+6dac9733315224fc562f6268df58e92d65fd0137
\ No newline at end of file
--- /dev/null
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>commons-cli</groupId>
+ <artifactId>commons-cli</artifactId>
+ <name>CLI</name>
+ <version>1.0</version>
+ <description>Commons CLI provides a simple API for working with the command line arguments and options.</description>
+ <inceptionYear>2002</inceptionYear>
+ <developers>
+ <developer>
+ <id>jstrachan</id>
+ <name>James Strachan</name>
+ <email>jstrachan@apache.org</email>
+ <organization>SpiritSoft, Inc.</organization>
+ </developer>
+ <developer>
+ <id>bob</id>
+ <name>bob mcwhirter</name>
+ <email>bob@werken.com</email>
+ <organization>Werken</organization>
+ </developer>
+ <developer>
+ <id>jkeyes</id>
+ <name>John Keyes</name>
+ <email>jbjk@mac.com</email>
+ <organization>integral Source</organization>
+ </developer>
+ </developers>
+ <contributors>
+ <contributor>
+ <name>Berin Loritsch</name>
+ <email>bloritsch@apache.org</email>
+ <roles>
+ <role>helped in the Avalon CLI merge</role>
+ </roles>
+ </contributor>
+ <contributor>
+ <name>Peter Maddocks</name>
+ <email>peter_maddocks@hp.com</email>
+ <organization>Hewlett-Packard</organization>
+ <roles>
+ <role>supplied patch</role>
+ </roles>
+ </contributor>
+ </contributors>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <includes>
+ <include>**/*Test*.java</include>
+ </includes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ <version>1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.7</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
--- /dev/null
+bc51fd74ed7c8ccf75b3abc84b3613d6ba60eb89 /home/projects/maven/repository-staging/to-ibiblio/maven2/commons-cli/commons-cli/1.0/commons-cli-1.0.pom\r
--- /dev/null
+c40f1b459fdf90848bfeef8b5856eba6
\ No newline at end of file
--- /dev/null
+098d85a82cd48a746e1304825ba70b8df25f4131
\ No newline at end of file
--- /dev/null
+e1b1720a761ca36eaa47e1c7d802e676
\ No newline at end of file
--- /dev/null
+2e8405d4a28a0b359fbfb8855bde0fdeb0099858
\ No newline at end of file
--- /dev/null
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <name>Logging</name>
+ <version>1.0.1</version>
+ <description>Commons Logging</description>
+ <inceptionYear>2002</inceptionYear>
+ <build />
+ <dependencies>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.1.3</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>logkit</groupId>
+ <artifactId>logkit</artifactId>
+ <version>1.0.1</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.7</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
--- /dev/null
+17548178996d55e5f1561a6fd675616f /home/projects/maven/repository-staging/to-ibiblio/maven2/commons-logging/commons-logging/1.0.1/commons-logging-1.0.1.pom\r
--- /dev/null
+665b8439aad27af8b87fd3fefa11d901d851c9d5 /home/projects/maven/repository-staging/to-ibiblio/maven2/commons-logging/commons-logging/1.0.1/commons-logging-1.0.1.pom\r
--- /dev/null
+<metadata>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.0.1</version>
+</metadata>
\ No newline at end of file
--- /dev/null
+629e92df42c9735e1794689ea6e2f1e5 ./commons-logging/commons-logging/1.0.1/maven-metadata.xml\r
--- /dev/null
+e8e65fd3a18876a01e3f771015c3ad052ca01af5 /home/maven/repository-staging/to-ibiblio/maven2/commons-logging/commons-logging/1.0.1/maven-metadata.xml\r
--- /dev/null
+23bc0c53b59b1689d3cbd97de42e0a74
\ No newline at end of file
--- /dev/null
+635c2d062a007ffc71a956d45a149f0896ffed8d
\ No newline at end of file
--- /dev/null
+bdb6d37e652f164451ebd0cb10b7f645
\ No newline at end of file
--- /dev/null
+37c659e57293656ebef1a247fc6ceb738ebdfc74
\ No newline at end of file
--- /dev/null
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <name>Logging</name>
+ <version>1.0.2</version>
+ <description>Commons Logging</description>
+ <inceptionYear>2002</inceptionYear>
+ <build />
+ <dependencies>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.1.3</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>logkit</groupId>
+ <artifactId>logkit</artifactId>
+ <version>1.0.1</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.7</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
--- /dev/null
+b7e001b135a56678ac81f21ac2469957 /home/projects/maven/repository-staging/to-ibiblio/maven2/commons-logging/commons-logging/1.0.2/commons-logging-1.0.2.pom\r
--- /dev/null
+994768b3b18380239296871de3d732935d390c24 /home/projects/maven/repository-staging/to-ibiblio/maven2/commons-logging/commons-logging/1.0.2/commons-logging-1.0.2.pom\r
--- /dev/null
+<metadata>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.0.2</version>
+</metadata>
\ No newline at end of file
--- /dev/null
+32d0d002721d3669f8d01970fb7d556c ./commons-logging/commons-logging/1.0.2/maven-metadata.xml\r
--- /dev/null
+db4cb003a7eacd19b5eb9747a484f23209ea20fd /home/maven/repository-staging/to-ibiblio/maven2/commons-logging/commons-logging/1.0.2/maven-metadata.xml\r
--- /dev/null
+852ef679e9998498e7d4ac6121c45316
\ No newline at end of file
--- /dev/null
+d0773fcb73e98a977b54c70c289fe06e60d57643
\ No newline at end of file
--- /dev/null
+5bc8bdd15b18018e84fd862993aaca42
\ No newline at end of file
--- /dev/null
+760c711c71588bc273d3e56d196d720a7678cd93
\ No newline at end of file
--- /dev/null
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <name>Logging</name>
+ <version>1.0.3</version>
+ <description>Commons Logging</description>
+ <url>http://jakarta.apache.org/commons/logging/</url>
+ <inceptionYear>2001</inceptionYear>
+ <build />
+ <dependencies>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.6</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>logkit</groupId>
+ <artifactId>logkit</artifactId>
+ <version>1.0.1</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.7</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
--- /dev/null
+881dca51df49b39efb7b81b05b31278d /home/projects/maven/repository-staging/to-ibiblio/maven2/commons-logging/commons-logging/1.0.3/commons-logging-1.0.3.pom\r
--- /dev/null
+b7de43bb310eb1dbfd00a34cec30500fa13cb577 /home/projects/maven/repository-staging/to-ibiblio/maven2/commons-logging/commons-logging/1.0.3/commons-logging-1.0.3.pom\r
--- /dev/null
+<metadata>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.0.3</version>
+</metadata>
\ No newline at end of file
--- /dev/null
+15cae318f3bfbde23028f26c8ba153aa ./commons-logging/commons-logging/1.0.3/maven-metadata.xml\r
--- /dev/null
+7f4047267ed6d4679ee568460c2abea4fe8146b6 /home/maven/repository-staging/to-ibiblio/maven2/commons-logging/commons-logging/1.0.3/maven-metadata.xml\r
--- /dev/null
+f0626403d6ba70cd8758d74a4d557a86
\ No newline at end of file
--- /dev/null
+e6ab582bb54e0eba076f314d98272457261501ee
\ No newline at end of file
--- /dev/null
+0a95b57dbd6ac8fc8da869de59709477 commons-logging/commons-logging/1.0.4/commons-logging-1.0.4-sources.jar\r
--- /dev/null
+08d3424a318e818f88568dfb3b55c58583364ba9 commons-logging/commons-logging/1.0.4/commons-logging-1.0.4-sources.jar\r
--- /dev/null
+8a507817b28077e0478add944c64586a
\ No newline at end of file
--- /dev/null
+f029a2aefe2b3e1517573c580f948caac31b1056
\ No newline at end of file
--- /dev/null
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <name>Logging</name>
+ <version>1.0.4</version>
+ <description>Commons Logging is a thin adapter allowing configurable bridging to other,
+ well known logging systems.</description>
+ <url>http://jakarta.apache.org/commons/logging/</url>
+ <issueManagement>
+ <url>http://issues.apache.org/bugzilla/</url>
+ </issueManagement>
+ <ciManagement>
+ <notifiers>
+ <notifier>
+ <configuration>
+ <address>commons-dev@jakarta.apache.org</address>
+ </configuration>
+ </notifier>
+ </notifiers>
+ </ciManagement>
+ <inceptionYear>2001</inceptionYear>
+ <mailingLists>
+ <mailingList>
+ <name>Commons Dev List</name>
+ <subscribe>commons-dev-subscribe@jakarta.apache.org</subscribe>
+ <unsubscribe>commons-dev-unsubscribe@jakarta.apache.org</unsubscribe>
+ <archive>http://nagoya.apache.org/eyebrowse/SummarizeList?listName=commons-dev@jakarta.apache.org</archive>
+ </mailingList>
+ <mailingList>
+ <name>Commons User List</name>
+ <subscribe>commons-user-subscribe@jakarta.apache.org</subscribe>
+ <unsubscribe>commons-user-unsubscribe@jakarta.apache.org</unsubscribe>
+ <archive>http://nagoya.apache.org/eyebrowse/SummarizeList?listName=commons-user@jakarta.apache.org</archive>
+ </mailingList>
+ </mailingLists>
+ <developers>
+ <developer>
+ <id>morgand</id>
+ <name>Morgan Delagrange</name>
+ <email>morgand at apache dot org</email>
+ <organization>Apache</organization>
+ <roles>
+ <role>Java Developer</role>
+ </roles>
+ </developer>
+ <developer>
+ <id>rwaldhoff</id>
+ <name>Rodney Waldhoff</name>
+ <email>rwaldhoff at apache org</email>
+ <organization>Apache Software Foundation</organization>
+ </developer>
+ <developer>
+ <id>craigmcc</id>
+ <name>Craig McClanahan</name>
+ <email>craigmcc at apache org</email>
+ <organization>Apache Software Foundation</organization>
+ </developer>
+ <developer>
+ <id>sanders</id>
+ <name>Scott Sanders</name>
+ <email>sanders at apache dot org</email>
+ <organization>Apache Software Foundation</organization>
+ </developer>
+ <developer>
+ <id>rdonkin</id>
+ <name>Robert Burrell Donkin</name>
+ <email>rdonkin at apache dot org</email>
+ <organization>Apache Software Foundation</organization>
+ </developer>
+ <developer>
+ <id>donaldp</id>
+ <name>Peter Donald</name>
+ <email>donaldp at apache dot org</email>
+ <organization></organization>
+ </developer>
+ <developer>
+ <id>costin</id>
+ <name>Costin Manolache</name>
+ <email>costin at apache dot org</email>
+ <organization>Apache Software Foundation</organization>
+ </developer>
+ <developer>
+ <id>rsitze</id>
+ <name>Richard Sitze</name>
+ <email>rsitze at apache dot org</email>
+ <organization>Apache Software Foundation</organization>
+ </developer>
+ <developer>
+ <id>baliuka</id>
+ <name>Juozas Baliuka</name>
+ <email>baliuka@apache.org</email>
+ <organization></organization>
+ <roles>
+ <role>Java Developer</role>
+ </roles>
+ </developer>
+ </developers>
+ <licenses>
+ <license>
+ <name>The Apache Software License, Version 2.0</name>
+ <url>/LICENSE.txt</url>
+ </license>
+ </licenses>
+ <scm>
+ <connection>scm:cvs:pserver:anoncvs@cvs.apache.org:/home/cvspublic:jakarta-commons/logging</connection>
+ <url>http://cvs.apache.org/viewcvs/jakarta-commons/logging/</url>
+ </scm>
+ <organization>
+ <name>The Apache Software Foundation</name>
+ <url>http://jakarta.apache.org</url>
+ </organization>
+ <build>
+ <sourceDirectory>src/java</sourceDirectory>
+ <testSourceDirectory>src/test</testSourceDirectory>
+ <plugins>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <includes>
+ <include>**/AvalonLoggerTest.java</include>
+ </includes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.6</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>logkit</groupId>
+ <artifactId>logkit</artifactId>
+ <version>1.0.1</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.7</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>avalon-framework</groupId>
+ <artifactId>avalon-framework</artifactId>
+ <version>4.1.3</version>
+ <optional>true</optional>
+ </dependency>
+ </dependencies>
+ <distributionManagement>
+ <repository>
+ <id>default</id>
+ <name>Default Repository</name>
+ <url>file:///www/jakarta.apache.org/builds/jakarta-commons/logging/</url>
+ </repository>
+ <site>
+ <id>default</id>
+ <name>Default Site</name>
+ <url>scp://jakarta.apache.org//www/jakarta.apache.org/commons/logging/</url>
+ </site>
+ </distributionManagement>
+</project>
--- /dev/null
+2794b156c9725ac6382c22663ae42124 /home/projects/maven/repository-staging/to-ibiblio/maven2/commons-logging/commons-logging/1.0.4/commons-logging-1.0.4.pom\r
--- /dev/null
+7d32e7520b801cabc3dc704d2afe59d020d00c45 /home/projects/maven/repository-staging/to-ibiblio/maven2/commons-logging/commons-logging/1.0.4/commons-logging-1.0.4.pom\r
--- /dev/null
+<metadata>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.0.4</version>
+</metadata>
\ No newline at end of file
--- /dev/null
+182e4358962671c46ee4242d9dad4013 ./commons-logging/commons-logging/1.0.4/maven-metadata.xml\r
--- /dev/null
+5bb716617b7904d05e5563801f72ebcce96a161a /home/maven/repository-staging/to-ibiblio/maven2/commons-logging/commons-logging/1.0.4/maven-metadata.xml\r
--- /dev/null
+cd31f6e132e9076168247b5b62e7d4f2
\ No newline at end of file
--- /dev/null
+e3f9527e9e04311a8d411b93bc06930574070839
\ No newline at end of file
--- /dev/null
+240b26992977c9ad119efb91cb21f8f8
\ No newline at end of file
--- /dev/null
+f10838aa1add95b8cd26b8c9c07b2278c21e64b4
\ No newline at end of file
--- /dev/null
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.0</version>
+</project>
--- /dev/null
+aa412f75c470cd28468a20bd4c811e7d /home/projects/maven/repository-staging/to-ibiblio/maven2/commons-logging/commons-logging/1.0/commons-logging-1.0.pom\r
--- /dev/null
+4f58df6cca7ad7b863e8186e5dc25a8ef502e374 /home/projects/maven/repository-staging/to-ibiblio/maven2/commons-logging/commons-logging/1.0/commons-logging-1.0.pom\r
--- /dev/null
+<metadata>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.0</version>
+</metadata>
\ No newline at end of file
--- /dev/null
+d507f2c419364009f089592dfd9acea2 ./commons-logging/commons-logging/1.0/maven-metadata.xml\r
--- /dev/null
+5fe9e6d013ddf2a2f9e2b21582024d4f8e2f7ca5 /home/maven/repository-staging/to-ibiblio/maven2/commons-logging/commons-logging/1.0/maven-metadata.xml\r
--- /dev/null
+6c6e00b54fdb9e3489554b49dface8ec /home/csanchez/repository-staging/to-ibiblio/maven2/commons-logging/commons-logging/1.1/commons-logging-1.1-sources.jar\r
--- /dev/null
+5c2bd34c9a05067c72dcf08cd248630561a9c852 /home/csanchez/repository-staging/to-ibiblio/maven2/commons-logging/commons-logging/1.1/commons-logging-1.1-sources.jar\r
--- /dev/null
+6b62417e77b000a87de66ee3935edbf5 /home/csanchez/repository-staging/to-ibiblio/maven2/commons-logging/commons-logging/1.1/commons-logging-1.1.jar\r
--- /dev/null
+ba24d5de831911b684c92cd289ed5ff826271824 /home/csanchez/repository-staging/to-ibiblio/maven2/commons-logging/commons-logging/1.1/commons-logging-1.1.jar\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?><project>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <name>Logging</name>
+ <version>1.1</version>
+ <description>Commons Logging is a thin adapter allowing configurable bridging to other,
+ well known logging systems.</description>
+ <url>http://jakarta.apache.org/commons/${pom.artifactId.substring(8)}/</url>
+ <issueManagement>
+ <url>http://issues.apache.org/bugzilla/</url>
+ </issueManagement>
+ <ciManagement>
+ <notifiers>
+ <notifier>
+ <configuration>
+ <address>commons-dev@jakarta.apache.org</address>
+ </configuration>
+ </notifier>
+ </notifiers>
+ </ciManagement>
+ <inceptionYear>2001</inceptionYear>
+ <mailingLists>
+ <mailingList>
+ <name>Commons Dev List</name>
+ <subscribe>commons-dev-subscribe@jakarta.apache.org</subscribe>
+ <unsubscribe>commons-dev-unsubscribe@jakarta.apache.org</unsubscribe>
+ <archive>http://mail-archives.apache.org/mod_mbox/jakarta-commons-dev/</archive>
+ </mailingList>
+ <mailingList>
+ <name>Commons User List</name>
+ <subscribe>commons-user-subscribe@jakarta.apache.org</subscribe>
+ <unsubscribe>commons-user-unsubscribe@jakarta.apache.org</unsubscribe>
+ <archive>http://mail-archives.apache.org/mod_mbox/jakarta-commons-user/</archive>
+ </mailingList>
+ </mailingLists>
+ <developers>
+ <developer>
+ <id>morgand</id>
+ <name>Morgan Delagrange</name>
+ <email>morgand at apache dot org</email>
+ <organization>Apache</organization>
+ <roles>
+ <role>Java Developer</role>
+ </roles>
+ </developer>
+ <developer>
+ <id>rwaldhoff</id>
+ <name>Rodney Waldhoff</name>
+ <email>rwaldhoff at apache org</email>
+ <organization>Apache Software Foundation</organization>
+ </developer>
+ <developer>
+ <id>craigmcc</id>
+ <name>Craig McClanahan</name>
+ <email>craigmcc at apache org</email>
+ <organization>Apache Software Foundation</organization>
+ </developer>
+ <developer>
+ <id>sanders</id>
+ <name>Scott Sanders</name>
+ <email>sanders at apache dot org</email>
+ <organization>Apache Software Foundation</organization>
+ </developer>
+ <developer>
+ <id>rdonkin</id>
+ <name>Robert Burrell Donkin</name>
+ <email>rdonkin at apache dot org</email>
+ <organization>Apache Software Foundation</organization>
+ </developer>
+ <developer>
+ <id>donaldp</id>
+ <name>Peter Donald</name>
+ <email>donaldp at apache dot org</email>
+ <organization></organization>
+ </developer>
+ <developer>
+ <id>costin</id>
+ <name>Costin Manolache</name>
+ <email>costin at apache dot org</email>
+ <organization>Apache Software Foundation</organization>
+ </developer>
+ <developer>
+ <id>rsitze</id>
+ <name>Richard Sitze</name>
+ <email>rsitze at apache dot org</email>
+ <organization>Apache Software Foundation</organization>
+ </developer>
+ <developer>
+ <id>baliuka</id>
+ <name>Juozas Baliuka</name>
+ <email>baliuka@apache.org</email>
+ <organization></organization>
+ <roles>
+ <role>Java Developer</role>
+ </roles>
+ </developer>
+ <developer>
+ <id>skitching</id>
+ <name>Simon Kitching</name>
+ <email>skitching@apache.org</email>
+ <organization>Apache Software Foundation</organization>
+ </developer>
+ <developer>
+ <id>dennisl</id>
+ <name>Dennis Lundberg</name>
+ <email>dennisl@apache.org</email>
+ <organization>Apache Software Foundation</organization>
+ </developer>
+ <developer>
+ <id>bstansberry</id>
+ <name>Brian Stansberry</name>
+ </developer>
+ </developers>
+ <licenses>
+ <license>
+ <name>The Apache Software License, Version 2.0</name>
+ <url>/LICENSE.txt</url>
+ </license>
+ </licenses>
+ <scm>
+ <connection>scm:svn:http://svn.apache.org/repos/asf/jakarta/commons/proper/${pom.artifactId.substring(8)}/trunk</connection>
+ <url>http://svn.apache.org/repos/asf/jakarta/commons/proper/${pom.artifactId.substring(8)}/trunk</url>
+ </scm>
+ <organization>
+ <name>The Apache Software Foundation</name>
+ <url>http://jakarta.apache.org</url>
+ </organization>
+ <build>
+ <sourceDirectory>src/java</sourceDirectory>
+ <testSourceDirectory>src/test</testSourceDirectory>
+ <plugins>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <includes>
+ <include>**/AvalonLoggerTest.java</include>
+ </includes>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-xdoc-plugin</artifactId>
+ <version>1.9.2</version>
+ <configuration>
+ <comment><strong>Site Only</strong> - v1.9.2 (minimum)</comment>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.12</version>
+ </dependency>
+ <dependency>
+ <groupId>logkit</groupId>
+ <artifactId>logkit</artifactId>
+ <version>1.0.1</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>avalon-framework</groupId>
+ <artifactId>avalon-framework</artifactId>
+ <version>4.1.3</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.3</version>
+ </dependency>
+ </dependencies>
+ <distributionManagement>
+ <repository>
+ <id>default</id>
+ <name>Default Repository</name>
+ <url>file:///www/jakarta.apache.org/builds/jakarta-commons/${pom.artifactId.substring(8)}/</url>
+ </repository>
+ <site>
+ <id>default</id>
+ <name>Default Site</name>
+ <url>scp://cvs.apache.org//www/jakarta.apache.org/commons/${pom.artifactId.substring(8)}/</url>
+ </site>
+ <status>converted</status>
+ </distributionManagement>
+</project>
\ No newline at end of file
--- /dev/null
+219b31dbb491c609210577941a27a390 /home/csanchez/repository-staging/to-ibiblio/maven2/commons-logging/commons-logging/1.1/commons-logging-1.1.pom\r
--- /dev/null
+d80c5278c4f112aba0a6e987d7321676ce074a22 /home/csanchez/repository-staging/to-ibiblio/maven2/commons-logging/commons-logging/1.1/commons-logging-1.1.pom\r
--- /dev/null
+<metadata>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1</version>
+</metadata>
\ No newline at end of file
--- /dev/null
+3da6bff52079500a1deb0b50b592f6cc ./commons-logging/commons-logging/1.1/maven-metadata.xml\r
--- /dev/null
+0672ee0df7fb5db281603d0fd9328086b8b1a912 /home/maven/repository-staging/to-ibiblio/maven2/commons-logging/commons-logging/1.1/maven-metadata.xml\r
--- /dev/null
+<metadata>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.0</version>
+ <versioning>
+ <versions>
+ <version>1.0</version>
+ <version>1.0.1</version>
+ <version>1.0.2</version>
+ <version>1.0.3</version>
+ <version>1.0.4</version>
+ <version>1.1</version>
+ </versions>
+ </versioning>
+</metadata>
--- /dev/null
+57ae0a2f19db170eb6a012e255dfe329 /home/maven/repository-staging/to-ibiblio/maven2/commons-logging/commons-logging/maven-metadata.xml\r
--- /dev/null
+fa606c3906d034dd7b98ebbf0a0655479a9dc956 /home/maven/repository-staging/to-ibiblio/maven2/commons-logging/commons-logging/maven-metadata.xml\r
--- /dev/null
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>felix-parent</artifactId>
+ <version>2.1</version>
+ <relativePath>../pom/pom.xml</relativePath>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <packaging>bundle</packaging>
+ <name>Apache Felix Bundle Repository</name>
+ <description>Bundle repository service.</description>
+ <artifactId>org.apache.felix.bundlerepository</artifactId>
+ <version>1.6.6</version>
+ <scm>
+ <connection>scm:svn:http://svn.apache.org/repos/asf/felix/releases/org.apache.felix.bundlerepository-1.6.6</connection>
+ <developerConnection>scm:svn:https://svn.apache.org/repos/asf/felix/releases/org.apache.felix.bundlerepository-1.6.6</developerConnection>
+ <url>http://svn.apache.org/repos/asf/felix/releases/org.apache.felix.bundlerepository-1.6.6</url>
+ </scm>
+ <dependencies>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>org.apache.felix.utils</artifactId>
+ <version>1.1.0</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>org.osgi.service.obr</artifactId>
+ <version>1.0.2</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>org.apache.felix.shell</artifactId>
+ <version>1.4.1</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>net.sf.kxml</groupId>
+ <artifactId>kxml2</artifactId>
+ <version>2.3.0</version>
+ <optional>true</optional>
+ <exclusions>
+ <exclusion>
+ <groupId>xmlpull</groupId>
+ <artifactId>xmlpull</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ <version>4.0.0</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <version>4.1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.woodstox</groupId>
+ <artifactId>woodstox-core-asl</artifactId>
+ <version>4.0.7</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymock</artifactId>
+ <version>2.4</version>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>2.3.4</version>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Export-Package>org.apache.felix.bundlerepository;version="2.0"</Export-Package>
+ <Private-Package>
+ org.kxml2.io,
+ org.xmlpull.v1,
+ org.apache.felix.bundlerepository.impl.*,
+ org.apache.felix.utils.*
+ </Private-Package>
+ <Import-Package>!javax.xml.parsers,!org.xml.sax,org.osgi.service.log;resolution:=optional,org.osgi.service.obr;resolution:=optional,javax.xml.stream;resolution:=optional,*</Import-Package>
+ <DynamicImport-Package>org.apache.felix.shell</DynamicImport-Package>
+ <Bundle-Activator>${project.artifactId}.impl.Activator</Bundle-Activator>
+ <Bundle-DocURL>http://felix.apache.org/site/apache-felix-osgi-bundle-repository.html</Bundle-DocURL>
+ <Bundle-Url>http://felix.apache.org/site/downloads.cgi</Bundle-Url>
+ <Bundle-Source>http://felix.apache.org/site/downloads.cgi</Bundle-Source>
+ <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
+ <Bundle-Vendor>The Apache Software Foundation</Bundle-Vendor>
+ <Export-Service>org.apache.felix.bundlerepository.RepositoryAdmin,org.osgi.service.obr.RepositoryAdmin</Export-Service>
+ <_versionpolicy>[$(version;==;$(@)),$(version;+;$(@)))</_versionpolicy>
+ <Include-Resource>META-INF/LICENSE=LICENSE,META-INF/LICENSE.kxml2=LICENSE.kxml2,META-INF/NOTICE=NOTICE,META-INF/DEPENDENCIES=DEPENDENCIES</Include-Resource>
+ </instructions>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.rat</groupId>
+ <artifactId>apache-rat-plugin</artifactId>
+ <configuration>
+ <excludeSubProjects>false</excludeSubProjects>
+ <useEclipseDefaultExcludes>true</useEclipseDefaultExcludes>
+ <useMavenDefaultExcludes>true</useMavenDefaultExcludes>
+ <excludes>
+ <param>doc/*</param>
+ <param>maven-eclipse.xml</param>
+ <param>.checkstyle</param>
+ <param>.externalToolBuilders/*</param>
+ </excludes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
--- /dev/null
+#Generated by org.apache.felix.bundleplugin
+#Thu Jun 30 15:25:37 NDT 2011
+version=2.2.2
+groupId=org.apache.karaf.features
+artifactId=org.apache.karaf.features.command
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.karaf.features</groupId>
+ <artifactId>features</artifactId>
+ <version>2.2.1</version>
+ </parent>
+
+ <artifactId>org.apache.karaf.features.core</artifactId>
+ <packaging>bundle</packaging>
+ <name>Apache Karaf :: Features :: Core</name>
+ <description>This bundle is the core implementation of the Karaf features support.</description>
+
+ <properties>
+ <appendedResourcesDirectory>${basedir}/../../etc/appended-resources</appendedResourcesDirectory>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.utils</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.bundlerepository</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.karaf.shell</groupId>
+ <artifactId>org.apache.karaf.shell.console</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.karaf.shell</groupId>
+ <artifactId>org.apache.karaf.shell.obr</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework.osgi</groupId>
+ <artifactId>spring-osgi-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.servicemix.bundles</groupId>
+ <artifactId>org.apache.servicemix.bundles.junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymock</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-jdk14</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <resources>
+ <resource>
+ <directory>${project.basedir}/src/main/resources</directory>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </resource>
+ <resource>
+ <directory>${project.basedir}/src/main/resources</directory>
+ <filtering>true</filtering>
+ <includes>
+ <include>**/*.info</include>
+ </includes>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <configuration>
+ <instructions>
+ <Export-Package>org.apache.karaf.features;version=${project.version}</Export-Package>
+ <Import-Package>
+ !org.apache.karaf.features,
+ javax.management,
+ javax.management.loading,
+ org.apache.felix.service.command,
+ org.apache.felix.gogo.commands,
+ org.apache.karaf.shell.console,
+ org.osgi.service.event*;resolution:=optional,
+ *
+ </Import-Package>
+ <Private-Package>
+ org.apache.karaf.features.internal,
+ org.apache.felix.utils.version,
+ org.apache.felix.utils.manifest
+ </Private-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.karaf.features</groupId>
+ <artifactId>features</artifactId>
+ <version>2.2.2</version>
+ </parent>
+
+ <artifactId>org.apache.karaf.features.core</artifactId>
+ <packaging>bundle</packaging>
+ <name>Apache Karaf :: Features :: Core</name>
+ <description>This bundle is the core implementation of the Karaf features support.</description>
+
+ <properties>
+ <appendedResourcesDirectory>${basedir}/../../etc/appended-resources</appendedResourcesDirectory>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.utils</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.bundlerepository</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.karaf.shell</groupId>
+ <artifactId>org.apache.karaf.shell.console</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.karaf.shell</groupId>
+ <artifactId>org.apache.karaf.shell.obr</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework.osgi</groupId>
+ <artifactId>spring-osgi-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.servicemix.bundles</groupId>
+ <artifactId>org.apache.servicemix.bundles.junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymock</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-jdk14</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <resources>
+ <resource>
+ <directory>${project.basedir}/src/main/resources</directory>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </resource>
+ <resource>
+ <directory>${project.basedir}/src/main/resources</directory>
+ <filtering>true</filtering>
+ <includes>
+ <include>**/*.info</include>
+ </includes>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <configuration>
+ <instructions>
+ <Export-Package>org.apache.karaf.features;version=${project.version}</Export-Package>
+ <Import-Package>
+ !org.apache.karaf.features,
+ javax.management,
+ javax.management.loading,
+ org.apache.felix.service.command,
+ org.apache.felix.gogo.commands,
+ org.apache.karaf.shell.console,
+ org.osgi.service.event*;resolution:=optional,
+ *
+ </Import-Package>
+ <Private-Package>
+ org.apache.karaf.features.internal,
+ org.apache.felix.utils.version,
+ org.apache.felix.utils.manifest
+ </Private-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
<artifactId>archiva-plexus-bridge</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>archiva-repository-admin-api</artifactId>
+ </dependency>
+
+
+ <dependency>
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>archiva-repository-admin-default</artifactId>
+ </dependency>
+
<dependency>
<groupId>org.apache.archiva</groupId>
<artifactId>metadata-repository-api</artifactId>
* under the License.
*/
-import org.apache.archiva.admin.repository.managed.ManagedRepository;
+import org.apache.archiva.admin.model.managed.ManagedRepository;
import org.apache.archiva.web.util.ContextUtils;
import org.apache.commons.lang.StringEscapeUtils;
import org.slf4j.Logger;
\r
import com.opensymphony.xwork2.ActionContext;\r
import com.opensymphony.xwork2.ActionSupport;\r
-import org.apache.archiva.admin.AuditInformation;\r
+import org.apache.archiva.admin.model.AuditInformation;\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.archiva.security.ArchivaXworkUser;\r
+import org.apache.commons.lang.StringUtils;\r
import org.apache.struts2.ServletActionContext;\r
import org.apache.struts2.interceptor.SessionAware;\r
import org.codehaus.plexus.redback.users.User;\r
/**
* Query string.
*/
+ private String q;
// FIXME olamy WTF here??
private ArchivaConfiguration archivaConfiguration;
- private String q;
-
/**
* The Search Results.
*/
*/
import com.opensymphony.xwork2.Preparable;
-import org.apache.archiva.admin.repository.admin.ArchivaAdministration;
-import org.apache.archiva.admin.repository.admin.OrganisationInformation;
+import org.apache.archiva.admin.model.admin.ArchivaAdministration;
+import org.apache.archiva.admin.model.admin.OrganisationInformation;
import org.apache.maven.archiva.web.action.AbstractActionSupport;
import javax.inject.Inject;
*/
import com.opensymphony.xwork2.Validateable;
-import org.apache.archiva.admin.repository.RepositoryAdminException;
-import org.apache.archiva.admin.repository.admin.OrganisationInformation;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.admin.OrganisationInformation;
import org.apache.archiva.security.common.ArchivaRoleConstants;
import org.apache.commons.lang.StringUtils;
import org.codehaus.plexus.redback.rbac.Resource;
* under the License.
*/
-import org.apache.archiva.admin.repository.RepositoryAdminException;
-import org.apache.archiva.admin.repository.managed.ManagedRepositoryAdmin;
-import org.apache.archiva.admin.repository.proxyconnector.ProxyConnector;
-import org.apache.archiva.admin.repository.proxyconnector.ProxyConnectorAdmin;
-import org.apache.archiva.admin.repository.remote.RemoteRepositoryAdmin;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
+import org.apache.archiva.admin.model.proxyconnector.ProxyConnector;
+import org.apache.archiva.admin.model.proxyconnector.ProxyConnectorAdmin;
+import org.apache.archiva.admin.model.remote.RemoteRepositoryAdmin;
import org.apache.archiva.security.common.ArchivaRoleConstants;
import org.apache.commons.lang.StringUtils;
import org.apache.maven.archiva.web.action.AbstractActionSupport;
*/
import com.opensymphony.xwork2.Preparable;
-import org.apache.archiva.admin.repository.RepositoryAdminException;
-import org.apache.archiva.admin.repository.proxyconnector.ProxyConnector;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.proxyconnector.ProxyConnector;
import org.apache.commons.lang.StringUtils;
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.policies.DownloadErrorPolicy;
* under the License.
*/
-import org.apache.archiva.admin.repository.RepositoryAdminException;
-import org.apache.archiva.admin.repository.proxyconnector.ProxyConnector;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.proxyconnector.ProxyConnector;
import org.apache.commons.lang.StringUtils;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
* under the License.
*/
-import org.apache.archiva.admin.repository.RepositoryAdminException;
-import org.apache.archiva.admin.repository.proxyconnector.ProxyConnector;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.proxyconnector.ProxyConnector;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
package org.apache.maven.archiva.web.action.admin.connectors.proxy;
-import org.apache.archiva.admin.repository.RepositoryAdminException;
-import org.apache.archiva.admin.repository.proxyconnector.ProxyConnector;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.proxyconnector.ProxyConnector;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
* under the License.
*/
-import org.apache.archiva.admin.repository.RepositoryAdminException;
-import org.apache.archiva.admin.repository.proxyconnector.ProxyConnector;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.proxyconnector.ProxyConnector;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
package org.apache.maven.archiva.web.action.admin.connectors.proxy;
-import org.apache.archiva.admin.repository.RepositoryAdminException;
-import org.apache.archiva.admin.repository.proxyconnector.ProxyConnector;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.proxyconnector.ProxyConnector;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
*/
import com.opensymphony.xwork2.Preparable;
-import org.apache.archiva.admin.repository.AbstractRepository;
-import org.apache.archiva.admin.repository.RepositoryAdminException;
-import org.apache.archiva.admin.repository.proxyconnector.ProxyConnector;
+import org.apache.archiva.admin.model.AbstractRepository;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.proxyconnector.ProxyConnector;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
* under the License.
*/
-import org.apache.archiva.admin.repository.RepositoryAdminException;
-import org.apache.archiva.admin.repository.proxyconnector.ProxyConnector;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.proxyconnector.ProxyConnector;
import org.apache.commons.lang.StringUtils;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import com.opensymphony.xwork2.Preparable;
import com.opensymphony.xwork2.Validateable;
-import org.apache.archiva.admin.repository.RepositoryAdminException;
-import org.apache.archiva.admin.repository.admin.ArchivaAdministration;
-import org.apache.archiva.admin.repository.admin.LegacyArtifactPath;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.admin.ArchivaAdministration;
+import org.apache.archiva.admin.model.admin.LegacyArtifactPath;
import org.apache.commons.lang.StringUtils;
import org.apache.maven.archiva.model.ArtifactReference;
import org.apache.maven.archiva.repository.ManagedRepositoryContent;
* under the License.\r
*/\r
\r
-import org.apache.archiva.admin.repository.RepositoryAdminException;\r
-import org.apache.archiva.admin.repository.admin.ArchivaAdministration;\r
+import org.apache.archiva.admin.model.RepositoryAdminException;\r
+import org.apache.archiva.admin.model.admin.ArchivaAdministration;\r
import org.apache.maven.archiva.web.action.AbstractActionSupport;\r
import org.springframework.context.annotation.Scope;\r
import org.springframework.stereotype.Controller;\r
*/\r
\r
import com.opensymphony.xwork2.Preparable;\r
-import org.apache.archiva.admin.repository.RepositoryAdminException;\r
-import org.apache.archiva.admin.repository.admin.ArchivaAdministration;\r
-import org.apache.archiva.admin.repository.admin.LegacyArtifactPath;\r
+import org.apache.archiva.admin.model.RepositoryAdminException;\r
+import org.apache.archiva.admin.model.admin.ArchivaAdministration;\r
+import org.apache.archiva.admin.model.admin.LegacyArtifactPath;\r
import org.apache.archiva.security.common.ArchivaRoleConstants;\r
import org.apache.archiva.web.util.ContextUtils;\r
import org.apache.maven.archiva.web.action.AbstractActionSupport;\r
import com.opensymphony.xwork2.Preparable;
import com.opensymphony.xwork2.Validateable;
-import org.apache.archiva.admin.repository.RepositoryAdminException;
-import org.apache.archiva.admin.repository.networkproxy.NetworkProxy;
-import org.apache.archiva.admin.repository.networkproxy.NetworkProxyAdmin;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.networkproxy.NetworkProxy;
+import org.apache.archiva.admin.model.networkproxy.NetworkProxyAdmin;
import org.apache.archiva.security.common.ArchivaRoleConstants;
import org.apache.commons.lang.StringUtils;
import org.apache.maven.archiva.web.action.AbstractActionSupport;
*/
import com.opensymphony.xwork2.Preparable;
-import org.apache.archiva.admin.repository.networkproxy.NetworkProxy;
-import org.apache.archiva.admin.repository.networkproxy.NetworkProxyAdmin;
+import org.apache.archiva.admin.model.networkproxy.NetworkProxy;
+import org.apache.archiva.admin.model.networkproxy.NetworkProxyAdmin;
import org.apache.archiva.security.common.ArchivaRoleConstants;
import org.apache.maven.archiva.web.action.AbstractActionSupport;
import org.codehaus.plexus.redback.rbac.Resource;
package org.apache.maven.archiva.web.action.admin.repositories;
-import org.apache.archiva.admin.repository.remote.RemoteRepositoryAdmin;
+import org.apache.archiva.admin.model.remote.RemoteRepositoryAdmin;
import javax.inject.Inject;
* under the License.
*/
+import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
import org.apache.archiva.admin.repository.RepositoryCommonValidator;
-import org.apache.archiva.admin.repository.managed.ManagedRepositoryAdmin;
import org.apache.archiva.audit.Auditable;
import org.apache.archiva.security.common.ArchivaRoleConstants;
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import com.opensymphony.xwork2.Preparable;
import com.opensymphony.xwork2.Validateable;
-import org.apache.archiva.admin.repository.RepositoryAdminException;
-import org.apache.archiva.admin.repository.managed.ManagedRepository;
+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 com.opensymphony.xwork2.Preparable;
import com.opensymphony.xwork2.Validateable;
-import org.apache.archiva.admin.repository.RepositoryAdminException;
-import org.apache.archiva.admin.repository.remote.RemoteRepository;
+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;
*/
import com.opensymphony.xwork2.Preparable;
-import org.apache.archiva.admin.repository.RepositoryAdminException;
+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.springframework.context.annotation.Scope;
{
- private ManagedRepositoryConfiguration repository;
+ private ManagedRepository repository;
- private ManagedRepositoryConfiguration stagingRepository;
+ private ManagedRepository stagingRepository;
private String repoid;
- // FIXME olamy use ManagedRepositoryAdmin rather tha, directly archivaConfiguration
public void prepare()
+ throws RepositoryAdminException
{
if ( StringUtils.isNotBlank( repoid ) )
{
- this.repository = archivaConfiguration.getConfiguration().findManagedRepositoryById( repoid );
- this.stagingRepository =
- archivaConfiguration.getConfiguration().findManagedRepositoryById( repoid + "-stage" );
+ this.repository = getManagedRepositoryAdmin().getManagedRepository( repoid );
+ this.stagingRepository = getManagedRepositoryAdmin().getManagedRepository( repoid + "-stage" );
}
}
private String deleteRepository( boolean deleteContents )
{
- ManagedRepositoryConfiguration existingRepository = repository;
+ ManagedRepository existingRepository = repository;
if ( existingRepository == null )
{
addActionError( "A repository with that id does not exist" );
return result;
}
- public ManagedRepositoryConfiguration getRepository()
+ public ManagedRepository getRepository()
{
return repository;
}
- public void setRepository( ManagedRepositoryConfiguration repository )
+ public void setRepository( ManagedRepository repository )
{
this.repository = repository;
}
*/
import com.opensymphony.xwork2.Preparable;
-import org.apache.archiva.admin.repository.RepositoryAdminException;
-import org.apache.archiva.admin.repository.remote.RemoteRepository;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.remote.RemoteRepository;
import org.apache.commons.lang.StringUtils;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
*/
import com.opensymphony.xwork2.Preparable;
-import org.apache.archiva.audit.AuditEvent;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.group.RepositoryGroup;
+import org.apache.archiva.admin.model.group.RepositoryGroupAdmin;
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 javax.inject.Inject;
+
/**
* DeleteRepositoryGroupAction
- *
*/
@Controller( "deleteRepositoryGroupAction" )
@Scope( "prototype" )
extends AbstractRepositoriesAdminAction
implements Preparable
{
- private RepositoryGroupConfiguration repositoryGroup;
+ private RepositoryGroup repositoryGroup;
+
+ @Inject
+ private RepositoryGroupAdmin repositoryGroupAdmin;
private String repoGroupId;
public void prepare()
+ throws RepositoryAdminException
{
+
if ( StringUtils.isNotBlank( repoGroupId ) )
{
- this.repositoryGroup = archivaConfiguration.getConfiguration().findRepositoryGroupById( repoGroupId );
+ this.repositoryGroup = repositoryGroupAdmin.getRepositoryGroup( repoGroupId );
}
}
public String delete()
{
- Configuration config = archivaConfiguration.getConfiguration();
- RepositoryGroupConfiguration group = config.findRepositoryGroupById( repoGroupId );
- if ( group == null )
+ try
{
- addActionError( "A repository group with that id does not exist." );
+ RepositoryGroup group = repositoryGroupAdmin.getRepositoryGroup( repoGroupId );
+ if ( group == null )
+ {
+ addActionError( "A repository group with that id does not exist." );
+ return ERROR;
+ }
+
+ repositoryGroupAdmin.deleteRepositoryGroup( repoGroupId, getAuditInformation() );
+ return SUCCESS;
+ }
+ catch ( RepositoryAdminException e )
+ {
+ addActionError( "error occured " + e.getMessage() );
return ERROR;
}
-
- config.removeRepositoryGroup( group );
- triggerAuditEvent( AuditEvent.DELETE_REPO_GROUP + " " + repoGroupId );
- return saveConfiguration( config );
}
- public RepositoryGroupConfiguration getRepositoryGroup()
+ public RepositoryGroup getRepositoryGroup()
{
return repositoryGroup;
}
- public void setRepositoryGroup( RepositoryGroupConfiguration repositoryGroup )
+ public void setRepositoryGroup( RepositoryGroup repositoryGroup )
{
this.repositoryGroup = repositoryGroup;
}
import com.opensymphony.xwork2.Preparable;
import com.opensymphony.xwork2.Validateable;
-import org.apache.archiva.admin.repository.RepositoryAdminException;
-import org.apache.archiva.admin.repository.managed.ManagedRepository;
+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 com.opensymphony.xwork2.Preparable;
-import org.apache.archiva.admin.repository.RepositoryAdminException;
-import org.apache.archiva.admin.repository.remote.RemoteRepository;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.remote.RemoteRepository;
import org.apache.commons.lang.StringUtils;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
*/
import com.opensymphony.xwork2.Preparable;
-import org.apache.archiva.admin.repository.RepositoryAdminException;
-import org.apache.archiva.admin.repository.group.RepositoryGroupAdmin;
-import org.apache.archiva.admin.repository.managed.ManagedRepository;
-import org.apache.archiva.admin.repository.managed.ManagedRepositoryAdmin;
-import org.apache.archiva.admin.repository.remote.RemoteRepository;
-import org.apache.archiva.admin.repository.remote.RemoteRepositoryAdmin;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.group.RepositoryGroupAdmin;
+import org.apache.archiva.admin.model.managed.ManagedRepository;
+import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
+import org.apache.archiva.admin.model.remote.RemoteRepository;
+import org.apache.archiva.admin.model.remote.RemoteRepositoryAdmin;
import org.apache.archiva.admin.repository.utils.RepositoryComparator;
import org.apache.archiva.metadata.repository.MetadataRepository;
import org.apache.archiva.metadata.repository.MetadataRepositoryException;
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.configuration.Configuration;
import org.apache.maven.archiva.web.action.AbstractActionSupport;
import org.apache.struts2.interceptor.ServletRequestAware;
import org.codehaus.plexus.redback.rbac.Resource;
implements SecureAction, ServletRequestAware, Preparable
{
- @Inject
- private ArchivaConfiguration archivaConfiguration;
-
@Inject
private ManagedRepositoryAdmin managedRepositoryAdmin;
*/
import com.opensymphony.xwork2.Preparable;
-import org.apache.archiva.admin.repository.RepositoryAdminException;
-import org.apache.archiva.admin.repository.group.RepositoryGroup;
-import org.apache.archiva.admin.repository.group.RepositoryGroupAdmin;
-import org.apache.archiva.admin.repository.managed.ManagedRepository;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.group.RepositoryGroup;
+import org.apache.archiva.admin.model.group.RepositoryGroupAdmin;
+import org.apache.archiva.admin.model.managed.ManagedRepository;
import org.apache.archiva.web.util.ContextUtils;
import org.apache.struts2.interceptor.ServletRequestAware;
import org.springframework.context.annotation.Scope;
/**
* SortRepositoriesAction
- *
+ * FIXME remove access to archivaconfiguration
*/
@Controller( "sortRepositoriesAction" )
@Scope( "prototype" )
public class SortRepositoriesAction
extends AbstractRepositoriesAdminAction
{
+
private String repoGroupId;
private String targetRepo;
import com.opensymphony.xwork2.Preparable;
import com.opensymphony.xwork2.Validateable;
-import org.apache.archiva.admin.repository.RepositoryAdminException;
-import org.apache.archiva.admin.repository.admin.ArchivaAdministration;
-import org.apache.archiva.admin.repository.admin.FileType;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.admin.ArchivaAdministration;
+import org.apache.archiva.admin.model.admin.FileType;
import org.apache.archiva.admin.repository.admin.FiletypeToMapClosure;
import org.apache.archiva.audit.Auditable;
import org.apache.archiva.repository.scanner.RepositoryContentConsumers;
* under the License.
*/
+import net.sf.beanlib.provider.replicator.BeanReplicator;
+import org.apache.archiva.admin.model.managed.ManagedRepository;
import org.apache.archiva.metadata.model.ArtifactMetadata;
import org.apache.archiva.metadata.repository.MetadataRepository;
import org.apache.archiva.metadata.repository.RepositorySession;
Configuration config = createConfiguration();
ManagedRepositoryContent repoContent = new ManagedDefaultRepositoryContent();
- repoContent.setRepository( config.findManagedRepositoryById( REPOSITORY_ID ) );
+ repoContent.setRepository(
+ new BeanReplicator().replicateBean( config.findManagedRepositoryById( REPOSITORY_ID ),
+ ManagedRepository.class ) );
configurationControl.expectAndReturn( configuration.getConfiguration(), config );
repositoryFactoryControl.expectAndReturn( repositoryFactory.getManagedRepositoryContent( REPOSITORY_ID ),
*/
import com.opensymphony.xwork2.Action;
+import net.sf.beanlib.provider.replicator.BeanReplicator;
+import org.apache.archiva.admin.model.managed.ManagedRepository;
import org.apache.archiva.metadata.model.ArtifactMetadata;
import org.apache.archiva.metadata.model.Dependency;
import org.apache.archiva.metadata.model.MailingList;
private static final String TEST_SNAPSHOT_VERSION = "1.0-SNAPSHOT";
private static final String TEST_TS_SNAPSHOT_VERSION = "1.0-20091120.111111-1";
-
+
private static final String TEST_NAMESPACE = "namespace";
private static final String OTHER_TEST_REPO = "first-repo";
private static final String TEST_TYPE = "jar";
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+ action = (ShowArtifactAction) getActionProxy( "/showArtifact.action" ).getAction();
+
+ metadataResolver = new TestMetadataResolver();
+ MetadataRepository repo = mock( MetadataRepository.class );
+ RepositorySession repositorySession = mock( RepositorySession.class );
+ when( repositorySession.getResolver() ).thenReturn( metadataResolver );
+ when( repositorySession.getRepository() ).thenReturn( repo );
+ TestRepositorySessionFactory repositorySessionFactory =
+ applicationContext.getBean( "repositorySessionFactory#test", TestRepositorySessionFactory.class );
+ repositorySessionFactory.setRepositorySession( repositorySession );
+
+ RepositoryContentFactory factory = mock( RepositoryContentFactory.class );
+
+ action.setRepositoryFactory( factory );
+
+ ManagedRepository config = new ManagedRepository();
+ config.setId( TEST_REPO );
+ config.setLocation( new File( "target/test-repo" ).getAbsolutePath() );
+
+ ManagedRepositoryContent content = new ManagedDefaultRepositoryContent();
+ content.setRepository( config );
+ when( factory.getManagedRepositoryContent( TEST_REPO ) ).thenReturn( content );
+
+ ArchivaConfiguration archivaConfig = mock( ArchivaConfiguration.class );
+
+ Configuration configuration = new Configuration();
+ configuration.addManagedRepository(
+ new BeanReplicator().replicateBean( config, ManagedRepositoryConfiguration.class ) );
+ when( archivaConfig.getConfiguration() ).thenReturn( configuration );
+
+ when( factory.getArchivaConfiguration() ).thenReturn( archivaConfig );
+
+ }
+
public void testInstantiation()
{
assertFalse( action == getActionProxy( "/showArtifact.action" ).getAction() );
assertNull( action.getMailingLists() );
assertTrue( action.getArtifacts().isEmpty() );
}
-
+
public void testMetadataHasRepositoryFacetProblem()
{
String errMsg = "Error in resolving artifact's parent POM file: Sample Parent POM not found";
- ProjectVersionMetadata metaData = createProjectModel(TEST_SNAPSHOT_VERSION);
- metaData.addFacet( createRepositoryProblemFacet( TEST_REPO, errMsg,
- TEST_GROUP_ID, TEST_SNAPSHOT_VERSION, TEST_NAMESPACE ) );
-
-
+ ProjectVersionMetadata metaData = createProjectModel( TEST_SNAPSHOT_VERSION );
+ metaData.addFacet(
+ createRepositoryProblemFacet( TEST_REPO, errMsg, TEST_GROUP_ID, TEST_SNAPSHOT_VERSION, TEST_NAMESPACE ) );
+
metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, metaData );
-
+
metadataResolver.setArtifacts( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, TEST_SNAPSHOT_VERSION,
- TEST_SNAPSHOT_ARTIFACTS );
+ TEST_SNAPSHOT_ARTIFACTS );
action.setGroupId( TEST_GROUP_ID );
action.setArtifactId( TEST_ARTIFACT_ID );
action.setVersion( TEST_SNAPSHOT_VERSION );
String result = action.artifact();
-
+
assertEquals( Action.SUCCESS, result );
assertTrue( action.hasActionErrors() );
assertFalse( action.hasActionMessages() );
assertEquals( "Artifact metadata is incomplete: " + errMsg, action.getActionErrors().toArray()[0].toString() );
}
-
+
public void testMetadataIncomplete()
{
- ProjectVersionMetadata metaData = createProjectModel(TEST_SNAPSHOT_VERSION);
+ ProjectVersionMetadata metaData = createProjectModel( TEST_SNAPSHOT_VERSION );
metaData.setIncomplete( true );
-
+
metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, metaData );
-
+
metadataResolver.setArtifacts( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, TEST_SNAPSHOT_VERSION,
- TEST_SNAPSHOT_ARTIFACTS );
+ TEST_SNAPSHOT_ARTIFACTS );
action.setGroupId( TEST_GROUP_ID );
action.setArtifactId( TEST_ARTIFACT_ID );
- action.setVersion( TEST_SNAPSHOT_VERSION );;
+ action.setVersion( TEST_SNAPSHOT_VERSION );
+ ;
String result = action.artifact();
-
+
assertEquals( Action.SUCCESS, result );
assertTrue( action.hasActionErrors() );
assertTrue( action.getActionErrors().isEmpty() );
assertTrue( action.getActionMessages().isEmpty() );
}
-
- private RepositoryProblemFacet createRepositoryProblemFacet( String repoId, String errMsg, String projectId, String projectVersion, String namespace )
+
+ private RepositoryProblemFacet createRepositoryProblemFacet( String repoId, String errMsg, String projectId,
+ String projectVersion, String namespace )
{
RepositoryProblemFacet repoProblemFacet = new RepositoryProblemFacet();
repoProblemFacet.setRepositoryId( repoId );
repoProblemFacet.setNamespace( namespace );
return repoProblemFacet;
}
-
- protected void setUp()
- throws Exception
- {
- super.setUp();
- action = (ShowArtifactAction) getActionProxy( "/showArtifact.action" ).getAction();
-
- metadataResolver = new TestMetadataResolver();
- MetadataRepository repo = mock( MetadataRepository.class );
- RepositorySession repositorySession = mock( RepositorySession.class );
- when( repositorySession.getResolver() ).thenReturn( metadataResolver );
- when( repositorySession.getRepository() ).thenReturn( repo );
- TestRepositorySessionFactory repositorySessionFactory =
- applicationContext.getBean( "repositorySessionFactory#test", TestRepositorySessionFactory.class );
- repositorySessionFactory.setRepositorySession( repositorySession );
-
- RepositoryContentFactory factory = mock( RepositoryContentFactory.class );
-
- action.setRepositoryFactory( factory );
-
- ManagedRepositoryConfiguration config = new ManagedRepositoryConfiguration();
- config.setId( TEST_REPO );
- config.setLocation( new File( "target/test-repo" ).getAbsolutePath() );
-
- ManagedRepositoryContent content = new ManagedDefaultRepositoryContent();
- content.setRepository( config );
- when( factory.getManagedRepositoryContent( TEST_REPO ) ).thenReturn( content );
-
- ArchivaConfiguration archivaConfig = mock( ArchivaConfiguration.class );
-
- Configuration configuration = new Configuration();
- configuration.addManagedRepository( config );
- when( archivaConfig.getConfiguration() ).thenReturn( configuration );
-
- when( factory.getArchivaConfiguration() ).thenReturn( archivaConfig );
-
- }
}
*/
import com.opensymphony.xwork2.Action;
+import net.sf.beanlib.provider.replicator.BeanReplicator;
+import org.apache.archiva.admin.model.managed.ManagedRepository;
import org.apache.archiva.audit.AuditEvent;
import org.apache.archiva.audit.AuditListener;
import org.apache.archiva.checksum.ChecksumAlgorithm;
private void assertAllArtifactsIncludingSupportArtifactsArePresent( String repoLocation, String artifact,
String version )
{
- assertTrue( new File( repoLocation, "/org/apache/archiva/artifact-upload/" + version + "/" + artifact + ".jar" ).exists() );
+ assertTrue( new File( repoLocation,
+ "/org/apache/archiva/artifact-upload/" + version + "/" + artifact + ".jar" ).exists() );
assertTrue( new File( repoLocation, "/org/apache/archiva/artifact-upload/" + version + "/" + artifact
+ ".jar.sha1" ).exists() );
assertTrue( new File( repoLocation, "/org/apache/archiva/artifact-upload/" + version + "/" + artifact
+ ".jar.md5" ).exists() );
- assertTrue( new File( repoLocation, "/org/apache/archiva/artifact-upload/" + version + "/" + artifact + ".pom" ).exists() );
+ assertTrue( new File( repoLocation,
+ "/org/apache/archiva/artifact-upload/" + version + "/" + artifact + ".pom" ).exists() );
assertTrue( new File( repoLocation, "/org/apache/archiva/artifact-upload/" + version + "/" + artifact
+ ".pom.sha1" ).exists() );
assertTrue( new File( repoLocation, "/org/apache/archiva/artifact-upload/" + version + "/" + artifact
+ ".pom.md5" ).exists() );
- assertTrue( new File( repoLocation, "/org/apache/archiva/artifact-upload/" + MetadataTools.MAVEN_METADATA ).exists() );
+ assertTrue(
+ new File( repoLocation, "/org/apache/archiva/artifact-upload/" + MetadataTools.MAVEN_METADATA ).exists() );
assertTrue( new File( repoLocation, "/org/apache/archiva/artifact-upload/" + MetadataTools.MAVEN_METADATA
+ ".sha1" ).exists() );
assertTrue( new File( repoLocation, "/org/apache/archiva/artifact-upload/" + MetadataTools.MAVEN_METADATA
private void verifyVersionMetadataChecksums( String repoLocation, String version )
throws IOException
{
- ChecksummedFile checksum =
- new ChecksummedFile( new File( repoLocation, "/org/apache/archiva/artifact-upload/" + version + "/"
- + MetadataTools.MAVEN_METADATA ) );
+ ChecksummedFile checksum = new ChecksummedFile( new File( repoLocation,
+ "/org/apache/archiva/artifact-upload/" + version + "/"
+ + MetadataTools.MAVEN_METADATA ) );
String sha1 = checksum.calculateChecksum( ChecksumAlgorithm.SHA1 );
String md5 = checksum.calculateChecksum( ChecksumAlgorithm.MD5 );
- String contents =
- FileUtils.readFileToString( new File( repoLocation, "/org/apache/archiva/artifact-upload/" + version + "/"
- + MetadataTools.MAVEN_METADATA + ".sha1" ) );
+ String contents = FileUtils.readFileToString( new File( repoLocation,
+ "/org/apache/archiva/artifact-upload/" + version + "/"
+ + MetadataTools.MAVEN_METADATA + ".sha1" ) );
assertTrue( StringUtils.contains( contents, sha1 ) );
- contents =
- FileUtils.readFileToString( new File( repoLocation, "/org/apache/archiva/artifact-upload/" + version + "/"
- + MetadataTools.MAVEN_METADATA + ".md5" ) );
+ contents = FileUtils.readFileToString( new File( repoLocation,
+ "/org/apache/archiva/artifact-upload/" + version + "/"
+ + MetadataTools.MAVEN_METADATA + ".md5" ) );
assertTrue( StringUtils.contains( contents, md5 ) );
}
private void verifyProjectMetadataChecksums( String repoLocation )
throws IOException
{
- ChecksummedFile checksum =
- new ChecksummedFile( new File( repoLocation, "/org/apache/archiva/artifact-upload/"
- + MetadataTools.MAVEN_METADATA ) );
+ ChecksummedFile checksum = new ChecksummedFile(
+ new File( repoLocation, "/org/apache/archiva/artifact-upload/" + MetadataTools.MAVEN_METADATA ) );
String sha1 = checksum.calculateChecksum( ChecksumAlgorithm.SHA1 );
String md5 = checksum.calculateChecksum( ChecksumAlgorithm.MD5 );
- String contents =
- FileUtils.readFileToString( new File( repoLocation, "/org/apache/archiva/artifact-upload/"
- + MetadataTools.MAVEN_METADATA + ".sha1" ) );
+ String contents = FileUtils.readFileToString(
+ new File( repoLocation, "/org/apache/archiva/artifact-upload/" + MetadataTools.MAVEN_METADATA + ".sha1" ) );
assertTrue( StringUtils.contains( contents, sha1 ) );
- contents =
- FileUtils.readFileToString( new File( repoLocation, "/org/apache/archiva/artifact-upload/"
- + MetadataTools.MAVEN_METADATA + ".md5" ) );
+ contents = FileUtils.readFileToString(
+ new File( repoLocation, "/org/apache/archiva/artifact-upload/" + MetadataTools.MAVEN_METADATA + ".md5" ) );
assertTrue( StringUtils.contains( contents, md5 ) );
}
String sha1;
String md5;
String contents;
- checksum =
- new ChecksummedFile( new File( repoLocation, "/org/apache/archiva/artifact-upload/" + version + "/"
- + artifact + ".pom" ) );
+ checksum = new ChecksummedFile(
+ new File( repoLocation, "/org/apache/archiva/artifact-upload/" + version + "/" + artifact + ".pom" ) );
sha1 = checksum.calculateChecksum( ChecksumAlgorithm.SHA1 );
md5 = checksum.calculateChecksum( ChecksumAlgorithm.MD5 );
- contents =
- FileUtils.readFileToString( new File( repoLocation, "/org/apache/archiva/artifact-upload/" + version + "/"
- + artifact + ".pom.sha1" ) );
+ contents = FileUtils.readFileToString(
+ new File( repoLocation, "/org/apache/archiva/artifact-upload/" + version + "/" + artifact + ".pom.sha1" ) );
assertTrue( StringUtils.contains( contents, sha1 ) );
- contents =
- FileUtils.readFileToString( new File( repoLocation, "/org/apache/archiva/artifact-upload/" + version + "/"
- + artifact + ".pom.md5" ) );
+ contents = FileUtils.readFileToString(
+ new File( repoLocation, "/org/apache/archiva/artifact-upload/" + version + "/" + artifact + ".pom.md5" ) );
assertTrue( StringUtils.contains( contents, md5 ) );
}
private void verifyArtifactChecksums( String repoLocation, String artifact, String version )
throws IOException
{
- ChecksummedFile checksum =
- new ChecksummedFile( new File( repoLocation, "/org/apache/archiva/artifact-upload/" + version + "/"
- + artifact + ".jar" ) );
+ ChecksummedFile checksum = new ChecksummedFile(
+ new File( repoLocation, "/org/apache/archiva/artifact-upload/" + version + "/" + artifact + ".jar" ) );
String sha1 = checksum.calculateChecksum( ChecksumAlgorithm.SHA1 );
String md5 = checksum.calculateChecksum( ChecksumAlgorithm.MD5 );
- String contents =
- FileUtils.readFileToString( new File( repoLocation, "/org/apache/archiva/artifact-upload/" + version + "/"
- + artifact + ".jar.sha1" ) );
+ String contents = FileUtils.readFileToString(
+ new File( repoLocation, "/org/apache/archiva/artifact-upload/" + version + "/" + artifact + ".jar.sha1" ) );
assertTrue( StringUtils.contains( contents, sha1 ) );
- contents =
- FileUtils.readFileToString( new File( repoLocation, "/org/apache/archiva/artifact-upload/" + version + "/"
- + artifact + ".jar.md5" ) );
+ contents = FileUtils.readFileToString(
+ new File( repoLocation, "/org/apache/archiva/artifact-upload/" + version + "/" + artifact + ".jar.md5" ) );
assertTrue( StringUtils.contains( contents, md5 ) );
}
{
endIndex = artifactsList[index].indexOf( ".pom" );
}
-
+
timestamp = artifactsList[index].substring( startIndex, endIndex );
return timestamp;
}
-
+
private MockControl mockAuditLogs( List<String> resources )
{
return mockAuditLogs( AuditEvent.UPLOAD_FILE, resources );
uploadAction.setAuditListeners( Collections.singletonList( listener ) );
return control;
}
-
+
public void testArtifactUploadWithPomSuccessful()
throws Exception
{
setUploadParameters( "1.0", null, new File( FileUtil.getBasedir(),
"target/test-classes/upload-artifact-test/artifact-to-be-uploaded.jar" ),
- new File( FileUtil.getBasedir(), "target/test-classes/upload-artifact-test/pom.xml" ), false );
+ new File( FileUtil.getBasedir(), "target/test-classes/upload-artifact-test/pom.xml" ),
+ false );
ManagedRepositoryContent content = new ManagedDefaultRepositoryContent();
- content.setRepository( config.findManagedRepositoryById( REPOSITORY_ID ) );
+ content.setRepository( getManagedRepository( config.findManagedRepositoryById( REPOSITORY_ID ) ) );
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
repoFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( REPOSITORY_ID ), content );
{
setUploadParameters( "1.0", "tests", new File( FileUtil.getBasedir(),
"target/test-classes/upload-artifact-test/artifact-to-be-uploaded.jar" ),
- new File( FileUtil.getBasedir(), "target/test-classes/upload-artifact-test/pom.xml" ), false );
+ new File( FileUtil.getBasedir(), "target/test-classes/upload-artifact-test/pom.xml" ),
+ false );
ManagedRepositoryContent content = new ManagedDefaultRepositoryContent();
- content.setRepository( config.findManagedRepositoryById( REPOSITORY_ID ) );
+ content.setRepository( getManagedRepository( config.findManagedRepositoryById( REPOSITORY_ID ) ) );
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
repoFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( REPOSITORY_ID ), content );
control.verify();
String repoLocation = config.findManagedRepositoryById( REPOSITORY_ID ).getLocation();
- assertTrue( new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0-tests.jar" ).exists() );
+ assertTrue( new File( repoLocation,
+ "/org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0-tests.jar" ).exists() );
assertTrue( new File( repoLocation,
"/org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0-tests.jar.sha1" ).exists() );
- assertTrue( new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0-tests.jar.md5" ).exists() );
+ assertTrue( new File( repoLocation,
+ "/org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0-tests.jar.md5" ).exists() );
- assertTrue( new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0.pom" ).exists() );
- assertTrue( new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0.pom.sha1" ).exists() );
- assertTrue( new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0.pom.md5" ).exists() );
+ assertTrue(
+ new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0.pom" ).exists() );
+ assertTrue(
+ new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0.pom.sha1" ).exists() );
+ assertTrue(
+ new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0.pom.md5" ).exists() );
- assertTrue( new File( repoLocation, "/org/apache/archiva/artifact-upload/" + MetadataTools.MAVEN_METADATA ).exists() );
+ assertTrue(
+ new File( repoLocation, "/org/apache/archiva/artifact-upload/" + MetadataTools.MAVEN_METADATA ).exists() );
assertTrue( new File( repoLocation, "/org/apache/archiva/artifact-upload/" + MetadataTools.MAVEN_METADATA
+ ".sha1" ).exists() );
assertTrue( new File( repoLocation, "/org/apache/archiva/artifact-upload/" + MetadataTools.MAVEN_METADATA
null, true );
ManagedRepositoryContent content = new ManagedDefaultRepositoryContent();
- content.setRepository( config.findManagedRepositoryById( REPOSITORY_ID ) );
+ content.setRepository( getManagedRepository( config.findManagedRepositoryById( REPOSITORY_ID ) ) );
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
repoFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( REPOSITORY_ID ), content );
null, false );
ManagedRepositoryContent content = new ManagedDefaultRepositoryContent();
- content.setRepository( config.findManagedRepositoryById( REPOSITORY_ID ) );
+ content.setRepository( getManagedRepository( config.findManagedRepositoryById( REPOSITORY_ID ) ) );
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
repoFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( REPOSITORY_ID ), content );
assertTrue(
new File( repoLocation, "/org/apache/archiva/artifact-upload/" + MetadataTools.MAVEN_METADATA ).exists() );
- assertTrue( new File( repoLocation, "/org/apache/archiva/artifact-upload/" + MetadataTools.MAVEN_METADATA +
- ".sha1" ).exists() );
- assertTrue( new File( repoLocation, "/org/apache/archiva/artifact-upload/" + MetadataTools.MAVEN_METADATA +
- ".md5" ).exists() );
+ assertTrue( new File( repoLocation, "/org/apache/archiva/artifact-upload/" + MetadataTools.MAVEN_METADATA
+ + ".sha1" ).exists() );
+ assertTrue( new File( repoLocation, "/org/apache/archiva/artifact-upload/" + MetadataTools.MAVEN_METADATA
+ + ".md5" ).exists() );
// verify checksums of jar file
ChecksummedFile checksum = new ChecksummedFile(
repoFactoryControl.verify();
String repoLocation = config.findManagedRepositoryById( REPOSITORY_ID ).getLocation();
- assertFalse( new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0.jar" ).exists() );
+ assertFalse(
+ new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0.jar" ).exists() );
- assertFalse( new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0.pom" ).exists() );
+ assertFalse(
+ new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0.pom" ).exists() );
- assertFalse( new File( repoLocation, "/org/apache/archiva/artifact-upload/" + MetadataTools.MAVEN_METADATA ).exists() );
+ assertFalse(
+ new File( repoLocation, "/org/apache/archiva/artifact-upload/" + MetadataTools.MAVEN_METADATA ).exists() );
}
public void testArtifactUploadSnapshots()
null, true );
ManagedRepositoryContent content = new ManagedDefaultRepositoryContent();
- content.setRepository( config.findManagedRepositoryById( REPOSITORY_ID ) );
+ content.setRepository( getManagedRepository( config.findManagedRepositoryById( REPOSITORY_ID ) ) );
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
repoFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( REPOSITORY_ID ), content );
assertEquals( 9, artifactsList.length );
assertTrue( new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0-SNAPSHOT/"
+ MetadataTools.MAVEN_METADATA ).exists() );
- assertTrue( new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0-SNAPSHOT/"
- + MetadataTools.MAVEN_METADATA + ".sha1" ).exists() );
- assertTrue( new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0-SNAPSHOT/"
- + MetadataTools.MAVEN_METADATA + ".md5" ).exists() );
+ assertTrue( new File( repoLocation,
+ "/org/apache/archiva/artifact-upload/1.0-SNAPSHOT/" + MetadataTools.MAVEN_METADATA
+ + ".sha1" ).exists() );
+ assertTrue( new File( repoLocation,
+ "/org/apache/archiva/artifact-upload/1.0-SNAPSHOT/" + MetadataTools.MAVEN_METADATA
+ + ".md5" ).exists() );
int startIndex = "artifact-upload-1.0-".length();
String timestampPath = getTimestamp( artifactsList, startIndex, 0 );
verifyVersionMetadataChecksums( repoLocation, "1.0-SNAPSHOT" );
// verify build number
- File metadataFile =
- new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0-SNAPSHOT/" + MetadataTools.MAVEN_METADATA );
+ File metadataFile = new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0-SNAPSHOT/"
+ + MetadataTools.MAVEN_METADATA );
ArchivaRepositoryMetadata artifactMetadata = RepositoryMetadataReader.read( metadataFile );
SnapshotVersion snapshotVersion = artifactMetadata.getSnapshotVersion();
// MRM-1353
// upload snapshot artifact again and check if build number was incremented
- setUploadParameters( "1.0-SNAPSHOT", null,
- new File( FileUtil.getBasedir(),
- "target/test-classes/upload-artifact-test/artifact-to-be-uploaded.jar" ), null,
- true );
+ setUploadParameters( "1.0-SNAPSHOT", null, new File( FileUtil.getBasedir(),
+ "target/test-classes/upload-artifact-test/artifact-to-be-uploaded.jar" ),
+ null, true );
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
repoFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( REPOSITORY_ID ), content );
-
+
archivaConfigControl.replay();
repoFactoryControl.replay();
-
+
fmt = new SimpleDateFormat( "yyyyMMdd.HHmmss" );
fmt.setTimeZone( TimeZone.getTimeZone( "UTC" ) );
timestamp = fmt.format( new Date() );
-
+
control = mockAuditLogs( Arrays.asList(
- "org/apache/archiva/artifact-upload/1.0-SNAPSHOT/artifact-upload-1.0-" + timestamp + "-2.jar",
- "org/apache/archiva/artifact-upload/1.0-SNAPSHOT/artifact-upload-1.0-" + timestamp + "-2.pom" ) );
-
+ "org/apache/archiva/artifact-upload/1.0-SNAPSHOT/artifact-upload-1.0-" + timestamp + "-2.jar",
+ "org/apache/archiva/artifact-upload/1.0-SNAPSHOT/artifact-upload-1.0-" + timestamp + "-2.pom" ) );
+
returnString = uploadAction.doUpload();
assertEquals( Action.SUCCESS, returnString );
archivaConfigControl.verify();
repoFactoryControl.verify();
control.verify();
-
+
artifactsList = new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0-SNAPSHOT/" ).list();
Arrays.sort( artifactsList );
-
+
assertEquals( 15, artifactsList.length );
timestampPath = getTimestamp( artifactsList, startIndex, 6 );
verifyVersionMetadataChecksums( repoLocation, "1.0-SNAPSHOT" );
// verify build number set in metadata and in filename
- metadataFile =
- new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0-SNAPSHOT/" + MetadataTools.MAVEN_METADATA );
+ metadataFile = new File( repoLocation,
+ "/org/apache/archiva/artifact-upload/1.0-SNAPSHOT/" + MetadataTools.MAVEN_METADATA );
artifactMetadata = RepositoryMetadataReader.read( metadataFile );
snapshotVersion = artifactMetadata.getSnapshotVersion();
ManagedRepositoryContent content = new ManagedDefaultRepositoryContent();
ManagedRepositoryConfiguration repoConfig = config.findManagedRepositoryById( REPOSITORY_ID );
repoConfig.setBlockRedeployments( false );
- content.setRepository( repoConfig );
+ content.setRepository( getManagedRepository( repoConfig ) );
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
repoFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( REPOSITORY_ID ), content );
null, true );
ManagedRepositoryContent content = new ManagedDefaultRepositoryContent();
- content.setRepository( config.findManagedRepositoryById( REPOSITORY_ID ) );
+ content.setRepository( getManagedRepository( config.findManagedRepositoryById( REPOSITORY_ID ) ) );
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 2 );
repoFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( REPOSITORY_ID ), content, 2 );
ManagedRepositoryContent content = new ManagedDefaultRepositoryContent();
ManagedRepositoryConfiguration repoConfig = config.findManagedRepositoryById( REPOSITORY_ID );
repoConfig.setBlockRedeployments( false );
- content.setRepository( repoConfig );
+ content.setRepository( getManagedRepository( repoConfig ) );
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 2 );
repoFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( REPOSITORY_ID ), content, 2 );
verifyPomChecksums( repoLocation, "artifact-upload-1.0", "1.0" );
verifyProjectMetadataChecksums( repoLocation );
}
+
+ ManagedRepository getManagedRepository( ManagedRepositoryConfiguration conf )
+ {
+ return new BeanReplicator().replicateBean( conf, ManagedRepository.class );
+ }
}
*/
import com.opensymphony.xwork2.Action;
+import org.apache.archiva.admin.model.proxyconnector.ProxyConnector;
import org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin;
import org.apache.archiva.admin.repository.proxyconnector.DefaultProxyConnectorAdmin;
-import org.apache.archiva.admin.repository.proxyconnector.ProxyConnector;
import org.apache.archiva.admin.repository.remote.DefaultRemoteRepositoryAdmin;
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.configuration.Configuration;
import org.apache.maven.archiva.policies.ReleasesPolicy;
import org.apache.maven.archiva.policies.SnapshotsPolicy;
import org.apache.maven.archiva.web.action.AbstractWebworkTestCase;
-import org.codehaus.redback.integration.interceptor.SecureActionBundle;
import org.codehaus.plexus.registry.RegistryException;
+import org.codehaus.redback.integration.interceptor.SecureActionBundle;
import org.easymock.MockControl;
import java.util.List;
*/
import com.opensymphony.xwork2.Action;
+import org.apache.archiva.admin.model.proxyconnector.ProxyConnector;
import org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin;
import org.apache.archiva.admin.repository.proxyconnector.DefaultProxyConnectorAdmin;
-import org.apache.archiva.admin.repository.proxyconnector.ProxyConnector;
import org.apache.archiva.admin.repository.remote.DefaultRemoteRepositoryAdmin;
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.configuration.Configuration;
import com.opensymphony.xwork2.validator.ActionValidatorManager;
import junit.framework.TestCase;
-import org.apache.archiva.admin.repository.admin.LegacyArtifactPath;
+import org.apache.archiva.admin.model.admin.LegacyArtifactPath;
import org.apache.archiva.web.validator.utils.ValidatorUtil;
import org.apache.maven.archiva.web.action.admin.repositories.DefaultActionValidatorManagerFactory;
*/
import com.opensymphony.xwork2.validator.ActionValidatorManager;
+import junit.framework.TestCase;
+import org.apache.archiva.admin.model.networkproxy.NetworkProxy;
+import org.apache.archiva.web.validator.utils.ValidatorUtil;
+import org.apache.maven.archiva.web.action.admin.repositories.DefaultActionValidatorManagerFactory;
+
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import junit.framework.TestCase;
-import org.apache.archiva.admin.repository.networkproxy.NetworkProxy;
-import org.apache.maven.archiva.configuration.NetworkProxyConfiguration;
-import org.apache.maven.archiva.web.action.admin.repositories.DefaultActionValidatorManagerFactory;
-import org.apache.archiva.web.validator.utils.ValidatorUtil;
-
public class ConfigureNetworkProxyActionTest extends TestCase
{
private static final String EMPTY_STRING = "";
*/
import com.opensymphony.xwork2.validator.ActionValidatorManager;
-import org.apache.archiva.admin.repository.managed.ManagedRepository;
-import org.apache.archiva.admin.repository.managed.ManagedRepositoryAdmin;
+import org.apache.archiva.admin.model.managed.ManagedRepository;
+import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
import org.apache.struts2.StrutsSpringTestCase;
import java.io.File;
*/
import com.opensymphony.xwork2.Action;
+import org.apache.archiva.admin.model.managed.ManagedRepository;
import org.apache.archiva.admin.repository.RepositoryCommonValidator;
import org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin;
-import org.apache.archiva.admin.repository.managed.ManagedRepository;
import org.apache.archiva.scheduler.repository.RepositoryArchivaTaskScheduler;
import org.apache.archiva.scheduler.repository.RepositoryTask;
import org.apache.archiva.security.ArchivaRoleConstants;
*/
import com.opensymphony.xwork2.Action;
+import org.apache.archiva.admin.model.remote.RemoteRepository;
import org.apache.archiva.admin.repository.remote.DefaultRemoteRepositoryAdmin;
-import org.apache.archiva.admin.repository.remote.RemoteRepository;
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.configuration.Configuration;
import org.apache.maven.archiva.web.action.AbstractActionTestCase;
*/
import com.opensymphony.xwork2.Action;
+import net.sf.beanlib.provider.replicator.BeanReplicator;
+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.admin.repository.managed.DefaultManagedRepositoryAdmin;
-import org.apache.archiva.admin.repository.managed.ManagedRepositoryAdmin;
import org.apache.archiva.audit.AuditEvent;
import org.apache.archiva.audit.AuditListener;
import org.apache.archiva.metadata.repository.MetadataRepository;
import org.apache.archiva.metadata.repository.RepositorySession;
import org.apache.archiva.metadata.repository.memory.TestRepositorySessionFactory;
import org.apache.archiva.metadata.repository.stats.RepositoryStatisticsManager;
+import org.apache.archiva.security.ArchivaRoleConstants;
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.ProxyConnectorConfiguration;
import org.apache.maven.archiva.configuration.RemoteRepositoryConfiguration;
import org.apache.maven.archiva.configuration.RepositoryGroupConfiguration;
-import org.apache.archiva.security.ArchivaRoleConstants;
import org.apache.maven.archiva.web.action.AbstractActionTestCase;
import org.apache.maven.archiva.web.action.AuditEventArgumentsMatcher;
import org.codehaus.plexus.redback.role.RoleManager;
}
public void testSecureActionBundle()
- throws SecureActionException
+ throws SecureActionException, RepositoryAdminException
{
archivaConfiguration.getConfiguration();
archivaConfigurationControl.setReturnValue( new Configuration() );
public void testDeleteRepositoryConfirmation()
throws Exception
{
- ManagedRepositoryConfiguration originalRepository = createRepository();
+ ManagedRepository originalRepository = createRepository();
Configuration configuration = createConfigurationForEditing( originalRepository );
archivaConfiguration.getConfiguration();
action.prepare();
assertEquals( REPO_ID, action.getRepoid() );
- ManagedRepositoryConfiguration repository = action.getRepository();
+ ManagedRepository repository = action.getRepository();
assertNotNull( repository );
assertRepositoryEquals( repository, createRepository() );
{
repositoryStatisticsManagerControl.replay();
- ManagedRepositoryConfiguration originalRepository = createRepository();
+ ManagedRepository originalRepository = createRepository();
Configuration configuration = prepDeletionTest( originalRepository, 3 );
String status = action.execute();
assertEquals( Action.SUCCESS, status );
- ManagedRepositoryConfiguration repository = action.getRepository();
+ ManagedRepository repository = action.getRepository();
assertRepositoryEquals( repository, createRepository() );
assertEquals( Collections.singletonList( originalRepository ), configuration.getManagedRepositories() );
}
- private Configuration prepDeletionTest( ManagedRepositoryConfiguration originalRepository,
- int expectCountGetConfig )
- throws RegistryException, IndeterminateConfigurationException
+ private Configuration prepDeletionTest( ManagedRepository originalRepository, int expectCountGetConfig )
+ throws RegistryException, IndeterminateConfigurationException, RepositoryAdminException
{
location.mkdirs();
action.prepare();
assertEquals( REPO_ID, action.getRepoid() );
- ManagedRepositoryConfiguration repository = action.getRepository();
+ ManagedRepository repository = action.getRepository();
assertNotNull( repository );
assertRepositoryEquals( repository, createRepository() );
return configuration;
}
- private void assertRepositoryEquals( ManagedRepositoryConfiguration expectedRepository,
- ManagedRepositoryConfiguration actualRepository )
+ private void assertRepositoryEquals( ManagedRepository expectedRepository, ManagedRepository actualRepository )
{
assertEquals( expectedRepository.getDaysOlder(), actualRepository.getDaysOlder() );
assertEquals( expectedRepository.getId(), actualRepository.getId() );
- assertEquals( expectedRepository.getIndexDir(), actualRepository.getIndexDir() );
+ assertEquals( expectedRepository.getIndexDirectory(), actualRepository.getIndexDirectory() );
assertEquals( expectedRepository.getLayout(), actualRepository.getLayout() );
assertEquals( expectedRepository.getLocation(), actualRepository.getLocation() );
assertEquals( expectedRepository.getName(), actualRepository.getName() );
- assertEquals( expectedRepository.getRefreshCronExpression(), actualRepository.getRefreshCronExpression() );
+ assertEquals( expectedRepository.getCronExpression(), actualRepository.getCronExpression() );
assertEquals( expectedRepository.getRetentionCount(), actualRepository.getRetentionCount() );
assertEquals( expectedRepository.isDeleteReleasedSnapshots(), actualRepository.isDeleteReleasedSnapshots() );
assertEquals( expectedRepository.isScanned(), actualRepository.isScanned() );
assertEquals( expectedRepository.isSnapshots(), actualRepository.isSnapshots() );
}
- private Configuration createConfigurationForEditing( ManagedRepositoryConfiguration repositoryConfiguration )
+ private Configuration createConfigurationForEditing( ManagedRepository repositoryConfiguration )
{
Configuration configuration = new Configuration();
- configuration.addManagedRepository( repositoryConfiguration );
+ configuration.addManagedRepository(
+ new BeanReplicator().replicateBean( repositoryConfiguration, ManagedRepositoryConfiguration.class ) );
return configuration;
}
- private ManagedRepositoryConfiguration createRepository()
+ private ManagedRepository createRepository()
{
- ManagedRepositoryConfiguration r = new ManagedRepositoryConfiguration();
+ ManagedRepository r = new ManagedRepository();
r.setId( REPO_ID );
r.setName( "repo name" );
r.setLocation( location.getAbsolutePath() );
r.setLayout( "default" );
- r.setRefreshCronExpression( "* 0/5 * * * ?" );
+ r.setCronExpression( "* 0/5 * * * ?" );
r.setDaysOlder( 0 );
r.setRetentionCount( 0 );
r.setReleases( true );
*/
import com.opensymphony.xwork2.Action;
-import org.apache.archiva.admin.repository.RepositoryAdminException;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.remote.RemoteRepository;
import org.apache.archiva.admin.repository.remote.DefaultRemoteRepositoryAdmin;
-import org.apache.archiva.admin.repository.remote.RemoteRepository;
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.configuration.Configuration;
import org.apache.maven.archiva.configuration.IndeterminateConfigurationException;
*/
import com.opensymphony.xwork2.Action;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.group.RepositoryGroup;
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.configuration.Configuration;
import org.apache.maven.archiva.configuration.RepositoryGroupConfiguration;
}
public void testSecureActionBundle()
- throws SecureActionException
+ throws SecureActionException, RepositoryAdminException
{
archivaConfiguration.getConfiguration();
archivaConfigurationControl.setReturnValue( new Configuration() );
action.prepare();
assertEquals( REPO_GROUP_ID, action.getRepoGroupId() );
- RepositoryGroupConfiguration repoGroup = action.getRepositoryGroup();
+ RepositoryGroup repoGroup = action.getRepositoryGroup();
assertNotNull( repoGroup );
assertEquals( repoGroup.getId(), action.getRepoGroupId() );
assertEquals( Collections.singletonList( origRepoGroup ), configuration.getRepositoryGroups() );
action.prepare();
assertEquals( REPO_GROUP_ID, action.getRepoGroupId() );
- RepositoryGroupConfiguration repoGroup = action.getRepositoryGroup();
+ RepositoryGroup repoGroup = action.getRepositoryGroup();
assertNotNull( repoGroup );
assertEquals( Collections.singletonList( repoGroup ), configuration.getRepositoryGroups() );
action.prepare();
assertEquals( REPO_GROUP_ID, action.getRepoGroupId() );
- RepositoryGroupConfiguration repoGroup = action.getRepositoryGroup();
+ RepositoryGroup repoGroup = action.getRepositoryGroup();
assertNotNull( repoGroup );
String status = action.execute();
*/
import com.opensymphony.xwork2.Action;
-import org.apache.archiva.admin.repository.RepositoryAdminException;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.managed.ManagedRepository;
import org.apache.archiva.admin.repository.RepositoryCommonValidator;
import org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin;
-import org.apache.archiva.admin.repository.managed.ManagedRepository;
import org.apache.archiva.audit.AuditListener;
import org.apache.archiva.metadata.repository.MetadataRepository;
import org.apache.archiva.metadata.repository.RepositorySession;
import org.apache.archiva.metadata.repository.stats.RepositoryStatisticsManager;
import org.apache.archiva.scheduler.repository.RepositoryArchivaTaskScheduler;
import org.apache.archiva.scheduler.repository.RepositoryTask;
+import org.apache.archiva.security.ArchivaRoleConstants;
+import org.apache.archiva.web.validator.utils.ValidatorUtil;
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.archiva.security.ArchivaRoleConstants;
-import org.apache.archiva.web.validator.utils.ValidatorUtil;
import org.codehaus.plexus.redback.role.RoleManager;
import org.codehaus.plexus.registry.Registry;
import org.codehaus.redback.integration.interceptor.SecureActionBundle;
*/
import com.opensymphony.xwork2.Action;
-import org.apache.archiva.admin.repository.RepositoryAdminException;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.remote.RemoteRepository;
import org.apache.archiva.admin.repository.remote.DefaultRemoteRepositoryAdmin;
-import org.apache.archiva.admin.repository.remote.RemoteRepository;
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.configuration.Configuration;
import org.apache.maven.archiva.configuration.RemoteRepositoryConfiguration;
import com.meterware.servletunit.ServletRunner;
import com.meterware.servletunit.ServletUnitClient;
import com.opensymphony.xwork2.Action;
-import org.apache.archiva.admin.repository.RepositoryAdminException;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.group.RepositoryGroup;
import org.apache.archiva.admin.repository.group.DefaultRepositoryGroupAdmin;
-import org.apache.archiva.admin.repository.group.RepositoryGroup;
import org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin;
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.configuration.Configuration;
</dependency>
<dependency>
<groupId>org.apache.archiva</groupId>
- <artifactId>archiva-repository-admin</artifactId>
+ <artifactId>archiva-repository-admin-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.archiva</groupId>
<artifactId>httpunit</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>archiva-repository-admin-default</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
<plugins>
* under the License.
*/
+import org.apache.archiva.admin.model.managed.ManagedRepository;
import org.apache.archiva.audit.AuditEvent;
import org.apache.archiva.audit.AuditListener;
import org.apache.archiva.scheduler.ArchivaTaskScheduler;
private String remoteAddr;
- private final ManagedRepositoryConfiguration repository;
+ private final ManagedRepository repository;
private final MimeTypes mimeTypes;
private Logger log = LoggerFactory.getLogger( ArchivaDavResource.class );
- public ArchivaDavResource( String localResource, String logicalResource, ManagedRepositoryConfiguration repository,
+ public ArchivaDavResource( String localResource, String logicalResource, ManagedRepository repository,
DavSession session, ArchivaDavResourceLocator locator, DavResourceFactory factory,
MimeTypes mimeTypes, List<AuditListener> auditListeners,
RepositoryArchivaTaskScheduler scheduler )
this.scheduler = scheduler;
}
- public ArchivaDavResource( String localResource, String logicalResource, ManagedRepositoryConfiguration repository,
+ public ArchivaDavResource( String localResource, String logicalResource, ManagedRepository repository,
String remoteAddr, String principal, DavSession session,
ArchivaDavResourceLocator locator, DavResourceFactory factory, MimeTypes mimeTypes,
List<AuditListener> auditListeners, RepositoryArchivaTaskScheduler scheduler )
* under the License.
*/
-import org.apache.archiva.admin.repository.RepositoryAdminException;
-import org.apache.archiva.admin.repository.managed.ManagedRepository;
-import org.apache.archiva.admin.repository.managed.ManagedRepositoryAdmin;
+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.security.ServletAuthenticator;
import org.apache.jackrabbit.webdav.DavException;
import org.apache.jackrabbit.webdav.DavLocatorFactory;
{
public ProjectMetadata getProject( String repoId, String namespace, String projectId )
{
- return null; //To change body of implemented methods use File | Settings | File Templates.
+ return null;
}
public ProjectVersionMetadata getProjectVersion( String repoId, String namespace, String projectId,
String projectVersion )
{
- return null; //To change body of implemented methods use File | Settings | File Templates.
+ return null;
}
public Collection<String> getArtifactVersions( String repoId, String namespace, String projectId,
String projectVersion )
{
- return null; //To change body of implemented methods use File | Settings | File Templates.
+ return null;
}
public Collection<ProjectVersionReference> getProjectReferences( String repoId, String namespace, String projectId,
String projectVersion )
{
- return null; //To change body of implemented methods use File | Settings | File Templates.
+ return null;
}
public Collection<String> getRootNamespaces( String repoId )
{
- return null; //To change body of implemented methods use File | Settings | File Templates.
+ return null;
}
public Collection<String> getNamespaces( String repoId, String namespace )
{
- return null; //To change body of implemented methods use File | Settings | File Templates.
+ return null;
}
public Collection<String> getProjects( String repoId, String namespace )
{
- return null; //To change body of implemented methods use File | Settings | File Templates.
+ return null;
}
public Collection<String> getProjectVersions( String repoId, String namespace, String projectId )
{
- return null; //To change body of implemented methods use File | Settings | File Templates.
+ return null;
}
public void updateProject( String repoId, ProjectMetadata project )
{
- //To change body of implemented methods use File | Settings | File Templates.
}
public void updateArtifact( String repoId, String namespace, String projectId, String projectVersion,
ArtifactMetadata artifactMeta )
{
- //To change body of implemented methods use File | Settings | File Templates.
+
}
public void updateProjectVersion( String repoId, String namespace, String projectId,
ProjectVersionMetadata versionMetadata )
{
- //To change body of implemented methods use File | Settings | File Templates.
+
}
public void updateNamespace( String repoId, String namespace )
{
- //To change body of implemented methods use File | Settings | File Templates.
+
}
public List<String> getMetadataFacets( String repodId, String facetId )
public MetadataFacet getMetadataFacet( String repositoryId, String facetId, String name )
{
- return null; //To change body of implemented methods use File | Settings | File Templates.
+ return null;
}
public void addMetadataFacet( String repositoryId, MetadataFacet metadataFacet )
{
- //To change body of implemented methods use File | Settings | File Templates.
+
}
public void removeMetadataFacets( String repositoryId, String facetId )
{
- //To change body of implemented methods use File | Settings | File Templates.
+
}
public void removeMetadataFacet( String repoId, String facetId, String name )
{
- //To change body of implemented methods use File | Settings | File Templates.
+
}
public List<ArtifactMetadata> getArtifactsByDateRange( String repoId, Date startTime, Date endTime )
{
- return null; //To change body of implemented methods use File | Settings | File Templates.
+ return null;
}
public Collection<String> getRepositories()
{
- return null; //To change body of implemented methods use File | Settings | File Templates.
+ return null;
}
public List<ArtifactMetadata> getArtifactsByChecksum( String repoId, String checksum )
{
- return null; //To change body of implemented methods use File | Settings | File Templates.
+ return null;
}
public void removeArtifact( String repositoryId, String namespace, String project, String version, String id )
{
- //To change body of implemented methods use File | Settings | File Templates.
+
}
public void removeRepository( String repoId )
{
- //To change body of implemented methods use File | Settings | File Templates.
+
}
public Collection<ArtifactMetadata> getArtifacts( String repoId, String namespace, String projectId,
String projectVersion )
{
- return null; //To change body of implemented methods use File | Settings | File Templates.
+ return null;
}
public void save()
{
- //To change body of implemented methods use File | Settings | File Templates.
+
}
public void close()
{
- //To change body of implemented methods use File | Settings | File Templates.
+
}
public void revert()
{
- //To change body of implemented methods use File | Settings | File Templates.
+
}
public boolean canObtainAccess( Class<?> aClass )
{
- return false; //To change body of implemented methods use File | Settings | File Templates.
+ return false;
}
public Object obtainAccess( Class<?> aClass )
{
- return null; //To change body of implemented methods use File | Settings | File Templates.
+ return null;
}
public List<ArtifactMetadata> getArtifacts( String repositoryId )
import junit.framework.Assert;
import junit.framework.TestCase;
import net.sf.ehcache.CacheManager;
-import org.apache.archiva.admin.repository.managed.ManagedRepository;
+import org.apache.archiva.admin.model.managed.ManagedRepository;
import org.apache.commons.io.FileUtils;
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.configuration.Configuration;
*/
import junit.framework.TestCase;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.group.RepositoryGroup;
+import org.apache.archiva.admin.model.managed.ManagedRepository;
+import org.apache.archiva.admin.repository.group.DefaultRepositoryGroupAdmin;
+import org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin;
import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException;
import org.apache.commons.io.FileUtils;
import org.apache.jackrabbit.webdav.DavServletResponse;
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.configuration.RepositoryGroupConfiguration;
import org.apache.maven.archiva.proxy.DefaultRepositoryProxyConnectors;
import org.apache.maven.archiva.repository.ManagedRepositoryContent;
@Inject
PlexusSisuBridge plexusSisuBridge;
+ @Inject
+ DefaultManagedRepositoryAdmin defaultManagedRepositoryAdmin;
+
+ @Inject
+ DefaultRepositoryGroupAdmin defaultRepositoryGroupAdmin;
+
+
@Before
public void setUp()
throws Exception
archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
config = new Configuration();
- config.addManagedRepository(
- createManagedRepository( RELEASES_REPO, new File( "target/test-classes/" + RELEASES_REPO ).getPath(),
- "default" ) );
- config.addManagedRepository(
- createManagedRepository( INTERNAL_REPO, new File( "target/test-classes/" + INTERNAL_REPO ).getPath(),
- "default" ) );
-
- RepositoryGroupConfiguration repoGroupConfig = new RepositoryGroupConfiguration();
+ archivaConfiguration.getConfiguration();
+ archivaConfigurationControl.setReturnValue( config, 5, 20 );
+ archivaConfiguration.save( config );
+ archivaConfigurationControl.setVoidCallable( 1, 4 );
+ archivaConfigurationControl.replay();
+
+ defaultManagedRepositoryAdmin.setArchivaConfiguration( archivaConfiguration );
+ defaultManagedRepositoryAdmin.getRepositoryCommonValidator().setArchivaConfiguration( archivaConfiguration );
+ if ( defaultManagedRepositoryAdmin.getManagedRepository( RELEASES_REPO ) == null )
+ {
+ defaultManagedRepositoryAdmin.addManagedRepository(
+ createManagedRepository( RELEASES_REPO, new File( "target/test-classes/" + RELEASES_REPO ).getPath(),
+ "default" ), false, null );
+ }
+ if ( defaultManagedRepositoryAdmin.getManagedRepository( INTERNAL_REPO ) == null )
+ {
+ defaultManagedRepositoryAdmin.addManagedRepository(
+ createManagedRepository( INTERNAL_REPO, new File( "target/test-classes/" + INTERNAL_REPO ).getPath(),
+ "default" ), false, null );
+ }
+ RepositoryGroup repoGroupConfig = new RepositoryGroup();
repoGroupConfig.setId( LOCAL_REPO_GROUP );
repoGroupConfig.addRepository( RELEASES_REPO );
repoGroupConfig.addRepository( INTERNAL_REPO );
- config.addRepositoryGroup( repoGroupConfig );
+ defaultRepositoryGroupAdmin.setArchivaConfiguration( archivaConfiguration );
+ if ( defaultManagedRepositoryAdmin.getManagedRepository( LOCAL_REPO_GROUP ) == null )
+ {
+ defaultRepositoryGroupAdmin.addRepositoryGroup( repoGroupConfig, null );
+ }
repoContentFactoryControl = MockClassControl.createControl( RepositoryContentFactory.class );
repoFactory = (RepositoryContentFactory) repoContentFactoryControl.getMock();
resourceFactory.setConnectors( new OverridingRepositoryProxyConnectors() );
}
- private ManagedRepositoryConfiguration createManagedRepository( String id, String location, String layout )
+ private ManagedRepository createManagedRepository( String id, String location, String layout )
{
- ManagedRepositoryConfiguration repoConfig = new ManagedRepositoryConfiguration();
+ ManagedRepository repoConfig = new ManagedRepository();
repoConfig.setId( id );
repoConfig.setName( id );
repoConfig.setLocation( location );
}
private ManagedRepositoryContent createManagedRepositoryContent( String repoId )
+ throws RepositoryAdminException
{
ManagedRepositoryContent repoContent = new ManagedDefaultRepositoryContent();
- repoContent.setRepository( config.findManagedRepositoryById( repoId ) );
+ repoContent.setRepository( defaultManagedRepositoryAdmin.getManagedRepository( repoId ) );
return repoContent;
}
new ArchivaDavLocatorFactory() );
ManagedRepositoryContent internalRepo = createManagedRepositoryContent( INTERNAL_REPO );
+ ManagedRepositoryContent releasesRepo = createManagedRepositoryContent( RELEASES_REPO );
try
{
+ archivaConfigurationControl.reset();
archivaConfigurationControl.expectAndReturn( archivaConfiguration.getConfiguration(), config );
requestControl.expectAndReturn( request.getMethod(), "GET", 2 );
repoContentFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( RELEASES_REPO ),
- createManagedRepositoryContent( RELEASES_REPO ) );
+ releasesRepo );
requestControl.expectAndReturn( request.getRemoteAddr(), "http://localhost:8080", 2 );
requestControl.expectAndReturn( request.getDavSession(), new ArchivaDavSession(), 2 );
repoRequestControl.expectAndReturn(
ManagedRepositoryContent internalRepo = createManagedRepositoryContent( INTERNAL_REPO );
+ ManagedRepositoryContent releasesRepo = createManagedRepositoryContent( RELEASES_REPO );
+
try
{
+ archivaConfigurationControl.reset();
archivaConfigurationControl.expectAndReturn( archivaConfiguration.getConfiguration(), config );
requestControl.expectAndReturn( request.getMethod(), "GET", 2 );
repoContentFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( INTERNAL_REPO ),
internalRepo );
repoContentFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( RELEASES_REPO ),
- createManagedRepositoryContent( RELEASES_REPO ) );
+ releasesRepo );
requestControl.expectAndReturn( request.getRemoteAddr(), "http://localhost:8080", 2 );
requestControl.expectAndReturn( request.getDavSession(), new ArchivaDavSession(), 2 );
repoRequestControl.expectAndReturn(
+ "/org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar", LOCAL_REPO_GROUP,
new ArchivaDavLocatorFactory() );
- config.addManagedRepository(
+ defaultManagedRepositoryAdmin.addManagedRepository(
createManagedRepository( LOCAL_MIRROR_REPO, new File( "target/test-classes/local-mirror" ).getPath(),
- "default" ) );
+ "default" ), false, null );
List<RepositoryGroupConfiguration> repoGroups = new ArrayList<RepositoryGroupConfiguration>();
RepositoryGroupConfiguration repoGroup = new RepositoryGroupConfiguration();
try
{
+ archivaConfigurationControl.reset();
archivaConfigurationControl.expectAndReturn( archivaConfiguration.getConfiguration(), config );
requestControl.expectAndReturn( request.getMethod(), "GET", 4 );
repoContentFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( INTERNAL_REPO ),
try
{
+ archivaConfigurationControl.reset();
archivaConfigurationControl.expectAndReturn( archivaConfiguration.getConfiguration(), config );
repoContentFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( INTERNAL_REPO ),
internalRepo );
try
{
+ archivaConfigurationControl.reset();
archivaConfigurationControl.expectAndReturn( archivaConfiguration.getConfiguration(), config );
repoContentFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( INTERNAL_REPO ),
internalRepo );
public void testRequestMetadataRepoIsLegacy()
throws Exception
{
- config.addManagedRepository(
+ defaultManagedRepositoryAdmin.addManagedRepository(
createManagedRepository( LEGACY_REPO, new File( "target/test-classes/" + LEGACY_REPO ).getPath(),
- "legacy" ) );
+ "legacy" ), false, null );
DavResourceLocator locator =
new ArchivaDavResourceLocator( "", "/repository/" + LEGACY_REPO + "/eclipse/maven-metadata.xml",
LEGACY_REPO, new ArchivaDavLocatorFactory() );
try
{
+ archivaConfigurationControl.reset();
archivaConfigurationControl.expectAndReturn( archivaConfiguration.getConfiguration(), config );
repoContentFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( LEGACY_REPO ),
legacyRepo );
*/
import junit.framework.TestCase;
+import org.apache.archiva.admin.model.managed.ManagedRepository;
import org.apache.archiva.audit.AuditListener;
import org.apache.commons.io.FileUtils;
import org.apache.jackrabbit.webdav.DavException;
private LockManager lockManager;
- private ManagedRepositoryConfiguration repository = new ManagedRepositoryConfiguration();
+ private ManagedRepository repository = new ManagedRepository();
@Override
@Before
* under the License.
*/
-import org.apache.archiva.admin.repository.managed.ManagedRepository;
-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.webdav.RepositoryServlet;
-
import com.meterware.httpunit.GetMethodWebRequest;
import com.meterware.httpunit.WebRequest;
import com.meterware.httpunit.WebResponse;
+import org.apache.archiva.admin.model.managed.ManagedRepository;
+import org.apache.maven.archiva.configuration.ArchivaConfiguration;
+import org.apache.maven.archiva.configuration.Configuration;
+import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
import org.junit.Test;
import java.io.File;
* under the License.
*/
-import java.util.List;
-
+import org.apache.archiva.admin.model.admin.ArchivaAdministration;
import org.apache.archiva.repository.scanner.RepositoryContentConsumers;
-import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.consumers.InvalidRepositoryContentConsumer;
import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
+import java.util.List;
+
public class StubRepositoryContentConsumers
extends RepositoryContentConsumers
{
- public StubRepositoryContentConsumers(ArchivaConfiguration configuration)
+ public StubRepositoryContentConsumers( ArchivaAdministration archivaAdministration )
{
- super(configuration);
+ super( archivaAdministration );
}
@Override
* under the License.
*/
-import org.apache.archiva.admin.repository.RepositoryAdminException;
+import org.apache.archiva.admin.model.RepositoryAdminException;
import javax.servlet.ServletConfig;
</dependency>
<dependency>
<groupId>org.apache.archiva</groupId>
- <artifactId>archiva-repository-admin</artifactId>
+ <artifactId>archiva-repository-admin-api</artifactId>
</dependency>
<dependency>
<groupId>com.atlassian.xmlrpc</groupId>
*/
import com.atlassian.xmlrpc.ServiceObject;
-import org.apache.archiva.admin.repository.RepositoryAdminException;
+import org.apache.archiva.admin.model.RepositoryAdminException;
import org.apache.archiva.web.xmlrpc.api.beans.ManagedRepository;
import org.apache.archiva.web.xmlrpc.api.beans.RemoteRepository;
</dependency>
<dependency>
<groupId>org.apache.archiva</groupId>
- <artifactId>archiva-repository-admin</artifactId>
+ <artifactId>archiva-repository-admin-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.archiva</groupId>
<artifactId>mockito-all</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>archiva-repository-admin-default</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
<pluginManagement>
* under the License.
*/
-import org.apache.archiva.admin.AuditInformation;
-import org.apache.archiva.admin.repository.RepositoryAdminException;
-import org.apache.archiva.admin.repository.managed.ManagedRepositoryAdmin;
-import org.apache.archiva.admin.repository.remote.RemoteRepositoryAdmin;
+import org.apache.archiva.admin.model.AuditInformation;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
+import org.apache.archiva.admin.model.remote.RemoteRepositoryAdmin;
import org.apache.archiva.audit.AuditEvent;
import org.apache.archiva.audit.AuditListener;
import org.apache.archiva.metadata.model.ArtifactMetadata;
{
List<ManagedRepository> managedRepos = new ArrayList<ManagedRepository>();
- for ( org.apache.archiva.admin.repository.managed.ManagedRepository repoConfig : managedRepositoryAdmin.getManagedRepositories() )
+ for ( org.apache.archiva.admin.model.managed.ManagedRepository repoConfig : managedRepositoryAdmin.getManagedRepositories() )
{
ManagedRepository repo =
new ManagedRepository( repoConfig.getId(), repoConfig.getName(), repoConfig.getLocation(),
{
List<RemoteRepository> remoteRepos = new ArrayList<RemoteRepository>();
- for ( org.apache.archiva.admin.repository.remote.RemoteRepository repoConfig : remoteRepositoryAdmin.getRemoteRepositories() )
+ for ( org.apache.archiva.admin.model.remote.RemoteRepository repoConfig : remoteRepositoryAdmin.getRemoteRepositories() )
{
RemoteRepository repo = new RemoteRepository( repoConfig.getId(), repoConfig.getName(), repoConfig.getUrl(),
repoConfig.getLayout() );
throws Exception
{
- org.apache.archiva.admin.repository.managed.ManagedRepository repository =
- new org.apache.archiva.admin.repository.managed.ManagedRepository( repoId, name, location, layout,
+ org.apache.archiva.admin.model.managed.ManagedRepository repository =
+ new org.apache.archiva.admin.model.managed.ManagedRepository( repoId, name, location, layout,
snapshotsIncluded, releasesIncluded,
blockRedeployments, cronExpression, null,
false, daysOlder, retentionCount,
*/
import junit.framework.TestCase;
+import net.sf.beanlib.provider.replicator.BeanReplicator;
import org.apache.archiva.admin.repository.RepositoryCommonValidator;
import org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin;
import org.apache.archiva.admin.repository.remote.DefaultRemoteRepositoryAdmin;
configControl.expectAndReturn( config.findManagedRepositoryById( "internal" ), managedRepo );
ManagedDefaultRepositoryContent repoContent = new ManagedDefaultRepositoryContent();
- repoContent.setRepository( managedRepo );
+ repoContent.setRepository( new BeanReplicator().replicateBean( managedRepo,
+ org.apache.archiva.admin.model.managed.ManagedRepository.class ) );
repoFactoryControl.expectAndReturn( repositoryFactory.getManagedRepositoryContent( "internal" ), repoContent );
configControl.expectAndReturn( config.findManagedRepositoryById( "internal" ), managedRepo );
ManagedLegacyRepositoryContent repoContent = new ManagedLegacyRepositoryContent();
- repoContent.setRepository( managedRepo );
+ repoContent.setRepository( new BeanReplicator().replicateBean( managedRepo,
+ org.apache.archiva.admin.model.managed.ManagedRepository.class ) );
repoContent.setFileTypes( fileTypes );
repoContent.setLegacyPathParser( parser );
configControl.expectAndReturn( config.findManagedRepositoryById( "internal" ), managedRepo );
ManagedDefaultRepositoryContent repoContent = new ManagedDefaultRepositoryContent();
- repoContent.setRepository( managedRepo );
+ repoContent.setRepository( new BeanReplicator().replicateBean( managedRepo,
+ org.apache.archiva.admin.model.managed.ManagedRepository.class ) );
repoFactoryControl.expectAndReturn( repositoryFactory.getManagedRepositoryContent( "internal" ), repoContent );
<groupId>org.apache.archiva</groupId>
<artifactId>metadata-repository-api</artifactId>
</dependency>
+ <!-- FIXME this deps must be removed -->
+ <dependency>
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>archiva-configuration</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>archiva-repository-admin-api</artifactId>
+ </dependency>
<dependency>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-checksum</artifactId>
* under the License.
*/
+import org.apache.archiva.admin.model.managed.ManagedRepository;
import org.apache.archiva.checksum.ChecksumAlgorithm;
import org.apache.archiva.checksum.ChecksummedFile;
import org.apache.archiva.metadata.model.ArtifactMetadata;
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.configuration.ConfigurationNames;
import org.apache.maven.archiva.configuration.FileTypes;
-import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.maven.archiva.consumers.AbstractMonitoredConsumer;
import org.apache.maven.archiva.consumers.ConsumerException;
import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
return Collections.emptyList();
}
- public void beginScan( ManagedRepositoryConfiguration repo, Date whenGathered )
+ public void beginScan( ManagedRepository repo, Date whenGathered )
throws ConsumerException
{
repoId = repo.getId();
repositorySession = repositorySessionFactory.createSession();
}
- public void beginScan( ManagedRepositoryConfiguration repo, Date whenGathered, boolean executeOnEntireRepo )
+ public void beginScan( ManagedRepository repo, Date whenGathered, boolean executeOnEntireRepo )
throws ConsumerException
{
beginScan( repo, whenGathered );
*/
import junit.framework.TestCase;
+import org.apache.archiva.admin.model.managed.ManagedRepository;
import org.apache.archiva.metadata.model.ArtifactMetadata;
import org.apache.archiva.metadata.model.MetadataFacet;
import org.apache.archiva.metadata.repository.MetadataRepository;
@Named( value = "knownRepositoryContentConsumer#duplicate-artifacts" )
private DuplicateArtifactsConsumer consumer;
- private ManagedRepositoryConfiguration config;
+ private ManagedRepository config;
private MetadataRepository metadataRepository;
assertNotNull( consumer );
- config = new ManagedRepositoryConfiguration();
+ config = new ManagedRepository();
config.setId( TEST_REPO );
config.setLocation( new File( "target/test-repository" ).getAbsolutePath() );
</dependency>
<dependency>
<groupId>org.apache.archiva</groupId>
- <artifactId>archiva-repository-admin</artifactId>
+ <artifactId>archiva-repository-admin-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>archiva-repository-admin-default</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
</dependency>
<!-- redback -->
+ <dependency>
+ <groupId>org.codehaus.redback</groupId>
+ <artifactId>redback-users-api</artifactId>
+ <version>${redback.version}</version>
+ </dependency>
<dependency>
<groupId>org.codehaus.redback</groupId>
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>org.codehaus.redback</groupId>
+ <artifactId>redback-rbac-cached</artifactId>
+ <version>${redback.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
<dependency>
<groupId>org.codehaus.redback</groupId>
<artifactId>redback-struts2-content</artifactId>