implemented creating of project/company/user dir on demand
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -229,11 +229,14 @@ public class FileModule extends BaseHandler implements FileService {
|
||||
}
|
||||
|
||||
var company = companies.get(cid);
|
||||
var filename = "/company/"+cid;
|
||||
if (!path.empty()) filename += "/"+URLDecoder.decode(path.toString(),UTF_8);
|
||||
var companyDir = "/company/"+cid;
|
||||
var filename = path.empty() ? companyDir : companyDir + "/"+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);
|
||||
var file = new File(baseDir+filename);
|
||||
if (!file.exists()) throw unprocessable("{0} does not exist!",filename);
|
||||
if (!file.exists()){
|
||||
if (!filename.equals(companyDir)) throw unprocessable("{0} does not exist!",filename);
|
||||
if (!file.mkdirs()) throw unprocessable("Failed to create directory {0}!",filename);
|
||||
}
|
||||
if (file.isDirectory()){
|
||||
Map<String,Object> map = getDirectory(file);
|
||||
map.put("title",filename.replace("/company/"+cpId,company.name()));
|
||||
@@ -286,11 +289,14 @@ public class FileModule extends BaseHandler implements FileService {
|
||||
throw invalidFieldException(PROJECT_ID,"Long");
|
||||
}
|
||||
var project = projects.loadMembers(projects.load(pid));
|
||||
var filename = "/project/"+pid;
|
||||
if (!path.empty()) filename += "/"+URLDecoder.decode(path.toString(),UTF_8);
|
||||
var projectDir = "/project/"+pid;
|
||||
var filename = path.empty() ? projectDir : projectDir+"/"+URLDecoder.decode(path.toString(),UTF_8);
|
||||
if (!project.hasMember(user) && !fileDb.isPermitted(user,filename)) throw forbidden("You are not allowed to access {0}",filename);
|
||||
var file = new File(baseDir+filename);
|
||||
if (!file.exists()) throw unprocessable("{0} does not exist!",filename);
|
||||
if (!file.exists()){
|
||||
if (!filename.equals(projectDir)) throw unprocessable("{0} does not exist!",filename);
|
||||
if (!file.mkdirs()) throw unprocessable("Failed to create directory {0}!",filename);
|
||||
}
|
||||
if (file.isDirectory()){
|
||||
Map<String,Object> map = getDirectory(file);
|
||||
map.put("title",filename.replace("/project/"+prjId,project.name()));
|
||||
@@ -309,12 +315,15 @@ public class FileModule extends BaseHandler implements FileService {
|
||||
} catch (NumberFormatException e) {
|
||||
throw invalidFieldException(PROJECT_ID,"Long");
|
||||
}
|
||||
var filename = "/user/"+uid;
|
||||
var userDir = "/user/"+uid;
|
||||
var filename = path.empty() ? userDir : userDir+"/"+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);
|
||||
var file = new File(baseDir+filename);
|
||||
if (!file.exists()) throw unprocessable("{0} does not exist!",filename);
|
||||
if (file.isDirectory()){
|
||||
if (!file.exists()){
|
||||
if (!filename.equals(userDir)) throw unprocessable("{0} does not exist!",filename);
|
||||
if (!file.mkdirs()) throw unprocessable("Failed to create directory {0}!",filename);
|
||||
} if (file.isDirectory()){
|
||||
Map<String,Object> map = getDirectory(file);
|
||||
map.put("title",filename);
|
||||
map.put("delete",true);
|
||||
|
||||
Reference in New Issue
Block a user