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;
import com.google.gwt.user.client.ui.HasVerticalAlignment;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.HorizontalSplitPanel;
-import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.view.client.SelectionChangeEvent;
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()) {
@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/advancedsettings.png")
ImageResource tools();
}
*/
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;
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();
}
}
}
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() {
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() {
};
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) {
public void sessionExpired() {
new SessionExpiredDialog(this).center();
- authenticateUser();
+ }
+
+ 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());
}
}