1 package org.apache.maven.archiva.consumers;
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.common.consumers.GenericArtifactConsumer;
23 import org.apache.maven.archiva.common.utils.BaseFile;
24 import org.apache.maven.archiva.configuration.ArchivaConfiguration;
25 import org.apache.maven.archiva.configuration.Configuration;
26 import org.apache.maven.archiva.indexer.RepositoryArtifactIndex;
27 import org.apache.maven.archiva.indexer.RepositoryArtifactIndexFactory;
28 import org.apache.maven.archiva.indexer.RepositoryIndexException;
29 import org.apache.maven.archiva.indexer.record.RepositoryIndexRecordFactory;
30 import org.apache.maven.artifact.Artifact;
31 import org.apache.maven.artifact.repository.ArtifactRepository;
36 * IndexArtifactConsumer
38 * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
41 * @plexus.component role="org.apache.maven.archiva.common.consumers.Consumer"
42 * role-hint="index-artifact"
43 * instantiation-strategy="per-lookup"
45 public class IndexArtifactConsumer
46 extends GenericArtifactConsumer
51 private RepositoryArtifactIndexFactory indexFactory;
54 * @plexus.requirement role-hint="standard"
56 private RepositoryIndexRecordFactory recordFactory;
59 * Configuration store.
63 private ArchivaConfiguration archivaConfiguration;
65 private RepositoryArtifactIndex index;
67 public boolean init( ArtifactRepository repository )
69 Configuration configuration = archivaConfiguration.getConfiguration();
71 File indexPath = new File( configuration.getIndexPath() );
73 index = indexFactory.createStandardIndex( indexPath );
75 return super.init( repository );
78 public void processArtifact( Artifact artifact, BaseFile file )
82 index.indexArtifact( artifact, recordFactory );
84 catch ( RepositoryIndexException e )
86 getLogger().warn( "Unable to index artifact " + artifact, e );
90 public void processFileProblem( BaseFile path, String message )
95 public String getName()
97 return "Index Artifact Consumer";