<defaultValue>/.indexer</defaultValue>
<description>The path of the merged index.</description>
</field>
+ <field>
+ <name>mergedIndexTtl</name>
+ <version>1.4.0+</version>
+ <type>int</type>
+ <required>false</required>
+ <defaultValue>30</defaultValue>
+ <description>The time to live of the merged index of the repository group.</description>
+ </field>
<field>
<name>repositories</name>
<version>1.2.0+</version>
*/
private String mergedIndexPath = "/.indexer";
+ /**
+ * The TTL (time to live) of the repo group's merged index.
+ */
+ private int mergedIndexTtl = 30;
+
public RepositoryGroup()
{
// no op
this.mergedIndexPath = mergedIndexPath;
}
- public RepositoryGroup mergedIndexPath( String mergedIndexPath )
- {
+ public int getMergedIndexTtl() {
+ return mergedIndexTtl;
+ }
+
+ /**
+ * Set the TTL of the repo group's merged index.
+ *
+ * @param mergedIndexTtl
+ */
+ public void setMergedIndexTtl(int mergedIndexTtl) {
+ this.mergedIndexTtl = mergedIndexTtl;
+ }
+
+ public RepositoryGroup mergedIndexPath( String mergedIndexPath ) {
this.mergedIndexPath = mergedIndexPath;
return this;
}
+ public RepositoryGroup mergedIndexTtl( int mergedIndexTtl ) {
+ this.mergedIndexTtl = mergedIndexTtl;
+ return this;
+ }
+
public boolean equals( Object other )
{
if ( this == other )
{
repositoriesGroups.add( new RepositoryGroup( repositoryGroupConfiguration.getId(), new ArrayList<String>(
repositoryGroupConfiguration.getRepositories() ) ).mergedIndexPath(
- repositoryGroupConfiguration.getMergedIndexPath() ) );
+ repositoryGroupConfiguration.getMergedIndexPath() ).mergedIndexTtl( repositoryGroupConfiguration.getMergedIndexTtl() ) );
}
return repositoriesGroups;
{
validateRepositoryGroup( repositoryGroup, false );
validateManagedRepositoriesExists( repositoryGroup.getRepositories() );
+
RepositoryGroupConfiguration repositoryGroupConfiguration = new RepositoryGroupConfiguration();
repositoryGroupConfiguration.setId( repositoryGroup.getId() );
repositoryGroupConfiguration.setRepositories( repositoryGroup.getRepositories() );
repositoryGroupConfiguration.setMergedIndexPath( repositoryGroup.getMergedIndexPath() );
+ repositoryGroupConfiguration.setMergedIndexTtl( repositoryGroup.getMergedIndexTtl() );
Configuration configuration = getArchivaConfiguration().getConfiguration();
configuration.addRepositoryGroup( repositoryGroupConfiguration );
saveConfiguration( configuration );
repositoryGroupConfiguration.setRepositories( repositoryGroup.getRepositories() );
repositoryGroupConfiguration.setMergedIndexPath( repositoryGroup.getMergedIndexPath() );
+ repositoryGroupConfiguration.setMergedIndexTtl( repositoryGroup.getMergedIndexTtl() );
configuration.addRepositoryGroup( repositoryGroupConfiguration );
saveConfiguration( configuration );
"Invalid character(s) found in identifier. Only the following characters are allowed: alphanumeric, '.', '-' and '_'" );
}
+ if ( repositoryGroup.getMergedIndexTtl() <= 0)
+ {
+ throw new RepositoryAdminException( "Merged Index TTL must be greater than 0." );
+ }
+
Configuration configuration = getArchivaConfiguration().getConfiguration();
if ( configuration.getRepositoryGroupsAsMap().containsKey( repoGroupId ) )
* under the License.
*/
+import org.apache.archiva.admin.model.RepositoryAdminException;
import org.apache.archiva.admin.model.beans.ManagedRepository;
import org.apache.archiva.admin.model.beans.RepositoryGroup;
import org.apache.archiva.admin.model.group.RepositoryGroupAdmin;
assertEquals( Arrays.asList( "test-new-one", "test-new-two" ),
repositoryGroupAdmin.getRepositoriesGroups().get( 0 ).getRepositories() );
+ // verify if default values were saved
+ assertEquals(30, repositoryGroupAdmin.getRepositoriesGroups().get( 0 ).getMergedIndexTtl() );
+ assertEquals("/.indexer", repositoryGroupAdmin.getRepositoriesGroups().get( 0 ).getMergedIndexPath() );
+
repositoryGroupAdmin.deleteRepositoryGroup( "repo-group-one", getFakeAuditInformation() );
assertEquals( 0, repositoryGroupAdmin.getRepositoriesGroups().size() );
managedRepositoryAdmin.addManagedRepository( managedRepositoryTwo, false, getFakeAuditInformation() );
- RepositoryGroup repositoryGroup = new RepositoryGroup( "repo-group-one", Arrays.asList( "test-new-one" ) );
+ RepositoryGroup repositoryGroup = new RepositoryGroup( "repo-group-one", Arrays.asList( "test-new-one" ) )
+ .mergedIndexTtl( 20 ).mergedIndexPath( "/.nonDefaultPath" );
mockAuditListener.clearEvents();
assertEquals( 1, repositoryGroupAdmin.getRepositoriesGroups().get( 0 ).getRepositories().size() );
assertEquals( Arrays.asList( "test-new-one" ),
repositoryGroupAdmin.getRepositoriesGroups().get( 0 ).getRepositories() );
+ assertEquals( 20, repositoryGroupAdmin.getRepositoriesGroups().get( 0 ).getMergedIndexTtl() );
+ assertEquals( "/.nonDefaultPath", repositoryGroupAdmin.getRepositoriesGroups().get( 0 ).getMergedIndexPath() );
repositoryGroup = repositoryGroupAdmin.getRepositoryGroup( "repo-group-one" );
assertNotNull( repositoryGroup );
}
}
-
@Test
- public void addAndDeleteGroupWithRemowingManagedRepo()
+ public void addAndDeleteGroupWithRemovedManagedRepo()
throws Exception
{
try
managedRepositoryAdmin.deleteManagedRepository( "test-new-two", getFakeAuditInformation(), true );
}
}
+
+ @Test( expected = RepositoryAdminException.class )
+ public void testAddGroupWithInvalidMergedIndexTtl() 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" ) )
+ .mergedIndexTtl( -1 );
+
+ mockAuditListener.clearEvents();
+
+ repositoryGroupAdmin.addRepositoryGroup( repositoryGroup, getFakeAuditInformation() );
+ }
+ finally
+ {
+ mockAuditListener.clearEvents();
+ managedRepositoryAdmin.deleteManagedRepository( "test-new-one", getFakeAuditInformation(), true );
+ managedRepositoryAdmin.deleteManagedRepository( "test-new-two", getFakeAuditInformation(), true );
+ }
+ }
+
+ @Test( expected = RepositoryAdminException.class )
+ public void testAddAndUpdateGroupWithInvalidMergedIndexTtl() 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() );
+
+ // verify if default values were saved
+ assertEquals(30, repositoryGroupAdmin.getRepositoriesGroups().get( 0 ).getMergedIndexTtl() );
+ assertEquals("/.indexer", repositoryGroupAdmin.getRepositoriesGroups().get( 0 ).getMergedIndexPath() );
+
+ repositoryGroup = repositoryGroupAdmin.getRepositoryGroup( "repo-group-one" );
+ assertNotNull( repositoryGroup );
+
+ repositoryGroup.mergedIndexTtl( -1 );
+
+ repositoryGroupAdmin.updateRepositoryGroup( repositoryGroup, getFakeAuditInformation() );
+ }
+ finally
+ {
+ mockAuditListener.clearEvents();
+ managedRepositoryAdmin.deleteManagedRepository( "test-new-one", getFakeAuditInformation(), true );
+ managedRepositoryAdmin.deleteManagedRepository( "test-new-two", getFakeAuditInformation(), true );
+ }
+ }
}
for ( org.apache.archiva.admin.model.beans.RepositoryGroup repoGroup : repositoryGroupAdmin.getRepositoriesGroups() )
{
repositoriesGroups.add( new RepositoryGroup( repoGroup.getId(), new ArrayList<String>(
- repoGroup.getRepositories() ) ).mergedIndexPath( repoGroup.getMergedIndexPath() ) );
+ repoGroup.getRepositories() ) ).mergedIndexPath( repoGroup.getMergedIndexPath() )
+ .mergedIndexTtl( repoGroup.getMergedIndexTtl() ) );
}
return repositoriesGroups;
}
{
return repositoryGroupAdmin.addRepositoryGroup(
new org.apache.archiva.admin.model.beans.RepositoryGroup( repoGroup.getId(), new ArrayList<String>(
- repoGroup.getRepositories() ) ).mergedIndexPath( repoGroup.getMergedIndexPath() ),
- getAuditInformation() );
+ repoGroup.getRepositories() ) ).mergedIndexPath( repoGroup.getMergedIndexPath() )
+ .mergedIndexTtl( repoGroup.getMergedIndexTtl() ), getAuditInformation() );
}
catch ( RepositoryAdminException e )
{
{
return repositoryGroupAdmin.updateRepositoryGroup(
new org.apache.archiva.admin.model.beans.RepositoryGroup( repoGroup.getId(), new ArrayList<String>(
- repoGroup.getRepositories() ) ).mergedIndexPath( repoGroup.getMergedIndexPath() ),
- getAuditInformation() );
+ repoGroup.getRepositories() ) ).mergedIndexPath( repoGroup.getMergedIndexPath() )
+ .mergedIndexTtl( repoGroup.getMergedIndexTtl() ), getAuditInformation() );
}
catch ( RepositoryAdminException e )
{
managedRepositoriesService.addManagedRepository( managedRepository );
- RepositoryGroup repositoryGroup = new RepositoryGroup( "one", Arrays.asList( managedRepository.getId() ) );
+ RepositoryGroup repositoryGroup = new RepositoryGroup( "one", Arrays.asList( managedRepository.getId() ) )
+ .mergedIndexTtl( 40 );
service.addRepositoryGroup( repositoryGroup );
assertFalse( service.getRepositoriesGroups().isEmpty() );
assertEquals( 1, service.getRepositoriesGroups().size() );
+ assertEquals( 40, service.getRepositoriesGroups().get(0).getMergedIndexTtl() );
service.deleteRepositoryGroup( "one" );
repository-groups.grid.tab.title=Repository Groups
repository.group.delete.confirm=Are you sure to delete Repository Group {0} ?
repository.group.mergedIndexPath=Merged Index Path
+repository.group.mergedIndexTtl=Merged Index Time to Live (in Minutes)
#roles
roles.bulk.save.confirm=Are you sure to update {0} Role(s)
,"knockout.simpleGrid","knockout.sortable"],
function(jquery,i18n,jqueryTmpl,bootstrap,jqueryValidate,jqueryUi,ko) {
- RepositoryGroup=function(id,repositories,mergedIndexPath){
+ RepositoryGroup=function(id,repositories,mergedIndexPath,mergedIndexTtl){
var self=this;
this.mergedIndexPath=ko.observable(mergedIndexPath?mergedIndexPath:".indexer");
this.mergedIndexPath.subscribe(function(newValue){self.modified(true)});
+ // private int mergedIndexTtl = 30;
+ this.mergedIndexTtl=ko.observable(mergedIndexTtl?mergedIndexTtl:30);
+ this.mergedIndexTtl.subscribe(function(newValue){self.modified(true)});
+
// private List<String> repositories;
this.repositories=ko.observableArray(repositories);
this.repositories.subscribe(function(newValue){self.modified(true)});
}
mapRepositoryGroup=function(data){
- return new RepositoryGroup(data.id, mapStringArray(data.repositories),data.mergedIndexPath);
+ return new RepositoryGroup(data.id, mapStringArray(data.repositories),data.mergedIndexPath,data.mergedIndexTtl);
}
});
data-bind="value: repositoryGroup.mergedIndexPath"/>
</div>
</div>
+ <div class="control-group">
+ <label class="control-label" for="mergedIndexPath">${$.i18n.prop('repository.group.mergedIndexTtl')}</label>
+ <div class="controls">
+ <input type="text" class="input-large required" id="mergedIndexTtl" name="mergedIndexTtl"
+ data-bind="value: repositoryGroup.mergedIndexTtl"/>
+ </div>
+ </div>
<div>
<a href="${window.archivaRuntimeInfo.baseUrl}/repository/${repositoryGroup.id()}" target="_blank">
{{if repositoryGroup.id()}}
if ( tmp != null && tmp.getDirectory() != null && tmp.getDirectory().exists() )
{
- if ( System.currentTimeMillis() - tmp.getCreationTime() > ( indexMerger.getGroupMergedIndexTtl() * 60
- * 1000 ) )
+ if ( System.currentTimeMillis() - tmp.getCreationTime() > ( repositoryGroupConfiguration.getMergedIndexTtl() * 60 * 1000 ) )
{
log.debug( MarkerFactory.getMarker( "group.merged.index" ),
"tmp group index '{}' is too old so delete it", repositoryGroupConfiguration.getId() );