1 package org.apache.archiva.scheduler.repository;
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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
22 import org.apache.archiva.consumers.AbstractMonitoredConsumer;
23 import org.apache.archiva.consumers.ConsumerException;
24 import org.apache.archiva.consumers.KnownRepositoryContentConsumer;
25 import org.apache.archiva.model.ArtifactReference;
26 import org.apache.archiva.repository.ManagedRepository;
27 import org.apache.archiva.repository.ManagedRepositoryContent;
28 import org.apache.archiva.repository.RepositoryContentFactory;
29 import org.apache.archiva.repository.layout.LayoutException;
30 import org.springframework.stereotype.Service;
32 import javax.inject.Inject;
33 import java.util.Collection;
34 import java.util.Collections;
35 import java.util.Date;
36 import java.util.HashSet;
37 import java.util.List;
40 @Service( "knownRepositoryContentConsumer#test-consumer" )
41 public class TestConsumer
42 extends AbstractMonitoredConsumer
43 implements KnownRepositoryContentConsumer
45 private Set<ArtifactReference> consumed = new HashSet<ArtifactReference>();
48 private RepositoryContentFactory factory;
50 private ManagedRepositoryContent repository;
55 return "test-consumer";
59 public String getDescription()
65 public List<String> getIncludes()
67 return Collections.singletonList( "**/**" );
71 public List<String> getExcludes()
77 public void beginScan( ManagedRepository repository, Date whenGathered )
78 throws ConsumerException
82 this.repository = repository.getContent();
86 public void beginScan( ManagedRepository repository, Date whenGathered, boolean executeOnEntireRepo )
87 throws ConsumerException
89 beginScan( repository, whenGathered );
93 public void processFile( String path )
94 throws ConsumerException
96 if ( !path.endsWith( ".sha1" ) && !path.endsWith( ".md5" ) )
100 consumed.add( repository.toArtifactReference( path ) );
102 catch ( LayoutException e )
104 throw new ConsumerException( e.getMessage(), e );
110 public void processFile( String path, boolean executeOnEntireRepo )
117 public void completeScan()
122 public void completeScan( boolean executeOnEntireRepo )
127 public Collection<ArtifactReference> getConsumed()