private void deleteDirectoryQuiet( Path f ) { try { org.apache.archiva.common.utils.FileUtils.deleteDirectory( f ); } catch ( IOException e ) { log.warn( "skip error delete {} : {}", f, e.getMessage() ); } }
@Override public void deleteVersion( VersionedReference reference ) { String path = toMetadataPath( reference ); Path projectPath = Paths.get( getRepoRoot(), path ); Path projectDir = projectPath.getParent(); if ( Files.exists(projectDir) && Files.isDirectory(projectDir) ) { org.apache.archiva.common.utils.FileUtils.deleteQuietly( projectDir ); } }
/** * TODO: Remove in favor of using FileUtils directly. */ protected void writeStringToFile( Path file, String content ) throws IOException { org.apache.archiva.common.utils.FileUtils.writeStringToFile( file, Charset.defaultCharset(), content ); }
public ChecksumFileContent parseChecksumFile( Path checksumFile, ChecksumAlgorithm expectedHash, Charset encoding ) String rawChecksumString = FileUtils.readFileToString( checksumFile, encoding ); String trimmedChecksum = rawChecksumString.replace( '\n', ' ' ).trim( );
contents = org.apache.archiva.common.utils.FileUtils.readFileToString( file, Charset.defaultCharset() ); if ( !force && Files.exists( targetFile ) ) String targetContents = org.apache.archiva.common.utils.FileUtils.readFileToString( targetFile, Charset.defaultCharset( ) ); matching = targetContents.equals( contents );
protected void revertMkDirs() throws IOException { if ( createdDirs != null ) { Collections.reverse( createdDirs ); while ( !createdDirs.isEmpty() ) { Path dir = createdDirs.remove( 0 ); if ( Files.isDirectory(dir)) { try(Stream<Path> str = Files.list(dir)) { if (str.count()==0) { org.apache.archiva.common.utils.FileUtils.deleteDirectory(dir); } } } else { //cannot rollback created directory if it still contains files break; } } } }
private void createChecksumFile( String path, Digester digester ) throws DigesterException, IOException { Path checksumFile = Paths.get( path + digester.getFilenameExtension() ); if ( !Files.exists(checksumFile) ) { org.apache.archiva.common.utils.FileUtils.deleteQuietly( checksumFile ); checksum.createChecksum( Paths.get( path ).toFile(), digester ); } else if ( !Files.isRegularFile( checksumFile) ) { log.error( "Checksum file is not a file." ); } }
String metadataXml = org.apache.archiva.common.utils.FileUtils.readFileToString( artifactMetadataFile, Charset.defaultCharset() );
private void writeChecksumFile( Path checksumFile, Charset encoding, String checksumHex ) { FileUtils.writeStringToFile( checksumFile, FILE_ENCODING, checksumHex + " " + referenceFile.getFileName( ).toString( ) ); }
@Override public void removeProject( String repositoryId, String namespace, String projectId ) throws MetadataRepositoryException { try { Path directory = getDirectory( repositoryId ).resolve( namespace + "/" + projectId ); org.apache.archiva.common.utils.FileUtils.deleteDirectory( directory ); } catch ( IOException e ) { throw new MetadataRepositoryException( e.getMessage(), e ); } }
@Override public void deleteArtifact( ArtifactReference artifactReference ) { String path = toPath( artifactReference ); Path filePath = Paths.get( getRepoRoot(), path ); if ( Files.exists(filePath) ) { org.apache.archiva.common.utils.FileUtils.deleteQuietly( filePath ); } Path filePathmd5 = Paths.get( getRepoRoot(), path + ".md5" ); if ( Files.exists(filePathmd5) ) { org.apache.archiva.common.utils.FileUtils.deleteQuietly( filePathmd5 ); } Path filePathsha1 = Paths.get( getRepoRoot(), path + ".sha1" ); if ( Files.exists(filePathsha1) ) { org.apache.archiva.common.utils.FileUtils.deleteQuietly( filePathsha1 ); } }
String metadataXml = org.apache.archiva.common.utils.FileUtils.readFileToString( artifactMetadataFile, Charset.defaultCharset() );
@Override public void removeProjectVersion( String repoId, String namespace, String projectId, String projectVersion ) throws MetadataRepositoryException { try { Path directory = getDirectory( repoId ).resolve( namespace + "/" + projectId + "/" + projectVersion ); org.apache.archiva.common.utils.FileUtils.deleteDirectory( directory ); } catch ( IOException e ) { throw new MetadataRepositoryException( e.getMessage(), e ); } }
org.apache.archiva.common.utils.FileUtils.deleteQuietly(fileToMove);
String metadataXml = org.apache.archiva.common.utils.FileUtils.readFileToString( artifactMetadataFile, Charset.defaultCharset() );
@Override public void removeMetadataFacet( String repoId, String facetId, String name ) throws MetadataRepositoryException { try { Path dir = getMetadataDirectory( repoId, facetId ).resolve( name ); org.apache.archiva.common.utils.FileUtils.deleteDirectory( dir ); } catch ( IOException e ) { throw new MetadataRepositoryException( e.getMessage(), e ); } }
private Path writeMergedMetadataToFile( ArchivaRepositoryMetadata mergedMetadata, String outputFilename ) throws RepositoryMetadataException, DigesterException, IOException { Path outputFile = Paths.get( outputFilename ); if ( Files.exists(outputFile) ) { org.apache.archiva.common.utils.FileUtils.deleteQuietly( outputFile ); } Files.createDirectories(outputFile.getParent()); RepositoryMetadataWriter.write( mergedMetadata, outputFile ); createChecksumFile( outputFilename, digestSha1 ); createChecksumFile( outputFilename, digestMd5 ); return outputFile; }
String metadataXml = org.apache.archiva.common.utils.FileUtils.readFileToString( artifactMetadataFile, Charset.defaultCharset() );
@Override public void removeMetadataFacets( String repositoryId, String facetId ) throws MetadataRepositoryException { try { Path dir = getMetadataDirectory( repositoryId, facetId ); org.apache.archiva.common.utils.FileUtils.deleteDirectory( dir ); } catch ( IOException e ) { throw new MetadataRepositoryException( e.getMessage(), e ); } }
public static void write( ArchivaRepositoryMetadata metadata, Path outputFile ) throws RepositoryMetadataException { boolean thrown = false; try (FileWriter writer = new FileWriter( outputFile.toFile() )) { write( metadata, writer ); writer.flush(); } catch ( IOException e ) { thrown = true; throw new RepositoryMetadataException( "Unable to write metadata file: " + outputFile.toAbsolutePath() + " - " + e.getMessage(), e ); } finally { if ( thrown ) { FileUtils.deleteQuietly( outputFile ); } } }