[Feature #13327] Checking upload permission before the upload starting

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/workspace-uploader@181695 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2019-09-16 10:19:31 +00:00
parent adfd7f4839
commit c1e9f1f89e
2 changed files with 11 additions and 15 deletions

View File

@ -5,6 +5,9 @@
<Change>[Task #17152] Workspace uploader: avoid . (dot) char added as
suffix when the filename does not contain an extension
</Change>
<Change>
[Feature #13327] Checking upload permission before the upload starting
</Change>
</Changeset>
<Changeset
component="org.gcube.portlets-widgets.workspace-uploader.2-0-2"

View File

@ -471,26 +471,19 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
if (!destinationItem.isFolder()) {
logger.error("Error processing request in upload servlet: The destination is not a folder");
saveWorkspaceUploaderStatus(workspaceUploader, UPLOAD_STATUS.FAILED, "An error occurred during upload: "+fileName+". The destination is not a folder", request.getSession());
sendError(response, "Internal error: Wrong destination item");
sendError(response, "Internal error: Wrong destination item. The destination is not a folder");
return;
}
final WorkspaceFolder destinationFolder = (WorkspaceFolder) destinationItem;
if(destinationFolder.isShared()) {
try {
WorkspaceItem rootSharedFolder = workspace.getRootSharedFolder(destinationFolder.getId());
//TODO RETRIEVE USERS BELONGING TO SHARE
//TODO RETRIEVE ACL
if(rootSharedFolder instanceof WorkspaceSharedFolder) {
}
} catch (Exception e) {
e.printStackTrace();
}
try {
workspace.canUserWriteIntoFolder(destinationFolder.getId());
} catch (Exception e1) {
logger.warn("The user cannot write in the destination folder with id: {}",destinationFolder.getId());
saveWorkspaceUploaderStatus(workspaceUploader, UPLOAD_STATUS.FAILED, "You are not authorized to write into folder: "+destinationFolder.getName(), request.getSession());
sendError(response, "Internal error: You are not authorized to write into folder: "+destinationFolder.getName());
return;
}