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.slf4j.Logger;
22import org.slf4j.LoggerFactory;
23import org.springframework.scheduling.annotation.Scheduled;
24import org.springframework.stereotype.Service;
2526import javax.inject.Inject;
27import java.util.Date;
2829/**30 * @author Olivier Lamy31 * @since 1.4-M232 */33 @Service
34publicclassTemporaryGroupIndexCleaner35 {
36private Logger log = LoggerFactory.getLogger( getClass() );
3738 @Inject
39privateIndexMerger indexMerger;
404142publicTemporaryGroupIndexCleaner( )
43 {
4445 }
4647// 90000048 @Scheduled(fixedDelay = 900000)
49publicvoid cleanTemporaryIndex()
50 {
5152 indexMerger.getTemporaryGroupIndexes()
53 .stream()
54 .forEach( temporaryGroupIndex ->
55 {
56// cleanup files older than the ttl57if ( new Date().getTime() - temporaryGroupIndex.getCreationTime() >
58 temporaryGroupIndex.getMergedIndexTtl() )
59 {
60 log.info( "cleanTemporaryIndex for groupId {}", temporaryGroupIndex.getGroupId() );
61 indexMerger.cleanTemporaryGroupIndex( temporaryGroupIndex );
6263 }
64 }
65 );
66 }
67 }