You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ArchivaIndexingContext.java 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. package org.apache.archiva.indexer;
  2. /*
  3. * Licensed to the Apache Software Foundation (ASF) under one
  4. * or more contributor license agreements. See the NOTICE file
  5. * distributed with this work for additional information
  6. * regarding copyright ownership. The ASF licenses this file
  7. * to you under the Apache License, Version 2.0 (the
  8. * "License"); you may not use this file except in compliance
  9. * with the License. You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing,
  14. * software distributed under the License is distributed on an
  15. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  16. * KIND, either express or implied. See the License for the
  17. * specific language governing permissions and limitations
  18. * under the License.
  19. */
  20. import org.apache.archiva.repository.Repository;
  21. import java.io.IOException;
  22. import java.net.URI;
  23. import java.time.ZonedDateTime;
  24. import java.util.Set;
  25. /**
  26. * This represents a indexing context that is used to manage the index of a certain repository.
  27. *
  28. */
  29. public interface ArchivaIndexingContext {
  30. /**
  31. * The identifier of the context
  32. * @return
  33. */
  34. String getId();
  35. /**
  36. * Returns the repository this index context is associated to.
  37. * @return
  38. */
  39. Repository getRepository();
  40. /**
  41. * The path where the index is stored.
  42. * @return
  43. */
  44. URI getPath();
  45. /**
  46. * Returns true, if the index has no entries or is not initialized.
  47. * @return
  48. */
  49. boolean isEmpty() throws IOException;
  50. /**
  51. * Writes the last changes to the index.
  52. * @throws IOException
  53. */
  54. void commit() throws IOException;
  55. /**
  56. * Throws away the last changes.
  57. * @throws IOException
  58. */
  59. void rollback() throws IOException;
  60. /**
  61. * Optimizes the index
  62. * @throws IOException
  63. */
  64. void optimize() throws IOException;
  65. /**
  66. * Closes any resources, this context has open.
  67. * @param deleteFiles True, if the index files should be deleted.
  68. * @throws IOException
  69. */
  70. void close(boolean deleteFiles) throws IOException;
  71. /**
  72. * Closes the context without deleting the files.
  73. * Is identical to <code>close(false)</code>
  74. * @throws IOException
  75. */
  76. void close() throws IOException;
  77. /**
  78. * Removes all entries from the index. After this method finished,
  79. * isEmpty() should return true.
  80. * @throws IOException
  81. */
  82. void purge() throws IOException;
  83. /**
  84. * Returns true, if this index implementation has support for the given repository specific
  85. * implementation class.
  86. * @param clazz
  87. * @return
  88. */
  89. boolean supports(Class<?> clazz);
  90. /**
  91. * Returns the repository specific implementation of the index. E.g. the maven index class.
  92. * @param clazz the specific class
  93. * @return the instance of the given class representing this index
  94. * @throws UnsupportedOperationException if the implementation is not supported
  95. */
  96. <T> T getBaseContext(Class<T> clazz) throws UnsupportedBaseContextException;
  97. /**
  98. * Returns the list of groups that are assigned to this index
  99. * @return
  100. */
  101. Set<String> getGroups() throws IOException;
  102. /**
  103. * Updates the timestamp of the index.
  104. * @param save
  105. * @throws IOException
  106. */
  107. void updateTimestamp(boolean save) throws IOException;
  108. /**
  109. * Updates the timestamp with the given time.
  110. * @param save
  111. * @param time
  112. * @throws IOException
  113. */
  114. void updateTimestamp(boolean save, ZonedDateTime time) throws IOException;
  115. }