001package org.apache.archiva.indexer; 002 003/* 004 * Licensed to the Apache Software Foundation (ASF) under one 005 * or more contributor license agreements. See the NOTICE file 006 * distributed with this work for additional information 007 * regarding copyright ownership. The ASF licenses this file 008 * to you under the Apache License, Version 2.0 (the 009 * "License"); you may not use this file except in compliance 010 * with the License. You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, 015 * software distributed under the License is distributed on an 016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 017 * KIND, either express or implied. See the License for the 018 * specific language governing permissions and limitations 019 * under the License. 020 */ 021 022import org.apache.archiva.repository.Repository; 023import org.apache.archiva.repository.RepositoryType; 024 025import java.net.URI; 026import java.util.Collection; 027import java.util.List; 028 029public interface ArchivaIndexManager { 030 031 String DEFAULT_INDEX_PATH=".indexer"; 032 String DEFAULT_PACKED_INDEX_PATH=".index"; 033 034 /** 035 * Compresses the index to a more dense packed format. 036 * @param context 037 */ 038 void pack(ArchivaIndexingContext context) throws IndexUpdateFailedException; 039 040 /** 041 * Rescans the whole repository, this index is associated to. 042 * @param context 043 * 044 */ 045 void scan(ArchivaIndexingContext context) throws IndexUpdateFailedException; 046 047 /** 048 * Updates the index from the remote url. 049 * @param context 050 * @param fullUpdate 051 */ 052 void update(ArchivaIndexingContext context, boolean fullUpdate) throws IndexUpdateFailedException; 053 054 /** 055 * Adds a list of artifacts to the index. 056 * @param context 057 * @param artifactReference 058 */ 059 void addArtifactsToIndex(ArchivaIndexingContext context, Collection<URI> artifactReference) throws IndexUpdateFailedException; 060 061 /** 062 * Removes a list of artifacts from the index. 063 * @param context 064 * @param artifactReference 065 */ 066 void removeArtifactsFromIndex(ArchivaIndexingContext context, Collection<URI> artifactReference) throws IndexUpdateFailedException; 067 068 069 /** 070 * Returns true, if this manager is able to apply the index actions for the given repository type. 071 * @param type 072 * @return 073 */ 074 boolean supportsRepository(RepositoryType type); 075 076 /** 077 * Creates the indexing context for the given repository. 078 * @param repository the repository for which the index context should be created 079 * @return the index context 080 */ 081 ArchivaIndexingContext createContext(Repository repository) throws IndexCreationFailedException; 082 083 /** 084 * Reinitializes the index. E.g. remove the files and create a new empty index. 085 * 086 * @param context 087 * @return the new created index 088 */ 089 ArchivaIndexingContext reset(ArchivaIndexingContext context) throws IndexUpdateFailedException; 090 091 /** 092 * Moves the context to a new directory. It's up to the implementation, if a new context is created 093 * or the context is moved only. 094 * 095 * @param context The current context 096 * @param repo The repository 097 * @return The new context 098 * @throws IndexCreationFailedException 099 */ 100 ArchivaIndexingContext move(ArchivaIndexingContext context, Repository repo) throws IndexCreationFailedException; 101 102 /** 103 * Updates the local path where the index is stored using the repository information. 104 * @return 105 */ 106 void updateLocalIndexPath(Repository repo); 107 108 109 /** 110 * Merges a list of contexts into a single one. 111 * 112 * @param destinationRepo The destination repository 113 * @param contexts The contexts of the indexes that should be merged. 114 * @param packIndex True, if the merged index should be packed, otherwise false. 115 * @return The merged context 116 * @throws UnsupportedOperationException if the underlying implementation does not allow to merge indexing contexts 117 */ 118 ArchivaIndexingContext mergeContexts(Repository destinationRepo, List<ArchivaIndexingContext> contexts, 119 boolean packIndex) throws UnsupportedOperationException, 120 IndexCreationFailedException; 121}