aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Lamy <olamy@apache.org>2012-09-18 22:00:57 +0000
committerOlivier Lamy <olamy@apache.org>2012-09-18 22:00:57 +0000
commit2103f2d60f5b0e763a526de867afd37404a50b56 (patch)
treee345fa2ec1be80dcb847651f1ac3b4c3b2711daf
parentcfb78daaaada7ffde4d03f0c4943e51f5c1f8fdb (diff)
downloadarchiva-2103f2d60f5b0e763a526de867afd37404a50b56.tar.gz
archiva-2103f2d60f5b0e763a526de867afd37404a50b56.zip
finish unit test for getMergeConflictedArtifacts rest method
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1387384 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/archiva/consumers/RepositoryContentConsumer.java3
-rw-r--r--archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/ManagedRepository.java2
-rw-r--r--archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/managed/DefaultManagedRepositoryAdmin.java40
-rw-r--r--archiva-modules/archiva-base/archiva-repository-scanner/src/main/java/org/apache/archiva/repository/scanner/RepositoryContentConsumers.java57
-rw-r--r--archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/main/java/org/apache/archiva/scheduler/repository/RepositoryArchivaTaskScheduler.java42
-rw-r--r--archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/MergeRepositoriesService.java4
-rw-r--r--archiva-modules/archiva-web/archiva-rest/archiva-rest-services/pom.xml27
-rw-r--r--archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/AbstractRestService.java41
-rw-r--r--archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultBrowseService.java20
-rw-r--r--archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultMergeRepositoriesService.java12
-rw-r--r--archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java3
-rw-r--r--archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/utils/ArtifactBuilder.java (renamed from archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/utils/ArtifactDownloadInfoBuilder.java)8
-rw-r--r--archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/AbstractArchivaRestTest.java12
-rw-r--r--archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/MergeRepositoriesServiceTest.java51
-rw-r--r--archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repositories.js4
-rw-r--r--archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/ShowArtifactAction.java4
16 files changed, 208 insertions, 122 deletions
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/archiva/consumers/RepositoryContentConsumer.java b/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/archiva/consumers/RepositoryContentConsumer.java
index 4712ec483..e5e422e27 100644
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/archiva/consumers/RepositoryContentConsumer.java
+++ b/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/archiva/consumers/RepositoryContentConsumer.java
@@ -27,7 +27,8 @@ import java.util.List;
/**
* A consumer of content (files) in the repository.
*
- *
+ * olamy: TODO/FIXME we must review this api, in the current situation we use prototype beans rather than singletons
+ * this is a bit memory consuming the better will be to ConsumerContext bean to transport repository context etc...
*/
public interface RepositoryContentConsumer
extends Consumer
diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/ManagedRepository.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/ManagedRepository.java
index a34469e52..4236ca114 100644
--- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/ManagedRepository.java
+++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/ManagedRepository.java
@@ -51,7 +51,7 @@ public class ManagedRepository
*/
private ManagedRepository stagingRepository;
- private boolean scanned = false;
+ private boolean scanned = true;
/**
diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/managed/DefaultManagedRepositoryAdmin.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/managed/DefaultManagedRepositoryAdmin.java
index 144f86aa3..30e86ca91 100644
--- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/managed/DefaultManagedRepositoryAdmin.java
+++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/managed/DefaultManagedRepositoryAdmin.java
@@ -220,8 +220,8 @@ public class DefaultManagedRepositoryAdmin
managedRepository.getCronExpression(), managedRepository.getIndexDirectory(),
managedRepository.getDaysOlder(), managedRepository.getRetentionCount(),
managedRepository.isDeleteReleasedSnapshots(), managedRepository.getDescription(),
- managedRepository.isSkipPackedIndexCreation(), auditInformation,
- getArchivaConfiguration().getConfiguration() ) != null;
+ managedRepository.isSkipPackedIndexCreation(), managedRepository.isScanned(),
+ auditInformation, getArchivaConfiguration().getConfiguration() ) != null;
createIndexContext( managedRepository );
return res;
@@ -234,7 +234,7 @@ public class DefaultManagedRepositoryAdmin
boolean stageRepoNeeded, String cronExpression,
String indexDir, int daysOlder, int retentionCount,
boolean deteleReleasedSnapshots, String description,
- boolean skipPackedIndexCreation,
+ boolean skipPackedIndexCreation, boolean scanned,
AuditInformation auditInformation,
Configuration config )
throws RepositoryAdminException
@@ -246,6 +246,7 @@ public class DefaultManagedRepositoryAdmin
repository.setBlockRedeployments( blockRedeployments );
repository.setReleases( releasesIncluded );
repository.setSnapshots( snapshotsIncluded );
+ repository.setScanned( scanned );
repository.setName( name );
repository.setLocation( getRepositoryCommonValidator().removeExpressions( location ) );
repository.setLayout( layout );
@@ -286,14 +287,17 @@ public class DefaultManagedRepositoryAdmin
//scan repository when adding of repository is successful
try
{
- scanRepository( repoId, true );
- // olamy no need of scanning staged repo
- /*
- if ( stageRepoNeeded )
+ if ( scanned )
+ {
+ scanRepository( repoId, true );
+ }
+
+ // TODO need a better to define scanning or not for staged repo
+ if ( stageRepoNeeded && scanned )
{
ManagedRepositoryConfiguration stagingRepository = getStageRepoConfig( repository );
scanRepository( stagingRepository.getId(), true );
- }*/
+ }
}
catch ( Exception e )
{
@@ -486,8 +490,8 @@ public class DefaultManagedRepositoryAdmin
managedRepository.getCronExpression(), managedRepository.getIndexDirectory(),
managedRepository.getDaysOlder(), managedRepository.getRetentionCount(),
managedRepository.isDeleteReleasedSnapshots(), managedRepository.getDescription(),
- managedRepository.isSkipPackedIndexCreation(), auditInformation,
- getArchivaConfiguration().getConfiguration() );
+ managedRepository.isSkipPackedIndexCreation(), managedRepository.isScanned(),
+ auditInformation, getArchivaConfiguration().getConfiguration() );
// Save the repository configuration.
RepositorySession repositorySession = getRepositorySessionFactory().createSession();
@@ -631,10 +635,24 @@ public class DefaultManagedRepositoryAdmin
stagingRepository.setBlockRedeployments( repository.isBlockRedeployments() );
stagingRepository.setDaysOlder( repository.getDaysOlder() );
stagingRepository.setDeleteReleasedSnapshots( repository.isDeleteReleasedSnapshots() );
- stagingRepository.setIndexDir( repository.getIndexDir() );
+
String path = repository.getLocation();
int lastIndex = path.replace( '\\', '/' ).lastIndexOf( '/' );
stagingRepository.setLocation( path.substring( 0, lastIndex ) + "/" + stagingRepository.getId() );
+
+ if ( StringUtils.isNotBlank( repository.getIndexDir() ) )
+ {
+ File indexDir = new File( repository.getIndexDir() );
+ // in case of absolute dir do not use the same
+ if ( indexDir.isAbsolute() )
+ {
+ stagingRepository.setIndexDir( stagingRepository.getLocation() + "/.index" );
+ }
+ else
+ {
+ stagingRepository.setIndexDir( repository.getIndexDir() );
+ }
+ }
stagingRepository.setRefreshCronExpression( repository.getRefreshCronExpression() );
stagingRepository.setReleases( repository.isReleases() );
stagingRepository.setRetentionCount( repository.getRetentionCount() );
diff --git a/archiva-modules/archiva-base/archiva-repository-scanner/src/main/java/org/apache/archiva/repository/scanner/RepositoryContentConsumers.java b/archiva-modules/archiva-base/archiva-repository-scanner/src/main/java/org/apache/archiva/repository/scanner/RepositoryContentConsumers.java
index 25150f8b5..381ca77e9 100644
--- a/archiva-modules/archiva-base/archiva-repository-scanner/src/main/java/org/apache/archiva/repository/scanner/RepositoryContentConsumers.java
+++ b/archiva-modules/archiva-base/archiva-repository-scanner/src/main/java/org/apache/archiva/repository/scanner/RepositoryContentConsumers.java
@@ -22,16 +22,16 @@ package org.apache.archiva.repository.scanner;
import org.apache.archiva.admin.model.RepositoryAdminException;
import org.apache.archiva.admin.model.admin.ArchivaAdministration;
import org.apache.archiva.admin.model.beans.ManagedRepository;
+import org.apache.archiva.common.utils.BaseFile;
+import org.apache.archiva.consumers.InvalidRepositoryContentConsumer;
+import org.apache.archiva.consumers.KnownRepositoryContentConsumer;
+import org.apache.archiva.consumers.functors.ConsumerWantsFilePredicate;
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.Closure;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.functors.IfClosure;
-import org.apache.archiva.common.utils.BaseFile;
-import org.apache.archiva.consumers.InvalidRepositoryContentConsumer;
-import org.apache.archiva.consumers.KnownRepositoryContentConsumer;
-import org.apache.archiva.consumers.functors.ConsumerWantsFilePredicate;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
@@ -47,10 +47,8 @@ import java.util.Map;
/**
* RepositoryContentConsumerUtil
- *
- *
*/
-@Service("repositoryContentConsumers")
+@Service ("repositoryContentConsumers")
public class RepositoryContentConsumers
implements ApplicationContextAware
{
@@ -163,22 +161,23 @@ public class RepositoryContentConsumers
public synchronized List<KnownRepositoryContentConsumer> getSelectedKnownConsumers()
throws RepositoryAdminException
{
- if ( selectedKnownConsumers == null )
+ // FIXME only for testing
+ if ( selectedKnownConsumers != null )
{
- List<KnownRepositoryContentConsumer> ret = new ArrayList<KnownRepositoryContentConsumer>();
+ return selectedKnownConsumers;
+ }
+ List<KnownRepositoryContentConsumer> ret = new ArrayList<KnownRepositoryContentConsumer>();
- List<String> knownSelected = getSelectedKnownConsumerIds();
+ List<String> knownSelected = getSelectedKnownConsumerIds();
- for ( KnownRepositoryContentConsumer consumer : getAvailableKnownConsumers() )
+ for ( KnownRepositoryContentConsumer consumer : getAvailableKnownConsumers() )
+ {
+ if ( knownSelected.contains( consumer.getId() ) || consumer.isPermanent() )
{
- if ( knownSelected.contains( consumer.getId() ) || consumer.isPermanent() )
- {
- ret.add( consumer );
- }
+ ret.add( consumer );
}
- this.selectedKnownConsumers = ret;
}
- return selectedKnownConsumers;
+ return ret;
}
/**
@@ -191,24 +190,28 @@ public class RepositoryContentConsumers
public synchronized List<InvalidRepositoryContentConsumer> getSelectedInvalidConsumers()
throws RepositoryAdminException
{
- if ( selectedInvalidConsumers == null )
+
+ // FIXME only for testing
+ if ( selectedInvalidConsumers != null )
{
- List<InvalidRepositoryContentConsumer> ret = new ArrayList<InvalidRepositoryContentConsumer>();
+ return selectedInvalidConsumers;
+ }
- List<String> invalidSelected = getSelectedInvalidConsumerIds();
+ List<InvalidRepositoryContentConsumer> ret = new ArrayList<InvalidRepositoryContentConsumer>();
- for ( InvalidRepositoryContentConsumer consumer : getAvailableInvalidConsumers() )
+ List<String> invalidSelected = getSelectedInvalidConsumerIds();
+
+ for ( InvalidRepositoryContentConsumer consumer : getAvailableInvalidConsumers() )
+ {
+ if ( invalidSelected.contains( consumer.getId() ) || consumer.isPermanent() )
{
- if ( invalidSelected.contains( consumer.getId() ) || consumer.isPermanent() )
- {
- ret.add( consumer );
- }
+ ret.add( consumer );
}
- selectedInvalidConsumers = ret;
}
- return selectedInvalidConsumers;
+ return ret;
}
+
/**
* Get the list of {@link KnownRepositoryContentConsumer} objects that are
* available and present in the classpath and as components in the IoC.
diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/main/java/org/apache/archiva/scheduler/repository/RepositoryArchivaTaskScheduler.java b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/main/java/org/apache/archiva/scheduler/repository/RepositoryArchivaTaskScheduler.java
index ae0245ae7..65894ac78 100644
--- a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/main/java/org/apache/archiva/scheduler/repository/RepositoryArchivaTaskScheduler.java
+++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/main/java/org/apache/archiva/scheduler/repository/RepositoryArchivaTaskScheduler.java
@@ -19,21 +19,21 @@ package org.apache.archiva.scheduler.repository;
* under the License.
*/
+import org.apache.archiva.common.ArchivaException;
+import org.apache.archiva.configuration.ArchivaConfiguration;
+import org.apache.archiva.configuration.ConfigurationEvent;
+import org.apache.archiva.configuration.ConfigurationListener;
+import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
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.redback.components.scheduler.CronExpressionValidator;
import org.apache.archiva.redback.components.scheduler.Scheduler;
-import org.apache.archiva.scheduler.ArchivaTaskScheduler;
-import org.apache.archiva.common.ArchivaException;
-import org.apache.archiva.configuration.ArchivaConfiguration;
-import org.apache.archiva.configuration.ConfigurationEvent;
-import org.apache.archiva.configuration.ConfigurationListener;
-import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.archiva.redback.components.taskqueue.TaskQueue;
import org.apache.archiva.redback.components.taskqueue.TaskQueueException;
-import org.apache.archiva.redback.components.scheduler.CronExpressionValidator;
+import org.apache.archiva.scheduler.ArchivaTaskScheduler;
import org.quartz.SchedulerException;
import org.quartz.impl.JobDetailImpl;
import org.quartz.impl.triggers.CronTriggerImpl;
@@ -54,7 +54,7 @@ import java.util.Set;
/**
* Default implementation of a scheduling component for archiva.
*/
-@Service( "archivaTaskScheduler#repository" )
+@Service ("archivaTaskScheduler#repository")
public class RepositoryArchivaTaskScheduler
implements ArchivaTaskScheduler<RepositoryTask>, ConfigurationListener
{
@@ -73,7 +73,7 @@ public class RepositoryArchivaTaskScheduler
*
*/
@Inject
- @Named( value = "taskQueue#repository-scanning" )
+ @Named (value = "taskQueue#repository-scanning")
private TaskQueue repositoryScanningQueue;
/**
@@ -86,12 +86,11 @@ public class RepositoryArchivaTaskScheduler
*
*/
@Inject
- @Named( value = "repositoryStatisticsManager#default" )
+ @Named (value = "repositoryStatisticsManager#default")
private RepositoryStatisticsManager repositoryStatisticsManager;
/**
* TODO: could have multiple implementations
- *
*/
@Inject
private RepositorySessionFactory repositorySessionFactory;
@@ -174,7 +173,7 @@ public class RepositoryArchivaTaskScheduler
}
- @SuppressWarnings( "unchecked" )
+ @SuppressWarnings ("unchecked")
public boolean isProcessingRepositoryTask( String repositoryId )
{
synchronized ( repositoryScanningQueue )
@@ -201,7 +200,7 @@ public class RepositoryArchivaTaskScheduler
}
}
- @SuppressWarnings( "unchecked" )
+ @SuppressWarnings ("unchecked")
private boolean isProcessingRepositoryTask( RepositoryTask task )
{
synchronized ( repositoryScanningQueue )
@@ -261,6 +260,7 @@ public class RepositoryArchivaTaskScheduler
}
}
}
+
public void configurationEvent( ConfigurationEvent event )
{
if ( event.getType() == ConfigurationEvent.SAVED )
@@ -298,7 +298,7 @@ public class RepositoryArchivaTaskScheduler
}
}
- @SuppressWarnings( "unchecked" )
+ @SuppressWarnings ("unchecked")
private boolean isPreviouslyScanned( ManagedRepositoryConfiguration repoConfig,
MetadataRepository metadataRepository )
throws MetadataRepositoryException
@@ -334,13 +334,13 @@ public class RepositoryArchivaTaskScheduler
{
if ( repoConfig.getRefreshCronExpression() == null )
{
- log.warn( "Skipping job, no cron expression for " + repoConfig.getId() );
+ log.warn( "Skipping job, no cron expression for {}", repoConfig.getId() );
return;
}
if ( !repoConfig.isScanned() )
{
- log.warn( "Skipping job, repository scannable has been disabled for " + repoConfig.getId() );
+ log.warn( "Skipping job, repository scannable has been disabled for {}", repoConfig.getId() );
return;
}
@@ -349,14 +349,15 @@ public class RepositoryArchivaTaskScheduler
if ( !cronValidator.validate( cronString ) )
{
- log.warn( "Cron expression [" + cronString + "] for repository [" + repoConfig.getId()
- + "] is invalid. Defaulting to hourly." );
+ log.warn( "Cron expression [{}] for repository [{}] is invalid. Defaulting to hourly.", cronString,
+ repoConfig.getId() );
cronString = CRON_HOURLY;
}
// setup the unprocessed artifact job
JobDetailImpl repositoryJob =
- new JobDetailImpl( REPOSITORY_JOB + ":" + repoConfig.getId(), REPOSITORY_SCAN_GROUP, RepositoryTaskJob.class );
+ new JobDetailImpl( REPOSITORY_JOB + ":" + repoConfig.getId(), REPOSITORY_SCAN_GROUP,
+ RepositoryTaskJob.class );
repositoryJob.getJobDataMap().put( TASK_QUEUE, repositoryScanningQueue );
repositoryJob.getJobDataMap().put( TASK_REPOSITORY, repoConfig.getId() );
@@ -364,7 +365,8 @@ public class RepositoryArchivaTaskScheduler
try
{
CronTriggerImpl trigger =
- new CronTriggerImpl( REPOSITORY_JOB_TRIGGER + ":" + repoConfig.getId(), REPOSITORY_SCAN_GROUP, cronString );
+ new CronTriggerImpl( REPOSITORY_JOB_TRIGGER + ":" + repoConfig.getId(), REPOSITORY_SCAN_GROUP,
+ cronString );
jobs.add( REPOSITORY_JOB + ":" + repoConfig.getId() );
scheduler.scheduleJob( repositoryJob, trigger );
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/MergeRepositoriesService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/MergeRepositoriesService.java
index 47beb66cf..6ad8326d6 100644
--- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/MergeRepositoriesService.java
+++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/MergeRepositoriesService.java
@@ -18,7 +18,7 @@ package org.apache.archiva.rest.api.services;
* under the License.
*/
-import org.apache.archiva.metadata.model.ArtifactMetadata;
+import org.apache.archiva.maven2.model.Artifact;
import org.apache.archiva.redback.authorization.RedbackAuthorization;
import javax.ws.rs.GET;
@@ -45,6 +45,6 @@ public interface MergeRepositoriesService
* <b>permissions are checked in impl</b>
* @since 1.4-M3
*/
- List<ArtifactMetadata> getMergeConflictedArtifacts( @PathParam ( "repositoryId" ) String repositoryId )
+ List<Artifact> getMergeConflictedArtifacts( @PathParam ( "repositoryId" ) String repositoryId )
throws ArchivaRestServiceException;
}
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/pom.xml b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/pom.xml
index 55ad0eaab..3973d3a73 100644
--- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/pom.xml
+++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/pom.xml
@@ -396,6 +396,11 @@
<version>${tomcat7Version}</version>
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>archiva-metadata-consumer</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
@@ -408,10 +413,9 @@
<configuration>
<excludes>
<exclude>src/test/repo-with-osgi/**</exclude>
+ <exclude>src/test/repo-with-osgi-stage/**</exclude>
<exclude>src/test/repo-with-classifier-only/**</exclude>
<exclude>src/test/repo-with-snapshots/**</exclude>
- <exclude>src/test/resources/target-repo/**</exclude>
- <exclude>src/test/resources/test-repository-stage/**</exclude>
</excludes>
</configuration>
</plugin>
@@ -443,30 +447,13 @@
<redback.jdbc.url>${redbackTestJdbcUrl}</redback.jdbc.url>
<redback.jdbc.driver.name>${redbackTestJdbcDriver}</redback.jdbc.driver.name>
<basedir>${basedir}</basedir>
+ <builddir>${project.build.directory}</builddir>
<org.apache.jackrabbit.maxCacheMemory>1</org.apache.jackrabbit.maxCacheMemory>
<org.apache.jackrabbit.maxMemoryPerCache>1</org.apache.jackrabbit.maxMemoryPerCache>
<!--org.apache.jackrabbit.minMemoryPerCache>1</org.apache.jackrabbit.minMemoryPerCache-->
</systemPropertyVariables>
</configuration>
</plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- <executions>
- <execution>
- <id>test-repository</id>
- <phase>generate-test-resources</phase>
- <goals>
- <goal>unpack-dependencies</goal>
- </goals>
- <configuration>
- <includeArtifactIds>test-repository</includeArtifactIds>
- <outputDirectory>target/test-repository</outputDirectory>
- <excludes>META-INF/**</excludes>
- </configuration>
- </execution>
- </executions>
- </plugin>
</plugins>
</build>
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/AbstractRestService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/AbstractRestService.java
index 6ea8f6bf0..d624fc6c5 100644
--- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/AbstractRestService.java
+++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/AbstractRestService.java
@@ -26,13 +26,17 @@ import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
import org.apache.archiva.audit.AuditEvent;
import org.apache.archiva.audit.AuditListener;
import org.apache.archiva.common.utils.VersionUtil;
+import org.apache.archiva.maven2.model.Artifact;
+import org.apache.archiva.metadata.model.ArtifactMetadata;
import org.apache.archiva.metadata.repository.RepositorySessionFactory;
import org.apache.archiva.redback.rest.services.RedbackAuthenticationThreadLocal;
import org.apache.archiva.redback.rest.services.RedbackRequestInformation;
import org.apache.archiva.redback.users.User;
import org.apache.archiva.redback.users.UserManager;
-import org.apache.archiva.maven2.model.Artifact;
+import org.apache.archiva.repository.RepositoryContentFactory;
+import org.apache.archiva.repository.RepositoryException;
import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
+import org.apache.archiva.rest.services.utils.ArtifactBuilder;
import org.apache.archiva.security.AccessDeniedException;
import org.apache.archiva.security.ArchivaSecurityException;
import org.apache.archiva.security.PrincipalNotFoundException;
@@ -72,7 +76,7 @@ public abstract class AbstractRestService
@Inject
- @Named( value = "repositorySessionFactory" )
+ @Named (value = "repositorySessionFactory")
protected RepositorySessionFactory repositorySessionFactory;
@Inject
@@ -81,6 +85,9 @@ public abstract class AbstractRestService
@Inject
protected ManagedRepositoryAdmin managedRepositoryAdmin;
+ @Inject
+ protected RepositoryContentFactory repositoryContentFactory;
+
@Context
protected HttpServletRequest httpServletRequest;
@@ -235,4 +242,34 @@ public abstract class AbstractRestService
Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), e );
}
}
+
+ protected List<Artifact> buildArtifacts( List<ArtifactMetadata> artifactMetadatas, String repositoryId )
+ throws ArchivaRestServiceException
+ {
+ try
+ {
+ if ( artifactMetadatas != null && !artifactMetadatas.isEmpty() )
+ {
+ List<Artifact> artifacts = new ArrayList<Artifact>( artifactMetadatas.size() );
+ for ( ArtifactMetadata artifact : artifactMetadatas )
+ {
+
+ ArtifactBuilder builder =
+ new ArtifactBuilder().forArtifactMetadata( artifact ).withManagedRepositoryContent(
+ repositoryContentFactory.getManagedRepositoryContent( repositoryId ) );
+ Artifact art = builder.build();
+ art.setUrl( getArtifactUrl( art ) );
+ artifacts.add( art );
+ }
+ return artifacts;
+ }
+ return Collections.emptyList();
+ }
+ catch ( RepositoryException e )
+ {
+ log.error( e.getMessage(), e );
+ throw new ArchivaRestServiceException( e.getMessage(),
+ Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), e );
+ }
+ }
}
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultBrowseService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultBrowseService.java
index dad8ace21..d087af144 100644
--- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultBrowseService.java
+++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultBrowseService.java
@@ -51,8 +51,8 @@ import org.apache.archiva.rest.api.model.Entry;
import org.apache.archiva.rest.api.model.VersionsList;
import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
import org.apache.archiva.rest.api.services.BrowseService;
+import org.apache.archiva.rest.services.utils.ArtifactBuilder;
import org.apache.archiva.rest.services.utils.ArtifactContentEntryComparator;
-import org.apache.archiva.rest.services.utils.ArtifactDownloadInfoBuilder;
import org.apache.archiva.security.ArchivaSecurityException;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.io.FileUtils;
@@ -686,26 +686,10 @@ public class DefaultBrowseService
metadataResolver.resolveArtifacts( session, repoId, groupId, artifactId, version ) );
Collections.sort( artifacts, ArtifactMetadataVersionComparator.INSTANCE );
- for ( ArtifactMetadata artifact : artifacts )
- {
-
- ArtifactDownloadInfoBuilder builder =
- new ArtifactDownloadInfoBuilder().forArtifactMetadata( artifact ).withManagedRepositoryContent(
- repositoryContentFactory.getManagedRepositoryContent( repoId ) );
- Artifact art = builder.build();
-
- art.setUrl( getArtifactUrl( art ) );
- artifactDownloadInfos.add( art );
- }
+ return buildArtifacts( artifacts, repositoryId );
}
}
- catch ( RepositoryException e )
- {
- log.error( e.getMessage(), e );
- throw new ArchivaRestServiceException( e.getMessage(),
- Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), e );
- }
catch ( MetadataResolutionException e )
{
log.error( e.getMessage(), e );
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultMergeRepositoriesService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultMergeRepositoriesService.java
index 4c5b9f260..3c20deb80 100644
--- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultMergeRepositoriesService.java
+++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultMergeRepositoriesService.java
@@ -18,6 +18,7 @@ package org.apache.archiva.rest.services;
* under the License.
*/
+import org.apache.archiva.maven2.model.Artifact;
import org.apache.archiva.metadata.model.ArtifactMetadata;
import org.apache.archiva.metadata.repository.RepositorySession;
import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
@@ -43,15 +44,19 @@ public class DefaultMergeRepositoriesService
@Named ( value = "repositoryMerger#maven2" )
private Maven2RepositoryMerger repositoryMerger;
- public List<ArtifactMetadata> getMergeConflictedArtifacts( String repositoryId )
+
+ public List<Artifact> getMergeConflictedArtifacts( String repositoryId )
throws ArchivaRestServiceException
{
String sourceRepoId = repositoryId + "-stage";
RepositorySession repositorySession = repositorySessionFactory.createSession();
try
{
- return repositoryMerger.getConflictingArtifacts( repositorySession.getRepository(), sourceRepoId,
- repositoryId );
+ List<ArtifactMetadata> artifactMetadatas =
+ repositoryMerger.getConflictingArtifacts( repositorySession.getRepository(), sourceRepoId,
+ repositoryId );
+
+ return buildArtifacts( artifactMetadatas, repositoryId );
}
catch ( Exception e )
{
@@ -61,5 +66,6 @@ public class DefaultMergeRepositoriesService
{
repositorySession.close();
}
+
}
}
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java
index 5e186cfce..420d24d3c 100644
--- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java
+++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java
@@ -70,11 +70,11 @@ import org.apache.archiva.scheduler.indexing.ArchivaIndexingTaskExecutor;
import org.apache.archiva.scheduler.indexing.ArtifactIndexingTask;
import org.apache.archiva.scheduler.indexing.DownloadRemoteIndexException;
import org.apache.archiva.scheduler.indexing.DownloadRemoteIndexScheduler;
+import org.apache.archiva.scheduler.repository.ArchivaRepositoryScanningTaskExecutor;
import org.apache.archiva.scheduler.repository.RepositoryArchivaTaskScheduler;
import org.apache.archiva.scheduler.repository.RepositoryTask;
import org.apache.archiva.security.ArchivaSecurityException;
import org.apache.archiva.security.common.ArchivaRoleConstants;
-import org.apache.archiva.stagerepository.merge.Maven2RepositoryMerger;
import org.apache.archiva.xml.XMLException;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.IOUtils;
@@ -86,7 +86,6 @@ import org.springframework.stereotype.Service;
import javax.inject.Inject;
import javax.inject.Named;
-import javax.ws.rs.PathParam;
import javax.ws.rs.core.Response;
import java.io.File;
import java.io.FileInputStream;
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/utils/ArtifactDownloadInfoBuilder.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/utils/ArtifactBuilder.java
index 8e29e1d2a..ed6d8447f 100644
--- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/utils/ArtifactDownloadInfoBuilder.java
+++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/utils/ArtifactBuilder.java
@@ -34,26 +34,26 @@ import java.util.Locale;
* @author Olivier Lamy
* @since 1.4-M3
*/
-public class ArtifactDownloadInfoBuilder
+public class ArtifactBuilder
{
private ManagedRepositoryContent managedRepositoryContent;
private ArtifactMetadata artifactMetadata;
- public ArtifactDownloadInfoBuilder()
+ public ArtifactBuilder()
{
// no op
}
- public ArtifactDownloadInfoBuilder withManagedRepositoryContent( ManagedRepositoryContent managedRepositoryContent )
+ public ArtifactBuilder withManagedRepositoryContent( ManagedRepositoryContent managedRepositoryContent )
{
this.managedRepositoryContent = managedRepositoryContent;
return this;
}
- public ArtifactDownloadInfoBuilder forArtifactMetadata( ArtifactMetadata artifactMetadata )
+ public ArtifactBuilder forArtifactMetadata( ArtifactMetadata artifactMetadata )
{
this.artifactMetadata = artifactMetadata;
return this;
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/AbstractArchivaRestTest.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/AbstractArchivaRestTest.java
index 27b41ccd2..2762108a2 100644
--- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/AbstractArchivaRestTest.java
+++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/AbstractArchivaRestTest.java
@@ -441,6 +441,7 @@ public abstract class AbstractArchivaRestTest
System.getProperty( "java.io.tmpdir" ) + "/target/.index-" + Long.toString( new Date().getTime() ) );
managedRepository.setStageRepoNeeded( stageNeeded );
+ managedRepository.setSnapshots( true );
ManagedRepositoriesService service = getManagedRepositoriesService( authorizationHeader );
service.addManagedRepository( managedRepository );
@@ -463,10 +464,17 @@ public abstract class AbstractArchivaRestTest
createAndIndexRepo( testRepoId, repoPath, true, false );
}
- protected void createStagedNeededAndIndexRepo( String testRepoId, String repoPath )
+ protected void createStagedNeededRepo( String testRepoId, String repoPath, boolean scan )
throws Exception
{
- createAndIndexRepo( testRepoId, repoPath, true, true );
+ createAndIndexRepo( testRepoId, repoPath, scan, true );
+ RepositoriesService repositoriesService = getRepositoriesService( authorizationHeader );
+ repositoriesService.scanRepositoryDirectoriesNow( testRepoId );
+ if ( scan )
+ {
+ repositoriesService.scanRepositoryNow( testRepoId + "-stage", true );
+ repositoriesService.scanRepositoryDirectoriesNow( testRepoId + "-stage" );
+ }
}
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/MergeRepositoriesServiceTest.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/MergeRepositoriesServiceTest.java
index a32794623..ecba587cf 100644
--- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/MergeRepositoriesServiceTest.java
+++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/MergeRepositoriesServiceTest.java
@@ -18,8 +18,13 @@ package org.apache.archiva.rest.services;
* under the License.
*/
-import org.apache.archiva.metadata.model.ArtifactMetadata;
+import org.apache.archiva.maven2.model.Artifact;
+import org.apache.archiva.rest.api.services.BrowseService;
import org.apache.archiva.rest.api.services.MergeRepositoriesService;
+import org.apache.commons.io.FileUtils;
+import org.fest.assertions.api.Assertions;
+import org.junit.After;
+import org.junit.Before;
import org.junit.Test;
import java.io.File;
@@ -31,23 +36,59 @@ import java.util.List;
public class MergeRepositoriesServiceTest
extends AbstractArchivaRestTest
{
+
+ @Override
+ @Before
+ public void startServer()
+ throws Exception
+ {
+
+ FileUtils.copyDirectory( new File( System.getProperty( "basedir" ), "src/test/repo-with-osgi" ),
+ new File( System.getProperty( "builddir" ), "test-repository" ) );
+ FileUtils.copyDirectory( new File( System.getProperty( "basedir" ), "src/test/repo-with-osgi-stage" ),
+ new File( System.getProperty( "builddir" ), "test-repository-stage" ) );
+ super.startServer();
+
+ }
+
+ @Override
+ @After
+ public void stopServer()
+ throws Exception
+ {
+ // TODO delete repositories
+ super.stopServer();
+ FileUtils.deleteDirectory( new File( System.getProperty( "builddir" ), "test-repository" ) );
+ FileUtils.deleteDirectory( new File( System.getProperty( "builddir" ), "test-repository-stage" ) );
+ }
+
@Test
public void mergeConflictedArtifacts()
throws Exception
{
try
{
- String testRepoId = "test-repo";
- createStagedNeededAndIndexRepo( testRepoId, new File( "target/target-repo" ).getAbsolutePath() );
+ String testRepoId = "test-repository";
+ createStagedNeededRepo( testRepoId,
+ new File( System.getProperty( "builddir" ), "test-repository" ).getAbsolutePath(),
+ true );
+
+ // force jcr data population !
+ BrowseService browseService = getBrowseService( authorizationHeader, false );
+ browseService.getRootGroups( testRepoId );
+ browseService.getRootGroups( testRepoId + "-stage" );
MergeRepositoriesService service = getMergeRepositoriesService();
- List<ArtifactMetadata> artifactMetadatas = service.getMergeConflictedArtifacts( testRepoId );
+ List<Artifact> artifactMetadatas = service.getMergeConflictedArtifacts( testRepoId );
log.info( "conflicts: {}", artifactMetadatas );
+ Assertions.assertThat( artifactMetadatas ).isNotNull().isNotEmpty().hasSize( 8 );
+
deleteTestRepo( testRepoId );
- } catch( Exception e)
+ }
+ catch ( Exception e )
{
log.error( e.getMessage(), e );
throw e;
diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repositories.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repositories.js
index 068200288..236f0a117 100644
--- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repositories.js
+++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repositories.js
@@ -72,8 +72,8 @@ define("archiva.repositories",["jquery","i18n","jquery.tmpl","bootstrap","jquery
this.retentionCount=ko.observable(retentionCount);
this.retentionCount.subscribe(function(newValue){self.modified(true)});
- //private boolean scanned = false;
- this.scanned=ko.observable(scanned);
+ //private boolean scanned = true;
+ this.scanned=ko.observable(scanned?scanned:true);
this.scanned.subscribe(function(newValue){self.modified(true)});
//private boolean deleteReleasedSnapshots;
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/ShowArtifactAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/ShowArtifactAction.java
index bbc6bf2fb..d6cb7b8a0 100644
--- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/ShowArtifactAction.java
+++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/ShowArtifactAction.java
@@ -38,7 +38,7 @@ import org.apache.archiva.repository.RepositoryContentFactory;
import org.apache.archiva.repository.RepositoryException;
import org.apache.archiva.repository.RepositoryNotFoundException;
import org.apache.archiva.maven2.model.Artifact;
-import org.apache.archiva.rest.services.utils.ArtifactDownloadInfoBuilder;
+import org.apache.archiva.rest.services.utils.ArtifactBuilder;
import org.apache.commons.lang.StringUtils;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
@@ -219,7 +219,7 @@ public class ShowArtifactAction
this.artifacts.put( artifact.getVersion(), l );
}
- ArtifactDownloadInfoBuilder builder = new ArtifactDownloadInfoBuilder().forArtifactMetadata(
+ ArtifactBuilder builder = new ArtifactBuilder().forArtifactMetadata(
artifact ).withManagedRepositoryContent(
repositoryFactory.getManagedRepositoryContent( repositoryId ) );
l.add( builder.build() );