|
|
|
@ -92,10 +92,7 @@ public class FileModule extends BaseHandler implements FileService { |
|
|
|
var filename = "/company/"+cid; |
|
|
|
var filename = "/company/"+cid; |
|
|
|
if (!path.empty()) filename += "/"+URLDecoder.decode(path.toString(),UTF_8); |
|
|
|
if (!path.empty()) filename += "/"+URLDecoder.decode(path.toString(),UTF_8); |
|
|
|
if (!companies.membership(cid,user.id()) && !fileDb.isPermitted(user,filename)) throw forbidden("You are not allowed to access {0}",filename); |
|
|
|
if (!companies.membership(cid,user.id()) && !fileDb.isPermitted(user,filename)) throw forbidden("You are not allowed to access {0}",filename); |
|
|
|
var file = new File(baseDir+filename); |
|
|
|
return deleteFile(ex, new File(baseDir+filename)); |
|
|
|
if (!file.exists()) throw unprocessable("{0} does not exist!",filename); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private boolean deleteProjectFile(Path path, HttpExchange ex, UmbrellaUser user) throws IOException { |
|
|
|
private boolean deleteProjectFile(Path path, HttpExchange ex, UmbrellaUser user) throws IOException { |
|
|
|
@ -140,7 +137,7 @@ public class FileModule extends BaseHandler implements FileService { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private boolean deleteUserFile(Path path, HttpExchange ex, UmbrellaUser user) { |
|
|
|
private boolean deleteUserFile(Path path, HttpExchange ex, UmbrellaUser user) throws IOException { |
|
|
|
var userId = path.pop(); |
|
|
|
var userId = path.pop(); |
|
|
|
if (userId == null) throw missingFieldException(USER_ID); |
|
|
|
if (userId == null) throw missingFieldException(USER_ID); |
|
|
|
long uid; |
|
|
|
long uid; |
|
|
|
@ -152,9 +149,7 @@ public class FileModule extends BaseHandler implements FileService { |
|
|
|
var filename = "/user/"+uid; |
|
|
|
var filename = "/user/"+uid; |
|
|
|
if (!path.empty()) filename += "/"+URLDecoder.decode(path.toString(),UTF_8); |
|
|
|
if (!path.empty()) filename += "/"+URLDecoder.decode(path.toString(),UTF_8); |
|
|
|
if (uid != user.id() && !fileDb.isPermitted(user,filename)) throw forbidden("You are not allowed to access {0}",filename); |
|
|
|
if (uid != user.id() && !fileDb.isPermitted(user,filename)) throw forbidden("You are not allowed to access {0}",filename); |
|
|
|
var file = new File(baseDir+filename); |
|
|
|
return deleteFile(ex, new File(baseDir+filename)); |
|
|
|
if (!file.exists()) throw unprocessable("{0} does not exist!",filename); |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
|