*/
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.
*/
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 );
-
}
* 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;
return repository;
}
- @Override
- public boolean hasContent( ArtifactReference reference ) throws ContentAccessException
- {
- return false;
- }
-
- @Override
- public boolean hasContent( VersionedReference reference ) throws ContentAccessException
- {
- return false;
- }
-
@Override
public void setRepository( ManagedRepository repo )
{
return null;
}
- @Override
- public StorageAsset toFile( ArchivaArtifact reference )
- {
- return null;
- }
-
@Override
public String toPath( ArtifactReference reference )
{
import org.apache.archiva.common.utils.VersionUtil;
import org.apache.archiva.metadata.model.ArtifactMetadata;
import org.apache.archiva.metadata.maven.model.MavenArtifactFacet;
-import org.apache.archiva.model.ArchivaArtifact;
import org.apache.archiva.model.ArtifactReference;
import org.apache.archiva.model.ProjectReference;
import org.apache.archiva.model.VersionedReference;
return repository;
}
- @Override
- public boolean hasContent( ArtifactReference reference ) throws ContentAccessException
- {
- return false;
- }
-
- @Override
- public boolean hasContent( VersionedReference reference ) throws ContentAccessException
- {
- return false;
- }
-
@Override
public void setRepository( ManagedRepository repo )
{
return getRepoRootAsset().resolve(refs.get(reference));
}
- @Override
- public StorageAsset toFile( ArchivaArtifact reference )
- {
- return null;
- }
-
private String formatAsDirectory( String directory )
{
return directory.replace( GROUP_SEPARATOR, PATH_SEPARATOR );
import org.apache.archiva.common.utils.VersionUtil;
import org.apache.archiva.metadata.model.ArtifactMetadata;
import org.apache.archiva.metadata.maven.model.MavenArtifactFacet;
-import org.apache.archiva.model.ArchivaArtifact;
import org.apache.archiva.model.ArtifactReference;
import org.apache.archiva.model.ProjectReference;
import org.apache.archiva.model.VersionedReference;
return repository;
}
- @Override
- public boolean hasContent( ArtifactReference reference ) throws ContentAccessException
- {
- return false;
- }
-
- @Override
- public boolean hasContent( VersionedReference reference ) throws ContentAccessException
- {
- return false;
- }
-
@Override
public void setRepository( ManagedRepository repo )
{
return getRepoRootAsset().resolve( refs.get(reference));
}
- @Override
- public StorageAsset toFile( ArchivaArtifact reference )
- {
- return null;
- }
-
private String formatAsDirectory( String directory )
{
return directory.replace( GROUP_SEPARATOR, PATH_SEPARATOR );
import org.apache.archiva.common.filelock.FileLockManager;
import org.apache.archiva.common.utils.FileUtils;
-import org.apache.archiva.common.utils.VersionUtil;
import org.apache.archiva.configuration.FileTypes;
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.ArtifactReference;
import org.apache.archiva.model.ProjectReference;
import org.apache.archiva.model.VersionedReference;
return repository;
}
- @Override
- public boolean hasContent( ArtifactReference reference ) throws ContentAccessException
- {
- StorageAsset artifactFile = toFile( reference );
- return artifactFile.exists( ) && !artifactFile.isContainer( );
- }
-
- @Override
- public boolean hasContent( VersionedReference reference ) throws ContentAccessException
- {
- try
- {
- return ( getFirstArtifact( reference ) != null );
- }
- catch ( LayoutException | ContentNotFoundException e )
- {
- return false;
- }
- catch ( IOException e )
- {
- String path = toPath( reference );
- log.error( "Could not read directory from repository {} - {}: ", getId( ), path, e.getMessage( ), e );
- throw new ContentAccessException( "Could not read path from repository " + getId( ) + ": " + path, e );
- }
- }
-
@Override
public void setRepository( final ManagedRepository repo )
{
return repository.getAsset( toPath( reference ) );
}
- @Override
- public StorageAsset toFile( ArchivaArtifact reference )
- {
- return repository.getAsset( toPath( reference ) );
- }
-
@Override
public StorageAsset toFile( VersionedReference reference )
{
import org.apache.archiva.repository.RepositoryGroup;
import org.apache.archiva.repository.RepositoryRegistry;
import org.apache.archiva.repository.RepositoryRequestInfo;
+import org.apache.archiva.repository.content.Artifact;
+import org.apache.archiva.repository.content.ContentItem;
import org.apache.archiva.repository.storage.fs.FilesystemStorage;
import org.apache.archiva.repository.storage.StorageAsset;
import org.apache.archiva.metadata.audit.AuditListener;
if ( managedRepositoryContent.getRepository().getActiveReleaseSchemes().contains( ReleaseScheme.RELEASE ) && !repositoryRequestInfo.isMetadata(
resourcePath ) && !repositoryRequestInfo.isSupportFile( resourcePath ) )
{
- ArtifactReference artifact = null;
+ // ArtifactReference artifact = null;
+ Artifact artifact = null;
try
{
BaseRepositoryContentLayout layout = managedRepositoryContent.getLayout( BaseRepositoryContentLayout.class );
- artifact = managedRepositoryContent.toArtifactReference( resourcePath );
-
- if ( !VersionUtil.isSnapshot( artifact.getVersion() ) )
+ ContentItem artifactItem = managedRepositoryContent.toItem( resourcePath );
+ artifact = layout.adaptItem( Artifact.class, artifactItem );
+ if ( !VersionUtil.isSnapshot( artifact.getVersion().getVersion() ) )
{
// check if artifact already exists and if artifact re-deployment to the repository is allowed
- if ( layout.hasContent( artifact )
+ if ( artifactItem.exists()
&& managedRepositoryContent.getRepository().blocksRedeployments())
{
log.warn( "Overwriting released artifacts in repository '{}' is not allowed.",