mirror of https://github.com/apache/archiva.git
[MRM-1586] rewrite upload artifact page some progress on uploading ui
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1306261 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
6c8e792aec
commit
93ff501274
|
@ -377,11 +377,14 @@ appearance-configuration.updated=Appearance has been updated
|
|||
appearance-configuration.updating-error=Error during appearance setting
|
||||
|
||||
#file upload
|
||||
fileupload.header=Upload Artifact
|
||||
fileupload.file.choose=Choose File
|
||||
menu.artifacts.upload=Upload Artifact
|
||||
fileupload.cancel=Cancel Upload
|
||||
fileupload.start=Start Upload
|
||||
fileupload.error=Error Upload
|
||||
fileupload.destroy=Delete Upload
|
||||
fileupload.delete=Delete Upload
|
||||
fileupload.errors.maxFileSize=File is too big
|
||||
fileupload.errors.minFileSize=File is too small
|
||||
fileupload.errors.acceptFileTypes=Filetype not allowed
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.apache.archiva.webapp.ui.services.api;
|
|||
import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
|
||||
import org.apache.archiva.webapp.ui.services.model.FileMetadata;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang.SystemUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -29,6 +30,8 @@ import javax.servlet.http.HttpServletRequest;
|
|||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.Response;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
|
@ -46,14 +49,19 @@ public class DefaultFileUploadService
|
|||
@Context
|
||||
private HttpServletResponse httpServletResponse;
|
||||
|
||||
public FileMetadata post()
|
||||
public FileMetadata post( String groupId, String artifactId, String version, String packaging, String classifier,
|
||||
String repositoryId, String generatePom )
|
||||
throws ArchivaRestServiceException
|
||||
{
|
||||
log.info( "uploading file" );
|
||||
log.info( "uploading file:" + groupId + ":" + artifactId + ":" + version );
|
||||
try
|
||||
{
|
||||
byte[] bytes = IOUtils.toByteArray( httpServletRequest.getInputStream() );
|
||||
return new FileMetadata( "thefile", bytes.length, "theurl" );
|
||||
File file = File.createTempFile( "upload-artifact", "tmp" );
|
||||
file.deleteOnExit();
|
||||
IOUtils.copy( httpServletRequest.getInputStream(), new FileOutputStream( file ) );
|
||||
FileMetadata fileMetadata = new FileMetadata( "thefile", file.length(), "theurl" );
|
||||
fileMetadata.setDeleteUrl( file.getName() );
|
||||
return fileMetadata;
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
|
@ -61,4 +69,16 @@ public class DefaultFileUploadService
|
|||
Response.Status.INTERNAL_SERVER_ERROR.getStatusCode() );
|
||||
}
|
||||
}
|
||||
|
||||
public Boolean deleteFile( String fileName )
|
||||
throws ArchivaRestServiceException
|
||||
{
|
||||
File file = new File( SystemUtils.getJavaIoTmpDir(), fileName );
|
||||
log.debug( "delete file:{},exists:{}", file.getPath(), file.exists() );
|
||||
if ( file.exists() )
|
||||
{
|
||||
return file.delete();
|
||||
}
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,8 +23,12 @@ import org.apache.archiva.webapp.ui.services.model.FileMetadata;
|
|||
import org.codehaus.plexus.redback.authorization.RedbackAuthorization;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.DELETE;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
/**
|
||||
|
@ -35,10 +39,21 @@ import javax.ws.rs.core.MediaType;
|
|||
public interface FileUploadService
|
||||
{
|
||||
|
||||
@Path( "upload" )
|
||||
//@Path( "upload" )
|
||||
@POST
|
||||
@Consumes( MediaType.MULTIPART_FORM_DATA )
|
||||
@Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
|
||||
@RedbackAuthorization( noRestriction = true )
|
||||
FileMetadata post()
|
||||
FileMetadata post( @QueryParam( "g" ) String groupId, @QueryParam( "a" ) String artifactId,
|
||||
@QueryParam( "v" ) String version, @QueryParam( "p" ) String packaging,
|
||||
@QueryParam( "c" ) String classifier, @QueryParam( "r" ) String repositoryId,
|
||||
@QueryParam( "generatePom" ) String generatePom )
|
||||
throws ArchivaRestServiceException;
|
||||
|
||||
@Path( "{fileName}" )
|
||||
@DELETE
|
||||
@Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
|
||||
@RedbackAuthorization( noRestriction = true )
|
||||
Boolean deleteFile( @PathParam( "fileName" ) String fileName )
|
||||
throws ArchivaRestServiceException;
|
||||
}
|
||||
|
|
|
@ -39,6 +39,8 @@ public class FileMetadata
|
|||
|
||||
private String deleteType;
|
||||
|
||||
private String errorKey;
|
||||
|
||||
public FileMetadata()
|
||||
{
|
||||
// no op
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" href="jquery.fileupload-ui.css"/>
|
||||
<link rel="stylesheet" href="css/jquery.fileupload-ui.css"/>
|
||||
<link rel="stylesheet" href="css/chosen-0.9.7.css"/>
|
||||
<link rel="stylesheet" href="css/jquery-ui-1.8.16.custom.css"/>
|
||||
<link rel="stylesheet" href="css/bootstrap.2.0.2.css">
|
||||
|
|
|
@ -1,23 +1,52 @@
|
|||
<script id="file-upload-tmpl" type="text/html">
|
||||
<form id="fileupload" action="restServices/archivaUiServices/fileUploadService/upload" method="POST" enctype="multipart/form-data">
|
||||
<div class="page-header">
|
||||
<h3>${$.i18n.prop('fileupload.header')}</h3>
|
||||
</div>
|
||||
<form id="fileupload" action="restServices/archivaUiServices/fileUploadService" method="POST"
|
||||
enctype="multipart/form-data" class="well form-horizontal">
|
||||
|
||||
<fieldset id="network-proxy-edit-fieldset">
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="groupId">${$.i18n.prop('fileupload.groupId')}</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="xlarge required" id="groupId" name="groupId" size="10" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="artifactId">${$.i18n.prop('fileupload.artifactId')}</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="xlarge required" id="artifactId" name="artifactId" size="10" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="artifactId">${$.i18n.prop('fileupload.version')}</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="xlarge required" id="version" name="version" size="10" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<div class="row fileupload-buttonbar">
|
||||
<div class="span7">
|
||||
<span class="btn btn-success fileinput-button">
|
||||
<i class="icon-plus icon-white"></i>
|
||||
<span>Add files...</span>
|
||||
<span>${$.i18n.prop('fileupload.file.choose')}</span>
|
||||
<input type="file" name="files[]" multiple="">
|
||||
</span>
|
||||
<button type="submit" class="btn btn-primary start">
|
||||
<i class="icon-upload icon-white"></i>
|
||||
<span>Start upload</span>
|
||||
<span>${$.i18n.prop('fileupload.start')}</span>
|
||||
</button>
|
||||
<button type="reset" class="btn btn-warning cancel">
|
||||
<i class="icon-ban-circle icon-white"></i>
|
||||
<span>Cancel upload</span>
|
||||
<span>${$.i18n.prop('fileupload.cancel')}</span>
|
||||
</button>
|
||||
<button type="button" class="btn btn-danger delete">
|
||||
<i class="icon-trash icon-white"></i>
|
||||
<span>Delete</span>
|
||||
<span>${$.i18n.prop('fileupload.delete')}</span>
|
||||
</button>
|
||||
<input type="checkbox" class="toggle">
|
||||
</div>
|
||||
|
@ -90,7 +119,8 @@
|
|||
<td colspan="2"></td>
|
||||
{% } %}
|
||||
<td class="delete">
|
||||
<button class="btn btn-danger" data-type="{%=file.deleteType%}" data-url="{%=file.deleteUrl%}">
|
||||
<button class="btn btn-danger" data-type="{%=file.deleteType%}"
|
||||
data-url="restServices/archivaUiServices/fileUploadService/{%=file.deleteUrl%}">
|
||||
<i class="icon-trash icon-white"></i>
|
||||
<span>{%=$.i18n.prop('fileupload.destroy')%}</span>
|
||||
</button>
|
||||
|
|
Loading…
Reference in New Issue