Adding packingIndexDir and event
Project: http://git-wip-us.apache.org/repos/asf/archiva/repo Commit: http://git-wip-us.apache.org/repos/asf/archiva/commit/f18aa86c Tree: http://git-wip-us.apache.org/repos/asf/archiva/tree/f18aa86c Diff: http://git-wip-us.apache.org/repos/asf/archiva/diff/f18aa86c Branch: refs/heads/master Commit: f18aa86c68f475c5932d818446f6dec644be635b Parents: 8b79055 Author: Martin Stockhammer <[email protected]> Authored: Thu Mar 29 23:46:16 2018 +0200 Committer: Martin Stockhammer <[email protected]> Committed: Thu Mar 29 23:46:51 2018 +0200 ---------------------------------------------------------------------- .../repository/features/IndexCreationEvent.java | 16 +++- .../features/IndexCreationFeature.java | 85 +++++++++++++++++--- 2 files changed, 90 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/archiva/blob/f18aa86c/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/features/IndexCreationEvent.java ---------------------------------------------------------------------- diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/features/IndexCreationEvent.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/features/IndexCreationEvent.java index 4c9dc8e..49a3d44 100644 --- a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/features/IndexCreationEvent.java +++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/features/IndexCreationEvent.java @@ -27,10 +27,22 @@ import java.net.URI; public class IndexCreationEvent extends RepositoryEvent<URI> { public enum Index implements EventType { - URI_CHANGE + INDEX_URI_CHANGE, PACKED_INDEX_URI_CHANGE } IndexCreationEvent(Repository repo, URI oldValue, URI value) { - super(Index.URI_CHANGE, repo, oldValue, value); + super(Index.INDEX_URI_CHANGE, repo, oldValue, value); + } + + IndexCreationEvent(Index type, Repository repo, URI oldValue, URI value) { + super(type, repo, oldValue, value); + } + + public static final IndexCreationEvent indexUriChange(Repository repo, URI oldValue, URI newValue) { + return new IndexCreationEvent(Index.INDEX_URI_CHANGE, repo, oldValue, newValue); + } + + public static final IndexCreationEvent packedIndexUriChange(Repository repo, URI oldValue, URI newValue) { + return new IndexCreationEvent(Index.PACKED_INDEX_URI_CHANGE, repo, oldValue, newValue); } } http://git-wip-us.apache.org/repos/asf/archiva/blob/f18aa86c/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/features/IndexCreationFeature.java ---------------------------------------------------------------------- diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/features/IndexCreationFeature.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/features/IndexCreationFeature.java index 0aa44a2..6289cc6 100644 --- a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/features/IndexCreationFeature.java +++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/features/IndexCreationFeature.java @@ -38,31 +38,42 @@ import java.util.List; */ public class IndexCreationFeature extends AbstractFeature implements RepositoryFeature<IndexCreationFeature>{ + public static final String DEFAULT_INDEX_PATH = ".indexer"; + public static final String DEFAULT_PACKED_INDEX_PATH = ".index"; private boolean skipPackedIndexCreation = false; private URI indexPath; + private URI packedIndexPath; + private Path localIndexPath; + private Path localPackedIndexPath; + private Repository repo; public IndexCreationFeature(Repository repoId, RepositoryEventListener listener) { super(listener); this.repo = repoId; - try - { - setIndexPath(new URI(".indexer")); - } - catch ( URISyntaxException e ) - { - // This may not happen. - e.printStackTrace( ); + try { + this.indexPath = new URI(DEFAULT_INDEX_PATH); + this.packedIndexPath = new URI(DEFAULT_PACKED_INDEX_PATH); + } catch (URISyntaxException e) { + // Does not happen + e.printStackTrace(); } } public IndexCreationFeature(boolean skipPackedIndexCreation) { this.skipPackedIndexCreation = skipPackedIndexCreation; + try { + this.indexPath = new URI(DEFAULT_INDEX_PATH); + this.packedIndexPath = new URI(DEFAULT_PACKED_INDEX_PATH); + } catch (URISyntaxException e) { + // Does not happen + e.printStackTrace(); + } } @Override @@ -104,7 +115,7 @@ public class IndexCreationFeature extends AbstractFeature implements RepositoryF { URI oldVal = this.indexPath; this.indexPath = indexPath; - raiseEvent(new IndexCreationEvent(repo, oldVal, this.indexPath)); + raiseEvent(IndexCreationEvent.indexUriChange(repo, oldVal, this.indexPath)); } @@ -113,11 +124,67 @@ public class IndexCreationFeature extends AbstractFeature implements RepositoryF return this.indexPath!=null && !StringUtils.isEmpty( this.indexPath.getPath() ); } + /** + * Returns the path where the index is stored physically. + * + * @return + */ public Path getLocalIndexPath() { return localIndexPath; } + /** + * Sets the path where the index is stored physically. This method should only be used by the + * MavenIndexProvider implementations. + * + * @param localIndexPath + */ public void setLocalIndexPath(Path localIndexPath) { this.localIndexPath = localIndexPath; } + + + /** + * Returns the path of the packed index. + * @return + */ + public URI getPackedIndexPath() { + return packedIndexPath; + } + + /** + * Sets the path (relative or absolute) of the packed index. + * @param packedIndexPath + */ + public void setPackedIndexPath(URI packedIndexPath) { + URI oldVal = this.packedIndexPath; + this.packedIndexPath = packedIndexPath; + raiseEvent(IndexCreationEvent.packedIndexUriChange(repo, oldVal, this.packedIndexPath)); + } + + /** + * Returns the directory where the packed index is stored. + * @return + */ + public Path getLocalPackedIndexPath() { + return localPackedIndexPath; + } + + /** + * Sets the path where the packed index is stored physically. This method should only be used by the + * MavenIndexProvider implementations. + * + * @param localPackedIndexPath + */ + public void setLocalPackedIndexPath(Path localPackedIndexPath) { + this.localPackedIndexPath = localPackedIndexPath; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("IndexCreationFeature:{").append("skipPackedIndexCreation=").append(skipPackedIndexCreation) + .append(",indexPath=").append(indexPath).append(",packedIndexPath=").append(packedIndexPath).append("}"); + return sb.toString(); + } }
