1package org.apache.archiva.indexer.merger;
2/*3 * Licensed to the Apache Software Foundation (ASF) under one4 * or more contributor license agreements. See the NOTICE file5 * distributed with this work for additional information6 * regarding copyright ownership. The ASF licenses this file7 * to you under the Apache License, Version 2.0 (the8 * "License"); you may not use this file except in compliance9 * with the License. You may obtain a copy of the License at10 *11 * http://www.apache.org/licenses/LICENSE-2.012 *13 * Unless required by applicable law or agreed to in writing,14 * software distributed under the License is distributed on an15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY16 * KIND, either express or implied. See the License for the17 * specific language governing permissions and limitations18 * under the License.19 */2021import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
22import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException;
23import org.apache.maven.index.NexusIndexer;
24import org.slf4j.Logger;
25import org.slf4j.LoggerFactory;
26import org.springframework.scheduling.annotation.Scheduled;
27import org.springframework.stereotype.Service;
2829import javax.inject.Inject;
30import java.util.Date;
3132/**33 * @author Olivier Lamy34 * @since 1.4-M235 */36 @Service
37publicclassTemporaryGroupIndexCleaner38 {
39private Logger log = LoggerFactory.getLogger( getClass() );
4041 @Inject
42privateIndexMerger indexMerger;
4344private NexusIndexer indexer;
4546 @Inject
47publicTemporaryGroupIndexCleaner( PlexusSisuBridge plexusSisuBridge )
48throws PlexusSisuBridgeException
49 {
50 indexer = plexusSisuBridge.lookup( NexusIndexer.class );
51 }
5253// 90000054 @Scheduled(fixedDelay = 900000)
55publicvoid cleanTemporaryIndex()
56 {
5758for ( TemporaryGroupIndex temporaryGroupIndex : indexMerger.getTemporaryGroupIndexes() )
59 {
60// cleanup files older than the ttl61if ( new Date().getTime() - temporaryGroupIndex.getCreationTime() > temporaryGroupIndex.getMergedIndexTtl() )
62 {
63 log.info( "cleanTemporaryIndex for groupId {}", temporaryGroupIndex.getGroupId() );
64 indexMerger.cleanTemporaryGroupIndex( temporaryGroupIndex );
6566 }
67 }
68 }
69 }