/**
* @author Olivier Lamy
*/
-@Service( "fileUploadService#rest" )
+@Service("fileUploadService#rest")
public class DefaultFileUploadService
extends AbstractRestService
implements FileUploadService
private ChecksumAlgorithm[] algorithms = new ChecksumAlgorithm[]{ ChecksumAlgorithm.SHA1, ChecksumAlgorithm.MD5 };
@Inject
- @Named( value = "archivaTaskScheduler#repository" )
+ @Named(value = "archivaTaskScheduler#repository")
private ArchivaTaskScheduler scheduler;
private String getStringValue( MultipartBody multipartBody, String attachmentId )
{
String classifier = getStringValue( multipartBody, "classifier" );
+ String packaging = getStringValue( multipartBody, "packaging" );
// skygo: http header form pomFile was once sending 1 for true and void for false
// leading to permanent false value for pomFile if using toBoolean(); use , "1", ""
boolean pomFile = BooleanUtils.toBoolean( getStringValue( multipartBody, "pomFile" ) );
fileMetadata.setClassifier( classifier );
fileMetadata.setDeleteUrl( tmpFile.getName() );
fileMetadata.setPomFile( pomFile );
+ fileMetadata.setPackaging( packaging );
log.info( "uploading file: {}", fileMetadata );
{
File file = new File( SystemUtils.getJavaIoTmpDir(), fileName );
log.debug( "delete file:{},exists:{}", file.getPath(), file.exists() );
- boolean removed = getSessionFileMetadatas().remove(
- new FileMetadata( SystemUtils.getJavaIoTmpDir().getPath() + "/" + fileName ) );
+ boolean removed = getSessionFileMetadatas().remove( new FileMetadata( fileName ) );
if ( file.exists() )
{
return file.delete();
List<FileMetadata> fileMetadatas = new ArrayList( getSessionFileMetadatas() );
for ( FileMetadata fileMetadata : fileMetadatas )
{
- deleteFile( new File( fileMetadata.getServerFileName() ).getName() );
+ deleteFile( new File( fileMetadata.getServerFileName() ).getPath() );
}
+ getSessionFileMetadatas().clear();
return Boolean.TRUE;
}
return fileMetadatas == null ? Collections.<FileMetadata>emptyList() : fileMetadatas;
}
- public Boolean save( String repositoryId, String groupId, String artifactId, String version,
- String packaging, boolean generatePom )
+ public Boolean save( String repositoryId, String groupId, String artifactId, String version, String packaging,
+ boolean generatePom )
throws ArchivaRestServiceException
{
repositoryId = StringUtils.trim( repositoryId );
artifactReference.setGroupId( groupId );
artifactReference.setVersion( version );
artifactReference.setClassifier( fileMetadata.getClassifier() );
- artifactReference.setType( packaging );
+ artifactReference.setType(
+ StringUtils.isEmpty( fileMetadata.getPackaging() ) ? packaging : fileMetadata.getPackaging() );
ManagedRepositoryContent repository = repositoryFactory.getManagedRepositoryContent( repositoryId );
}
catch ( IOException ie )
{
+ log.error( "IOException copying file: {}", ie.getMessage(), ie );
throw new ArchivaRestServiceException(
"Overwriting released artifacts in repository '" + repoConfig.getId() + "' is not allowed.",
Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), ie );
private String classifier;
+ private String packaging;
+
private boolean pomFile;
public FileMetadata()
this.serverFileName = serverFileName;
}
+ public String getPackaging()
+ {
+ return packaging;
+ }
+
+ public void setPackaging( String packaging )
+ {
+ this.packaging = packaging;
+ }
+
@Override
public boolean equals( Object o )
{
@Override
public String toString()
{
- final StringBuilder sb = new StringBuilder();
- sb.append( "FileMetadata" );
- sb.append( "{name='" ).append( name ).append( '\'' );
+ final StringBuilder sb = new StringBuilder( "FileMetadata{" );
+ sb.append( "name='" ).append( name ).append( '\'' );
sb.append( ", serverFileName='" ).append( serverFileName ).append( '\'' );
sb.append( ", size=" ).append( size );
sb.append( ", url='" ).append( url ).append( '\'' );
sb.append( ", deleteType='" ).append( deleteType ).append( '\'' );
sb.append( ", errorKey='" ).append( errorKey ).append( '\'' );
sb.append( ", classifier='" ).append( classifier ).append( '\'' );
+ sb.append( ", packaging='" ).append( packaging ).append( '\'' );
sb.append( ", pomFile=" ).append( pomFile );
sb.append( '}' );
return sb.toString();