archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/maven/content/ManagedDefaultRepositoryContent.java
/**
     * Removes the item from the filesystem. For namespaces, projects and versions it deletes
     * recursively.
     * For namespaces you have to be careful, because maven repositories may have sub namespaces
     * parallel to projects. Which means deleting a namespaces also deletes the sub namespaces and
     * not only the projects of the given namespace. Better run the delete for each project of
     * a namespace.
     *
     * Artifacts are deleted as provided. No related artifacts will be deleted.
     *
     * @param item the item that should be removed
     * @throws ItemNotFoundException if the item does not exist
     * @throws ContentAccessException if some error occurred while accessing the filesystem
     */
Removes the item from the filesystem. For namespaces, projects and versions it deletes
recursively.
For namespaces you have to be careful, because maven repositories may have sub namespaces
parallel to projects. Which means deleting a namespaces also deletes the sub namespaces and
not only the projects of the given namespace. Better run the delete for each project of
a namespace.

Artifacts are deleted as provided. No related artifacts will be deleted.

@param item the item that should be removed
@throws ItemNotFoundException if the item does not exist
@throws ContentAccessException if some error occurred while accessing the filesystem
Removes the item from the filesystem . For namespaces projects and versions it deletes recursively . For namespaces you have to be careful because maven repositories may have sub namespaces parallel to projects . Which means deleting a namespaces also deletes the sub namespaces and not only the projects of the given namespace . Better run the delete for each project of a namespace . Artifacts are deleted as provided . No related artifacts will be deleted . @param item the item that should be removed @throws ItemNotFoundException if the item does not exist @throws ContentAccessException if some error occurred while accessing the filesystem
@Override
    public void deleteItem( ContentItem item ) throws ItemNotFoundException, ContentAccessException
    {
        final Path baseDirectory = getRepoDir( );
        final Path itemPath = item.getAsset( ).getFilePath( );
        if ( !Files.exists( itemPath ) )
        {
            throw new ItemNotFoundException( "The item " + item.toString() + "does not exist in the repository " + getId( ) );
        }
        if ( !itemPath.toAbsolutePath().startsWith( baseDirectory.toAbsolutePath() ) )
        {
            log.error( "The namespace {} to delete from repository {} is not a subdirectory of the repository base.", item, getId( ) );
            log.error( "Namespace directory: {}", itemPath );
            log.error( "Repository directory: {}", baseDirectory );
            throw new ContentAccessException( "Inconsistent directories found. Could not delete namespace." );
        }
        try
        {
            if (Files.isDirectory( itemPath ))
            {
                FileUtils.deleteDirectory( itemPath );
            } else {
                Files.deleteIfExists( itemPath );
            }
        }
        catch ( IOException e )
        {
            log.error( "Could not delete item from path {}: {}", itemPath, e.getMessage( ), e );
            throw new ContentAccessException( "Error occured while deleting item " + item + ": " + e.getMessage( ), e );
        }
    }
@ Override public void deleteItem ( ContentItem item ) throws ItemNotFoundException , ContentAccessException { final Path baseDirectory = getRepoDir ( ) ; final Path itemPath = item . getAsset ( ) . getFilePath ( ) ; if ( ! Files . exists ( itemPath ) ) { throw new ItemNotFoundException ( "The item " + item . toString ( ) + "does not exist in the repository " + getId ( ) ) ; } if ( ! itemPath . toAbsolutePath ( ) . startsWith ( baseDirectory . toAbsolutePath ( ) ) ) { log . error ( "The namespace {} to delete from repository {} is not a subdirectory of the repository base." , item , getId ( ) ) ; log . error ( "Namespace directory: {}" , itemPath ) ; log . error ( "Repository directory: {}" , baseDirectory ) ; throw new ContentAccessException ( "Inconsistent directories found. Could not delete namespace." ) ; } try { if ( Files . isDirectory ( itemPath ) ) { FileUtils . deleteDirectory ( itemPath ) ; } else { Files . deleteIfExists ( itemPath ) ; } } catch ( IOException e ) { log . error ( "Could not delete item from path {}: {}" , itemPath , e . getMessage ( ) , e ) ; throw new ContentAccessException ( "Error occured while deleting item " + item + ": " + e . getMessage ( ) , e ) ; } }
Removes the item from the filesystem.
Removes the item from the filesystem .