[Task #7820] D&D and Browse: create new version of existing items

Updated pom version at 1.8.0

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/workspace-uploader@146379 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2017-03-28 10:36:11 +00:00
parent ca1dc03657
commit dbf5163ca1
6 changed files with 37 additions and 10 deletions

View File

@ -1,4 +1,10 @@
<ReleaseNotes>
<Changeset component="org.gcube.portlets-widgets.workspace-uploader.1-8-0"
date="2017-03-27">
<Change>[Task #7820] DaD and Browse: create new version of existing
items added</Change>
<Change>Removed currUserId parameter from client-side</Change>
</Changeset>
<Changeset component="org.gcube.portlets-widgets.workspace-uploader.1-7-0"
date="2017-02-23">
<Change>Removed currUserId parameter from client-side</Change>

View File

@ -12,7 +12,7 @@
<groupId>org.gcube.portlets.widgets</groupId>
<artifactId>workspace-uploader</artifactId>
<packaging>jar</packaging>
<version>1.7.0-SNAPSHOT</version>
<version>1.8.0-SNAPSHOT</version>
<name>Workspace Uploader Widget</name>
<description>Workspace Uploader Widget allows your application to upload file/s in the gCube Workspace</description>
<scm>

View File

@ -47,7 +47,7 @@ import com.google.gwt.user.client.ui.VerticalPanel;
*/
public class DialogUpload extends ClosableDialog implements HasWorskpaceUploadNotificationListener{
private Hidden hiddenOverwrite = new Hidden(ConstantsWorkspaceUploader.IS_OVERWRITE,"false");
private Hidden hiddenOverwrite = new Hidden(ConstantsWorkspaceUploader.IS_OVERWRITE, "true");
protected final FormPanel formPanel = new FormPanel();
protected FileUpload fileUpload;
protected Hidden jsonClientKeys;

View File

@ -653,7 +653,7 @@ public class MultipleDNDUpload extends LayoutPanel implements HasWorskpaceUpload
formdata.append("currGroupId", scopeGroupId);
//formdata.append("currUserId", currUserId);
var overwrite = false;
var overwrite = true; //default D&D overwrite the item
formdata.append("isOverwrite", overwrite);
var numFolder = 0;
@ -688,6 +688,7 @@ public class MultipleDNDUpload extends LayoutPanel implements HasWorskpaceUpload
overwrite = true;
console.log("overwrite confirmed!");
}else{
overwrite = false;
instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload::reset()();
return;
}

View File

@ -193,7 +193,7 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
String destinationId = null;
String uploadType = null;
boolean isOverwrite = false;
boolean isOverwrite = true; //CREATE A NEW VERSION OF FILE IS BEHAVIOUR BY DEFAULT
// String clientUploadKey = null;
FileItemStream uploadItem = null;
ArrayList<String> listClientUploadKeys = null;
@ -225,8 +225,13 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
}
if (item.isFormField() && IS_OVERWRITE.equals(item.getFieldName())){
isOverwrite = Boolean.parseBoolean(Streams.asString(item.openStream()));
logger.debug("IS_OVERWRITE OK "+ isOverwrite);
try{
isOverwrite = Boolean.parseBoolean(Streams.asString(item.openStream()));
logger.debug("IS_OVERWRITE OK "+ isOverwrite);
}catch(Exception e){
//Silent exception;
}
}
if(item.isFormField() && CLIENT_UPLOAD_KEYS.equals(item.getFieldName())){
@ -445,10 +450,25 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
String itemName = "";
logger.debug("getItemName from HL");
if(!isOverwrite)
if(!isOverwrite){
itemName = WorkspaceUtil.getUniqueName(fileName, destinationFolder);
else
itemName = fileName;
}
else{
logger.debug("Validating overwrite checking if file with name: "+fileName+" exists into folder ID: "+destinationFolder.getId());
boolean isReallyExisting = wa.exists(fileName, destinationFolder.getId());
logger.debug("Existing it? "+isReallyExisting);
if(isReallyExisting){
logger.info("forcing overwrite at 'true' in order to create new version of file: "+fileName);
isOverwrite = true;
itemName = fileName;
}else{
itemName = WorkspaceUtil.getUniqueName(fileName, destinationFolder);
logger.debug("File with name: "+fileName+" does not exist creating new one: "+fileName);
logger.info("forcing overwrite at 'false' in order to create the new file: "+fileName);
isOverwrite = false;
itemName = fileName;
}
}
Long size = getContentLength(request);
logger.debug("size: " + size + " bytes");

View File

@ -68,7 +68,7 @@ public class WorkspaceUploaderMng {
* @throws IOException Signals that an I/O exception has occurred.
*/
private static WorkspaceUploaderItem createWorkspaceUploaderFile(final GCubeUser currUser, final String scopeGroupId, final HttpServletRequest request, final WorkspaceUploaderItem workspaceUploader, final HttpSession httpSession, final boolean isOvewrite, final Workspace wa, final InputStream uploadFile, final String itemName, final WorkspaceFolder destinationFolder, final String contentType, final long totalBytes) throws InternalErrorException, IOException{
logger.debug("Creating WorkspaceUploaderFile...");
logger.debug("Creating WorkspaceUploaderFile... isOvewrite: " +isOvewrite);
workspaceUploader.setUploadStatus(UPLOAD_STATUS.IN_PROGRESS);
workspaceUploader.setStatusDescription("Uploading "+itemName);