View Javadoc

1   package org.apache.continuum.purge.repository.scanner;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import org.apache.continuum.model.repository.LocalRepository;
23  import org.apache.continuum.purge.controller.PurgeController;
24  import org.apache.maven.archiva.common.utils.BaseFile;
25  import org.codehaus.plexus.util.DirectoryWalkListener;
26  import org.slf4j.Logger;
27  import org.slf4j.LoggerFactory;
28  
29  import java.io.File;
30  
31  /**
32   * Codes were taken from Archiva and made some few changes
33   */
34  public class RepositoryScannerInstance
35      implements DirectoryWalkListener
36  {
37      private static final Logger log = LoggerFactory.getLogger( RepositoryScannerInstance.class );
38  
39      private final LocalRepository repository;
40  
41      private final PurgeController purgeController;
42  
43      public RepositoryScannerInstance( LocalRepository repository, PurgeController purgeController )
44      {
45          this.repository = repository;
46          this.purgeController = purgeController;
47      }
48  
49      public void debug( String message )
50      {
51          log.debug( "Repository Scanner: " + message );
52      }
53  
54      public void directoryWalkFinished()
55      {
56          log.info( "Walk Finished: [" + this.repository.getId() + "] " + this.repository.getLocation() );
57      }
58  
59      public void directoryWalkStarting( File file )
60      {
61          log.info( "Walk started [" + this.repository.getId() + "] " + this.repository.getLocation() );
62      }
63  
64      public void directoryWalkStep( int percentage, File file )
65      {
66          BaseFile basefile = new BaseFile( repository.getLocation(), file );
67          purgeController.doPurge( basefile.getRelativePath() );
68      }
69  
70  }