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.KnownRepositoryContentConsumer;
26  import org.springframework.context.annotation.Scope;
27  import org.springframework.stereotype.Service;
28  
29  import java.util.ArrayList;
30  import java.util.Arrays;
31  import java.util.Date;
32  import java.util.List;
33  
34  /**
35   * ScanConsumer 
36   *
37   *
38   */
39  public class KnownScanConsumer
40      extends AbstractMonitoredConsumer
41      implements KnownRepositoryContentConsumer
42  {
43      private int processCount = 0;
44  
45      private List<String> includes = new ArrayList<>();
46  
47      private boolean processUnmodified = false;
48  
49      @Override
50      public List<String> getExcludes()
51      {
52          return null;
53      }
54  
55      public void setIncludes( String includesArray[] )
56      {
57          this.includes.clear();
58          this.includes.addAll( Arrays.asList( includesArray ) );
59      }
60  
61      @Override
62      public List<String> getIncludes()
63      {
64          return includes;
65      }
66  
67      @Override
68      public String getId()
69      {
70          return "test-scan-consumer";
71      }
72  
73      @Override
74      public String getDescription()
75      {
76          return "Scan Consumer (for testing)";
77      }
78  
79      @Override
80      public void beginScan( ManagedRepository repository, Date whenGathered )
81          throws ConsumerException
82      {
83          /* do nothing */
84      }
85  
86      @Override
87      public void beginScan( ManagedRepository repository, Date whenGathered, boolean executeOnEntireRepo )
88          throws ConsumerException
89      {
90          beginScan( repository, whenGathered );
91      }
92  
93      @Override
94      public void processFile( String path )
95          throws ConsumerException
96      {
97          this.processCount++;
98      }
99  
100     @Override
101     public void processFile( String path, boolean executeOnEntireRepo )
102         throws Exception
103     {
104         processFile( path );
105     }
106 
107     @Override
108     public void completeScan()
109     {
110         /* do nothing */
111     }
112 
113     @Override
114     public void completeScan( boolean executeOnEntireRepo )
115     {
116        completeScan();
117     }
118 
119     public int getProcessCount()
120     {
121         return processCount;
122     }
123 
124     public void setProcessCount( int processCount )
125     {
126         this.processCount = processCount;
127     }
128 
129     @Override
130     public boolean isProcessUnmodified()
131     {
132         return processUnmodified;
133     }
134 
135     public void setProcessUnmodified( boolean processUnmodified )
136     {
137         this.processUnmodified = processUnmodified;
138     }
139 }