This project has retired. For details please refer to its Attic page.
Source code
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.storage.StorageAsset;
024
025import java.io.IOException;
026import java.net.URI;
027import java.time.ZonedDateTime;
028import java.util.Set;
029
030/**
031 * This represents a indexing context that is used to manage the index of a certain repository.
032 *
033 */
034public interface ArchivaIndexingContext {
035
036    /**
037     * The identifier of the context
038     * @return
039     */
040    String getId();
041
042    /**
043     * Returns the repository this index context is associated to.
044     * @return
045     */
046    Repository getRepository();
047
048    /**
049     * The path where the index is stored.
050     * @return
051     */
052    StorageAsset getPath();
053
054    /**
055     * Returns true, if the index has no entries or is not initialized.
056     * @return
057     */
058    boolean isEmpty() throws IOException;
059
060    /**
061     * Writes the last changes to the index.
062     * @throws IOException
063     */
064    void commit() throws IOException;
065
066    /**
067     * Throws away the last changes.
068     * @throws IOException
069     */
070    void rollback() throws IOException;
071
072    /**
073     * Optimizes the index
074     * @throws IOException
075     */
076    void optimize() throws IOException;
077
078    /**
079     * Closes any resources, this context has open.
080     * @param deleteFiles True, if the index files should be deleted.
081     * @throws IOException
082     */
083    void close(boolean deleteFiles) throws IOException;
084
085    /**
086     * Closes the context without deleting the files.
087     * Is identical to <code>close(false)</code>
088     * @throws IOException
089     */
090    void close() throws IOException;
091
092    /**
093     * Returns the status of this context. This method will return <code>false</code>, after the {@link #close()} method
094     * has been called.
095     *
096     * @return <code>true</code>, if the <code>close()</code> method has not been called, otherwise <code>false</code>
097     */
098    boolean isOpen();
099
100    /**
101     * Removes all entries from the index. After this method finished,
102     * isEmpty() should return true.
103     * @throws IOException
104     */
105    void purge() throws IOException;
106
107    /**
108     * Returns true, if this index implementation has support for the given repository specific
109     * implementation class.
110     * @param clazz
111     * @return
112     */
113    boolean supports(Class<?> clazz);
114
115    /**
116     * Returns the repository specific implementation of the index. E.g. the maven index class.
117     * @param clazz the specific class
118     * @return the instance of the given class representing this index
119     * @throws UnsupportedOperationException if the implementation is not supported
120     */
121    <T> T getBaseContext(Class<T> clazz) throws UnsupportedBaseContextException;
122
123
124
125    /**
126     * Returns the list of groups that are assigned to this index
127     * @return
128     */
129    Set<String> getGroups() throws IOException;
130
131    /**
132     * Updates the timestamp of the index.
133     * @param save
134     * @throws IOException
135     */
136    void updateTimestamp(boolean save) throws IOException;
137
138    /**
139     * Updates the timestamp with the given time.
140     * @param save
141     * @param time
142     * @throws IOException
143     */
144    void updateTimestamp(boolean save, ZonedDateTime time) throws IOException;
145}