private static void populateArtifactMetadataFromFile( ArtifactMetadata metadata, Path file ) throws IOException { metadata.setWhenGathered( new Date() ); metadata.setFileLastModified( Files.getLastModifiedTime(file).toMillis() ); ChecksummedFile checksummedFile = new ChecksummedFile( file ); try { metadata.setMd5( checksummedFile.calculateChecksum( ChecksumAlgorithm.MD5 ) ); } catch ( IOException e ) { LOGGER.error( "Unable to checksum file {}: {},MD5", file, e.getMessage() ); } try { metadata.setSha1( checksummedFile.calculateChecksum( ChecksumAlgorithm.SHA1 ) ); } catch ( IOException e ) { LOGGER.error( "Unable to checksum file {}: {},SHA1", file, e.getMessage() ); } metadata.setSize( Files.size(file) ); }
private static void populateArtifactMetadataFromFile( ArtifactMetadata metadata, File file ) { metadata.setWhenGathered( new Date() ); metadata.setFileLastModified( file.lastModified() ); ChecksummedFile checksummedFile = new ChecksummedFile( file ); try { metadata.setMd5( checksummedFile.calculateChecksum( ChecksumAlgorithm.MD5 ) ); } catch ( IOException e ) { LOGGER.error( "Unable to checksum file {}: {},MD5", file, e.getMessage() ); } try { metadata.setSha1( checksummedFile.calculateChecksum( ChecksumAlgorithm.SHA1 ) ); } catch ( IOException e ) { LOGGER.error( "Unable to checksum file {}: {},SHA1", file, e.getMessage() ); } metadata.setSize( file.length() ); }
artifact.setSize( Long.valueOf( value ) );
artifact.setSize( Long.valueOf( value ) );
artifact.setSize( artifactNode.getProperty( "size" ).getLong() );
artifact.setSize( artifactNode.getProperty( "size" ).getLong() );
protected ArtifactMetadata mapArtifactMetadataStringColumnSlice( ColumnSlice<String, String> columnSlice ) { ArtifactMetadata artifactMetadata = new ArtifactMetadata(); artifactMetadata.setNamespace( getStringValue( columnSlice, NAMESPACE_ID.toString() ) ); artifactMetadata.setSize( getAsLongValue( columnSlice, SIZE.toString() ) ); artifactMetadata.setId( getStringValue( columnSlice, ID.toString() ) ); artifactMetadata.setFileLastModified( getAsLongValue( columnSlice, FILE_LAST_MODIFIED.toString() ) ); artifactMetadata.setMd5( getStringValue( columnSlice, MD5.toString() ) ); artifactMetadata.setProject( getStringValue( columnSlice, PROJECT.toString() ) ); artifactMetadata.setProjectVersion( getStringValue( columnSlice, PROJECT_VERSION.toString() ) ); artifactMetadata.setRepositoryId( getStringValue( columnSlice, REPOSITORY_NAME.toString() ) ); artifactMetadata.setSha1( getStringValue( columnSlice, SHA1.toString() ) ); artifactMetadata.setVersion( getStringValue( columnSlice, VERSION.toString() ) ); Long whenGathered = getAsLongValue( columnSlice, WHEN_GATHERED.toString() ); if ( whenGathered != null ) { artifactMetadata.setWhenGathered( new Date( whenGathered ) ); } return artifactMetadata; }
protected ArtifactMetadata mapArtifactMetadataLongColumnSlice( ColumnSlice<String, Long> columnSlice ) { ArtifactMetadata artifactMetadata = new ArtifactMetadata(); artifactMetadata.setNamespace( getAsStringValue( columnSlice, NAMESPACE_ID.toString() ) ); artifactMetadata.setSize( getLongValue( columnSlice, SIZE.toString() ) ); artifactMetadata.setId( getAsStringValue( columnSlice, ID.toString() ) ); artifactMetadata.setFileLastModified( getLongValue( columnSlice, FILE_LAST_MODIFIED.toString() ) ); artifactMetadata.setMd5( getAsStringValue( columnSlice, MD5.toString() ) ); artifactMetadata.setProject( getAsStringValue( columnSlice, PROJECT.toString() ) ); artifactMetadata.setProjectVersion( getAsStringValue( columnSlice, PROJECT_VERSION.toString() ) ); artifactMetadata.setRepositoryId( getAsStringValue( columnSlice, REPOSITORY_NAME.toString() ) ); artifactMetadata.setSha1( getAsStringValue( columnSlice, SHA1.toString() ) ); artifactMetadata.setVersion( getAsStringValue( columnSlice, VERSION.toString() ) ); Long whenGathered = getLongValue( columnSlice, WHEN_GATHERED.toString() ); if ( whenGathered != null ) { artifactMetadata.setWhenGathered( new Date( whenGathered ) ); } return artifactMetadata; }