import org.apache.archiva.model.ArtifactReference;
import org.apache.archiva.components.registry.Registry;
import org.apache.archiva.components.registry.RegistryListener;
+import org.apache.archiva.repository.ManagedRepositoryContent;
import org.apache.archiva.repository.LayoutException;
import org.apache.archiva.repository.ManagedRepository;
-import org.apache.archiva.repository.ManagedRepositoryContent;
+import org.apache.archiva.repository.BaseRepositoryContentLayout;
import org.apache.archiva.repository.RepositoryContentFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
try
{
ManagedRepositoryContent repositoryContent = repository.getContent();
- ArtifactReference artifact = repositoryContent.toArtifactReference( path );
+ BaseRepositoryContentLayout layout = repositoryContent.getLayout( BaseRepositoryContentLayout.class );
+ ArtifactReference artifact = layout.toArtifactReference( path );
repositorySession.getRepository().getArtifacts( repositorySession, repository.getId(), artifact.getGroupId(),
artifact.getArtifactId(), artifact.getVersion() );
import org.apache.archiva.model.ArtifactReference;
import org.apache.archiva.model.ProjectReference;
import org.apache.archiva.model.VersionedReference;
+import org.apache.archiva.repository.ManagedRepositoryContent;
import org.apache.archiva.repository.LayoutException;
import org.apache.archiva.repository.ManagedRepository;
-import org.apache.archiva.repository.ManagedRepositoryContent;
+import org.apache.archiva.repository.BaseRepositoryContentLayout;
import org.apache.archiva.repository.RepositoryException;
import org.apache.archiva.repository.RepositoryNotFoundException;
import org.apache.archiva.repository.RepositoryRegistry;
import org.apache.archiva.repository.metadata.base.MetadataTools;
import org.apache.archiva.repository.metadata.RepositoryMetadataException;
+import org.apache.archiva.repository.storage.StorageAsset;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Scope;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
private ManagedRepositoryContent repository;
- private Path repositoryDir;
+ private StorageAsset repositoryDir;
private List<String> includes = new ArrayList<>( 0 );
if (this.repository==null) {
throw new RepositoryNotFoundException( "Repository content not found: "+repoConfig.getId() );
}
- this.repositoryDir = Paths.get( repository.getRepoRoot( ) );
+ this.repositoryDir = repository.getRepository().getAsset( "" );
this.scanStartTimestamp = System.currentTimeMillis( );
}
catch ( RepositoryException e )
{
try
{
- ArtifactReference artifact = repository.toArtifactReference( path );
+ ArtifactReference artifact = repository.getLayout( BaseRepositoryContentLayout.class ).toArtifactReference( path );
updateVersionMetadata( artifact, path );
updateProjectMetadata( artifact, path );
}
{
String metadataPath = this.metadataTools.toPath( projectRef );
- Path projectMetadata = this.repositoryDir.resolve( metadataPath );
+ StorageAsset projectMetadata = this.repositoryDir.resolve( metadataPath );
- if ( Files.exists(projectMetadata) && ( Files.getLastModifiedTime( projectMetadata).toMillis() >= this.scanStartTimestamp ) )
+ if ( projectMetadata.exists() && ( projectMetadata.getModificationTime().toEpochMilli() >= this.scanStartTimestamp ) )
{
// This metadata is up to date. skip it.
log.debug( "Skipping uptodate metadata: {}", this.metadataTools.toPath( projectRef ) );
triggerConsumerError( TYPE_METADATA_WRITE_FAILURE,
"Unable to write project metadata for artifact [" + path + "]: " + e.getMessage( ) );
}
- catch ( IOException e )
- {
- log.warn( "Project metadata not written due to IO warning: ", e );
- triggerConsumerWarning( TYPE_METADATA_IO,
- "Project metadata not written due to IO warning: " + e.getMessage( ) );
- }
}
private void updateVersionMetadata( ArtifactReference artifact, String path )
{
String metadataPath = this.metadataTools.toPath( versionRef );
- Path projectMetadata = this.repositoryDir.resolve( metadataPath );
+ StorageAsset projectMetadata = this.repositoryDir.resolve( metadataPath );
- if ( Files.exists(projectMetadata) && ( Files.getLastModifiedTime( projectMetadata ).toMillis() >= this.scanStartTimestamp ) )
+ if ( projectMetadata.exists() && ( projectMetadata.getModificationTime().toEpochMilli() >= this.scanStartTimestamp ) )
{
// This metadata is up to date. skip it.
log.debug( "Skipping uptodate metadata: {}", this.metadataTools.toPath( versionRef ) );
triggerConsumerError( TYPE_METADATA_WRITE_FAILURE,
"Unable to write version metadata for artifact [" + path + "]: " + e.getMessage( ) );
}
- catch ( IOException e )
- {
- log.warn( "Version metadata not written due to IO warning: ", e );
- triggerConsumerWarning( TYPE_METADATA_IO,
- "Version metadata not written due to IO warning: " + e.getMessage( ) );
- }
}
/*
import org.apache.archiva.metadata.model.facets.AuditEvent;
import org.apache.archiva.metadata.maven.model.MavenArtifactFacet;
import org.apache.archiva.metadata.repository.*;
-import org.apache.archiva.model.ArtifactReference;
-import org.apache.archiva.repository.ContentNotFoundException;
-import org.apache.archiva.repository.ManagedRepositoryContent;
import org.apache.archiva.metadata.audit.RepositoryListener;
+import org.apache.archiva.repository.ManagedRepositoryContent;
import org.apache.archiva.repository.content.Artifact;
import org.apache.archiva.repository.content.ItemNotFoundException;
import org.apache.archiva.repository.storage.StorageAsset;
import org.apache.archiva.model.ProjectReference;
import org.apache.archiva.model.VersionedReference;
import org.apache.archiva.repository.ContentNotFoundException;
-import org.apache.archiva.repository.LayoutException;
import org.apache.archiva.repository.ManagedRepositoryContent;
+import org.apache.archiva.repository.LayoutException;
+import org.apache.archiva.repository.BaseRepositoryContentLayout;
import org.apache.archiva.repository.ReleaseScheme;
-import org.apache.archiva.repository.RepositoryException;
import org.apache.archiva.repository.RepositoryRegistry;
import org.apache.archiva.metadata.audit.RepositoryListener;
import org.apache.archiva.repository.content.ItemSelector;
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.storage.StorageAsset;
import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
{
try
{
- Path artifactFile = Paths.get( repository.getRepoRoot( ), path );
+ StorageAsset artifactFile = repository.getRepository( ).getAsset( "" ).resolve( path );
+ BaseRepositoryContentLayout layout = repository.getLayout( BaseRepositoryContentLayout.class );
- if ( !Files.exists(artifactFile) )
+ if ( !artifactFile.exists() )
{
// Nothing to do here, file doesn't exist, skip it.
return;
}
- ArtifactReference artifactRef = repository.toArtifactReference( path );
+ ArtifactReference artifactRef = repository.getLayout( BaseRepositoryContentLayout.class ).toArtifactReference( path );
if ( !VersionUtil.isSnapshot( artifactRef.getVersion( ) ) )
{
if ( repo.getActiveReleaseSchemes().contains( ReleaseScheme.RELEASE ))
{
- ManagedRepositoryContent repoContent = repo.getContent();
+ BaseRepositoryContentLayout repoContent = repo.getContent().getLayout( BaseRepositoryContentLayout.class );
Project proj = repoContent.getProject( selector );
for ( Version version : repoContent.getVersions( proj ) )
{
if ( releasedVersions.contains( VersionUtil.getReleaseVersion( artifactRef.getVersion( ) ) ) )
{
versionRef.setVersion( artifactRef.getVersion( ) );
- repository.deleteVersion( versionRef );
+ layout.deleteVersion( versionRef );
for ( RepositoryListener listener : listeners )
{
listener.deleteArtifact( metadataRepository, repository.getId( ), artifactRef.getGroupId( ),
artifactRef.getArtifactId( ), artifactRef.getVersion( ),
- artifactFile.getFileName().toString() );
+ artifactFile.getName() );
}
metadataRepository.removeProjectVersion( repositorySession, repository.getId( ),
artifactRef.getGroupId( ), artifactRef.getArtifactId( ), artifactRef.getVersion( ) );
import org.apache.archiva.common.utils.VersionUtil;
import org.apache.archiva.metadata.audit.RepositoryListener;
import org.apache.archiva.metadata.repository.RepositorySession;
-import org.apache.archiva.model.ArtifactReference;
-import org.apache.archiva.repository.ContentNotFoundException;
-import org.apache.archiva.repository.LayoutException;
import org.apache.archiva.repository.ManagedRepositoryContent;
+import org.apache.archiva.repository.LayoutException;
+import org.apache.archiva.repository.BaseRepositoryContentLayout;
import org.apache.archiva.repository.content.Artifact;
import org.apache.archiva.repository.content.ContentItem;
-import org.apache.archiva.repository.content.ItemNotFoundException;
import org.apache.archiva.repository.content.base.ArchivaItemSelector;
-import org.apache.archiva.repository.storage.StorageAsset;
import org.apache.commons.lang3.StringUtils;
import java.text.ParseException;
.build( );
List<String> artifactVersions;
- try( Stream<? extends Artifact> stream = repository.newArtifactStream( selector )){
+ try( Stream<? extends Artifact> stream = repository.getLayout( BaseRepositoryContentLayout.class ).newArtifactStream( selector )){
artifactVersions = stream.map( a -> a.getArtifactVersion( ) )
.filter( StringUtils::isNotEmpty )
.distinct()
// Is this a generic snapshot "1.0-SNAPSHOT" ?
if ( VersionUtil.isGenericSnapshot( version ) )
{
- List<? extends Artifact> artifactList = repository.getArtifacts( artifactSelector );
+ List<? extends Artifact> artifactList = repository.getLayout( BaseRepositoryContentLayout.class ).getArtifacts( artifactSelector );
if ( artifactList.size()>0 && artifactList.get(0).getAsset().getModificationTime( ).toEpochMilli( ) < olderThanThisDate.getTimeInMillis( ) )
{
artifactsToDelete.addAll( artifactList );
if ( timestampCal.getTimeInMillis( ) < olderThanThisDate.getTimeInMillis( ) )
{
- artifactsToDelete.addAll( repository.getArtifacts( artifactSelector ) );
+ artifactsToDelete.addAll( repository.getLayout( BaseRepositoryContentLayout.class ).getArtifacts( artifactSelector ) );
}
}
} catch ( IllegalArgumentException e ) {
import org.apache.archiva.metadata.repository.RepositorySessionFactory;
import org.apache.archiva.components.registry.Registry;
import org.apache.archiva.components.registry.RegistryListener;
-import org.apache.archiva.repository.ManagedRepository;
import org.apache.archiva.repository.ManagedRepositoryContent;
+import org.apache.archiva.repository.ManagedRepository;
import org.apache.archiva.repository.RepositoryContentFactory;
import org.apache.archiva.repository.RepositoryRegistry;
import org.apache.archiva.metadata.audit.RepositoryListener;
import org.apache.archiva.common.utils.VersionUtil;
import org.apache.archiva.metadata.repository.RepositorySession;
import org.apache.archiva.model.ArtifactReference;
-import org.apache.archiva.model.VersionedReference;
-import org.apache.archiva.repository.ContentNotFoundException;
-import org.apache.archiva.repository.LayoutException;
import org.apache.archiva.repository.ManagedRepositoryContent;
+import org.apache.archiva.repository.LayoutException;
+import org.apache.archiva.repository.BaseRepositoryContentLayout;
import org.apache.archiva.metadata.audit.RepositoryListener;
import org.apache.archiva.repository.content.Artifact;
import org.apache.archiva.repository.content.ContentItem;
-import org.apache.archiva.repository.content.ItemSelector;
-import org.apache.archiva.repository.content.Version;
import org.apache.archiva.repository.content.base.ArchivaItemSelector;
import org.apache.commons.lang3.StringUtils;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
List<String> versions;
- try( Stream<? extends Artifact> stream = repository.newArtifactStream( selector) ){
+ try( Stream<? extends Artifact> stream = repository.getLayout( BaseRepositoryContentLayout.class ).newArtifactStream( selector) ){
versions = stream.map( a -> a.getArtifactVersion( ) )
.filter( StringUtils::isNotEmpty )
.distinct()
{
break;
}
- List<? extends Artifact> delArtifacts = repository.getArtifacts( selectorBuilder.withArtifactVersion( version ).build( ) );
+ List<? extends Artifact> delArtifacts = repository.getLayout( BaseRepositoryContentLayout.class ).getArtifacts( selectorBuilder.withArtifactVersion( version ).build( ) );
if (delArtifacts!=null && delArtifacts.size()>0)
{
artifactsToDelete.addAll( delArtifacts );
import org.apache.archiva.metadata.repository.MetadataRepository;
import org.apache.archiva.metadata.repository.RepositorySession;
import org.apache.archiva.metadata.repository.RepositorySessionFactory;
+import org.apache.archiva.repository.ManagedRepositoryContent;
import org.apache.archiva.repository.maven.metadata.storage.Maven2RepositoryPathTranslator;
import org.apache.archiva.repository.base.BasicManagedRepository;
-import org.apache.archiva.repository.ManagedRepositoryContent;
import org.apache.archiva.repository.ReleaseScheme;
import org.apache.archiva.repository.RepositoryContentProvider;
import org.apache.archiva.metadata.audit.RepositoryListener;
import org.apache.archiva.proxy.model.ProxyFetchResult;
import org.apache.archiva.proxy.model.RepositoryProxyHandler;
import org.apache.archiva.components.taskqueue.TaskQueueException;
+import org.apache.archiva.repository.BaseRepositoryContentLayout;
+import org.apache.archiva.repository.LayoutException;
import org.apache.archiva.repository.ManagedRepository;
import org.apache.archiva.repository.RemoteRepository;
import org.apache.archiva.repository.RemoteRepositoryContent;
public StorageAsset fetchFromProxies( ManagedRepository repository, ArtifactReference artifact )
throws ProxyDownloadException
{
- StorageAsset localFile = toLocalFile( repository, artifact );
+ StorageAsset localFile = null;
+ Map<String, Exception> previousExceptions = new LinkedHashMap<>();
+ try
+ {
+ localFile = toLocalFile( repository, artifact );
+ }
+ catch ( LayoutException e )
+ {
+ previousExceptions.put( "LayoutException", e );
+ throw new ProxyDownloadException( "Could not convert to BasicRepositoryContentLayout " + e.getMessage( ), previousExceptions);
+ }
Properties requestProperties = new Properties();
requestProperties.setProperty( "filetype", "artifact" );
requestProperties.setProperty( "managedRepositoryId", repository.getId() );
List<ProxyConnector> connectors = getProxyConnectors( repository );
- Map<String, Exception> previousExceptions = new LinkedHashMap<>();
for ( ProxyConnector connector : connectors )
{
if ( !connector.isEnabled() )
}
}
- private StorageAsset toLocalFile(ManagedRepository repository, ArtifactReference artifact )
+ private StorageAsset toLocalFile(ManagedRepository repository, ArtifactReference artifact ) throws LayoutException
{
- return repository.getContent().toFile( artifact );
+ return repository.getContent().getLayout( BaseRepositoryContentLayout.class ).toFile( artifact );
}
/**
--- /dev/null
+package org.apache.archiva.repository;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.model.ArchivaArtifact;
+import org.apache.archiva.model.ArtifactReference;
+import org.apache.archiva.model.ProjectReference;
+import org.apache.archiva.model.VersionedReference;
+import org.apache.archiva.repository.content.Artifact;
+import org.apache.archiva.repository.content.ContentItem;
+import org.apache.archiva.repository.content.ItemNotFoundException;
+import org.apache.archiva.repository.content.ItemSelector;
+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.storage.StorageAsset;
+
+import java.nio.file.Path;
+import java.util.List;
+import java.util.stream.Stream;
+
+/**
+ * Layout interface for interacting with a managed repository in an abstract way,
+ * without the need for processing based on filesystem paths, or working with the database.
+ *
+ *
+ */
+public interface BaseRepositoryContentLayout extends RepositoryContent, ManagedRepositoryContent, ManagedRepositoryContentLayout
+{
+
+ /// ***************** New generation interface **********************
+
+
+ /**
+ * Returns the namespace for the given selected coordinates. The selector must specify a namespace. All other
+ * coordinates are ignored.
+ * The following coordinates must be set at the given selector:
+ * <ul>
+ * <li>namespace</li>
+ * </ul>
+ * If not, a {@link IllegalArgumentException} will be thrown.
+ *
+ * @param namespaceSelector the selectory with the namespace coordinates
+ * @return the namespace
+ * @throws ItemNotFoundException if the item does not exist
+ * @throws ContentAccessException if the item cannot be accessed
+ * @throws IllegalArgumentException if the selector has no namespace specified
+ */
+ Namespace getNamespace( ItemSelector namespaceSelector ) throws ContentAccessException, IllegalArgumentException;
+
+ /**
+ * Returns the project for the given coordinates.
+ * The following coordinates must be set at the given selector:
+ * <ul>
+ * <li>namespace</li>
+ * <li>projectId</li>
+ * </ul>
+ * If not, a {@link IllegalArgumentException} will be thrown.
+ * Additional coordinates will be ignored.
+ *
+ * @param projectSelector
+ * @return the project instance
+ * @throws ItemNotFoundException if the project does not exist
+ * @throws ContentAccessException if the item cannot be accessed
+ * @throws IllegalArgumentException if the selector does not specify the required coordinates
+ */
+ Project getProject( ItemSelector projectSelector ) throws ContentAccessException, IllegalArgumentException;
+
+ /**
+ * Returns the version for the given coordinates.
+ * The following coordinates must be set at the given selector:
+ * <ul>
+ * <li>namespace</li>
+ * <li>projectId</li>
+ * <li>version</li>
+ * </ul>
+ * If not, a {@link IllegalArgumentException} will be thrown.
+ *
+ * Additional coordinates will be ignored.
+ *
+ * @param versionCoordinates
+ * @return the version object
+ * @throws ItemNotFoundException
+ * @throws ContentAccessException
+ * @throws IllegalArgumentException
+ */
+ Version getVersion(ItemSelector versionCoordinates) throws ContentAccessException, IllegalArgumentException;
+
+
+ /**
+ * Returns the artifact object for the given coordinates.
+ *
+ * Normally the following coordinates should be set at the given selector:
+ * <ul>
+ * <li>namespace</li>
+ * <li>artifactVersion and or version</li>
+ * <li>artifactId or projectId</li>
+ * </ul>
+ * If the coordinates do not provide enough information for selecting a artifact, a {@link IllegalArgumentException} will be thrown
+ * It depends on the repository type, what exactly is returned for a given set of coordinates. Some repository type
+ * may have different required and optional coordinates. For further information please check the documentation for the
+ * type specific implementations.
+ *
+ * The following coordinates are optional and may further specify the artifact to return.
+ * <ul>
+ * <li>classifier</li>
+ * <li>type</li>
+ * <li>extension</li>
+ * </ul>
+ *
+ * The method always returns a artifact object, if the coordinates are valid. It does not guarantee that the artifact
+ * exists. To check if there is really a physical representation of the artifact, use the <code>{@link Artifact#exists()}</code>
+ * method of the artifact.
+ * For upload and data retrieval use the methods of the {@link StorageAsset} reference returned in the artifact.
+ *
+ *
+ * @param selector the selector with the artifact coordinates
+ * @return a artifact object
+ * @throws IllegalArgumentException if the selector coordinates do not specify a artifact
+ * @throws ContentAccessException if the access to the underlying storage failed
+ */
+ Artifact getArtifact(ItemSelector selector) throws ContentAccessException;
+
+
+ /**
+ * Returns the artifacts that match the given selector. It is up to the repository implementation
+ * what artifacts are returned for a given set of coordinates.
+ *
+ * @param selector the selector for the artifacts
+ * @return a list of artifacts.
+ * @throws IllegalArgumentException if the specified coordinates cannot be found in the repository
+ * @throws ContentAccessException if the access to the underlying storage failed
+ */
+ List<? extends Artifact> getArtifacts( ItemSelector selector) throws ContentAccessException;
+
+ /**
+ * Returns the artifacts that match the given selector. It is up to the repository implementation
+ * what artifacts are returned for a given set of coordinates.
+ *
+ * The returned stream is autoclosable and should always closed after using it.
+ *
+ * There is no guarantee about the order of the returned artifacts
+ *
+ * @param selector the selector for the artifacts
+ * @return a stream with artifact elements.
+ * @throws ItemNotFoundException if the specified coordinates cannot be found in the repository
+ * @throws ContentAccessException if the access to the underlying storage failed
+ */
+ Stream<? extends Artifact> newArtifactStream( ItemSelector selector) throws ContentAccessException;
+
+
+ /**
+ * Return the projects that are part of the given namespace.
+ *
+ * @param namespace the namespace
+ * @return the list of projects or a empty list, if there are no projects for the given namespace.
+ */
+ List<? extends Project> getProjects( Namespace namespace) throws ContentAccessException;
+
+ /**
+ * Returns the list of projects that match the given selector. The selector must at least specify a
+ * a namespace.
+ *
+ * @param selector the selector
+ * @return the list of projects that match the selector. A empty list of not project matches.
+ * @throws ContentAccessException if the access to the storage backend failed
+ * @throws IllegalArgumentException if the selector does not contain sufficient data for selecting projects
+ */
+ List<? extends Project> getProjects( ItemSelector selector ) throws ContentAccessException, IllegalArgumentException;
+
+ /**
+ * Return the existing versions of the given project.
+ *
+ * @param project the project
+ * @return a list of versions or a empty list, if not versions are available for the specified project
+ * @throws ContentAccessException if the access to the underlying storage failed
+ */
+ List<? extends Version> getVersions( Project project) throws ContentAccessException;
+
+
+ /**
+ * Return the versions that match the given selector. The selector must at least specify a namespace and a projectId.
+ *
+ * @param selector the item selector. At least namespace and projectId must be set.
+ * @return the list of version or a empty list, if no version matches the selector
+ * @throws ContentAccessException if the access to the backend failed
+ * @throws IllegalArgumentException if the selector does not contain enough information for selecting versions
+ */
+ List<? extends Version> getVersions( ItemSelector selector ) throws ContentAccessException, IllegalArgumentException;
+
+ /**
+ * Returns all found artifact versions that can be found for the given selector. The selector must specify at least
+ * a project.
+ *
+ * @param selector the item selector that must specify at least a project
+ * @return the list of artifact versions
+ * @throws ContentAccessException if the access to the underlying storage failed
+ * @throws IllegalArgumentException if the selector does not have project information
+ */
+ List<String> getArtifactVersions( ItemSelector selector ) throws ContentAccessException, IllegalArgumentException;
+
+ /**
+ * Return all the artifacts of a given content item (namespace, project, version)
+ *
+ * @param item the item
+ * @return a list of artifacts or a empty list, if no artifacts are available for the specified item
+ */
+ List<? extends Artifact> getArtifacts( ContentItem item) throws ContentAccessException;
+
+ /**
+ * Return a stream of artifacts that are part of the given content item. The returned stream is
+ * auto closable. There is no guarantee about the order of returned artifacts.
+ *
+ * As the stream may access IO resources, you should always use call this method inside try-with-resources or
+ * make sure, that the stream is closed after using it.
+ *
+ * @param item the item from where the artifacts should be returned
+ * @return a stream of artifacts. The stream is auto closable. You should always make sure, that the stream
+ * is closed after use.
+ * @throws ContentAccessException if the access to the underlying storage failed
+ */
+ Stream<? extends Artifact> newArtifactStream( ContentItem item ) throws ContentAccessException;
+
+
+ /**
+ * Copies the artifact to the given destination coordinates
+ *
+ * @param sourceFile the path to the source file
+ * @param destination the coordinates of the destination
+ * @throws IllegalArgumentException if the destination is not valid
+ */
+ void addArtifact( Path sourceFile, Artifact destination ) throws IllegalArgumentException, ContentAccessException;
+
+
+ /// ***************** End of new generation interface **********************
+
+
+
+ /**
+ * Returns the version reference for the given coordinates.
+ * @param groupId the group id
+ * @param artifactId the artifact id
+ * @param version the version number
+ * @return a version reference
+ */
+ VersionedReference toVersion( String groupId, String artifactId, String version );
+
+
+ /**
+ * Return the version reference that matches exactly the version string of the artifact
+ *
+ * @param artifactReference The artifact reference
+ * @return the version reference
+ */
+ VersionedReference toVersion( ArtifactReference artifactReference);
+
+
+ /**
+ * Delete from the managed repository all files / directories associated with the
+ * provided version reference.
+ *
+ * @param reference the version reference to delete.
+ * @throws ContentNotFoundException
+ */
+ void deleteVersion( VersionedReference reference )
+ throws ContentNotFoundException, ContentAccessException;
+
+
+
+ /**
+ * delete a specified artifact from the repository
+ *
+ * @param artifactReference
+ * @throws ContentNotFoundException
+ */
+ void deleteArtifact( ArtifactReference artifactReference )
+ throws ContentNotFoundException, ContentAccessException;
+
+
+
+ /**
+ * @param groupId
+ * @throws ContentNotFoundException
+ * @since 1.4-M3
+ */
+ void deleteGroupId( String groupId )
+ throws ContentNotFoundException, ContentAccessException;
+
+
+
+
+ /**
+ *
+ * @param namespace groupId for maven
+ * @param projectId artifactId for maven
+ * @throws ContentNotFoundException
+ */
+ void deleteProject( String namespace, String projectId )
+ throws ContentNotFoundException, ContentAccessException;
+
+
+ /**
+ * Deletes a project
+ * @param reference
+ */
+ void deleteProject(ProjectReference reference) throws ContentNotFoundException, ContentAccessException;
+
+
+
+
+
+
+ /**
+ * <p>
+ * Gather up the list of related artifacts to the ArtifactReference provided.
+ * This typically includes the pom files, and those things with
+ * classifiers (such as doc, source code, test libs, etc...). Even if the classifier
+ * is set in the artifact reference, it may return artifacts with different classifiers.
+ * </p>
+ * <p>
+ * <strong>NOTE:</strong> Some layouts (such as maven 1 "legacy") are not compatible with this query.
+ * </p>
+ *
+ * @param reference the reference to work off of.
+ * @return the list of ArtifactReferences for related artifacts, if
+ * @throws ContentNotFoundException if the initial artifact reference does not exist within the repository.
+ */
+ List<ArtifactReference> getRelatedArtifacts( VersionedReference reference )
+ throws ContentNotFoundException, LayoutException, ContentAccessException;
+
+
+ /**
+ * Returns all artifacts that belong to a given version
+ * @param reference the version reference
+ * @return the list of artifacts or a empty list
+ */
+ List<ArtifactReference> getArtifacts(VersionedReference reference) throws ContentNotFoundException, LayoutException, ContentAccessException;
+
+
+
+
+ /**
+ * <p>
+ * Convenience method to get the repository (on disk) root directory.
+ * </p>
+ * <p>
+ * Equivalent to calling <code>.getRepository().getLocation()</code>
+ * </p>
+ *
+ * @return the repository (on disk) root directory.
+ */
+ String getRepoRoot();
+
+ /**
+ * Determines if the artifact referenced exists in the repository.
+ *
+ * @param reference the artifact reference to check for.
+ * @return true if the artifact referenced exists.
+ */
+ boolean hasContent( ArtifactReference reference ) throws ContentAccessException;
+
+ /**
+ * Determines if the version reference exists in the repository.
+ *
+ * @param reference the version reference to check for.
+ * @return true if the version referenced exists.
+ */
+ boolean hasContent( VersionedReference reference ) throws ContentAccessException;
+
+
+
+ /**
+ * Given an {@link ArtifactReference}, return the file reference to the artifact.
+ *
+ * @param reference the artifact reference to use.
+ * @return the relative path to the artifact.
+ */
+ StorageAsset toFile( VersionedReference reference );
+
+ /**
+ * Given an {@link ArtifactReference}, return the file reference to the artifact.
+ *
+ * @param reference the artifact reference to use.
+ * @return the relative path to the artifact.
+ */
+ StorageAsset toFile( ArtifactReference reference );
+
+ /**
+ * Given an {@link ArchivaArtifact}, return the file reference to the artifact.
+ *
+ * @param reference the archiva artifact to use.
+ * @return the relative path to the artifact.
+ */
+ StorageAsset toFile( ArchivaArtifact reference );
+
+ /**
+ * Given a {@link ProjectReference}, return the path to the metadata for
+ * the project.
+ *
+ * @param reference the reference to use.
+ * @return the path to the metadata file, or null if no metadata is appropriate.
+ */
+ String toMetadataPath( ProjectReference reference );
+
+ /**
+ * Given a {@link VersionedReference}, return the path to the metadata for
+ * the specific version of the project.
+ *
+ * @param reference the reference to use.
+ * @return the path to the metadata file, or null if no metadata is appropriate.
+ */
+ String toMetadataPath( VersionedReference reference );
+
+ /**
+ * Given an {@link ArchivaArtifact}, return the relative path to the artifact.
+ *
+ * @param reference the archiva artifact to use.
+ * @return the relative path to the artifact.
+ */
+ String toPath( ArchivaArtifact reference );
+
+
+}
* Sets the content
* @param content
*/
- void setContent(ManagedRepositoryContent content);
+ void setContent( ManagedRepositoryContent content);
/**
* Adds an active release scheme. Release schemes may be combined.
+++ /dev/null
-package org.apache.archiva.repository;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.archiva.repository.content.ContentItem;
-import org.apache.archiva.repository.content.ItemNotFoundException;
-import org.apache.archiva.repository.content.ItemSelector;
-import org.apache.archiva.repository.storage.StorageAsset;
-
-import java.util.List;
-import java.util.function.Consumer;
-import java.util.stream.Stream;
-
-/**
- * @author Martin Stockhammer <martin_s@apache.org>
- */
-public interface GenericManagedRepositoryContent
-{
- /**
- * Delete all items that match the given selector. The type and number of deleted items
- * depend on the specific selector:
- * <ul>
- * <li>namespace: the complete namespace is deleted (recursively if the recurse flag is set)</li>
- * <li>project: the complete project and all contained versions are deleted</li>
- * <li>version: the version inside the project is deleted (project is required)</li>
- * <li>artifactId: all artifacts that match the id (project and version are required)</li>
- * <li>artifactVersion: all artifacts that match the version (project and version are required)</li>
- * <li></li>
- * </ul>
- *
- * @param selector the item selector that selects the artifacts to delete
- * @param consumer a consumer of the items that will be called after deletion
- * @returns the list of items that are deleted
- * @throws ContentAccessException if the deletion was not possible or only partly successful, because the access
- * to the artifacts failed
- * @throws IllegalArgumentException if the selector does not specify valid artifacts to delete
- */
- void deleteAllItems( ItemSelector selector, Consumer<ItemDeleteStatus> consumer ) throws ContentAccessException, IllegalArgumentException;
-
- /**
- * Removes the specified content item and if the item is a container or directory,
- * all content stored under the given item.
- *
- * @param item the item.
- * @throws ItemNotFoundException if the item cannot be found
- * @throws ContentAccessException if the deletion was not possible or only partly successful, because the access
- * to the artifacts failed
- */
- void deleteItem( ContentItem item ) throws ItemNotFoundException, ContentAccessException;
-
- /**
- * Returns a item for the given selector. The type of the returned item depends on the
- * selector.
- *
- * @param selector the item selector
- * @return the content item that matches the given selector
- * @throws ContentAccessException if an error occured while accessing the backend
- * @throws IllegalArgumentException if the selector does not select a valid content item
- */
- ContentItem getItem( ItemSelector selector ) throws ContentAccessException, IllegalArgumentException;
-
- /**
- * Returns a stream of items that match the given selector. It may return a stream of mixed types,
- * like namespaces, projects, versions and artifacts. It will not select a specific type.
- * The selector can specify the '*' pattern for all fields.
- * The returned elements will be provided by depth first.
- *
- * @param selector the item selector that specifies the items
- * @return the stream of content items
- * @throws ContentAccessException if the access to the underlying storage failed
- * @throws IllegalArgumentException if a illegal coordinate combination was provided
- */
- Stream<? extends ContentItem> newItemStream( ItemSelector selector, boolean parallel ) throws ContentAccessException, IllegalArgumentException;
-
- /**
- * Returns the item that matches the given path. The item at the path must not exist.
- *
- * @param path the path string that points to the item
- * @return the content item if the path is a valid item path
- * @throws LayoutException if the path is not valid for the repository layout
- */
- ContentItem toItem( String path ) throws LayoutException;
-
- /**
- * Returns the item that matches the given asset path. The asset must not exist.
- *
- * @param assetPath the path to the artifact or directory
- * @return the item, if it is a valid path for the repository layout
- * @throws LayoutException if the path is not valid for the repository
- */
- ContentItem toItem( StorageAsset assetPath ) throws LayoutException;
-
- /**
- * Returns true, if the selector coordinates point to a existing item in the repository.
- *
- * @param selector the item selector
- * @return <code>true</code>, if there exists such a item, otherwise <code>false</code>
- */
- boolean hasContent( ItemSelector selector );
-
- /**
- * Returns the parent of the item.
- * @param item the current item
- * @return the parent item, or <code>null</code> if no such item exists
- */
- ContentItem getParent(ContentItem item);
-
- /**
- * Returns the list of children items.
- * @param item the current item
- * @return the list of children, or a empty list, if no children exist
- */
- List<? extends ContentItem> getChildren( ContentItem item);
-
- /**
- * Tries to apply the given characteristic to the content item. If the layout does not allow this,
- * it will throw a <code>LayoutException</code>.
- *
- * @param clazz the characteristic class to apply
- * @param item the content item
- * @param <T> The characteristic
- * @return the applied characteristic
- */
- <T extends ContentItem> T applyCharacteristic(Class<T> clazz, ContentItem item) throws LayoutException;
-}
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ * http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* under the License.
*/
-import org.apache.archiva.model.ArchivaArtifact;
-import org.apache.archiva.model.ArtifactReference;
-import org.apache.archiva.model.ProjectReference;
-import org.apache.archiva.model.VersionedReference;
-import org.apache.archiva.repository.content.Artifact;
import org.apache.archiva.repository.content.ContentItem;
import org.apache.archiva.repository.content.ItemNotFoundException;
import org.apache.archiva.repository.content.ItemSelector;
-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.storage.StorageAsset;
-import java.nio.file.Path;
-import java.util.BitSet;
import java.util.List;
-import java.util.Set;
import java.util.function.Consumer;
import java.util.stream.Stream;
/**
- * ManagedRepositoryContent interface for interacting with a managed repository in an abstract way,
- * without the need for processing based on filesystem paths, or working with the database.
- *
- * This interface
+ * @author Martin Stockhammer <martin_s@apache.org>
*/
-public interface ManagedRepositoryContent extends RepositoryContent, GenericManagedRepositoryContent
+public interface ManagedRepositoryContent
{
- /// ***************** New generation interface **********************
-
/**
- * Returns the namespace for the given selected coordinates. The selector must specify a namespace. All other
- * coordinates are ignored.
- * The following coordinates must be set at the given selector:
- * <ul>
- * <li>namespace</li>
- * </ul>
- * If not, a {@link IllegalArgumentException} will be thrown.
+ * Returns the path of the given item.
*
- * @param namespaceSelector the selectory with the namespace coordinates
- * @return the namespace
- * @throws ItemNotFoundException if the item does not exist
- * @throws ContentAccessException if the item cannot be accessed
- * @throws IllegalArgumentException if the selector has no namespace specified
+ * @param item
+ * @return
*/
- Namespace getNamespace( ItemSelector namespaceSelector ) throws ContentAccessException, IllegalArgumentException;
+ String toPath( ContentItem item );
+
- /**
- * Returns the project for the given coordinates.
- * The following coordinates must be set at the given selector:
- * <ul>
- * <li>namespace</li>
- * <li>projectId</li>
- * </ul>
- * If not, a {@link IllegalArgumentException} will be thrown.
- * Additional coordinates will be ignored.
- *
- * @param projectSelector
- * @return the project instance
- * @throws ItemNotFoundException if the project does not exist
- * @throws ContentAccessException if the item cannot be accessed
- * @throws IllegalArgumentException if the selector does not specify the required coordinates
- */
- Project getProject( ItemSelector projectSelector ) throws ContentAccessException, IllegalArgumentException;
/**
- * Returns the version for the given coordinates.
- * The following coordinates must be set at the given selector:
- * <ul>
- * <li>namespace</li>
- * <li>projectId</li>
- * <li>version</li>
- * </ul>
- * If not, a {@link IllegalArgumentException} will be thrown.
- *
- * Additional coordinates will be ignored.
+ * <p>
+ * Convenience method to get the repository id.
+ * </p>
+ * <p>
+ * Equivalent to calling <code>.getRepository().getId()</code>
+ * </p>
*
- * @param versionCoordinates
- * @return the version object
- * @throws ItemNotFoundException
- * @throws ContentAccessException
- * @throws IllegalArgumentException
+ * @return the repository id.
*/
- Version getVersion(ItemSelector versionCoordinates) throws ContentAccessException, IllegalArgumentException;
-
+ String getId();
/**
- * Returns the artifact object for the given coordinates.
- *
- * Normally the following coordinates should be set at the given selector:
- * <ul>
- * <li>namespace</li>
- * <li>artifactVersion and or version</li>
- * <li>artifactId or projectId</li>
- * </ul>
- * If the coordinates do not provide enough information for selecting a artifact, a {@link IllegalArgumentException} will be thrown
- * It depends on the repository type, what exactly is returned for a given set of coordinates. Some repository type
- * may have different required and optional coordinates. For further information please check the documentation for the
- * type specific implementations.
- *
- * The following coordinates are optional and may further specify the artifact to return.
+ * Delete all items that match the given selector. The type and number of deleted items
+ * depend on the specific selector:
* <ul>
- * <li>classifier</li>
- * <li>type</li>
- * <li>extension</li>
+ * <li>namespace: the complete namespace is deleted (recursively if the recurse flag is set)</li>
+ * <li>project: the complete project and all contained versions are deleted</li>
+ * <li>version: the version inside the project is deleted (project is required)</li>
+ * <li>artifactId: all artifacts that match the id (project and version are required)</li>
+ * <li>artifactVersion: all artifacts that match the version (project and version are required)</li>
+ * <li></li>
* </ul>
*
- * The method always returns a artifact object, if the coordinates are valid. It does not guarantee that the artifact
- * exists. To check if there is really a physical representation of the artifact, use the <code>{@link Artifact#exists()}</code>
- * method of the artifact.
- * For upload and data retrieval use the methods of the {@link StorageAsset} reference returned in the artifact.
- *
- *
- * @param selector the selector with the artifact coordinates
- * @return a artifact object
- * @throws IllegalArgumentException if the selector coordinates do not specify a artifact
- * @throws ContentAccessException if the access to the underlying storage failed
+ * @param selector the item selector that selects the artifacts to delete
+ * @param consumer a consumer of the items that will be called after deletion
+ * @returns the list of items that are deleted
+ * @throws ContentAccessException if the deletion was not possible or only partly successful, because the access
+ * to the artifacts failed
+ * @throws IllegalArgumentException if the selector does not specify valid artifacts to delete
*/
- Artifact getArtifact(ItemSelector selector) throws ContentAccessException;
-
+ void deleteAllItems( ItemSelector selector, Consumer<ItemDeleteStatus> consumer ) throws ContentAccessException, IllegalArgumentException;
/**
- * Returns the artifacts that match the given selector. It is up to the repository implementation
- * what artifacts are returned for a given set of coordinates.
+ * Removes the specified content item and if the item is a container or directory,
+ * all content stored under the given item.
*
- * @param selector the selector for the artifacts
- * @return a list of artifacts.
- * @throws IllegalArgumentException if the specified coordinates cannot be found in the repository
- * @throws ContentAccessException if the access to the underlying storage failed
+ * @param item the item.
+ * @throws ItemNotFoundException if the item cannot be found
+ * @throws ContentAccessException if the deletion was not possible or only partly successful, because the access
+ * to the artifacts failed
*/
- List<? extends Artifact> getArtifacts( ItemSelector selector) throws ContentAccessException;
+ void deleteItem( ContentItem item ) throws ItemNotFoundException, ContentAccessException;
/**
- * Returns the artifacts that match the given selector. It is up to the repository implementation
- * what artifacts are returned for a given set of coordinates.
- *
- * The returned stream is autoclosable and should always closed after using it.
+ * Returns a item for the given selector. The type of the returned item depends on the
+ * selector.
*
- * There is no guarantee about the order of the returned artifacts
- *
- * @param selector the selector for the artifacts
- * @return a stream with artifact elements.
- * @throws ItemNotFoundException if the specified coordinates cannot be found in the repository
- * @throws ContentAccessException if the access to the underlying storage failed
+ * @param selector the item selector
+ * @return the content item that matches the given selector
+ * @throws ContentAccessException if an error occured while accessing the backend
+ * @throws IllegalArgumentException if the selector does not select a valid content item
*/
- Stream<? extends Artifact> newArtifactStream( ItemSelector selector) throws ContentAccessException;
-
+ ContentItem getItem( ItemSelector selector ) throws ContentAccessException, IllegalArgumentException;
/**
- * Return the projects that are part of the given namespace.
+ * Returns a stream of items that match the given selector. It may return a stream of mixed types,
+ * like namespaces, projects, versions and artifacts. It will not select a specific type.
+ * The selector can specify the '*' pattern for all fields.
+ * The returned elements will be provided by depth first.
*
- * @param namespace the namespace
- * @return the list of projects or a empty list, if there are no projects for the given namespace.
- */
- List<? extends Project> getProjects( Namespace namespace) throws ContentAccessException;
-
- /**
- * Returns the list of projects that match the given selector. The selector must at least specify a
- * a namespace.
- *
- * @param selector the selector
- * @return the list of projects that match the selector. A empty list of not project matches.
- * @throws ContentAccessException if the access to the storage backend failed
- * @throws IllegalArgumentException if the selector does not contain sufficient data for selecting projects
- */
- List<? extends Project> getProjects( ItemSelector selector ) throws ContentAccessException, IllegalArgumentException;
-
- /**
- * Return the existing versions of the given project.
- *
- * @param project the project
- * @return a list of versions or a empty list, if not versions are available for the specified project
- * @throws ContentAccessException if the access to the underlying storage failed
- */
- List<? extends Version> getVersions( Project project) throws ContentAccessException;
-
-
- /**
- * Return the versions that match the given selector. The selector must at least specify a namespace and a projectId.
- *
- * @param selector the item selector. At least namespace and projectId must be set.
- * @return the list of version or a empty list, if no version matches the selector
- * @throws ContentAccessException if the access to the backend failed
- * @throws IllegalArgumentException if the selector does not contain enough information for selecting versions
- */
- List<? extends Version> getVersions( ItemSelector selector ) throws ContentAccessException, IllegalArgumentException;
-
- /**
- * Returns all found artifact versions that can be found for the given selector. The selector must specify at least
- * a project.
- *
- * @param selector the item selector that must specify at least a project
- * @return the list of artifact versions
- * @throws ContentAccessException if the access to the underlying storage failed
- * @throws IllegalArgumentException if the selector does not have project information
- */
- List<String> getArtifactVersions( ItemSelector selector ) throws ContentAccessException, IllegalArgumentException;
-
- /**
- * Return all the artifacts of a given content item (namespace, project, version)
- *
- * @param item the item
- * @return a list of artifacts or a empty list, if no artifacts are available for the specified item
- */
- List<? extends Artifact> getArtifacts( ContentItem item) throws ContentAccessException;
-
- /**
- * Return a stream of artifacts that are part of the given content item. The returned stream is
- * auto closable. There is no guarantee about the order of returned artifacts.
- *
- * As the stream may access IO resources, you should always use call this method inside try-with-resources or
- * make sure, that the stream is closed after using it.
- *
- * @param item the item from where the artifacts should be returned
- * @return a stream of artifacts. The stream is auto closable. You should always make sure, that the stream
- * is closed after use.
+ * @param selector the item selector that specifies the items
+ * @return the stream of content items
* @throws ContentAccessException if the access to the underlying storage failed
+ * @throws IllegalArgumentException if a illegal coordinate combination was provided
*/
- Stream<? extends Artifact> newArtifactStream( ContentItem item ) throws ContentAccessException;
-
+ Stream<? extends ContentItem> newItemStream( ItemSelector selector, boolean parallel ) throws ContentAccessException, IllegalArgumentException;
/**
- * Copies the artifact to the given destination coordinates
+ * Returns the item that matches the given path. The item at the path must not exist.
*
- * @param sourceFile the path to the source file
- * @param destination the coordinates of the destination
- * @throws IllegalArgumentException if the destination is not valid
+ * @param path the path string that points to the item
+ * @return the content item if the path is a valid item path
+ * @throws LayoutException if the path is not valid for the repository layout
*/
- void addArtifact( Path sourceFile, Artifact destination ) throws IllegalArgumentException, ContentAccessException;
-
-
- /// ***************** End of new generation interface **********************
-
-
-
- /**
- * Returns the version reference for the given coordinates.
- * @param groupId the group id
- * @param artifactId the artifact id
- * @param version the version number
- * @return a version reference
- */
- VersionedReference toVersion( String groupId, String artifactId, String version );
-
+ ContentItem toItem( String path ) throws LayoutException;
/**
- * Return the version reference that matches exactly the version string of the artifact
+ * Returns the item that matches the given asset path. The asset must not exist.
*
- * @param artifactReference The artifact reference
- * @return the version reference
+ * @param assetPath the path to the artifact or directory
+ * @return the item, if it is a valid path for the repository layout
+ * @throws LayoutException if the path is not valid for the repository
*/
- VersionedReference toVersion( ArtifactReference artifactReference);
-
+ ContentItem toItem( StorageAsset assetPath ) throws LayoutException;
/**
- * Delete from the managed repository all files / directories associated with the
- * provided version reference.
+ * Returns true, if the selector coordinates point to a existing item in the repository.
*
- * @param reference the version reference to delete.
- * @throws ContentNotFoundException
+ * @param selector the item selector
+ * @return <code>true</code>, if there exists such a item, otherwise <code>false</code>
*/
- void deleteVersion( VersionedReference reference )
- throws ContentNotFoundException, ContentAccessException;
-
-
-
- /**
- * delete a specified artifact from the repository
- *
- * @param artifactReference
- * @throws ContentNotFoundException
- */
- void deleteArtifact( ArtifactReference artifactReference )
- throws ContentNotFoundException, ContentAccessException;
-
-
-
- /**
- * @param groupId
- * @throws ContentNotFoundException
- * @since 1.4-M3
- */
- void deleteGroupId( String groupId )
- throws ContentNotFoundException, ContentAccessException;
-
-
-
-
- /**
- *
- * @param namespace groupId for maven
- * @param projectId artifactId for maven
- * @throws ContentNotFoundException
- */
- void deleteProject( String namespace, String projectId )
- throws ContentNotFoundException, ContentAccessException;
-
-
- /**
- * Deletes a project
- * @param reference
- */
- void deleteProject(ProjectReference reference) throws ContentNotFoundException, ContentAccessException;
-
-
-
-
- /**
- * <p>
- * Convenience method to get the repository id.
- * </p>
- * <p>
- * Equivalent to calling <code>.getRepository().getId()</code>
- * </p>
- *
- * @return the repository id.
- */
- String getId();
-
- /**
- * <p>
- * Gather up the list of related artifacts to the ArtifactReference provided.
- * This typically includes the pom files, and those things with
- * classifiers (such as doc, source code, test libs, etc...). Even if the classifier
- * is set in the artifact reference, it may return artifacts with different classifiers.
- * </p>
- * <p>
- * <strong>NOTE:</strong> Some layouts (such as maven 1 "legacy") are not compatible with this query.
- * </p>
- *
- * @param reference the reference to work off of.
- * @return the list of ArtifactReferences for related artifacts, if
- * @throws ContentNotFoundException if the initial artifact reference does not exist within the repository.
- */
- List<ArtifactReference> getRelatedArtifacts( VersionedReference reference )
- throws ContentNotFoundException, LayoutException, ContentAccessException;
-
-
- /**
- * Returns all artifacts that belong to a given version
- * @param reference the version reference
- * @return the list of artifacts or a empty list
- */
- List<ArtifactReference> getArtifacts(VersionedReference reference) throws ContentNotFoundException, LayoutException, ContentAccessException;
-
-
-
-
- /**
- * <p>
- * Convenience method to get the repository (on disk) root directory.
- * </p>
- * <p>
- * Equivalent to calling <code>.getRepository().getLocation()</code>
- * </p>
- *
- * @return the repository (on disk) root directory.
- */
- String getRepoRoot();
+ boolean hasContent( ItemSelector selector );
/**
* Get the repository configuration associated with this
*/
ManagedRepository getRepository();
-
- /**
- * Determines if the artifact referenced exists in the repository.
- *
- * @param reference the artifact reference to check for.
- * @return true if the artifact referenced exists.
- */
- boolean hasContent( ArtifactReference reference ) throws ContentAccessException;
-
- /**
- * Determines if the version reference exists in the repository.
- *
- * @param reference the version reference to check for.
- * @return true if the version referenced exists.
- */
- boolean hasContent( VersionedReference reference ) throws ContentAccessException;
-
/**
* Set the repository configuration to associate with this
* repository content.
void setRepository( ManagedRepository repo );
/**
- * Given an {@link ArtifactReference}, return the file reference to the artifact.
- *
- * @param reference the artifact reference to use.
- * @return the relative path to the artifact.
+ * Returns the parent of the item.
+ * @param item the current item
+ * @return the parent item, or <code>null</code> if no such item exists
*/
- StorageAsset toFile( VersionedReference reference );
+ ContentItem getParent(ContentItem item);
/**
- * Given an {@link ArtifactReference}, return the file reference to the artifact.
- *
- * @param reference the artifact reference to use.
- * @return the relative path to the artifact.
+ * Returns the list of children items.
+ * @param item the current item
+ * @return the list of children, or a empty list, if no children exist
*/
- StorageAsset toFile( ArtifactReference reference );
+ List<? extends ContentItem> getChildren( ContentItem item);
/**
- * Given an {@link ArchivaArtifact}, return the file reference to the artifact.
+ * Tries to apply the given characteristic to the content item. If the layout does not allow this,
+ * it will throw a <code>LayoutException</code>.
*
- * @param reference the archiva artifact to use.
- * @return the relative path to the artifact.
+ * @param clazz the characteristic class to apply
+ * @param item the content item
+ * @param <T> The characteristic
+ * @return the applied characteristic
*/
- StorageAsset toFile( ArchivaArtifact reference );
+ <T extends ContentItem> T applyCharacteristic(Class<T> clazz, ContentItem item) throws LayoutException;
/**
- * Given a {@link ProjectReference}, return the path to the metadata for
- * the project.
- *
- * @param reference the reference to use.
- * @return the path to the metadata file, or null if no metadata is appropriate.
+ * Returns the given layout from the content.
+ * @param clazz The layout class
+ * @param <T> the layout class
+ * @return the specific layout
+ * @throws LayoutException if the repository does not support this layout type
*/
- String toMetadataPath( ProjectReference reference );
+ <T extends ManagedRepositoryContentLayout> T getLayout(Class<T> clazz) throws LayoutException;
/**
- * Given a {@link VersionedReference}, return the path to the metadata for
- * the specific version of the project.
- *
- * @param reference the reference to use.
- * @return the path to the metadata file, or null if no metadata is appropriate.
+ * Returns <code>true</code>, if the specific layout is supported by this content.
+ * @param clazz the layout class
+ * @return <code>true</code>, if the layout is supported, otherwise <code>false</code>
*/
- String toMetadataPath( VersionedReference reference );
-
- /**
- * Given an {@link ArchivaArtifact}, return the relative path to the artifact.
- *
- * @param reference the archiva artifact to use.
- * @return the relative path to the artifact.
- */
- String toPath( ArchivaArtifact reference );
-
-
+ <T extends ManagedRepositoryContentLayout> boolean supportsLayout(Class<T> clazz);
}
--- /dev/null
+package org.apache.archiva.repository;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ *
+ * Basic interface for content layouts.
+ * A content layout provides specific content item instances for the content structure like Namespace,
+ * Project, Version and their relationships.
+ *
+ * @author Martin Stockhammer <martin_s@apache.org>
+ */
+public interface ManagedRepositoryContentLayout
+{
+ ManagedRepositoryContent getGenericContent();
+}
import org.apache.archiva.model.ArtifactReference;
import org.apache.archiva.model.VersionedReference;
+import org.apache.archiva.repository.content.ContentItem;
import org.apache.archiva.repository.content.ItemSelector;
* @return a new instance
* @throws RepositoryException if the layout is not supported, or a error occured during initialization
*/
- ManagedRepositoryContent createManagedContent(ManagedRepository repository) throws RepositoryException;
+ ManagedRepositoryContent createManagedContent( ManagedRepository repository) throws RepositoryException;
/**
* Creates a generic content object.
String getLayout( String requestPath );
/**
- * Adjust the requestedPath to conform to the native layout of the provided {@link org.apache.archiva.repository.ManagedRepositoryContent}.
+ * Adjust the requestedPath to conform to the native layout of the provided {@link BaseRepositoryContentLayout}.
*
* @param requestPath the incoming requested path.
* @return the adjusted (to native) path.
* under the License.
*/
-import org.apache.archiva.repository.ItemConversionException;
import org.apache.archiva.repository.ManagedRepositoryContent;
-import org.apache.archiva.repository.UnsupportedConversionException;
+import org.apache.archiva.repository.ItemConversionException;
import org.apache.archiva.repository.storage.StorageAsset;
import java.util.Map;
}
@Override
- public void setContent(ManagedRepositoryContent content) {
+ public void setContent( ManagedRepositoryContent content) {
this.content = content;
}
import org.apache.archiva.repository.content.base.builder.ProjectOptBuilder;
import org.apache.archiva.repository.content.base.builder.ProjectWithIdBuilder;
import org.apache.archiva.repository.content.base.builder.WithAssetBuilder;
-import org.apache.archiva.repository.content.base.builder.WithNamespaceBuilder;
import org.apache.archiva.repository.content.base.builder.WithNamespaceObjectBuilder;
-import org.apache.archiva.repository.content.base.builder.WithProjectBuilder;
import org.apache.archiva.repository.storage.StorageAsset;
import org.apache.commons.lang3.StringUtils;
import org.apache.archiva.repository.content.Version;
import org.apache.archiva.repository.content.base.builder.VersionOptBuilder;
import org.apache.archiva.repository.content.base.builder.WithAssetBuilder;
-import org.apache.archiva.repository.content.base.builder.WithNamespaceBuilder;
import org.apache.archiva.repository.content.base.builder.WithProjectBuilder;
import org.apache.archiva.repository.content.base.builder.WithVersionBuilder;
import org.apache.archiva.repository.storage.StorageAsset;
*/
import org.apache.archiva.model.ArtifactReference;
-import org.apache.archiva.repository.ManagedRepository;
import org.apache.archiva.repository.ManagedRepositoryContent;
+import org.apache.archiva.repository.LayoutException;
+import org.apache.archiva.repository.ManagedRepository;
+import org.apache.archiva.repository.BaseRepositoryContentLayout;
import org.apache.archiva.repository.RepositoryContentFactory;
import org.apache.archiva.repository.RepositoryException;
import org.apache.archiva.repository.storage.StorageAsset;
public Path getArtifactPath( ManagedRepository repository, ArtifactReference artifactReference ) throws RepositoryException
{
final ManagedRepositoryContent content = repositoryContentFactory.getManagedRepositoryContent( repository );
- final String artifactPath = content.toPath( artifactReference );
+ final String artifactPath;
+ try
+ {
+ artifactPath = content.getLayout( BaseRepositoryContentLayout.class ).toPath( artifactReference );
+ }
+ catch ( LayoutException e )
+ {
+ throw new RepositoryException( "Could not convert to layout BaseRepositoryContentLayout" );
+ }
return Paths.get( repository.getLocation( ) ).resolve( artifactPath );
}
public StorageAsset getArtifactAsset( ManagedRepository repository, ArtifactReference artifactReference ) throws RepositoryException
{
final ManagedRepositoryContent content = repositoryContentFactory.getManagedRepositoryContent( repository );
- final String artifactPath = content.toPath( artifactReference );
+ final String artifactPath;
+ try
+ {
+ artifactPath = content.getLayout( BaseRepositoryContentLayout.class ).toPath( artifactReference );
+ }
+ catch ( LayoutException e )
+ {
+ throw new RepositoryException( "Could not convert to layout BaseRepositoryContentLayout" );
+ }
return repository.getAsset( artifactPath );
}
* under the License.
*/
+import org.apache.archiva.repository.ManagedRepositoryContent;
import org.apache.archiva.repository.ItemConversionException;
import org.apache.archiva.repository.LayoutException;
-import org.apache.archiva.repository.ManagedRepositoryContent;
import org.apache.archiva.repository.content.ContentItem;
import org.apache.archiva.repository.storage.StorageAsset;
import org.apache.commons.lang3.StringUtils;
import org.apache.archiva.components.registry.Registry;
import org.apache.archiva.components.registry.RegistryListener;
import org.apache.archiva.repository.ContentNotFoundException;
-import org.apache.archiva.repository.LayoutException;
import org.apache.archiva.repository.ManagedRepositoryContent;
+import org.apache.archiva.repository.LayoutException;
+import org.apache.archiva.repository.BaseRepositoryContentLayout;
import org.apache.archiva.repository.RemoteRepositoryContent;
import org.apache.archiva.repository.RepositoryRegistry;
import org.apache.archiva.repository.RepositoryType;
.withArtifactId( reference.getArtifactId( ) )
.withVersion( reference.getVersion( ) )
.build( );
- try(Stream<? extends Artifact> stream = managedRepository.newArtifactStream( selector )) {
+ try(Stream<? extends Artifact> stream = managedRepository.getLayout( BaseRepositoryContentLayout.class ).newArtifactStream( selector )) {
foundVersions = stream.map( a -> a.getArtifactVersion( ) )
.filter( StringUtils::isNotEmpty )
.collect( Collectors.toSet( ) );
StorageAsset metadataFile = managedRepository.getRepository().getAsset( toPath( reference ) );
ArchivaRepositoryMetadata existingMetadata = readMetadataFile( managedRepository, metadataFile );
+ BaseRepositoryContentLayout layout = managedRepository.getLayout( BaseRepositoryContentLayout.class );
long lastUpdated = getExistingLastUpdated( existingMetadata );
Set<String> allVersions = null;
try
{
- Project project = managedRepository.getProject( selector );
- allVersions = managedRepository.getVersions( project ).stream()
+ Project project = layout.getProject( selector );
+ allVersions = layout.getVersions( project ).stream()
.map( v -> v.getVersion() ).collect( Collectors.toSet());
}
catch ( org.apache.archiva.repository.ContentAccessException e )
* @throws IOException if the versioned reference is invalid (example: doesn't exist, or isn't a directory)
* @throws LayoutException
*/
- public ArtifactReference getFirstArtifact( ManagedRepositoryContent managedRepository,
+ public ArtifactReference getFirstArtifact( BaseRepositoryContentLayout managedRepository,
VersionedReference reference )
throws LayoutException, IOException
{
import org.apache.archiva.model.VersionedReference;
import org.apache.archiva.repository.ContentAccessException;
import org.apache.archiva.repository.ContentNotFoundException;
+import org.apache.archiva.repository.ManagedRepositoryContent;
import org.apache.archiva.repository.ItemDeleteStatus;
import org.apache.archiva.repository.LayoutException;
import org.apache.archiva.repository.ManagedRepository;
-import org.apache.archiva.repository.ManagedRepositoryContent;
+import org.apache.archiva.repository.BaseRepositoryContentLayout;
+import org.apache.archiva.repository.ManagedRepositoryContentLayout;
import org.apache.archiva.repository.content.Artifact;
import org.apache.archiva.repository.content.ContentItem;
import org.apache.archiva.repository.content.ItemNotFoundException;
* @author Martin Stockhammer <martin_s@apache.org>
*/
@Service("managedRepositoryContent#mock")
-public class ManagedRepositoryContentMock implements ManagedRepositoryContent
+public class ManagedRepositoryContentMock implements BaseRepositoryContentLayout
{
private ManagedRepository repository;
return null;
}
+ @Override
+ public <T extends ManagedRepositoryContentLayout> T getLayout( Class<T> clazz ) throws LayoutException
+ {
+ return null;
+ }
+
+ @Override
+ public <T extends ManagedRepositoryContentLayout> boolean supportsLayout( Class<T> clazz )
+ {
+ return false;
+ }
+
@Override
public void addArtifact( Path sourceFile, Artifact destination ) throws IllegalArgumentException
{
}
+ @Override
+ public String toPath( ContentItem item )
+ {
+ return null;
+ }
+
@Override
public String getId( )
{
return null;
}
+ @Override
+ public ManagedRepositoryContent getGenericContent( )
+ {
+ return null;
+ }
}
*/
import org.apache.archiva.repository.ManagedRepository;
-import org.apache.archiva.repository.ManagedRepositoryContent;
+import org.apache.archiva.repository.BaseRepositoryContentLayout;
import org.apache.archiva.repository.RemoteRepository;
import org.apache.archiva.repository.RemoteRepositoryContent;
import org.apache.archiva.repository.Repository;
}
@Override
- public ManagedRepositoryContent createManagedContent(ManagedRepository repository) throws RepositoryException {
+ public BaseRepositoryContentLayout createManagedContent( ManagedRepository repository) throws RepositoryException {
return new ManagedRepositoryContentMock();
}
/**
* @author Martin Stockhammer <martin_s@apache.org>
*/
-public class ManagedRepositoryContentMock implements ManagedRepositoryContent
+public class ManagedRepositoryContentMock implements BaseRepositoryContentLayout
{
private static final String PATH_SEPARATOR = "/";
private static final String GROUP_SEPARATOR = ".";
return null;
}
+ @Override
+ public <T extends ManagedRepositoryContentLayout> T getLayout( Class<T> clazz ) throws LayoutException
+ {
+ return null;
+ }
+
+ @Override
+ public <T extends ManagedRepositoryContentLayout> boolean supportsLayout( Class<T> clazz )
+ {
+ return false;
+ }
+
@Override
public void addArtifact( Path sourceFile, Artifact destination ) throws IllegalArgumentException
{
}
+ @Override
+ public String toPath( ContentItem item )
+ {
+ return null;
+ }
+
@Override
public String getId( )
{
return null;
}
+ @Override
+ public ManagedRepositoryContent getGenericContent( )
+ {
+ return null;
+ }
}
import org.apache.archiva.policies.ReleasesPolicy;
import org.apache.archiva.policies.SnapshotsPolicy;
import org.apache.archiva.policies.urlcache.UrlFailureCache;
+import org.apache.archiva.repository.BaseRepositoryContentLayout;
import org.apache.archiva.repository.storage.StorageAsset;
import org.apache.maven.wagon.ResourceDoesNotExistException;
import org.easymock.EasyMock;
/**
* CacheFailuresTransferTest
- *
- *
*/
public class CacheFailuresTransferTest
extends AbstractProxyTestCase
UrlFailureCache urlFailureCache;
@Test
- public void testGetWithCacheFailuresOn()
+ public void testGetWithCacheFailuresOn( )
throws Exception
{
String path = "org/apache/maven/test/get-in-second-proxy/1.0/get-in-second-proxy-1.0.jar";
assertNotExistsInManagedDefaultRepo( expectedFile );
- ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
+ BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
+ ArtifactReference artifact = layout.toArtifactReference( path );
// Configure Repository (usually done within archiva.xml configuration)
saveRemoteRepositoryConfig( "badproxied1", "Bad Proxied 1", "http://bad.machine.com/repo/", "default" );
// Configure Connector (usually done within archiva.xml configuration)
saveConnector( ID_DEFAULT_MANAGED, "badproxied1", ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS,
- SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.YES, false );
+ SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.YES, false );
saveConnector( ID_DEFAULT_MANAGED, "badproxied2", ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS,
- SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.YES, false );
+ SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.YES, false );
- wagonMock.get( EasyMock.eq( path ), EasyMock.anyObject( File.class ));
+ wagonMock.get( EasyMock.eq( path ), EasyMock.anyObject( File.class ) );
- EasyMock.expectLastCall().andThrow( new ResourceDoesNotExistException( "resource does not exist." ) ).times( 2 );
+ EasyMock.expectLastCall( ).andThrow( new ResourceDoesNotExistException( "resource does not exist." ) ).times( 2 );
- wagonMockControl.replay();
+ wagonMockControl.replay( );
//noinspection UnusedAssignment
- StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository(), artifact );
+ StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository( ), artifact );
- wagonMockControl.verify();
+ wagonMockControl.verify( );
// Second attempt to download same artifact use cache
- wagonMockControl.reset();
- wagonMockControl.replay();
- downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository(), artifact );
- wagonMockControl.verify();
+ wagonMockControl.reset( );
+ wagonMockControl.replay( );
+ downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository( ), artifact );
+ wagonMockControl.verify( );
- assertNotDownloaded( downloadedFile);
+ assertNotDownloaded( downloadedFile );
assertNoTempFiles( expectedFile );
}
@Test
- public void testGetWithCacheFailuresOff()
+ public void testGetWithCacheFailuresOff( )
throws Exception
{
String path = "org/apache/maven/test/get-in-second-proxy/1.0/get-in-second-proxy-1.0.jar";
assertNotExistsInManagedDefaultRepo( expectedFile );
- ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
+ BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
+ ArtifactReference artifact = layout.toArtifactReference( path );
// Configure Repository (usually done within archiva.xml configuration)
saveRemoteRepositoryConfig( "badproxied1", "Bad Proxied 1", "http://bad.machine.com/repo/", "default" );
// Configure Connector (usually done within archiva.xml configuration)
saveConnector( ID_DEFAULT_MANAGED, "badproxied1", ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS,
- SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
+ SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
saveConnector( ID_DEFAULT_MANAGED, "badproxied2", ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS,
- SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
+ SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
- wagonMock.get( EasyMock.eq( path ), EasyMock.anyObject( File.class ));
- EasyMock.expectLastCall().andThrow( new ResourceDoesNotExistException( "resource does not exist." ) ).times( 2 );
+ wagonMock.get( EasyMock.eq( path ), EasyMock.anyObject( File.class ) );
+ EasyMock.expectLastCall( ).andThrow( new ResourceDoesNotExistException( "resource does not exist." ) ).times( 2 );
- wagonMockControl.replay();
+ wagonMockControl.replay( );
- StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository(), artifact );
+ StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository( ), artifact );
- wagonMockControl.verify();
+ wagonMockControl.verify( );
// Second attempt to download same artifact DOES NOT use cache
- wagonMockControl.reset();
+ wagonMockControl.reset( );
- wagonMock.get( EasyMock.eq( path ), EasyMock.anyObject( File.class ));
- EasyMock.expectLastCall().andThrow( new ResourceDoesNotExistException( "resource does not exist." ) ).times( 2 );
+ wagonMock.get( EasyMock.eq( path ), EasyMock.anyObject( File.class ) );
+ EasyMock.expectLastCall( ).andThrow( new ResourceDoesNotExistException( "resource does not exist." ) ).times( 2 );
- wagonMockControl.replay();
+ wagonMockControl.replay( );
- downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository(), artifact );
+ downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository( ), artifact );
- wagonMockControl.verify();
+ wagonMockControl.verify( );
- assertNotDownloaded( downloadedFile);
+ assertNotDownloaded( downloadedFile );
assertNoTempFiles( expectedFile );
}
@Test
- public void testGetWhenInBothProxiedButFirstCacheFailure()
+ public void testGetWhenInBothProxiedButFirstCacheFailure( )
throws Exception
{
String path = "org/apache/maven/test/get-in-second-proxy/1.0/get-in-second-proxy-1.0.jar";
setupTestableManagedRepository( path );
- Path expectedFile = managedDefaultDir.resolve(path );
- ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
+ Path expectedFile = managedDefaultDir.resolve( path );
+ BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
+ ArtifactReference artifact = layout.toArtifactReference( path );
- Files.deleteIfExists(expectedFile);
- assertFalse( Files.exists(expectedFile) );
+ Files.deleteIfExists( expectedFile );
+ assertFalse( Files.exists( expectedFile ) );
String url = PathUtil.toUrl( REPOPATH_PROXIED1 + "/" + path );
// Intentionally set failure on url in proxied1 (for test)
- UrlFailureCache failurlCache = lookupUrlFailureCache();
+ UrlFailureCache failurlCache = lookupUrlFailureCache( );
failurlCache.cacheFailure( url );
// Configure Connector (usually done within archiva.xml configuration)
saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS,
- SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.YES, false );
+ SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.YES, false );
saveConnector( ID_DEFAULT_MANAGED, "proxied2", ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS,
- SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.YES, false );
+ SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.YES, false );
- StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository(), artifact );
+ StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository( ), artifact );
// Validate that file actually came from proxied2 (as intended).
Path proxied2File = Paths.get( REPOPATH_PROXIED2, path );
- assertNotNull(downloadedFile);
- assertFileEquals( expectedFile, downloadedFile.getFilePath(), proxied2File );
+ assertNotNull( downloadedFile );
+ assertFileEquals( expectedFile, downloadedFile.getFilePath( ), proxied2File );
assertNoTempFiles( expectedFile );
}
- protected UrlFailureCache lookupUrlFailureCache()
+ protected UrlFailureCache lookupUrlFailureCache( )
throws Exception
{
assertNotNull( "URL Failure Cache cannot be null.", urlFailureCache );
import org.apache.archiva.policies.ChecksumPolicy;
import org.apache.archiva.policies.ReleasesPolicy;
import org.apache.archiva.policies.SnapshotsPolicy;
+import org.apache.archiva.repository.BaseRepositoryContentLayout;
import org.apache.archiva.repository.storage.StorageAsset;
import org.apache.maven.wagon.ResourceDoesNotExistException;
import org.easymock.EasyMock;
/**
* ChecksumTransferTest
- *
- *
*/
public class ChecksumTransferTest
extends AbstractProxyTestCase
{
@Test
- public void testGetChecksumWhenConnectorIsDisabled()
+ public void testGetChecksumWhenConnectorIsDisabled( )
throws Exception
{
String path = "org/apache/maven/test/get-checksum-both-right/1.0/get-checksum-both-right-1.0.jar";
setupTestableManagedRepository( path );
Path expectedFile = managedDefaultDir.resolve( path );
- ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
- org.apache.archiva.common.utils.FileUtils.deleteDirectory( expectedFile.getParent() );
- assertFalse( Files.exists(expectedFile) );
+ BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
+ ArtifactReference artifact = layout.toArtifactReference( path );
+
+ org.apache.archiva.common.utils.FileUtils.deleteDirectory( expectedFile.getParent( ) );
+ assertFalse( Files.exists( expectedFile ) );
// Configure Connector (usually done within archiva.xml configuration)
saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.IGNORE, ReleasesPolicy.ALWAYS,
- SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, true );
+ SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, true );
- StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository(), artifact );
+ StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository( ), artifact );
assertNull( downloadedFile );
}
@Test
- public void testGetChecksumBothCorrect()
+ public void testGetChecksumBothCorrect( )
throws Exception
{
String path = "org/apache/maven/test/get-checksum-both-right/1.0/get-checksum-both-right-1.0.jar";
setupTestableManagedRepository( path );
Path expectedFile = managedDefaultDir.resolve( path );
- ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
+ BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
+ ArtifactReference artifact = layout.toArtifactReference( path );
- org.apache.archiva.common.utils.FileUtils.deleteDirectory( expectedFile.getParent() );
- assertFalse( Files.exists(expectedFile) );
+ org.apache.archiva.common.utils.FileUtils.deleteDirectory( expectedFile.getParent( ) );
+ assertFalse( Files.exists( expectedFile ) );
// Configure Connector (usually done within archiva.xml configuration)
saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.IGNORE, ReleasesPolicy.ALWAYS,
- SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
+ SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
- StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository(), artifact );
+ StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository( ), artifact );
Path proxied1File = Paths.get( REPOPATH_PROXIED1, path );
- assertFileEquals( expectedFile, downloadedFile.getFilePath(), proxied1File );
+ assertFileEquals( expectedFile, downloadedFile.getFilePath( ), proxied1File );
assertNoTempFiles( expectedFile );
assertChecksums( expectedFile, "066d76e459f7782c312c31e8a11b3c0f1e3e43a7 *get-checksum-both-right-1.0.jar",
- "e58f30c6a150a2e843552438d18e15cb *get-checksum-both-right-1.0.jar" );
+ "e58f30c6a150a2e843552438d18e15cb *get-checksum-both-right-1.0.jar" );
}
@Test
- public void testGetChecksumCorrectSha1NoMd5()
+ public void testGetChecksumCorrectSha1NoMd5( )
throws Exception
{
String path = "org/apache/maven/test/get-checksum-sha1-only/1.0/get-checksum-sha1-only-1.0.jar";
setupTestableManagedRepository( path );
Path expectedFile = managedDefaultDir.resolve( path );
- ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
+ BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
+ ArtifactReference artifact = layout.toArtifactReference( path );
- FileUtils.deleteDirectory( expectedFile.getParent() );
- assertFalse( Files.exists(expectedFile) );
+ FileUtils.deleteDirectory( expectedFile.getParent( ) );
+ assertFalse( Files.exists( expectedFile ) );
// Configure Connector (usually done within archiva.xml configuration)
saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.IGNORE, ReleasesPolicy.ALWAYS,
- SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
+ SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
- StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository(), artifact );
+ StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository( ), artifact );
Path proxied1File = Paths.get( REPOPATH_PROXIED1, path );
- assertFileEquals( expectedFile, downloadedFile.getFilePath(), proxied1File );
+ assertFileEquals( expectedFile, downloadedFile.getFilePath( ), proxied1File );
assertNoTempFiles( expectedFile );
assertChecksums( expectedFile, "748a3a013bf5eacf2bbb40a2ac7d37889b728837 *get-checksum-sha1-only-1.0.jar",
- null );
+ null );
}
@Test
- public void testGetChecksumNoSha1CorrectMd5()
+ public void testGetChecksumNoSha1CorrectMd5( )
throws Exception
{
String path = "org/apache/maven/test/get-checksum-md5-only/1.0/get-checksum-md5-only-1.0.jar";
setupTestableManagedRepository( path );
Path expectedFile = managedDefaultDir.resolve( path );
- ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
+ BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
+ ArtifactReference artifact = layout.toArtifactReference( path );
- FileUtils.deleteDirectory( expectedFile.getParent() );
- assertFalse( Files.exists(expectedFile) );
+ FileUtils.deleteDirectory( expectedFile.getParent( ) );
+ assertFalse( Files.exists( expectedFile ) );
// Configure Connector (usually done within archiva.xml configuration)
saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.IGNORE, ReleasesPolicy.ALWAYS,
- SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
+ SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
- StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository(), artifact );
+ StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository( ), artifact );
Path proxied1File = Paths.get( REPOPATH_PROXIED1, path );
- assertFileEquals( expectedFile, downloadedFile.getFilePath(), proxied1File );
+ assertFileEquals( expectedFile, downloadedFile.getFilePath( ), proxied1File );
assertNoTempFiles( expectedFile );
assertChecksums( expectedFile, null, "f3af5201bf8da801da37db8842846e1c *get-checksum-md5-only-1.0.jar" );
}
@Test
- public void testGetWithNoChecksumsUsingIgnoredSetting()
+ public void testGetWithNoChecksumsUsingIgnoredSetting( )
throws Exception
{
String path = "org/apache/maven/test/get-default-layout/1.0/get-default-layout-1.0.jar";
setupTestableManagedRepository( path );
Path expectedFile = managedDefaultDir.resolve( path );
- ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
+ BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
+ ArtifactReference artifact = layout.toArtifactReference( path );
- FileUtils.deleteDirectory( expectedFile.getParent() );
- assertFalse( Files.exists(expectedFile) );
+ FileUtils.deleteDirectory( expectedFile.getParent( ) );
+ assertFalse( Files.exists( expectedFile ) );
// Configure Connector (usually done within archiva.xml configuration)
saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.IGNORE, ReleasesPolicy.ALWAYS,
- SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
+ SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
- StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository(), artifact );
+ StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository( ), artifact );
Path proxied1File = Paths.get( REPOPATH_PROXIED1, path );
- assertFileEquals( expectedFile, downloadedFile.getFilePath(), proxied1File );
+ assertFileEquals( expectedFile, downloadedFile.getFilePath( ), proxied1File );
assertNoTempFiles( expectedFile );
assertChecksums( expectedFile, null, null );
}
@Test
- public void testGetChecksumBadSha1BadMd5IgnoredSetting()
+ public void testGetChecksumBadSha1BadMd5IgnoredSetting( )
throws Exception
{
String path = "org/apache/maven/test/get-checksum-both-bad/1.0/get-checksum-both-bad-1.0.jar";
setupTestableManagedRepository( path );
Path expectedFile = managedDefaultDir.resolve( path );
- ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
+ BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
+ ArtifactReference artifact = layout.toArtifactReference( path );
- FileUtils.deleteDirectory( expectedFile.getParent() );
- assertFalse( Files.exists(expectedFile) );
+ FileUtils.deleteDirectory( expectedFile.getParent( ) );
+ assertFalse( Files.exists( expectedFile ) );
// Configure Connector (usually done within archiva.xml configuration)
saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.IGNORE, ReleasesPolicy.ALWAYS,
- SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
+ SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
- StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository(), artifact );
+ StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository( ), artifact );
Path proxied1File = Paths.get( REPOPATH_PROXIED1, path );
- assertFileEquals( expectedFile, downloadedFile.getFilePath(), proxied1File );
+ assertFileEquals( expectedFile, downloadedFile.getFilePath( ), proxied1File );
assertNoTempFiles( expectedFile );
assertChecksums( expectedFile, "invalid checksum file", "invalid checksum file" );
}
@Test
- public void testGetChecksumBadSha1BadMd5FailSetting()
+ public void testGetChecksumBadSha1BadMd5FailSetting( )
throws Exception
{
String path = "org/apache/maven/test/get-checksum-both-bad/1.0/get-checksum-both-bad-1.0.jar";
setupTestableManagedRepository( path );
Path expectedFile = managedDefaultDir.resolve( path );
- ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
+ BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
+ ArtifactReference artifact = layout.toArtifactReference( path );
- FileUtils.deleteDirectory( expectedFile.getParent() );
- assertFalse( Files.exists(expectedFile) );
+ FileUtils.deleteDirectory( expectedFile.getParent( ) );
+ assertFalse( Files.exists( expectedFile ) );
// Configure Connector (usually done within archiva.xml configuration)
saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.FAIL, ReleasesPolicy.ALWAYS,
- SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
+ SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
- StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository(), artifact );
+ StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository( ), artifact );
assertNotDownloaded( downloadedFile );
assertChecksums( expectedFile, null, null );
}
@Test
- public void testGetChecksumBadSha1BadMd5FixSetting()
+ public void testGetChecksumBadSha1BadMd5FixSetting( )
throws Exception
{
String path = "org/apache/maven/test/get-checksum-both-bad/1.0/get-checksum-both-bad-1.0.jar";
setupTestableManagedRepository( path );
Path expectedFile = managedDefaultDir.resolve( path );
- ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
+ BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
+ ArtifactReference artifact = layout.toArtifactReference( path );
- FileUtils.deleteDirectory( expectedFile.getParent() );
- assertFalse( Files.exists(expectedFile) );
+ FileUtils.deleteDirectory( expectedFile.getParent( ) );
+ assertFalse( Files.exists( expectedFile ) );
// Configure Connector (usually done within archiva.xml configuration)
saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS,
- SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
+ SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
- StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository(), artifact );
+ StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository( ), artifact );
Path proxied1File = Paths.get( REPOPATH_PROXIED1, path );
- assertFileEquals( expectedFile, downloadedFile.getFilePath(), proxied1File );
+ assertFileEquals( expectedFile, downloadedFile.getFilePath( ), proxied1File );
assertNoTempFiles( expectedFile );
assertChecksums( expectedFile, "4ec20a12dc91557330bd0b39d1805be5e329ae56 get-checksum-both-bad-1.0.jar",
- "a292491a35925465e693a44809a078b5 get-checksum-both-bad-1.0.jar" );
+ "a292491a35925465e693a44809a078b5 get-checksum-both-bad-1.0.jar" );
}
@Test
- public void testGetChecksumCorrectSha1BadMd5UsingFailSetting()
+ public void testGetChecksumCorrectSha1BadMd5UsingFailSetting( )
throws Exception
{
String path = "org/apache/maven/test/get-checksum-sha1-bad-md5/1.0/get-checksum-sha1-bad-md5-1.0.jar";
setupTestableManagedRepository( path );
- Path expectedFile = managedDefaultDir.resolve(path);
- ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
+ Path expectedFile = managedDefaultDir.resolve( path );
+ BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
+ ArtifactReference artifact = layout.toArtifactReference( path );
- FileUtils.deleteDirectory( expectedFile.getParent() );
- assertFalse( Files.exists(expectedFile) );
+ FileUtils.deleteDirectory( expectedFile.getParent( ) );
+ assertFalse( Files.exists( expectedFile ) );
// Configure Connector (usually done within archiva.xml configuration)
saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.FAIL, ReleasesPolicy.ALWAYS,
- SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
+ SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
- StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository(), artifact );
+ StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository( ), artifact );
assertNotDownloaded( downloadedFile );
assertChecksums( expectedFile, null, null );
}
@Test
- public void testGetChecksumNoSha1CorrectMd5UsingFailSetting()
+ public void testGetChecksumNoSha1CorrectMd5UsingFailSetting( )
throws Exception
{
String path = "org/apache/maven/test/get-checksum-md5-only/1.0/get-checksum-md5-only-1.0.jar";
setupTestableManagedRepository( path );
- Path expectedFile = managedDefaultDir.resolve(path);
- ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
+ Path expectedFile = managedDefaultDir.resolve( path );
+ BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
+ ArtifactReference artifact = layout.toArtifactReference( path );
- FileUtils.deleteDirectory( expectedFile.getParent() );
- assertFalse( Files.exists(expectedFile) );
+ FileUtils.deleteDirectory( expectedFile.getParent( ) );
+ assertFalse( Files.exists( expectedFile ) );
// Configure Connector (usually done within archiva.xml configuration)
saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.FAIL, ReleasesPolicy.ALWAYS,
- SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
+ SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
- StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository(), artifact );
+ StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository( ), artifact );
// This is a success situation. No SHA1 with a Good MD5.
- Path proxied1File = Paths.get(REPOPATH_PROXIED1, path);
- assertFileEquals( expectedFile, downloadedFile.getFilePath(), proxied1File );
+ Path proxied1File = Paths.get( REPOPATH_PROXIED1, path );
+ assertFileEquals( expectedFile, downloadedFile.getFilePath( ), proxied1File );
assertNoTempFiles( expectedFile );
assertChecksums( expectedFile, null, "f3af5201bf8da801da37db8842846e1c *get-checksum-md5-only-1.0.jar" );
}
@Test
- public void testGetWithNoChecksumsUsingFailSetting()
+ public void testGetWithNoChecksumsUsingFailSetting( )
throws Exception
{
String path = "org/apache/maven/test/get-default-layout/1.0/get-default-layout-1.0.jar";
setupTestableManagedRepository( path );
- Path expectedFile = managedDefaultDir.resolve(path);
- ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
+ Path expectedFile = managedDefaultDir.resolve( path );
+ BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
+ ArtifactReference artifact = layout.toArtifactReference( path );
- FileUtils.deleteDirectory( expectedFile.getParent() );
- assertFalse( Files.exists(expectedFile) );
+ FileUtils.deleteDirectory( expectedFile.getParent( ) );
+ assertFalse( Files.exists( expectedFile ) );
// Configure Connector (usually done within archiva.xml configuration)
saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.FAIL, ReleasesPolicy.ALWAYS,
- SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
+ SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
- StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository(), artifact );
+ StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository( ), artifact );
assertNotDownloaded( downloadedFile );
assertChecksums( expectedFile, null, null );
}
@Test
- public void testGetChecksumCorrectSha1BadMd5UsingIgnoredSetting()
+ public void testGetChecksumCorrectSha1BadMd5UsingIgnoredSetting( )
throws Exception
{
String path = "org/apache/maven/test/get-checksum-sha1-bad-md5/1.0/get-checksum-sha1-bad-md5-1.0.jar";
setupTestableManagedRepository( path );
- Path expectedFile = managedDefaultDir.resolve(path);
- ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
+ Path expectedFile = managedDefaultDir.resolve( path );
+ BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
+ ArtifactReference artifact = layout.toArtifactReference( path );
- FileUtils.deleteDirectory( expectedFile.getParent() );
- assertFalse( Files.exists(expectedFile) );
+ FileUtils.deleteDirectory( expectedFile.getParent( ) );
+ assertFalse( Files.exists( expectedFile ) );
// Configure Connector (usually done within archiva.xml configuration)
saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.IGNORE, ReleasesPolicy.ALWAYS,
- SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
+ SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
- StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository(), artifact );
+ StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository( ), artifact );
- Path proxied1File = Paths.get(REPOPATH_PROXIED1, path);
- assertFileEquals( expectedFile, downloadedFile.getFilePath(), proxied1File );
+ Path proxied1File = Paths.get( REPOPATH_PROXIED1, path );
+ assertFileEquals( expectedFile, downloadedFile.getFilePath( ), proxied1File );
assertNoTempFiles( expectedFile );
assertChecksums( expectedFile, "3dd1a3a57b807d3ef3fbc6013d926c891cbb8670 *get-checksum-sha1-bad-md5-1.0.jar",
- "invalid checksum file" );
+ "invalid checksum file" );
}
@Test
- public void testGetChecksumCorrectSha1BadMd5UsingFixSetting()
+ public void testGetChecksumCorrectSha1BadMd5UsingFixSetting( )
throws Exception
{
String path = "org/apache/maven/test/get-checksum-sha1-bad-md5/1.0/get-checksum-sha1-bad-md5-1.0.jar";
setupTestableManagedRepository( path );
- Path expectedFile = managedDefaultDir.resolve(path);
- ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
+ Path expectedFile = managedDefaultDir.resolve( path );
+ BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
+ ArtifactReference artifact = layout.toArtifactReference( path );
- FileUtils.deleteDirectory( expectedFile.getParent() );
- assertFalse( Files.exists(expectedFile) );
+ FileUtils.deleteDirectory( expectedFile.getParent( ) );
+ assertFalse( Files.exists( expectedFile ) );
// Configure Connector (usually done within archiva.xml configuration)
saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS,
- SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
+ SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
- StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository(), artifact );
+ StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository( ), artifact );
- Path proxied1File = Paths.get(REPOPATH_PROXIED1, path);
- assertFileEquals( expectedFile, downloadedFile.getFilePath(), proxied1File );
+ Path proxied1File = Paths.get( REPOPATH_PROXIED1, path );
+ assertFileEquals( expectedFile, downloadedFile.getFilePath( ), proxied1File );
assertNoTempFiles( expectedFile );
assertChecksums( expectedFile, "3dd1a3a57b807d3ef3fbc6013d926c891cbb8670 *get-checksum-sha1-bad-md5-1.0.jar",
- "c35f3b76268b73a4ba617f6f275c49ab get-checksum-sha1-bad-md5-1.0.jar" );
+ "c35f3b76268b73a4ba617f6f275c49ab get-checksum-sha1-bad-md5-1.0.jar" );
}
@Test
- public void testGetChecksumNoSha1CorrectMd5UsingFixSetting()
+ public void testGetChecksumNoSha1CorrectMd5UsingFixSetting( )
throws Exception
{
String path = "org/apache/maven/test/get-checksum-md5-only/1.0/get-checksum-md5-only-1.0.jar";
setupTestableManagedRepository( path );
- Path expectedFile = managedDefaultDir.resolve(path);
- ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
+ Path expectedFile = managedDefaultDir.resolve( path );
+ BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
+ ArtifactReference artifact = layout.toArtifactReference( path );
- FileUtils.deleteDirectory( expectedFile.getParent() );
- assertFalse( Files.exists(expectedFile) );
+ FileUtils.deleteDirectory( expectedFile.getParent( ) );
+ assertFalse( Files.exists( expectedFile ) );
// Configure Connector (usually done within archiva.xml configuration)
saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS,
- SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
+ SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
- StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository(), artifact );
+ StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository( ), artifact );
- Path proxied1File = Paths.get(REPOPATH_PROXIED1, path);
- assertFileEquals( expectedFile, downloadedFile.getFilePath(), proxied1File );
+ Path proxied1File = Paths.get( REPOPATH_PROXIED1, path );
+ assertFileEquals( expectedFile, downloadedFile.getFilePath( ), proxied1File );
assertNoTempFiles( expectedFile );
assertChecksums( expectedFile, "71f7dc3f72053a3f2d9fdd6fef9db055ef957ffb get-checksum-md5-only-1.0.jar",
- "f3af5201bf8da801da37db8842846e1c *get-checksum-md5-only-1.0.jar" );
+ "f3af5201bf8da801da37db8842846e1c *get-checksum-md5-only-1.0.jar" );
}
@Test
- public void testGetWithNoChecksumsUsingFixSetting()
+ public void testGetWithNoChecksumsUsingFixSetting( )
throws Exception
{
String path = "org/apache/maven/test/get-default-layout/1.0/get-default-layout-1.0.jar";
setupTestableManagedRepository( path );
- Path expectedFile = managedDefaultDir.resolve(path);
- ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
+ Path expectedFile = managedDefaultDir.resolve( path );
+ BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
+ ArtifactReference artifact = layout.toArtifactReference( path );
- FileUtils.deleteDirectory( expectedFile.getParent() );
- assertFalse( Files.exists(expectedFile) );
+ FileUtils.deleteDirectory( expectedFile.getParent( ) );
+ assertFalse( Files.exists( expectedFile ) );
// Configure Connector (usually done within archiva.xml configuration)
saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS,
- SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
+ SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
- StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository(), artifact );
+ StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository( ), artifact );
- Path proxied1File = Paths.get(REPOPATH_PROXIED1, path);
- assertFileEquals( expectedFile, downloadedFile.getFilePath(), proxied1File );
+ Path proxied1File = Paths.get( REPOPATH_PROXIED1, path );
+ assertFileEquals( expectedFile, downloadedFile.getFilePath( ), proxied1File );
assertNoTempFiles( expectedFile );
assertChecksums( expectedFile, "1f12821c5e43e1a0b76b9564a6ddb0548ccb9486 get-default-layout-1.0.jar",
- "3f7341545f21226b6f49a3c2704cb9be get-default-layout-1.0.jar" );
+ "3f7341545f21226b6f49a3c2704cb9be get-default-layout-1.0.jar" );
}
@Test
- public void testGetChecksumNotFoundOnRemote()
+ public void testGetChecksumNotFoundOnRemote( )
throws Exception
{
String path = "org/apache/maven/test/get-checksum-sha1-only/1.0/get-checksum-sha1-only-1.0.jar";
setupTestableManagedRepository( path );
Path expectedFile = managedDefaultDir.resolve( path );
- ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
+ BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
+ ArtifactReference artifact = layout.toArtifactReference( path );
- FileUtils.deleteDirectory( expectedFile.getParent() );
- assertFalse( Files.exists(expectedFile.getParent()) );
- assertFalse( Files.exists(expectedFile) );
+ FileUtils.deleteDirectory( expectedFile.getParent( ) );
+ assertFalse( Files.exists( expectedFile.getParent( ) ) );
+ assertFalse( Files.exists( expectedFile ) );
saveRemoteRepositoryConfig( "badproxied", "Bad Proxied", "http://bad.machine.com/repo/", "default" );
// Configure Connector (usually done within archiva.xml configuration)
saveConnector( ID_DEFAULT_MANAGED, "badproxied", ChecksumPolicy.IGNORE, ReleasesPolicy.ALWAYS,
- SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
+ SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
- wagonMock.get( EasyMock.eq( path ), EasyMock.anyObject( File.class ));
- EasyMock.expectLastCall().once();
+ wagonMock.get( EasyMock.eq( path ), EasyMock.anyObject( File.class ) );
+ EasyMock.expectLastCall( ).once( );
- wagonMock.get( EasyMock.eq( path + ".sha1" ), EasyMock.anyObject( File.class ));
- EasyMock.expectLastCall().once();
+ wagonMock.get( EasyMock.eq( path + ".sha1" ), EasyMock.anyObject( File.class ) );
+ EasyMock.expectLastCall( ).once( );
- wagonMock.get( EasyMock.eq( path + ".md5" ), EasyMock.anyObject( File.class ));
- EasyMock.expectLastCall().andThrow( new ResourceDoesNotExistException( "Resource does not exist." ) ).once();
+ wagonMock.get( EasyMock.eq( path + ".md5" ), EasyMock.anyObject( File.class ) );
+ EasyMock.expectLastCall( ).andThrow( new ResourceDoesNotExistException( "Resource does not exist." ) ).once( );
- wagonMockControl.replay();
+ wagonMockControl.replay( );
- StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository(), artifact );
+ StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository( ), artifact );
- wagonMockControl.verify();
+ wagonMockControl.verify( );
// Do what the mock doesn't do.
- Path proxyPath = Paths.get( REPOPATH_PROXIED1, path ).toAbsolutePath();
- Path localPath = managedDefaultDir.resolve( path ).toAbsolutePath();
- Files.copy( proxyPath, localPath, StandardCopyOption.REPLACE_EXISTING);
- Files.copy( proxyPath.resolveSibling( proxyPath.getFileName() + ".sha1" ),
- localPath.resolveSibling( localPath.getFileName() + ".sha1" ), StandardCopyOption.REPLACE_EXISTING );
+ Path proxyPath = Paths.get( REPOPATH_PROXIED1, path ).toAbsolutePath( );
+ Path localPath = managedDefaultDir.resolve( path ).toAbsolutePath( );
+ Files.copy( proxyPath, localPath, StandardCopyOption.REPLACE_EXISTING );
+ Files.copy( proxyPath.resolveSibling( proxyPath.getFileName( ) + ".sha1" ),
+ localPath.resolveSibling( localPath.getFileName( ) + ".sha1" ), StandardCopyOption.REPLACE_EXISTING );
// Test results.
Path proxied1File = Paths.get( REPOPATH_PROXIED1, path );
- assertFileEquals( expectedFile, downloadedFile.getFilePath(), proxied1File );
+ assertFileEquals( expectedFile, downloadedFile.getFilePath( ), proxied1File );
assertNoTempFiles( expectedFile );
assertChecksums( expectedFile, "748a3a013bf5eacf2bbb40a2ac7d37889b728837 *get-checksum-sha1-only-1.0.jar",
- null );
+ null );
}
@Test
- public void testGetAlwaysBadChecksumPresentLocallyAbsentRemoteUsingIgnoredSetting()
+ public void testGetAlwaysBadChecksumPresentLocallyAbsentRemoteUsingIgnoredSetting( )
throws Exception
{
String path = "org/apache/maven/test/get-bad-local-checksum/1.0/get-bad-local-checksum-1.0.jar";
setManagedOlderThanRemote( expectedFile, remoteFile );
- ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
+ BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
+ ArtifactReference artifact = layout.toArtifactReference( path );
// Configure Connector (usually done within archiva.xml configuration)
saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.IGNORE, ReleasesPolicy.ALWAYS,
- SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
+ SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
- StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository(), artifact );
+ StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository( ), artifact );
Path proxied1File = Paths.get( REPOPATH_PROXIED1, path );
- assertFileEquals( expectedFile, downloadedFile.getFilePath(), proxied1File );
+ assertFileEquals( expectedFile, downloadedFile.getFilePath( ), proxied1File );
assertNoTempFiles( expectedFile );
// There are no hashcodes on the proxy side to download, hence the local ones should remain invalid.
assertChecksums( expectedFile, "invalid checksum file", "invalid checksum file" );
}
@Test
- public void testGetAlwaysBadChecksumPresentLocallyAbsentRemoteUsingFailSetting()
+ public void testGetAlwaysBadChecksumPresentLocallyAbsentRemoteUsingFailSetting( )
throws Exception
{
String path = "org/apache/maven/test/get-bad-local-checksum/1.0/get-bad-local-checksum-1.0.jar";
setManagedOlderThanRemote( expectedFile, remoteFile );
- ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
+ BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
+ ArtifactReference artifact = layout.toArtifactReference( path );
// Configure Connector (usually done within archiva.xml configuration)
saveConnector( ID_DEFAULT_MANAGED, ID_PROXIED1, ChecksumPolicy.FAIL, ReleasesPolicy.ALWAYS,
- SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
+ SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
- StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository(), artifact );
+ StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository( ), artifact );
assertNotDownloaded( downloadedFile );
assertNoTempFiles( expectedFile );
}
@Test
- public void testGetAlwaysBadChecksumPresentLocallyAbsentRemoteUsingFixSetting()
+ public void testGetAlwaysBadChecksumPresentLocallyAbsentRemoteUsingFixSetting( )
throws Exception
{
String path = "org/apache/maven/test/get-bad-local-checksum/1.0/get-bad-local-checksum-1.0.jar";
setupTestableManagedRepository( path );
- Path expectedFile = managedDefaultDir.resolve(path);
- Path remoteFile = Paths.get(REPOPATH_PROXIED1, path);
+ Path expectedFile = managedDefaultDir.resolve( path );
+ Path remoteFile = Paths.get( REPOPATH_PROXIED1, path );
setManagedOlderThanRemote( expectedFile, remoteFile );
- ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
+ BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
+ ArtifactReference artifact = layout.toArtifactReference( path );
// Configure Connector (usually done within archiva.xml configuration)
saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS,
- SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
+ SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
- StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository(), artifact );
+ StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository( ), artifact );
- Path proxied1File = Paths.get(REPOPATH_PROXIED1, path);
- assertFileEquals( expectedFile, downloadedFile.getFilePath(), proxied1File );
+ Path proxied1File = Paths.get( REPOPATH_PROXIED1, path );
+ assertFileEquals( expectedFile, downloadedFile.getFilePath( ), proxied1File );
assertNoTempFiles( expectedFile );
assertChecksums( expectedFile, "96a08dc80a108cba8efd3b20aec91b32a0b2cbd4 get-bad-local-checksum-1.0.jar",
- "46fdd6ca55bf1d7a7eb0c858f41e0ccd get-bad-local-checksum-1.0.jar" );
+ "46fdd6ca55bf1d7a7eb0c858f41e0ccd get-bad-local-checksum-1.0.jar" );
}
}
*/
import org.apache.archiva.policies.*;
+import org.apache.archiva.repository.BaseRepositoryContentLayout;
import org.apache.archiva.repository.LayoutException;
import org.apache.archiva.repository.storage.StorageAsset;
import org.apache.maven.wagon.ResourceDoesNotExistException;
StorageAsset downloadedFile = null;
try
{
+ BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository(),
- managedDefaultRepository.toArtifactReference( path ) );
+ layout.toArtifactReference( path ) );
fail( "Proxy should not have succeeded" );
}
catch ( ProxyDownloadException e )
wagonMockControl.replay();
// Attempt the proxy fetch.
+ BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
+
StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository(),
- managedDefaultRepository.toArtifactReference( path ) );
+ layout.toArtifactReference( path ) );
wagonMockControl.verify();
return downloadedFile;
managedDefaultRepository = repositoryRegistry.getManagedRepository(MANAGED_ID).getContent();
- Path expectedFile = Paths.get( managedDefaultRepository.getRepoRoot() ).resolve( path );
+ BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
+ Path expectedFile = managedDefaultRepository.getRepository().getAsset( "" ).resolve( path ).getFilePath();
Files.deleteIfExists( expectedFile );
- ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
+ ArtifactReference artifact = layout.toArtifactReference( path );
// Attempt the proxy fetch.
StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository(), artifact );
import org.apache.archiva.policies.ChecksumPolicy;
import org.apache.archiva.policies.ReleasesPolicy;
import org.apache.archiva.policies.SnapshotsPolicy;
+import org.apache.archiva.repository.BaseRepositoryContentLayout;
import org.apache.archiva.repository.storage.StorageAsset;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
setupTestableManagedRepository( path );
Path expectedFile = managedDefaultDir.resolve(path);
- ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
+
+ BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
+
+ ArtifactReference artifact = layout.toArtifactReference( path );
// Ensure file isn't present first.
assertNotExistsInManagedDefaultRepo( expectedFile );
setupTestableManagedRepository( path );
Path expectedFile = managedDefaultDir.resolve(path);
- ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
+
+ BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
+
+ ArtifactReference artifact = layout.toArtifactReference( path );
// Ensure file isn't present first.
assertNotExistsInManagedDefaultRepo( expectedFile );
Path expectedFile = managedDefaultDir.resolve(path);
- ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
+ BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
+
+ ArtifactReference artifact = layout.toArtifactReference( path );
assertTrue( Files.exists(expectedFile) );
setManagedNewerThanRemote( expectedFile, remoteFile );
long originalModificationTime = Files.getLastModifiedTime( expectedFile).toMillis();
- ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
+
+ BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
+
+ ArtifactReference artifact = layout.toArtifactReference( path );
assertTrue( Files.exists(expectedFile) );
// Set the managed file to be newer than remote file.
setManagedOlderThanRemote( expectedFile, remoteFile );
- ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
+ BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
+
+ ArtifactReference artifact = layout.toArtifactReference( path );
assertTrue( Files.exists(expectedFile) );
setupTestableManagedRepository( path );
Path expectedFile = managedDefaultDir.resolve(path);
- ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
+
+ BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
+
+ ArtifactReference artifact = layout.toArtifactReference( path );
assertTrue( Files.exists(expectedFile) );
Files.setLastModifiedTime( expectedFile, FileTime.from(getPastDate().getTime(), TimeUnit.MILLISECONDS ));
setupTestableManagedRepository( path );
Path expectedFile = managedDefaultDir.resolve(path);
- ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
+
+ BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
+
+ ArtifactReference artifact = layout.toArtifactReference( path );
assertNotExistsInManagedDefaultRepo( expectedFile );
setupTestableManagedRepository( path );
Path expectedFile = managedDefaultDir.resolve(path);
- ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
+
+ BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
+
+ ArtifactReference artifact = layout.toArtifactReference( path );
assertNotExistsInManagedDefaultRepo( expectedFile );
setupTestableManagedRepository( path );
Path expectedFile = managedDefaultDir.resolve(path);
- ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
+
+ BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
+
+ ArtifactReference artifact = layout.toArtifactReference( path );
assertNotExistsInManagedDefaultRepo( expectedFile );
setupTestableManagedRepository( path );
Path expectedFile = managedDefaultDir.resolve(path);
- ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
+
+ BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
+
+ ArtifactReference artifact = layout.toArtifactReference( path );
assertNotExistsInManagedDefaultRepo( expectedFile );
setupTestableManagedRepository( path );
Path expectedFile = managedDefaultDir.resolve( path );
- ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
+
+ BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
+
+ ArtifactReference artifact = layout.toArtifactReference( path );
assertNotExistsInManagedDefaultRepo( expectedFile );
import org.apache.archiva.policies.ChecksumPolicy;
import org.apache.archiva.policies.ReleasesPolicy;
import org.apache.archiva.policies.SnapshotsPolicy;
+import org.apache.archiva.repository.BaseRepositoryContentLayout;
import org.apache.archiva.repository.metadata.base.MetadataTools;
import org.apache.archiva.repository.metadata.RepositoryMetadataException;
import org.apache.archiva.repository.metadata.base.RepositoryMetadataWriter;
ProjectReference metadata = createProjectReference( requestedResource );
+ BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
StorageAsset downloadedFile = proxyHandler.fetchMetadataFromProxies( managedDefaultRepository.getRepository(),
- managedDefaultRepository.toMetadataPath(
+ layout.toMetadataPath(
metadata ) ).getFile();
assertNull( "Should not have downloaded a file.", downloadedFile );
ProjectReference metadata = createProjectReference( requestedResource );
+ BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
+
StorageAsset downloadedFile = proxyHandler.fetchMetadataFromProxies( managedDefaultRepository.getRepository(),
- managedDefaultRepository.toMetadataPath(
+ layout.toMetadataPath(
metadata ) ).getFile();
assertNotNull( "Should have downloaded a file.", downloadedFile );
Path expectedFile = managedDefaultDir.resolve(requestedResource);
ProjectReference metadata = createProjectReference( requestedResource );
+ BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
StorageAsset downloadedFile = proxyHandler.fetchMetadataFromProxies( managedDefaultRepository.getRepository(),
- managedDefaultRepository.toMetadataPath(
+ layout.toMetadataPath(
metadata ) ).getFile();
assertNull( downloadedFile );
VersionedReference metadata = createVersionedReference( requestedResource );
+ BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
StorageAsset downloadedFile = proxyHandler.fetchMetadataFromProxies( managedDefaultRepository.getRepository(),
- managedDefaultRepository.toMetadataPath(
+ layout.toMetadataPath(
metadata ) ).getFile();
assertNotNull( "Should have downloaded a file.", downloadedFile );
Path expectedFile = managedDefaultDir.resolve(requestedResource);
VersionedReference metadata = createVersionedReference( requestedResource );
+ BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
StorageAsset downloadedFile = proxyHandler.fetchMetadataFromProxies( managedDefaultRepository.getRepository(),
- managedDefaultRepository.toMetadataPath(
+ layout.toMetadataPath(
metadata ) ).getFile();
assertNull( downloadedFile );
import org.apache.archiva.policies.ChecksumPolicy;
import org.apache.archiva.policies.ReleasesPolicy;
import org.apache.archiva.policies.SnapshotsPolicy;
+import org.apache.archiva.repository.BaseRepositoryContentLayout;
import org.apache.archiva.repository.storage.StorageAsset;
import org.junit.Test;
setupTestableManagedRepository( path );
Path expectedFile = managedDefaultDir.resolve(path);
- ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
+ BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
+ ArtifactReference artifact = layout.toArtifactReference( path );
Files.deleteIfExists(expectedFile);
assertFalse( Files.exists(expectedFile) );
setupTestableManagedRepository( path );
Path expectedFile = managedDefaultDir.resolve(path);
- ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
+ BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
+
+ ArtifactReference artifact = layout.toArtifactReference( path );
Files.deleteIfExists(expectedFile);
assertFalse( Files.exists(expectedFile) );
setupTestableManagedRepository( path );
Path expectedFile = managedDefaultDir.resolve(path);
- ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
+ BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
+
+ ArtifactReference artifact = layout.toArtifactReference( path );
assertTrue( Files.exists(expectedFile) );
Files.setLastModifiedTime( expectedFile, FileTime.from( getPastDate().getTime(), TimeUnit.MILLISECONDS ));
Path remoteFile = Paths.get(REPOPATH_PROXIED1, path);
setManagedNewerThanRemote( expectedFile, remoteFile );
-
- ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
+
+ BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
+
+ ArtifactReference artifact = layout.toArtifactReference( path );
// Configure Connector (usually done within archiva.xml configuration)
saveConnector( ID_DEFAULT_MANAGED, ID_PROXIED1, false );
setupTestableManagedRepository( path );
Path expectedFile = managedDefaultDir.resolve(path);
- ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
+ BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
+ ArtifactReference artifact = layout.toArtifactReference( path );
assertTrue( Files.exists(expectedFile) );
setManagedNewerThanRemote( expectedFile, remoteFile, 12000000 );
long expectedTimestamp = Files.getLastModifiedTime( expectedFile ).toMillis();
-
- ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
+
+ BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
+
+ ArtifactReference artifact = layout.toArtifactReference( path );
// Configure Connector (usually done within archiva.xml configuration)
saveConnector( ID_DEFAULT_MANAGED, ID_PROXIED1, false);
setupTestableManagedRepository( path );
Path expectedFile = managedDefaultDir.resolve(path);
- ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
+
+ BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
+
+ ArtifactReference artifact = layout.toArtifactReference( path );
Files.deleteIfExists(expectedFile);
assertFalse( Files.exists(expectedFile) );
setupTestableManagedRepository( path );
Path expectedFile = managedDefaultDir.resolve(path);
- ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
+
+ BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
+
+ ArtifactReference artifact = layout.toArtifactReference( path );
Files.deleteIfExists(expectedFile);
assertFalse( Files.exists(expectedFile) );
setupTestableManagedRepository( path );
Path expectedFile = managedDefaultDir.resolve(path);
- ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
+
+ BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
+
+ ArtifactReference artifact = layout.toArtifactReference( path );
assertTrue( Files.exists(expectedFile) );
* @author Martin Stockhammer <martin_s@apache.org>
*/
@Service("managedRepositoryContent#mock")
-public class ManagedRepositoryContentMock implements ManagedRepositoryContent
+public class ManagedRepositoryContentMock implements BaseRepositoryContentLayout, ManagedRepositoryContent
{
private static final String PATH_SEPARATOR = "/";
private static final String GROUP_SEPARATOR = ".";
return null;
}
+ @Override
+ public <T extends ManagedRepositoryContentLayout> T getLayout( Class<T> clazz ) throws LayoutException
+ {
+ return (T) this;
+ }
+
+ @Override
+ public <T extends ManagedRepositoryContentLayout> boolean supportsLayout( Class<T> clazz )
+ {
+ return true;
+ }
+
@Override
public void addArtifact( Path sourceFile, Artifact destination ) throws IllegalArgumentException
{
}
+ @Override
+ public String toPath( ContentItem item )
+ {
+ return null;
+ }
+
@Override
public String getId( )
{
return null;
}
+ @Override
+ public ManagedRepositoryContent getGenericContent( )
+ {
+ return null;
+ }
}
}
@Override
- public ManagedRepositoryContent createManagedContent(ManagedRepository repository) throws RepositoryException {
+ public BaseRepositoryContentLayout createManagedContent( ManagedRepository repository) throws RepositoryException {
return new ManagedRepositoryContentMock(repository);
}
import org.apache.archiva.common.utils.VersionUtil;
import org.apache.archiva.metadata.repository.storage.RepositoryPathTranslator;
+import org.apache.archiva.repository.content.ContentItem;
import org.apache.archiva.repository.maven.metadata.storage.ArtifactMappingProvider;
import org.apache.archiva.repository.maven.metadata.storage.Maven2RepositoryPathTranslator;
import org.apache.archiva.model.ArchivaArtifact;
reference.getClassifier(), reference.getType() );
}
+
+
protected String formatAsDirectory( String directory )
{
return directory.replace( GROUP_SEPARATOR, PATH_SEPARATOR );
import org.apache.archiva.metadata.maven.MavenMetadataReader;
import org.apache.archiva.metadata.repository.storage.RepositoryPathTranslator;
import org.apache.archiva.model.ArchivaArtifact;
-import org.apache.archiva.model.ArchivaRepositoryMetadata;
import org.apache.archiva.model.ArtifactReference;
import org.apache.archiva.model.ProjectReference;
import org.apache.archiva.model.VersionedReference;
import org.apache.archiva.repository.ContentAccessException;
import org.apache.archiva.repository.ContentNotFoundException;
import org.apache.archiva.repository.EditableManagedRepository;
+import org.apache.archiva.repository.ManagedRepositoryContent;
import org.apache.archiva.repository.ItemDeleteStatus;
import org.apache.archiva.repository.LayoutException;
import org.apache.archiva.repository.ManagedRepository;
-import org.apache.archiva.repository.ManagedRepositoryContent;
+import org.apache.archiva.repository.BaseRepositoryContentLayout;
+import org.apache.archiva.repository.ManagedRepositoryContentLayout;
import org.apache.archiva.repository.content.Artifact;
import org.apache.archiva.repository.content.ArtifactType;
import org.apache.archiva.repository.content.BaseArtifactTypes;
-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.DataItemType;
import org.apache.archiva.repository.content.ItemNotFoundException;
import org.apache.archiva.repository.content.ItemSelector;
import org.apache.archiva.repository.content.Namespace;
import org.apache.archiva.repository.content.base.builder.ArtifactOptBuilder;
import org.apache.archiva.repository.maven.metadata.storage.ArtifactMappingProvider;
import org.apache.archiva.repository.maven.metadata.storage.DefaultArtifactMappingProvider;
-import org.apache.archiva.repository.metadata.RepositoryMetadataException;
import org.apache.archiva.repository.storage.RepositoryStorage;
import org.apache.archiva.repository.storage.StorageAsset;
import org.apache.archiva.repository.storage.util.StorageUtil;
import javax.inject.Inject;
import javax.inject.Named;
-import javax.naming.Name;
import java.io.IOException;
import java.net.URI;
import java.nio.file.Files;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
-import java.util.Optional;
import java.util.function.Consumer;
import java.util.function.Predicate;
import java.util.regex.Matcher;
*/
public class ManagedDefaultRepositoryContent
extends AbstractDefaultRepositoryContent
- implements ManagedRepositoryContent
+ implements BaseRepositoryContentLayout
{
// attribute flag that marks version objects that point to a snapshot artifact version
}
}
+ @Override
+ public ManagedRepositoryContent getGenericContent( )
+ {
+ return this;
+ }
+
// Simple object to hold artifact information
private class ArtifactInfo
{
}
}
+ @Override
+ public <T extends ManagedRepositoryContentLayout> T getLayout( Class<T> clazz ) throws LayoutException
+ {
+ if (clazz.isAssignableFrom( this.getClass() )) {
+ return (T) this;
+ } else {
+ throw new LayoutException( "Cannot convert to layout " + clazz );
+ }
+ }
+
+ @Override
+ public <T extends ManagedRepositoryContentLayout> boolean supportsLayout( Class<T> clazz )
+ {
+ return clazz.isAssignableFrom( this.getClass( ) );
+ }
+
/**
* Moves the file to the artifact destination
*/
return toVersion( artifactReference.getGroupId( ), artifactReference.getArtifactId( ), artifactReference.getVersion( ) );
}
+ @Override
+ public String toPath( ContentItem item ) {
+ return item.getAsset( ).getPath( );
+ }
@Override
public void deleteVersion( VersionedReference ref ) throws ContentNotFoundException, ContentAccessException
import org.apache.archiva.configuration.FileTypes;
import org.apache.archiva.repository.maven.metadata.storage.ArtifactMappingProvider;
import org.apache.archiva.repository.ManagedRepository;
-import org.apache.archiva.repository.ManagedRepositoryContent;
+import org.apache.archiva.repository.BaseRepositoryContentLayout;
import org.apache.archiva.repository.RemoteRepository;
import org.apache.archiva.repository.RemoteRepositoryContent;
import org.apache.archiva.repository.Repository;
}
@Override
- public ManagedRepositoryContent createManagedContent( ManagedRepository repository ) throws RepositoryException
+ public BaseRepositoryContentLayout createManagedContent( ManagedRepository repository ) throws RepositoryException
{
if (!supports( repository.getType() )) {
throw new RepositoryException( "Repository type "+repository.getType()+" is not supported by this implementation." );
if (!supports( repository.getType() )) {
throw new RepositoryException( "Repository type "+repository.getType()+" is not supported by this implementation." );
}
- if (repository instanceof ManagedRepository && ManagedRepositoryContent.class.isAssignableFrom( clazz ) ) {
+ if (repository instanceof ManagedRepository && BaseRepositoryContentLayout.class.isAssignableFrom( clazz ) ) {
return (T) this.createManagedContent( (ManagedRepository) repository );
} else if (repository instanceof RemoteRepository && RemoteRepository.class.isAssignableFrom( clazz )) {
return (T) this.createRemoteContent( (RemoteRepository) repository );
import org.apache.archiva.repository.*;
import org.apache.archiva.repository.content.PathParser;
import org.apache.archiva.repository.features.RepositoryFeature;
-import org.apache.archiva.repository.maven.content.DefaultPathParser;
import org.apache.archiva.repository.metadata.base.MetadataTools;
import org.apache.commons.lang3.StringUtils;
}
/**
- * Adjust the requestedPath to conform to the native layout of the provided {@link org.apache.archiva.repository.ManagedRepositoryContent}.
+ * Adjust the requestedPath to conform to the native layout of the provided {@link BaseRepositoryContentLayout}.
*
* @param requestedPath the incoming requested path.
* @return the adjusted (to native) path.
// Treat as an artifact reference.
ArtifactReference ref = toArtifactReference( referencedResource );
- String adjustedPath = repository.getContent().toPath( ref );
+ String adjustedPath = repository.getContent().getLayout( BaseRepositoryContentLayout.class ).toPath( ref );
return adjustedPath + supportfile;
}
import org.apache.archiva.maven2.model.TreeEntry;
import org.apache.archiva.metadata.repository.storage.RepositoryPathTranslator;
import org.apache.archiva.model.ArchivaRepositoryMetadata;
+import org.apache.archiva.repository.BaseRepositoryContentLayout;
+import org.apache.archiva.repository.LayoutException;
import org.apache.archiva.repository.ManagedRepository;
import org.apache.archiva.repository.RemoteRepository;
import org.apache.archiva.repository.RepositoryRegistry;
import org.eclipse.aether.collection.DependencyCollectionException;
import org.eclipse.aether.graph.Dependency;
import org.eclipse.aether.graph.DependencyVisitor;
+import org.jsoup.Connection;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
// FIXME take care of relative path
ResolveRequest resolveRequest = new ResolveRequest();
resolveRequest.dependencyVisitor = dependencyVisitor;
- resolveRequest.localRepoDir = repository.getContent().getRepoRoot();
+ try
+ {
+ resolveRequest.localRepoDir = repository.getContent().getLayout( BaseRepositoryContentLayout.class ).getRepoRoot();
+ }
+ catch ( LayoutException e )
+ {
+ throw new DependencyTreeBuilderException( "Could not convert to layout " + e.getMessage( ), e );
+ }
resolveRequest.groupId = groupId;
resolveRequest.artifactId = artifactId;
resolveRequest.version = version;
proxyHandler.fetchFromProxies(managedRepository, pomReference);
// Open and read the POM from the managed repo
- StorageAsset pom = managedRepository.getContent().toFile(pomReference);
+ StorageAsset pom = null;
+ try
+ {
+ pom = managedRepository.getContent().getLayout( BaseRepositoryContentLayout.class ).toFile(pomReference);
+ }
+ catch ( LayoutException e )
+ {
+ throw new ProxyDownloadException( "Cannot convert layout ", new HashMap<>( ) );
+ }
if (!pom.exists()) {
return;
import org.apache.archiva.repository.ManagedRepositoryContent;
import org.apache.archiva.repository.RemoteRepositoryContent;
import org.apache.archiva.repository.RepositoryContentProvider;
-import org.apache.archiva.repository.maven.MavenManagedRepository;
-import org.apache.archiva.repository.maven.MavenRemoteRepository;
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
import org.junit.Rule;
import org.junit.rules.TestName;
--- /dev/null
+package org.apache.archiva.repository.maven.content;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.repository.LayoutException;
+import org.apache.archiva.repository.content.ItemSelector;
+import org.apache.archiva.repository.content.base.ArchivaItemSelector;
+import org.junit.Test;
+
+import static org.junit.Assert.fail;
+
+/**
+ * Specific tests for ManagedRepositoryContent
+ *
+ * @author Martin Stockhammer <martin_s@apache.org>
+ */
+public abstract class AbstractBaseRepositoryContentLayoutTest extends AbstractRepositoryContentTest
+{
+
+ @Override
+ protected void assertBadPathCi( String path, String reason )
+ {
+ super.assertBadPathCi( path, reason );
+ try
+ {
+ getManaged().toItem( path );
+ fail(
+ "toItem(path) should have thrown a LayoutException on the invalid path [" + path + "] because of [" + reason + "]" );
+ }
+ catch ( LayoutException e )
+ {
+ /* expected path */
+ }
+ }
+
+ @Test
+ public void testGetArtifactOnEmptyPath() {
+ ItemSelector selector = ArchivaItemSelector.builder( ).build( );
+ try {
+ getManaged( ).getArtifact( selector );
+ fail( "getArtifact(ItemSelector) with empty selector should throw IllegalArgumentException" );
+ } catch (IllegalArgumentException e) {
+ // Good
+ }
+ }
+}
+++ /dev/null
-package org.apache.archiva.repository.maven.content;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.archiva.repository.LayoutException;
-import org.apache.archiva.repository.content.ItemSelector;
-import org.apache.archiva.repository.content.base.ArchivaItemSelector;
-import org.junit.Test;
-
-import static org.junit.Assert.fail;
-
-/**
- * Specific tests for ManagedRepositoryContent
- *
- * @author Martin Stockhammer <martin_s@apache.org>
- */
-public abstract class AbstractManagedRepositoryContentTest extends AbstractRepositoryContentTest
-{
-
- @Override
- protected void assertBadPathCi( String path, String reason )
- {
- super.assertBadPathCi( path, reason );
- try
- {
- getManaged().toItem( path );
- fail(
- "toItem(path) should have thrown a LayoutException on the invalid path [" + path + "] because of [" + reason + "]" );
- }
- catch ( LayoutException e )
- {
- /* expected path */
- }
- }
-
- @Test
- public void testGetArtifactOnEmptyPath() {
- ItemSelector selector = ArchivaItemSelector.builder( ).build( );
- try {
- getManaged( ).getArtifact( selector );
- fail( "getArtifact(ItemSelector) with empty selector should throw IllegalArgumentException" );
- } catch (IllegalArgumentException e) {
- // Good
- }
- }
-}
import org.apache.archiva.repository.RepositoryContent;
import org.apache.archiva.repository.maven.AbstractRepositoryLayerTestCase;
import org.apache.archiva.repository.LayoutException;
-import org.apache.archiva.repository.ManagedRepositoryContent;
+import org.apache.archiva.repository.BaseRepositoryContentLayout;
import org.apache.archiva.repository.content.Artifact;
import org.apache.archiva.repository.content.ItemSelector;
import org.apache.archiva.repository.content.Namespace;
protected abstract ItemSelector toItemSelector(String path) throws LayoutException;
- protected abstract ManagedRepositoryContent getManaged();
+ protected abstract BaseRepositoryContentLayout getManaged();
protected abstract RepositoryContent getContent( );
}
import org.apache.archiva.model.ProjectReference;
import org.apache.archiva.model.VersionedReference;
import org.apache.archiva.repository.EditableManagedRepository;
+import org.apache.archiva.repository.ManagedRepositoryContent;
import org.apache.archiva.repository.LayoutException;
import org.apache.archiva.repository.ManagedRepository;
-import org.apache.archiva.repository.ManagedRepositoryContent;
+import org.apache.archiva.repository.BaseRepositoryContentLayout;
import org.apache.archiva.repository.RepositoryContent;
import org.apache.archiva.repository.content.Artifact;
import org.apache.archiva.repository.content.BaseArtifactTypes;
import org.apache.archiva.repository.content.Project;
import org.apache.archiva.repository.content.Version;
import org.apache.archiva.repository.content.base.ArchivaContentItem;
-import org.apache.archiva.repository.content.base.ArchivaDataItem;
import org.apache.archiva.repository.content.base.ArchivaItemSelector;
import org.apache.archiva.repository.maven.MavenManagedRepository;
import org.apache.archiva.repository.maven.metadata.storage.ArtifactMappingProvider;
-import org.apache.archiva.repository.metadata.MetadataReader;
import org.apache.archiva.repository.storage.StorageAsset;
import org.apache.commons.io.FileUtils;
import org.junit.Before;
* ManagedDefaultRepositoryContentTest
*/
public class ManagedDefaultRepositoryContentTest
- extends AbstractManagedRepositoryContentTest
+ extends AbstractBaseRepositoryContentLayoutTest
{
private ManagedDefaultRepositoryContent repoContent;
}
@Override
- protected ManagedRepositoryContent getManaged( )
+ protected BaseRepositoryContentLayout getManaged( )
{
return repoContent;
}
assertTrue( result.stream( ).anyMatch( a -> "axis2-1.3-20070725.210059-1.pom".equals( a.getAsset( ).getName( ) ) ) );
}
-// @Test
-// public void testNewItemStreamWithNamespace2() {
-// ItemSelector selector = ArchivaItemSelector.builder( )
-// .withNamespace( "org.apache.maven" )
-// .build();
-//
-// Stream<? extends ContentItem> stream = repoContent.newItemStream( selector, false );
-// List<? extends ContentItem> result = stream.collect( Collectors.toList( ) );
-// int versions = 0;
-// int projects = 0;
-// int artifacts = 0;
-// int namespaces = 0;
-// int dataitems = 0;
-// for (int i=0; i<result.size(); i++) {
-// ContentItem ci = result.get( i );
-// System.out.println( i + ": " + result.get( i ) + " - " +result.get(i).getClass().getName() + " - " + result.get(i).getAsset().getPath() );
-// if (ci instanceof Version) {
-// versions++;
-// } else if (ci instanceof Project) {
-// projects++;
-// } else if (ci instanceof Namespace) {
-// namespaces++;
-// } else if (ci instanceof Artifact) {
-// artifacts++;
-// } else if (ci instanceof DataItem ) {
-// dataitems++;
-// }
-// }
-// System.out.println( "namespaces=" + namespaces + ", projects=" + projects + ", versions=" + versions + ", artifacts=" + artifacts + ", dataitems=" + dataitems );
-// assertEquals( 170, result.size( ) );
-// assertEquals( 92, result.stream( ).filter( a -> a instanceof Artifact ).count( ) );
-// }
+ @Test
+ public void testNewItemStreamWithNamespace2() {
+ ItemSelector selector = ArchivaItemSelector.builder( )
+ .withNamespace( "org.apache.maven" )
+ .recurse()
+ .build();
+
+ Stream<? extends ContentItem> stream = repoContent.newItemStream( selector, false );
+ List<? extends ContentItem> result = stream.collect( Collectors.toList( ) );
+ assertEquals( 170, result.size( ) );
+ assertEquals( 92, result.stream( ).filter( a -> a instanceof DataItem ).count( ) );
+ }
@Test
public void testGetArtifactFromContentItem() {
@Test
- public void testAddArtifact() throws IOException, URISyntaxException
+ public void testAddArtifact() throws IOException, URISyntaxException, LayoutException
{
ManagedRepository repo = createManagedRepoWithContent( "delete-repository" );
ManagedRepositoryContent myRepoContent = repo.getContent( );
+ BaseRepositoryContentLayout layout = myRepoContent.getLayout( BaseRepositoryContentLayout.class );
Path repoRoot = repo.getAsset( "" ).getFilePath( );
Path tmpFile = Files.createTempFile( "archiva-mvn-repotest", "jar" );
.withArtifactVersion( "2.0" )
.withExtension( "jar" )
.build( );
- Artifact artifact = myRepoContent.getArtifact( selector );
- myRepoContent.addArtifact( tmpFile, artifact );
+ Artifact artifact = layout.getArtifact( selector );
+ layout.addArtifact( tmpFile, artifact );
FileTime lmtAfter = Files.getLastModifiedTime( file );
assertNotEquals( lmtAfter, lmt );
Reader ln = Files.newBufferedReader( file, Charset.forName( "UTF-8" ) );
.withArtifactVersion( "2.0" )
.withExtension( "test" )
.build( );
- artifact = myRepoContent.getArtifact( selector );
- myRepoContent.addArtifact( tmpFile, artifact );
+ artifact = layout.getArtifact( selector );
+ layout.addArtifact( tmpFile, artifact );
ln = Files.newBufferedReader( file, Charset.forName( "UTF-8" ) );
ln.read( content );
assertTrue( new String( content ).startsWith( "test.test.test" ) );
import org.apache.archiva.configuration.ArchivaConfiguration;
import org.apache.archiva.configuration.FileType;
import org.apache.archiva.configuration.FileTypes;
+import org.apache.archiva.repository.ManagedRepositoryContent;
import org.apache.archiva.repository.maven.metadata.storage.ArtifactMappingProvider;
import org.apache.archiva.model.ArtifactReference;
import org.apache.archiva.repository.LayoutException;
-import org.apache.archiva.repository.ManagedRepositoryContent;
import org.apache.archiva.repository.RepositoryContentProvider;
import org.apache.archiva.repository.maven.MavenManagedRepository;
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
import org.apache.archiva.model.ArtifactReference;
import org.apache.archiva.repository.LayoutException;
-import org.apache.archiva.repository.ManagedRepositoryContent;
+import org.apache.archiva.repository.BaseRepositoryContentLayout;
import org.apache.archiva.repository.RemoteRepository;
import org.apache.archiva.repository.RemoteRepositoryContent;
import org.apache.archiva.repository.RepositoryContent;
}
@Override
- protected ManagedRepositoryContent getManaged( )
+ protected BaseRepositoryContentLayout getManaged( )
{
return null;
}
import org.apache.archiva.common.utils.VersionComparator;
import org.apache.archiva.configuration.ProxyConnectorConfiguration;
+import org.apache.archiva.repository.ManagedRepositoryContent;
import org.apache.archiva.repository.maven.metadata.storage.mock.MockConfiguration;
import org.apache.archiva.model.ProjectReference;
import org.apache.archiva.model.VersionedReference;
import org.apache.archiva.policies.SnapshotsPolicy;
import org.apache.archiva.repository.maven.AbstractRepositoryLayerTestCase;
import org.apache.archiva.repository.LayoutException;
-import org.apache.archiva.repository.ManagedRepositoryContent;
import org.apache.archiva.repository.RemoteRepositoryContent;
import org.apache.archiva.repository.RepositoryContentProvider;
import org.apache.archiva.repository.metadata.RepositoryMetadataException;
ProjectReference reference )
throws LayoutException, IOException, SAXException, ParserConfigurationException
{
- Path metadataFile = Paths.get( repository.getRepoRoot(), tools.toPath( reference ) );
+ Path metadataFile = repository.getRepository().getAsset( "" ).getFilePath().resolve(tools.toPath( reference ) );
String actualMetadata = org.apache.archiva.common.utils.FileUtils.readFileToString( metadataFile, Charset.defaultCharset() );
Diff detailedDiff = DiffBuilder.compare( expectedMetadata ).withTest( actualMetadata ).checkForSimilar().build();
VersionedReference reference )
throws LayoutException, IOException, SAXException, ParserConfigurationException
{
- Path metadataFile = Paths.get( repository.getRepoRoot(), tools.toPath( reference ) );
+ Path metadataFile = repository.getRepository().getAsset("").getFilePath().resolve( tools.toPath( reference ) );
String actualMetadata = org.apache.archiva.common.utils.FileUtils.readFileToString( metadataFile, Charset.defaultCharset() );
Diff detailedDiff = DiffBuilder.compare( expectedMetadata ).withTest( actualMetadata ).checkForSimilar().build();
Path srcRepoDir = getRepositoryPath( "metadata-repository" );
Path srcDir = srcRepoDir.resolve( path );
- Path destDir = Paths.get( repo.getRepoRoot(), path );
+ Path destDir = repo.getRepository().getAsset( "" ).getFilePath().resolve( path );
assertTrue( "Source Dir exists: " + srcDir, Files.exists(srcDir) );
Files.createDirectories(destDir);
import org.apache.archiva.consumers.ConsumerException;
import org.apache.archiva.consumers.KnownRepositoryContentConsumer;
import org.apache.archiva.model.ArtifactReference;
+import org.apache.archiva.repository.ManagedRepositoryContent;
import org.apache.archiva.repository.LayoutException;
import org.apache.archiva.repository.ManagedRepository;
-import org.apache.archiva.repository.ManagedRepositoryContent;
+import org.apache.archiva.repository.BaseRepositoryContentLayout;
import org.apache.archiva.repository.RepositoryContentFactory;
import org.springframework.stereotype.Service;
{
try
{
- consumed.add( repository.toArtifactReference( path ) );
+ consumed.add( repository.getLayout( BaseRepositoryContentLayout.class ).toArtifactReference( path ) );
}
catch ( LayoutException e )
{
import org.apache.archiva.redback.rest.services.RedbackAuthenticationThreadLocal;
import org.apache.archiva.redback.rest.services.RedbackRequestInformation;
import org.apache.archiva.redback.users.User;
-import org.apache.archiva.repository.ManagedRepository;
import org.apache.archiva.repository.ManagedRepositoryContent;
+import org.apache.archiva.repository.ManagedRepository;
import org.apache.archiva.repository.RepositoryException;
import org.apache.archiva.repository.RepositoryRegistry;
import org.apache.archiva.metadata.audit.AuditListener;
import org.apache.archiva.admin.model.beans.ManagedRepository;
import org.apache.archiva.common.utils.VersionComparator;
import org.apache.archiva.common.utils.VersionUtil;
+import org.apache.archiva.repository.ManagedRepositoryContent;
+import org.apache.archiva.repository.content.base.ArchivaItemSelector;
import org.apache.archiva.repository.maven.dependency.tree.DependencyTreeBuilder;
import org.apache.archiva.maven2.model.Artifact;
import org.apache.archiva.maven2.model.TreeEntry;
import org.apache.archiva.metadata.repository.*;
import org.apache.archiva.repository.maven.metadata.storage.ArtifactMetadataVersionComparator;
import org.apache.archiva.repository.maven.metadata.storage.MavenProjectFacet;
-import org.apache.archiva.model.ArchivaArtifact;
import org.apache.archiva.model.ArchivaRepositoryMetadata;
import org.apache.archiva.proxy.ProxyRegistry;
import org.apache.archiva.proxy.model.RepositoryProxyHandler;
import org.apache.archiva.components.cache.Cache;
-import org.apache.archiva.repository.ManagedRepositoryContent;
import org.apache.archiva.repository.ReleaseScheme;
import org.apache.archiva.repository.RepositoryException;
import org.apache.archiva.repository.RepositoryNotFoundException;
@Named( value = "browse#versionMetadata" )
private Cache<String, ProjectVersionMetadata> versionMetadataCache;
- private ManagedRepositoryContent getManagedRepositoryContent(String id) throws RepositoryException
+ private ManagedRepositoryContent getManagedRepositoryContent( String id) throws RepositoryException
{
org.apache.archiva.repository.ManagedRepository repo = repositoryRegistry.getManagedRepository( id );
if (repo==null) {
ManagedRepositoryContent managedRepositoryContent =
getManagedRepositoryContent( repoId );
- ArchivaArtifact archivaArtifact = new ArchivaArtifact( groupId, artifactId, version, classifier,
- StringUtils.isEmpty( type ) ? "jar" : type,
- repoId );
- StorageAsset file = managedRepositoryContent.toFile( archivaArtifact );
+ ArchivaItemSelector itemSelector = ArchivaItemSelector.builder( ).withNamespace( groupId )
+ .withProjectId( artifactId ).withVersion( version ).withClassifier( classifier )
+ .withType( StringUtils.isEmpty( type ) ? "jar" : type )
+ .withArtifactId( artifactId ).build();
+ org.apache.archiva.repository.content.Artifact archivaArtifact = managedRepositoryContent.getItem( itemSelector ).adapt( org.apache.archiva.repository.content.Artifact.class );
+ StorageAsset file = archivaArtifact.getAsset();
if ( file.exists() )
{
return readFileEntries( file, path, repoId );
log.error("No repository content found for "+repoId);
continue;
}
- ArchivaArtifact archivaArtifact = new ArchivaArtifact( groupId, artifactId, version, classifier,
- StringUtils.isEmpty( type ) ? "jar" : type,
- repoId );
- StorageAsset file = managedRepositoryContent.toFile( archivaArtifact );
+ ArchivaItemSelector itemSelector = ArchivaItemSelector.builder( ).withNamespace( groupId )
+ .withProjectId( artifactId ).withVersion( version ).withClassifier( classifier )
+ .withType( StringUtils.isEmpty( type ) ? "jar" : type )
+ .withArtifactId( artifactId ).build();
+ org.apache.archiva.repository.content.Artifact archivaArtifact = managedRepositoryContent.getItem( itemSelector ).adapt( org.apache.archiva.repository.content.Artifact.class );
+ StorageAsset file = archivaArtifact.getAsset( );
if ( !file.exists() )
{
log.debug( "file: {} not exists for repository: {} try next repository", file, repoId );
ManagedRepositoryContent managedRepositoryContent = getManagedRepositoryContent( repoId );
// FIXME default to jar which can be wrong for war zip etc....
- ArchivaArtifact archivaArtifact = new ArchivaArtifact( groupId, artifactId, version,
- StringUtils.isEmpty( classifier )
- ? ""
- : classifier, "jar", repoId );
- StorageAsset file = managedRepositoryContent.toFile( archivaArtifact );
+ ArchivaItemSelector itemSelector = ArchivaItemSelector.builder( ).withNamespace( groupId )
+ .withProjectId( artifactId ).withVersion( version ).withClassifier( StringUtils.isEmpty( classifier )
+ ? ""
+ : classifier )
+ .withType( "jar" )
+ .withArtifactId( artifactId ).build();
+ org.apache.archiva.repository.content.Artifact archivaArtifact = managedRepositoryContent.getItem( itemSelector ).adapt( org.apache.archiva.repository.content.Artifact.class );
+ StorageAsset file = archivaArtifact.getAsset( );
if ( file != null && file.exists() )
{
import org.apache.archiva.redback.users.UserManagerException;
import org.apache.archiva.redback.users.UserNotFoundException;
import org.apache.archiva.repository.ContentNotFoundException;
+import org.apache.archiva.repository.ManagedRepositoryContent;
import org.apache.archiva.repository.LayoutException;
import org.apache.archiva.repository.ManagedRepository;
-import org.apache.archiva.repository.ManagedRepositoryContent;
+import org.apache.archiva.repository.BaseRepositoryContentLayout;
import org.apache.archiva.repository.RepositoryException;
import org.apache.archiva.repository.RepositoryNotFoundException;
import org.apache.archiva.repository.RepositoryRegistry;
import org.apache.archiva.repository.RepositoryType;
+import org.apache.archiva.repository.content.ContentItem;
import org.apache.archiva.repository.content.ItemNotFoundException;
import org.apache.archiva.repository.content.Version;
import org.apache.archiva.repository.content.base.ArchivaItemSelector;
}
}
- private ManagedRepositoryContent getManagedRepositoryContent(String id) throws RepositoryException
+ private ManagedRepositoryContent getManagedRepositoryContent( String id) throws RepositoryException
{
org.apache.archiva.repository.ManagedRepository repo = repositoryRegistry.getManagedRepository( id );
if (repo==null) {
ManagedRepositoryContent sourceRepository =
getManagedRepositoryContent( artifactTransferRequest.getRepositoryId() );
-
- String artifactSourcePath = sourceRepository.toPath( artifactReference );
+ BaseRepositoryContentLayout layout = sourceRepository.getLayout( BaseRepositoryContentLayout.class );
+ String artifactSourcePath = layout.toPath( artifactReference );
if ( StringUtils.isEmpty( artifactSourcePath ) )
{
ManagedRepositoryContent targetRepository =
getManagedRepositoryContent( artifactTransferRequest.getTargetRepositoryId() );
- String artifactPath = targetRepository.toPath( artifactReference );
+ String artifactPath = layout.toPath( artifactReference );
int lastIndex = artifactPath.lastIndexOf( '/' );
log.debug("copyArtifact {}", msg);
}
- catch ( RepositoryException e )
+ catch ( RepositoryException | LayoutException e )
{
log.error( "RepositoryException: {}", e.getMessage(), e );
throw new ArchivaRestServiceException( e.getMessage(), e );
try
{
ManagedRepositoryContent repository = getManagedRepositoryContent( repositoryId );
-
+ BaseRepositoryContentLayout layout = repository.getLayout( BaseRepositoryContentLayout.class );
ArchivaItemSelector selector = ArchivaItemSelector.builder( )
.withNamespace( namespace )
.withProjectId( projectId )
.withVersion( version )
.build( );
- Version versionItem = repository.getVersion( selector );
+ Version versionItem = layout.getVersion( selector );
if (versionItem!=null && versionItem.exists()) {
repository.deleteItem( versionItem );
}
metadataRepository.removeProjectVersion(repositorySession , repositoryId, namespace, projectId, version );
}
- catch ( MetadataRepositoryException | MetadataResolutionException | RepositoryException | ItemNotFoundException e )
+ catch ( MetadataRepositoryException | MetadataResolutionException | RepositoryException | ItemNotFoundException | LayoutException e )
{
throw new ArchivaRestServiceException( "Repository exception: " + e.getMessage(), 500, e );
}
ref.setVersion( artifact.getVersion() );
ManagedRepositoryContent repository = getManagedRepositoryContent( repositoryId );
+ BaseRepositoryContentLayout layout = repository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifactReference = new ArtifactReference();
artifactReference.setArtifactId( artifact.getArtifactId() );
MetadataRepository metadataRepository = repositorySession.getRepository();
- String path = repository.toMetadataPath( ref );
+ String path = layout.toMetadataPath( ref );
if ( StringUtils.isNotBlank( artifact.getClassifier() ) )
{
throw new ArchivaRestServiceException( "You must configure a type/packaging when using classifier",
400, null );
}
- List<? extends org.apache.archiva.repository.content.Artifact> artifactItems = repository.getArtifacts( selector );
+ List<? extends org.apache.archiva.repository.content.Artifact> artifactItems = layout.getArtifacts( selector );
for ( org.apache.archiva.repository.content.Artifact aRef : artifactItems ) {
try
{
// delete from file system
if ( !snapshotVersion )
{
- repository.deleteVersion( ref );
+ layout.deleteVersion( ref );
}
else
{
// We are deleting all version related artifacts for a snapshot version
- VersionedReference versionRef = repository.toVersion( artifactReference );
- List<ArtifactReference> related = repository.getRelatedArtifacts( versionRef );
+ VersionedReference versionRef = layout.toVersion( artifactReference );
+ List<ArtifactReference> related = layout.getRelatedArtifacts( versionRef );
log.debug( "related: {}", related );
for ( ArtifactReference artifactRef : related )
{
try
{
- repository.deleteArtifact( artifactRef );
+ layout.deleteArtifact( artifactRef );
} catch (ContentNotFoundException e) {
log.warn( "Artifact that should be deleted, was not found: {}", artifactRef );
}
try
{
ManagedRepositoryContent repository = getManagedRepositoryContent( repositoryId );
-
- repository.deleteGroupId( groupId );
+ ArchivaItemSelector itemselector = ArchivaItemSelector.builder( ).withNamespace( groupId ).build();
+ ContentItem item = repository.getItem( itemselector );
+ repository.deleteItem( item );
MetadataRepository metadataRepository = repositorySession.getRepository();
log.error( e.getMessage(), e );
throw new ArchivaRestServiceException( "Repository exception: " + e.getMessage(), 500, e );
}
+ catch ( ItemNotFoundException e )
+ {
+ log.error( "Item not found {}", e.getMessage(), e );
+ throw new ArchivaRestServiceException( "Repository exception: " + e.getMessage(), 500, e );
+ }
finally
{
try
{
ManagedRepositoryContent repository = getManagedRepositoryContent( repositoryId );
+ ArchivaItemSelector itemSelector = ArchivaItemSelector.builder( ).withNamespace( groupId )
+ .withProjectId( projectId ).build( );
+ ContentItem item = repository.getItem( itemSelector );
- repository.deleteProject( groupId, projectId );
+ repository.deleteItem( item );
}
catch ( ContentNotFoundException e )
{
log.error( e.getMessage(), e );
throw new ArchivaRestServiceException( "Repository exception: " + e.getMessage(), 500, e );
}
+ catch ( ItemNotFoundException e )
+ {
+ log.error( "Item not found {}", e.getMessage(), e );
+ throw new ArchivaRestServiceException( "Repository exception: " + e.getMessage(), 500, e );
+ }
try
{
import org.apache.archiva.metadata.model.ArtifactMetadata;
import org.apache.archiva.metadata.maven.model.MavenArtifactFacet;
import org.apache.archiva.model.ArtifactReference;
+import org.apache.archiva.repository.BaseRepositoryContentLayout;
import org.apache.archiva.repository.ManagedRepositoryContent;
+import org.apache.archiva.repository.LayoutException;
import org.apache.archiva.repository.storage.StorageAsset;
import org.apache.archiva.repository.storage.util.StorageUtil;
ref.setClassifier( classifier );
ref.setType( type );
- StorageAsset file = managedRepositoryContent.toFile( ref );
+ BaseRepositoryContentLayout layout;
+ try
+ {
+ layout = managedRepositoryContent.getLayout( BaseRepositoryContentLayout.class );
+ }
+ catch ( LayoutException e )
+ {
+ throw new RuntimeException( "Could not convert to layout " + e.getMessage( ) );
+ }
+ StorageAsset file = layout.toFile( ref );
String extension = getExtensionFromFile(file);
artifact.setPackaging( type );
artifact.setType( type );
artifact.setFileExtension( extension );
- artifact.setPath( managedRepositoryContent.toPath( ref ) );
+ artifact.setPath( layout.toPath( ref ) );
// TODO: find a reusable formatter for this
double s = this.artifactMetadata.getSize();
String symbol = "b";
import org.apache.archiva.model.ArtifactReference;
import org.apache.archiva.policies.ProxyDownloadException;
import org.apache.archiva.components.taskqueue.TaskQueueException;
-import org.apache.archiva.repository.ManagedRepository;
import org.apache.archiva.repository.ManagedRepositoryContent;
+import org.apache.archiva.repository.ManagedRepository;
import org.apache.archiva.metadata.audit.RepositoryListener;
import org.apache.archiva.scheduler.repository.model.RepositoryArchivaTaskScheduler;
import org.apache.archiva.scheduler.repository.model.RepositoryTask;
import org.apache.archiva.redback.system.SecuritySession;
import org.apache.archiva.redback.users.User;
import org.apache.archiva.redback.users.UserManager;
+import org.apache.archiva.repository.ManagedRepositoryContent;
import org.apache.archiva.repository.LayoutException;
import org.apache.archiva.repository.ManagedRepository;
-import org.apache.archiva.repository.ManagedRepositoryContent;
+import org.apache.archiva.repository.BaseRepositoryContentLayout;
import org.apache.archiva.repository.ReleaseScheme;
import org.apache.archiva.repository.RepositoryGroup;
import org.apache.archiva.repository.RepositoryRegistry;
repositoryRequestInfo = repo.getRequestInfo();
String logicalResource = getLogicalResource( archivaLocator, null, false );
resourcesInAbsolutePath.add(
- Paths.get( managedRepositoryContent.getRepoRoot(), logicalResource ).toAbsolutePath().toString() );
+ managedRepositoryContent.getRepository().getAsset( "" ).getFilePath().resolve(logicalResource ).toAbsolutePath().toString() );
}
logicalResource = logicalResource.substring( 1 );
}
resourcesInAbsolutePath.add(
- Paths.get( managedRepositoryContent.getRepoRoot(), logicalResource ).toAbsolutePath().toString() );
+ managedRepositoryContent.getRepository().getAsset( "" ).resolve( logicalResource ).getFilePath().toAbsolutePath().toString() );
}
catch ( DavException e )
{
ArtifactReference artifact = null;
try
{
- artifact = managedRepositoryContent.toArtifactReference( resourcePath );
+ BaseRepositoryContentLayout layout = managedRepositoryContent.getLayout( BaseRepositoryContentLayout.class );
+ artifact = layout.toArtifactReference( resourcePath );
if ( !VersionUtil.isSnapshot( artifact.getVersion() ) )
{
// check if artifact already exists and if artifact re-deployment to the repository is allowed
- if ( managedRepositoryContent.hasContent( artifact )
+ if ( layout.hasContent( artifact )
&& managedRepositoryContent.getRepository().blocksRedeployments())
{
log.warn( "Overwriting released artifacts in repository '{}' is not allowed.",
* create the collections themselves.
*/
- Path rootDirectory = Paths.get( managedRepositoryContent.getRepoRoot() );
- Path destDir = rootDirectory.resolve( logicalResource.getPath() ).getParent();
+ StorageAsset rootDirectory = managedRepositoryContent.getRepository( ).getAsset( "" );
+ StorageAsset destDir = rootDirectory.resolve( logicalResource.getPath() ).getParent();
- if ( !Files.exists(destDir) )
+ if ( !destDir.exists() )
{
try
{
- Files.createDirectories( destDir );
+ destDir.create();
}
catch ( IOException e )
{
log.error("Could not create directory {}: {}", destDir, e.getMessage(), e);
throw new DavException( HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Could not create directory "+destDir );
}
- String relPath = PathUtil.getRelative( rootDirectory.toAbsolutePath().toString(), destDir );
+ String relPath = PathUtil.getRelative( rootDirectory.getPath(), destDir.getPath() );
- log.debug( "Creating destination directory '{}' (current user '{}')", destDir.getFileName(),
+ log.debug( "Creating destination directory '{}' (current user '{}')", destDir.getName(),
activePrincipal );
triggerAuditEvent( request.getRemoteAddr(), managedRepositoryContent.getId(), relPath,
StorageAsset proxiedFile = proxyHandler.fetchFromProxies( managedRepository, artifact );
- resource.setPath( managedRepository.getContent().toPath( artifact ) );
+ resource.setPath( managedRepository.getContent().getLayout( BaseRepositoryContentLayout.class ).toPath( artifact ) );
log.debug( "Proxied artifact '{}:{}:{}'", artifact.getGroupId(), artifact.getArtifactId(),
artifact.getVersion() );
import org.apache.archiva.repository.maven.metadata.storage.ArtifactMappingProvider;
import org.apache.archiva.proxy.ProxyRegistry;
import org.apache.archiva.repository.EditableManagedRepository;
-import org.apache.archiva.repository.ManagedRepositoryContent;
+import org.apache.archiva.repository.BaseRepositoryContentLayout;
import org.apache.archiva.repository.RemoteRepository;
import org.apache.archiva.repository.RemoteRepositoryContent;
import org.apache.archiva.repository.Repository;
return repoConfig;
}
- private ManagedRepositoryContent createManagedRepositoryContent( String repoId )
+ private BaseRepositoryContentLayout createManagedRepositoryContent( String repoId )
throws RepositoryAdminException
{
org.apache.archiva.repository.ManagedRepository repo = repositoryRegistry.getManagedRepository( repoId );
- ManagedRepositoryContent repoContent = new ManagedDefaultRepositoryContent(repo, artifactMappingProviders, fileTypes, fileLockManager);
+ BaseRepositoryContentLayout repoContent = new ManagedDefaultRepositoryContent(repo, artifactMappingProviders, fileTypes, fileLockManager);
if (repo!=null && repo instanceof EditableManagedRepository)
{
( (EditableManagedRepository) repo ).setContent( repoContent );
return repoContent;
}
- private RepositoryContentProvider createRepositoryContentProvider(ManagedRepositoryContent content) {
+ private RepositoryContentProvider createRepositoryContentProvider( BaseRepositoryContentLayout content) {
Set<RepositoryType> TYPES = new HashSet<>( );
TYPES.add(RepositoryType.MAVEN);
return new RepositoryContentProvider( )
}
@Override
- public ManagedRepositoryContent createManagedContent( org.apache.archiva.repository.ManagedRepository repository ) throws RepositoryException
+ public BaseRepositoryContentLayout createManagedContent( org.apache.archiva.repository.ManagedRepository repository ) throws RepositoryException
{
content.setRepository( repository );
return content;
+ "/org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar", LOCAL_REPO_GROUP,
new ArchivaDavLocatorFactory() );
- ManagedRepositoryContent internalRepo = createManagedRepositoryContent( INTERNAL_REPO );
- ManagedRepositoryContent releasesRepo = createManagedRepositoryContent( RELEASES_REPO );
+ BaseRepositoryContentLayout internalRepo = createManagedRepositoryContent( INTERNAL_REPO );
+ BaseRepositoryContentLayout releasesRepo = createManagedRepositoryContent( RELEASES_REPO );
try
{
config.setRepositoryGroups( repoGroups );
- ManagedRepositoryContent internalRepo = createManagedRepositoryContent( INTERNAL_REPO );
+ BaseRepositoryContentLayout internalRepo = createManagedRepositoryContent( INTERNAL_REPO );
- ManagedRepositoryContent releasesRepo = createManagedRepositoryContent( RELEASES_REPO );
+ BaseRepositoryContentLayout releasesRepo = createManagedRepositoryContent( RELEASES_REPO );
try
{
config.setRepositoryGroups( repoGroups );
- ManagedRepositoryContent internalRepo = createManagedRepositoryContent( INTERNAL_REPO );
- ManagedRepositoryContent localMirrorRepo = createManagedRepositoryContent( LOCAL_MIRROR_REPO );
+ BaseRepositoryContentLayout internalRepo = createManagedRepositoryContent( INTERNAL_REPO );
+ BaseRepositoryContentLayout localMirrorRepo = createManagedRepositoryContent( LOCAL_MIRROR_REPO );
repositoryRegistry.putRepositoryGroup( repoGroup );
new ArchivaDavResourceLocator( "", "/repository/" + INTERNAL_REPO + "/eclipse/jdtcore/maven-metadata.xml",
INTERNAL_REPO, new ArchivaDavLocatorFactory() );
- ManagedRepositoryContent internalRepo = createManagedRepositoryContent( INTERNAL_REPO );
+ BaseRepositoryContentLayout internalRepo = createManagedRepositoryContent( INTERNAL_REPO );
// use actual object (this performs the isMetadata, isDefault and isSupportFile check!)
MavenRepositoryRequestInfo repoRequest = new MavenRepositoryRequestInfo(internalRepo.getRepository() );
new ArchivaDavResourceLocator( "", "/repository/" + INTERNAL_REPO + "/eclipse/maven-metadata.xml",
INTERNAL_REPO, new ArchivaDavLocatorFactory() );
- ManagedRepositoryContent internalRepo = createManagedRepositoryContent( INTERNAL_REPO );
+ BaseRepositoryContentLayout internalRepo = createManagedRepositoryContent( INTERNAL_REPO );
try
{
public void testRequestMetadataRepoIsLegacy()
throws Exception
{
- ManagedRepositoryContent legacyRepo = createManagedRepositoryContent( LEGACY_REPO );
+ BaseRepositoryContentLayout legacyRepo = createManagedRepositoryContent( LEGACY_REPO );
ConfigurableListableBeanFactory beanFactory = ((ConfigurableApplicationContext) applicationContext).getBeanFactory();
RepositoryContentProvider provider = createRepositoryContentProvider(legacyRepo );
beanFactory.registerSingleton("repositoryContentProvider#legacy", provider);
import org.apache.archiva.filter.Filter;
import org.apache.archiva.model.ArtifactReference;
import org.apache.archiva.policies.ProxyDownloadException;
-import org.apache.archiva.repository.ManagedRepository;
import org.apache.archiva.repository.ManagedRepositoryContent;
+import org.apache.archiva.repository.ManagedRepository;
import org.apache.archiva.xml.XMLException;
import java.io.IOException;
import org.apache.archiva.metadata.repository.storage.RepositoryStorageRuntimeException;
import org.apache.archiva.model.ArtifactReference;
import org.apache.archiva.policies.ProxyDownloadException;
-import org.apache.archiva.repository.ManagedRepository;
import org.apache.archiva.repository.ManagedRepositoryContent;
+import org.apache.archiva.repository.ManagedRepository;
import org.apache.archiva.metadata.audit.RepositoryListener;
import org.apache.archiva.xml.XMLException;