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.ManagedRepositoryContent;
27 import org.apache.archiva.repository.LayoutException;
28 import org.apache.archiva.repository.ManagedRepository;
29 import org.apache.archiva.repository.BaseRepositoryContentLayout;
30 import org.apache.archiva.repository.RepositoryContentFactory;
31 import org.springframework.stereotype.Service;
33 import javax.inject.Inject;
34 import java.util.Collection;
35 import java.util.Collections;
36 import java.util.Date;
37 import java.util.HashSet;
38 import java.util.List;
41 @Service( "knownRepositoryContentConsumer#test-consumer" )
42 public class TestConsumer
43 extends AbstractMonitoredConsumer
44 implements KnownRepositoryContentConsumer
46 private Set<ArtifactReference> consumed = new HashSet<ArtifactReference>();
49 private RepositoryContentFactory factory;
51 private ManagedRepositoryContent repository;
56 return "test-consumer";
60 public String getDescription()
66 public List<String> getIncludes()
68 return Collections.singletonList( "**/**" );
72 public List<String> getExcludes()
78 public void beginScan( ManagedRepository repository, Date whenGathered )
79 throws ConsumerException
83 this.repository = repository.getContent();
87 public void beginScan( ManagedRepository repository, Date whenGathered, boolean executeOnEntireRepo )
88 throws ConsumerException
90 beginScan( repository, whenGathered );
94 public void processFile( String path )
95 throws ConsumerException
97 if ( !path.endsWith( ".sha1" ) && !path.endsWith( ".md5" ) )
101 consumed.add( repository.getLayout( BaseRepositoryContentLayout.class ).toArtifactReference( path ) );
103 catch ( LayoutException e )
105 throw new ConsumerException( e.getMessage(), e );
111 public void processFile( String path, boolean executeOnEntireRepo )
118 public void completeScan()
123 public void completeScan( boolean executeOnEntireRepo )
128 public Collection<ArtifactReference> getConsumed()