1 package org.apache.archiva.repository.mock;
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
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
22 import org.apache.archiva.model.ArchivaArtifact;
23 import org.apache.archiva.model.ArtifactReference;
24 import org.apache.archiva.model.ProjectReference;
25 import org.apache.archiva.model.VersionedReference;
26 import org.apache.archiva.repository.ContentAccessException;
27 import org.apache.archiva.repository.ContentNotFoundException;
28 import org.apache.archiva.repository.ItemDeleteStatus;
29 import org.apache.archiva.repository.LayoutException;
30 import org.apache.archiva.repository.ManagedRepository;
31 import org.apache.archiva.repository.ManagedRepositoryContent;
32 import org.apache.archiva.repository.content.Artifact;
33 import org.apache.archiva.repository.content.ContentItem;
34 import org.apache.archiva.repository.content.ItemNotFoundException;
35 import org.apache.archiva.repository.content.ItemSelector;
36 import org.apache.archiva.repository.content.Namespace;
37 import org.apache.archiva.repository.content.Project;
38 import org.apache.archiva.repository.content.Version;
39 import org.apache.archiva.repository.storage.StorageAsset;
40 import org.springframework.stereotype.Service;
42 import java.nio.file.Path;
43 import java.util.List;
44 import java.util.function.Consumer;
45 import java.util.stream.Stream;
48 * @author Martin Stockhammer <martin_s@apache.org>
50 @Service("managedRepositoryContent#mock")
51 public class ManagedRepositoryContentMock implements ManagedRepositoryContent
53 private ManagedRepository repository;
56 public VersionedReference toVersion( String groupId, String artifactId, String version )
62 public VersionedReference toVersion( ArtifactReference artifactReference )
68 public void deleteAllItems( ItemSelector selector, Consumer<ItemDeleteStatus> consumer ) throws ContentAccessException, IllegalArgumentException
74 public void deleteItem( ContentItem item ) throws ItemNotFoundException, ContentAccessException
80 public ContentItem getItem( ItemSelector selector ) throws ContentAccessException, IllegalArgumentException
86 public Namespace getNamespace( ItemSelector namespaceSelector ) throws ContentAccessException, IllegalArgumentException
92 public Project getProject( ItemSelector projectSelector ) throws ContentAccessException, IllegalArgumentException
99 public void deleteVersion( VersionedReference reference ) throws ContentNotFoundException, ContentAccessException
106 public Version getVersion( ItemSelector versionCoordinates ) throws ContentAccessException, IllegalArgumentException
112 public void deleteArtifact( ArtifactReference artifactReference ) throws ContentNotFoundException, ContentAccessException
119 public Artifact getArtifact( ItemSelector selector ) throws ContentAccessException
125 public List<? extends Artifact> getArtifacts( ItemSelector selector ) throws ContentAccessException
131 public Stream<? extends Artifact> newArtifactStream( ItemSelector selector ) throws ContentAccessException
137 public Stream<? extends ContentItem> newItemStream( ItemSelector selector, boolean parallel ) throws ContentAccessException, IllegalArgumentException
143 public List<? extends Project> getProjects( Namespace namespace ) throws ContentAccessException
149 public List<? extends Project> getProjects( ItemSelector selector ) throws ContentAccessException, IllegalArgumentException
155 public List<? extends Version> getVersions( Project project ) throws ContentAccessException
161 public List<? extends Version> getVersions( ItemSelector selector ) throws ContentAccessException, IllegalArgumentException
167 public List<String> getArtifactVersions( ItemSelector selector ) throws ContentAccessException, IllegalArgumentException
173 public List<? extends Artifact> getArtifacts( ContentItem item ) throws ContentAccessException
179 public Stream<? extends Artifact> newArtifactStream( ContentItem item ) throws ContentAccessException
185 public boolean hasContent( ItemSelector selector )
191 public ContentItem getParent( ContentItem item )
197 public List<? extends ContentItem> getChildren( ContentItem item )
203 public <T extends ContentItem> T applyCharacteristic( Class<T> clazz, ContentItem item ) throws LayoutException
209 public void addArtifact( Path sourceFile, Artifact destination ) throws IllegalArgumentException
215 public ContentItem toItem( String path ) throws LayoutException
221 public ContentItem toItem( StorageAsset assetPath ) throws LayoutException
228 public void deleteGroupId( String groupId ) throws ContentNotFoundException, ContentAccessException
235 public void deleteProject( String namespace, String projectId ) throws ContentNotFoundException, ContentAccessException
241 public void deleteProject( ProjectReference reference ) throws ContentNotFoundException, ContentAccessException
247 public String getId( )
253 public List<ArtifactReference> getRelatedArtifacts( VersionedReference reference ) throws ContentNotFoundException, LayoutException, ContentAccessException
259 public List<ArtifactReference> getArtifacts( VersionedReference reference ) throws ContentNotFoundException, LayoutException, ContentAccessException
265 public String getRepoRoot( )
271 public ManagedRepository getRepository( )
277 public boolean hasContent( ArtifactReference reference ) throws ContentAccessException
283 public boolean hasContent( VersionedReference reference ) throws ContentAccessException
289 public void setRepository( ManagedRepository repo )
291 this.repository = repo;
295 public StorageAsset toFile( VersionedReference reference )
301 public ArtifactReference toArtifactReference( String path ) throws LayoutException
307 public StorageAsset toFile( ArtifactReference reference )
313 public StorageAsset toFile( ArchivaArtifact reference )
319 public String toMetadataPath( ProjectReference reference )
325 public String toMetadataPath( VersionedReference reference )
331 public String toPath( ArtifactReference reference )
337 public String toPath( ItemSelector selector )
343 public ItemSelector toItemSelector( String path ) throws LayoutException
349 public String toPath( ArchivaArtifact reference )