View Javadoc
1   package org.apache.archiva.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.archiva.admin.model.beans.ManagedRepository;
23  import org.apache.archiva.consumers.AbstractMonitoredConsumer;
24  import org.apache.archiva.consumers.ConsumerException;
25  import org.apache.archiva.consumers.InvalidRepositoryContentConsumer;
26  import org.slf4j.Logger;
27  import org.slf4j.LoggerFactory;
28  import org.springframework.context.annotation.Scope;
29  import org.springframework.stereotype.Service;
30  
31  import java.util.ArrayList;
32  import java.util.Date;
33  import java.util.List;
34  
35  /**
36   * InvalidScanConsumer 
37   *
38   *
39   */
40  public class InvalidScanConsumer
41      extends AbstractMonitoredConsumer
42      implements InvalidRepositoryContentConsumer
43  {
44      /**
45       * default-value="unset-id"
46       */
47      private String id = "unset-id";
48  
49      private Logger logger = LoggerFactory.getLogger( getClass() );
50      
51      private int processCount = 0;
52  
53      private List<String> paths = new ArrayList<>( );
54  
55      @Override
56      public void beginScan( ManagedRepository repository, Date whenGathered )
57          throws ConsumerException
58      {
59          /* do nothing */
60      }
61  
62      @Override
63      public void beginScan( ManagedRepository repository, Date whenGathered, boolean executeOnEntireRepo )
64          throws ConsumerException
65      {
66          beginScan( repository, whenGathered );
67      }
68  
69      @Override
70      public void completeScan()
71      {
72          /* do nothing */
73      }
74  
75      @Override
76      public void completeScan( boolean executeOnEntireRepo )
77      {
78          completeScan();
79      }
80  
81      @Override
82      public List<String> getExcludes()
83      {
84          return null;
85      }
86  
87      @Override
88      public List<String> getIncludes()
89      {
90          return null;
91      }
92  
93      @Override
94      public void processFile( String path )
95          throws ConsumerException
96      {
97          logger.info( "processFile: {}", path );
98          paths.add( path );
99          processCount++;
100     }
101 
102     @Override
103     public void processFile( String path, boolean executeOnEntireRepo )
104         throws ConsumerException
105     {
106         processFile( path );
107     }
108 
109     @Override
110     public String getDescription()
111     {
112         return "Bad Content Scan Consumer (for testing)";
113     }
114 
115     @Override
116     public String getId()
117     {
118         return id;
119     }
120 
121     public int getProcessCount()
122     {
123         return processCount;
124     }
125 
126     public void setProcessCount( int processCount )
127     {
128         this.processCount = processCount;
129     }
130 
131     public void setId( String id )
132     {
133         this.id = id;
134     }
135 
136     public List<String> getPaths()
137     {
138         return paths;
139     }
140 }