diff options
author | Martin Stockhammer <martin_s@apache.org> | 2019-05-19 17:28:09 +0200 |
---|---|---|
committer | Martin Stockhammer <martin_s@apache.org> | 2019-05-19 17:28:09 +0200 |
commit | 02cf1bd7e78603ec8c159822f20fe1c20417488f (patch) | |
tree | 6885a0d903e990b72031c9e4fd4a8028a887806a | |
parent | f3aa14f3e2445e5404b9d254c9d3c3dd90221f6a (diff) | |
download | archiva-02cf1bd7e78603ec8c159822f20fe1c20417488f.tar.gz archiva-02cf1bd7e78603ec8c159822f20fe1c20417488f.zip |
Adding repository storage API
-rw-r--r-- | archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/content/RepositoryStorage.java | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/content/RepositoryStorage.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/content/RepositoryStorage.java new file mode 100644 index 000000000..82b40b2ce --- /dev/null +++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/content/RepositoryStorage.java @@ -0,0 +1,91 @@ +package org.apache.archiva.repository.content; + +/* + * 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.io.IOException; +import java.io.InputStream; +import java.util.function.Consumer; + +/** + * Repository storage gives access to the files and directories on the storage. + * The storage may be on a filesystem but can be any other storage system. + * + * This API is low level repository access. If you use this API you must + * either have knowledge about the specific repository layout or use the structure + * as it is, e.g. for browsing. + * + * It is the decision of the implementation, if this API provides access to all elements, or + * just a selected view. + * + * Checking access is not part of this API. + */ +public interface RepositoryStorage { + /** + * Returns information about a specific storage asset. + * @param path + * @return + */ + StorageAsset getAsset(String path); + + /** + * Consumes the data and sets a lock for the file during the operation. + * + * @param asset + * @param consumerFunction + * @param readLock + * @throws IOException + */ + void consumeData(StorageAsset asset, Consumer<InputStream> consumerFunction, boolean readLock) throws IOException; + + /** + * Adds a new asset to the underlying storage. + * @param path The path to the asset. + * @param container True, if the asset should be a container, false, if it is a file. + * @return + */ + StorageAsset addAsset(String path, boolean container); + + /** + * Removes the given asset from the storage. + * + * @param asset + * @throws IOException + */ + void removeAsset(StorageAsset asset) throws IOException; + + /** + * Moves the asset to the given location and returns the asset object for the destination. + * + * @param origin + * @param destination + * @return + */ + StorageAsset moveAsset(StorageAsset origin, String destination) throws IOException; + + /** + * Copies the given asset to the new destination. + * + * @param origin + * @param destination + * @return + * @throws IOException + */ + StorageAsset copyAsset(StorageAsset origin, String destination) throws IOException; +} |