mirror of https://github.com/apache/archiva.git
[MRM-1769]Can't uploads multiple artifacts of different types
fix issue deleting temporary files git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1546471 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
91cc505d00
commit
4f7f1d74f9
|
@ -85,7 +85,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
|||
/**
|
||||
* @author Olivier Lamy
|
||||
*/
|
||||
@Service( "fileUploadService#rest" )
|
||||
@Service("fileUploadService#rest")
|
||||
public class DefaultFileUploadService
|
||||
extends AbstractRestService
|
||||
implements FileUploadService
|
||||
|
@ -107,7 +107,7 @@ public class DefaultFileUploadService
|
|||
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 )
|
||||
|
@ -125,6 +125,7 @@ public class DefaultFileUploadService
|
|||
{
|
||||
|
||||
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" ) );
|
||||
|
@ -142,6 +143,7 @@ public class DefaultFileUploadService
|
|||
fileMetadata.setClassifier( classifier );
|
||||
fileMetadata.setDeleteUrl( tmpFile.getName() );
|
||||
fileMetadata.setPomFile( pomFile );
|
||||
fileMetadata.setPackaging( packaging );
|
||||
|
||||
log.info( "uploading file: {}", fileMetadata );
|
||||
|
||||
|
@ -181,8 +183,7 @@ public class DefaultFileUploadService
|
|||
{
|
||||
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();
|
||||
|
@ -196,8 +197,9 @@ public class DefaultFileUploadService
|
|||
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;
|
||||
}
|
||||
|
||||
|
@ -210,8 +212,8 @@ public class DefaultFileUploadService
|
|||
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 );
|
||||
|
@ -362,7 +364,8 @@ public class DefaultFileUploadService
|
|||
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 );
|
||||
|
||||
|
@ -430,6 +433,7 @@ public class DefaultFileUploadService
|
|||
}
|
||||
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 );
|
||||
|
|
|
@ -45,6 +45,8 @@ public class FileMetadata
|
|||
|
||||
private String classifier;
|
||||
|
||||
private String packaging;
|
||||
|
||||
private boolean pomFile;
|
||||
|
||||
public FileMetadata()
|
||||
|
@ -157,6 +159,16 @@ public class FileMetadata
|
|||
this.serverFileName = serverFileName;
|
||||
}
|
||||
|
||||
public String getPackaging()
|
||||
{
|
||||
return packaging;
|
||||
}
|
||||
|
||||
public void setPackaging( String packaging )
|
||||
{
|
||||
this.packaging = packaging;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals( Object o )
|
||||
{
|
||||
|
@ -188,9 +200,8 @@ public class FileMetadata
|
|||
@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( '\'' );
|
||||
|
@ -198,6 +209,7 @@ public class FileMetadata
|
|||
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();
|
||||
|
|
|
@ -734,7 +734,8 @@
|
|||
{% for (var i=0, file; file=o.files[i]; i++) { %}
|
||||
<tr class="template-upload">
|
||||
<td class="name"><span>{%=file.name%}</span></td>
|
||||
<td><input type="text" id="classifier" name="classifier" placeholder="classifier" value=""/></td>
|
||||
<td><input type="text" class="input-small" id="classifier" name="classifier" placeholder="classifier" value=""/></td>
|
||||
<td><input type="text" class="input-small" id="packaging" name="packaging" placeholder="packaging" value=""></td>
|
||||
<td><span>pomFile:</span><input type="checkbox" id="pomFile" name="pomFile"/></td>
|
||||
<td class="size"><span>{%=o.formatFileSize(file.size)%}</span></td>
|
||||
{% if (file.error) { %}
|
||||
|
|
Loading…
Reference in New Issue