1package org.apache.archiva.indexer.merger.base;
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.indexer.merger.IndexMerger;
22import org.slf4j.Logger;
23import org.slf4j.LoggerFactory;
24import org.springframework.scheduling.annotation.Scheduled;
25import org.springframework.stereotype.Service;
2627import javax.inject.Inject;
28import java.util.Date;
2930/**31 * @author Olivier Lamy32 * @since 1.4-M233 */34 @Service
35publicclassTemporaryGroupIndexCleaner36 {
37private Logger log = LoggerFactory.getLogger( getClass() );
3839 @Inject
40privateIndexMerger indexMerger;
414243publicTemporaryGroupIndexCleaner( )
44 {
4546 }
4748// 90000049 @Scheduled(fixedDelay = 900000)
50publicvoid cleanTemporaryIndex()
51 {
5253 indexMerger.getTemporaryGroupIndexes()
54 .stream()
55 .forEach( temporaryGroupIndex ->
56 {
57// cleanup files older than the ttl58if ( new Date().getTime() - temporaryGroupIndex.getCreationTime() >
59 temporaryGroupIndex.getMergedIndexTtl() )
60 {
61 log.info( "cleanTemporaryIndex for groupId {}", temporaryGroupIndex.getGroupId() );
62 indexMerger.cleanTemporaryGroupIndex( temporaryGroupIndex );
6364 }
65 }
66 );
67 }
68 }