formatting only

git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/MRM-1025@885816 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Porter 2009-12-01 16:17:08 +00:00
parent 52bcd1b58b
commit cfabf95ff6
1 changed files with 21 additions and 20 deletions

View File

@ -292,8 +292,7 @@ public class UploadAction
try try
{ {
Configuration config = configuration.getConfiguration(); Configuration config = configuration.getConfiguration();
ManagedRepositoryConfiguration repoConfig = ManagedRepositoryConfiguration repoConfig = config.findManagedRepositoryById( repositoryId );
config.findManagedRepositoryById( repositoryId );
ArtifactReference artifactReference = new ArtifactReference(); ArtifactReference artifactReference = new ArtifactReference();
artifactReference.setArtifactId( artifactId ); artifactReference.setArtifactId( artifactId );
@ -345,20 +344,22 @@ public class UploadAction
filename = filename.replaceAll( "SNAPSHOT", timestamp + "-" + newBuildNumber ); filename = filename.replaceAll( "SNAPSHOT", timestamp + "-" + newBuildNumber );
} }
boolean fixChecksums = !( config.getRepositoryScanning().getKnownContentConsumers().contains( "create-missing-checksums" ) ); boolean fixChecksums =
!( config.getRepositoryScanning().getKnownContentConsumers().contains( "create-missing-checksums" ) );
try try
{ {
File targetFile = new File( targetPath, filename ); File targetFile = new File( targetPath, filename );
if( targetFile.exists() && !VersionUtil.isSnapshot( version ) && repoConfig.isBlockRedeployments() ) if ( targetFile.exists() && !VersionUtil.isSnapshot( version ) && repoConfig.isBlockRedeployments() )
{ {
addActionError( "Overwriting released artifacts in repository '" + repoConfig.getId() + "' is not allowed." ); addActionError(
"Overwriting released artifacts in repository '" + repoConfig.getId() + "' is not allowed." );
return ERROR; return ERROR;
} }
else else
{ {
copyFile( artifactFile, targetPath, filename, fixChecksums ); copyFile( artifactFile, targetPath, filename, fixChecksums );
queueRepositoryTask( repository.getId(), repository.toFile( artifactReference ) ); queueRepositoryTask( repository.getId(), repository.toFile( artifactReference ) );
} }
} }
catch ( IOException ie ) catch ( IOException ie )
@ -373,17 +374,17 @@ public class UploadAction
pomFilename = StringUtils.remove( pomFilename, "-" + classifier ); pomFilename = StringUtils.remove( pomFilename, "-" + classifier );
} }
pomFilename = FilenameUtils.removeExtension( pomFilename ) + ".pom"; pomFilename = FilenameUtils.removeExtension( pomFilename ) + ".pom";
if ( generatePom ) if ( generatePom )
{ {
try try
{ {
File generatedPomFile = createPom( targetPath, pomFilename ); File generatedPomFile = createPom( targetPath, pomFilename );
if( fixChecksums ) if ( fixChecksums )
{ {
fixChecksums( generatedPomFile ); fixChecksums( generatedPomFile );
} }
queueRepositoryTask( repoConfig.getId(), generatedPomFile ); queueRepositoryTask( repoConfig.getId(), generatedPomFile );
} }
catch ( IOException ie ) catch ( IOException ie )
{ {
@ -400,7 +401,7 @@ public class UploadAction
if ( pomFile != null && pomFile.length() > 0 ) if ( pomFile != null && pomFile.length() > 0 )
{ {
try try
{ {
copyFile( pomFile, targetPath, pomFilename, fixChecksums ); copyFile( pomFile, targetPath, pomFilename, fixChecksums );
queueRepositoryTask( repoConfig.getId(), new File( targetPath, pomFilename ) ); queueRepositoryTask( repoConfig.getId(), new File( targetPath, pomFilename ) );
} }
@ -413,7 +414,7 @@ public class UploadAction
} }
// explicitly update only if metadata-updater consumer is not enabled! // explicitly update only if metadata-updater consumer is not enabled!
if( !config.getRepositoryScanning().getKnownContentConsumers().contains( "metadata-updater" ) ) if ( !config.getRepositoryScanning().getKnownContentConsumers().contains( "metadata-updater" ) )
{ {
updateMetadata( metadata, metadataFile, lastUpdatedTimestamp, timestamp, newBuildNumber, fixChecksums ); updateMetadata( metadata, metadataFile, lastUpdatedTimestamp, timestamp, newBuildNumber, fixChecksums );
} }
@ -439,13 +440,13 @@ public class UploadAction
return ERROR; return ERROR;
} }
} }
private void fixChecksums( File file ) private void fixChecksums( File file )
{ {
ChecksummedFile checksum = new ChecksummedFile( file ); ChecksummedFile checksum = new ChecksummedFile( file );
checksum.fixChecksums( algorithms ); checksum.fixChecksums( algorithms );
} }
private void copyFile( File sourceFile, File targetPath, String targetFilename, boolean fixChecksums ) private void copyFile( File sourceFile, File targetPath, String targetFilename, boolean fixChecksums )
throws IOException throws IOException
{ {
@ -466,8 +467,8 @@ public class UploadAction
out.close(); out.close();
input.close(); input.close();
} }
if( fixChecksums ) if ( fixChecksums )
{ {
fixChecksums( new File( targetPath, targetFilename ) ); fixChecksums( new File( targetPath, targetFilename ) );
} }
@ -507,7 +508,7 @@ public class UploadAction
} }
/** /**
* Update artifact level metadata. If it does not exist, create the metadata and * Update artifact level metadata. If it does not exist, create the metadata and
* fix checksums if necessary. * fix checksums if necessary.
*/ */
private void updateMetadata( ArchivaRepositoryMetadata metadata, File metadataFile, Date lastUpdatedTimestamp, private void updateMetadata( ArchivaRepositoryMetadata metadata, File metadataFile, Date lastUpdatedTimestamp,
@ -563,8 +564,8 @@ public class UploadAction
} }
RepositoryMetadataWriter.write( metadata, metadataFile ); RepositoryMetadataWriter.write( metadata, metadataFile );
if( fixChecksums ) if ( fixChecksums )
{ {
fixChecksums( metadataFile ); fixChecksums( metadataFile );
} }