aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-modules
diff options
context:
space:
mode:
authorOlivier Lamy <olamy@apache.org>2013-02-07 14:57:55 +0000
committerOlivier Lamy <olamy@apache.org>2013-02-07 14:57:55 +0000
commitcde16b4a260af25c44a5e349db580f5e224fce07 (patch)
tree7acbdc5a95a0b486fdd1501a6ab272cb6ee2d801 /archiva-modules
parente0ecff38ea3e9d4f6c9b3bf4f93843e572e38bd1 (diff)
downloadarchiva-cde16b4a260af25c44a5e349db580f5e224fce07.tar.gz
archiva-cde16b4a260af25c44a5e349db580f5e224fce07.zip
use a bean class for request to ease future enhancements
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1443527 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules')
-rw-r--r--archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/DefaultIndexMerger.java11
-rw-r--r--archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/IndexMerger.java5
-rw-r--r--archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/TemporaryGroupIndex.java5
-rw-r--r--archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/TemporaryGroupIndexCleaner.java6
-rw-r--r--archiva-modules/archiva-web/archiva-webapp/pom.xml1
-rw-r--r--archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java14
6 files changed, 24 insertions, 18 deletions
diff --git a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/DefaultIndexMerger.java b/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/DefaultIndexMerger.java
index e4b69a97f..aaee1e576 100644
--- a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/DefaultIndexMerger.java
+++ b/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/DefaultIndexMerger.java
@@ -47,7 +47,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
* @author Olivier Lamy
* @since 1.4-M2
*/
-@Service("indexMerger#default")
+@Service( "indexMerger#default" )
public class DefaultIndexMerger
implements IndexMerger
{
@@ -87,7 +87,7 @@ public class DefaultIndexMerger
this.groupMergedIndexTtl = Integer.getInteger( IndexMerger.TMP_GROUP_INDEX_SYS_KEY, DEFAULT_GROUP_INDEX_TTL );
}
- public IndexingContext buildMergedIndex( Collection<String> repositoriesIds, boolean packIndex )
+ public IndexingContext buildMergedIndex( IndexMergerRequest indexMergerRequest )
throws IndexMergerException
{
File tempRepoFile = Files.createTempDir();
@@ -102,7 +102,7 @@ public class DefaultIndexMerger
indexer.addIndexingContext( tempRepoId, tempRepoId, tempRepoFile, indexLocation, null, null,
mavenIndexerUtils.getAllIndexCreators() );
- for ( String repoId : repositoriesIds )
+ for ( String repoId : indexMergerRequest.getRepositoriesIds() )
{
IndexingContext idxToMerge = indexer.getIndexingContexts().get( repoId );
if ( idxToMerge != null )
@@ -113,12 +113,13 @@ public class DefaultIndexMerger
indexingContext.optimize();
- if ( packIndex )
+ if ( indexMergerRequest.isPackIndex() )
{
IndexPackingRequest request = new IndexPackingRequest( indexingContext, indexLocation );
indexPacker.packIndex( request );
}
- temporaryGroupIndexes.add( new TemporaryGroupIndex( tempRepoFile, tempRepoId ) );
+ temporaryGroupIndexes.add(
+ new TemporaryGroupIndex( tempRepoFile, tempRepoId, indexMergerRequest.getGroupId() ) );
return indexingContext;
}
catch ( IOException e )
diff --git a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/IndexMerger.java b/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/IndexMerger.java
index be0fb10e1..b7d6fd487 100644
--- a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/IndexMerger.java
+++ b/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/IndexMerger.java
@@ -35,12 +35,11 @@ public interface IndexMerger
static final String TMP_GROUP_INDEX_SYS_KEY = "archiva.tmp.group.index.ttl";
/**
- * @param repositoriesIds repositories Ids to merge content
- * @param packIndex will generate a downloadable index
+ * @param indexMergerRequest
* @return a temporary directory with a merge index (directory marked deleteOnExit)
* @throws IndexMergerException
*/
- IndexingContext buildMergedIndex( Collection<String> repositoriesIds, boolean packIndex )
+ IndexingContext buildMergedIndex( IndexMergerRequest indexMergerRequest )
throws IndexMergerException;
void cleanTemporaryGroupIndex( TemporaryGroupIndex temporaryGroupIndex );
diff --git a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/TemporaryGroupIndex.java b/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/TemporaryGroupIndex.java
index 489ac1594..06bb69e68 100644
--- a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/TemporaryGroupIndex.java
+++ b/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/TemporaryGroupIndex.java
@@ -34,10 +34,13 @@ public class TemporaryGroupIndex
private String indexId;
- public TemporaryGroupIndex( File directory, String indexId )
+ private String groupId;
+
+ public TemporaryGroupIndex( File directory, String indexId, String groupId )
{
this.directory = directory;
this.indexId = indexId;
+ this.groupId = groupId;
}
public long getCreationTime()
diff --git a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/TemporaryGroupIndexCleaner.java b/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/TemporaryGroupIndexCleaner.java
index edfec5a77..8d0cedaeb 100644
--- a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/TemporaryGroupIndexCleaner.java
+++ b/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/TemporaryGroupIndexCleaner.java
@@ -51,14 +51,14 @@ public class TemporaryGroupIndexCleaner
}
// 900000
- @Scheduled( fixedDelay = 900000 )
+ @Scheduled(fixedDelay = 900000)
public void cleanTemporaryIndex()
{
log.info( "cleanTemporaryIndex" );
for ( TemporaryGroupIndex temporaryGroupIndex : indexMerger.getTemporaryGroupIndexes() )
{
- // cleanup files older than 60 minutes 3600000
- if ( new Date().getTime() - temporaryGroupIndex.getCreationTime() > 3600000 )
+ // cleanup files older than the ttl
+ if ( new Date().getTime() - temporaryGroupIndex.getCreationTime() > indexMerger.getGroupMergedIndexTtl() )
{
indexMerger.cleanTemporaryGroupIndex( temporaryGroupIndex );
diff --git a/archiva-modules/archiva-web/archiva-webapp/pom.xml b/archiva-modules/archiva-web/archiva-webapp/pom.xml
index d76d5fa52..8c8bceba6 100644
--- a/archiva-modules/archiva-web/archiva-webapp/pom.xml
+++ b/archiva-modules/archiva-web/archiva-webapp/pom.xml
@@ -991,6 +991,7 @@
<archiva.devMode>${archiva.devMode}</archiva.devMode>
<archiva.javascriptLog>${archiva.javascriptLog}</archiva.javascriptLog>
<archiva.logMissingI18n>${archiva.logMissingI18n}</archiva.logMissingI18n>
+ <archiva.tmp.group.index.ttl>0</archiva.tmp.group.index.ttl>
</systemProperties>
<additionalClasspathDirs>
<additionalClasspathDir>${basedir}/src/test/tomcat</additionalClasspathDir>
diff --git a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java
index a2b7efec0..7078cadca 100644
--- a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java
+++ b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java
@@ -33,6 +33,7 @@ import org.apache.archiva.configuration.ArchivaConfiguration;
import org.apache.archiva.configuration.RepositoryGroupConfiguration;
import org.apache.archiva.indexer.merger.IndexMerger;
import org.apache.archiva.indexer.merger.IndexMergerException;
+import org.apache.archiva.indexer.merger.IndexMergerRequest;
import org.apache.archiva.indexer.merger.TemporaryGroupIndex;
import org.apache.archiva.indexer.search.RepositorySearch;
import org.apache.archiva.maven2.metadata.MavenMetadataReader;
@@ -109,7 +110,7 @@ import java.util.Set;
/**
*
*/
-@Service("davResourceFactory#archiva")
+@Service( "davResourceFactory#archiva" )
public class ArchivaDavResourceFactory
implements DavResourceFactory, Auditable
{
@@ -140,7 +141,7 @@ public class ArchivaDavResourceFactory
*
*/
@Inject
- @Named(value = "repositoryProxyConnectors#default")
+ @Named( value = "repositoryProxyConnectors#default" )
private RepositoryProxyConnectors connectors;
/**
@@ -170,7 +171,7 @@ public class ArchivaDavResourceFactory
*
*/
@Inject
- @Named(value = "httpAuthenticator#basic")
+ @Named( value = "httpAuthenticator#basic" )
private HttpAuthenticator httpAuth;
@Inject
@@ -206,7 +207,7 @@ public class ArchivaDavResourceFactory
*
*/
@Inject
- @Named(value = "archivaTaskScheduler#repository")
+ @Named( value = "archivaTaskScheduler#repository" )
private RepositoryArchivaTaskScheduler scheduler;
private ApplicationContext applicationContext;
@@ -1216,10 +1217,11 @@ public class ArchivaDavResourceFactory
}
log.info( "generate temporary merged index for repository group '{}' for repositories '{}'", groupId,
authzRepos );
- IndexingContext indexingContext = indexMerger.buildMergedIndex( authzRepos, true );
+ IndexingContext indexingContext =
+ indexMerger.buildMergedIndex( new IndexMergerRequest( authzRepos, true, groupId ) );
File mergedRepoDir = indexingContext.getIndexDirectoryFile();
TemporaryGroupIndex temporaryGroupIndex =
- new TemporaryGroupIndex( mergedRepoDir, indexingContext.getId() ).setCreationTime(
+ new TemporaryGroupIndex( mergedRepoDir, indexingContext.getId(), groupId ).setCreationTime(
new Date().getTime() );
temporaryGroupIndexMap.put( groupId, temporaryGroupIndex );
session.setAttribute( TemporaryGroupIndexSessionCleaner.TEMPORARY_INDEX_SESSION_KEY,