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.maven.archiva.configuration.ManagedRepositoryConfiguration;
23 import org.apache.maven.archiva.consumers.AbstractMonitoredConsumer;
24 import org.apache.maven.archiva.consumers.ConsumerException;
25 import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
26 import org.apache.maven.archiva.model.ArtifactReference;
27 import org.apache.maven.archiva.repository.ManagedRepositoryContent;
28 import org.apache.maven.archiva.repository.RepositoryContentFactory;
29 import org.apache.maven.archiva.repository.RepositoryException;
30 import org.apache.maven.archiva.repository.layout.LayoutException;
31 import org.springframework.stereotype.Service;
33 import javax.inject.Inject;
34 import javax.inject.Named;
35 import java.util.Collection;
36 import java.util.Collections;
37 import java.util.Date;
38 import java.util.HashSet;
39 import java.util.List;
42 @Service( "knownRepositoryContentConsumer#test-consumer" )
43 public class TestConsumer
44 extends AbstractMonitoredConsumer
45 implements KnownRepositoryContentConsumer
47 private Set<ArtifactReference> consumed = new HashSet<ArtifactReference>();
50 private RepositoryContentFactory factory;
52 private ManagedRepositoryContent repository;
56 return "test-consumer";
59 public String getDescription()
64 public boolean isPermanent()
69 public List<String> getIncludes()
71 return Collections.singletonList( "**/**" );
74 public List<String> getExcludes()
79 public void beginScan( ManagedRepositoryConfiguration repository, Date whenGathered )
80 throws ConsumerException
86 this.repository = factory.getManagedRepositoryContent( repository.getId() );
88 catch ( RepositoryException e )
90 throw new ConsumerException( e.getMessage(), e );
94 public void beginScan( ManagedRepositoryConfiguration repository, Date whenGathered, boolean executeOnEntireRepo )
95 throws ConsumerException
97 beginScan( repository, whenGathered );
100 public void processFile( String path )
101 throws ConsumerException
103 if ( !path.endsWith( ".sha1" ) && !path.endsWith( ".md5" ) )
107 consumed.add( repository.toArtifactReference( path ) );
109 catch ( LayoutException e )
111 throw new ConsumerException( e.getMessage(), e );
116 public void processFile( String path, boolean executeOnEntireRepo )
122 public void completeScan()
126 public void completeScan( boolean executeOnEntireRepo )
131 public Collection<ArtifactReference> getConsumed()