fix on upload archive
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/workspace-uploader@171509 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
19a6deac59
commit
471cb428a9
|
@ -32,7 +32,6 @@ import org.apache.commons.fileupload.util.Streams;
|
||||||
import org.apache.commons.io.FilenameUtils;
|
import org.apache.commons.io.FilenameUtils;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
import org.gcube.common.homelibrary.util.MimeTypeUtil;
|
|
||||||
import org.gcube.common.portal.PortalContext;
|
import org.gcube.common.portal.PortalContext;
|
||||||
import org.gcube.common.storagehub.model.items.FolderItem;
|
import org.gcube.common.storagehub.model.items.FolderItem;
|
||||||
import org.gcube.common.storagehub.model.items.Item;
|
import org.gcube.common.storagehub.model.items.Item;
|
||||||
|
@ -103,6 +102,8 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
||||||
|
|
||||||
public static final String FILE = "File";
|
public static final String FILE = "File";
|
||||||
|
|
||||||
|
public static final String ARCHIVE = "Archive";
|
||||||
|
|
||||||
// public static final String D4ST = Extensions.REPORT_TEMPLATE.getName(); //extension of Report Template type
|
// public static final String D4ST = Extensions.REPORT_TEMPLATE.getName(); //extension of Report Template type
|
||||||
// public static final String D4SR = Extensions.REPORT.getName(); //extension of Report type
|
// public static final String D4SR = Extensions.REPORT.getName(); //extension of Report type
|
||||||
|
|
||||||
|
@ -539,42 +540,33 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
||||||
|
|
||||||
String contentType = null; //It's set into HL
|
String contentType = null; //It's set into HL
|
||||||
|
|
||||||
if(uploadType.compareTo(FILE)==0) {//IS FILE UPLOAD
|
|
||||||
|
|
||||||
workspaceUploader = WorkspaceUploaderMng.uploadFile(storageHubWrapper, user, scopeGroupId, request, workspaceUploader, request.getSession(), itemName, inputStream, destinationFolder, contentType, isOverwrite, size);
|
if(uploadType.compareTo(ARCHIVE)==0){ //UPLOAD ARCHIVE
|
||||||
|
|
||||||
if(workspaceUploader==null)
|
|
||||||
throw new Exception("Error when creating uploader, it is null!");
|
|
||||||
|
|
||||||
sendMessage(response, workspaceUploader.getIdentifier());
|
|
||||||
|
|
||||||
}else {//IS ARCHIVE UPLOAD
|
|
||||||
|
|
||||||
//TODO UPLOAD ARCHIVE
|
//TODO UPLOAD ARCHIVE
|
||||||
logger.debug("Archive content type: "+uploadItem.getContentType());
|
logger.debug("Archive content type: "+uploadItem.getContentType());
|
||||||
|
|
||||||
if (MimeTypeUtil.isZipContentType(uploadItem.getContentType())){ //UNZIP??
|
|
||||||
logger.debug("Unziping content");
|
|
||||||
//THE WORKSPACE HAS BEEN INSTANCIED ABOVE
|
|
||||||
workspaceUploader = WorkspaceUploaderMng.uploadArchive(storageHubWrapper, user, scopeGroupId, workspaceUploader, request, itemName, inputStream, destinationFolder, size);
|
workspaceUploader = WorkspaceUploaderMng.uploadArchive(storageHubWrapper, user, scopeGroupId, workspaceUploader, request, itemName, inputStream, destinationFolder, size);
|
||||||
|
// if (MimeTypeUtil.isZipContentType(uploadItem.getContentType())){ //UNZIP??
|
||||||
|
// logger.debug("Unziping content");
|
||||||
|
// //THE WORKSPACE HAS BEEN INSTANCIED ABOVE
|
||||||
|
|
||||||
if(workspaceUploader==null)
|
if(workspaceUploader==null)
|
||||||
throw new Exception("Error when creating uploader, it is null!");
|
throw new Exception("Error when creating uploader, it is null!");
|
||||||
|
|
||||||
sendMessage(response, workspaceUploader.getIdentifier());
|
sendMessage(response, workspaceUploader.getIdentifier());
|
||||||
} else{
|
|
||||||
//THE WORKSPACE HAS BEEN INSTANCIED ABOVE. DEFAULT CASE IS UPLOADING A FILE
|
}else{ //UPLOAD FILE. IT IS DEFAULT CASE
|
||||||
|
//I don't need to check this if(uploadType.compareTo(FILE)==0) {//IS FILE UPLOAD
|
||||||
|
|
||||||
workspaceUploader = WorkspaceUploaderMng.uploadFile(storageHubWrapper, user, scopeGroupId, request, workspaceUploader, request.getSession(), itemName, inputStream, destinationFolder, contentType, isOverwrite, size);
|
workspaceUploader = WorkspaceUploaderMng.uploadFile(storageHubWrapper, user, scopeGroupId, request, workspaceUploader, request.getSession(), itemName, inputStream, destinationFolder, contentType, isOverwrite, size);
|
||||||
|
|
||||||
if(workspaceUploader==null)
|
if(workspaceUploader==null)
|
||||||
throw new Exception("Error when creating uploader, it is null!");
|
throw new Exception("Error when creating uploader, it is null!");
|
||||||
|
|
||||||
sendMessage(response, workspaceUploader.getIdentifier());
|
sendMessage(response, workspaceUploader.getIdentifier());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//saveWorkspaceUploaderInSession(workspaceUploader, request.getSession());
|
|
||||||
// file.delete();
|
|
||||||
} catch (InsufficientPrivilegesException e) {
|
} catch (InsufficientPrivilegesException e) {
|
||||||
logger.error("Error creating elements", e);
|
logger.error("Error creating elements", e);
|
||||||
saveWorkspaceUploaderStatus(workspaceUploader, UPLOAD_STATUS.FAILED, "An error occurred in the upload. Insufficient privileges", request.getSession());
|
saveWorkspaceUploaderStatus(workspaceUploader, UPLOAD_STATUS.FAILED, "An error occurred in the upload. Insufficient privileges", request.getSession());
|
||||||
|
|
Loading…
Reference in New Issue