1package org.apache.archiva.repository.content.maven2;
23/*4 * Licensed to the Apache Software Foundation (ASF) under one5 * or more contributor license agreements. See the NOTICE file6 * distributed with this work for additional information7 * regarding copyright ownership. The ASF licenses this file8 * to you under the Apache License, Version 2.0 (the9 * "License"); you may not use this file except in compliance10 * with the License. You may obtain a copy of the License at11 *12 * http://www.apache.org/licenses/LICENSE-2.013 *14 * Unless required by applicable law or agreed to in writing,15 * software distributed under the License is distributed on an16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY17 * KIND, either express or implied. See the License for the18 * specific language governing permissions and limitations19 * under the License.20 */2122import org.apache.archiva.admin.model.beans.RemoteRepository;
23import org.apache.archiva.model.ArtifactReference;
24import org.apache.archiva.model.RepositoryURL;
25import org.apache.archiva.repository.RemoteRepositoryContent;
26import org.apache.archiva.repository.layout.LayoutException;
27import org.springframework.context.annotation.Scope;
28import org.springframework.stereotype.Service;
2930/**31 * RemoteDefaultRepositoryContent32 *33 *34 */35 @Service( "remoteRepositoryContent#default" )
36 @Scope( "prototype" )
37publicclassRemoteDefaultRepositoryContent38extendsAbstractDefaultRepositoryContent39implements RemoteRepositoryContent
40 {
41private RemoteRepository repository;
4243 @Override
44public String getId()
45 {
46return repository.getId();
47 }
4849 @Override
50public RemoteRepository getRepository()
51 {
52return repository;
53 }
5455 @Override
56public RepositoryURL getURL()
57 {
58returnnew RepositoryURL( repository.getUrl() );
59 }
6061 @Override
62publicvoid setRepository( RemoteRepository repository )
63 {
64this.repository = repository;
65 }
6667/**68 * Convert a path to an artifact reference.69 *70 * @param path the path to convert. (relative or full url path)71 * @throws org.apache.archiva.repository.layout.LayoutException if the path cannot be converted to an artifact reference.72 */73 @Override
74public ArtifactReference toArtifactReference( String path )
75throws LayoutException
76 {
77if ( ( path != null ) && path.startsWith( repository.getUrl() ) )
78 {
79returnsuper.toArtifactReference( path.substring( repository.getUrl().length() ) );
80 }
8182returnsuper.toArtifactReference( path );
83 }
8485 @Override
86public RepositoryURL toURL( ArtifactReference reference )
87 {
88 String url = repository.getUrl() + toPath( reference );
89returnnew RepositoryURL( url );
90 }
91 }