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.ContentNotFoundException;
27 import org.apache.archiva.repository.ManagedRepository;
28 import org.apache.archiva.repository.ManagedRepositoryContent;
29 import org.apache.archiva.repository.RepositoryException;
30 import org.apache.archiva.repository.layout.LayoutException;
31 import org.springframework.stereotype.Service;
34 import java.nio.file.Path;
35 import java.nio.file.Paths;
39 * @author Martin Stockhammer <martin_s@apache.org>
41 @Service("managedRepositoryContent#mock")
42 public class ManagedRepositoryContentMock implements ManagedRepositoryContent
44 private ManagedRepository repository;
47 public void deleteVersion( VersionedReference reference ) throws ContentNotFoundException
53 public void deleteArtifact( ArtifactReference artifactReference ) throws ContentNotFoundException
59 public void deleteGroupId( String groupId ) throws ContentNotFoundException
65 public void deleteProject( String namespace, String projectId ) throws RepositoryException
71 public String getId( )
77 public Set<ArtifactReference> getRelatedArtifacts( ArtifactReference reference ) throws ContentNotFoundException
83 public String getRepoRoot()
85 return convertUriToPath( repository.getLocation() );
88 private String convertUriToPath( URI uri ) {
89 if (uri.getScheme()==null) {
90 return Paths.get(uri.getPath()).toString();
91 } else if ("file".equals(uri.getScheme())) {
92 return Paths.get(uri).toString();
94 return uri.toString();
99 public ManagedRepository getRepository( )
105 public Set<String> getVersions( ProjectReference reference ) throws ContentNotFoundException, LayoutException
111 public Set<String> getVersions( VersionedReference reference ) throws ContentNotFoundException
117 public boolean hasContent( ArtifactReference reference )
123 public boolean hasContent( ProjectReference reference )
129 public boolean hasContent( VersionedReference reference )
135 public void setRepository( ManagedRepository repo )
137 this.repository = repo;
141 public ArtifactReference toArtifactReference( String path ) throws LayoutException
147 public Path toFile( ArtifactReference reference )
153 public Path toFile( ArchivaArtifact reference )
159 public String toMetadataPath( ProjectReference reference )
165 public String toMetadataPath( VersionedReference reference )
171 public String toPath( ArtifactReference reference )
177 public String toPath( ArchivaArtifact reference )