}
@Override
- public ProxyFetchResult fetchMetadataFromProxies( ManagedRepository repository, String logicalPath )
+ public ProxyFetchResult fetchMetadataFromProxies( ManagedRepository repository, String rawLogicalPath )
{
+ String logicalPath;
+ if (rawLogicalPath.startsWith( "/" )){
+ logicalPath = rawLogicalPath.substring( 1 );
+ } else {
+ logicalPath = rawLogicalPath;
+ }
StorageAsset localFile = repository.getAsset( logicalPath );
Properties requestProperties = new Properties();
{
url = url + "/";
}
- url = url + remotePath;
+ if (remotePath.startsWith( "/" )) {
+ url = url + remotePath.substring( 1 );
+ } else {
+ url = url + remotePath;
+ }
requestProperties.setProperty( "url", url );
// Is a whitelist defined?
import org.apache.archiva.model.VersionedReference;
import org.apache.archiva.repository.*;
import org.apache.archiva.repository.content.Artifact;
+import org.apache.archiva.repository.content.BaseDataItemTypes;
import org.apache.archiva.repository.content.ContentItem;
import org.apache.archiva.repository.content.DataItem;
import org.apache.archiva.repository.content.ItemNotFoundException;
import org.apache.archiva.repository.content.Namespace;
import org.apache.archiva.repository.content.Project;
import org.apache.archiva.repository.content.Version;
+import org.apache.archiva.repository.content.base.ArchivaDataItem;
import org.apache.archiva.repository.content.base.ArchivaNamespace;
import org.apache.archiva.repository.content.base.ArchivaProject;
import org.apache.archiva.repository.content.base.ArchivaVersion;
return null;
}
+ @Override
+ public DataItem getMetadataItem( Project project )
+ {
+ return ArchivaDataItem.withAsset( project.getAsset( ).resolve( "maven-metadata.xml" ) ).withId( "maven-metadata.xml" )
+ .withDataType( BaseDataItemTypes.METADATA ).build( );
+ }
+
+
@Override
public ContentItem toItem( String path ) throws LayoutException
{
import org.apache.archiva.repository.BaseRepositoryContentLayout;
import org.apache.archiva.repository.content.ContentItem;
import org.apache.archiva.repository.content.DataItem;
+import org.apache.archiva.repository.content.Project;
import org.apache.archiva.repository.content.Version;
+import org.apache.archiva.repository.content.base.ArchivaItemSelector;
import org.apache.archiva.repository.metadata.base.MetadataTools;
import org.apache.archiva.repository.metadata.RepositoryMetadataException;
import org.apache.archiva.repository.metadata.base.RepositoryMetadataWriter;
assertNoRepoMetadata( ID_PROXIED1, requestedResource );
Path expectedFile = managedDefaultDir.resolve(requestedResource);
-
- ProjectReference metadata = createProjectReference( requestedResource );
-
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
+ ContentItem metaItem = managedDefaultRepository.toItem( requestedResource );
+ Project project = layout.adaptItem( Project.class, managedDefaultRepository.getParent( metaItem ) );
+ assertNotNull( project );
+ String metaPath = managedDefaultRepository.toPath( layout.getMetadataItem( project ) );
StorageAsset downloadedFile = proxyHandler.fetchMetadataFromProxies( managedDefaultRepository.getRepository(),
- layout.toMetadataPath(
- metadata ) ).getFile();
+ metaPath ).getFile();
assertNull( "Should not have downloaded a file.", downloadedFile );
assertNoTempFiles( expectedFile );
{
Path expectedFile = managedDefaultDir.resolve(requestedResource);
- ProjectReference metadata = createProjectReference( requestedResource );
-
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
+ ContentItem metaItem = managedDefaultRepository.toItem( requestedResource );
+ Project project = layout.adaptItem( Project.class, managedDefaultRepository.getParent( metaItem ) );
+ assertNotNull( project );
+ String metaPath = managedDefaultRepository.toPath( layout.getMetadataItem( project ) );
StorageAsset downloadedFile = proxyHandler.fetchMetadataFromProxies( managedDefaultRepository.getRepository(),
- layout.toMetadataPath(
- metadata ) ).getFile();
+ metaPath ).getFile();
assertNotNull( "Should have downloaded a file.", downloadedFile );
assertNoTempFiles( expectedFile );
throws Exception
{
Path expectedFile = managedDefaultDir.resolve(requestedResource);
- ProjectReference metadata = createProjectReference( requestedResource );
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
+ ContentItem metaItem = managedDefaultRepository.toItem( requestedResource );
+ Project project = layout.adaptItem( Project.class, managedDefaultRepository.getParent( metaItem ) );
+ assertNotNull( project );
+ String metaPath = managedDefaultRepository.toPath( layout.getMetadataItem( project ) );
StorageAsset downloadedFile = proxyHandler.fetchMetadataFromProxies( managedDefaultRepository.getRepository(),
- layout.toMetadataPath(
- metadata ) ).getFile();
+ metaPath ).getFile();
assertNull( downloadedFile );
assertNoTempFiles( expectedFile );