1 package org.apache.maven.archiva.indexer;
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.indexer.query.Query;
23 import org.apache.maven.archiva.indexer.record.RepositoryIndexRecordFactory;
24 import org.apache.maven.artifact.Artifact;
26 import java.util.Collection;
27 import java.util.List;
30 * Maintain an artifact index on the repository.
32 * @author <a href="mailto:brett@apache.org">Brett Porter</a>
34 public interface RepositoryArtifactIndex
37 * Indexes the artifacts found within the specified list of index records. If the artifacts are already in the
38 * repository they are updated.
40 * @param records the records to index
41 * @throws RepositoryIndexException if there is a problem indexing the records
43 void indexRecords( Collection records )
44 throws RepositoryIndexException;
47 * Search the index based on the search criteria specified. Returns a list of index records.
49 * @param query The query that contains the search criteria
50 * @return the index records found
51 * @throws RepositoryIndexSearchException if there is a problem searching
52 * @todo should it return "SearchResult" instances that contain the index record and other search data (like score?)
54 List search( Query query )
55 throws RepositoryIndexSearchException;
58 * Check if the index already exists.
60 * @return true if the index already exists
61 * @throws RepositoryIndexException if the index location is not valid
64 throws RepositoryIndexException;
67 * Delete records from the index. Simply ignore the request any did not exist.
69 * @param records the records to delete
70 * @throws RepositoryIndexException if there is a problem removing the record
72 void deleteRecords( Collection records )
73 throws RepositoryIndexException;
76 * Retrieve all records in the index.
79 * @throws RepositoryIndexSearchException if there was an error searching the index
81 Collection getAllRecords()
82 throws RepositoryIndexSearchException;
85 * Retrieve all primary keys of records in the index.
88 * @throws RepositoryIndexException if there was an error searching the index
90 Collection getAllRecordKeys()
91 throws RepositoryIndexException;
94 * Indexes the artifact specified. If the artifact is already in the repository they it is updated.
95 * This method should use less memory than indexRecords as the records can be created and disposed of on the fly.
97 * @param artifact the artifact to index
98 * @param factory the artifact to record factory
99 * @throws RepositoryIndexException if there is a problem indexing the artifacts
101 void indexArtifact( Artifact artifact, RepositoryIndexRecordFactory factory )
102 throws RepositoryIndexException;
105 * Indexes the artifacts found within the specified list. If the artifacts are already in the
106 * repository they are updated. This method should use less memory than indexRecords as the records can be
107 * created and disposed of on the fly.
109 * @param artifacts the artifacts to index
110 * @param factory the artifact to record factory
111 * @throws RepositoryIndexException if there is a problem indexing the artifacts
113 void indexArtifacts( List artifacts, RepositoryIndexRecordFactory factory )
114 throws RepositoryIndexException;
117 * Get all the group IDs in the index.
119 * @return list of groups as strings
120 * @throws RepositoryIndexException if there is a problem searching for the group ID
122 List getAllGroupIds()
123 throws RepositoryIndexException;
126 * Get the list of artifact IDs in a group in the index.
128 * @param groupId the group ID to search
129 * @return the list of artifact ID strings
130 * @throws RepositoryIndexSearchException if there is a problem searching for the group ID
132 List getArtifactIds( String groupId )
133 throws RepositoryIndexSearchException;
136 * Get the list of available versions for a given artifact.
138 * @param groupId the group ID to search for
139 * @param artifactId the artifact ID to search for
140 * @return the list of version strings
141 * @throws RepositoryIndexSearchException if there is a problem searching for the artifact
143 List getVersions( String groupId, String artifactId )
144 throws RepositoryIndexSearchException;
147 * Get the time when the index was last updated. Note that this does not monitor external processes.
149 * @return the last updated time, or 0 if it has not been updated since the class was instantiated.
151 long getLastUpdatedTime();