1 package org.apache.archiva.repository;
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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
21 import org.apache.archiva.repository.content.ContentItem;
22 import org.apache.archiva.repository.content.ItemNotFoundException;
23 import org.apache.archiva.repository.content.ItemSelector;
24 import org.apache.archiva.repository.storage.StorageAsset;
26 import java.util.List;
27 import java.util.function.Consumer;
28 import java.util.stream.Stream;
31 * @author Martin Stockhammer <martin_s@apache.org>
33 public interface GenericManagedRepositoryContent
36 * Delete all items that match the given selector. The type and number of deleted items
37 * depend on the specific selector:
39 * <li>namespace: the complete namespace is deleted (recursively if the recurse flag is set)</li>
40 * <li>project: the complete project and all contained versions are deleted</li>
41 * <li>version: the version inside the project is deleted (project is required)</li>
42 * <li>artifactId: all artifacts that match the id (project and version are required)</li>
43 * <li>artifactVersion: all artifacts that match the version (project and version are required)</li>
47 * @param selector the item selector that selects the artifacts to delete
48 * @param consumer a consumer of the items that will be called after deletion
49 * @returns the list of items that are deleted
50 * @throws ContentAccessException if the deletion was not possible or only partly successful, because the access
51 * to the artifacts failed
52 * @throws IllegalArgumentException if the selector does not specify valid artifacts to delete
54 void deleteAllItems( ItemSelector selector, Consumer<ItemDeleteStatus> consumer ) throws ContentAccessException, IllegalArgumentException;
57 * Removes the specified content item and if the item is a container or directory,
58 * all content stored under the given item.
60 * @param item the item.
61 * @throws ItemNotFoundException if the item cannot be found
62 * @throws ContentAccessException if the deletion was not possible or only partly successful, because the access
63 * to the artifacts failed
65 void deleteItem( ContentItem item ) throws ItemNotFoundException, ContentAccessException;
68 * Returns a item for the given selector. The type of the returned item depends on the
71 * @param selector the item selector
72 * @return the content item that matches the given selector
73 * @throws ContentAccessException if an error occured while accessing the backend
74 * @throws IllegalArgumentException if the selector does not select a valid content item
76 ContentItem getItem( ItemSelector selector ) throws ContentAccessException, IllegalArgumentException;
79 * Returns a stream of items that match the given selector. It may return a stream of mixed types,
80 * like namespaces, projects, versions and artifacts. It will not select a specific type.
81 * The selector can specify the '*' pattern for all fields.
82 * The returned elements will be provided by depth first.
84 * @param selector the item selector that specifies the items
85 * @return the stream of content items
86 * @throws ContentAccessException if the access to the underlying storage failed
87 * @throws IllegalArgumentException if a illegal coordinate combination was provided
89 Stream<? extends ContentItem> newItemStream( ItemSelector selector, boolean parallel ) throws ContentAccessException, IllegalArgumentException;
92 * Returns the item that matches the given path. The item at the path must not exist.
94 * @param path the path string that points to the item
95 * @return the content item if the path is a valid item path
96 * @throws LayoutException if the path is not valid for the repository layout
98 ContentItem toItem( String path ) throws LayoutException;
101 * Returns the item that matches the given asset path. The asset must not exist.
103 * @param assetPath the path to the artifact or directory
104 * @return the item, if it is a valid path for the repository layout
105 * @throws LayoutException if the path is not valid for the repository
107 ContentItem toItem( StorageAsset assetPath ) throws LayoutException;
110 * Returns true, if the selector coordinates point to a existing item in the repository.
112 * @param selector the item selector
113 * @return <code>true</code>, if there exists such a item, otherwise <code>false</code>
115 boolean hasContent( ItemSelector selector );
118 * Returns the parent of the item.
119 * @param item the current item
120 * @return the parent item, or <code>null</code> if no such item exists
122 ContentItem getParent(ContentItem item);
125 * Returns the list of children items.
126 * @param item the current item
127 * @return the list of children, or a empty list, if no children exist
129 List<? extends ContentItem> getChildren( ContentItem item);
132 * Tries to apply the given characteristic to the content item. If the layout does not allow this,
133 * it will throw a <code>LayoutException</code>.
135 * @param clazz the characteristic class to apply
136 * @param item the content item
137 * @param <T> The characteristic
138 * @return the applied characteristic
140 <T extends ContentItem> T applyCharacteristic(Class<T> clazz, ContentItem item) throws LayoutException;