import com.google.gwt.http.client.RequestCallback;
import com.google.gwt.http.client.RequestException;
import com.google.gwt.http.client.Response;
+import com.google.gwt.http.client.URL;
import com.google.gwt.json.client.JSONArray;
import com.google.gwt.json.client.JSONObject;
import com.google.gwt.json.client.JSONParser;
* Instantiate an application-level image bundle. This object will provide
* programmatic access to all the images needed by widgets.
*/
- private static Images images = (Images) GWT.create(Images.class);
+ static Images images = (Images) GWT.create(Images.class);
public String getUsername() {
return username;
otherSharedTreeView.updateFolder(f, showfiles);
}
- public void updateTag(Tag t) {
- tagTreeView.updateTag(t);
- }
-
- public void updateTags() {
- tagTreeViewModel.initialize(getAllTags());
- }
-
public List<Tag> getAllTags() {
List<Tag> tagList = new ArrayList<Tag>();
for (Folder f : account.getContainers()) {
* An aggregate image bundle that pulls together all the images for this
* application into a single bundle.
*/
- public interface Images extends TopPanel.Images, FileList.Images {
+ public interface Images extends TopPanel.Images, FileList.Images, ToolsMenu.Images {
@Source("gr/grnet/pithos/resources/document.png")
ImageResource folders();
- @Source("gr/grnet/pithos/resources/edit_group_22.png")
- ImageResource groups();
-
- @Source("gr/grnet/pithos/resources/search.png")
- ImageResource search();
+ @Source("gr/grnet/pithos/resources/advancedsettings.png")
+ ImageResource tools();
}
/**
*/
private Object currentSelection;
-
- /**
- * The WebDAV password of the current user
- */
- private String webDAVPassword;
-
public HashMap<String, String> userFullNameMap = new HashMap<String, String>();
private String username = null;
*/
private String token;
+ VerticalPanel trees;
+
SingleSelectionModel<Folder> folderTreeSelectionModel;
FolderTreeViewModel folderTreeViewModel;
FolderTreeView folderTreeView;
SingleSelectionModel<Folder> mysharedTreeSelectionModel;
- private MysharedTreeViewModel mysharedTreeViewModel;
- MysharedTreeView mysharedTreeView;
+ MysharedTreeViewModel mysharedTreeViewModel;
+ MysharedTreeView mysharedTreeView = null;;
protected SingleSelectionModel<Folder> otherSharedTreeSelectionModel;
- private OtherSharedTreeViewModel otherSharedTreeViewModel;
- OtherSharedTreeView otherSharedTreeView;
-
- protected SingleSelectionModel<Tag> tagTreeSelectionModel;
- private TagTreeViewModel tagTreeViewModel;
- private TagTreeView tagTreeView;
+ OtherSharedTreeViewModel otherSharedTreeViewModel;
+ OtherSharedTreeView otherSharedTreeView = null;
GroupTreeViewModel groupTreeViewModel;
private GroupTreeView groupTreeView;
Folder trash;
- @SuppressWarnings("rawtypes")
- private List<SingleSelectionModel> selectionModels = new ArrayList<SingleSelectionModel>();
+ @SuppressWarnings("rawtypes") List<SingleSelectionModel> selectionModels = new ArrayList<SingleSelectionModel>();
Button upload;
private HTML totalBytes;
private HTML usedPercent;
+
+ private HTML numOfFiles;
+
+ private Button toolsButton;
@Override
public void onModuleLoad() {
rightside.addStyleName("pithos-rightSide");
rightside.setSpacing(5);
- HTML folderStatistics = new HTML("5 Files (size: 1.1GB)");
+ toolsButton = new Button(AbstractImagePrototype.create(images.tools()).getHTML());
+ toolsButton.addClickHandler(new ClickHandler() {
+
+ @Override
+ public void onClick(ClickEvent event) {
+ ToolsMenu menu = new ToolsMenu(Pithos.this, images, getSelectedTree(), getSelectedTree().getSelection(), getFileList().getSelectedFiles());
+ if (!menu.isEmpty()) {
+ menu.setPopupPosition(event.getClientX(), event.getClientY());
+ menu.show();
+ }
+ }
+ });
+ rightside.add(toolsButton);
+ rightside.setCellHorizontalAlignment(toolsButton, HasHorizontalAlignment.ALIGN_LEFT);
+
+ HorizontalPanel folderStatistics = new HorizontalPanel();
folderStatistics.addStyleName("pithos-folderStatistics");
+ numOfFiles = new HTML();
+ folderStatistics.add(numOfFiles);
+ HTML numOfFilesLabel = new HTML(" Files");
+ folderStatistics.add(numOfFilesLabel);
rightside.add(folderStatistics);
+ rightside.setCellHorizontalAlignment(folderStatistics, HasHorizontalAlignment.ALIGN_RIGHT);
+
inner.add(rightside);
- inner.setCellHorizontalAlignment(rightside, HasHorizontalAlignment.ALIGN_RIGHT);
inner.setCellVerticalAlignment(rightside, HasVerticalAlignment.ALIGN_MIDDLE);
inner.setCellHeight(rightside, "60px");
fileList = new FileList(this, images, folderTreeView);
inner.add(fileList);
- mysharedTreeSelectionModel = new SingleSelectionModel<Folder>();
- mysharedTreeSelectionModel.addSelectionChangeHandler(new Handler() {
- @Override
- public void onSelectionChange(@SuppressWarnings("unused") SelectionChangeEvent event) {
- if (mysharedTreeSelectionModel.getSelectedObject() != null) {
- deselectOthers(mysharedTreeView, mysharedTreeSelectionModel);
- upload.setEnabled(false);
- updateSharedFolder(mysharedTreeSelectionModel.getSelectedObject(), true);
- }
- }
- });
- selectionModels.add(mysharedTreeSelectionModel);
- mysharedTreeViewModel = new MysharedTreeViewModel(this, mysharedTreeSelectionModel);
- mysharedTreeView = new MysharedTreeView(mysharedTreeViewModel);
-
- otherSharedTreeSelectionModel = new SingleSelectionModel<Folder>();
- otherSharedTreeSelectionModel.addSelectionChangeHandler(new Handler() {
- @Override
- public void onSelectionChange(@SuppressWarnings("unused") SelectionChangeEvent event) {
- if (otherSharedTreeSelectionModel.getSelectedObject() != null) {
- deselectOthers(otherSharedTreeView, otherSharedTreeSelectionModel);
- applyPermissions(otherSharedTreeSelectionModel.getSelectedObject());
- updateOtherSharedFolder(otherSharedTreeSelectionModel.getSelectedObject(), true);
- }
- }
- });
- selectionModels.add(otherSharedTreeSelectionModel);
- otherSharedTreeViewModel = new OtherSharedTreeViewModel(this, otherSharedTreeSelectionModel);
- otherSharedTreeView = new OtherSharedTreeView(otherSharedTreeViewModel);
-
groupTreeViewModel = new GroupTreeViewModel(this);
groupTreeView = new GroupTreeView(groupTreeViewModel);
- VerticalPanel trees = new VerticalPanel();
+ trees = new VerticalPanel();
upload = new Button("Upload File", new ClickHandler() {
@Override
trees.add(treeHeader);
trees.add(folderTreeView);
- trees.add(mysharedTreeView);
- trees.add(otherSharedTreeView);
-// trees.add(tagTreeView);
trees.add(groupTreeView);
// Add the left and right panels to the split panel.
splitPanel.setLeftWidget(trees);
}
folderTreeViewModel.initialize(account);
groupTreeViewModel.initialize();
+ createMySharedTree();
showStatistics();
}
}
else
displayError("System error fetching file: " + t.getMessage());
}
+
+ @Override
+ protected void onUnauthorized(Response response) {
+ sessionExpired();
+ }
};
getFile.setHeader("X-Auth-Token", "0000");
Scheduler.get().scheduleDeferred(getFile);
else
displayError("System error fetching user data: " + t.getMessage());
}
+
+ @Override
+ protected void onUnauthorized(Response response) {
+ sessionExpired();
+ }
};
getAccount.setHeader("X-Auth-Token", token);
Scheduler.get().scheduleDeferred(getAccount);
else
displayError("System error fetching user data: " + t.getMessage());
}
+
+ @Override
+ protected void onUnauthorized(Response response) {
+ sessionExpired();
+ }
};
headAccount.setHeader("X-Auth-Token", token);
Scheduler.get().scheduleDeferred(headAccount);
else
displayError("System error Error creating pithos: " + t.getMessage());
}
+
+ @Override
+ protected void onUnauthorized(Response response) {
+ sessionExpired();
+ }
};
createPithos.setHeader("X-Auth-Token", getToken());
Scheduler.get().scheduleDeferred(createPithos);
else
displayError("System error Error creating pithos: " + t.getMessage());
}
+
+ @Override
+ protected void onUnauthorized(Response response) {
+ sessionExpired();
+ }
};
createPithos.setHeader("X-Auth-Token", getToken());
Scheduler.get().scheduleDeferred(createPithos);
return token;
}
- public String getWebDAVPassword() {
- return webDAVPassword;
- }
-
public static native void preventIESelection() /*-{
$doc.body.onselectstart = function () { return false; };
}-*/;
}
public void deleteFolder(final Folder folder) {
- String path = getApiPath() + folder.getOwner() + "/" + folder.getContainer() + "?format=json&delimiter=/&prefix=" + folder.getPrefix();
+ String path = getApiPath() + folder.getOwner() + "/" + folder.getContainer() + "?format=json&delimiter=/&prefix=" + URL.encodeQueryString(folder.getPrefix()) + "&t=" + System.currentTimeMillis();
RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, path);
- builder.setHeader("If-Modified-Since", "0");
builder.setHeader("X-Auth-Token", getToken());
try {
builder.sendRequest("", new RequestCallback() {
GWT.log("", t);
displayError("System error unable to delete folder: " + t.getMessage());
}
+
+ @Override
+ protected void onUnauthorized(Response response) {
+ sessionExpired();
+ }
};
delete.setHeader("X-Auth-Token", getToken());
Scheduler.get().scheduleDeferred(delete);
else if (o != null) {
String subdir = o.get("subdir").isString().stringValue();
subdir = subdir.substring(0, subdir.length() - 1);
- String path = getApiPath() + getUsername() + "/" + folder.getContainer() + "?format=json&delimiter=/&prefix=" + subdir;
+ String path = getApiPath() + getUsername() + "/" + folder.getContainer() + "?format=json&delimiter=/&prefix=" + URL.encodeQueryString(subdir) + "&t=" + System.currentTimeMillis();
RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, path);
- builder.setHeader("If-Modified-Since", "0");
builder.setHeader("X-Auth-Token", getToken());
try {
builder.sendRequest("", new RequestCallback() {
else
displayError("System error unable to delete folder: " + t.getMessage());
}
+
+ @Override
+ protected void onUnauthorized(Response response) {
+ sessionExpired();
+ }
};
deleteFolder.setHeader("X-Auth-Token", getToken());
Scheduler.get().scheduleDeferred(deleteFolder);
else
displayError("System error unable to copy file: "+t.getMessage());
}
+
+ @Override
+ protected void onUnauthorized(Response response) {
+ sessionExpired();
+ }
};
copyFile.setHeader("X-Auth-Token", getToken());
copyFile.setHeader("X-Copy-From", file.getUri());
+ if (!file.getOwner().equals(targetUsername))
+ copyFile.setHeader("X-Source-Account", file.getOwner());
Scheduler.get().scheduleDeferred(copyFile);
}
else if (callback != null) {
PutRequest createFolder = new PutRequest(getApiPath(), targetUsername, path) {
@Override
public void onSuccess(@SuppressWarnings("unused") Resource result) {
- GetRequest<Folder> getFolder = new GetRequest<Folder>(Folder.class, getApiPath(), f.getOwner(), "/" + f.getContainer() + "?format=json&delimiter=/&prefix=" + f.getPrefix(), f) {
+ GetRequest<Folder> getFolder = new GetRequest<Folder>(Folder.class, getApiPath(), f.getOwner(), "/" + f.getContainer() + "?format=json&delimiter=/&prefix=" + URL.encodeQueryString(f.getPrefix()), f) {
@Override
public void onSuccess(final Folder _f) {
else
displayError("System error getting folder: " + t.getMessage());
}
+
+ @Override
+ protected void onUnauthorized(Response response) {
+ sessionExpired();
+ }
};
getFolder.setHeader("X-Auth-Token", getToken());
Scheduler.get().scheduleDeferred(getFolder);
else
displayError("System error creating folder: " + t.getMessage());
}
+
+ @Override
+ protected void onUnauthorized(Response response) {
+ sessionExpired();
+ }
};
createFolder.setHeader("X-Auth-Token", getToken());
createFolder.setHeader("Accept", "*/*");
public Folder getSelection() {
return selectedTree.getSelection();
}
+
+ public void showFolderStatistics(int folderFileCount) {
+ numOfFiles.setHTML(String.valueOf(folderFileCount));
+ }
+
+ public GroupTreeView getGroupTreeView() {
+ return groupTreeView;
+ }
+
+ public void sessionExpired() {
+ new SessionExpiredDialog(this).center();
+ }
+
+ public void updateRootFolder(Command callback) {
+ updateFolder(account.getPithos(), false, callback);
+ }
+
+ void createMySharedTree() {
+ mysharedTreeSelectionModel = new SingleSelectionModel<Folder>();
+ mysharedTreeSelectionModel.addSelectionChangeHandler(new Handler() {
+ @Override
+ public void onSelectionChange(@SuppressWarnings("unused") SelectionChangeEvent event) {
+ if (mysharedTreeSelectionModel.getSelectedObject() != null) {
+ deselectOthers(mysharedTreeView, mysharedTreeSelectionModel);
+ upload.setEnabled(false);
+ updateSharedFolder(mysharedTreeSelectionModel.getSelectedObject(), true);
+ }
+ }
+ });
+ selectionModels.add(mysharedTreeSelectionModel);
+ mysharedTreeViewModel = new MysharedTreeViewModel(Pithos.this, mysharedTreeSelectionModel);
+ mysharedTreeViewModel.initialize(new Command() {
+
+ @Override
+ public void execute() {
+ mysharedTreeView = new MysharedTreeView(mysharedTreeViewModel);
+ trees.insert(mysharedTreeView, 3);
+ createOtherSharedTree();
+ }
+ });
+ }
+
+ void createOtherSharedTree() {
+ otherSharedTreeSelectionModel = new SingleSelectionModel<Folder>();
+ otherSharedTreeSelectionModel.addSelectionChangeHandler(new Handler() {
+ @Override
+ public void onSelectionChange(@SuppressWarnings("unused") SelectionChangeEvent event) {
+ if (otherSharedTreeSelectionModel.getSelectedObject() != null) {
+ deselectOthers(otherSharedTreeView, otherSharedTreeSelectionModel);
+ applyPermissions(otherSharedTreeSelectionModel.getSelectedObject());
+ updateOtherSharedFolder(otherSharedTreeSelectionModel.getSelectedObject(), true);
+ }
+ }
+ });
+ selectionModels.add(otherSharedTreeSelectionModel);
+ otherSharedTreeViewModel = new OtherSharedTreeViewModel(Pithos.this, otherSharedTreeSelectionModel);
+ otherSharedTreeViewModel.initialize(new Command() {
+
+ @Override
+ public void execute() {
+ otherSharedTreeView = new OtherSharedTreeView(otherSharedTreeViewModel);
+ trees.insert(otherSharedTreeView, 4);
+ }
+ });
+ }
+
+ public void logoff() {
+ Configuration conf = (Configuration) GWT.create(Configuration.class);
+ Cookies.removeCookie(conf.authCookie());
+ Cookies.removeCookie(conf.authTokenCookie(), "/");
+ for (String s: Cookies.getCookieNames())
+ if (s.startsWith(conf.shibSessionCookiePrefix()))
+ Cookies.removeCookie(s, "/");
+ Window.Location.assign(Window.Location.getPath());
+ }
}