private void createFolder() {\r
String name = folderName.getText();\r
String path = folder.getUri() + "/" + name;\r
- PutRequest createFolder = new PutRequest(app.getApiPath(), app.getUsername(), path) {\r
+ PutRequest createFolder = new PutRequest(app.getApiPath(), folder.getOwner(), path) {\r
@Override\r
public void onSuccess(@SuppressWarnings("unused") Resource result) {\r
- app.updateFolder(folder, true, null);\r
+ app.updateFolder(folder, true, new Command() {\r
+ \r
+ @Override\r
+ public void execute() {\r
+ app.updateStatistics();\r
+ }\r
+ });\r
}\r
\r
@Override\r
else\r
app.displayError("System error creating folder:" + t.getMessage());\r
}\r
- };\r
+\r
+ @Override\r
+ protected void onUnauthorized(Response response) {\r
+ app.sessionExpired();\r
+ }\r
+ };\r
createFolder.setHeader("X-Auth-Token", app.getToken());\r
createFolder.setHeader("Accept", "*/*");\r
createFolder.setHeader("Content-Length", "0");\r
final String newName = folderName.getText().trim();\r
if (!folder.isContainer() && !folder.getName().equals(newName)) {\r
final String path = folder.getParent().getUri() + "/" + newName;\r
- PutRequest newFolder = new PutRequest(app.getApiPath(), app.getUsername(), path) {\r
+ PutRequest newFolder = new PutRequest(app.getApiPath(), folder.getParent().getOwner(), path) {\r
@Override\r
public void onSuccess(@SuppressWarnings("unused") Resource result) {\r
Iterator<File> iter = folder.getFiles().iterator();\r
- app.copyFiles(iter, folder.getParent().getUri() + "/" + newName, new Command() {\r
+ app.copyFiles(iter, folder.getParent().getOwner(), folder.getParent().getUri() + "/" + newName, new Command() {\r
@Override\r
public void execute() {\r
Iterator<Folder> iterf = folder.getSubfolders().iterator();\r
- app.copySubfolders(iterf, folder.getParent().getUri() + "/" + newName, new Command() {\r
+ app.copySubfolders(iterf, folder.getParent().getOwner(), folder.getParent().getUri() + "/" + newName, new Command() {\r
@Override\r
public void execute() {\r
app.deleteFolder(folder);\r
else\r
app.displayError("System error modifying folder: " + t.getMessage());\r
}\r
+\r
+ @Override\r
+ protected void onUnauthorized(Response response) {\r
+ app.sessionExpired();\r
+ }\r
};\r
newFolder.setHeader("X-Auth-Token", app.getToken());\r
newFolder.setHeader("Content-Type", "application/folder");\r
if (t instanceof RestException) {\r
if (((RestException) t).getHttpStatusCode() == Response.SC_NOT_FOUND) { //Probably a virtual folder\r
final String path1 = folder.getUri();\r
- PutRequest newFolder = new PutRequest(app.getApiPath(), app.getUsername(), path1) {\r
+ PutRequest newFolder = new PutRequest(app.getApiPath(), folder.getOwner(), path1) {\r
@Override\r
public void onSuccess(@SuppressWarnings("unused") Resource result) {\r
updateMetadata(path, newPermissions);\r
}\r
\r
@Override\r
- public void onError(Throwable t) {\r
- GWT.log("", t);\r
- if(t instanceof RestException){\r
- app.displayError("Unable to update folder: " + ((RestException) t).getHttpStatusText());\r
+ public void onError(Throwable _t) {\r
+ GWT.log("", _t);\r
+ if(_t instanceof RestException){\r
+ app.displayError("Unable to update folder: " + ((RestException) _t).getHttpStatusText());\r
}\r
else\r
- app.displayError("System error modifying folder: " + t.getMessage());\r
+ app.displayError("System error modifying folder: " + _t.getMessage());\r
}\r
+\r
+ @Override\r
+ protected void onUnauthorized(Response response) {\r
+ app.sessionExpired();\r
+ }\r
};\r
newFolder.setHeader("X-Auth-Token", app.getToken());\r
newFolder.setHeader("Content-Type", "application/folder");\r
newFolder.setHeader("Content-Length", "0");\r
Scheduler.get().scheduleDeferred(newFolder);\r
}\r
+ else if (((RestException) t).getHttpStatusCode() == Response.SC_CONFLICT) {\r
+ app.displayError("Cannot set permissions. Probably subfolders or files already have permissions set");\r
+ }\r
+ else\r
+ app.displayError("Wrror modifying folder: " + t.getMessage());\r
}\r
else\r
app.displayError("System error modifying folder: " + t.getMessage());\r
}\r
+\r
+ @Override\r
+ protected void onUnauthorized(Response response) {\r
+ app.sessionExpired();\r
+ }\r
};\r
updateFolder.setHeader("X-Auth-Token", app.getToken());\r
String readPermHeader = "read=";\r