diff options
Diffstat (limited to 'archiva-modules/archiva-base/archiva-repository-api')
8 files changed, 178 insertions, 2 deletions
diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/ArchivaIndexManager.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/ArchivaIndexManager.java index fb34eb2ff..63a8a9297 100644 --- a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/ArchivaIndexManager.java +++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/ArchivaIndexManager.java @@ -20,6 +20,7 @@ package org.apache.archiva.indexer; */ import org.apache.archiva.repository.Repository; +import org.apache.archiva.repository.RepositoryEventListener; import org.apache.archiva.repository.RepositoryType; import java.net.URI; @@ -75,4 +76,23 @@ public interface ArchivaIndexManager { * @return the index context */ ArchivaIndexingContext createContext(Repository repository) throws IndexCreationFailedException; + + /** + * Reinitializes the index. E.g. remove the files and create a new empty index. + * + * @param context + * @return the new created index + */ + ArchivaIndexingContext reset(ArchivaIndexingContext context) throws IndexUpdateFailedException; + + /** + * Moves the context to a new directory. It's up to the implementation, if a new context is created + * or the context is moved only. + * + * @param context The current context + * @param repo The repository + * @return The new context + * @throws IndexCreationFailedException + */ + ArchivaIndexingContext move(ArchivaIndexingContext context, Repository repo) throws IndexCreationFailedException; } diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/GenericIndexManager.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/GenericIndexManager.java index d0f803416..8d8072e32 100644 --- a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/GenericIndexManager.java +++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/GenericIndexManager.java @@ -20,6 +20,7 @@ package org.apache.archiva.indexer; */ import org.apache.archiva.repository.Repository; +import org.apache.archiva.repository.RepositoryEvent; import org.apache.archiva.repository.RepositoryType; import org.springframework.stereotype.Service; @@ -63,4 +64,15 @@ public class GenericIndexManager implements ArchivaIndexManager { public ArchivaIndexingContext createContext(Repository repository) { return null; } + + @Override + public ArchivaIndexingContext reset(ArchivaIndexingContext context) throws IndexUpdateFailedException { + return null; + } + + @Override + public ArchivaIndexingContext move(ArchivaIndexingContext context, Repository repo) throws IndexCreationFailedException { + return null; + } + } diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/EditableRepository.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/EditableRepository.java index b27549211..7b7dd8f8a 100644 --- a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/EditableRepository.java +++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/EditableRepository.java @@ -19,6 +19,8 @@ package org.apache.archiva.repository; * under the License. */ +import org.apache.archiva.indexer.ArchivaIndexingContext; + import java.net.URI; import java.util.Locale; @@ -120,5 +122,11 @@ public interface EditableRepository extends Repository */ void setLayout(String layout); + /** + * Sets the indexing context reference. + * @param context + */ + void setIndexingContext(ArchivaIndexingContext context); + } diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/Repository.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/Repository.java index fae5745dd..78a330a96 100644 --- a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/Repository.java +++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/Repository.java @@ -22,6 +22,7 @@ package org.apache.archiva.repository; import org.apache.archiva.indexer.ArchivaIndexingContext; import org.apache.archiva.repository.features.RepositoryFeature; +import java.io.IOException; import java.net.URI; import java.nio.file.Path; import java.util.List; @@ -34,7 +35,7 @@ import java.util.Set; * * Created by Martin Stockhammer on 21.09.17. */ -public interface Repository { +public interface Repository extends RepositoryEventHandler { /** * Return the identifier of the repository. Repository identifier should be unique at least @@ -175,4 +176,10 @@ public interface Repository { * @throws UnsupportedOperationException */ ArchivaIndexingContext getIndexingContext(); + + /** + * Closes all resources that are opened by this repository. + */ + void close(); + } diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryEvent.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryEvent.java new file mode 100644 index 000000000..d8bdf95fe --- /dev/null +++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryEvent.java @@ -0,0 +1,69 @@ +package org.apache.archiva.repository; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.time.LocalDateTime; + +/** + * Repository event. Repository events are used for providing information about repository changes. + * + * @param <T> + */ +public class RepositoryEvent<T> { + + final EventType type; + final String repo; + final T value; + final T oldValue; + final LocalDateTime instant; + + public RepositoryEvent(EventType type, String repo, T oldValue, T value) { + this.type = type; + this.repo = repo; + this.value = value; + this.oldValue = oldValue; + this.instant = LocalDateTime.now(); + } + + public interface EventType { + String name(); + } + + + EventType getType() { + return type; + }; + + String getRepositoryId() { + return repo; + }; + + T getValue() { + return value; + } + + T getOldValue() { + return oldValue; + } + + public LocalDateTime getInstant() { + return instant; + } +} diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryEventHandler.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryEventHandler.java new file mode 100644 index 000000000..74326270c --- /dev/null +++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryEventHandler.java @@ -0,0 +1,32 @@ +package org.apache.archiva.repository; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + * Implementations of this interface are able to handle repository event listeners + */ +public interface RepositoryEventHandler { + + void addListener(RepositoryEventListener listener); + + void removeListener(RepositoryEventListener listener); + + void clearListeners(); +} diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryEventListener.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryEventListener.java new file mode 100644 index 000000000..0234f34b4 --- /dev/null +++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryEventListener.java @@ -0,0 +1,28 @@ +package org.apache.archiva.repository; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + * Listener that accepts repository events. + */ +public interface RepositoryEventListener { + + <T> void raise(RepositoryEvent<T> event); +} diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryProvider.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryProvider.java index a501514da..4492b01cb 100644 --- a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryProvider.java +++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryProvider.java @@ -37,7 +37,7 @@ import java.util.Set; * * */ -public interface RepositoryProvider +public interface RepositoryProvider extends RepositoryEventListener { /** |