This project has retired. For details please refer to its Attic page.
ArchivaIndexingContext xref
View Javadoc
1   package org.apache.archiva.indexer;
2   
3   /*
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
11   *
12   *  http://www.apache.org/licenses/LICENSE-2.0
13   *
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
19   * under the License.
20   */
21  
22  import org.apache.archiva.repository.Repository;
23  import org.apache.archiva.repository.storage.StorageAsset;
24  
25  import java.io.IOException;
26  import java.net.URI;
27  import java.time.ZonedDateTime;
28  import java.util.Set;
29  
30  /**
31   * This represents a indexing context that is used to manage the index of a certain repository.
32   *
33   */
34  public interface ArchivaIndexingContext {
35  
36      /**
37       * The identifier of the context
38       * @return
39       */
40      String getId();
41  
42      /**
43       * Returns the repository this index context is associated to.
44       * @return
45       */
46      Repository getRepository();
47  
48      /**
49       * The path where the index is stored.
50       * @return
51       */
52      StorageAsset getPath();
53  
54      /**
55       * Returns true, if the index has no entries or is not initialized.
56       * @return
57       */
58      boolean isEmpty() throws IOException;
59  
60      /**
61       * Writes the last changes to the index.
62       * @throws IOException
63       */
64      void commit() throws IOException;
65  
66      /**
67       * Throws away the last changes.
68       * @throws IOException
69       */
70      void rollback() throws IOException;
71  
72      /**
73       * Optimizes the index
74       * @throws IOException
75       */
76      void optimize() throws IOException;
77  
78      /**
79       * Closes any resources, this context has open.
80       * @param deleteFiles True, if the index files should be deleted.
81       * @throws IOException
82       */
83      void close(boolean deleteFiles) throws IOException;
84  
85      /**
86       * Closes the context without deleting the files.
87       * Is identical to <code>close(false)</code>
88       * @throws IOException
89       */
90      void close() throws IOException;
91  
92      /**
93       * Returns the status of this context. This method will return <code>false</code>, after the {@link #close()} method
94       * has been called.
95       *
96       * @return <code>true</code>, if the <code>close()</code> method has not been called, otherwise <code>false</code>
97       */
98      boolean isOpen();
99  
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 }